I was unaware of this until I discovered my spell hook code not working for NPCs (or companions using AI) casting spells: Spell hooking does not work for NPCs/PCs not controlled by the player.
In other words, if you have some spell hook code that you want to fire (irrespective of who is casting the spell), then it will not fire if neither the player or DM are controlling the caster. This also means spells cast by companions while using AI rather than the player controlling them will not fire your spell hook code.
The workaround is to add the following line of code to every area OnEnter:
// FORCE SPELL HOOK CODE TO WORK ON NPCS (FOR AI CASTING AS WELL)
object oCreature = GetEnteringObject();
object oArea = GetArea(oCreature);
SetLocalInt(oArea, "X2_L_WILD_MAGIC", 1); // SEE x2_inc_spellhook
It may be something that only I am concerned about, but may be of interest to other builders who also want their spell hook code to work no matter who or what is casting the said spell.
Lance.
Modifié par Lance Botelle, 14 février 2011 - 08:17 .





Retour en haut







