NPC Captive Spitescale Scout Not attacking on aggro

Hey guys, ive been working on a smart AI for the quest The proving pit:

/* Starter quest Proving pit, Fix Darkspear jailor
and SHatterspear scouts Waypoints and Both NPC’s
give’s Credit to quest */

/* Darkspear jailor : 39062 On gossip select say text: Get in the pit and show us your stuff */

UPDATE creature_template SET spell1 = 15089 WHERE entry= 38142;
UPDATE creature_template SET AIName= ‘SmartAI’ WHERE entry= 39062;
UPDATE creature_template SET AIName= ‘SmartAI’ WHERE entry= 38142;

DELETE FROM creature_text WHERE entry IN (39062);
DELETE FROM creature_text WHERE entry IN (38142);
INSERT INTO creature_text (entry,groupid,id,text,type,language,probability,emote,duration,sound,comment) VALUES
(39062,0,0,‘Get in the pit and show us your stuff, $N’,12,0,100,0,0,0,‘Darkspear jailor say text’),
(38142,0,1,‘I sshal ssslaughter you, Darksspear runt!’,12,0,100,0,0,0,‘Captive Spitescale Scout say text’),
(38142,0,2,‘I sshal tasste your blood, landling.’,12,0,100,0,0,0,‘Captive Spitescale Scout say text’),
(38142,0,3,‘The Sssea Witch will kill you all.’,12,0,100,0,0,0,‘Captive Spitescale Scout say text’),
(38142,0,4,‘They sssend you to your death, youngling.’,12,0,100,0,0,0,‘Captive Spitescale Scout jailor say text’);

/* Darkspear jailor wp */
DELETE FROM waypoints WHERE entry = 142394;
DELETE FROM waypoints WHERE entry = 142383;
INSERT INTO waypoints(entry, pointid, position_x, position_y, position_z, point_comment) VALUES
(142394, 1, -1158.72, -5518.99, 13, ‘Darkspear jailor wp1’ ),
(142394, 2, -1152.91, -5518.91, 13, ‘Darkspear jailor wp1’),
(142383, 1, -1148.53, -5526.33, 13, ‘Captive Spitescale Scout wp1’);

DELETE FROM smart_scripts WHERE entryorguid IN (-142394);
DELETE FROM smart_scripts WHERE entryorguid IN (-142383);
INSERT INTO smart_scripts (entryorguid,source_type,id,link,event_type,event_phase_mask,event_chance,event_flags,event_param1,event_param2,event_param3,event_param4,action_type,action_param1,action_param2,action_param3,action_param4,action_param5,action_param6,target_type,target_param1,target_param2,target_param3,target_x,target_y,target_z,target_o,comment) VALUES
(-142394,0,0,0,62,0,100,1,10974,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘On gossip option select Darkspear jailor say text’),
(-142394, 0, 1, 0, 62, 0, 100, 1, 10974, 1, 0, 0, 33, 39062, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, ‘Darkspear Jailor Quest Credit’),
(-142394, 0, 2, 0, 62, 0, 100, 1, 10974, 1, 0, 0, 53, 0, 142394, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘Darkspear Jailor WP Start’),
(-142394, 0, 3, 0, 58, 0, 100, 1, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 14, 48543, 201968, 0, 0, 0, 0, 0, ‘Darkspear_Jailor_open_cage’),
(-142394, 0, 4, 0, 58, 0, 100, 1, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 10, 142383, 38142, 0, 0, 0, 0, 0, ‘Darkspear_Jailor Set Captive Spitescale Scout Data’),
(-142383, 0, 0, 0, 38, 0, 100, 1, 0, 0, 0, 0, 53, 0, 142383, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘Captive Spitescale Scout WP Move’),
(-142383, 0, 1, 0, 4, 0, 100, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘On Aggro pull Captive Spitescale Scout say text’);

Now for some reason after the Spitescale Scout left the cage i can attack it if its unit flag is set to 0 but it does not attack me on aggro which it should do. the npc is suppose to attack and cast Frost shock spell. can saymone please help me out,

Thanks for now

change this

(-142394, 0, 2, 0, 62, 0, 100, 1, 10974, 1, 0, 0, 53, 0, 142394, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘Darkspear Jailor WP Start’),
to

(-142394, 0, 2, 0, 62, 0, 100, 1, 10974, 1, 0, 0, 53, 0, 142394, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, ‘Darkspear Jailor WP Start’),

this makes npc path defensively… zero is default and if on smart path they wont attack unless you add the #2 flag.

Reallylylyly work for me… thanks very very much guys!

This doesnt work in the 6x branch, trying to figure it out now