What you need:
=======================
1. Notepad
2. Lua Enabled on your server
=======================
Alright. I will give you a basic example of an Lua code and explain it to you.
1. Alrite the word function is always needed. What it does is basically tell the script what you are GOING to do. The names can be whatever you want.Code:function Captain_Dementox_Enrage(pUnit, event) if pUnit:GetHealthPct() < 40 then pUnit:RemoveEvents() pUnit:PlaySoundToSet(11273) pUnit:CastSpell(33653) pUnit:CastSpell(36900) pUnit:SendChatMessage(12, 0, "I have not come this far to be stopped! The future I have planned will not be jepordized! Now you will taste true power!") end end function Captain_Dementox_onCombat(pUnit, event) pUnit:PlaySoundToSet(11263) pUnit:SendChatMessage(12, 0, "Alas, sometimes one must take matters into one's own hands.") pUnit:RegisterEvent("Captain_Dementox_Enrage",1000,0) end function Captain_Dementox_onLeaveCombat(pUnit, event) pUnit:RemoveAura(33653) pUnit:RemoveAura(36900) pUnit:RemoveEvents() end function Captain_Dementox_onDeath(pUnit, event) pUnit:PlaySoundToSet(11204) pUnit:SendChatMessage(12, 0, "Forgive me my prince....I have..failed...") pUnit:RemoveAura(33653) pUnit:RemoveAura(36900) pUnit:RemoveEvents() end RegisterUnitEvent(26, 1, "Captain_Dementox_onCombat") RegisterUnitEvent(26, 2, "Captain_Dementox_onLeaveCombat") RegisterUnitEvent(26, 4, "Captain_Dementox_onDeath")
2. The parenthesis (pUnit, event) declares what you ARE doing.
pUnit means npc/player, event means what it is. They are not so important. You just have to know they have to be there.
3. Now I will list the basic commands in this code:
1.2.Code:pUnit:PlaySoundToSet(####) <--Plays a sound to the surrounding area<---Makes the NPC say what is in quotesCode:pUnit:SendChatMessage(12, 0, "Forgive me my prince....I have..failed...")
3.<---Removes the spell ID that is on the unitCode:pUnit:RemoveAura(####)
4.<---Casts the spell ID number on itself NOT on a playerCode:punit:CastSpell(####)
5.<--- This allows the script to get the current percentage of the mob's health at the time it is executed.[/li][/list]Code:pUnit:GetHealthPct()
REGISTERING YOUR EVENTS
Okay that is is a breakdown of the code. However in order to run these functions you need to tell the script when to run them and how to run them. This goes at the end of your code. In this example:
What we are telling the script to do is:Code:RegisterUnitEvent(26, 1, "Captain_Dementox_onCombat") RegisterUnitEvent(26, 2, "Captain_Dementox_onLeaveCombat") RegisterUnitEvent(26, 4, "Captain_Dementox_onDeath")
1. Run the function/event "Captain_Dementox_onCombat"
2. Run the function/event "Captain_Dementox_onLeaveCombat"
3. Run the function/event "Captain_Dementox_onDeath"
Now how does the script know when these events occur? Well that is what the little numbers are:
The number 1 signifies that this will run once the mob enters combatCode:RegisterUnitEvent (26, 1, "Captain_Dementox_onCombat") RegisterUnitEvent (26, 2, "Captain_Dementox_onLeaveCombat") RegisterUnitEvent (26, 4, "Captain_Dementox_onDeath")
The number 2 signifies that this will run when you run from a mob
4. signifies that this will run when the mob is killed.
These numbers are hard coded into your LuA Engine. You can't just go making numbers up as the engine will not recognize what you are doing.
Once you create a code in notepad you must save it as a .lua file. and then put it into the scripts folder in your ascent directory NOT the scripts_bin folder.
By default LuA is disabled on ArcEmu, you must enable it if you compile your own version. So you will find out if your server has it when you put scripts into the script folder of ascent and see if it loads up. Many repacks do have it enabled however.
Credits :
Halestorm @ wow vendetta
Yvoms @ Mmotop Guidelines.



LinkBack URL
About LinkBacks



Reply With Quote



Bookmarks