Jump to content

Need Help Scripting a Timed Sequence!


MrFisse

Recommended Posts

So i've tried your script now Cipscis and it works great. Think you forgot a "set stage" in the final one but managed to work that one out.

Think i really understand the iStage system now, so big kudos to you. And yes it was on your site i read up on the Timed Stage. So thanks again for that :)

 

Here is the code as it looks now, might help someone in the future.

 

ScriptName LightSwitchScriptTEST

float fTimer
int iStage
; 0 - All lights disabled
; 1 - Wait time before first light is activated
; 2 - Enable first light
; 3 - Enable second light
; 4 - Enable third light
; 5 - Enable fourth light
; 6 - All lights enabled
; 7 - Disable all lights

int bState

Begin OnActivate

	if iStage == 6
			set iStage to 7

	elseif iStage == 0
			set iStage to 1
	endif

End

Begin GameMode

	if fTimer > 0
			set fTimer to fTimer - GetSecondsPassed

	elseif iStage == 1
			set iStage to 2
			set fTimer to 20
			
	

	elseif iStage == 2
			set iStage to 3
			set fTimer to 3
			"WalkwayStage1REF".Enable
	elseif iStage == 3
			set iStage to 4
			set fTimer to 3
			"WalkwayStage2REF".Enable
	elseif iStage == 4
			set iStage to 5
			set fTimer to 3
			"WalkwayStage3REF".Enable
	elseif iStage == 5
	set iStage to 6
			"WalkwayStage4REF".Enable
			

	elseif iStage == 7
			"WalkwayStage1REF".Disable
			"WalkwayStage1REF".Disable
			"WalkwayStage1REF".Disable
			"WalkwayStage4REF".Disable
				
	set iStage to 0
	endif

End

 

Gonna try to go a bit further with this one now. But this makes a really nice effect when the vault door opens :)

*woho*

Link to comment
Share on other sites

Edited the code further and implemented it to the switch for the Vault Door.

Added code so when the exterior console is activated (since its the one that probably will be used when the player leaves the Vault) it will shut down all the lights in the complex. Since there are other switches inside that also alters the light in different sections and for the walkway that will light up in sequence when the vault door is activated from the outside. This to prevent for example if you activate the outside switch to close the vault door and if the lights inside would be turned of manually inside and the vault way would be lit up then when you open the door from the outside the walkway wouldn't light up again since it was already activated.

Don't know if this is a complicated way to do things, but it works atleast. I want the Vault to be unlit if you activate the door from the outside so i think this is the way to do it?

Dont know if the last section with the iStage is needed now since the lights will always be turned of if the exterior console is activated by the player.

 

Here's the code

scn GenericControlPodScriptLightSuequence
;See V112 for generic setup.


short mode
ref myLink
float fTimer
int iStage
; 0 - All lights disabled
; 1 - Wait time before first light is activated
; 2 - Enable first light
; 3 - Enable second light
; 4 - Enable third light
; 5 - Enable fourth light
; 6 - All lights enabled
; 7 - Disable all lights

int bState
begin onActivate

	if IsActionRef player == 1
			"172mainswitchElecBox1REF".Disable
			"172mainswitchREF".Disable
			"WalkwayStage1REF".Disable
			"WalkwayStage2REF".Disable
			"WalkwayStage3REF".Disable
			"WalkwayStage4REF".Disable
                   set iStage to 0
	endif


	if iStage == 6
			set iStage to 7

	elseif iStage == 0
			set iStage to 1
	endif



if IsActionRef player == 1
	set myLink to getLinkedRef			;the linked ref should be the door.
	if ((myLink.getOpenState == 3) || (myLink.getOpenState == 1)) && mode != 2
		playgroup Forward 0	
		set mode to 2
		activate myLink	
	endif
endif


	if iStage == 6
			set iStage to 7

	elseif iStage == 0
			set iStage to 1
	endif

End
begin gameMode
if fTimer > 0
			set fTimer to fTimer - GetSecondsPassed
