触发和动作脚本

此页面列出全部火卫一引入的AI脚本与触发相关的逻辑。

Bugfixes and Miscellanous

  • 脚本动作移动到单元格现在遵循YR的单元格计算规则,使用1000 * Y + X,而非遗留自RA1的128 * Y + X

  • 路径点的范围由[0,701]扩展到[0, 2147483647]。

  • 地图触发动作125 将建筑建造于...现在可以设置是否播放建造动画(需要下述设置)。

  • 全局变量与局部变量现在都是无限数量的了。

  • 脚本动作部署现在会使DeploysInto载具自动搜寻空地,而非卡死在原处。

Script Actions

10000-10999 Ingame Actions

10000-10049 Attack Actions

  • These actions instruct the TeamType to use the TaskForce to approach and attack the target specified by the second parameter which is an index of a generic pre-defined group. Look at the tables below for the possible actions (first parameter value) and arguments (the second parameter value).

  • 基于威胁度的攻击行为会参考 rulesmd.iniTargetSpecialThreatCoefficientDefaultEnemyHouseThreatBonus 标签。

  • All aircraft that attack other air units will end the script. This behavior is intentional because without it aircraft had some bugs that weren’t fixable at the time of developing the feature.

  • AITargetTypes actions instruct the TeamType to use the TaskForce to approach and attack the target specified by the second parameter which is an index of a modder-defined group from AITargetTypess. Look at the tables below for the possible actions (first parameter value) and arguments (the second parameter value).

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=i,n             ; For i values check the next table

行为

参数

重复

目标优先级

描述

10000

目标类型#

更近

10001

目标类型#

更近

当一个小队成员摧毁给定目标时结束

10002

AITargetTypes 序号#

更近

10003

AITargetTypes 序号#

更近

当一个小队成员摧毁给定目标时结束

10004

AITargetTypes 序号#

更近

从列表中随机选择一个目标

10005

目标类型#

更远

10006

目标类型#

更远

当一个小队成员摧毁给定目标时结束

10007

AITargetTypes 序号#

更远

10008

AITargetTypes 序号#

更远

当一个小队成员摧毁给定目标时结束

10009

AITargetTypes 序号#

更远

从列表中随机选择一个目标

10010

目标类型#

更近时更高威胁

10011

目标类型#

更近时更高威胁

当一个小队成员摧毁给定目标时结束

10012

AITargetTypes 序号#

更近时更高威胁

10013

AITargetTypes 序号#

更近时更高威胁

当一个小队成员摧毁给定目标时结束

10014

目标类型#

更远时更高威胁

10015

目标类型#

更远时更高威胁

当一个小队成员摧毁给定目标时结束

10016

AITargetTypes 序号#

更远时更高威胁

10017

AITargetTypes 序号#

更远时更高威胁

当一个小队成员摧毁给定目标时结束

  • 下列值是可被用于新攻击脚本行为的第二参数的目标类型#

目标类型

描述

1

任意目标

任意敌方 VehicleTypes, AircraftTypes, InfantryTypesBuildingTypes

2

建筑

任何不含 Artillary=yes, TickTank=yes, ICBMLauncher=yesSensorArray=yes 的敌方 BuildingTypes

3

矿车

任何含有 Harvester=yesResourceGatherer=yes 的敌方 VehicleTypes, 以及含有 ResourceGatherer=yes 的敌方 BuildingTypes

4

步兵

任意敌方 InfantryTypes

5

载具

任何含有 Artillary=yes, TickTank=yes, ICBMLauncher=yesSensorArray=yesVehicleTypes, AircraftTypes, BuildingTypes

6

工厂

任何含有Factory=设定的敌方 BuildingTypes

7

防御建筑

任何含有 IsBaseDefense=yes 的敌方 BuildingTypes

8

所属方威胁

任何将小队所属方的任何单位作为目标的敌方对象,或者任何接近小队队长的敌人

9

发电厂

