Jump to content

Help with script to force an NPC to cast a spell.


zzjay

Recommended Posts

hello, i am looking for a persn who knows how to basically force an NPC to cast a spell whenever a certain AI package runs.
Teorethycally it's all set, however the NPC still will not cast.

 

Link to comment
Share on other sites

Hi @zzjay, and welcome to AFK! :)

What kind of package is it? Please post the script- a quest should be set up for this kind of thing to work.

Link to comment
Share on other sites

Hi zzjay, nice to meet you here!

You can use an UseMagic package as a template to create your own. This should be attached to the alias npc inside a quest. Make sure you use a spell the npc is able to cast. Check the spells and perks of your basic actor. Spell usage for npcs is very limited. You can setup a global and change it with a script. Attach that global to the package. If you change the global with the script to match the value in the package and use "EvaluatePackage(), your npc should start casting.

Link to comment
Share on other sites

12 hours ago, lmstearn said:

Hi @zzjay, and welcome to AFK! :)

What kind of package is it? Please post the script- a quest should be set up for this kind of thing to work.

The scriptline is this:
------------------------------

Event OnPackageStart(Package akNewPackage)

    If akNewPackage == TrissHorseFollowerPackage
        SpellTrissHorseSummon.Cast(TrissMerigoldW3)
    EndIf
EndEvent
----------------------------------
unknown.png

unknown.png

*the second condition is an MCM condition.

Script is added to alias script, and package is also added to alias.
The spell has no casting requirement.
The package is a imple follower package with just different conditions, of triggering, aka when player swims, when player is not sneaking, when player rides horse, so that when player does somethgn the NPC is forcecasting a spell that summons horse or gives waterbreathign, so it wont drown. for some reason it wont cast...

The script was sent to me by a friend, and he got it working, so the idea behind the script works, just need to figure out what's wrongmand why the package will not trigger.
if i summon the horse with console, then the follower uses it,however the horse itself won't self kill to these conditions. I already checked the mod he made, and teted it successfully, but despite it being the same, something is not working with either script or packages.
----------------------
Event OnPackageEnd(Package akOldPackage)
    If akOldPackage == TrissHorseFollowerPackage
        Self.Kill()
    EndIf
EndEvent
--------------------
Ownership of the horse to NPC is also assigned through script. and that works.

@Tasheni
I do not need to see the NPC cast the sell necessarily, as long as the spell gets cast, even through script i'm fine with that.

Link to comment
Share on other sites

8 hours ago, lmstearn said:

To narrow things down a bit ,were you able to ascertain the condition akNewPackage == TrissHorseFollowerPackage was met with something like MessageBox_Debug?

I did try debug messages, but i haven't been able to have it show up, which is why im suspecting packages are acting up.

But packages are pretty simple. horse package is suppposed to activate when player uses horse.

the weird part is that she is still using the package, because if i ride a horse, she does, while if i remove that package she wont ride her own horse. it's just the casting part that will not work.

Link to comment
Share on other sites

11 hours ago, lmstearn said:

To narrow things down a bit ,were you able to ascertain the condition akNewPackage == TrissHorseFollowerPackage was met with something like MessageBox_Debug?

Truns out it's working now, for some reason i just had to copy paste the script as a new script with a different name.

Do i have to rename and recreate any time i add or change a line?

for example if i add some feature or whatever?

Link to comment
Share on other sites

Glad you got it working. :)

No, that should be fine, as long as all the edits are created and saved into an esp file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...