SAI Scripting questions

Do these creatures appear on order or random?

Do you get quest credit for each or quest complete at end?

Maybe post a list of events.

The mobs appear at once, and need to be killed, to get one quest credit.

Quest: http://www.wowhead.com/quest=13214

[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’),
(31135,0,7,8,38,32,100,0,0,6,0,0,26,13204,0,0,0,0,0,16,0,0,0,0,0,0,0, ‘Geirrvif - at phase 6 - give quest credit’),
(31135,0,8,0,61,32,100,0,0,6,0,0,22,0,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Geirrvif - at phase 6 - set phase 0’),

– Script 1
(3113500,9,0,0,0,0,100,0,0,0,0,0,23,1,0,0,0,0,1,0,0,0,0,0,0,0,0, ‘Geirrvif - Increment phase’),
(3113500,9,1,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,2,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,3,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,4,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,5,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,6,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,7,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]

This will run a script when a creature is killed and increment phase.

At phase 6 the npc will give quest credit. Not that your on dataset is in phase 0 “all phases” so they will run no matter what phase the npc is in.

[/CODE]

for phase manipulation you have to use …how to name it… “phase IDs”

there are 6 useable phases total

phase 0 is always running (hm, then actually 7 phase /emoticons/default_tongue.png)

usable phases are: 1,2,3,4,5,6

example: you are in phase 0 by default, want to go to phase 1, then you have two choices:

inc_phase by 1 or set_phase 1

if you are in p0 and want to skip to p2:

inc_phase by 2 or set phase to 2

if you are in p1 and want to skip to p2:

inc_phase by 1 or set phase to 2

it was made like that to be simple to use, and you dont have to bother with bitmasking while scripting actions

(unfortunately most of the people mix things with eai)

about the event.phasemask

this is the only place where you can use bitmasked values

PHASE_ALWAYS_BIT = 0, // this is the default PHASE_1_BIT = 1, PHASE_2_BIT = 2, PHASE_3_BIT = 4, PHASE_4_BIT = 8, PHASE_5_BIT = 16, PHASE_6_BIT = 32,

example: you want an event to accour in p1 and p4:

phasemask = 1+8 = 9

1 for phase_bit_1

8 for phase_bit_4

common scripter error:

inc_phase by bitmask values instead of ‘phase ID’

example:

incrementing phase by ie 32, would skip to current_phase+32, which is invalid

