Remove Spell Not Working on NPC

Post » Thu Jun 21, 2012 2:38 pm

Here is my script applied to a magic effect:


Scriptname SpellCoolDown extends activemagiceffect

Int Property time Auto
SPELL Property Move Auto

event OnEffectStart(Actor akTarget, Actor akCaster)
akCaster.removespell(Move)
akCaster.unequipspell(Move,0)
akCaster.unequipspell(Move,1)
Utility.Wait(time)
akCaster.addspell(Move)
endEvent


Issue is that it works if the player uses the spell, but if the NPC uses it it will only unequip the spell. The "removespell" command does not work for the NPC.

Can anyone tell me why? Been working on this for several days = /
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am

Post » Thu Jun 21, 2012 1:42 pm

Wait, you aren't trying to use this on an Atronach or something are you? Some Races have spells as well, and I think even if you removed the Actor's version of the spell, the Race data might override that.

If its not that, try this.

akCaster.RemoveSpell(akCaster.GetEquippedSpell(0))
akCaster.RemoveSpell(akCaster.GetEquippedSpell(1))
User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Thu Jun 21, 2012 7:11 am

No it's a custom made creature and a custom made spell. Maybe it's a bug or something?

I tried that way yesterday, lol. Didn't work either = /
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Wed Jun 20, 2012 10:36 pm

So I just tried something as a test. I made a copy of the FireDamageFFAimed effect and put the script in it.
I made a copy of Firebolt and deleted all effects and added the new one.
I made a copy of a bandit and gave him the new spell.

He unequips the spell every time he casts it, but it doesn't remove it from him. So I don't see how it could be related to anything but the script. I've tried it on multiple NPC's, multiple spells, and multiple magic effects. Yet why would it work fine for the player?
This is very confusing.
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Thu Jun 21, 2012 1:43 pm

It may be for the same reason that you can't use addperk on NPCs. Perhaps once loaded, an NPC has what it has in terms of stats and abilities, and you can't do squat about it.

What are you trying to accomplish?
User avatar
Annika Marziniak
 
Posts: 3416
Joined: Wed Apr 18, 2007 6:22 am

Post » Thu Jun 21, 2012 2:19 pm

It may be for the same reason that you can't use addperk on NPCs. Perhaps once loaded, an NPC has what it has in terms of stats and abilities, and you can't do squat about it.

What are you trying to accomplish?

Nope, it isn't that. I've used the exact script he's using before to control NPC casting behaviour. Worked fine.
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Thu Jun 21, 2012 8:29 am

I'm just trying to make the NPC cast random spells instead of casting their favorite over and over again while ignoring the others.http://www.gamesas.com/user/789866-il-ducey/ came up with this script and it worked for him, but when I try it they still spam the same spell over and over. The script should be unequipping and removing the spell for a set amount of time making it impossible for the NPC to use it. But when I test it the NPC unequips the spell but immediately equips it again, and the spell is not being removed from him.

When I give it to myself, however, the script works as intended. That's what I can't figure out. Why would it remove the spell from me, but not from an npc?
User avatar
Esther Fernandez
 
Posts: 3415
Joined: Wed Sep 27, 2006 11:52 am

Post » Thu Jun 21, 2012 2:11 am

I'm thinking maybe the script is having trouble finding out which spell it needs to remove for some reason. Like, the property isn't working properly. Maybe try this?
Scriptname etc.Int Property Cooldown autoEvent OnEffectStart(Actor Target, Actor Caster)   Spell Move1 = Caster.GetEquippedSpell(0)   Spell Move2 = Caster.GetEquippedSpell(1)   Caster.RemoveSpell(Move1)   Caster.RemoveSpell(Move2)   Caster.UnequipSpell(Move1)   Caster.UnequipSpell(Move2)   Utility.Wait(Cooldown)   Caster.AddSpell(Move1)   Caster.AddSpell(Move2)endEvent

This would also help in case the problem is that actually the NPC casters have multiple versions of the spell, some for the right hand, others for the left, etc.
User avatar
Kevan Olson
 
