Random location of troops

Post new scenarios and mods here to share with other gamers.

Moderator: Campaign Series Matrix Edition Development Group

Post Reply
Sergobor
Posts: 5
Joined: Sun Jan 30, 2022 5:35 am

Random location of troops

Post by Sergobor »

Hi. I have a question about the scenario editor. Is there any way to make enemy (AI) troops appear in random hexes?
User avatar
Crossroads
Posts: 18550
Joined: Sun Jul 05, 2009 8:57 am

RE: Random location of troops

Post by Crossroads »

Hello @Sergopor! You need CSEE in Lua file to do that, too. First, set any units you want placed randomly as replacements, arriving perhaps in a turn number that is higher than what there are turn in the scenario. That way they will stand out from perhaps those replacements that are due to arrive during the game play, per how they are set in the editor itself.

Once those are in place, use CSEE functions set_reinforcement_hex (id, hc) and set_reinforcement_turn (id, hc) to dynamically set on which turn and on what hex they will make their entrance.

Please see LUA_FUNCTIONS_REFERENCE document in the Manual folder for details.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.10.20 Available Now (Dec 03, 2025)
CS: Middle East 1948-1985 < v3.10.20 Available Now (Dec 03, 2025)
Sergobor
Posts: 5
Joined: Sun Jan 30, 2022 5:35 am

RE: Random location of troops

Post by Sergobor »

Thank you! Did I understand correctly that this will allow you to place the enemy in random hexes rather than predetermined hexes?
User avatar
Crossroads
Posts: 18550
Joined: Sun Jul 05, 2009 8:57 am

RE: Random location of troops

Post by Crossroads »

ORIGINAL: Sergobor

Thank you! Did I understand correctly that this will allow you to place the enemy in random hexes rather than predetermined hexes?
Yes. Each reinforcement has a unique ID moniker, and using that, you can set turn and hex, respecitively, by those two commands in the scenario specific Lua file.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.10.20 Available Now (Dec 03, 2025)
CS: Middle East 1948-1985 < v3.10.20 Available Now (Dec 03, 2025)
User avatar
Crossroads
Posts: 18550
Joined: Sun Jul 05, 2009 8:57 am

RE: Random location of troops

Post by Crossroads »

^To be more specific, put those functions into on_next_phase() event function, then It will affect both H2H play and also vs-SAI play. There's also a side specific battle_plan function, but that is only called if said side is under computer opponent control.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.10.20 Available Now (Dec 03, 2025)
CS: Middle East 1948-1985 < v3.10.20 Available Now (Dec 03, 2025)
Sergobor
Posts: 5
Joined: Sun Jan 30, 2022 5:35 am

RE: Random location of troops

Post by Sergobor »

Thank you! I'm going to try it. For me, experimenting with the editor in this awesome game is just as much fun as playing it!
User avatar
Crossroads
Posts: 18550
Joined: Sun Jul 05, 2009 8:57 am

RE: Random location of troops

Post by Crossroads »

Good luck, any questions just give us a shout!
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < v2.10.20 Available Now (Dec 03, 2025)
CS: Middle East 1948-1985 < v3.10.20 Available Now (Dec 03, 2025)
Post Reply

Return to “Scenario Design and Modding”