Page 1 of 1

Trigger on Hostilities Commence

Posted: Fri Dec 06, 2019 8:46 pm
by patpatpowercat
I am trying to figure out how to activate a list of missions once two sides commence hostilities. I understand how to activate the missions using lua ScenEdit_SetMission {isactive=true}, but I am trying to figure how to best trigger this action. Originally I was going to do it with a unit destroyed, but I don't want a 3rd side to commence hostilities between the two sides prematurely. So I was looking into firing a once a second trigger and using ScenEdit_GetSidePosture, have if it returns hostile than activate the missions. However, my lua knowledge isn't that great and I'm not sure how to take the return of the GetSidePosture and turn it into a variable for us in an if/then argument, or if this would be the optimal way of doing so.

Any suggestions?

RE: Trigger on Hostilities Commence

Posted: Fri Dec 06, 2019 9:11 pm
by Rory Noonan
If it's important that the only variable that is counted is the side postures (i.e. you don't want to use a surrogate like a unit destroyed or a weapon fired) then I'd use a regular time trigger of whatever suits, 1s would be fine because this will be light performance wise until triggered, and have an if statement at the start of the script that checks if the sides are hostile and then activates the missions if that condition is true.
local sidePosture = ScenEdit_GetSidePosture('Side A','Side B')

if sidePosture == 'H' then

--your code here

end

RE: Trigger on Hostilities Commence

Posted: Fri Dec 06, 2019 9:35 pm
by patpatpowercat
Thanks so much! I just had H instead of 'H' and it wasn't working.