[code](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
[/CODE]

notice that it only worked till ‘inc phase by 4’

0+4 = 4, phase is set to 4, which is fine

next line:

0+8 = 8, phase is set to 8, which is invalid, our max phase is 6!

hope it helped

Hi,

I have a little problem…can You tell me where I’m wrong?

[CODE]DELETE FROM smart_scripts WHERE entryorguid = 24539;

INSERT INTO trinity_world2.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

(24539 , 0, 1, 0, 2, 0, 100, 0, 15, 15, 0, 0, 2, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, “Prova change faction”);

UPDATE creature_template SET AIName=‘SmartAI’ WHERE entry=24539;

[/CODE]

I would npc 24539 change faction, but It doesn’t happens.

[CODE]DELETE FROM smart_scripts WHERE entryorguid = 24539;
INSERT INTO trinity_world2.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
(24539 , 0, 1, 0, 2, 0, 100, 0, 15, 15, 0, 0, 2, 35, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, “Prova change faction”);
UPDATE creature_template SET AIName=‘SmartAI’ WHERE entry=24539[/sql]

You didn’t have a target defined.

[/CODE]

Oh really thanks…:-S

I’m sorry fort this stupid question

What are the meaning of “Link” and “Id” in Smart ai?

One question about timeline… if you waana script some linked events Than summnons Gameobjects during two seconds with pauses between then. And all will start when you use a gameobject in the game.

I see than to make that type of event (from the GOSSIP_HELLO) is the code 64, and then you can link with the another events, but i dont undernstand the diferences between SMART_EVENT_UPDATE_IC & SMART_EVENT_UPDATE_OCC

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

(@ENTRY,1,0,1,64,0,100,3,0,0,0,0,50,@GO,2000,0,0,0,0,8,0,0,0,@X,@Y,@Z,@O, ‘Spawn GO during 2 Seg.’),

(@ENTRY,1,1,2,??,0,100,3,5000,5000,5000,5000,50,@GO,2000,0,0,0,0,8,0,0,0,@X,@Y,@Z,@O, ‘Wait 5 Seconds and Spawn GO during 2 Seg.’),

(@ENTRY,1,2,0,??,0,100,3,5000,5000,5000,5000,50,@GO,2000,0,0,0,0,8,0,0,0,@X,@Y,@Z,@O, ‘Wait 5 Seconds and Spawn GO during 2 Seg.’);

¿What must i use? ¿UPDATE_IC or UPDATE_OOC? And if i use UPDATE_IC, ¿I must change the wait timers?.

Sorry for my english, i’m trying to fix the Sunken Temple instance, and is the last thing i need to code.

Thanx in advance.

Link is the ID of the next event in the chain. And the ID is the number of the event.

For Example… for the creature “@ENTRY” you must wanna to make a chain of events that will execute in order, when you enter in the Aggro zone.

entryorguid,source_type,id,link,event_type

@ENTRY, 0, 0, 1, 4 … (When you enter in the aggro zone the chain will start.

@ENTRY, 0, 1, 2, 61 … (And then continue…

@ENTRY, 0, 2, 0, 61 … (and ends…)

Thanks Neuro.

THis day is the “question day”:

In this event:

SMART_EVENT_GOSSIP_SELECT 62 menuID actionID

What is actionID?

This event means for example:

When you click on gossip, NPC makes a given action?

Every line of SAI needs to have a separate id eg. 0,1,2,3,4,5,6. The link field is used to add more actions to the event. Thus if you have an event 8 “Spellhit” and you want this event to do several actions you will have to add extra ines of SAI with event 61 “linked event” and add the next lines id number in the link field.

If you look at the follow SAI, when line id 0 runs the core sees that line id 1 is set in its link field. Thus after it gives quest credit it will run the next line and also close gossip. Because line id 1 is linked to line id 0 it will never run unless line id 0 is true.

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 (@ENTRY,0,0,1,62,0,100,0,8396,0,0,0,26,10814,0,1,0,0,0,7,0,0,0,0,0,0,0,'Neltharaku - On Gossip option - Quest credit'), (@ENTRY,0,1,0,61,0,100,0,0,0,0,0,72,0,0,0,0,0,0,7,0,0,0,0,0,0,0,'Neltharaku - On Gossip option - Close gossip');[/sql]

IC = In combat

OOC = Out of Combat

In this Action:

SMART_ACTION_SUMMON_GO 50 Gameobject_template.entry DespawnTime in ms

What suppose to do “DespawnTime”?

I make in an event a DespawnTime of 2000 (Supposing than this is the time of the object before it leaves…) but the object persist, and dont disapear after that time.

If dont work that way, how can be removed and object summoned with that smartaction (Supposing than that action is in a list of actions “SMART_SCRIPT_TYPE_TIMED_ACTIONLIST 9” than summon more objects, than must be removed after some seconds.

There is some way to remove all the gameobject summoned in a SMART_SCRIPT_TYPE_TIMED_ACTIONLIST?

Or a way to summon a gameobject during a period of time?

Thanx in advance.

Despawning of gameobjects is not implemented (or very buggy) (in the core scripts, not specifically in SmartAI).

I would like to be able to despawn GOs too but it isn’t an option at this momment.

Another problem:

When I spawn a gob with SAI, I can’t loot it, but when I spawn it manually I can.

Did it happen to someone?

Edit:

anyone can tell me where I’m wrong?

[CODE]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

(18716, 0, 0, 0, 64, 1, 100, 1, 0, 0, 0, 0, 11, 47068, 1, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, “Quest: who are they”);

[/CODE]

A question about moving(move to pos or waypoint) and combat.

I have an npc who on spawn start to move the positions(I know have wp system, this is now no matter, the problem is same in both case), the npc move nicely to the positions, but if the moving ended, and the npc get to combat, the npc just start go back to his spawn point and not figting with the player. If I used waypoints, same problem.

I started the moving with SMART_ACTION_CALL_TIMED_ACTIONLIST = 80, and if the script >>ENDED<<(all components ran), the problem started. If I started combat with npc when he moved to the points, not went back to spawn point, just after combat ended, stopped moving. On wp movement, same problem. So the question: why go back to his spawn point if get to combat?

Here is my code:

[CODE]DELETE FROM smart_scripts WHERE entryorguid IN (31242, 3124200, 3124201);
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
– (31242,0,1,0,11,0,100,1,0,0,0,0,11,61165,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid cast frostbite weap on self’),
(31242,0,2,0,9,0,100,0,5,30,0,0,21,0,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid stop comb. move in range’),
(31242,0,3,0,9,0,100,0,5,30,2000,5000,11,61168,0,0,0,0,0,2,0,0,0,0,0,0,0, ‘sigrid cast throw weap in range’),
(31242,0,4,0,9,0,100,0,30,100,0,0,21,1,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid allow comb move in 30+ yd’),
(31242,0,5,0,9,0,100,0,0,5,0,0,21,1,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid allow comb move in 5 yd’),
(31242,0,6,0,9,0,100,0,0,5,15000,20000,80,3124200,0,2,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid run script 00 in 5 yd’),
(31242,0,7,0,11,0,100,0,0,0,0,0,80,3124201,0,2,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid on spawn run script 01’),

– Script 00
(3124200,9,0,0,0,0,100,0,0,0,0,0,11,61170,2,0,0,0,0,2,0,0,0,0,0,0,0, ‘sigrid cast flash freeze on target’),
(3124200,9,1,0,0,0,100,0,0,0,0,0,8,0,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid set react state off’),
(3124200,9,2,0,0,0,100,0,0,0,0,0,11,57635,0,0,0,0,0,2,0,0,0,0,0,0,0, ‘sigrid cast disengage on self’),
(3124200,9,4,0,0,0,100,0,1000,1000,0,0,8,2,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid set react state on’),

– Script 01
(3124201,9,0,0,0,0,100,0,0,0,0,0,60,1,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid set fly on’),
(3124201,9,1,0,0,0,100,0,0,0,0,0,71,0,1,41815,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid equip weapon’),
(3124201,9,2,0,0,0,100,0,0,0,0,0,43,0,26742,0,0,0,0,1,0,0,0,0,0,0,0, ‘sigrid mount on spawn’),
(3124201,9,3,0,0,0,100,0,1000,1000,0,0,69,0,0,0,0,0,0,8,0,0,0,8217.3,3551.7,714.68,0, ‘sigrid move to pos’),
(3124201,9,4,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8246.4,3545.8,704.5,0, ‘sigrid move to pos’),
(3124201,9,5,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8255,3517.3,684,0, ‘sigrid move to pos’),
(3124201,9,6,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8250,3476.7,663.7,0, ‘sigrid move to pos’),
(3124201,9,7,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8198,3456.7,638.5,0, ‘sigrid move to pos’),
(3124201,9,8,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8173.5,3461,632,0, ‘sigrid move to pos’),
(3124201,9,9,0,0,0,100,0,4000,4000,0,0,69,0,0,0,0,0,0,8,0,0,0,8168.7,3481.8,630,0.62, ‘sigrid move to pos’);[/sql][/CODE]

this is just a request but malcrom, can you continue the tutorials, i found them helpful in understanding the smart script system. The only suggestions I would have with them is to maybe just clean up the grammar a bit so it’s easier to understand but that’s no biggie.

Cleanup the grammer?