任何含有正数值 Power= 的敌方 BuildingTypes

10

驻扎建筑

任何被步兵驻扎的 BuildingTypes

11

科技建筑

任何含有 Unsellable=yes, Capturable=yes, 负数值 TechLevel= 或出现在 [AI]>NeutralTechBuildings= 列表上的 BuildingTypes

12

矿石精炼厂

任何含有Refinery=yes or ResourceGatherer=yes 的敌方 BuildingTypes 及含有 ResourceGatherer=yesHarvester=no 的敌方 VehicleTypes (如奴隶矿厂)

13

心灵控制者

任何拥有带 MindControl=yes 弹头的武器的 VehicleTypes, AircraftTypes, InfantryTypesBuildingTypes

14

空中单位

任意敌方的 AircraftTypes 及飞行的 VehicleTypesInfantryTypes

15

海上目标

任何含有 Naval=yes 的敌方 BuildingTypes and VehicleTypes, 以及在水面单元格上的敌方 VehicleTypes, AircraftTypes, InfantryTypes

16

干扰者

任何含有正数值 InhibitorRange=, RadarJamRadius=CloakGenerator=yesGapGenerator=yes的敌方对象

17

地面载具

任何不含 Naval=yes 的敌方 VehicleTypes, 着陆的 AircraftTypes 及由载具部署而来的 BuildingTypes

18

经济单位

任何含有 Harvester=yes or ResourceGatherer=yes 的敌方 VehicleTypes, 及含有 Refinery=yes, ResourceGatherer=yesOrePurifier=yes 的敌方 BuildingTypes

19

兵营

任何含有 Factory=InfantryType 的敌方 BuildingTypes

20

战车工厂

任何含有 Naval=noFactory=UnitType 的敌方 `BuildingTypes

21

机场

任何含有 Factory=AircraftType 的敌方 `BuildingTypes

22

雷达

任何含有 Radar=yes or SpySat=yes 的敌方 BuildingTypes

23

科技实验室

任何在 [AI]>BuildTech= 列表上的敌方 BuildingTypes

24

船坞

任何含有 Naval=yesFactory=UnitType 的敌方 `BuildingTypes

25

超级武器

任何含有 SuperWeapon=, SuperWeapon2=SuperWeapons= 的敌方 BuildingTypes

26

建造厂

任何含有 ConstructionYard=yesFactory=BuildingType 的敌方 BuildingTypes

27

中立

任意中立对象 (Civilian)

28

发生器

任何含有 CloakGenerator=yesGapGenerator=yes 的敌方 BuildingTypes

29

雷达干扰器

任何含有正数值 RadarJamRadius= 的敌方 BuildingTypes

30

屏蔽器

任何含有正数值 InhibitorRange= 的敌方 BuildingTypes

31

海军单位

任何含有 Naval=yes 的 敌方 VehicleTypes, 或在水面单元格上的敌方 VehicleTypes, AircraftTypes, InfantryTypes

32

机动单位

任意 VehicleTypes, AircraftTypes and InfantryTypes

33

可占领目标

任何含有 Capturable=yes 或同时有 BridgeRepairHut=yesRepairable=yesBuildingTypes

34

区域威胁

任何处于小队队长的警戒范围内的敌方对象

35

战车工厂与海军船坞

任何含有 Factory=UnitType 的敌方 `BuildingTypes

36

非防御建筑

任何含有 IsBaseDefense=no 的敌方 BuildingTypes

  • The second parameter with a 0-based index for the AITargetTypes section specifies the list of possible VehicleTypes, AircraftTypes, InfantryTypes and BuildingTypes that can be evaluated.

  • The AITargetTypes index# values are obtained in the new AITargetTypes section that must be declared in rulesmd.ini:

rulesmd.ini中:

[AITargetTypes]  ; List of TechnoType lists
0=SOMETECHNOTYPE,SOMEOTHERTECHNOTYPE,SAMPLETECHNOTYPE
1=ANOTHERTECHNOTYPE,YETANOTHERTECHNOTYPE
; ...

10050-10099 Move Team to Techno Location actions

  • These actions instructs the TeamType to use the TaskForce to approach the target specified by the second parameter. Look at the tables below for the possible actions (first parameter value).

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=i,n             ; For i values check the next table

行为

参数

Target Owner

目标优先级

描述

10050

目标类型#

敌方

更近时更高威胁

10051

AITargetTypes 序号#

敌方

更近时更高威胁

10052

AITargetTypes 序号#

敌方

更近

从被选中的列表中随机选择一个目标

10053

目标类型#

友方

更近

10054

AITargetTypes 序号#

友方

更近

10055

AITargetTypes 序号#

友方

更近

从被选中的列表中随机选择一个目标

10056

目标类型#

敌方

更远时更高威胁

10057

AITargetTypes 序号#

敌方

更远时更高威胁

10058

AITargetTypes 序号#

敌方

更远

从被选中的列表中随机选择一个目标

10059

目标类型#

友方

更远

10060

AITargetTypes 序号#

友方

更远

10061

AITargetTypes 序号#

友方

更远

从被选中的列表中随机选择一个目标

10000-10049 General Purpose

10100 Timed Area Guard
  • Puts the TaskForce into Area Guard mode for the given units of time. Unlike the original timed Guard script action (5,n) that just stays in place doing a basic guard operation this action has a more active role attacking nearby invaders or defending units that needs protection.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=10100,n            ; integer, time in ingame seconds
10101 Wait Until Ammo is Full
  • 当小队内所有成员弹药满时继续执行下一个动作。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=10101,0
10102 Regroup Temporarily Around the Team Leader
  • Puts the TaskForce into Area Guard mode for the given amount of time around the Team Leader (this unit remains almost immobile until the action ends). The default radius around the leader is [General] > CloseEnough and the units will not leave that area.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=10102,n
10103 Load onto Transports
  • If the TaskForce contains unit(s) that can be carried by the transports of the same TaskForce then this action will make the units enter the transports. In single player missions the next action must be “Wait until fully loaded” (43,0) or the script will not continue.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=10103,0

12000-12999 Suplementary/Setup Pre-actions

12000 Wait if No Target Found

  • When executed before a new Attack ScriptType actions like Generic Target Type Attack actions and AITargetTypes Attack actions the TeamType will remember that must wait 1 second if no target was selected. The second parameter is a positive value that specifies how much retries the Attack will do when no target was found before new Attack ScriptType Action is discarded & the script execution jumps to the next line. The value 0 means infinite retries.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=12000,n            ; integer n=0

12001 Modify Target Distance

  • By default Moving Team to techno location actions ends when the Team Leader reaches a distance declared in rulesmd.ini called CloseEnough. When this action is executed before the actions Moving Team to techno location overwrites CloseEnough value. This action works only the first time and CloseEnough will be used again the next Movement action.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=12001,n

12002 Set Move Action End Mode

  • Sets how the Movement actions ends and jumps to the next line. This action works only the first time and CloseEnough will be used again the next Movement action.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=12002,n
  • 可选参数为:

参数

动作结束当…

0

小队队长抵达最小距离

1

一个单位抵达最小距离

2

所有成员抵达最小距离

14000-14999 Utility Actions

14000 Team’s Trigger Weight Reward

  • When executed before a new Attack ScriptType actions like Generic Target Type Attack actions and AITargetTypes Attack actions the TeamType will remember that must be rewarded increasing the current weight of the AI Trigger when the TeamType Target was killed by any of the Team members. The current weight will never surprass the minimum weight and maximum weight limits of the AI Trigger. The second parameter is a positive value.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=14000,n         ; integer n=0

