Looking for scripting/mission help

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.

Moderator: MOD_Command

Post Reply
User avatar
1nutworld
Posts: 385
Joined: Sun Apr 13, 2014 12:34 pm

Looking for scripting/mission help

Post by 1nutworld »

Hey everyone,

* - If this post needs to be placed under a different topic feel free to move it.

I am working on a testing scenario comparing the F-35 v F-22

There will be an OPFOR CAP that the planes will have to contend with, as well as a ground strike capability. So the F-35's and F-22's will have a strike mission w escorts set up.

What I want to do is add an 59N6 radar that will NOT be emitting until after the inbound flight is detected by the CAP a/c.
Once the inbound strike A/C are detected by the opfor CAP, then the 59N6 will begin emitting to help defensive SAM's engage the escorts/strike F-35 and F-22's.

Thanks in advance.

Scott
USS Dwight D. Eisenhower (CVN-69) 1990-1994.
tmoilanen
Posts: 74
Joined: Wed Oct 19, 2011 4:28 pm

RE: Looking for scripting/mission help

Post by tmoilanen »

Hi Scott - you should create an event with a "Unit is Detected" trigger on your F-35/F-22.

below is a LUA script that should work as the action for that event...replace myside and myunitname with your OPFOR side and the unitname of the emitter that you want to activate.

Hope this helps...TM

myside = 'PLAN'
myunitname = {'KZLDY'}

for i = 1, #myunitname
do
unitname = myunitname
myunit = ScenEdit_GetUnit({side=myside,name=unitname})
print(myunit)

print(myunit.obeyEMCON)
myunit.obeyEMCON = true
print(myunit.obeyEMCON)
myemcon = 1 -- if you want to add some randomness to it substitute math.random(1,2) for 1
if myemcon == 1 then -- check the random emcon variable
ScenEdit_SetEMCON('Unit',unitname,'Inherit=false;OECM=Active') --if myemcon = 1 activate the radar
else
ScenEdit_SetEMCON('Unit',unitname,'Inherit=false;OECM=Passive') --if myemcon does not equal 1 do nothing
print(myunit.sensors)
end
end
thewood1
Posts: 6845
Joined: Sun Nov 27, 2005 6:24 pm

RE: Looking for scripting/mission help

Post by thewood1 »

My knee jerk reaction would have been to put the radar on a mission with radar on but deactivated. Then activate the mission based on entry into a zone or unit detection levels.
You are like puss filled boil on nice of ass of bikini model. You are nasty to everybody but then try to sweeten things up with a nice post somewhere else. That's nice but you're still a boil on a beautiful thing! - BDukes
User avatar
1nutworld
Posts: 385
Joined: Sun Apr 13, 2014 12:34 pm

RE: Looking for scripting/mission help

Post by 1nutworld »

ORIGINAL: tmoilanen

Hi Scott - you should create an event with a "Unit is Detected" trigger on your F-35/F-22.

below is a LUA script that should work as the action for that event...replace myside and myunitname with your OPFOR side and the unitname of the emitter that you want to activate.

Hope this helps...TM

myside = 'PLAN'
myunitname = {'KZLDY'}

for i = 1, #myunitname
do
unitname = myunitname
myunit = ScenEdit_GetUnit({side=myside,name=unitname})
print(myunit)

print(myunit.obeyEMCON)
myunit.obeyEMCON = true
print(myunit.obeyEMCON)
myemcon = 1 -- if you want to add some randomness to it substitute math.random(1,2) for 1
if myemcon == 1 then -- check the random emcon variable
ScenEdit_SetEMCON('Unit',unitname,'Inherit=false;OECM=Active') --if myemcon = 1 activate the radar
else
ScenEdit_SetEMCON('Unit',unitname,'Inherit=false;OECM=Passive') --if myemcon does not equal 1 do nothing
print(myunit.sensors)
end
end



I'm, not getting the script to run properly....I guarantee you it is something to do with my typing.

mind if I send you PM to help figure out the issue? I'm sure it's something simple
USS Dwight D. Eisenhower (CVN-69) 1990-1994.
tmoilanen
Posts: 74
Joined: Wed Oct 19, 2011 4:28 pm

RE: Looking for scripting/mission help

Post by tmoilanen »

Sure no problem
User avatar
1nutworld
Posts: 385
Joined: Sun Apr 13, 2014 12:34 pm

RE: Looking for scripting/mission help

Post by 1nutworld »

ORIGINAL: thewood1

My knee jerk reaction would have been to put the radar on a mission with radar on but deactivated. Then activate the mission based on entry into a zone or unit detection levels.

that sounds like a simple solution, but I'm not a scripter...though I can cut and paste. LOL.

Seriously, though, that might be something I try. I can run the scenario in editor and do the activation myself I suppose, but I'd like to have computer controlled side run it for me
USS Dwight D. Eisenhower (CVN-69) 1990-1994.
tmoilanen
Posts: 74
Joined: Wed Oct 19, 2011 4:28 pm

RE: Looking for scripting/mission help

Post by tmoilanen »

Actually the error was in the original script I shared.

You can either remove the brackets from myunitname = {'KZLDY'}

Code: Select all

myunitname = 'KZLDY'

or

change unitname = myunitname to the following

Code: Select all

unitname = myunitname[i]

Either should fix the issue.
thewood1
Posts: 6845
Joined: Sun Nov 27, 2005 6:24 pm

RE: Looking for scripting/mission help

Post by thewood1 »

ORIGINAL: 1nutworld

ORIGINAL: thewood1

My knee jerk reaction would have been to put the radar on a mission with radar on but deactivated. Then activate the mission based on entry into a zone or unit detection levels.

that sounds like a simple solution, but I'm not a scripter...though I can cut and paste. LOL.

Seriously, though, that might be something I try. I can run the scenario in editor and do the activation myself I suppose, but I'd like to have computer controlled side run it for me

I don't see the difference in doing what I suggested vs. lua. But whatever works for you.

btw, there's zero scripting involved in my possible solution. Its just an event, a trigger, an action, and a mission. No lua and no scripting. I tend to exhaust all solutions before resorting to lua. Lua scripts tend to complicate modding scenarios if you didn't write the original scripts. Using events and missions like this has always seemed an easier.

And my suggestion is for the AI. No manual intervention needed.
You are like puss filled boil on nice of ass of bikini model. You are nasty to everybody but then try to sweeten things up with a nice post somewhere else. That's nice but you're still a boil on a beautiful thing! - BDukes
Post Reply

Return to “Command: Modern Operations series”