Question about how to script this condition

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
lerugray
Posts: 160
Joined: Mon Dec 22, 2014 12:42 pm

Question about how to script this condition

Post by lerugray »

Hi All.

So I'm working on a scenario where if the player hits certain targets between 9-6 he gets penalized, where as outside of working hours he gains VPs as normal.

I figure I need to do something like this for the time

Code: Select all

local now = ScenEdit_CurrentTime()
 local elapsed = now - timeFromLastTriggered
 
 if elapsed > 3600*14  then
   -- Past 6, 14 hours later than game start
   approved_time = true
 end

But what I can't figure out is how to get the point scoring event not to triger if it's within that time frame (and instead trigger a penalty for civ casualties) any help is appreciated, thanks!
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Question about how to script this condition

Post by Rory Noonan »

What I would do is this:

Use the time and date settings in CMANO along with the console to get the timecodes from the start and finish of your penalty period, using console entries similar to
local now = ScenEdit_CurrentTime()
print (now)

Copy/Save those numbers somewhere

Create a trigger for destruction of the target

Create an action with your normal points for destroying your target (without any penalty)

Create a condition as below
local now = ScenEdit_CurrentTime()
local start = --INSERT START TIMECODE HERE
local end = --INSERT END TIMECODE HERE

if now > start and now < end then
--ENTER POINTS PENALTY FUNCTION HERE
return true
else

return true
end

Basically when you destroy the target, the trigger fires, the event is checked and removes points if between certain times, and regardless of time the normal points for destruction are allocated.

I haven't had a chance to fully test that but it should work. This is also a very basic solution, you might be better off with two seperate events tied to the same trigger with different conditions for more flexibility.
Image
lerugray
Posts: 160
Joined: Mon Dec 22, 2014 12:42 pm

RE: Question about how to script this condition

Post by lerugray »

ORIGINAL: apache85

What I would do is this:

Use the time and date settings in CMANO along with the console to get the timecodes from the start and finish of your penalty period, using console entries similar to
local now = ScenEdit_CurrentTime()
print (now)

Copy/Save those numbers somewhere

Create a trigger for destruction of the target

Create an action with your normal points for destroying your target (without any penalty)

Create a condition as below
local now = ScenEdit_CurrentTime()
local start = --INSERT START TIMECODE HERE
local end = --INSERT END TIMECODE HERE

if now > start and now < end then
--ENTER POINTS PENALTY FUNCTION HERE
return true
else

return true
end

Basically when you destroy the target, the trigger fires, the event is checked and removes points if between certain times, and regardless of time the normal points for destruction are allocated.

I haven't had a chance to fully test that but it should work. This is also a very basic solution, you might be better off with two seperate events tied to the same trigger with different conditions for more flexibility.


Thank you so much! I'm going to incorporate your ideas into a condition idea I had to cover both conditions in regards to target and time.

Code: Select all

local now = ScenCurrentTime()
 if now > now += 3600*2 and now < now += 3600*14 then
   if SecnEdit_GetUnit({side='BSA', name='Ammo Factory' or name='Textile Factory' or name='Power Station'
   or name='Military Factory' or name='Diesel Tank' or name='Processing Plant' or name='Serb Police Station Alpha'
   or name='Serb Police Station Bravo' or name='Serb Police Station Charlie' or name='Serb Police Station Charlie' 
   or name='Serb Police Station Delta' or name='Serb Police Station Echo'}) == nil then
     ScenEdit_ExecuteEventAction('Civilians Killed')
   end
 end
 
Post Reply

Return to “Mods and Scenarios”