Hello guys,
I planned on doing this for a while now, but I was delayed with a permanent ban, thanks to someone who recently left the Shaiya Section.
Anyway, here we are, a short tutorial on how to create custom monster AI, AI standing for artificial intelligence.
First of all, what does AI in Shaiya mean, and what can you do with it ?
Such a thing is seen in game only on 2 maps. It has nothing to do with the maps, except for the fact that those maps are Caelum Sacra F1(light), Caelum Sacra F1(fury) and Caelum Sacra F2, and as you probably already know, the monsters affected by custom AI, which we're going to be guiding by in this tutorial, are all forms of Dios Exiel and his 4 guards, Eternel, Gargadel, Huistaton and Luhiel.
Let's get started. The files that you're going to need are stored on the server side, obviously, in the PSM_Client\Bin\Data\Lua folder.
I think the best way to understand this is by applying a custom AI to a monster that doesn't have one yet. All you have to do is follow along, and do exactly as the tutorial says. If you do everything right, you will most likely understand how this works.
Let's say we take Dentatus and apply a custom AI to it that does the following:
The first line says something like :
The 2 numbers I underlined stand for the ID of the mob you want the AI to be applied on, and for the number of the AI, so basically it must look like this:
The following line respresents the initialization of the custom AI:
These 3 lines represent the initialization of 3 variables:
These lines are the function declarations:
For what we set out to do we could have used more of the above functions, but I decided to put all the code in the last one, which is function WhileCombat.
We need to make Dentatus insult us. Everything a monster speaks is located on the client side, in sysmsg-uni.txt. Go to the bottom, and make a new line. For this tutorial we'll use line count from 12001 on.
It should look like:
Since I decided to store all the things we're going to do in the WhileCombat function, we had to run a check on the monster's health. Normally you cannot kill Dentatus in 1 hit, so the first line checks if Dentatus's HP is at 95% or above, which surely has to be. The second line checks the variable bMobSay, which is a counter for how many times the monster has spoken. The next, third line is the one that makes the monster actually speak, the first parameter stands for the index of the string it needs to display, taken from the sysmsg-uni.txt. The forth line is where we increment the bMobStay variable, which again, is a counter for how many times the monster has spoken. The AI will still work without it, but as you saw our second line, we need to keep track of the amount of times the monster has spoken.
We need to make it so when Dentatus reaches 75%, Secreta will spawn and Dentatus will say something related to that.
The text goes inside the WhileCombat function, below the one we wrote for the first part of our objective.
As you see, there's just one new function that is actually very easy to understand, but I'll still explain it shortly. The LuaCreateMob function is the one responsible for a new spawn. The 4 parameters stand for MobID to be spawned, how many of those mobs to be spawned and the coordinates on the X and the Z axises where to spawn the specified amount of mobs of the specified MobID. If the coordinates are 0.0 it will spawn in the same point where the monster whom the AI is applied to.
Part 3 shouldn't be hard to complete on your own, as it is very similar to Part 2.
We need to make it so when Dentatus's HP reaches 25%, Ales will spawn, Dentatus will say something related to that and it will also start using Death Breath.
The function that is still new to you is LuaAttackAI. It enables the use of another skill, the parameter representing the SkillID of the skill you want the monster to use, taken from the NpcSkill.SData. NpcSkill.SData is the file located in the client side, in the Data\Monster folder. If you want to be able to open it with Shaiya Studio, rename it to Skill.SData. There you can find all the skills available for the monsters to use. The equivalent skills server sided are located in the database, inside PS_GameDefs.dbo.Skills, with SkillLevel = 100.
The fifth part is just like part 2 and 3, so you shouldn't have any problem to write that.
Before testing, don't forget to assign the AI to the mob, in this case Dentatus:
A server restart is required to make the changes apply.
P.S. I wrote this tutorial from college, on a PC that was built in the previous century, so everything comes from my head. I've previously done that on my test server, and it was successful. If this doesn't work as expected, I'll look into it more when I get home.
I planned on doing this for a while now, but I was delayed with a permanent ban, thanks to someone who recently left the Shaiya Section.
Anyway, here we are, a short tutorial on how to create custom monster AI, AI standing for artificial intelligence.
First of all, what does AI in Shaiya mean, and what can you do with it ?
- Spawn multiple monsters when some event is triggered on a monster. For example: When a mob reaches 80% of its full HP, you can make it duplicate itself. You can also choose where a new mob will be spawned after the event is triggered, which makes this custom AI much more flexible than what you can do in Obelisk.ini
- Unlock portals.
- Make the mob affected by this AI to change the types of attacks or use other attack skills.
- Make monsters talk.
- Delete monsters.
- More cool things that you might wanna research by yourself.
Such a thing is seen in game only on 2 maps. It has nothing to do with the maps, except for the fact that those maps are Caelum Sacra F1(light), Caelum Sacra F1(fury) and Caelum Sacra F2, and as you probably already know, the monsters affected by custom AI, which we're going to be guiding by in this tutorial, are all forms of Dios Exiel and his 4 guards, Eternel, Gargadel, Huistaton and Luhiel.
Let's get started. The files that you're going to need are stored on the server side, obviously, in the PSM_Client\Bin\Data\Lua folder.
I think the best way to understand this is by applying a custom AI to a monster that doesn't have one yet. All you have to do is follow along, and do exactly as the tutorial says. If you do everything right, you will most likely understand how this works.
Let's say we take Dentatus and apply a custom AI to it that does the following:
- Part 1 : When you start attacking it, it will insult you.
- Part 2 : When its HP reaches 75%, Secreta will spawn and Dentatus will say something related to that.
- Part 3 : When its HP reaches 50%, Lumen will spawn and Dentatus will say something related to that.
- Part 4 : When its HP reaches 25%, Ales will spawn, Dentatus will say something related to that and it will also start using Death Breath.
- Part 5 : When its about to die, Dentatus will totally curse you and promise to take revenge.
The first line says something like :
Code:
-- Д«АП·л »зЕ©¶у єёЅє 2Вч_єРЅЕ јТИЇµЗ±вАь ёуЅєЕН_ID-2470 AI 117.Lua ver.090113
Code:
-- Д«АП·л »зЕ©¶у єёЅє 2Вч_єРЅЕ јТИЇµЗ±вАь ёуЅєЕН_ID-2821 AI 119.Lua ver.090113
Code:
Mob = LuaMob(CMob)
Code:
dwNextCreateTime = 0 bMobSay = 0 bMobCreate = 0
Code:
function Init() end function OnAttacked( dwTime, dwCharID ) end function OnAttackable( dwTime, dwCharID ) end function OnNormalReset( dwTime ) end function OnDeath( dwTime, dwAttackedCount ) end function OnReturnHome( dwTime, dwAttackedCount ) end function OnMoveEnd( dwTime ) end function WhileCombat( dwTime, dwHPPercent, dwAttackedCount ) end
For what we set out to do we could have used more of the above functions, but I decided to put all the code in the last one, which is function WhileCombat.
Part 1:
We need to make Dentatus insult us. Everything a monster speaks is located on the client side, in sysmsg-uni.txt. Go to the bottom, and make a new line. For this tutorial we'll use line count from 12001 on.
It should look like:
Code:
12001 "My name is Dentatus and yo mama's so fat that she's stuck at the login page."
Code:
if ( dwHPPercent >= 95 ) then if ( bMobSay < 1) then Mob:LuaSayByIndex ( 12001, 200.0 ) bMobSay = bMobSay + 1 end end
Part 2:
We need to make it so when Dentatus reaches 75%, Secreta will spawn and Dentatus will say something related to that.
The text goes inside the WhileCombat function, below the one we wrote for the first part of our objective.
Code:
if ( dwHPPercent <= 75 ) then if ( bMobSay < 2) then Mob:LuaSayByIndex ( 12002, 200.0 ) bMobSay = bMobSay + 1 end Mob:LuaCreateMob ( 2803, 1, 0.0, 0.0 ) end
Part 3 shouldn't be hard to complete on your own, as it is very similar to Part 2.
Part 4:
We need to make it so when Dentatus's HP reaches 25%, Ales will spawn, Dentatus will say something related to that and it will also start using Death Breath.
Code:
if ( dwHPPercent <= 25 ) then if ( bMobSay < 4) then Mob:LuaSayByIndex ( 12004, 200.0 ) bMobSay = bMobSay + 1 end Mob:LuaCreateMob ( 2785, 1, 0.0, 0.0 ) Mob:LuaAttackAI ( 173 ) end
The fifth part is just like part 2 and 3, so you shouldn't have any problem to write that.
Before testing, don't forget to assign the AI to the mob, in this case Dentatus:
Code:
UPDATE PS_GameDefs.dbo.Mobs SET AI = 119 WHERE MobID = 2821
P.S. I wrote this tutorial from college, on a PC that was built in the previous century, so everything comes from my head. I've previously done that on my test server, and it was successful. If this doesn't work as expected, I'll look into it more when I get home.