Looking for scripting/mission help (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series



Message


1nutworld -> Looking for scripting/mission help (7/27/2021 2:41:42 PM)

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




tmoilanen -> RE: Looking for scripting/mission help (7/27/2021 10:47:49 PM)

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 -> RE: Looking for scripting/mission help (7/27/2021 11:15:40 PM)

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.




1nutworld -> RE: Looking for scripting/mission help (7/27/2021 11:20:42 PM)


quote:

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




tmoilanen -> RE: Looking for scripting/mission help (7/27/2021 11:21:57 PM)

Sure no problem




1nutworld -> RE: Looking for scripting/mission help (7/27/2021 11:29:30 PM)


quote:

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




tmoilanen -> RE: Looking for scripting/mission help (7/27/2021 11:30:35 PM)

Actually the error was in the original script I shared.

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

myunitname = 'KZLDY'


or

change unitname = myunitname to the following

unitname = myunitname[i]


Either should fix the issue.




thewood1 -> RE: Looking for scripting/mission help (7/27/2021 11:44:41 PM)

quote:

ORIGINAL: 1nutworld


quote:

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.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.78125