Jump to content

Will this staged timer work?


saxon7610

Recommended Posts

I am working on a mod that will build a new casino in searchlight over a number of days after the player has completed a quest to close the radiation canisters in the firehouse. I was hoping to get a pro tip on this script, i.e. "will it work", the examples I have seen with staged timers have all use GetSecondsPassed instead of GameDaysPassed.

 

scn zzSearchlightTimer

Float timer
Short Day3
Short Day15
Short Day30
short Casino

Begin Gamemode

If getstage Quest >= 100 && (Day30 == 0)
Set timer to GameDaysPassed + 30
Endif

;enables foundation and guards
if (timer == GameDaysPassed - 27) && (Day3 == 0)
xxxxxx.enable
set Day3 to 1
endif

;enables casino exterior
if (timer == GameDaysPassed - 15) && (Day15 == 0)
xxxxx.enable
Set Day15 to 1
endif

;opens casino for business
If (timer == GameDaysPassed - 30) && (Casino == 0)
xxxxx.enable
Set Casino to 1
Endif

End

Link to comment
Share on other sites

Your script wouldn't work like you expect. You're not setting the Day30 variable anywhere, so the timer is set to days passed + 30 with every iteration.

If we start at day 7: 30 + 7 = 37 days. The next day it would be 38, and so on.

Additionally, your conditions are way off. The following will never evaluate to true:

timer == GameDaysPassed - 27

The difference is always going to be exactly 57, they will never equal one another. And equality is a bad comparison to make anyways with GameDaysPassed, since it actually returns a floating point value. It'll only return a natural number in a splitsecond, if at all. Best to use larger/smaller than comparisons instead.

 

I've written a new script for you that I'm quite sure will do what you want. There's a few comments in there to explain things.

ScriptName SearchlightTimer
float fTimeStamp

Begin GameMode

	; Save the time when the quest completed
	If GetStage Quest >= 100 && fTimeStamp == 0
		Set fTimeStamp to GameDaysPassed

	; Halt script if we don't have a timestamp yet
	Else
		Return
	EndIf

	; If xxx is disabled and 3 days has passed, enable it
	If GameDaysPassed - fTimeStamp >= 3 && xxx.GetDisabled
		xxx.Enable

	; If zzz is disabled and 15 days has passed, enable it
	ElseIf GameDaysPassed - fTimeStamp >= 15 && zzz.GetDisabled
		zzz.Enable

	; This can be copied for as many days/things to enable you want

	EndIf
End
Link to comment
Share on other sites

If you'd set it when you set the timer, then no, it wouldn't count up. But it still wouldn't work.

 

Say timer gets set at day 7, so the value is 37.

 

Three days after, the first condition is supposed to be true, but it will evaluate to 37 == -17, which is false. You would need to subtract by 3 instead of 27.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...