Difference between revisions of "InterruptCast - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Terra Nova
imported>Cipscis
(Cleaned up larger example a bit, mainly removing lines that didn't do anything, and trying to make the script do what I've guessed it's intended to do)
 
Line 22: Line 22:
</source><br>
</source><br>


<source lang="papyrus">
<source lang="papyrus">;This example script extends ActiveMagicEffect
;This example script extends from activemagiceffect


float property max auto  
float Property max auto


Event OnEffectStart(Actor akTarget, Actor akCaster)
Event OnEffectStart(Actor akTarget, Actor akCaster)
    ; Lets say you want to restore your health through a script.    
 
    Game.GetPlayer()== akTarget
; Let's say you want to restore your health through a script.
    akTarget.GetAV("health")
If (Game.GetPlayer() == akTarget)
    akTarget.GetActorValuePercentage("health")
If (akTarget.GetActorValuePercentage("health") >= max)
if akTarget.GetActorValuePercentage("health") == max
akTarget.InterruptCast()
    akTarget.InterruptCast()
Debug.Notification("You cannot cast this spell at this time")
    debug.notification("You cannot cast this spell at this time")
; Because your health is at 100% (represented by 1.0) this casting will be interrupted until the condition is met.
    ;Because your health is at 100%(1.0 from the float) this casting will be interrupted until the condition is met.
ElseIf (akTarget.GetActorValuePercentage("health") <= max)
else
akTarget.RestoreAV("health", 300)
    akTarget.GetActorValuePercentage("health") <= max
EndIf
    akTarget.RestoreAV("health", 300)
EndIf
endif
 
EndEvent
EndEvent
;Using this for a conditional statement is best for beginners before moving on to complex ways of using it.
</source>
</source>



Latest revision as of 21:33, 28 February 2012

Member of: ObjectReference Script

Interrupts and stops any spell-casting this object might be doing.

Syntax[edit | edit source]

Function InterruptCast() native

Parameters[edit | edit source]

None.

Return Value[edit | edit source]

None.

Examples[edit | edit source]

; Stop this flame trap from casting
FlameTrap.InterruptCast()


;This example script extends ActiveMagicEffect

float Property max auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

	; Let's say you want to restore your health through a script.
	If (Game.GetPlayer() == akTarget)
		If (akTarget.GetActorValuePercentage("health") >= max)
			akTarget.InterruptCast()
			Debug.Notification("You cannot cast this spell at this time")
			; Because your health is at 100% (represented by 1.0) this casting will be interrupted until the condition is met.
		ElseIf (akTarget.GetActorValuePercentage("health") <= max)
			akTarget.RestoreAV("health", 300)
		EndIf
	EndIf

EndEvent

See Also[edit | edit source]