Random map scripting: Regicide inconsistency, adjusting starting resources, enabling custom gamemode selection, and more

NetherlandsHenkdesupernerd

Well Known Pikeman
Feb 5, 2017
247
399
78
25
Netherlands
Voobly
HenkDeSuperNerd
View profile
Ladder
RM - 1v1
Rating
1639
Wins
35
Losses
29
Streak
1
#1
I like to share my toughts and recent findings regarding adjusting starting resources in a random map script.
I also like to ask anyone who is familiar with scripting and/or understands the game core features to share their toughts on the problem of using conditionals of starting resources along with conditionals for gamemodes. Also I want to notify active random map scipters, aswell as new/aspiring scripters about some problems when making regicide maps and some other small inconsistencies.
( @Zetnus @TriRem @scripter64 @hszemi @HJFE )


This is a pretty long and technical post so I have tried to subdivide this topic in two parts:
1) adjusting starting resources.
2) freeing up slots for custom game-mode selection.


These parts will be discussed in more detail below, but here is a summary:
1)
adjusting resources can be usefull for maps that have regicide as part of the script. These maps can be used to allow regicide + King of the hill or other combinations of gamemodes. The adjustment of resources is necesary in these scripts to create a similar start as we're used to. However there are a few problems:
- Many of the Regicide maps are incomplete and will generate 'double regicide' resources.
- Regicide maps (which could be combined with KotH) would have different starting resources when medium or high resources are selected when compared to the regular regicide game with medium/high starting resources.
- There are more inconsistencies in regicide maps, such as no nomad resources, in a nomad game.
Read more about adjusting starting resources in the upper section.

2)
A feature that opens a lot of options in the random map script is to use predefined conditionals to influence your map generation. The definitions LOW_RESOURCES, DEFAULT_RESOURCES, MEDIUM_RESOURCES, HIGH_RESOURCES can be used within an if-statement to adjust the script so certain things will be generated only when the right setting was selected. Since LOW and DEFAULT resources are both equal (200w, 200f, 100g, 200s in standard games) this means the starting resources selection can be used to influence the map generation. A simple example is having a map generated as nomad when low resources is selected, while the players will startt with a towncenter if standard resources was selected in the game lobby. I will explore the possibilities of freeing up more slots to enable more options of custom-gamemode selections, read more about that in the lower section.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
ADJUSTING STARTING RESOURCES (1)

So I've been playing around a lot with changing starting resources in random map scripts.

Userpatch 1.5 allows you to change starting resources, which is used for custom random map scripts.

Code:
     effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET 300
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET 300
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -100
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -50
This is an example of what is used to 'recreate' the Regicide resources.

However I have noticed some strange behaviour.

The first problem I encountered is that when REGICIDE is selected as a gamemode the standard regicide starting resources apply AND the adjustment of starting resources from the game script apply, which would result in an amount of starting resources of 800w, 800f, -100gold, and 100stone.

Many regicide scripts do not take into account that the gamemode regicide could be seleted by accident. To make it failproof the scripter should include a 'regicide-check' in his code.
This ensures that the resources will always be the 'standard regicide resources' of 500w, 500f, 0g, 150s

Code:
if REGICIDE
else
    guard_state KING AMOUNT_GOLD 0 1
    effect_amount MOD_RESOURCE STARTING_WOOD ATTR_ADD 300
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_ADD 300
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_ADD -100
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_ADD -50
endif
however when I select some other game-settings, such as HIGH_RESOURCES things get confusing, and it turns out our script is sill not completely fail-proof.

So I started to investigate further. What exactly are your starting resources and how are they affected by the game-settings (which you select in the lobby, prior to starting the game), and how can they be adjusted with userpatch-effects in random map scripts.

Userpatch-effects
Let's start with the userpatch effects. From numerous tests I have found out two ways to adjust starting resources.
in the script under <PLAYER_SETUP> the starting resource will be adjusted by using a line like this

effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET 100

the type of resource can easily be substituted (replace WOOD by FOOD, GOLD or STONE)

also the kind of operation can be changed.
ATTR_SET will add a value to the starting resource. If you have multiple lines with ATTR_SET that affect one resources then the last line will override the lines before.

example:
Code:
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 5000
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET 5000

    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 200
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -100
now the bottom lines will override the top ones and you will start the game with 200 more gold and 100 less stone.

