Tuto SAI-Editor: initiation

dokuro

Veteran Member
Verified Member
31
2020
8
Location
Paris
Making a tutorial on SAI-Editor or SmartAI

Quest Part-4.jpg

would be a little presumptuous in view of these many possibilities.
I will therefore by this tutorial try to make you pass the first impression of complexity that it gives by a discovery of the interface and these main lines, see some examples / simple tips to illustrate it.
Personally I like SmartAI a lot because unlike C ++ it has the big advantage of crossing wow versions and it is also much more accessible than learning a programming language.

So drop the kikou impression "this is for beginners I code in C ++ because I am a pro" Wink

But before starting it would be good to recover it ... and as much as possible already compiled: it's HERE

Then in the settings menu choose the game extension, the auto connection and what you want.

---


If you've never seen the SQL of a patch or update, its looks like this:

SET @ENTRY := 1100000;
UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
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,0,73,0,100,0,0,0,2000,2000,62,0,0,0,0,0,0,7,0,0,0,-14286.2,556.544,8.68897,4.36638,"Téléportation a Baie du Butin");

It is not very practical to edit or understand, especially if the script is long enough. SAI-Editor by a graphical interface will allow you to generate these lines in order to copy / paste them in a sql file (text) or to execute them directly in the DB.

In the latter case so that it is taken into account without having to restart the server, you will need:
- Whether the NPC already has his AIName defined in "SmartAI" or for the gameobject in "SmartGameObjectAI"
- type the command .reload smart_scripts
- Under 6x a small bug makes that the NPCs / GOB already spawn will not be refreshed, so you will need the respawn (.npc add 1100000 or .gob add 1100123)

Imgur: The magic of the Internet

( i can't up img more 75kb it's very wrong...)

For simplicity I would designate by MOB the creature which has this script and TARGET a mob (him or other), a player, a coordinate, etc. on which we will act. I would also cite only a few example actions because there are too many possible combinations.

The editing interface mainly includes 4 areas:
Each line in D indicates an execution (a test / action / target): if it passes its (4) then you make its (5) on the target (6), roughly:
- "He the mob" if you detect a hostile mob less than 50m send him a potato
- OR on this screen: if you right click on the NPC (spellclick) (4) then teleports to map 0 (5) the one who did this action (6), (6) will also include the XYZO coordinates of the place of teleportation as is the case most of the time when we designate a coordinate, because it is on the target that we act and not the mob.

Zone A:
1) Entry or guid: A positive value indicates the ID, a negative value a GUID
2) Source type: Defines what type of element will be scripted: SCRIPT_TYPE_CREATURE for mobs and SCRIPT_TYPE_GAMEOBJECT for gameobjects.
There are other choices but I admit never having used them or being sure that they are functional.


Zone B:
4) Event: Designates what will trigger / launch this line of the script, for example:
- EVENT_UPDATE_IC (0): if the mob is in combat
- EVENT_SPELLHIT (8): if the mob is under the effect of a spell
- EVENT_ACCEPTED_QUEST (19) & EVENT_REWARD_QUEST (20): here I play or take a quest from the mob
- EVENT_JUST_SUMMONED (54): in the case where the mob is a fart, if it has just been invoked

- EVENT_LINK (61): then this event is a bit special, it does not perform a test like the others but allows to chain events / action in D, because these lines do only one thing normally : 1 test + 1 action + 1 target.
If you want several simultaneous results for the same starting event condition, this is the choice to make, the big advantage is that if the previous action is not performed then it will not be executed, nor the following.
A far-fetched example to illustrate: if your goal is to bring a player down from his mount (dismount) and then transform him into a pig, he cannot be transformed into a pig since we cannot get him down from a mount because the player is on foot

- EVENT_GOSSIP_HELLO (64) & EVENT_GOSSIP_SELECT (62): in the first case click on the mob and in the second a choice gossip_menu as for example for an innkeeper click on "Make this inn your home", in this case it will be necessary to define its gossip flag and its gossip_menu_id in creature_template then the gossip_menu_option table. Example of gossip_menu_option:

