홈 › 모딩 정보 › 스크립트 확장
13장

스크립트 확장

프로필이 모드의 유닛 스크립트에 줄 수 있는 값(유닛의 처치 수, 소유자의 동맹 등)과 COB 스크립트가 각 값을 읽는 방법.

프로필이 모드의 유닛 스크립트에 줄 수 있는 값 8개입니다. 모드는 프로필에서 확장을 마운트하고, COB 스크립트는 다른 값과 똑같이 그 값을 읽습니다. 각 제목을 누르면 확장 페이지가 열리며, 스크립트가 값을 읽는 방법이 나와 있습니다.

모든 확장

Allied With a Unit's Ownerunit.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 Unitunit.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 Machineunit.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 100unit.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 Idunit.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 Idunit.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 Idunit.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 Unitunit.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와 같은 값을 돌려주며, 대개 0입니다.