ATTR_ADD will do exactly the same as ATTR_SET in the case of adjusting starting resources, except that multiple commands affecting the same resource will STACK.

this is very handy in complex random map scripts. for example:
Code:
        effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 5000
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET 5000

if TINY_MAP
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_ADD -200
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_ADD -200
else
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_ADD 400
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_ADD 400
endif
now the players will start with +5000 stone and gold. ON TOP OF THAT the players will get a -200gold and stone penalty if playing on a tiny map, but a 400 bonus if playing on other size maps.

it is possible to stack multiple ATTR_ADD lines on top of each other, or start of with a ATTR_SET, this does not matter.

multiply? I was expecting there would be an operation to multiply the starting resources, but I havent been able to find the code for it. probably because you are not actually adjusting the starting resources themselves but you are giving an additional bonus/defecit ON TOP of the starting resources. Multiplying the starting resources from the game would allow other tricks but for most things I think adding/subtracting will be sufficient.


Standard Starting resources
Next I started wondering how the starting resources would be influenced by picking ddifferent options in the game-lobby.
I wanted to make sure to understand the game correctly so I tested a lot of scenarios.
Questions I would ask myself were:
- if selecting high resources, do you get standard resources + extras? are the standard resources multiplied? is it a fixed amount? and how will it interact with the resource adjustments from the script?
- what happens when you select gamemodes that give different starting resources like DeathMatch or Regicide?

here are the results of starting resources for the generic civ without civbonus:

standard gamemode: random-map
Low: 200w, 200f, 100g, 200s
Standard: 200w, 200f, 100g, 200s (no difference from low)
Medium: 500w, 500f, 300g, 400s
High: 1000w, 1000f, 700g, 800s

gamemode: Regicide
Low: 500w, 500f, 0g, 150s
Standard: 500w, 500f, 0g, 150s (no difference from low)
Medium: 750w, 750f, 0g, 225s
High: 1000w, 1000f, 0g, 300s

gamemode: DeathMatch
Low: 20000w, 20000f, 10000g, 5000s
Standard: 20000w, 20000f, 10000g, 5000s (no difference from low)
Medium: 30000w, 30000f, 15000g, 7500s
High: 40000w, 40000f, 20000g, 10000s

as you can see each gamemode has their own values for each starting-resource setting.

To get more understanding of the intereaction with the random map script and the gamemode, I was thinking of a way to make a script that will always start with 0 starting resources.

I knew it was possibble to use conditionals to check what starting resources are selected and what gamemode.

I had good succes like this:

Code:
if DEFAULT_RESOURCES
    effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -200
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -200
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -100
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -200
elseif MEDIUM_RESOURCES
    effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -500
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -500
...
endif
also the resources of regicide could be set to 0
Code:
if REGICIDE
    effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -500
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -500
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 0
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -150
endif
however when I tried to do the logical step of tackling the regicide resources with a different starting resources settings:
Code:
if REGICIDE
    if HIGH_RESOURCES
         effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -1000
         effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -1000
         effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 0
         effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -300
   endif
endif
it did not do aything. so I tested a bit more and found out that the HIGH_RESOURCES conditional will be invalid when the gamemode is not standard random-map but something like regicide. this is a slightly worrysome problem.


Problems of inconsistency in Regicide Scripts

To complete regicide maps (which have a guardstate on a king build in within the code of the random map script) the script should be fail-proof.

Many regicide scripts do not take into account that the gamemode regicide could be seleted by accident. To make it failproof the scripter can use this code:

Code:
if REGICIDE
else
    guard_state KING AMOUNT_GOLD 0 1
    effect_amount MOD_RESOURCE STARTING_WOOD ATTR_ADD 300
    effect_amount MOD_RESOURCE STARTING_FOOD ATTR_ADD 300
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_ADD -100
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_ADD -50
endif
to ensure that the resources will always be the 'standard regicide resources' of 500w, 500f, 0g, 150s.

HOWEVER, if the players like to play with high resources they will find themselves with a starting amount different from the high resources that you expect in a regicide game
Regicide on high resources should give 1000w, 1000f, 0g, 300s starting resources.
However playing this mapscript as random-map or other gamemodes (such as king of the hill) will have different results when picking high resources:
This is a result of the adjustments that affect the regular HIGH resources of 1000w, 1000f, 700g, 800s and which will in the end result in a game with high resources selected on this regicide-map of 1300w, 1300f, 600g, 750s. which is very different from the regicide high resources of 1000w, 1000f, 0g, 300s which should be the stadard for regicide on High resources.