REPLACE INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `OptionBroadcastTextID`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_poi_id`, `box_coded`, `box_money`, `box_text`, `BoxBroadcastTextID`) VALUES
(ID défini dansgossip_menu_id de créature_template , Nunero du choix 0 1 2 3 ... 99 du gossip, 0, "Faites de cette auberge votre foyer", 0, 1, 1, 0, 0, 0, 0, '', 0);

5) Designates the action itself, in 99% of the cases what the mob will do but not that, there are some specific exceptions.
- ACTION_ADD_QUEST (7): add a quest to the target (6)
- ACTION_WP_START (53): the target (6) begins to follow a path recorded in the waypoint table. Attention to create this path we will use the command .wp add ID but this one records this data in the waypoint_data table, it will be necessary to adapt it and import it into the waypoint table.

- ACTION_CROSS_CAST (86): this is precisely the special case, the 1% missing. The script actually goes for this line, pretending it was not executed on the mob ... nor the target ... but another defined in action (7). What is it for? well some aura or spell only act on the launcher and no one else. Here you want to apply it to the target (6) it is impossible because locked in the dbc.

Donc avec ACTION_CROSS_CAST (86) le script dit a trinity " bon c'est moi qui l’exécute mais fait comme ci c’était le petit gnome qui me cliquette la " .
Donc pour que le mob applique cette aura vérouillé au joueur il faudra remplir Target (6) sur TARGET_SELF (1) et action (7) sur Target type caster =7
Target : TARGET_SELF (1)

- ACTION_CALL_KILLEDMONSTER (33): One of the most important actions since it gives credit, it makes it possible to validate a quest condition. What you should know is that many quests have this type of credit as a condition even if what is asked is not to kill a creature. This is why you can come across wowhead NPCs with the mention "The location of this NPC is unknown.", This mention can also indicate a pet. It should be noted that this entry must exist as a PNJ in the table creature_template, even here I remind it it is not a PNJ strictly speaking and used only that in this case. I would come back to the question in a tutorial to repair quests thanks to keira2 + SAI-Editor.

6) Designate who or what we are going to act on.
- TARGET_SELF (1): the MOB itself
- TARGET_ACTION_INVOKER (7): for example the player who clicked on the mob, the one who launched the event (4).
- TARGET_POSITION (8): a coordinate which can be or must move this MOB, I remind that for all coordinates not designating the MOB it is necessary to inform that in TARGET_ACTION_INVOKER for the player for example and not by TARGET_POSITION.
- TARGET_VICTIM: the target on which the MOB hits: creature or player
- TARGET_CREATURE_DISTANCE (11): a creature lying between it and a maximum distance

3) Here some settings for each line of the script
- ID must be unique, however avoid ID 0 since the 0 is used in other boxes to indicate a line number in "none", its confusing.
- Link to & Link from are used to link the script lines when EVENT_LINK (61) in (4) is used, be careful if you change the ID these lines are not updated.


Zone C: Here we will define the parameters for commands 4 5 6 in zone B. Important: never leave time counters (expressed in thousand seconds) at zero in event C, when you define a despawn time always enter a minimum time even this one must be instantaneous (100ms for example), I already have had bugs for this reason. Most importantly ... if you change B then delete the data found in C which is no longer used for it. I also sometimes had bugs for this reason ... It's stupid to look for hours why a script does not work against all logic because of its Tongue


Zone D: Here appear the different lines of the script created in A B C.


Here it is finished ... phew ... it is always more difficult to explain or to understand in writing rather than by the experiment therefore Ci that seems complicated to you it is a little normal, do not throw the sponge but rather enter values in SAI-editor and experiment ... you will see how clearer and easier it is.


for example you can start by modifying, experimenting with the little script below:

-- Gazelle SAI
SET @ENTRY := 4166;
UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
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,2000,0,10,0,100,0,1,15,2000,2000,11,68326,0,0,0,0,0,1,0,0,0,0,0,0,0,"Si detecte mouvement hors combat : auto peur 8225");

Explanation: If this deer detects a movement between him and 15m and that he is out of combat, then he casts a fear spell on himself and therefore flees the one who approaches him.
FYI I used this script in the repack on critters and certain creatures such as Fallow Deer, Deer, Squirrel, Deer, Rabbit, Rat, Skunk, Giraffe, Troteur, Zhevra, Goeland, Seagull and even civilians.

You now have the right to go drink a beer and by the same to bring me one, good game to you

Credit to : Stitch from Aquayoup
 
Last edited by a moderator:
Top