Difference between revisions of "User talk:Lisselli"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
imported>Lisselli
Line 16: Line 16:
return
return
                 else
                 else
                    GoToState("Done")
                     ; Things you want to do with SpellSource
                     ; Things you want to do with SpellSource
endif
endif
endif
endif
EndEvent
EndEvent
 
STATE Done
ENDSTATE


Bool Function GetSpellSkill(Form kSource, Spell[] akSpells)
Bool Function GetSpellSkill(Form kSource, Spell[] akSpells)

Revision as of 20:38, 5 November 2016

Sandbox Page for when I need to post code on the forums. Because it doesn't allow indention..

Spell[] property DestructionSpells auto
; Add every playable destruction spell to this array property. Fireball, Firebolt, etc..
; Do not add the ones that are suffixed with Left, Right or BothHands. Example: Don't add ThunderboltLeftHand

Spell SpellSource

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
	If akSource as Spell
           SpellSource = akSource as Spell
		if GetSpellSkill(SpellSource as Spell, DestructionSpells) == false
			debug.notification("The spell was not a Destruction Spell")
			return
                else
                     GoToState("Done")
                    ; Things you want to do with SpellSource
		endif
	endif
EndEvent

STATE Done
ENDSTATE

Bool Function GetSpellSkill(Form kSource, Spell[] akSpells)
; This will return false if the source isn't a Destruction spell at all.

Int i = 0
Int iIndex = akSpells.Length

; loop through all spells til it reaches the last spell.
While i < iIndex
	if kSource == akSpells[i]
		return true
	else
		i += 1
	endif
EndWhile

return false

EndFunction