Jump to content

[LE] Make an actor use a certain spell at the start of combat


Recommended Posts

I am trying to make a follower and i want him to use a specific spell on the start of every combat, i tried AI packages, Combat style and scripts but couldn't figure it out.

 

i am a bit new to modding so help me please.

 

edit :

 

AI Packages attempt:

made a usemagic package

 

put it in a formlist and assigned it in the follower's combat override package list in ai packages tab, but when the combat starts he just uses the spell and then stands there doing nothing , and for some reason the enemy stops attacking anyone while still being detected as a threat/enemy(you can see the red dot on the compass and his health bar)

 

Sctipts attempt:

Scriptname PlayerCloneStartCombat extends ObjectReference

bool Function RemoveSpell(Spell akSpell, bool abVerbose = true) native
bool Function AddSpell(Spell akSpell, bool abVerbose = true) native
bool Function DispelSpell(Spell akSpell) native
bool Function HasSpell(Form akForm) native
Spell Property MySpellAbility auto


Event OnCombatStateChanged(Actor akTarget, int aeCombatState)

    if (aeCombatState == 0)
        DispelSpell(MySpellAbility)
        RemoveSpell(MySpellAbility)

    elseif (aeCombatState == 1)
       AddSpell(MySpellAbility)
    elseif (aeCombatState == 2)
           if(!HasSpell(MySpellAbility))
                 AddSpell(MySpellAbility)
           else

           endIf
    endIf
  
endEvent

made this script and put it in the actor scripts of the follower ,but this time he doesn't use the spell but he attacks the enemies

in this script i converted the spell into an ability and used addspell and i also tried the function cast with the original spell using a PlayerCloneRef

when i checked the papyrus log i found the error "Unbound native function "AddSpell" called".

Edited by sMooDi31
Link to comment
Share on other sites

Hmm. Is the event itself working? What happens if you put Debug.Messagebox tests along with your AddSpell lines?

Have you filled the property?

 

Another way to make this work is to give your actor an ability spell with a condition "IsInCombat". Make the spell's magic effect Constant Effect and Archetype: Script. Then in the script, OnEffectStart, add your combat magic spell to the actor. Now every time your actor enters combat the condition will become true and the spell will be cast.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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