| | Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE] |  | 
07-15-2009
|  | Sergeant | | | Join Date: May 2008
Posts: 46
Reputation: 16 Level up: 50%, 251 Points needed |     | | Amazing Lua guide!!! [CENTER] I know this has been done 100 times over but i want to explain it my way and add more onto it because what people have shown is really, really basic and will get you nowhere but a basic boss... TABLE OF CONTENTS 1. Begginers Guide....BASIC's 2. Casting Spells!! 3. Making your script loop! 4. Phases!! 5. Random Events WOOT! 6. How to add your script
Ok lets kick it off 1 == BASIC GUIDE The one thing you MUST remember is that Lua is sensitive
Ok lets start off simple...a function name. This means alot, it just names your script so you can register it late and it can be named anything you want but cannot be named something thats already used. lets name a function Quote:
function Random_OnCombat(pUnit, Event)
end
| this starts your script and will be used alot.
ok lets make this guy talk Quote:
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
end
| the 12 is the type of message you want Quote:
12 -- Talking
13 -- Whisper
14 -- Yelling
and much more
| the 0 is the language you want it in Quote:
0 -- Universal - heard by all
1 -- Orcish
2 -- Darnassian
3 -- Taurahe
6 -- Dwarven
7 -- Common
8 -- Demonic
9 -- Titans
13 -- Gnomish
14 -- Zalandari
33 -- Gutterspeak
35 -- Draenei
| now we need to make it complete by adding what he does when you leave combat and when you kill him or when he kills you. Quote:
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
end
function Random_OnLeave
pUnit:RemoveEvent() -- This removes the events above
end
function Random_OnDie
end -- BTW the end, ends the script...
-- now we register them to an NPC
RegisterUnitEvent(99999, 1, "Random_OnCombat") -- the 99999 is the ID of the npc
RegisterUnitEvent(99999, 2, "Random_OnLeave") -- The 2 is the type of event only change it for the Random_OnCombat
RegisterUnitEvent(99999, 4, "Random_OnDie) -- 3 is for when the npc kills someone
| here is a list of all the different things you can do with combat Quote:
CREATURE_EVENT_ON_ENTER_COMBAT = 1,
CREATURE_EVENT_ON_LEAVE_COMBAT = 2,
CREATURE_EVENT_ON_TARGET_DIED = 3,
CREATURE_EVENT_ON_DIED = 4,
CREATURE_EVENT_ON_TARGET_PARRIED = 5,
CREATURE_EVENT_ON_TARGET_DODGED = 6,
CREATURE_EVENT_ON_TARGET_BLOCKED = 7,
CREATURE_EVENT_ON_TARGET_CRIT_HIT = 8,
CREATURE_EVENT_ON_PARRY = 9,
CREATURE_EVENT_ON_DODGED = 10,
CREATURE_EVENT_ON_BLOCKED = 11,
CREATURE_EVENT_ON_CRIT_HIT = 12,
CREATURE_EVENT_ON_HIT = 13,
CREATURE_EVENT_ON_ASSIST_TARGET_DIED = 14,
CREATURE_EVENT_ON_FEAR = 15,
CREATURE_EVENT_ON_FLEE = 16,
CREATURE_EVENT_ON_CALL_FOR_HELP = 17,
CREATURE_EVENT_ON_LOAD = 18, -- this is for when the creature is spawned it starts the script
CREATURE_EVENT_ON_REACH_WP = 19, -- this is for when the NPC reaches a waypoint
CREATURE_EVENT_ON_LOOT_TAKEN = 20, -- this is for when its loot is well looted
CREATURE_EVENT_ON_AIUPDATE = 21, -- Dunno what this is 0_0
CREATURE_EVENT_ON_EMOTE = 22, -- this is when a specific emote the npc does happens
CREATURE_EVENT_COUNT, -- this is for a timer e.g. 40000 milliseconds or 40 seconds
| 2 -- CASTING A SPELL!!!
Lets use our script from before Quote:
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
end
function Random_OnLeave
pUnit:RemoveEvent()
end
function Random_OnDie
end
RegisterUnitEvent(99999, 1, "Random_OnCombat")
RegisterUnitEvent(99999, 2, "Random_OnLeave")
RegisterUnitEvent(99999, 4, "Random_OnDie)
| and lets say you arent happy with just text and you want a spell casted...DONE!
There is one simple way to do this, that is to make a new function or event and have it cast the spell but register it elsewhere...i know your like WHA??? but it will make sense in a moment
E.G. Quote:
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
pUnit:RegisterEvent("test_spell", 1000, 0) -- This makes it so that after he talks it goes down to test spell and does that event. The 1000 is a time in milliseconds to when the event is done and the 0 is how many times it is done 0 being a default of 1 time.
end
function test_spell(pUnit, Event)
pUnit:FullCastSpellOnTarget(11, pUnit:GetClosestPlayer()) -- This casts frostbolt of ages, the 11 is the spell ID and the pUnit:GetClosestPlayer()) is what the NPC targets and casts the spell on
end
function Random_OnLeave
pUnit:RemoveEvent()
end
function Random_OnDie
end
RegisterUnitEvent(99999, 1, "Random_OnCombat")
RegisterUnitEvent(99999, 2, "Random_OnLeave")
RegisterUnitEvent(99999, 4, "Random_OnDie)
| there are two ways to cast a spell one is for AOE and one is for target spells
pUnit:FullCastSpellOnTarget() is for Target spells and
pUnit:FullCastSpell() is for AOE spells like arcane explosion How to make your script loop
This enables a smaller better script that goes on until the npc dies. What i will do is loop it from 1st spell to 2nd spell to 1st spell and so forth
E.G. Quote:
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
pUnit:RegisterEvent("test_spell", 1000, 0)
end
function test_spell(pUnit, Event)
pUnit:FullCastSpellOnTarget(11, pUnit:GetClosestPlayer())
pUnit:RegisterEvent("test_spell2", 1000, 0) -- This uses the test_spell 2 event
end
function test_spell2(pUnit, Event)
pUnit:FullCastSpell(40647)
pUnit:RegisterEvent("test_spell", 1000, 0) -- this will use the test_spell event and loop it.
end
function Random_OnLeave
pUnit:RemoveEvent()
end
function Random_OnDie
end
RegisterUnitEvent(99999, 1, "Random_OnCombat")
RegisterUnitEvent(99999, 2, "Random_OnLeave")
RegisterUnitEvent(99999, 4, "Random_OnDie)
| You can use this on any number of spells, its like a circle chain you register the next event then at the last one you register the first thus creating a loop PHASES!!
Now onto phases.... Phases make your script much more eye-pleaseing and basically fun!
Now phases are simple and fun, you can make your NPC morph display IDs or mod the scale. You can even make them cast a spell and morph and change their scale at the same time!!
The way phases work is that at a certain Health percentage the npc triggers the event below. Quote:
function TEST_Morph1(pUnit,Event)
if pUnit:GetHealthPct() <= 75 then -- this checks to see if the NPC has 75 percent health
pUnit:RemoveEvents() -- this removes the GethealthPct command so it stops checking
pUnit:SetModel(18945) -- this changes the display ID
pUnit:SendChatMessage(12, 0, "You think you are a match for me? Pfft, what about if I do.... THIS?") -- this sends the chat message
pUnit:SetScale(0.1) -- this sets the scale!
| Now you can add anything below pUnit:RemoveEvents() like pUnit:FullCastSpell(SPELL ID) and much more!! Lua random math function!!!!
This is very useful if you want a boss fight never to be the same!! It is a little more complex but useful once you get the jist of it!
I will just show you through an example in one of my scripts! Quote:
function Leviathan_Talk(pUnit, Event)
Choice=math.random(1, 3)
if Choice==1 then -- this is saying that if it chooses number 1 then it will send a chat message and cast a spell!
pUnit:SendChatMessage(14, 0, "You are quite strong my friend! Feel the
power of the elements!")
pUnit:FullCastSpell(31895)
end -- this end is for the 1st choice's If command
if Choice==2 then -- this one is saying if it chooses choice 2 it will send a chat message and cast an AOE spell.
pUnit:SendChatMessage(14, 0, "If you run, I might just spare your lives!")
pUnit:FullCastSpell(31895)
end -- this end is for the 2nd choice's If command
if Choice==3 then
pUnit:SendChatMessage(14, 0, "The power i have, It will be enough to crush
you like little bugs!")
pUnit:FullCastSpell(31895)
end -- this end is for the 3rd choice's If command
end -- this end is for the function at the very top of math.random
| Now for how to input your script.
THIS IS THE REALLY EASY PART lol
1.find your arcemu core or repack. Usually located it C:\
2. Open it up
3. go into your arcemu folder if not already there
4. find the folder named SCRIPTS NOT! script_bin!
5. Open scripts up.
6. copy your .Lua file into there.
DONE!!
I hoped you enjoyed this... I know i did | Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
07-15-2009
|  | Knight-Lieutenant | | | Join Date: Nov 2008
Posts: 242
Reputation: 28 Level up: 61%, 198 Points needed | | | This could be very helpful for people who are just starting =) Nice guild btw
__________________  
Rep anyone who helps you or posts something usefull! | 
07-22-2009
|  | Is Bored | | | Join Date: Sep 2007 Location: England
Posts: 1,260
Nominated 38 Times in 2 Posts  TOTM/W Award(s): 1 Reputation: 545 Level up: 44%, 625 Points needed |     | | | Looks like an alright guide, but no rep for asking me to rep you on msn. | 
07-22-2009
|  | Sergeant Major | | | Join Date: Mar 2009 Location: Ohio
Posts: 147
Reputation: 69 Level up: 83%, 88 Points needed |  | |  simple and nice.
__________________ Need help with your PS (private server) well PM me and I'll do the best I can to help you out. ~-L0sT-~ | 
07-22-2009
|  | Sergeant | | | Join Date: May 2008
Posts: 46
Reputation: 16 Level up: 50%, 251 Points needed |     | | thanks, i would like to talk to you  i have a few questions | 
07-25-2009
|  | Sergeant Major | | | Join Date: Mar 2009 Location: Ohio
Posts: 147
Reputation: 69 Level up: 83%, 88 Points needed |  | | | Me (fillah)
__________________ Need help with your PS (private server) well PM me and I'll do the best I can to help you out. ~-L0sT-~ | 
07-26-2009
| | New User | | | Join Date: Jan 2008
Posts: 5
Reputation: 1 Level up: 83%, 68 Points needed | | | Really just an amazing guide!
I'm using a trinity and not arcemu, and i haven't been able to find the location of the scripts, do anybody know how i add a script to the server when it's trinity? :b | 
07-27-2009
|  | Sergeant | | | Join Date: May 2008
Posts: 46
Reputation: 16 Level up: 50%, 251 Points needed |     | | Quote:
Originally Posted by Sazs Really just an amazing guide!
I'm using a trinity and not arcemu, and i haven't been able to find the location of the scripts, do anybody know how i add a script to the server when it's trinity? :b | trinity uses C++ not Lua sorry lol | 
07-27-2009
|  | Lieutenant Commander | | | Join Date: Apr 2007
Posts: 626
Reputation: 51 Level up: 25%, 527 Points needed |     | | | It's an OK guide.
But it could be more colorful and just in general better.
__________________ Server ad's in sigs have to be approved by an admin. | 
07-27-2009
| | New User | | | Join Date: Jul 2009
Posts: 4
Reputation: 1 | | | Hey good guide thx | 
08-02-2009
| | New User | | | Join Date: Mar 2009
Posts: 5
Reputation: 1 Level up: 30%, 283 Points needed | | | I tried, but it doesesnt work.. I have made the npc with entry 9002, and it looks to me as you did exept names and id's.
Someone know what im doing wrong? Quote:
function Destruction_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Testing"
pUnit:RegisterEvent("Typhoon",10000, 0)
end
function Typhoon
(pUnit, Event)
pUnit:FullCastSpellOnTarget(53223, pUnit:GetClosestPlayer())
end
function Destruction_OnLeave
pUnit:RemoveEvent()
end
function Destruction:OnDie
end
RegisterUnitEvent(9002, 1,"Destruction_OnCombat")
RegisterUnitEvent(9002, 2,"Destruction_OnLeave")
RegisterUnitEvent(9002, 4,"Destruction_OnDie")
| | 
08-02-2009
| | Master Sergeant | | | Join Date: Aug 2008
Posts: 131
Reputation: 10 Level up: 97%, 16 Points needed |  | | Quote:
Originally Posted by klinkers I tried, but it doesesnt work.. I have made the npc with entry 9002, and it looks to me as you did exept names and id's.
Someone know what im doing wrong?  | Line number 2 doesnt have an ending Code: pUnit:SendChatMessage(12, 0, "Testing"
It needs to be Code: pUnit:SendChatMessage(12, 0, "Testing")
(you just didnt add the last ) needed to complete the line ;D) | 
08-03-2009
|  | Sergeant | | | Join Date: Dec 2007 Location: China. Haha jk.
Posts: 66
Reputation: 8 Level up: 15%, 429 Points needed | | | Code: function Destruction:OnDie
end
needs to be Code: function Destruction_OnDie
end
| 
08-05-2009
| | New User | | | Join Date: Aug 2009
Posts: 4
Reputation: 2 Level up: 11%, 359 Points needed | | | | This guide really is amazing!! |  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 01:56 AM. |