Sign in to follow this  
Followers 0
gacob

[TUTORIAL] Smart_scripts - basic level

2 posts in this topic

In first place, i'm spanish so i can have mistakes in my english. Sorry for that.

 

Smart_scripts is avanced stuff, please, learn the basic first.

How to fix loot

Translation of quests

Behavior of a creature

 

In this tutorial you will learn a basic level of smart_scripts(SAI). SAI is used to do scripts for spells, quests, creatures, etc. In this tutorial you will learn to add spells to a creature.

Wiki

SAI wiki

 

First you need prepare the creature for allow SAI, for do this you need edit the field called `AIName` in `creature_template`. The field `AIName` is a char(64) type, this means than the field is text with 64 maximum characters. If you know the enough about types, you should know than that fields use quotes(' ' in SQLYog, " " in HeidiSQL). You have to edit the field to "SmartAI".

UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=XXX;

 

Now the creature is ready for allow SAI but there still you have to do things in creature_template. If we will work in SAI with spells, first you have to add the spells to the creature. I gonna use spell1=50 and spell2=100 only for this tutorial.

UPDATE `creature_template` SET `spell1`=50, `spell2`=100 WHERE `entry`=XXX;

Now we can start to use SAI.

• Field explanations:

- Entryorguid = ID of the creature,gobject,etc

- Source_type = If the ID is a creature, a gobject, etc. (0 creature, 1 gobject)

- id = This starts in 0 and it's the id of the SAI code.

- Link = This is for link a id to other id using event_type 61 (for example, id 3 only will work if id 2 worked)

- Event_type = This is the list of the causes called events (in combat, out of combat, a player in range, when a quest finish, etc)

- Event_phase_mask = It's the phase of the SAI

- Event_chance = This means what chance has the event to happens

- Event_flags = Flags than control in what conditions can the event happens

- Event_param1-4 = Params of the event_type chosen

- Action_type = The action than will be triggered when the event happens

- Action_param1-6 = Params of the action_type chosen

- Target_type = Who will be the target of the action

- Target_param1-3 = Params of the target

- target_x-o = This is only used in some cases

- Comment = A comment of your script with " "/ ' '

DELETE FROM `smart_scripts` WHERE `entryorguid` IN (XXX);
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
(xxx, 0, 0, 0, 0, 0, 100, 0, 100, 20000, 3000, 17000, 11, 50, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Cast spell 50'),
(xxx, 0, 1, 0, 0, 0, 100, 0, 100, 20000, 30000, 38000, 11, 100, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Cast spell 100');

 

For script spells in SAI to a creature, we have to use  SMART_EVENT_UPDATE_IC  (0) than means that it happens when the NPC is in combat. It has params: InitialMin, InitialMax, RepeatMin and RepeatMax. The values have to be in milisecs and InitialMin means the minimum time which the spell can be launched(in my script, you can see that the spell can be launched in minimum 0,1 seconds and in maximum 20 seconds). RepeatMin and RepeatMax means the same but for the second time and more than the spell will be launched, the RepeatMin must to be minimum the CD/cast of the spell.

For action we have to use SMART_ACTION_CAST (11) with param1 spellid(50 and 100), castflag(0) and triggeredinflags(0). The other params in 0 too.

For the target_type, it depends. If it's a spell than the NPC launch to the enemy, the value is  SMART_TARGET_VICTIM (2) but if it's a spell than the NPC launch in himself, it's  SMART_TARGET_SELF (1). There can be more options.

 

This is the end of the tutorial, you can do questions and ask me for other tutorials.

Edited by TitanFurryWf
Edited code
4 people like this

Share this post


Link to post
Share on other sites

In the SAI code i have some mistakes by copy&paste a code for the example.

"194488" in action_type param1 is 50 and "215377" is 100. If a mod can change it, thanks you.

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0