- UID
- 37087
- 阅读权限
- 255
- 注册时间
- 2009-8-27
- 最后登录
- 2024-10-25
- 在线时间
- 5598 小时
教皇
帝國榮譽元帥
- 耕战
- 64323
- 鹰币
- 97876
- 天龙币
- 0
- 回帖
- 200
|
本帖最后由 孟雨亲王 于 2015-4-2 17:02 编辑
Age of Empires Script Reference
帝国时代脚本参考
翻译:孟雨亲王(道禪無)
翔鹰帝国论坛 荣誉出品
https://steamcommunity.com/app/221380/discussions/0/684839199943495537/
Summary 概述
Hi everyone, I'm writing here to document the various script support we have added to Age of Empires. Most of these scripts emulate features found in UserPatch. The Forgotten was based on UserPatch, so we supported the features necessary to support the campaigns and Improved Standard AI. The AI's can efficiently hunt boars improving their castle booms.
None of us know who User Patch is and he (or she) was not involved in development of this expansion. However, props out to whoever this person is and making our job easier to reverse engineering using UserPatch Reference[userpatch.aiscripters.net]. It was a unique challenge because we had to try and figure out what UserPatch actually did and emulate similar behavior by working with Bert, Tom, and Archon. The boar hunting support was particularly challenging to get right.
General Changes (both AoK and AoF) 一般改变
• Updated the number of timers from 10 to 50
• 计时器数量从10更新至50
• Updated the number of allowed facts from 1000 to 10000
• 允许的事实数量从1000更新至10000
• Updated the number of goals from 50 to 512.
• 目标的数量从50更新至512
• sn-task-ungrouped-soldiers now defaults to 0.
• sn-task-ungrouped-soldiers现预设为0
• dropsite-min-distance now supports additional dropsite-types: hunting, boar-hunting, deer-hunting, and live-boar.
• dropsite-min-distance现支援额外的dropsite-types:hunting,boar-hunting,deer-hunting,和 live-boar
New Random Map Script Commands (*.rms2) 新随机地图脚本命令
These commands are only available in *.rms2 files which can only be used while AoF is enabled.
这些命令只在*.rms2文件中可用且*.rms2文件只能在AoF启用时使用。
ai_map_info_type
ai_map_info_type inConstMapName inConstIsNomad inConstIsMichi inConstExtraStyle
You can set the map type and additional AI information. There are several new map types defined for AoF.
您可设置地图类型和额外的人工智能信息。AoF定义了几个新的地图类型。
Examples for ai_info_map_type:
示例:
1. #load-if-defined COASTAL-MAP will be true for AIs.
COASTAL-MAP将对人工智能为真
- <PLAYER_SETUP>
- random_placement
- ai_info_map_type COASTAL 0 0 0
复制代码
2. #load-if-defined MONGOLIA-MAP and UP-NOMAD-STYLE will be true for AIs.
MONGOLIA-MAP 和 UP-NOMAD-STYLE将对人工智能为真
- <PLAYER_SETUP>
- random_placement
- ai_info_map_type MONGOLIA 1 0 0
复制代码
3. #load-if-defined BLACK-FOREST-MAP and UP-MICHI-STYLE will be true for AIs.
BLACK-FOREST-MAP 和 UP-MICHI-STYLE将对人工智能为真
- <PLAYER_SETUP>
- random_placement
- ai_info_map_type BLACK_FOREST 0 1 0
复制代码
The last parameter will define UP-EXTRA-STYLE if someone out there is feeling particularly creative and wants to link an RMS2 with a new AI2/PER2.
最后一个参量将定义UP-EXTRA-STYLE,若您感觉特别的创造性并想要将一个RMS2与一个新的AI2/PER2关联。
New valid map types are (Forgotten Only):
新的有效地图类型有:(仅AoF)
- ACROPOLIS-MAP
- BUDAPEST-MAP
- CENOTES-MAP
- CITYOFLAKES-MAP
- GOLDENPIT-MAP
- HIDEOUT-MAP
- HILLFORT-MAP
- LOMBARDIA-MAP
- STEPPE-MAP
- VALLEY-MAP
- MEGARANDOM-MAP
- HAMBURGER-MAP
复制代码
base_elevation:
base_elevation: inConstElevation
• Modify the base elevation for player and standard lands. <ELEVATION_GENERATION> must exist if used.
• 修正玩家和标准地区的基础海拔。如果使用,则<ELEVATION_GENERATION>必须存在。
• Section: LAND_GENERATION :: create_player_lands, create_land
Examples for base_elevation
示例
1. Create a palm desert land with elevation 2.
创建一片高地2的棕榈沙漠地区
- <LAND_GENERATION>
- create_land
- {
- terrain_type PALM_DESERT
- number_of_tiles 128
- base_elevation 2
- }
- <ELEVATION_GENERATION>
复制代码
grouped_by_team:
• Position team members in close proximity on the map. This command and "random_placement" are mutually exclusive. The "base_size" specified in "create_player_lands" determines the distance between players on a team. When enabled, the UP-GROUPED-BY-TEAM #load symbol will be defined for AIs.
• 在地图上紧密临近放置组队成员。此命令和 “random_placement”互相排斥。“create_player_lands”指定的“base_size”决定了一个组队的玩家之间的距离当启用时,UP-GROUPED-BY-TEAM装载标识将为人工智能定义。
• Section: PLAYER_SETUP
Examples for grouped_by_team
示例
1. Enable the team positioning system for player lands.
为玩家地区启用组队位置系统
- <PLAYER_SETUP>
- grouped_by_team /*replaces random_placement*/
复制代码
nomad_resources:
• Modify starting resources to match the built-in nomad map. This means that the cost of a town center (275W, 100S) is added to the stockpile. When enabled, the UP-NOMAD-RESOURCES #load symbol will be defined for AIs.
• 修正起始资源以匹配内置的游牧地图。这意味着一个市镇中心的花费(275木材,100石材)将增至资源储备。当启用时,UP-NOMAD-RESOURCES装载标识将为人工智能定义。
• Section: PLAYER_SETUP
Examples for nomad_resources
示例
1. Set starting resources like nomad with +275W, +100S.
设置起始资源类似游牧+275木材,+100石材
- <PLAYER_SETUP>
- random_placement
- nomad_resources
复制代码
New AI Script Commands (*.per2) 新人工智能脚本命令
These commands are only available in *.per2 files which can only be used while AoF is enabled.
这些命令只在*.per2文件中可用且*.per2文件只能在AoF启用时使用。
up-retask-gatherers:
(up-retask-gatherers inConstResource typeOp inOpValue)
• Retask a specific number of villagers gathering from a resource.
• 再指派指定数量的村民采集一种资源。
Examples for up-retask-gatherers
示例
1. Request up to 3 lumberjacks to attempt to retask.
要求至多3名伐木工尝试再指派
- (defrule
- (true)
- =>
- (up-retask-gatherers wood c: 3)
- (disable-self))
复制代码
boar-food is a new valid type for up-retask-gatherers.
boar-food是up-retask-gatherers的一个新的有效类型
up-request-hunters:
(up-request-hunters typeOp inOpValue)
• Attempt to request support hunters for the active boar lure. This is not guaranteed to reach the total.
• 尝试要求猎人支援活跃的野猪引诱。这不保证能达到总数。
Examples for up-request-hunters
示例
1. Request a total of 4 hunters to support the current lure.
要求总数为4的猎人支援当前引诱。
- (defrule
- (true)
- =>
- (up-request-hunters c: 4)
- (disable-self))
复制代码
up-jump-rule:
(up-jump-rule inConstRuleDelta)
• Jump forward or backward within the current rule set. Never use this command where #load blocks may make your jump target unreliable. Please ensure that the rule you are jumping to actually exists. With this action, you can either decrease rules per pass with intelligent skips, or greatly increase it with loops. Please consider game performance.
• 向前或向后跳过当前的规则集合。不要在#load块可能使您的跳跃目标不可靠的位置使用此命令。请确保您将要跳跃至的规则实际存在。通过此动作,您可或者通过智能的跳跃每通过一次减少规则,或者通过循环极大地增加之。请考虑游戏性能。
Examples for up-jump-rule
示例
1. Skip 1 rule if a condition is true.
若条件为真跳过1条规则。
- (defrule
- (true)
- =>
- (up-jump-rule 1)
- )
- (defrule ; this rule is skipped
- (true)
- =>
- (do-nothing))
复制代码
2. Loop over a rule 3 times.
3次循环1条规则
- (defconst gl-value 100)
- (defrule
- (true)
- =>
- (chat-local-to-self "Start")
- (set-goal gl-value 0)
- )
- (defrule
- (up-compare-goal gl-value < 3)
- =>
- (up-modify-goal gl-value c:+ 1)
- (up-jump-rule -1))
复制代码
up-get-threat-data:
(up-get-threat-data outGoalElapsedTime outGoalPlayerId outGoalSourceClass outGoalTargetClass)
• Get the elapsed time, player, source, and target of the last threat.
• 获取运行的时间,玩家,资源,和上次威胁的目标。
Examples for up-get-threat-data
示例
1. Store the latest threat information from anywhere on the map.
存储地图上任何位置的最新的威胁信息。
- (defconst gl-threat-time 101)
- (defconst gl-threat-player 102)
- (defconst gl-threat-source 103)
- (defconst gl-threat-target 104)
- (defrule
- (true)
- =>
- (up-get-threat-data gl-threat-time gl-threat-player gl-threat-source gl-threat-target))
复制代码
up-chat-data-to-all:
(up-chat-data-to-all inTextFormat typeOp inOpValue)
• Send a chat message with a formatted value to everyone.
• 以格式化的值向所有人发送一条聊天信息。
Examples for up-chat-data-to-all
示例
1. Tell everyone what your player number is.
告诉所有人您的玩家编号。
- (defrule
- (true)
- =>
- (up-chat-data-to-all "I am player %d." c: my-player-number)
- (disable-self))
复制代码
up-chat-data-to-player:
(up-chat-data-to-player inPlayerAny inTextFormat typeOp inOpValue)
• Send a chat message with a formatted value to a player.
• 以格式化的值向一名玩家发送一条聊天信息。
Examples for up-chat-data-to-player
示例
1. Tell every ally know who the current target player is.
告诉所有盟友当前目标玩家是谁。
- (defrule
- (true)
- =>
- (up-chat-data-to-player every-ally "The target is player %d." s: sn-target-player-number)
- (disable-self))
复制代码
up-chat-data-to-self:
(up-chat-data-to-self inTextFormat typeOp inOpValue)
• Send a chat message with a formatted value locally.
• 以格式化的值向本地发送一条聊天信息。
Examples for up-chat-data-to-self
示例
1. Chat "Food: 5." to self.
向自己聊天“Food: 5.”
- (defrule
- (true)
- =>
- (up-chat-data-to-self "Food: %d." c: 5)
- (disable-self))
复制代码
chat-debug:
Special Note: This can be used in AoK and AoF
特别注意:此功能可用于AoK和AoF
This is a chat-to-all command that also logs itself to a chat-debug.txt file found in the Logs folder (inside another folder matching your timestamp when you started the game). I found this particularly useful for debugging AI, as I could play a full game then look at the log to see whatever I was interested in.
这是一个将自己记录到存储于Logs文件夹(在其中的与您启动游戏的时间印章匹配的另一个文件夹内)的chat-debug.txt文件的chat-to-all命令。我发现这对调试人工智能特别有用,因为我可以游玩一整场游戏然后观看记录中我感兴趣的任何部分。
Example:
示例
- (defrule
- (goal upgrade-conflict 19)
- (can-research-with-escrow ri-hussar)
- =>
- (release-escrow food)
- (release-escrow gold)
- (research ri-hussar)
- (chat-debug "UPGRADES research ri-hussar")
- (set-goal upgrade-conflict NO))
复制代码
Example Output (with a bunch of other chats too):
[00:00:00] _Standard AI (BASE): AI PETERSEN RULES orders age-advancement NO (starting goals)
[00:00:00] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:00:00] _Standard AI (BASE): AI PETERSEN RULES orders house construction (no houses)
[00:00:26] _Standard AI (BASE): UPGRADES research loom defrule 1
[00:00:54] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:01:20] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:01:20] _Standard AI (BASE): AI PETERSEN RULES orders house construction (housing-headroom < 5 && population-headroom > 0)
[00:01:47] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:02:13] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:02:20] _Standard AI (BASE): AI PETERSEN RULES orders mill construction (don't have any and found food)
[00:02:23] _Standard AI (BASE): AI PETERSEN RULES orders lumber-camp construction (don't have any and found wood, game-time>90)
[00:02:39] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
[00:03:06] _Standard AI (BASE): AI PETERSEN RULES train villager defrule 1
PATCH 3.4 CHANGES 变更
We've opened up the scripting improvements to the base game, so the new AI scripts (above and below) will work in both flavors now. You still have to keep in mind differences with FE specific maps, civs, units, techs, etc.
New Defines 新定义
• up-pocket-position:
If this is defined, then the AI player is in a "pocket position" - that is, it has allies starting on its flanks. For example, suppose in an eight player game players are arranged like so:
A B C D
E F G H
In this case, B, C, F, and G are all in "pocket positions."
• 若人工智能玩家在“口袋位置”则定义之。这是说,它在其侧面有盟友。
• TEAM-TOGETHER:
This is defined if the "Team Together" option is set.
• 若“组队集中”选项已设置则定义之。
• UP-SCENARIO-GAME:
This is defined if the game is in a custom scenario.
• 若游戏在定制地图上则定义之。
• TURBO-RANDOM-MAP:
This is defined if the game mode is "turbo random map."
• 若游戏模式为“加速随机地图”则定义之。
• ALL-TECHS-ENABLED:
This is defined if the "All Techs" option is set.
• 若“完整科技”选项已设置则定义之。
New Constants 新常量
• target-player: Set to the number of the player that should be targeted for attack. If this sn is set to -1, initiating an attack will instead provide assistance to allies. When set to 0, sn-attack-winning-player will determine the target. Setting this to a player that cannot be attacked (an ally or the AI itself) will result in undefined behavior. You can also use this value with the "target-player" identifier in facts and actions.
This is a wildcard option for use with players-building-count, players-building-type-count, players-civilian-population, etc. with the additional effect that the AI's target player selection algorithm will use whatever this is set to as an override. This is set to whatever the player sets it to using sn-target-player-number.
• 设置应成为攻击目标的玩家的数量。如果此战略数字数值为-1,则发动进攻将改为为盟友提供支援。设置为一个不能进攻的玩家(一个盟友或人工智能自身)将会得到未定义的行为的结果。您也可在事实和动作中和“"target-player”标识符一同使用此数值。
这是一个和players-building-count,players-building-type-count,players-civilian-population,等等一同使用的通配符选项,带有额外的效果,即人工智能的目标玩家选择算法将会使用此常量设置的值覆盖之。使用sn-target-player-number将之设置为玩家设置为的数值。
• focus-player: This is a wildcard option for use with players-building-count, players-building-type-count, players-civilian-population, etc. This is set to whatever the player sets it to using sn-focus-player-number.
• 这是一个和players-building-count,players-building-type-count,players-civilian-population,等等一同使用的通配符选项。使用sn-focus-player-number将之设置为玩家设置为的数值。
• huskarl-set
• tarken-set
New Strategic Numbers: 新战略数字
• sn-percent-building-cancellation: Set to the maximum allowable completion percentage for building cancellation.
• 设置为最大允许的取消建筑的完成百分比。
• sn-enable-new-building-system: Set to 1 to allow the AIs to build more than one of the same building at a time.
• 设置为1以允许人工智能同时建造多于一个的相同建筑。
• sn-target-player-number: Set this to set the target-player wildcard.
• 设置此项以设置target-player通配符。
• sn-focus-player-number:Set this to set the focus-player wildcard.
• 设置此项以设置focus-player通配符。
• sn-preferred-mill-placement:This controls where the AI likes to put mills. Set to 0 for forage, 1 for deer, or 2 for shore fish.
• 这控制了人工智能放置磨坊的位置。设置为0以偏好浆果丛,1偏好鹿群,2偏好海岸鱼群。
• sn-number-civilian-militia: Set to the maximum number of villagers who may be used to attack the enemy. Specifically, to attack the enemy who are in the AI player's town.
• 设置为最大数量的可能用于攻击敌人的村民。特别是,攻击在人工智能玩家市镇的敌人。
• sn-enable-training-queue: Set to 1 to allow an additional unit to be queued at each building. If set to 0, buildings will train one unit at a time.
• 设置为1以允许一个额外的单位在每个建筑排队等待训练。若设置为0,则建筑一次会训练一个单位。
up-pending-objects:
(up-pending-objects typeOp inOpObjectId compareOp inOpValue)
• Perform a comparison with the pending count of an object.
• 对一个物件的待定数量执行比较。
Examples for up-pending-objects
示例
1. Check if there is at least 1 house pending completion.
检查是否有至少1座房屋等待完成。
- (defrule
- (up-pending-objects c: house >= 1)
- =>
- (do-nothing))
复制代码
up-research-status:
(up-research-status typeOp inOpTechId compareOp inOpResearchState)
• Check the research status of a specific technology.
• 检查特定科技的研究状态。
Examples for up-research-status
示例
1. Check if loom is either being researched or already complete.
检查织布机是否正在研究或者已经完成。
- (defrule
- (up-research-status c: ri-loom >= research-pending)
- =>
- (do-nothing))
复制代码
up-timer-status:
(up-timer-status inConstTimerId compareOp inOpTimerState)
• Check whether a timer is disabled, triggered, running, or a combination.
• 检查一个计时器是否被禁用,被触发,正在运行,或是以个组合。
Examples for up-timer-status
示例
1. Check if the specified timer is disabled or triggered.
检查指定的计时器是否被禁用或被触发。
- (defconst tm-gathering 1)
- (defrule
- (up-timer-status tm-gathering <= timer-triggered)
- =>
- (do-nothing))
复制代码
2. Check if the specified timer is running.
检查指定的计时器是否正在运行。
- (defconst tm-gathering 1)
- (defrule
- (up-timer-status tm-gathering == timer-running)
- =>
- (do-nothing))
复制代码
up-assign-builders:
(up-assign-builders typeOp inOpBuildingId typeOp inOpValue)
• Assign a specific number of builders to a building type or class.
• 指派一个特定数量的建筑工到一个类型或类别的建筑。
Examples for up-assign-builders
示例
1. Assign at least 2 builders for houses (not per house).
指定至少2名建筑工建造房屋(非每座房屋)。
- (defrule
- (true)
- =>
- (up-assign-builders c: house c: 2)
- (disable-self))
复制代码
2. Assign at least 4 builders for town centers (special exception).
指定至少4名建筑工建造市镇中心(特别例外)。
- (defrule
- (true)
- =>
- (up-assign-builders c: town-center-foundation c: 4) ; town-center-foundation = 621
- ;(up-assign-builders c: town-center c: 4) ; error: this will not work
- (disable-self))
复制代码
up-reset-unit:
(up-reset-unit typeOp inOpUnitId)
• Halt the activity of all units of a specific type. This is equivalent to clicking the "stop" button.
• 停止特定类型的所有单位的活动。这等价于点击“停止”按钮。
Examples for up-reset-unit
示例
1. Stop all spearmen on the map.
停止地图上所有的长矛兵。
- (defrule
- (true)
- =>
- (up-reset-unit c: spearman-line))
复制代码
up-modify-goal:
(up-modify-goal ioGoalId mathOp inOpValue)
• Perform math operations on the value stored in a goal variable.
• 对存储于目标变量的数值执行数学运算。
Examples for up-modify-goal
示例
1. Add 1 to the value stored in "gl-sheep-total".
对存储于“gl-sheep-total”的数值加1。
- (defconst gl-sheep-total 101)
- (defrule
- (true)
- =>
- (up-modify-goal gl-sheep-total c:+ 1)
- (disable-self))
复制代码
up-modify-sn:
(up-modify-sn ioSnId mathOp inOpValue)
• Perform math operations on a strategic number.
• 对战略数字执行数学运算。
Examples for up-modify-sn
示例
1. Subtract 2 from "sn-maximum-town-size".
从“sn-maximum-town-size”减2。
- (defrule
- (true)
- =>
- (up-modify-sn sn-maximum-town-size c:- 2)
- (disable-self))
复制代码
up-retreat-now:
(up-retreat-now)
• Retreat all military units to the home town center.
• 将所有军事单位撤退至家乡市镇中心。
Examples for up-retreat-now
示例
1. Retreat to the home town center.
撤退至家乡市镇中心。
- (defrule
- (true)
- =>
- (up-retreat-now)
- (disable-self))
复制代码
up-find-player:
(up-find-player inConstPlayerStance inConstFindPlayerMethod outGoalPlayerId)
• Find the first active player based on the provided information.
• 基于提供的信息寻找第一个活跃的玩家。
Examples for up-find-player
示例
1. Store the closest enemy player into gl-player.
将最近的敌人玩家存储至gl-player。
(- defconst gl-player 101)
- (defrule
- (true)
- =>
- (up-find-player enemy find-closest gl-player))
复制代码
New operators 新的运算子
The 'c' prefix indicates that the operator works on consts, the 'g' prefix indicates that the operator works on goals, and the 's' prefix indicates that the operator works on strategic numbers.
‘c’前缀指示运算子对常量工作,‘g’前缀指示运算子对目标工作,‘s’前缀指示运算子对战略数字工作,
• c:<
• c:<=
• c:>
• c:>=
• c:==
• c:!=
• g:<
• g:<=
• g:>
• g:>=
• g:==
• g:!=
• s:<
• s:<=
• s:>
• s:>=
• s:==
• s:!=
|
|