[Help] Trigger NPC

Hi, im trying to create trigger, npc which will cast spell on player if he is withing 50f from it, so here is my code

#include “ScriptPCH.h”

class NPC_Trigger : public CreatureScript
{
public:
NPC_Trigger() : CreatureScript(“NPC_Trigger”) { }

    struct NPC_TriggerAI : public ScriptedAI
    {
        NPC_TriggerAI(Creature* creature) : ScriptedAI(creature) { }

        void MoveInLineOfSight(Unit* who)
        {
            if(!who)
                return;

            if(who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 50.0f))
            {
                DoCast(who, 25661, true);
                return;
            }
        }
    };

    CreatureAI* GetAI(Creature* pCreature)
    {
        return new NPC_TriggerAI(pCreature);
    }

};

void AddSC_NPC_Trigger()
{
new NPC_Trigger();
}

The problem is, doesnt matter how far im from it, its still doing nothing.

Here is SQL for NPC

INSERT INTO creature_template (entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName, VerifiedBuild) VALUES
(100000, 0, 0, 0, 0, 0, 10045, 0, 0, 0, ‘NPC Trigger’, ‘Main Trigger’, NULL, 0, 1, 80, 0, 35, 0, 0.91, 1.14286, 1, 0, 422, 586, 0, 642, 1, 2000, 2200, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 345, 509, 103, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘’, 0, 4, 1, 0.0125, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 130, ‘NPC_Trigger’, 0);

And of course i’ve added it to ScriptLoader.cpp

Try remove 128 (trigger) from the extra_flags for NPC and try again to see if it now triggers.

Often the reason things dont work is cause the NPC cant see player etc.

thx, ill try, i just created this SQL by looking at tc2 creature_template.