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)
 
(2 intermediate revisions by one other user not shown)
Line 20: Line 20:
; Stop this flame trap from casting
; Stop this flame trap from casting
FlameTrap.InterruptCast()
FlameTrap.InterruptCast()
</source>
</source><br>
<br>
<source lang="papyrus">


;This script example is extending from activemagiceffect.
<source lang="papyrus">;This example script extends ActiveMagicEffect
;The idea is to interrupt a spell the target has.


;properties
float Property max auto
Spell property IceStorm1 auto ; spell chosen in the property window is Ice Storm


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


;akTarget = the enemy this spell effect will be placed on.
Event OnEffectStart(Actor akTarget, Actor akCaster)
        if akTarget.HasSpell(IceStorm1) ;if the target has a certain spell, you would like to interrupt, use a conditional.
          akTarget.InterruptCast() ;then it will be interrupted by this line.
      endif
EndEvent
EndEvent
</source>
</source>
The result is if the enemy attempts to cast the spell Ice Storm, he will be unable to complete the cast.<br>
Very useful for enemies that use wards spells - it will still appear briefly but they will be unable to "turtle" with it because of the script.


== See Also ==
== See Also ==
*[[ObjectReference Script]]
*[[ObjectReference Script]]
*[[Cast - Spell]]
*[[Cast - Spell]]

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]