elseif iStage == 1
			set iStage to 2
			set fTimer to 18
			
	

	elseif iStage == 2
			set iStage to 3
			set fTimer to 2
			"WalkwayStage1REF".Enable
	elseif iStage == 3
			set iStage to 4
			set fTimer to 2
			"WalkwayStage2REF".Enable
	elseif iStage == 4
			set iStage to 5
			set fTimer to 2
			"WalkwayStage3REF".Enable
	elseif iStage == 5
	set iStage to 6
			"WalkwayStage4REF".Enable
			

	elseif iStage == 7
			"WalkwayStage1REF".Disable
			"WalkwayStage2REF".Disable
			"WalkwayStage3REF".Disable
			"WalkwayStage4REF".Disable
				
	set iStage to 0
	endif

if (mode == 2)
	if (isAnimPlaying == 0)
		set myLink to getLinkedRef		
		playgroup Left 1				
		set mode to 3
		myLink.activate player
	endif
endif

end

Link to comment
Share on other sites

Used your script further now and applied it to my generators. Works almost perfect :)

Looks really cook when you start up the vault.

 

There is however one issue and that is when i activate the Generators inside the vault it is supposed to deactivate the walkway lights in the sequence where the the generators are starting. I've put the lights to 4 diffrent parents. And it works for the first three but the fourth and last wont get disabled for some reason. Looked through the scripts but cant find anything that explains why it behaves like this. The activator outside the vault shuts it down properly so i would guess that the parent is set up right.

 

And another a bit less important is that when you use the activator outside the vault and the door opens and the sequence script runs like it should lighting up the alleyway. Then when you go up to the Generator switch inside an use the activator there the script don't start. Until you press it a second time. Not a big issue really but i don't understand why. And when you exit the vault and close the vault door and then opens it again there is a 10 second delay before the alleyway light script runs. Don't know why it does that either? Does it take time for the float/timer to reset or something?

 

 

Here is the code if you have time to check it and see if you see anything strange in there. Know it isn't easy when it it's someone else naming on world items etc. But who knows you maybe can make something of it.

It is the "WalkwayStage4REF".Disable that doesnt seem to work in the second script (inside the vault). You can see it flashing i.e i think it does a fast disable and then enables instantly again.

 

Script for the activator outside the vault (Kills all the lights, Start the alleyway lightup and opens/closes the vault door)

 

scn GenericControlPodScriptLightSuequence

short mode
ref myLink
float fTimer
int iStage
; 18 - All lights disabled
; 19 - Wait time before first light is activated
; 20 - Enable first light
; 21 - Enable second light
; 22 - Enable third light
; 23 - Enable fourth light
; 24 - All lights enabled
; 25 - Disable all lights

int bState
begin onActivate

	if IsActionRef player == 1
			"172mainswitchElecBox1REF".Disable
			"172mainswitchREF".Disable
			"WalkwayStage1REF".Disable
			"WalkwayStage2REF".Disable
			"WalkwayStage3REF".Disable
			"WalkwayStage4REF".Disable
			"172FXGenerator1BrightSpot5".Disable		
			"172Generator1Light".Disable				
			"172FXGenerator1BrightSpot4".Disable
			"172FXGenerator1BrightSpot3".Disable
			"172Generator1Bigspark2".Disable
			"172FXGenerator2BrightSpot5".Disable
			"172Generator2Light".Disable
			"172FXGenerator1BrightSpot2".Disable
			"172FXGenerator2BrightSpot4".Disable
			"172FXGenerator1BrightSpot1".Disable
			"172FXGenerator2BrightSpot3".Disable
			"172Generator1Light".Disable
			"172Generator1Bigspark1".Disable
			"172Generator2Bigspark2".Disable
			"172Generator1spark1".Disable
			"172FXGenerator2BrightSpot2".Disable
			"172Generator1spark3".Disable
			"172FXGenerator2BrightSpot1".Disable
			"172Generator2Light".Disable
			"172Generator2Bigspark1".Disable
			"172Generator1spark4".Disable
			"172Generator2spark1".Disable
			"172Generator1spark2".Disable
			"172Generator2spark2".Disable
			"172Generator2spark3".Disable
			"172GeneratorSmokeWisps".Disable
			"172Generator2spark4".Disable
			"172GeneratorBOXSpark1".Disable
			"172GeneratorBOXLight3".Disable
			"172GeneratorBOXSpark2".Disable
			"172GeneratorBOXLight2".Disable
			"172GeneratorBOXLight1".Disable
				set iStage to 18
	endif


	if iStage == 24
			set iStage to 25

	elseif iStage == 18
			set iStage to 19
	endif