14001 Increase AI Trigger Current Weight

  • When executed this increases the current weight of the AI Trigger. The current weight will never surprass the minimum weight and maximum weight limits of the AI Trigger. Take note that all TeamTypes of the same AI Trigger will update the AI Trigger Current Weight sooner or later. The second parameter is a positive value. Take note that the original game only uses the first of the two Teams for calculating the AI Trigger Current weight at the end of the Trigger life, this action ignores if the Team is the first or the second of the AI Trigger and the Current weight is calculated when is executed the action.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=14001,n

14002 Decrease AI Trigger Current Weight

  • When executed this decreases the current weight of the AI Trigger. Details same as above.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=14002,n

14003 Unregister Team Success

  • 就是49,0的反向版本。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=14003,0

16000-16999 Flow Control

16000 Start a Timed Jump to the Same Line

  • When the timer ends the current script action ends and start again the same script action. The timer jump repeats again (infinite loop) until is stopped with action 16002 or the team is destroyed.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=16000,n           ; integer n=0, in ingame seconds

16001 Start a Timed Jump to the Next Line

  • 当此脚本动作的计时器结束时,开始下一行。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=16001,n           ; integer n=0, in ingame seconds

16002 Stop the Timed Jumps

  • 如果定时跳转已经激活,那么停止。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=16002,0

16003 Randomly Skip Next Action

  • 执行此动作时会挑选一个1-100之间的随机数,如果此数值小于等于第二个参数,则跳过下一个动作。第二个参数为0时,下一个脚本一定会执行;为100时,下一个脚本一定不会执行。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=16003,n           ; where 0 > n <= 100

16004 Pick a Random Script

  • When executed this action picks a random Script Type and replaces the current script by the new picked one. The second parameter is a 0-based index from the new section AIScriptsList explained below.

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=16004,n

第二个参数是基于0的AIScriptsList中的索引,指定了可用的ScriptTypes列表。要使本脚本正常工作,需要在rulesmd.ini中声明[AIScriptsList]。

rulesmd.ini中:

[AIScriptsList]  ; List of ScriptType lists
0=SOMESCRIPTTYPE,SOMEOTHERSCRIPTTYPE,SAMPLESCRIPTTYPE
1=ANOTHERSCRIPTTYPE,YETANOTHERSCRIPTTYPE
; ...

18000-18999 Variable Manipulation

18000-18023 Edit Variable

  • 计算一个变量的值

  • 由于某些原因,变量的类型是int16而不是像触发动作中那样是int32,意味着值域范围为[-32768,32767]。

  • 超过此范围可能会引起预期外的效果。

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=i,n             ; where 18000 <= i <= 18023, n is made up of two parts, the low 16 bits is being used to store the variable index, the high 16 bits is being used for storing the param value.

18024 - 18047 Edit Variable using Local Variable

  • Operate a variable’s value using a local variable’s value

  • Similar to 18000-18023, but the number to operate the value is being read from a local variable

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=i,n             ; where 18024 <= i <= 18047, n is made up of two parts, the low 16 bits is being used to store the variable index, the high 16 bits is being used for storing the local variable index.

18000 - 18071 Edit Variable using Global Variable

  • Operate a variable’s value using a global variable’s value

  • Similar to 18000-18023, but the number to operate the value is being read from a global variable

aimd.ini中:

[SOMESCRIPTTYPE]  ; ScriptType
x=i,n             ; where 18048 <= i <= 18071, n is made up of two parts, the low 16 bits is being used to store the variable index, the high 16 bits is being used for storing the global variable index.

19000-19999 Miscellanous/Uncategorized

This category is empty for now.

Trigger Actions

500 保存游戏

  • 立刻存档(仅单人游戏)。

  • 以下原版CSF被使用:TXT_SAVING_GAMETXT_GAME_WAS_SAVEDTXT_ERROR_SAVING_GAME

  • 存档名将会是地图名 - CSF

  • 例如:盟军战役25: 僵僵の钱 - 钱全被偷光了!

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],500,4,[CSFKey],0,0,0,0,A,[ActionX]
...

