Need help: how to add spell to all bandit

Post » Sat Jan 10, 2015 10:10 pm

I have already added a cloak spell to player that may affect all NPC nearby

but I just want bandit to be affected.

Here is my code

Spoiler

Class Property EncClassBanditMelee Auto

Spell Property Myspell Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

ActorBase TargetBase = akTarget.GetBaseObject() as ActorBase
Class TargetClass = TargetBase.GetClass()

if TargetClass == EncClassBanditMelee

akTarget.AddSpell(Myspell)

endIf

EndEvent

Then I try the three bandit in the Bleak Falls Barrow, it dosn't work, Is that means the three bandit in the Bleak Falls Barrow are't EncBandit, or there is something wrong in my code

btw...my spell will add to Stump( the dog in Riverwood ) , so the dog is also a bandit

User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Sat Jan 10, 2015 9:44 pm

Make sure your class property is filled.

I recommend checking by Faction instead:

http://www.creationkit.com/IsInFaction_-_Actor

Yours may be more reliable but if your property is filled then perhaps there's an issue with checking against classes.

User avatar
Kayla Keizer
 
Posts: 3357
Joined: Tue Dec 12, 2006 4:31 pm

Post » Sat Jan 10, 2015 5:29 pm

Using IsInFaction() if you want to cover all bandits makes sense indeed. Just one note on cloak spells. They're not the holy grail everybody thinks. Highly demanding and prone to fail. I'd recommend using a find function in combination, which does its job just as well. Use cloak spell only if you really can't be using another variant. Since cloak spells use OnUpdate(), you can achieve the same with find functions and using OnUpdate() with the same result but much more streamlined code.

User avatar
Samantha hulme
 
Posts: 3373
Joined: Wed Jun 21, 2006 4:22 pm


Return to V - Skyrim