Random Insurgency Generator

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
User avatar
cf_dallas
Posts: 303
Joined: Thu Apr 13, 2006 3:35 pm
Location: Grapevine, TX

Random Insurgency Generator

Post by cf_dallas »

I built a random insurgency generator which could be adapted to add just about any enemies to any scenario. I would use this to model units coming out from cover to fight.

Basic mechanism is:

1) Set up a blind neutral side with one unit somewhere completely unrelated to the conflict scenario; in this case, west Pacific, when the insurgency is in northern Syria.
2) Set up a patrol box, assign the unit to patrol it... it runs randomly around the box until it runs out of fuel (more on this later).
3) Within the patrol box, set up zones; use those zones to build "Unit Enters Area" triggers. Vary the size of the zones depending on the desired mix of forces generated. In this case I have a large area for Rebel Infantry Platoon, smaller area for Armed Technical, and smaller areas yet for Mortar Platoon and Howitzer Battery
4) Use a Lua script Action to spawn units within an area. I've got one action for each unit type, and the script is as follows:
ScenEdit_AddFacility('Insurgency', 'InfPl 1', 626, 0, 'DEC', 35+math.random(), 37+math.random())
That script drops a Rebel Infantry Platoon into a random location between 35-36N Lat and 37-38E Lon.

The attached ZIP contains two versions... "Steady" and "Surges". In the first I've used a blind/dumb Akula sub (ie, unlimited range) to patrol. Since it's an nuc it will run around the box indefinitely, building up forces in the insurgency area at a random but steady pace. In the second I've used a fighter and taken advantage of its finite fuel supply. It flies around the box until Bingo fuel, then goes home, refuels, and comes back. The result is a relatively fast buildup for a period of time, then a break, then another surge of new units. By changing the plane's patrol speed, or range, or the distance to home, you could infinitely vary the durations of the surge and the break between surges.

Problems I've seen in Rev A:
1) I'd love to be able to list reference points in the unit-spawn script, and have the game drop them in randomly in the area. Right now you have to call out a Lat/Lon coordinate, so I'm using the "math.random()" Lua function as a workaround.
2) The placement isn't truly random, I'm getting multiple units stacked on top of one another. I'm not sure what the scoop is there, I think it's a limitation in the randomness of a Lua-generated number. The Lua-Users Wiki suggests using "math.randomseed(x)" with "ostime()" in place of "x", but I couldn't get math.randomseed() to work in CMANO.
3) I would like to name/number the units individually... my first thought is to try something like setting a variable, using that variable in the unit name, and then incrementing the variable; but I'm out of time for today (and I'm a terrible coder anyway, I really am hunting around in the dark).

I'll keep chipping away when I get the chance; if anyone else wants to build on this, I'd welcome the crowdsourced help. :-)
Attachments
InsurgencyGenerator.zip
(10.63 KiB) Downloaded 26 times
Formerly cwemyss
RoryAndersonCDT
Posts: 1826
Joined: Mon Jun 15, 2009 11:45 pm

RE: Random Insurgency Generator

Post by RoryAndersonCDT »

Haha, what a neat idea! [:D]

1) I think ckfinite has something that can do this; or something along these lines. I'll send him a message to take a look next time I chat with him.
2) math.randomseed will be available for use in 1.07; and math.randomseed will be automatically called on scenario load to ensure random scenarios work right.
3) Definitely could do something along those lines with variables


Command Dev Team
Technical Lead
jarraya
Posts: 339
Joined: Mon Sep 10, 2007 4:04 pm

RE: Random Insurgency Generator

Post by jarraya »

This sounds very cool but it obviously isn't for the uninitiated. Will there be changes made to the editor that will allow for random events to be generated in an easier way?
User avatar
tjhkkr
Posts: 2430
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

RE: Random Insurgency Generator

Post by tjhkkr »

That is a fantastic idea. :)
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
Post Reply

Return to “Mods and Scenarios”