Jump to content

Why doesn't this script work?


DamarStiehl

Recommended Posts

Created a Hostile magic effect, type script, area 100, fire and forget, on self.

 

Attached this script:

 

Scriptname zzApplyEffectoTargetsinAreaScript extends ActiveMagicEffect  

Spell property EffectToApply Auto

event onEffectStart(Actor akTarget, Actor akCaster)

    Debug.Trace("Magic effect was started on " + akTarget)
    EffectToApply.cast (none, akTarget)

endEvent

 

The property EffecttoApply is populated with Fireball spell.

 

Added this magic effect to a spell. When I cast it, NPCs react to it as a hostile action (I get a bounty, NPCs get in fighting stance, etc). But nothing else happens. I don't see a debug message, and theoretically everyone should have a fireball cast on them, but it doesn't happen either. What am I doing wrong?

 

Help appreciated.

Link to comment
Share on other sites

Fair point. By the way of testing, I changed caster from "None" to "player" and fireballs were lobbed in the general direction of affected NPCs (though imprecisely). That's not entirely what I was going for though.

 

Here's what I did next:

 

1. Created an invisible (meshless) activator, named it zzSpellCaster and stuck it in the Unowned Cell.

2. Created a reference for this activator, zzSpellCasterRef.

3. Wrote this:

 

 

Scriptname zzApplyEffectoTargetsinAreaScript extends ActiveMagicEffect  

Spell property EffectToApply Auto
ObjectReference property zzSpellCasterRef Auto

actor target

event onEffectStart(Actor akTarget, Actor akCaster)
    
    target = akTarget

endEvent

event onUpdate()
    
    Debug.Notification ("there should be a cast now")
    int random = Utility.RandomInt(1, 5)
    utility.wait(random)
    zzSpellCasterRef.moveTo (target)
    EffectToApply.Cast(zzSpellCasterRef, target)

endEvent

 

The way I see it, the activator should randomly move between affected NPCs and casting the EffectToApply on them (fireball). But it does not happen. NPCs react as being affected by the hostile spell, but the rest of it never happens.

 

Any more pointers? Thanks very much for help thus far.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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