Difference between revisions of "User talk:Lisselli"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
imported>Lisselli
Line 8: Line 8:
Spell SpellSource
Spell SpellSource


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



Revision as of 20:35, 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
                    ; Things you want to do with SpellSource
		endif
	endif
EndEvent
	

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