501 编辑变量

  • 计算一个变量的值

  • 变量类型为int32,即值域范围为[-2147483648,2147483647]。

  • 超过此范围可能会引起预期外的效果。

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],501,0,[VariableIndex],[Operation],[Number],[IsGlobalVariable],0,A,[ActionX]
...

操作数

描述

0

当前值=数字

1

当前值=当前值+数字

2

当前值=当前值-数字

3

当前值=当前值*数字

4

当前值=当前值/数字

5

当前值=当前值%数字

6

当前值=当前值<<数字

7

当前值=当前值>>数字

8

当前值=~当前值

9

当前值=当前值⊕数字

10

当前值=当前值|数字

11

当前值=当前值&数字

502 生成随机数

  • 在[Min, Max]之间生成一个随机数,存储在给定的变量中。

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],502,0,[VariableIndex],[Min],[Max],[IsGlobalVariable],0,A,[ActionX]
...

504 变量间计算

  • 将两个变量的值进行计算

  • 类似501,但计算数由另一个变量中读取

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],504,0,[VariableIndex],[Operation],[VariableForOperationIndex],[IsGlobalVariable],[IsOperationGlobalVariable],A,[ActionX]
...

操作数请查阅501号动作

505 在特定地点发射超级武器

  • 将超级武器发射到指定地点。

  • 所属方索引可以有以下值:

所属方索引

描述

>= 0

地图上的此所属方

4475-4482

类似0-7

-1

随机挑选非中立所属

-2

第一个中立所属方

-3

随机人类玩家

  • 坐标的X和Y可以取正数或-1,-1代表在可视区域内随机。

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],505,0,0,[SuperWeaponTypesIndex],[HouseIndex],[CoordinateX],[CoordinateY],A,[ActionX]
...

506 在特定路径点发射超级武器

  • 将超级武器发射到指定路径点。

mycampaign.map中:

[Actions]
...
ID=ActionCount,[Action1],506,0,0,[SuperWeaponTypesIndex],[HouseIndex],[WaypointIndex],0,A,[ActionX]
...

触发事件

500-511 变量比较

  • 将变量与给定的数字相比。

mycampaign.map中:

[Events]
...
ID=EventCount,[Event1],[EVENTID],2,[VariableIndex],[Param],[EventX]
...

事件ID

描述

全局

500

当前值>数字

501

当前值<数字

502

当前值=数字

503

当前值>=数字

504

当前值<=数字

505

当前值&数字

506

当前值>数字

507

当前值<数字

508

当前值=数字

509

当前值>=数字

510

当前值<=数字

511

当前值&数字

512-523 变量与局部变量比较

  • 将变量值与给定的局部变量值进行比较。

mycampaign.map中:

[Events]
...
ID=EventCount,[Event1],[EVENTID],2,[VariableIndex],[LocalVariableIndex],[EventX]
...

事件ID

描述

全局

512

当前值>局部变量值

513

当前值<局部变量值

514

当前值=局部变量值

515

当前值>=局部变量值

516

当前值<=局部变量值

517

当前值&局部变量值

518

当前值>局部变量值

519

当前值<局部变量值

520

当前值=局部变量值

521

当前值>=局部变量值

522

当前值<=局部变量值

523

当前值&局部变量值

524-535 变量与全局变量比较

  • 将变量值与给定的全局变量值进行比较。

mycampaign.map中:

[Events]
...
ID=EventCount,[Event1],[EVENTID],2,[VariableIndex],[GlobalVariableIndex],[EventX]
...

事件ID

描述

全局

524

当前值>全局变量值

525

当前值<全局变量值

526

当前值=全局变量值

527

当前值>=全局变量值

528

当前值<=全局变量值

529

当前值&全局变量值

530

当前值>全局变量值

531

当前值<全局变量值

532

当前值=全局变量值

533

当前值>=全局变量值

534

当前值<=全局变量值

535

当前值&全局变量值

600 The shield of the attached object is broken

mycampaign.map中:

[Events]
...
ID=EventCount,...,600,2,0,0,...
...