no, use myself.i_ai0
but if many players spelled at one time - last player's spell will be stored in NPC memory.
And you wrong, you should store speller id , and in MY_DYING give item not to last attacker, you mast give item to stored speller.
class mob_sa_quest_st_1 : default_npc
{
handler:
EventHandler CREATED()
{
myself.i_ai0 = 0;
myself.c_ai0 = 0;
}
EventHandler SPELLED(speller, skill_name_id)
{
if(skill_name_id == @s_soul_crystal && myself.sm.hp <= myself.sm.maxhp/2)
{
myself.c_ai0=speller;
}
}
EventHandler ATTACKED(attacker, damage)
{
//don't need anything here
//just
super;
}
EventHandler MY_DYING()
{
c1 = GetLastAttacker();
if( myself.c_ai0 !=0 )
{
if(OwnItemCount(myself.c_ai0, @red_soul_crystal_0)>1)
{
ShowSystemMessage(myself.c_ai0, 977);
}
if(OwnItemCount(myself.c_ai0, @red_soul_crystal_0)==1)
{
DeleteItem1(myself.c_ai0, @red_soul_crystal_0,1);
GiveItem1(myself.c_ai0, @red_soul_crystal_1,1);
ShowSystemMessage(myself.c_ai0, 974);
}
}
}
}
|