Hello every one,
Well i know that there is many "How to script Boss in Lua" tutorials
But im gonna update this almost every day..
So this is how we gonna start..
First of all we need to make template of boss script.
So lets start:
Code:
function OnCombat(Unit, event, player)
end
function OnLeaveCombat(Unit, event, player)
end
function OnDeath(Unit, event, player)
end
function OnKilledTarget(Unit, event)
end
RegisterUnitEvent(NPCID, 1, "OnCombat")
RegisterUnitEvent(NPCID, 2, "OnLeaveCombat")
RegisterUnitEvent(NPCID, 3, "OnKilledTarget")
RegisterUnitEvent(NPCID, 4, "OnDeath")
So that was some simle structure...
Now we gonna add some phases etc because if we leave it like this
Boss wont do anything, also it wont work because in registers we typed
NPCID but we did not add local for it.
So next we gonna add this:
Code:
local NPCID = 23995 -- there change 23995 to some number of your boss ID
okay now we wont get any error but still boss wont do anything..
So we gonna edit little this first functions...
Code:
------------------------------------------
--locals--
-------------------------------------------
--Main Temp--
-------------------------------------------
local NPCID = 23995 -- there change 23995 to some number of your boss ID
local randomtext = math.random(1,2)
local InRange = Unit:GetInRangePlayers()
function OnCombat(Unit, event, player)
Unit:SendChatMessage(14, 0, "You cant beat me,you will die!") -- So this was my custom text on enter in combat if you dont like it just change everything from " "
Unit:PlaySoundToSet(12527) -- Also you can add some sound on start change sound id from ( ).. visit this topic for more ids http://www.mmowned.com/forums/world-of-warcraft/emulator-servers/54099-playall-list.html
Unit:RegisterEvent("Mage_Armor", 1000, 1) -- Now register event for Mage Armor spell
Unit:RegisterEvent("Phase1", 1000, 0) -- Phase 1 starting
end
function OnLeaveCombat(Unit, event, player) -- When you run away from boss or leave combat...
Unit:PlaySoundToSet(12497) -- Again some Music :P
if randomtext == 1 then
Unit:SendChatMessage(14, 0, "Cowards come back to me!") -- random text on leave combat
if randomtext == 2 then
Unit:SendChatMessage(14, 0, "Haha take sickness!!") -- random text on leave combat
for k,v in pairs(InRange) do
v:CastSpell(69131)
Unit:RemoveEvents() -- And ofc we want to remove boss events on leave combat...
end
end
end
function OnDeath(Unit, event, player)
Unit:RemoveEvents()
Unit:PlaySoundToSet(11964)
Unit:SendChatMessage(14, 0, "Nooooooooooooooooooooo!")
local InRange = Unit:GetInRangePlayers()
for k,v in pairs(InRange) do
v:CastSpell(58451)
v:CastSpell(58451)
v:CastSpell(48100)
v:CastSpell(58452)
v:CastSpell(48104)
v:CastSpell(48102)
v:CastSpell(48469)
v:CastSpell(61024)
v:CastSpell(20217)
v:CastSpell(48161)
v:CastSpell(48073)
v:CastSpell(48169)
v:CastSpell(54675)
v:CastSpell(15366)
v:CastSpell(33077)
v:CastSpell(53307)
v:CastSpell(43017)
v:CastSpell(5697)
v:CastSpell(132)
v:CastSpell(1706)
v:CastSpell(16618)
end
end
end
function OnKilledTarget(Unit, event)
Unit:SendChatMessage(14, 0, "Hahahah Die Die Die!")
Unit:RegisterEvent("SpellWave", 10000, 1000000) -- Cast Blast Wave
Unit:PlaySoundToSet(12498)
end
end
RegisterUnitEvent(NPCID, 1, "OnCombat")
RegisterUnitEvent(NPCID, 2, "OnLeaveCombat")
RegisterUnitEvent(NPCID, 3, "OnKilledTarget")
RegisterUnitEvent(NPCID, 4, "OnDeath")
------------------------------------------
--------------------------------------
-- Spell Events--
---------------------------------------
function Mage_Armor(Unit,Event) --Mage Armor
Unit:CastSpell(43024)
end
function SpellWave(Unit, event) --Blast Wave
Unit:CastSpell(38536)
Unit:PlaySoundToSet(12507)
end
-------------------------------
So this is something simple but now again wont work good because we registred phase1 but we didnt added it so we need to finish it..
after Spell events at bottom add this:
Code:
-------------------------------------
-- Phases--
-------------------------------------
function Phase1(Unit,Event)
if Unit:GetHealthPct() <= 90 then -- If boss has 90% then phase 1 starts
Unit:RemoveEvents()
Unit:SendChatMessage(12, 0, "Take this!")
Unit:RegisterEvent("Cone_of_Cold", 10000, 0)
Unit:RegisterEvent("Frost_Ward", 30000, 0)
Unit:RegisterEvent("Frostbolt", 5000, 0)
--- Add here Unit:RegisterEvent("Phase2", 1000, 0) if you want phase 2
end
end
Frequently Asked Questions:
What application you use for scripting?
Well i prefer Notepad++ but you can use and Notepad or any other text editor..
How to add this script to my server?
Save as NAME.lua and copy it in Core Folder/Scripts
Lua Rules:
Remember: Every 'if' requires an 'end'
Remember: Every 'function' requires an 'end'
Remember: Every 'for' requires an 'end'
Remember: Lua is case sensitive and code sensitive. (ex: pPlayer: cannot be pplayer: )
Remember: You must use statements that ArcEmu has implemented. (ex: pPlayer:GetName(). Not: pPlayer's:Name())
Remember: You can comment things with '--'. Comments WILL NOT be noticed by the Lua Engine. Comments can include your thoughts, ToDo's, and more. (ex: -- Tutorial by Trle94 from Mmowned)
Remember: Block comments can comment more than one line (ex:
--[[Remember: Every 'if' requires an 'end'
Remember: Every 'function' requires an 'end'
Remember: Every 'for' requires an 'end' ]]-- )
Feel free to ask anything you dont understand and Im gonna help you.
Credits:
TRLE94