So you made a server, put in some custom mobs, and now you feel like giving them some "intelligent" functionality... Maybe make them to fry the player's arse or punt them away?
Well, it's possible with MaNGOS as well. The key?
ACID and ScriptDev2.
Now I'm skipping the explanation of the above to type it in further below, but since most people just want to speed it all up and get going, it's essential that you have your SD2 installed and configured correctly. Other guides covered that thoroughly so no need to repeat.
What I'll be tackling, is the simpler, database-related scripting of mobs.
Pros and Cons to it:
-It's fairly straight forward.
-It's lightweight and avoids compiling and such.
-It lacks the reload functionality. So restarting the server is still a requirement.
-It's not too comprehensive. Scripting simple mobs is fine, bosses... ScriptDev2 is there for that.
Basic Setup:
Knowing the limitation of ACID, aka Database Mob Scripting, it's time to get started on the basics to scripting it.
Let's start with what you'll want:
-A mob.
-The EventAI_Scripts table inside the Scripting Database (used by SD2)
-Stay sober. Please - Do it. If you get drunk at this step you'll end up in quite some trouble to figure out how to undo what you did and redo it the right way.
Let's start off by considering the first basic entry of a mob, at ID "60k". We'll make it so that it makes use of the mob_eventai script.
DATABASENAME: The name of your WORLD Database.UPDATE `DATABASENAME`.`creature_template` SET `ScriptName` = 'mob_eventai' WHERE `creature_template`.`entry` =CREATUREID LIMIT 1 ;
CREATUREID: The Creature to whom you'll bind this script to.
So now we configured the mob to make use of the scripts table. What's left for us is to make the mob cast da frigging spell
Now this is the complicated part. And it will require some playing around with, I personally spend 2 days working and testing possible outcomes, so don't expect to pull it off in one go. SD2 have their own IRC where you can pop in and ask questions there, but I'll leave searching that to you
So we're stuck with building the mob itself. This is where your head spins with all the values and such. I recommend this website to acquiring the general layout: Event AI Creator for UDB
Once you grab the SQL file, run through it and check if it's all fine or not. I'm guiding you through a simple spell for a mob at id "60k" in the following quote:
Ok let's break it down quickly./*60k Mob Frostbolt Rank 5*/
INSERT INTO `itagback_mfs`.`eventai_scripts` (`id`, `creature_id`, `event_type`, `event_inverse_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action1_type`, `action1_param1`, `action1_param2`, `action1_param3`, `action2_type`, `action2_param1`, `action2_param2`, `action2_param3`, `action3_type`, `action3_param1`, `action3_param2`, `action3_param3`, `comment`)
VALUES ('87000', '60000', '0', '0', '70', '1', '10', '20', '9000', '12000', '11', '16766', '1', '3', '0', '0', '0', '0', '0', '0', '0', '0', '60kMob Frostbolt');
- The First Value is what SQL always asks you for, and ID to identify that particular script entry. Keep it unique.
- The second value is the mob you're binding this to. Make sure it's correct, it can be duplicate if you're adding more than one event.
- Now the Event_Type is set to 0 which indicates a TIMED EVENT.
- Phase Mask is slightly more advanced so we're skipping on that.
- Event Chance is how possible is it for that event to take place? The value is percentage, do NOT include the % sign. 100 indicates an action which will trigger, 70 means it will occur slightly more oftenly than twice every 3 times. Etc.
-The Event_Flags is set to 1. This indicates it's repeatable.
-The next 4 values are the event parameters. Since our event is a TIMED EVENT, they are: MinTime, MaxTime, MinRepeat, MaxRepeat. They are in MILLISECONDS, thus 1000 = 1s. The event will trigger nearly immediately upon the mob entering combat. It will repeat the spell every 9 to 12 seconds.
The next values are the Action Values. Each entry is based on an EVENT. Once the event triggers, you're allowed to setup at most 3 actions.
I've only inputted one action in this case, that is to make it cast a spell. Each action has the Action_Type and 3 parameters.
In this case, the Action Type is "11" which indicates CAST.
The First Paramater is set to "1" This is the target type. Aka Hostile Player that the mob is focusing its attacks on.
The Second paramater holds the CAST FLAGS in the case of a CAST action.
I set it to three which basically interrupts any previous spell, and triggers the spell, even if the mob is lacking mana or particular reagants.
Now the question must be in your head by now:
How the **** do you know all that? The answer is the documentation. It explains what each field is for and what you can input in it.
Where to find the Documentation? Well, hoping you installed SD2 correctly, it's in there. It's a text file called EventAI.txt A quick search in the SVN should make it pop up.
I understand it's not the nicest-looking guide, and your eyes may be all messed up by now, but I just wanted to build a guide for getting people off on scripting, since most people end up staring at how to start off mob scripting and eventually give up.
Let me know if you have questions, and make sure you follow the Documentation to building your setups.