Posts: 3402
Joined: Tue Oct 16, 2007 1:09 am

Post » Thu Jun 21, 2012 3:21 am

Well, I don't think it would be a problem with the properties because it can unequip the spell just fine. I tried your script, but I had to tweak it a bit to get it to compile.


Int Property Cooldown autoEvent OnEffectStart(Actor akTarget, Actor akCaster)   Spell Move1 = akCaster.GetEquippedSpell(0)   Spell Move2 = akCaster.GetEquippedSpell(1)   akCaster.RemoveSpell(Move1)   akCaster.RemoveSpell(Move2)   akCaster.UnequipSpell(Move1,0)   akCaster.UnequipSpell(Move2,1)   Utility.Wait(Cooldown)   akCaster.AddSpell(Move1)   akCaster.AddSpell(Move2)endEvent


Still it works perfectly for the player, but not for the NPC. They only have one version of the spell and it is set to left hand only.

Also, I've tried it with all the spells that the NPC has and deleted the ones he usually spams so that he uses the others, but it doesn't work on any of his spells. He has four different ones.
User avatar
Jade MacSpade
 
Posts: 3432
Joined: Thu Jul 20, 2006 9:53 pm

Post » Thu Jun 21, 2012 2:23 pm

The only thing I can think of is that maybe you have two versions of your mod running simultaneously for some reason.
User avatar
Leticia Hernandez
 
Posts: 3426
Joined: Tue Oct 23, 2007 9:46 am

Post » Thu Jun 21, 2012 11:52 am

I use Nexus Mod Manager and I disabled every mod except this one, but still nothing...
User avatar
Donatus Uwasomba
 
Posts: 3361
Joined: Sun May 27, 2007 7:22 pm

Post » Thu Jun 21, 2012 5:43 am

Alright, I'm gonna look through my old Pokemon mod (what I made that for) to see if there's anything else going on.

Oh, the spell you're trying to remove isn't a concentration spell is it?
User avatar
Rude_Bitch_420
 
Posts: 3429
Joined: Wed Aug 08, 2007 2:26 pm

Post » Thu Jun 21, 2012 7:45 am

No it's fire and forget.
User avatar
-__^
 
Posts: 3420
Joined: Mon Nov 20, 2006 4:48 pm

Post » Thu Jun 21, 2012 9:48 am

Well, it probably shouldn't take three long days of research and trial and error to do something so simple, but it did. Thanks Bethesda.

So first I downloaded your pokemon mod to see if I could find any differences between the way yours was set up and mine. I noticed right away that the spells on your NPCs were not in their spell list but instead added through a script.
I guess if the spells are in the spell list they are impossible to remove through a script. That's why it was working for the player, because I was giving it to the player through a spell tome.

So basically what you have to do is make a script and place it in your actor that gives him all the spells you want him to have. I made one that happens at the start of battle. I figured this would be the best way. I also took it further and added the cooldown script to the actor as well. That way you don't have to put a script on every spell you give him. However, if you want it to be spell-specific (different cooldown times, etc) you can still use the first part of my script below and put the cooldown script in the magic effect.

So here it is, finally. Hope this saves someone else from tearing their hair out like I did = /:

Scriptname GiveSpells extends ActorSpell Property Spell01 AutoSpell Property Spell02 AutoSpell Property Spell03 AutoSpell Property Spell04 AutoInt Property Time AutoEvent OnCombatStateChanged (Actor akTarget, int aeCombatState)	if (aeCombatState == 1)	  Self.AddSpell (Spell01)	  Self.AddSpell (Spell02)	  Self.AddSpell (Spell03)	  Self.AddSpell (Spell04)	endIfendEventEvent OnSpellCast (Form akSpell)   Self.RemoveSpell (akSpell as Spell)   Utility.Wait (Time)   Self.AddSpell (akSpell as Spell)endEvent

For more spells of course just add more "Spell Property XXXX Auto".
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am


Return to V - Skyrim