Jump to content

[TUTORIAL] How to script with SmartAI


Frappe
 Share

Recommended Posts

Note! This is a tutorial wrote by me, therefore there might be some mistakes so please feel free to correct me.

 

 

 

Requirements:

* Installed and Running SkyFire Fork

* Any version of TDB

* An SQL Editor(HeidiSQL)

* Notepad++

 

Introduction

 

In order to use SmartAI you may want to be sure that you already have some basic skills of SQL. For instance you should know how to EDIT a DataBase, or how to verify your work.

 

Documentation

 

You may want to read and try to FULLY Understand what is written here:

>URL HERE<

 

Trust me when I say, there is no need for you to proceed further if you have absolutely no idea what is there.

 

All these being said, let's proceed with an example, since talking is cheap and usually until you won't have an Example, you will probably understand nothing.

 

 

Example

 

- First of all you have to decide what the script will be used for. For instance, you want to script an Object, a Creature... you need to decide.

 

*I shall pick this Creature:

>URL HERE<

 

*This Creature is related to the quest:

>URL HERE<

 

- As seen on someone's report this Creature can't be attacked, therefore the Quest can't be completed.

 

*You can also notice that the Creature has an Aura applied on it:

>URL HERE<

 

- As long as that Aura is on the Creature you can not attack it. The Quest has an item that SHOULD remove that aura when used, unfortunately it's not working as it should.

 

*You quickly notice that the item:

>URL HERE<

 

*Is working just fine CASTING the spell:

>URL HERE<

 

So what can be done?

 

 

 

 

 

You can use SmartAI to make the creature RESPOND when that SPELL is being CASTED on the CREATURE.

 

How?

*Quite easy. We shall now start creating the script as we know what needs to be done.

 

Step 1 - Assign SmartAI to the Creature so he can use it by doing so:

UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=24464;

 

Now the CREATURE will use SmartAI.

 

Step 2 - Create the Script.

I shall quote the query and explain it later.

 

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`, `comment`, `target_y`, `target_z`, `target_o`) VALUES (24464, 0, 0, 0, 8, 0, 100, 0, 50133, 0, 0, 0, 28, 43874, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 'On Spell Hit- Remove Aura', 0, 0, 0);

 

 

So basically what you did UP THERE? It's easy...

*You set the `entryorguid` 24464 since this is the Creature that will use the script.

*You set the `id` 0 since this is the first command executed by this script(You can add more, it's an incremented vallue.

*You set `event_type` 8 since this is the VALUE for "SMART_EVENT_SPELLHIT"

*You set `event_param1` 50133 since this is the spell that will start the EVENT when RECEIVED.

 

http://www.wowhead.com/spell=50133

 

*You set `action_type` 28 since this is the VALUE for "SMART_ACTION_REMOVEAURASFROMSPELL"

*You set `action_param1` 43874 since this is the AURA we want to REMOVE when the EVENT occurs.

 

http://www.wowhead.com/spell=43874

 

*You set `target_type` 1 since this is the VALUE for "SMART_TARGET_SELF"

 

So, now that CREATURE will use SmartAI, and when it will RECEIVE the SPELL casted by the QUEST ITEM, that AURA will be automatically be removed, and you may now attack it while completing the quest.

 

 

Now you should know:

*What a Smart Script means.

*How to Assign one.

*How to Create one.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.