SAI Scripting questions

Ask for help here.

SMART_ACTION_SET_INST_DATA

SMART_ACTION_SET_DATA

How can I use it, and when I need to use? I don’t understand. I see you use it in some scripts, why?

I use this to start SAI on another npc. I can only make one npc tell another to do a limited amount of commands. So when I want more functions I set the data field 0 to 1 to the target npc and have its SAI check that field to perform actions.

Once I see the value has changed I reset the value and start the required script.

I hope this is helpful.

Very big thanks Malcrom, now I understand. /emoticons/default_smile.png Thanks.

i am missing something somewhere… how do you use SAI to take off an aura and or turn one on… i tried SMART_ACTION_REMOVEAURASFROMSPELL but it appears that when the npc has it set already, its not taking it off… the npc(s) are the cured gazelles and cured deer… they are not suppose to have the sick aura on them… now before you suggest it… creature_template_addon doesnt have them in it and of course the creature_addon doesnt have it set because you need guids and these creatures are not spawned so you dont have npcs. Your explanation on how to add aura was good, but getting rid of it is a different story it appears.

so where is this set or how can i use sai to remove it. did i complicate it enough? http://www.trinitycore.org/f/public/style_emoticons/default/tongue.gif

What is the aura?

19502

but in my db i dont see it applied to the cured deer and cured gazelles, its applied to the sickly ones and the cured ones should not have it.

If the aura is not applied in the addon tables and you remove the EAI by installing SAI where are they getting the aura from? Doesn’t make sense.

agreed… and i didnt have an eai on the cured npcs, so i didnt remove anything, infact that is what i wanted to do, but am baffled atm. i will have to investigate this more on the db side and find out where this aura is being apllied and remove it. thanks any way malcrom.

is there a .cpp script (maybe even for some other NPC in the area) that might be applying it?

well, my clean db has 121 lines for gazellas + aura 19502

in creature_addon

i found it, had wrong id that i was looking at.

A question about waypoint movement:

  • I have an npc, who start a wp movement

  • At the end of waypoint path, he summon a hostile mob, what need to kill for the quest

The problem:

The npc ended his wp movement, wait few seconds and summon the killable mob, this is ok,

but if the player starts combat with the hostile mob, the wp npc simply went back to his spawn point,

and this is not ok. The wp npc needs to help to the player in the fight. How can I solve this problem?

Example Quests:

http://www.wowhead.com/quest=11592

OR

http://www.wowhead.com/quest=12249

show code

if you used only pathid in the start-wp action then the npc’s react state is set to default (react_passive)

SMART_ACTION_WP_START = 53, // run/walk, pathID, canRepeat, quest, despawntime, reactState

some notes about this:

canRepeat, default off, and only use this where the last wp is near the start wp, (circular paths) otherwise if its in a straight line, it will look stupid , and the npc will move from last wp to frist in a simple straigth line

reactState: deafault 0

REACT_PASSIVE = 0, REACT_DEFENSIVE = 1, REACT_AGGRESSIVE = 2

and note that the npc will only help the player if npc is hostile to the attacking mob

[/CODE]

Another question about phases:

I want to fix the Icecrown Arena quest series, but have some issues. I wrote a test script to see how the phases worked. This is the part of my code:

[CODE]DELETE FROM smart_scripts WHERE entryorguid IN (31135, 3113500);

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

(31135, 0, 1, 0, 38, 0, 100, 0, 0, 1, 0, 0, 23, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 1 inc phase by 1’),

(31135, 0, 2, 0, 38, 0, 100, 0, 0, 2, 0, 0, 23, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 2 inc phase by 1’),

(31135, 0, 3, 0, 38, 0, 100, 0, 0, 3, 0, 0, 23, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 3 inc phase by 2’),

(31135, 0, 4, 0, 38, 0, 100, 0, 0, 4, 0, 0, 23, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 4 inc phase by 4’),

(31135, 0, 5, 0, 38, 0, 100, 0, 0, 5, 0, 0, 23, 8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 5 inc phase by 8’),

(31135, 0, 6, 0, 38, 0, 100, 0, 0, 6, 0, 0, 23, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 6 inc phase by 16’),

(31135, 0, 7, 0, 1, 1, 100, 1, 1000, 1000, 0, 0, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase1 say text1’), – worked

(31135, 0, 8, 0, 1, 2, 100, 1, 1000, 1000, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase2 say text2’), – worked

(31135, 0, 9, 0, 1, 4, 100, 1, 1000, 1000, 0, 0, 1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase3 say text3’), – worked

(31135, 0, 10, 0, 1, 8, 100, 1, 1000, 1000, 0, 0, 1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase4 say text4’), – worked

(31135, 0, 11, 0, 1, 16, 100, 1, 1000, 1000, 0, 0, 1, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase5 say text5’), – not worked

(31135, 0, 12, 0, 1, 32, 100, 1, 1000, 1000, 0, 0, 1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase6 say text6’); – not worked

– SAI for Jhadras

DELETE FROM smart_scripts WHERE entryorguid =31191;

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

(31191, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 1, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ‘on death set data 0 1 for geirrviff’);

– SAI for Eldreth

DELETE FROM smart_scripts WHERE entryorguid =31195;

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

(31195, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 2, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ’ on death set data 0 2 for geirrviff’);

– SAI for Geness Half-Soul

DELETE FROM smart_scripts WHERE entryorguid =31193;

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

(31193, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 3, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ‘on death set data 0 3 for geirrviff’);

– SAI for Masud

DELETE FROM smart_scripts WHERE entryorguid =31192;

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

(31192, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 4, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ‘on death set data 0 4 for geirrviff’);

– SAI for Rith

DELETE FROM smart_scripts WHERE entryorguid =31196;

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

(31196, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 5, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ‘on death set data 0 5 for geirrviff’);

– SAI for Talla

DELETE FROM smart_scripts WHERE entryorguid =31194;

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

(31194, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 45, 0, 6, 0, 0, 0, 0, 9, 31135, 0, 50, 0, 0, 0, 0, ‘on death set data 0 6 for geirviff’);[/CODE]

On phase 5 and 6 the Npc says nothing. What I’m missing?

[CODE]DELETE FROM smart_scripts WHERE entryorguid IN (31135, 3113500);
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
(31135, 0, 1, 0, 38, 0, 100, 0, 0, 1, 0, 0, 23, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 1 inc phase by 1’),
(31135, 0, 2, 0, 38, 0, 100, 0, 0, 2, 0, 0, 23, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 2 inc phase by 1’),
(31135, 0, 3, 0, 38, 0, 100, 0, 0, 3, 0, 0, 23, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 3 inc phase by 2’),
(31135, 0, 4, 0, 38, 0, 100, 0, 0, 4, 0, 0, 23, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 4 inc phase by 4’),
(31135, 0, 5, 0, 38, 0, 100, 0, 0, 5, 0, 0, 23, 8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 5 inc phase by 8’),
(31135, 0, 6, 0, 38, 0, 100, 0, 0, 6, 0, 0, 23, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ‘on dataset 0 6 inc phase by 16’),

(31135, 0, 7, 0, 1, 1, 100, 1, 1000, 1000, 0, 0, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase1 say text1’), – worked
(31135, 0, 8, 0, 1, 2, 100, 1, 1000, 1000, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase2 say text2’), – worked
(31135, 0, 9, 0, 1, 4, 100, 1, 1000, 1000, 0, 0, 1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase3 say text3’), – worked
(31135, 0, 10, 0, 1, 8, 100, 1, 1000, 1000, 0, 0, 1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase4 say text4’), – worked
(31135, 0, 11, 0, 1, 16, 100, 1, 1000, 1000, 0, 0, 1, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase5 say text5’), – not worked
(31135, 0, 12, 0, 1, 32, 100, 1, 1000, 1000, 0, 0, 1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ‘on phase6 say text6’); – not worked[/sql]

Should be “Set phase to” not 'inc phase by"

If the dataset is happening OOC you should run a script rather than set a phase.

[/CODE]

This would be better. Just add in the other scripts:

[CODE]-- SAI for Geirrvif
UPDATE creature_template SET AIName=‘SmartAI’ WHERE entry=31135;
DELETE FROM smart_scripts WHERE source_type=0 AND entryorguid IN (31135);
DELETE FROM smart_scripts WHERE source_type=9 AND entryorguid IN (3113500,3113501,3113502,3113503,3113504,3113505);
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
– AI
(31135,0,1,0,38,0,100,0,0,1,0,0,80,3113500,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 1 run script’),
(31135,0,2,0,38,0,100,0,0,2,0,0,80,3113501,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 2 run script 1’),
(31135,0,3,0,38,0,100,0,0,3,0,0,80,3113502,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 3 run script 2’),
(31135,0,4,0,38,0,100,0,0,4,0,0,80,3113503,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 4 run script 3’),
(31135,0,5,0,38,0,100,0,0,5,0,0,80,3113504,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 5 run script 4’),
(31135,0,6,0,38,0,100,0,0,6,0,0,80,3113505,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - on dataset 0 6 run script 5’),
– Script 1
(3113500,9,0,0,0,0,100,0,0,0,0,0,34,0,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - data set 0 0’),
(3113500,9,1,0,0,0,100,0,1000,1000,0,0,1,10,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text1’),
(3113500,9,2,0,0,0,100,0,1000,1000,0,0,1,11,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text2’),
(3113500,9,3,0,0,0,100,0,1000,1000,0,0,1,12,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text3’),
(3113500,9,4,0,0,0,100,0,1000,1000,0,0,1,13,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text4’),
(3113500,9,5,0,0,0,100,0,1000,1000,0,0,1,14,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text5’),
(3113500,9,6,0,0,0,100,0,1000,1000,0,0,1,15,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - say text6’);
– Script 2

– Script 3

– Script 4

– Script 5[/sql]

Notice I set data 0 back to value 0 so the AI event would not keep repeating.

[/CODE]

I need to inc phase, because to the quest needs to kill six mob, and if the player killed all the mobs, get a quest credit. So the “set phase” function not usable in this case.

My concept:

If the player kill a mob, the mob incerasing the phase of the quest starter npc. In the end(when all the six mob killed) the q starter npc get to phase 6 and get kill credit to the player. One mob = one phase.

This say script only have, because I want to see, that the phases worked or not.

Edit: all the 6 mob come at once

Sorry for my bad english.

Do you get the quest credit after or before the last text?