User talk:Lisselli

From the CreationKit Wiki
Revision as of 20:31, 5 November 2016 by imported>Lisselli
Jump to navigation Jump to search

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

AUTO STATE CatchingSpell
	Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
  	bool abBashAttack, bool abHitBlocked)
		If akSource as Spell
			GoToState("Done")
			SpellSource = akSource as Spell
			if GetSpellSkill(SpellSource as Spell, DestructionSpells) == false
				debug.notification("The spell was not a Destruction Spell")
				return
			endif
		endif
	EndEvent
ENDSTATE

STATE Done
	Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
 	 bool abBashAttack, bool abHitBlocked)
	 ;empty
	EndEvent
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