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
function
Random_OnCombat(pUnit, Event)
end
this starts your script and will be used alot.
ok lets make this guy talk
function Random_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Enter Custom Text Here")
end
the 12 is the type of message you want
12 -- Talking
13 -- Whisper
14 -- Yelling
and much more
the 0 is the language you want it in
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.
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
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
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.
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.
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.
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!
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