Passero Posted September 16, 2020 Posted September 16, 2020 Is there some timer mechanism that I can use in the missions? For example I'm making an escort mission where you have to stay close to the unit you need to target. That part is setup using moving zones. When you leave the zone, I want to start a timer and when it reaches 30 seconds, I want to mark the mission as failed. So how can I create a timer that keeps track of this?
Passero Posted September 16, 2020 Author Posted September 16, 2020 (edited) Think I figured it out... I'm using a Repetitive action to check for my condition and when it's true it increases a flag by 1. Because this is run every second, I keep track of the time. I have another repetitive action that checks if that flag is > 30 and if it's true, it fails the mission... Another trigger is used to reset the flag if I get back into the required zone. I'm wondering... Would that be easier using Lua? In the end, it's and If/Else statement so in pseudo code it looks like this: if UnitInMovingZone(......) then setFlag(1,0) else increaseFlag(1,1) end if flag(1) >= 30 then FailMission() end Edited September 16, 2020 by Passero
Habu_69 Posted September 17, 2020 Posted September 17, 2020 You can also use this timer function timer.scheduleFunction( NewBandit, {}, timer.getTime() + 5 ) -- NewBandit is some function. Delays action by 5 sec.
Passero Posted September 17, 2020 Author Posted September 17, 2020 Ah thanks. I ended up using Moose and its scheduler object. Works just fine :)
Recommended Posts