Age of Empires II (2013)

Age of Empires II (2013)

Advance to the Steam Age
Explore new maps, multiplayer scenarios, and user created campaigns. Or reinvent your game experience with new sounds, visuals, AI, units, and more! Ready to share your creations with the world? Upload right from the map editor, or collaborate with friends to create a masterpiece collection.
 This topic has been pinned, so it's probably important
morness 6 Nov, 2013 @ 3:37pm
Age of Empires Script Reference
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
  • Updated the number of allowed facts from 1000 to 10000
  • Updated the number of goals from 50 to 512.
  • sn-task-ungrouped-soldiers now defaults to 0.
  • dropsite-min-distance now supports additional dropsite-types: hunting, boar-hunting, deer-hunting, and 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.

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.

Examples for ai_info_map_type:

1. #load-if-defined COASTAL-MAP will be true for AIs.
<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.
<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.
<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.

New valid map types are (Forgotten Only):
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.
  • Section: LAND_GENERATION :: create_player_lands, create_land
Examples for base_elevation
1. Create a palm desert land with elevation 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.
  • 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.
  • Section: PLAYER_SETUP
Examples for nomad_resources
1. Set starting resources like nomad with +275W, +100S.
<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.

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.
(defrule (true) => (up-retask-gatherers wood c: 3) (disable-self) )
boar-food is a new valid type for 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.
(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.
Examples for up-jump-rule
1. Skip 1 rule if a condition is true.
(defrule (true) => (up-jump-rule 1) ) (defrule ; this rule is skipped (true) => (do-nothing) )

2. Loop over a rule 3 times.
(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.
(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
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.
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.
  • 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.
  • 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.
  • sn-target-player-number: Set this to set the target-player wildcard.
  • sn-focus-player-number:Set this to set the focus-player wildcard.
  • 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.
  • 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.

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.
(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).
(defrule (true) => (up-assign-builders c: house c: 2) (disable-self) )
2. Assign at least 4 builders for town centers (special exception).
(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".
(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".
(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.
(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:<
  • c:<=
  • c:>
  • c:>=
  • c:==
  • c:!=
  • g:<
  • g:<=
  • g:>
  • g:>=
  • g:==
  • g:!=
  • s:<
  • s:<=
  • s:>
  • s:>=
  • s:==
  • s:!=

Last edited by Cysion; 31 Jul, 2014 @ 4:00pm
< >
Showing 1-15 of 129 comments
Torg Smith 6 Nov, 2013 @ 3:41pm 
Coolness.
samao 6 Nov, 2013 @ 4:27pm 
Unrelated but in AoF is all the food the same like it is in UP 1.4? ex. you can go from berries to sheep without having to drop thevberries off first or lose the food into the void.
Originally posted by morness:
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].

I wonder why that person is so hidden. There name doesn't appear on their website, or on the whois data for it.
Gae Assail 1 6 Nov, 2013 @ 5:15pm 
It gotta be elusive!

Hes trolling the hell out of everyone and his name is a private joke >.>
Biz 3 6 Nov, 2013 @ 5:57pm 
does the resource_delta rms flag work?

and why isn't RMS separated from AoF balance changes?
Caesar 11 Nov, 2013 @ 1:11am 
It seems all this configuration have broken AI compatibility. Now, custom AI like chamaleon, the horde and others can't be used due to "Error 5001:File not found"
Whykonen 11 Nov, 2013 @ 3:24pm 
I noticed, how to fix this? Really want to play customs!
CPOKashue 8 12 Nov, 2013 @ 1:20pm 
I'd like to start using the new Forgotten units and scenery objects in random map scripts. is there a comprehensive list of the names of new elements as far as AOE knows? Using their designer names it doesn't seem possible to generate things like Rain or Grass Patchs.
morness 12 Nov, 2013 @ 4:01pm 
A bunch of defConsts are created for civs, units, researches, and lines, but there is nothing for props. Here is a recent dump of all the definitions that are known to FE. I didn't want to put it in the original post because I thought it was too much :AOESheep:

I eyeballed the list and cut out the non-RMS stuff, so here is everything I think:

Defining Constant terrain-grass (value of 0) Defining Constant terrain-grass2 (value of 12) Defining Constant terrain-grass3 (value of 9) Defining Constant terrain-grass-snow (value of 34) Defining Constant terrain-grass-old (value of 16) Defining Constant terrain-water (value of 1) Defining Constant terrain-water-deep (value of 22) Defining Constant terrain-water-medium (value of 23) Defining Constant terrain-water-bridge (value of 28) Defining Constant terrain-water-old (value of 15) Defining Constant terrain-water-beach (value of 2) Defining Constant terrain-shallows (value of 4) Defining Constant terrain-ice (value of 26) Defining Constant terrain-ice2 (value of 35) Defining Constant terrain-ice-beach (value of 37) Defining Constant terrain-desert (value of 14) Defining Constant terrain-dirt (value of 6) Defining Constant terrain-dirt2 (value of 11) Defining Constant terrain-dirt3 (value of 3) Defining Constant terrain-dirt-snow (value of 33) Defining Constant terrain-farm (value of 7) Defining Constant terrain-farm1 (value of 29) Defining Constant terrain-farm2 (value of 30) Defining Constant terrain-farm3 (value of 31) Defining Constant terrain-farm-dead (value of 8) Defining Constant terrain-forest (value of 10) Defining Constant terrain-forest-bamboo (value of 18) Defining Constant terrain-forest-jungle (value of 17) Defining Constant terrain-forest-oak (value of 20) Defining Constant terrain-forest-palm (value of 13) Defining Constant terrain-forest-pine (value of 19) Defining Constant terrain-forest-snow (value of 21) Defining Constant terrain-foundation (value of 27) Defining Constant terrain-foundation-snow (value of 36) Defining Constant terrain-koh (value of 40) Defining Constant terrain-leaves (value of 5) Defining Constant terrain-road (value of 24) Defining Constant terrain-road-broken (value of 25) Defining Constant terrain-road-snow (value of 38) Defining Constant terrain-road-fungus (value of 39) Defining Constant terrain-snow (value of 32) Defining Constant terrain-unknown (value of 41) Defining Constant italian (value of 19) Defining Constant indian (value of 20) Defining Constant incan (value of 21) Defining Constant magyar (value of 22) Defining Constant slavic (value of 23) Defining Constant ri-chivalry (value of 493) Defining Constant ri-inquisition (value of 492) Defining Constant ri-sipahi (value of 491) Defining Constant ri-madrasah (value of 490) Defining Constant ri-ironclad (value of 489) Defining Constant ri-boiling-oil (value of 488) Defining Constant ri-nomads (value of 487) Defining Constant ri-panokseon (value of 486) Defining Constant ri-yasama (value of 485) Defining Constant ri-renegades (value of 483) Defining Constant ri-atlatl (value of 460) Defining Constant ri-war-wolf (value of 461) Defining Constant ri-greek-fire (value of 464) Defining Constant ri-chieftains (value of 463) Defining Constant ri-great-wall (value of 462) Defining Constant ri-stronghold (value of 482) Defining Constant ri-orthodoxy (value of 512) Defining Constant ri-druzhina (value of 513) Defining Constant ri-elite-boyar (value of 504) Defining Constant ri-andean-sling (value of 516) Defining Constant ri-couriers (value of 517) Defining Constant ri-elite-kamayuk (value of 509) Defining Constant ri-sultans (value of 506) Defining Constant ri-shatagni (value of 507) Defining Constant ri-imperial-camel (value of 521) Defining Constant ri-elite-elephant-archer (value of 481) Defining Constant ri-mercenaries (value of 514) Defining Constant ri-recurve-bow (value of 515) Defining Constant ri-elite-magyar-huszar (value of 472) Defining Constant ri-silk-road (value of 499) Defining Constant ri-pavise (value of 494) Defining Constant ri-elite-genoese-crossbow (value of 468) Defining Constant ri-revetments (value of 525) Defining Constant ri-eagle-warrior (value of 384) Defining Constant ri-gillnets (value of 65) Defining Constant ri-hunting-dogs (value of 526) Defining Constant imperial-camel (value of 207) Defining Constant slinger (value of 185) Defining Constant condottiero (value of 882) Defining Constant kamayuk (value of 879) Defining Constant elite-kamayuk (value of 881) Defining Constant elephant-archer (value of 873) Defining Constant elite-elephant-archer (value of 875) Defining Constant genoese-crossbowman (value of 866) Defining Constant elite-genoese-crossbowman (value of 868) Defining Constant magyar-huszar (value of 869) Defining Constant elite-magyar-huszar (value of 871) Defining Constant boyar (value of 876) Defining Constant elite-boyar (value of 878) Defining Constant heavy-eagle-warrior (value of 753) Defining Constant genoese-crossbowman-line (value of -263) Defining Constant elephant-archer-line (value of -262) Defining Constant boyar-line (value of -261) Defining Constant magyar-huszar-line (value of -260) Defining Constant kamayuk-line (value of -259) Defining Constant stable-tarkan (value of 886) Defining Constant stable-elite-tarkan (value of 887) Defining Constant forage-food (value of 907) Defining Constant deer-food (value of 909) Defining Constant boar-food (value of 910) Defining Constant fish-food (value of 933) Defining Constant farm-food (value of 949) Defining Constant sheep-food (value of 958) Defining Constant acropolis (value of 50) Defining Constant budapest (value of 51) Defining Constant cenotes (value of 52) Defining Constant cityoflakes (value of 53) Defining Constant goldenpit (value of 54) Defining Constant hideout (value of 55) Defining Constant hillfort (value of 56) Defining Constant lombardia (value of 57) Defining Constant steppe (value of 58) Defining Constant valley (value of 59) Defining Constant megarandom (value of 60) Defining Constant hamburger (value of 61)

CPOKashue 8 13 Nov, 2013 @ 9:30pm 
Awesome, thanks!
Parzival 14 Nov, 2013 @ 1:32am 
Originally posted by morness:
Here is a recent dump of all the definitions that are known to FE.

Thanks for posting this information! :-)

This "Error 5001:File not found" is a real problem, because Custom AIs are a big part of the fun and gameplay since many, many years.

Broken Custom AI compatibility and the missing AIs from ForgottenEmpires (I know they will be implemented "soon") are somewhat disappointing.
Last edited by ZZebraDog; 14 Nov, 2013 @ 11:16am
Zetnus 59 29 Nov, 2013 @ 7:22am 
For random map scripting, I just thought I would point out that the map size label LUDIKRIS_MAP has been added.
For example:

if LUDIKRIS_MAP
create_object GOLD
and so on

If you don't include this in the objects generation section, the LudiKRIS maps can be very devoid of gold and stone. Just try loading up one of the custom ES random maps scripts on LudiKRIS size and you will see.

EDIT: I finally took a look at the new official AOF scripts and some of them use "elseif LUDIKRIS_MAP" while others just use "else" after all the other sizes.
Last edited by Zetnus; 16 Nov, 2014 @ 9:50am
Dexie 29 Nov, 2013 @ 7:36am 
Originally posted by {ZwK}Parzival:
Broken Custom AI compatibility and the missing AIs from ForgottenEmpires (I know they will be implemented "soon") are somewhat disappointing.

Yeah, is this planned for patch 3.2?
Last edited by Dexie; 29 Nov, 2013 @ 7:36am
I do not understand this post at all. What we talking about here?
FE_HockeySam18 1 Dec, 2013 @ 7:14am 
AI and RMS scripting.
< >
Showing 1-15 of 129 comments
Per page: 1530 50