SCN moX0AAMWTrapBlind


Short ControlXnoPROBE
Short ControlXyesProbe
Short button
short XDisarmSwitch
ref  XProbeID
ref  XSpellID

Begin OnActivate

	Set XProbeID to "Lockpick"
	Set XSpellID to "TestFireball"

	If XDisarmSwitch == 1

; Trap Previously Disarmed or Triggered so open and go.
		Activate
		Return
	ENDIF


	If XDisarmSwitch == 0 && IsActionRef Player && Player.GetItemCount XProbeID >= 1

; PC has at least one Probe, so Untrap and Open.

		MessageBox "This Door is Trapped. You can Untrap it with a Probe or you can trigger the trap.", "Use Probe", "Open Door without using Probe", "Do Nothing"
		Set ControlXyesProbe to 1
		SET ControlXnoProbe  to 0	



	ElseIf XDisarmSwitch == 0 && IsActionRef Player && Player.GetItemCount XProbeID < 1

; PC does not have a Probe so get confirmation for triggering trap.  

		MessageBox "This door is Trapped, but you do not have a Probe to disarm it. Would you like to Trigger the Trap?", "Yes", "No"
		Set ControlXyesProbe to 0
		Set ControlXnoProbe to 1


	ENDIF

END


Begin GameMode

	If ( ControlXyesProbe == 0 ) && (ControlXnoProbe ==0)
		Return 								;  Nothing to do, so save on Processing.
	ENDIF



	If ( ControlXyesProbe == 1 ) || (ControlXnoProbe == 1)
		Set button to GetButtonPressed 				; A MenuBox has Opened so watch out for buttons pressed.

		If ( button == -1 )
			Return									; No Button Pressed this Frame, so Skip and Save on Processing



		ElseIf (( button == 0 ) && ControlXnoProbe == 1 && ControlXyesProbe == 0) || (( button == 1 ) && ControlXYesProbe == 1 && ControlXnoProbe == 0)

; PC has chosen to Trigger Trap so punish him\her and remove the Trap.
			Cast XSpellID Player
			Message "Trap Triggered"
			Set XDisarmSwitch to 1
			Set ControlXnoProbe to 0
			Set ControlXyesProbe to 0


		ElseIf (( button == 2 ) && ControlXnoProbe == 1 && ControlXyesProbe == 0) || (( button == 3 ) && ControlXYesProbe == 1 && ControlXnoProbe == 0)		

; PC has chosen to leave the Trapped Door alone, so do nothing.


			Set ControlXnoProbe to 0
			Set ControlXyesProbe to 0
			Return


		ElseIf (( button == 0 ) && ControlXYesProbe == 1 && ControlXnoProbe == 0)				

; PC has chosen to use the Probe to disarm the Trap, so do that.


			Message "Door untrapped successfully!"
			Player.RemoveItem XProbeID 1
			Set ControlXnoProbe to 0
			Set ControlXyesProbe to 0
			Set XDisarmSwitch to 1



		ENDIF	
	ENDIF
END	