if IsActionRef player == 1
	set myLink to getLinkedRef	;the linked ref should be the door.
	if ((myLink.getOpenState == 3) || (myLink.getOpenState == 1)) && mode != 2
		playgroup Forward 0	
		set mode to 2
		activate myLink	
	endif
endif

End
begin gameMode
if fTimer > 0
			set fTimer to fTimer - GetSecondsPassed
elseif iStage == 19
			set iStage to 20
			set fTimer to 18
			
	

	elseif iStage == 20
			set iStage to 21
			set fTimer to 1
			"WalkwayStage1REF".Enable
	elseif iStage == 21
			set iStage to 22
			set fTimer to 1
			"WalkwayStage2REF".Enable
	elseif iStage == 22
			set iStage to 23
			set fTimer to 1
			"WalkwayStage3REF".Enable
	elseif iStage == 23
			"WalkwayStage4REF".Enable
	endif

if (mode == 2)
	if (isAnimPlaying == 0)
		set myLink to getLinkedRef	
		playgroup Left 1	
		set mode to 3
		myLink.activate player
	endif
endif

end

 

Script for the activator inside the vault (Starts the generator and kills the alleyway lights, almost ;) )

 

ScriptName 172GeneratorStartupScript


float fTimer
int iStage
; 0 - Generator disabled
; 1 - Wait time before generator is enabled
; 2 - Stage 1 Generator 1 Starting
; 3 - Stage 2
; 4 - Stage 3 Generator 2 Starting
; 5 - Stage 4 
; 6 - Stage 5
; 7 - Stage 6
; 8 - Stage 7
; 9 - Stage 8
; 10 - Stage 9 Generator 1 Finished Starting
; 11 - Stage 10 
; 12 - Stage 11 Generator 2 Finished Starting
; 13 - Stage 12 Generator Box Getting Power
; 14 - Stage 13 Lights Enabled 
; 15 - Everything started
; 16 - Shutdown Generator
; 17 - Shutdown Lights


int bState
begin onActivate

	

	if iStage == 15
			set iStage to 16

	elseif iStage == 0
			set iStage to 1
	endif



End


