Triggering in a Certain Order

Post » Mon Mar 14, 2011 2:28 pm

I have a scenario where the player must stand on three different pressure plates in the floor, and they must stand on them one at a time, IN THE PROPER ORDER. If the player stands on each one in the proper order, some doors will open. If they stand on them in the WRONG order, then a floating activator in the middle of the room will cast several rounds of lightning at all within the room, and the player will be locked out from trying the puzzle again until the room resets in 3 days. And I am having a heck of a time trying to figure out how to script this svcker. As usual I'm working on this script while I'm only half awake, so I'm probably overlooking the obvious and also making the scripts more complicated than they need to be, but I've been at this svcker for hours upon hours and the scripts have went through more iterations than I can count. :(

This is where my scripts currently stand:

--------------------------------------------------------------------------------------------
The 1st pressure plate (activator) - WORLD REF: StrDpREF3LordsFloorTrig01
scn StrDp3LordsPuzzPressurePlate01SCRIPTshort Activatedshort PuzzleSolvedBegin GameMode	if (Activated == 0)		if (GetDistance player < 64)			set Activated to 1			PlayGroup forward 1			PlaySound3D TRPSwitchStoneStart			set StrDpREF3LordsWarder.FirstPlateTriggered to 1			set StrDpREF3LordsWarder.CheckCount01 to 1		endif	endifEndBegin OnReset	if (PuzzleSolved == 0)		Reset3DState		set Activated to 0	endifEnd



--------------------------------------------------------------------------------------------
The 2nd pressure plate (activator) - WORLD REF: StrDpREF3LordsFloorTrig02
scn StrDp3LordsPuzzPressurePlate02SCRIPTshort Activatedshort PuzzleSolvedBegin GameMode	if (Activated == 0)		if (GetDistance player < 64)			set Activated to 1			PlayGroup forward 1			PlaySound3D TRPSwitchStoneStart			set StrDpREF3LordsWarder.SecondPlateTriggered to 1			set StrDpREF3LordsWarder.CheckCount02 to 1		endif	endifEndBegin OnReset	if (PuzzleSolved == 0)		Reset3DState		set Activated to 0	endifEnd



--------------------------------------------------------------------------------------------
The 3rd pressure plate (activator) - WORLD REF: StrDpREF3LordsFloorTrig03
scn StrDp3LordsPuzzPressurePlate03SCRIPTshort Activatedshort PuzzleSolvedBegin GameMode	if (Activated == 0)		if (GetDistance player < 64)			set Activated to 1			PlayGroup forward 1			PlaySound3D TRPSwitchStoneStart			set StrDpREF3LordsWarder.ThirdPlateTriggered to 1			set StrDpREF3LordsWarder.CheckCount03 to 1		endif	endifEndBegin OnReset	if (PuzzleSolved == 0)		Reset3DState		set Activated to 0	endifEnd



--------------------------------------------------------------------------------------------
The controller that watches the order in which the switches get activated and dishes out punishment if the plates are activated in the WRONG order. I've went through well over a dozen iterations of this script and it's become unwieldy, so I apologize for that.
(activator) - WORLD REF: StrDpREF3LordsWarder
scn StrDp3LordsMonitorSCRIPTref MySelfshort CheckCountshort CheckCount01short CheckCount02short CheckCount03short FirstPlateTriggeredshort FirstPlateSetshort SecondPlateTriggeredshort SecondPlateSetshort ThirdPlateTriggeredshort ThirdPlateSetshort PlateCountshort Punishmentshort PuzzleSolvedshort CastShockSpellshort ShockTimer01Onfloat ShockTimer01short ShockTimer02Onfloat ShockTimer02short ShockTimer03Onfloat ShockTimer03short ShockTimer03Onfloat ShockTimer03short ShockTimer04Onfloat ShockTimer04short ShockTimer05Onfloat ShockTimer05Begin GameMode	if (CheckCount01 == 1)		set CheckCount to 0		if (FirstPlateTriggered == 1)			if (SecondPlateTriggered == 0)				if (ThirdPlateTriggered == 0)					if (FirstPlateSet == 0)						set FirstPlateSet to 1						set PlateCount to (PlateCount + 1)					endif				endif			endif		else			set PlateCount to 0			set StrDpREF3LordsFloorTrig01.Activated to 1			set StrDpREF3LordsFloorTrig02.Activated to 1			set StrDpREF3LordsFloorTrig03.Activated to 1			set Punishment to 1		endif	endif	if (CheckCount02 == 1)		if (SecondPlateTriggered == 1)			if (FirstPlateTriggered == 1)				if (ThirdPlateTriggered == 0)					if (SecondPlateSet == 0)						set SecondPlateSet to 1						set PlateCount to (PlateCount + 1)					endif				endif			endif		else			set PlateCount to 0			set StrDpREF3LordsFloorTrig01.Activated to 1			set StrDpREF3LordsFloorTrig02.Activated to 1			set StrDpREF3LordsFloorTrig03.Activated to 1			set Punishment to 1		endif	endif	if (CheckCount03 == 1)		if (ThirdPlateTriggered == 1)			if (FirstPlateTriggered == 1)				if (SecondPlateTriggered == 1)					if (ThirdPlateSet == 0)						set ThirdPlateSet to 1						set PlateCount to (PlateCount + 1)					endif				endif			endif		else			set PlateCount to 0			set StrDpREF3LordsFloorTrig01.Activated to 1			set StrDpREF3LordsFloorTrig02.Activated to 1			set StrDpREF3LordsFloorTrig03.Activated to 1			set Punishment to 1		endif	endif	if (PlateCount == 3) && (PuzzleSolved == 0)		set PuzzleSolved to 1		set PlateCount to 0		set StrDpREF3LordsFloorTrig01.PuzzleSolved to 1		set StrDpREF3LordsFloorTrig02.PuzzleSolved to 1		set StrDpREF3LordsFloorTrig03.PuzzleSolved to 1		StrDp3LordsTombGate01.Unlock 1		StrDp3LordsTombGate02.Unlock 1		StrDp3LordsTombGate03.Unlock 1		StrDp3LordsTombGate01.Activate		StrDp3LordsTombGate02.Activate		StrDp3LordsTombGate03.Activate		PlaySound3D TRPGearsClaws	endif	if (Punishment == 1)		set Punishment to 0		Enable		set MySelf to GetSelf		set CastShockSpell to 1		set ShockTimer01On to 1	endif	if (CastShockSpell == 1)		set CastShockSpell to 0		Cast StrDpSPTumarillBlastArrowAOE MySelf	endif	if (ShockTimer01On == 1)		set ShockTimer01 to ShockTimer01 + GetSecondsPassed		if ( ShockTimer01 > 2 )			set ShockTimer01On to 0			set ShockTimer01 to 0			set CastShockSpell to 1			set ShockTimer02On to 1		endif	endif	if (ShockTimer02On == 1)		set ShockTimer02 to ShockTimer02 + GetSecondsPassed		if ( ShockTimer02 > 2 )			set ShockTimer02On to 0			set ShockTimer02 to 0			set CastShockSpell to 1			set ShockTimer03On to 1		endif	endif	if (ShockTimer03On == 1)		set ShockTimer03 to ShockTimer03 + GetSecondsPassed		if ( ShockTimer03 > 2 )			set ShockTimer03On to 0			set ShockTimer03 to 0			set CastShockSpell to 1			set ShockTimer04On to 1		endif	endif	if (ShockTimer04On == 1)		set ShockTimer04 to ShockTimer04 + GetSecondsPassed		if ( ShockTimer04 > 2 )			set ShockTimer04On to 0			set ShockTimer04 to 0			set CastShockSpell to 1			set ShockTimer05On to 1		endif	endif	if (ShockTimer05On == 1)		set ShockTimer05 to ShockTimer05 + GetSecondsPassed		if ( ShockTimer05 > 2 )			set ShockTimer05On to 0			set ShockTimer05 to 0			set CastShockSpell to 1		endif	endifEndBegin OnReset	Disable	if (PuzzleSolved == 0)		set PlateCount to 0		set CheckCount01 to 0		set CheckCount02 to 0		set CheckCount03 to 0		set FirstPlateTriggered to 0		set SecondPlateTriggered to 0		set ThirdPlateTriggered to 0		set FirstPlateSet to 0		set SecondPlateSet to 0		set ThirdPlateSet to 0		Disable	endifEnd



Where have I gone wrong? I'd appreciate any help anyone can give me. ;)
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am

Post » Mon Mar 14, 2011 6:49 pm

Just a follow-up before I drag my sleepy self off to bed. All 4 activators are set to persistent references and I've had the scenario working to some degree in several iterations. So far I've had it open the gates no matter WHAT order I step on the plates each time (and never punish for the wrong order), and then I've also had it punish each time (even when the plates are activated in the CORRECT order.

Okay, I'm off to slumber land. I hope when I take this back up tomorrow, after much needed rest, that either I'll look at the code and slap myself for being a dunce, or, if I'm still at a loss, perhaps someone here will have pointed out my blunder. :P
User avatar
ShOrty
 
Posts: 3392
Joined: Sun Jul 02, 2006 8:15 pm

Post » Tue Mar 15, 2011 4:44 am

If sequence is important, then you really need a variable to hold the previous plate number, so you can check for the right one each time a new plate is used.

Activating any plate should set the same variable in the quest script to indicate a check is needed, and then the gamemode block in the quest script turns it back off after the check is made. You need the fQuestDelayTime set less than the time it takes to get to the next plate, but the default may be OK. Replace all your CheckCount variables with one.

The main logic is then approximately
if CheckCount   if FirstPlateTriggered      if PreviousPlate == 0         Set PreviousPlate to 1         Set CheckCount to 0      else        Set Punishment to 1      endif   elseif SecondPlateTriggered     if PreviousPlate == 1       set PreviousPlate to 2  ...endif 

You'd also set CheckCount and PreviousPlate back to zero after zapping the guy.
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Tue Mar 15, 2011 12:57 am

After getting some sleep and then coming back here to see your response, I want to slap myself for not seeing the obvious and, once again, making something that's simple into something overly complicated. It's my bane.

Thank you, ghastley. :P
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm


Return to IV - Oblivion