Idealy we could isolate the conditionals for resources and for regicide, and adjust them accordingly, but for now I have not found a way to have low/standard/medium/high resources recognised while regicide is active.

Unrelated to the starting resources (the topic of this thread) I think it still might be worth to mention other (essential) options to include in your mapscript when you make a regicide-mapscript
these are:

guard_state KING AMOUNT_GOLD 0 1
( this creates a gaurd state on the king, if you lose it you are defeated. In case you have multiple units, you won't be defeated untill the last one is dead. AMOUNT_GOLD can be substituded by AMOUNT_WOOD, AMOUNT_STONE, or AMOUNT_FOOD. these are the resource trickle which could be enabled aswell with the guardstate but for standard regicide it is disabled, so it doesnt matter which reosurce you got here)

effect_amount GAIA_SET_PLAYER_DATA DATA_MODE_FLAGS ATTR_SET 1
( Enable spies or treason att the castle. Set to 0 for Spies only, 3 for Treason only, 1 for both Spies and Treason )

objects: King(s), villagers, castle or tower
( Usually a regicide game should start with aditional units. Normally this means +7 villagers, +1 king and a castle. In nomad you normally won't have additional villagers and also no castle)

effect_amount MOD_RESOURCE POP_HEADROOM ATTR_SET 10
( Usually a regicide game should start with aditional units. The castle gives population space so you won't be housed from the start. However you can choose not to give a castle because it would be too impactfull for your map. Instead you could give a watchtower or nothing at all. In that case it is advised to set a pop-headroom which acts as bonus housing-space. I advise to use a multiple of 5, to not confuse players. 10pop headroom should be sufficient when starting with +7villagers and +1 king.)


Even more inconsistency (nomad regicide)
So maybe you made a mapscript that should be played as nomad and regicide and should allow playing other gamemodes awell. again you would have to recreate regicide settings by giving the regicide resources. However you might also want to hav nomad resources (+275w, +100s). However from tests it seems tthatt when Regicide is played on a nomad or land nomad map, there are no additional reosurces for constructing a towncenter. For consistency it would therefor be better to NOT have the nomad resources as part of your script. If the regicide function is optional, then without nomad resources you might find yourself in awkward situations again...

--------------------------------------------------------------------------------------------------------------------------------------------------

SELECTING CUSTOM SETTINGS (2)

Options to select map-script related settings
Back to the starting resources option at the gamelobby/starting screen:
Since low- and standard resources are equal in any case the conditional LOW_RESOURCES or DEFAULT_RESOURCES can be used to select a custom option in a mapscript.

As an easy example, if-statements can be included in the script that check if LOW_RESOURCES is selected to prevent the generation of a towncenter. This way you can allow the players to choose to play a map as nomad or as standard, by selecting the LOW_RESOURCES option in the gamelobby.

Code:
if LOW_RESOURCES
else
create_object TOWN_CENTER
{
....
}
however since selecting REGICIDE will make the starting-resource settings all invalid again these kind of scripts will not be failproof.


Freeing up more options to select map-script related settings
Continuing on the method to have custom setttings selected like the option that becomes available of selecting either standard- or low resources. I realised the custom options could be expanded by using the other starting reosurce options, assuming the map will never be played on medium or high resources anyways.

therefor I free the options MEDIUM_RESOURCES and HIGH_RESOURCES by using the userpatch adjustments of starting resources. with the following code I make sure selecting low/standard/medium/high resources would all result in the same standard resources of 200w, 200f, 100g, 200s. which frees up the starting resource selection to now have 4 custom settings. (with the cost that this map script will not be possible to play on medium or high resources)

Code:
if MEDIUM_RESOURCES
         effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -300
         effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -300
         effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -200
         effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -200
elseif HIGH_RESOURCES
         effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET -800
         effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET -800
         effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -600
         effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -600
endif
But again when REGICIDE is selected things go wrong....

-----------------------------------------------------------------------------------------------------------------------------------------------

all constants that were used in the examples should be defined in your script if you plan on using them:

Code:
#const AMOUNT_FOOD 0
#const AMOUNT_WOOD 1
#const AMOUNT_STONE 2
#const AMOUNT_GOLD 3
#const STARTING_FOOD 91
#const STARTING_WOOD 92
#const STARTING_STONE 93
#const STARTING_GOLD 94
#const MOD_RESOURCE 1
#const ATTR_SET 0
#const ATTR_ADD 1

#const DATA_MODE_FLAGS 1
#const GAIA_SET_PLAYER_DATA -10
 
Last edited:

Unknownscripter64

Longswordman
May 22, 2011
1,005
708
113
#3
The latest UP v1.5 public beta now has the fix (20180804-000000, build 6202) if you'd like to try it. However, it's only available as a standalone update and can't be used on Voobly yet. When the current ECL stage is complete, it will be updated there, as well.

If you'd like to update an offline WK installation with it, I think you can probably replace SetupAoC.exe in the WK installer folder and reinstall with the WK installer exe.
 

DenmarkChrazini

Known Member
Dec 31, 2013
92
177
48
Denmark
Voobly
Chrazini
View profile
Ladder
RM - 1v1
Rating
1687
Wins
32
Losses
21
Streak
3
#5
It's great to see these amazing UP features and constant brought to light.
There is a of things they can be used for - sadly they're fairly unknown.

I haven't had too many cases where I changed the starting resources. For some reason, this is one of the few things I don't want to mess too much with when I do random map scripting. I do, however, use ”LOW_RESOURCES” as a way to enable a custom nomad game mode within my maps. As you stated in the thread, “Low Resources” act the exact same way as “Standard Resources”, which essentially allows you to use it as a hidden extra way to make changes to the map script inside the lobby, without altering else.
I’ve always wanted the ability to have a custom dropdown menu in the game lobby where you could add different game modes to your maps right from the lobby. Essentially this would just define or undefine certain constants whiting the game – like “CUSTOM_1, CUSTOM_2, CUSTOM_3 and CUSTOM_4 – depending on what you chose in the lobby, and it would be up to the individual mapper to utilize this feature the way they wanted whiting the script.

Code:
if CUSTOM_1
    /* SOME CODE */
elseif CUSTOM_2
    /* SOME OTHER CODE */
elseif CUSTOM_3
    /* SOME CRAZY CODE */
elseif CUSTOM_4
    /* SOME STRANGE CODE */
elseif CUSTOM_5
    /* SOME FUN CODE */
endif
Anyway, this is probably besides the point, I just got carried away. One thing you said, that I do not completely agree with is the POP_HEADROOM attribute.
I've played around with a lot of the UP features - the possibilities are almost endless. It's a alot of fun, and you get to create a lot of unique things. However, if you want to remain whiting the default setting of the game, most of these features can not be used during normal map scripting - this includes POP_HEADROOM in my opinion. Instead of changing something so funamental as the tower population headroom, I would simply create a few extra houses around the player spawns or just leaves the players to build their own houses once the game has started - but this is a matter of opinion.

Great thread - and great job from @scripter64 for already fixing the issues seconds after its discovery. You're insane :wink:
 

NetherlandsHenkdesupernerd

Well Known Pikeman
Feb 5, 2017
247
399
78
25
Netherlands
Voobly
HenkDeSuperNerd
View profile
Ladder
RM - 1v1
Rating
1639
Wins
35
Losses
29
Streak
1
#6
The thing with tricks like custom options selection for example to enable nomad mode is very untransparant. With this i mean it is nearly impossible to notify the user that such option exists.

Ofcourse players could read about the script on sites like aoezone where they download them, or in description of the voobly mod that contains the maps, but most of the users will get access to maps via sharing.

The only place to explain the possibilties of your mapscript to these users is in the script itself and 99.999% of the players would not open a script to read its description/code.

One option would be to allow random map scripters to write a small paragraph in the objective tab in game. Which would atleast notify some players (now maybe 10% of the users would figure out the description of the features instead of <<1% of the users)

However describing how to select custom options before the game in a objectives tab In the game is a bit late and would only help to notify how playershow to use the map in future play, or require them to relaunch and this time with the correct settings (I have experienced this with scenarios where in the objectives tab the prefered gamelobby settings are described. We had to relaunch the game to select the right settibgs and make it work)

Writing a small paragraph to explain features in the objectives tab however still is a wish of me. It will be more usefull for maps where players might want to read up instructions DURING games. Examples are:
- explain that it is sudden death and you cant make tcs (now it only says 'gaurd state: TownCenter')
- explain that there is a resource trickle once you capture a monument
- explain that there is a gaurd state on a hero unit
- explain that a technology had been removed or altered (no walls, sling nerf)
- explain that unit balance is altered
- etc

In the ideal scenario there would be a dropdown list to select custom options and hovering over the option would show a custom description (just a small explanation). There already is a small text description on the bottom of the gamelobby when you cycle through standard game modes and maps. It would be awesome if this textbox could be used to write a custom explanation of your custom option selection.
 

DenmarkChrazini

Known Member
Dec 31, 2013
92
177
48
Denmark
Voobly
Chrazini
View profile
Ladder
RM - 1v1
Rating
1687
Wins
32
Losses
21
Streak
3
#7
You're absolutely right. It would by far not be a perfect solution.
Perhaps if the game actually read the first few lines of the RMS once it was selected in the lobby, it could change the custom game options with predefined text from the script, allowing everyone to easily see what each option does – together with a description for a perfect experience.

Though I feel like a feature like this would never happen, but I can dream :D
 
Mar 24, 2018
2
1
18
hszemi.de
#8
ATTR_ADD will do exactly the same as ATTR_SET in the case of adjusting starting resources, except that multiple commands affecting the same resource will STACK.

this is very handy in complex random map scripts. for example:
Code:
        effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 5000
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET 5000

if TINY_MAP
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -200
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -200
else
    effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET 400
    effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET 400
endif
now the players will start with +5000 stone and gold. ON TOP OF THAT the players will get a -200gold and stone penalty if playing on a tiny map, but a 400 bonus if playing on other size maps.
You might want to edit the bottom statements in order to say ATTR_ADD?

multiply? I was expecting there would be an operation to multiply the starting resources, but I havent been able to find the code for it. probably because you are not actually adjusting the starting resources themselves but you are giving an additional bonus/defecit ON TOP of the starting resources. Multiplying the starting resources from the game would allow other tricks but for most things I think adding/subtracting will be sufficient.
I do not see a scenario in which it would be sensible to multiply starting resources. From a technical perspective, multiplication is also quite different from addition, so someone would have had to put in the effort of implement that. Which probably explains why there is no such thing currently.
 
Aug 7, 2014
17
4
13
#10
This is an interesting read. I'm afraid I am starting to feel oldschool here. I try to keep most of my maps backwards compatible, and I've only played around with the weather and direct_placement features in UP 1.5, so I don't have anything specific to add.

I was not aware of the Nomad+Regicide issue, but in the end, it doesn't matter unless you are messing with starting resources, because the Regicide starting resources are enough to build as TC anyway. It's good to know about though.

Just as an aside, I always set up my regicide conditionals so that the king replaces the scout. My reasoning being that the king is fast and can be used for scouting. Dunno if anyone else does this. I just did it at some point and stuck with it ever since.
 

DenmarkChrazini

Known Member
Dec 31, 2013
92
177
48
Denmark
Voobly
Chrazini
View profile
Ladder
RM - 1v1
Rating
1687
Wins
32
Losses
21
Streak
3
#12
Just as an aside, I always set up my regicide conditionals so that the king replaces the scout. My reasoning being that the king is fast and can be used for scouting. Dunno if anyone else does this. I just did it at some point and stuck with it ever since.
I've been replacing the scout with a queen instead, so the gameplay is fairly consistent as she acts pretty much as a scout with no attack. Though, admittedly - this does sometimes add confusuion as people think they have to protect the queen aswell.
Just a little eyecandy I thought that was fun to do, and I've kept doing it since.
 

Time

Your time
G M T
Your zone

Upcoming Events

Talk of the Empire
Wednesday 20:00 (GMT +02:00)
w/ Nili, Zak & Nicov
ECL Africa 3v3
Saturday 16:00 (GMT +02:00)
ECL Africa 3v3 Round of 8
ECL Africa 3v3
October 6th 16:00 (GMT +02:00)
ECL Africa 3v3 Semi Finals & Grand Final
Halloween Party - 12 Hour Stream!
October 26th 21:00 (GMT +02:00)
Halloween Stream

Age Of Empires On Twitch

There are in total 26 streamers online
Click here for details
Age of Empires II 294 viewers
Age of Empires II 216 viewers
Age of Empires 120 viewers
age of empires ii 53 viewers
Age of Empires III: The Asian Dynasties 25 viewers
Top