Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.
Hi, I got CMANO 1.12.5 last week, sorry to start a new thread but I've been stuck all weekend on a couple of things-
1- When creating scens, is there any way to place AI ships so that when the game begins they'll appear at random locations in the area of operations so that I won't know where they are and will have the fun of hunting them down?
2- I can't figure out how to set the 'event/trigger' routines to make my home-made scens automatically end when my (or the AI's) last ship is sunk.
For example if I BOL-launch ASM's at his suspected position it'd give me a warm fuzzy feeling if the game ended shortly afterwards so I'd know I'd nailed him..
"Fight with your brain first and your weapons second!"
You're in luck, both of these are possible and easy to do.
To start in a random position, I usually use Lua scripting as it is much more customisable. However, the easiest way is to place your units in the editor, then create an area with reference points where you'd like the random position to be and then set up an event as follows:
Trigger: Time-Game start time +1s
Action: Teleport selected units to selected area.
This will teleport the selected units to a random position within the selected area at game start time +1s.
To end a scenario automatically, set up an event as follows:
Trigger: Unit destroyed (in your example; could be any trigger you like)
Action: End scenario
By "last" I think you may need a "counter". I have set up a dummy "side" called "shipcounter" and incremented its score by +1 as each ship is sunk. Then you can evaluate the score in an Side Score event to end the scenario using the End Scenario action when the final ship goes down. The dummy side is sort of a global variable within the context of Command and lua. Dummy sides can hold a lot of valuable housekeeping info.
Kevin
“The study of history lies at the foundation of all sound military conclusions and practice.”
Alfred Thayer Mahan
I know this is a week old- but for doing randomization you really should be using a non-repeatable "Scenario Is Loaded" trigger. This means you can randomize the location of player units cleanly as well.
Hi, I got CMANO 1.12.5 last week, sorry to start a new thread but I've been stuck all weekend on a couple of things-
1- When creating scens, is there any way to place AI ships so that when the game begins they'll appear at random locations in the area of operations so that I won't know where they are and will have the fun of hunting them down?
Listen, I cannot help you with number 2, but I can help you with this one.
Would you like me to PM you a script that would accomplish this?
Or I can put it out on this group of messages.
I am also working on a way to randomly set units to one side or another... that should be operational in the next day or so...
The biggest problem I have had with that is that you cannot change WHOLE groups... the LUA script chokes on the scenedit command.
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.
This LUA script was meant to add randomly located oil rigs....
Some are enemy.
The 'Neutral 1' will not fire on the opponent, but will report the position
Neutral was truly neutral.
The latitudes and longitudes were within a specific geographical area in the Persian Gulf.
the variable 'b' is the number of platforms I wanted.
So if you wanted to place say, random submarines, and wanted 7, b would be 7.
====
a = 0
b = 25
repeat
a = a + 1
string.name = 'Oil Platform EOP.' .. a
UnitProf = math.random(1,5); UnitProf = UnitProf - 1
r = math.random(1, 85) - 1
r = r / 100
lati = 25.5 + r
r = math.random(1, 175) - 1
r = r / 100
longi = 52.05 + r
string.strLati = lati; string.strLongi = longi
r = math.random(1, 12)
if r >= 1 and r <= 5 then
string.sidename = 'Neutral 1'
rr = math.random(1, 3)
if rr == 1 or rr == 2 then
numdbid = 1869
else
numdbid = 1239
end
elseif r >= 6 and r <= 10 then
string.sidename = 'Neutral'
rr = math.random(1, 3)
if rr == 1 or rr == 2 then
numdbid = 1869
else
numdbid = 1239
end
elseif r > 10 then
string.sidename = 'ISIS/Al Quaida'
numdbid = 1239
if UnitProf < 4 then
UnitProf = UnitProf + 1
end
end
ScenEdit_AddUnit({type = 'ship', name = string.name, heading = 0, dbid = numdbid, side = string.sidename, Latitude= string.strLati ,Longitude= string.strLongi, autodetectable="false",holdfire="false",proficiency=UnitProf})
if string.sidename == 'ISIS/Al Quaida' then
ScenEdit_AssignUnitToMission(string.name, 'YankeeGoHome')
end
until a >= b
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.
First of all, many of you many not understand the need for such a script, but I love fog of war.
This Script takes single units and randomly assigns it to a nation...
It only takes SINGLE units, it does not work on groups because the Scenedit_SetUnitSide chokes on groups.
The script makes use of subscripted variables. string.SiteName is loaded... obviously you have need to make sure you have the names of the units you wish to run through this process both unique AND must be present or the script ABENDs.
You can have as many units as you want but the last unit must be EOF. That is how the script knows to end.
So I take the sites/units that I want to assign randomly either to Neutral or Iran.
I assign them then to a Mission.
*** WARNING ***
Make sure you save the scenario BEFORE running the script. The change is permanent...
ALSO: the randomseed number should be changed from game to game to that you have some 'randomness'
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.
I read in lua forums that there is an issue with the language generating random numbers and it's best to seed a few times before accepting the number, e.g.
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.
ORIGINAL: kevinkin
I read in lua forums that there is an issue with the language generating random numbers and it's best to seed a few times before accepting the number, e.g.
These are rather old posts. But I wanted to mention it to make sure everyone's code runs the way they want.
Kevin
Thank you, that is VERY good to know.
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.