theeverysiteforum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

basic eventai

Go down

basic eventai Empty basic eventai

Post by Digit Sun Jan 17, 2016 10:02 am

Alright so i've noticed there isnt really that much information nor tutorials about EventAI scripting, (or maybe I just suck @ google search), and since i've learned so much from this community I wanted to repay a little with this tutorial (tested only on a 3.3.5 trinitycore2 server, might work on some others).

What is EventAI?

A: Under my own understanding, EventAI is one of the current only 2 possible ways to script mobs on Trinitycore (being C++ the other one), the great advantage of EventAI is the fact that scripting on it is way faster and easier than it is on C++, the downside of it is that it's limited in terms of flexibility of events. While you can achieve powerful scripting on it, will never be as good and complete as C++, though, learning and completely understanding C++ might take from weeks to months, its always your choice, anyways, let's begin.

Tools and General requierements

- Access to the database files (ofc)
- Truice editor software (download here (http://truice.googlecode.com/files/Truice_rev63.7z))

Setting up and preparation

First step is to install truice, once done, open it and it will promp for your database access info, type it and click on connect.

Now search for the "Creature" tab, click it, and on the search bar input the name of the mob you want to script, lets suppose you created a custom mob called Justin Bieber (I will not cover the part of creating custom mobs, there are plenty of tutorials outthere on how to make one), then double click on him, that will open new sub tabs, then click on the "Event AI" tab located by the right of the screen, this is where we're going to work, you should see a screen like this:

https://2img.net/h/i150.photobucket.com/albums/s87/yashirotcm/t1.jpg

How does EventAI work?

A: Pff, explaining how it works is kinda hard for me, cause it can get confusing at times. But basically, EventAI consists on making the mob perform actions depending on what situation it is in and when it should execute them, example: If Im walking by the park and then 3 thugs appear by me, I can:

a) Run for my life
b) Withdraw a chainsaw and rip their heads off
c) quickly take my phone and call the police

When to perform action a: Instantly!
When to perform action b: 5 seconds after my Chainsaw is withdrawn
When to perform action c: 2 seconds after i get my hands on my phone.

If you could not understand the logic on that then read again, if after reading over u couldn't understand then stop reading, this guide is not for you.

And basically thats the logic behind EventAI, so lets do this!

:::::MAKING YOUR MOB CAST FROSTBOLT EACH 5 SECS:::::

Lets say we want Justin Bieber to cast Frostbolts at his enemies in an infinite loop of 5 secs each, the values and final script will look like this:

https://2img.net/h/i150.photobucket.com/albums/s87/yashirotcm/t2.jpg

Explanation of field values:

id: This the id of the event, by event we mean the situation that will make me take actions, aka the thugs appearing by, this value can be any number and must be UNIQUE, since more events might be added later, I chose number 85000, choose yours.

creature_id: Lets say your custom Justin Bieber's creature id is 54100, then put that vaule there, cause this is where you tell the script which mob will have that script.

event_type: This field is like the main engine of the script, as this is the one that will define what will trigger the actions. I picked value 0 which is event_t_timer, which is an event that performs actions in a loop defined by an specific timer. for a complete list of possible events and their descriptions click here (http://www.trinitycore.org/w/How-to:EventAI#Event_Explanations), but for now set it to 0

event_inverse_phase_mask: this field refers to phases, phases are perhaps the most complex part to understand about EventAI so i will not be covering it on this tutorial. for now leave it on 0

event_chance: percentage (%) of chance this event will happen, if u want it to always happen, set it to 100.

event_flags: Set it to 5 if your mob will be outdoors, or either 2 or 3 if your mob will be spawn inside instances.

event_param 1 to 4: The values on these fields change depending on the type of event you chose on the event_type field, refer to the link i previously gave you to check the values for each individual event type. In this case I want Justin to perform his first cast after 1 to 2 secs of entering combat mode (values here are set in miliseconds) set on fields event_param1 and 2, and then again each 5 to 6 secs set on fields event_param3 and 4.

action1_type: as you've probably noticed by now, each event can have up to 3 different actions you can perform simultaneously as a response of the event, you cannot mix actions that requiere a load or cast time though, i.e., you cannot perform 2 cast timed spells simultaneusly, i think its obvious why, though for this example we will only perform one action, I chose action 11 which is action_t_cast which is the action that commands the mob to cast a spell, for a list of all the possible action types click here (http://www.trinitycore.org/w/How-to:EventAI#Action_Explanations).

action_param 1 to 3: these values vary just like events, depending on the action type you chose, so again, check the list of possible actions to understand their values. I chose 59855 for action1_param1, which is the spell id of the Frostbolt spell i want the mob to cast, you can use sites like www.wowhead.com to find out the id's of the spells you want. Now I put a 1 on action1_param2 cause the target the frostbolt will be shot at is a hostile in the 1st place of aggro list (tank), then 0 on action1_param3 cause i don't need it to interrupt any other cast.

now fill the rest of the fields with zeros as we will not be adding extra actions except the comments field which is optional yet very useful so you do not confuse yourself in a sea of events :p, at this point i must clarify that no field must be left unfilled or you will get an SQL error at the time of compiling it.

Ok, now that all the fields are filled with the correct values, click the "+" green button to add that event to the script line, then click on "Show Event AI Script" button which will take you to another tab where you will then click on the Execute script button and confirm the action, now click back on the Event AI tab and click on the bottom "Show FULL Event AI Script" button, and do the same. 

NOW IT'S TIME TO TEST YOUR SCRIPT!

First, reset your server so it reloads the scripts, log into the game, spawn your mob and watch it cast those frostbolts at you!, (dont forget to .gm off first) :p

Also make sure the mob's faction is set to one that is hostile to you on the creature_template table.

I will try to cover different and more complex scripts in my next tutorial, like making mobs to heal other mobs, summons, enraging at a certain % of health left, etc. but for now I strongly recommend you all to experiment with different types of events and actions and see what you can achieve.

Hope this helps, cya =3

Digit
Admin

Posts : 8
Join date : 2016-01-17

https://theeverysite.board-directory.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum