第 13 章
脚本扩展
配置文件可提供给模组单位脚本的值,例如单位的击杀数或其所有者的同盟关系,以及 COB 脚本如何读取每一项。
配置文件可提供给模组单位脚本的 8 个值。模组在其配置文件中挂载扩展;COB 脚本随后像读取其他值一样读取它。每个标题都会打开该扩展的页面,展示脚本如何读取它。
全部扩展
Allied With a Unit's Owner
unit.allied-withAlliance here is one-way, as each player sets it in the game's alliance menu: the answer is 1 as soon as the calling unit's player has allied the other player, whether or not the other player has allied back.Build Percent Left of a Unit
unit.build-percent-left-ofIn 3.1c, get 73 reads 0, as get does at every index outside 1 to 20. Without a profile that mounts the extension at the index, this engine reads 0 there too.Unit Played on This Machine
unit.is-localThe answer differs from machine to machine on purpose. In a multiplayer game each machine answers 1 only for its own players. In a game against computer players on one machine, every player is played on this machine, so every unit answers 1.Kill Count Times 100
unit.kills-x100The value is a count, not a veterancy level: a unit with 3 kills reads 300, whatever level those kills give under veterancy.model.Highest Unit Id
unit.max-idThe unit table holds ten ranges of ids after id 0, one for each of the ten player places, whether or not ten players are playing: with a unit limit of L units per player, each range holds L ids and the last ends at 10L. unit.min-id says which range is whose. In a skirmish or a multiplayer game, the limit the game records is the one it plays at (in a multiplayer game, the one the host chose), so the value is 10L, the last id of the table, and every machine reads the same.Lowest Unit Id
unit.min-idA unit id names a place in the game's unit table. With a unit limit of L units per player, the table holds ten ranges of L ids after id 0, one for each of the ten player places, and each player's units take their ids from its own range. Which range is whose depends on the kind of game:Own Unit Id
unit.my-idA script needs its own id to ask the extensions that read a unit by id about itself, such as unit.owner-of for its own player or unit.is-local for whether this machine plays it, and to leave itself out of a walk over every unit id.Owner of a Unit
unit.owner-ofEach player's units take their ids from a range of their own (see unit.min-id for which range is whose), so the answer for an id is the player whose range holds it. Under the default exact fidelity that is also the answer for an id that holds no unit at the moment; under safe fidelity such an id reads 0.挂载扩展
配置文件在 script-extensions 下列出其脚本读取的扩展。引擎会拒绝列出未实现扩展的模组,这样玩家永远不会遇到无声的脚本错误。
script-extensions: unit.kills-x100: true # 脚本读取 get UNIT_KILLS_X100 unit.allied-with: true
保真:脚本读取未挂载的扩展时,其返回与 3.1c 相同,通常为零。