Jump to content

Oblivion Mine Script Edit Problem


Ranokoa

Recommended Posts

I'm trying to get this script to work so it only begins to destruct when the player pulls a lever that is parented to the mines. Here is my edited version of the script, I thought a simple change would suffice but I was never good at editing existing trap scripts to change function. Anyone wanna give me a hand? Would be much appreciated.

 

scriptname RMineTrapScriptActivate

;Detonates mine using an arrow or spell

float mineTimer
float chainTimer
ref mySelf
ref myParent
short next
short busyUP

short SpellRank
short activated
short chainActivate

short stage
short detonated

;stage 0 = untriggered
;stage 1 = triggered but not detonated
;stage 2 = BOOM
;stage 3 = detonated
;stage 4 = disabled after 10 seconds


begin OnActivate

if SpellRank == 0
	;This section will choose the trap spell based on the PC's level (hopefully)
	if player.GetLevel <= 4
		set SpellRank to 1
	elseif ( player.GetLevel >= 5) && ( player.GetLevel <= 8 )
		set SpellRank to 2
	elseif ( player.GetLevel >= 9 ) && ( player.GetLevel <= 12 )
		set SpellRank to 3
	elseif ( player.GetLevel >= 13 ) && ( player.GetLevel <= 16 )
		set SpellRank to 4
	elseif ( player.GetLevel >= 17 ) && ( player.GetLevel <= 20 )
		set SpellRank to 5
	elseif ( player.GetLevel >= 21 ) && ( player.GetLevel <= 24 )
		set SpellRank to 6
	endif
endif

if activated == 0
	set mySelf to getSelf
	set myParent to getParentRef
	set activated to 1
endif

if Detonated == 1
	return
endif

if activated == 1	
	if getDistance Player <= 330 && detonated == 0 && stage == 0
		set stage to 1
		;messagebox "stage 1"
	endif

	if stage == 1 && busyUP == 0
		playgroup Forward 0
		set mineTimer to 8
		set busyUP to 1
	endif

	;Distance check for deactivation
	if stage == 1 && getDistance player >= 330
		if mineTimer >= 7  && chainActivate == 0
			playgroup Backward 0
			set stage to 0
			set mineTimer to 0
		endif
	endif

	if stage == 1 && mineTimer <= 6
		set stage to 2
		;messagebox "Stage 2"
	endif

	if stage == 2
		if SpellRank == 1
			cast TRAPFireDamageSelf01 player
		elseif SpellRank == 2
			cast TRAPFireDamageSelf02 player
		elseif SpellRank == 3
			cast TRAPFireDamageSelf03 player
		elseif SpellRank == 4
			cast TRAPFireDamageSelf04 player
		elseif SpellRank == 5
			cast TRAPFireDamageSelf05 player
		elseif SpellRank == 6
			cast TRAPFireDamageSelf06 player
		endif

		playgroup Unequip 0
		set stage to 3
		set chainTimer to 2
		set next to 1
	endif

	if stage == 3 && mineTimer <= 0
		disable mySelf
		set stage to 4
		set activated to 2
		set detonated to 1
		;messagebox "stage 3"
	endif

	;Check if anim is playing
	if isAnimPlaying == 0 && busyUP == 1
		set busyUP to 0
	endif

	;Timer for deactivating mine
	if mineTimer > 0
		set mineTimer to mineTimer - getSecondsPassed
	endif

	;Timer for linked parent
	if chainTimer > 0
		set chainTimer to chainTimer - getSecondsPassed
	endif

	; daisy-chain activation
	if next == 1 && chainTimer <=0
		set next to 0
		myParent.activate mySelf 1
	endif
endif
end



begin onTrigger

;Detonates right away
if detonated == 0

	if SpellRank == 1
		cast TRAPFireDamageSelf01 player
	elseif SpellRank == 2
		cast TRAPFireDamageSelf02 player
	elseif SpellRank == 3
		cast TRAPFireDamageSelf03 player
	elseif SpellRank == 4
		cast TRAPFireDamageSelf04 player
	elseif SpellRank == 5
		cast TRAPFireDamageSelf05 player
	elseif SpellRank == 6
		cast TRAPFireDamageSelf06 player
	endif
	set detonated to 1
	playgroup Unequip 0
	set stage to 3
	set chainTimer to 2
	set next to 1
endif

end	
	
begin onActivate

if stage == 0 &&  isActionRef player == 0 &&  isActionRef mySelf == 0
	set stage to 1
	set chainActivate to 1
	set next to 1
	set chainTimer to 2
endif

end	

begin onReset

reset3DState ;puts animations and havok stuff back in place
set mineTimer to 0 ;whatever state variables should go back to 
set chainTimer to 0 ;initial values
set next to 0
set busyUP to 0
set Spellrank to 0
set Detonated to 0
set activated to 0
set chainActivate to 0

end




 

What happens is that when I get to the mines they are already detonated, they don't even wait for a player distance, they just go kerboom on themselves. I want it to wait to be activated and activated by only a parent, rather than self activated and waiting for the player to get close.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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