Jump to content

Objects Respond to Spells?


jdietz

Recommended Posts

Remember in oblivion, with Vahtacen Ruins and the cool turning door? I'm trying to write a similar script that will cause an pillar to play a set of three animations on being hit by certain order of spells until a door opens at the bottom. IsSpellTarget would be a great function to use, except all i can figure out how to use is actor.isSpellTarget. can it target objects? Edited by jdietz
Link to comment
Share on other sites

It may well be easier than that. There is an event OnHit which can be attached to the object. It returns the value of the source so you can evaluate the incoming spells and do different things for each. For example:

 

GlobalVariable Property FirstSpell auto
GlobalVariable Property SecondSpell auto
Door Property MyDoor auto
Spell Property SpellToCheck1 auto
Spell Property SpellToCheck2 auto
Spell Property SpellToCheck3 auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

int Source = akSource.GetFormID()
if(Source == SpellToCheck1.GetFormID() && FirstSpell.GetValue() == 0)
	FirstSpell.SetValue(1)
	Debug.Notification("First spell successfully cast")
	; Run first animation
;	elseif(Source != SpellToCheck2.GetFormID() && FirstSpell.GetValue() == 1)
;		FirstSpell.SetValue(0)
;		Debug.Notification("Second spell wrong - Sequence Reset")
	; Stop/reset first animation
elseif(Source == SpellToCheck2.GetFormID() && FirstSpell.GetValue() == 1)
	SecondSpell.SetValue(1)
	Debug.Notification("Second spell successfully cast")
	; Run second animation
;	elseif(Source != SpellToCheck3.GetFormID() && SecondSpell.GetValue() == 1)
;		Debug.Notification("Third Spell Wrong - Sequence Reset")
;		FirstSpell.SetValue(0) ; Remove this to only go back one step, instead of back to the start
;		SecondSpell.SetValue(0)
	; Stop/reset second animation
elseif(Source == SpellToCheck3.GetFormID() && SecondSpell.GetValue() == 1)
	Debug.Notification("Third spell successfully cast")
	; Open MyDoor
else
	Debug.Notification("First spell wrong")
endif

EndEvent

This will detect the incoming source and evaluate whether it's the correct spell, in the correct sequence. There are commented-out conditions to "reset" the sequence if an incorrect spell is cast. It requires two custom Global Variables be created with an initial value of 0.

Link to comment
Share on other sites

Yes, weapon and projectiles can also be returned. From the wiki page:

 

akSource: The Weapon, Spell, Explosion, Ingredient, Potion, or Enchantment that hit this reference.

akProjectile: The Projectile that hit this reference.

 

The source will return the weapon or spell. The projectile is returned as akProjectile, not akSource.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...