begin gameMode
	if fTimer > 0
			set fTimer to fTimer - GetSecondsPassed
	
	elseif iStage == 1
			set iStage to 2
			set fTimer to 2
			
	

	elseif iStage == 2
			set iStage to 3
			set fTimer to 1
			"WalkwayStage1REF".Disable
			"172FXGenerator1BrightSpot5".Enable		
			"172Generator1Light".Enable
		


	elseif iStage == 3
			set iStage to 4
			set fTimer to 1
			"WalkwayStage2REF".Disable
			"172FXGenerator1BrightSpot4".Enable


	elseif iStage == 4
			set iStage to 5
			set fTimer to 1
			"WalkwayStage3REF".Disable
			"172FXGenerator1BrightSpot3".Enable
			"172Generator1Bigspark2".Enable
			"172FXGenerator2BrightSpot5".Enable
			"172Generator2Light".Enable

	
	elseif iStage == 5
			set iStage to 6
			set fTimer to 1
			"WalkwayStage4REF".Disable
			"172FXGenerator1BrightSpot2".Enable
			"172FXGenerator2BrightSpot4".Enable

	
	elseif iStage == 6
			set iStage to 7
			set fTimer to 1
			"172FXGenerator1BrightSpot1".Enable
			"172FXGenerator2BrightSpot3".Enable
			"172Generator1Light".Enable
			"172Generator1Bigspark1".Enable
			"172Generator2Bigspark2".Enable
		
	elseif iStage == 7
			set iStage to 8
			set fTimer to 1
			"172Generator1spark1".Enable
			"172FXGenerator2BrightSpot2".Enable


	elseif iStage == 8
			set iStage to 9
			set fTimer to 1
			"172Generator1spark3".Enable
			"172FXGenerator2BrightSpot1".Enable
			"172Generator2Light".Enable
			"172Generator2Bigspark1".Enable

	elseif iStage == 9
			set iStage to 10
			set fTimer to 1
			"172Generator1spark4".Enable
			"172Generator2spark1".Enable


	elseif iStage == 10
			set iStage to 11
			set fTimer to 1
			"172Generator1spark2".Enable
			"172Generator2spark2".Enable

	elseif iStage == 11
			set iStage to 12
			set fTimer to 1
			"172Generator2spark3".Enable
			"172GeneratorSmokeWisps".Enable

	elseif iStage == 12
			set iStage to 13
			set fTimer to 1
			"172Generator2spark4".Enable
			"172GeneratorBOXSpark1".Enable
			"172GeneratorBOXLight3".Enable

	elseif iStage == 13
			set iStage to 14
			set fTimer to 1
			"172GeneratorBOXSpark2".Enable
			"172GeneratorBOXLight2".Enable
			"172GeneratorBOXLight1".Enable
			"WalkwayStage1REF".Disable
			"WalkwayStage2REF".Disable
			"WalkwayStage3REF".Disable
			"WalkwayStage4REF".Disable

	elseif iStage == 14
			set iStage to 15
			set fTimer to 1
			"172mainswitchREF".Enable

	elseif iStage == 16
		set iStage to 17
			set fTimer to 2
			
			"172FXGenerator1BrightSpot5".Disable		
			"172Generator1Light".Disable				
			"172FXGenerator1BrightSpot4".Disable			
			"172FXGenerator1BrightSpot3".Disable
			"172Generator1Bigspark2".Disable
			"172FXGenerator2BrightSpot5".Disable
			"172Generator2Light".Disable		
			"172FXGenerator1BrightSpot2".Disable
			"172FXGenerator2BrightSpot4".Disable
			"172FXGenerator1BrightSpot1".Disable
			"172FXGenerator2BrightSpot3".Disable
			"172Generator1Light".Disable
			"172Generator1Bigspark1".Disable
			"172Generator2Bigspark2".Disable
			"172Generator1spark1".Disable
			"172FXGenerator2BrightSpot2".Disable
			"172Generator1spark3".Disable
			"172FXGenerator2BrightSpot1".Disable
			"172Generator2Light".Disable
			"172Generator2Bigspark1".Disable
			"172Generator1spark4".Disable
			"172Generator2spark1".Disable
			"172Generator1spark2".Disable
			"172Generator2spark2".Disable
			"172Generator2spark3".Disable
			"172GeneratorSmokeWisps".Disable
			"172Generator2spark4".Disable
			"172GeneratorBOXSpark1".Disable
			"172GeneratorBOXLight3".Disable
			"172GeneratorBOXSpark2".Disable
			"172GeneratorBOXLight2".Disable
			"172GeneratorBOXLight1".Disable
			


	elseif iStage == 17
			set iStage to 0
			"172mainswitchREF".Disable
			"172mainswitchElecBox1REF".Disable
			"WalkwayStage1REF".Enable
			"WalkwayStage2REF".Enable
			"WalkwayStage3REF".Enable
			"WalkwayStage4REF".Enable
	endif

end

 

 

Cheers !

Link to comment
Share on other sites

The only circumstances that I know of under which Enable or Disable will fail are when they are called on a reference with an Enable Parent. Is this the case with your references that won't be disabled?

 

In "GenericControlPodScriptLightSuequence", you're setting "iStage" to 18 before you check its value, is this intentional? You can also drop the "== 1" from your IsActionRef conditions - it makes no change to the outcome but does reduce the efficiency of your script slightly.

 

Cipscis

Link to comment
Share on other sites

Hm not anything that i can see atleast. The strange thing is that it works with the other script outside the vault using the same parameter. And in the script that fails to disable the reference is disabling the other stuff in that iStage. Looks like something else is enabling it again but i have no idea what it could be :/

iStage is set to 18 intentional since it is possible to make the script to fail using other scripts inside otherwise. It is probably solvable but since i think its taking water over my head digging into that right now. So much else to do in the vault :)

The generator rigg is looking really cool, now i just need to find a cool startup sound, cant seem to find any "powering up" sound in the geck so i guess i will have to look somewhere else for that :)

 

Some screens of the first part of the Vault :)

 

The generator in Vault 172 shutdown.

http://www.mrfisse.com/ScreenShot1.jpg

 

Vault 172 Control room, generator down

http://www.mrfisse.com/ScreenShot2.jpg

 

Vault 172 Generator fired up

http://www.mrfisse.com/ScreenShot3.jpg

 

Vault 172 Workstation Area

http://www.mrfisse.com/ScreenShot4.jpg

Link to comment
Share on other sites

  • Recently Browsing   0 members

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