So, I wanna fix some bugs on NPC summoned by the player.
I need that the player, use some object, that object summons a NPC (you know, that kind of 'Minion of player'/'Guardian of player')
This part works like it should.
Now, I want that summoned NPC (i don't know if 'summoned' its the word i should use) cast a spell on the player who summoned it.
I tried several things, which didn't work at all.
First, I wrote a script and attached to the creature_template in 'ScriptName'. Did not work. (I've done some scripting on creatures that worked, but never summoned creatures).
This is my script
Code:
#include "ScriptPCH.h"
enum Spells
{
SPELL_HEALTH = 139
};
class summoned_creature : public CreatureScript
{
public:
summoned_creature() : CreatureScript("summoned_creature") { }
struct summoned_creatureAI : public CreatureAI
{
summoned_creatureAI(Creature* creature) : CreatureAI(creature)
{
}
void EnterCombat(Unit* /*who*/) override
{
}
void KilledUnit(Unit * /*victim*/) override
{
}
void JustDied(Unit * /*victim*/) override
{
}
void JustSummoned(Creature * Summoner/*summoner*/)
{
DoCast(Summoner, SPELL_HEALTH);
me->DisappearAndDie();
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return new summoned_creatureAI(creature);
}
};
void AddSC_summoned_creature()
{
new summoned_creature();
}
Second, I tryed modifying the smart_scripts table, (erasing the ScriptName field) and with this link help, make the NPC do its work.
It didn't.
Luckily, you'll guide me to resolve this.
I hope I'd not make any mistakes, since I'm not an English expert
Thanks