Can any scenario maker recommend me a way to create random units spawn? lets say a random nomad spawn for each player,
Maybe theres a possibility for % chance on xs?
Hello,
You can do it like this:
- XS side
-
Use the XS function
xsGetRandomNumber. -
Prepare a list of possible spawn coordinates (x, y) (or spawn areas).
- Python side (AoE2ScenarioParser)
- Use Python + AoE2ScenarioParser to generate all triggers automatically (so you don’t create them manually).
Logic
-
When the game starts, your XS
main()runs and generates a random number (example: 1 to 10). -
Store that value into a variable per player (e.g., Variable 1..8 for players 1..8).
Then for each player you create triggers like:
Trigger 1
- Condition: Variable value == 1
Effect: Create Object at (x1, y1)
Trigger 2
-
Condition: Variable value == 2
Effect: Create Object at (x2, y2) -
… one trigger per spawn location hence per variable value
Example: If the random number is 4, then the trigger with Variable value == 4 fires and places the unit in the corresponding spawn location.
This approach scales well: you just add coordinates, re-run the Python script, and it regenerates all triggers.
If you need help with XS or generating the triggers in AoE2ScenarioParser, feel free to ping.