Likes: 0
Results 1 to 4 of 4
Thread: How to script a boss in LUA
-
03-09-08, 10:47 AM #1
How to script a boss in LUA
Register to remove this adFist off, i suggest that you draw up a list of what you want your boss to do and all of the spells he will use. I also suggest that you sit down and write exactly how you want the fight to start off.
Now lets get to some code:
We need to start off by giving the boss some basic combat events:
Code:--[[ Zaxis.lua Author: Insomnicide]]-- --Zaxis Script AI-- function Zaxis_OnCombat(pUnit, Event) end function Zaxis_OnLeaveCombat(pUnit, Event) pUnit:RemoveEvents() end function Zaxis_OnDied(pUnit, Event) end function Zaxis_OnKilledTarget (pUnit, Event) end
Code:function Zaxis_OnCombat(pUnit, Event) end function Volley(pUnit, Event) pUnit:FullCastSpellOnTarget(45031, pUnit:GetRandomPlayer(0)) end function Flash(pUnit, Event) local stomprel="nofollow" target=pUnit:GetMainTank(); pUnit:FullCastSpellOnTarget(46442, stomptarget) end function Nova(pUnit, Event) pUnit:CastSpellOnTarget(30852, pUnit:GetRandomPlayer(0)) end function Drain(pUnit, Event) pUnit:CastSpellOnTarget(46466, pUnit:GetRandomPlayer(0)) end function Beam(pUnit, Event) pUnit:CastSpellOnTarget(40759, pUnit:GetRandomPlayer(0)) end function Negative(pUnit, Event) pUnit:CastSpellOnTarget(46285, pUnit:GetRandomPlayer(0)) end function Zaxis_OnLeaveCombat(pUnit, Event) pUnit:RemoveEvents() end function Zaxis_OnKilledTarget (pUnit, Event) end function Zaxis_OnDied(pUnit, Event) end
Code:function Zaxis_OnCombat(pUnit, Event) pUnit:RegisterEvent("Combat_Talk", 30000, 0) pUnit:RegisterEvent("Nova", 45000, 0) pUnit:RegisterEvent("Flash", 25000, 0) pUnit:RegisterEvent("Volley", 27000, 0) pUnit:RegisterEvent("Drain", 15000, 0) pUnit:RegisterEvent("Beam", 30000, 0) pUnit:RegisterEvent("Negative", 32000, 0) end function Volley(pUnit, Event) pUnit:FullCastSpellOnTarget(45031, pUnit:GetRandomPlayer(0)) end function Flash(pUnit, Event) local stomprel="nofollow" target=pUnit:GetMainTank(); pUnit:FullCastSpellOnTarget(46442, stomptarget) end function Nova(pUnit, Event) pUnit:CastSpellOnTarget(30852, pUnit:GetRandomPlayer(0)) end function Drain(pUnit, Event) pUnit:CastSpellOnTarget(46466, pUnit:GetRandomPlayer(0)) end function Beam(pUnit, Event) pUnit:CastSpellOnTarget(40759, pUnit:GetRandomPlayer(0)) end function Negative(pUnit, Event) pUnit:CastSpellOnTarget(46285, pUnit:GetRandomPlayer(0)) end function Zaxis_OnLeaveCombat(pUnit, Event) pUnit:RemoveEvents() end function Zaxis_OnKilledTarget (pUnit, Event) end function Zaxis_OnDied(pUnit, Event) end
Code:function Zaxis_OnCombat(pUnit, Event) pUnit:RegisterEvent("Combat_Talk", 30000, 0) pUnit:RegisterEvent("Nova", 45000, 0) pUnit:RegisterEvent("Flash", 25000, 0) pUnit:RegisterEvent("Volley", 27000, 0) pUnit:RegisterEvent("Drain", 15000, 0) pUnit:RegisterEvent("Beam", 30000, 0) pUnit:RegisterEvent("Negative", 32000, 0) end function Volley(pUnit, Event) pUnit:FullCastSpellOnTarget(45031, pUnit:GetRandomPlayer(0)) end function Flash(pUnit, Event) local stomprel="nofollow" target=pUnit:GetMainTank(); pUnit:FullCastSpellOnTarget(46442, stomptarget) end function Nova(pUnit, Event) pUnit:CastSpellOnTarget(30852, pUnit:GetRandomPlayer(0)) end function Drain(pUnit, Event) pUnit:CastSpellOnTarget(46466, pUnit:GetRandomPlayer(0)) end function Beam(pUnit, Event) pUnit:CastSpellOnTarget(40759, pUnit:GetRandomPlayer(0)) end function Negative(pUnit, Event) pUnit:CastSpellOnTarget(46285, pUnit:GetRandomPlayer(0)) end function Zaxis_OnLeaveCombat(pUnit, Event) pUnit:RemoveEvents() end function Zaxis_OnKilledTarget (pUnit, Event) end function Zaxis_OnDied(pUnit, Event) RegisterUnitEvent(UnitID, 1, "Zaxis_OnCombat") RegisterUnitEvent(UnitID, 2, "Zaxis_OnLeaveCombat") RegisterUnitEvent(UnitID, 3, "Zaxis_OnKilledTarget") RegisterUnitEvent(UnitID, 4, "Zaxis_OnDied")
Now, i will put my full shadow based boss script in here. My final product has a few more bells and whistles on it that i might create a guide on later on. My final script is in a different order, but it doesnt matter:
Code:--[[ Zaxis.lua Author: Insomnicide]]-- --Zaxis Script AI-- function Zaxis_OnCombat(pUnit, Event) pUnit:SendChatMessage(14, 0, "Your Lives have recently expired.") pUnit:RegisterEvent("Combat_Talk", 30000, 0) pUnit:RegisterEvent("Nova", 45000, 0) pUnit:RegisterEvent("Flash", 25000, 0) pUnit:RegisterEvent("Volley", 27000, 0) pUnit:RegisterEvent("Drain", 15000, 0) pUnit:RegisterEvent("Beam", 30000, 0) pUnit:RegisterEvent("Negative", 32000, 0) end function Zaxis_OnLeaveCombat(pUnit, Event) pUnit:RemoveEvents() end function Zaxis_OnKilledTarget (pUnit, Event) local Choice=math.random(1, 3) if Choice==1 then pUnit:SendChatMessage(14, 0, "Perish, insect!") pUnit:PlaySoundToSet(12464) elseif Choice==2 then pUnit:SendChatMessage(14, 0, "You are finished!") elseif Choice==3 then pUnit:SendChatMessage(14, 0, "Too easy!") pUnit:PlaySoundToSet(12466) end end function Zaxis_OnDied(pUnit, Event) pUnit:SendChatMessage(14, 0, "Gah! This is not possible!") pUnit:PlaySoundToSet(11706) pUnit:RemoveEvents() end function Volley(pUnit, Event) pUnit:FullCastSpellOnTarget(45031, pUnit:GetRandomPlayer(0)) end function Flash(pUnit, Event) local stomprel="nofollow" target=pUnit:GetMainTank(); pUnit:FullCastSpellOnTarget(46442, stomptarget) end function Nova(pUnit, Event) pUnit:CastSpellOnTarget(30852, pUnit:GetRandomPlayer(0)) end function Drain(pUnit, Event) pUnit:CastSpellOnTarget(46466, pUnit:GetRandomPlayer(0)) end function Beam(pUnit, Event) pUnit:CastSpellOnTarget(40759, pUnit:GetRandomPlayer(0)) end function Negative(pUnit, Event) pUnit:CastSpellOnTarget(46285, pUnit:GetRandomPlayer(0)) end function Combat_Talk(pUnit, Event) local Choice=math.random(1, 3) if Choice==1 then pUnit:SendChatMessage(14, 0, "You cannot surive my wrath!") elseif Choice==2 then pUnit:SendChatMessage(14, 0, "You shall burn in eternity!") elseif Choice==3 then pUnit:SendChatMessage(14, 0, "I live for this!") end end RegisterUnitEvent(UnitID, 1, "Zaxis_OnCombat") RegisterUnitEvent(UnitID, 2, "Zaxis_OnLeaveCombat") RegisterUnitEvent(UnitID, 3, "Zaxis_OnKilledTarget") RegisterUnitEvent(UnitID, 4, "Zaxis_OnDied")
› See More: How to script a boss in LUALast edited by insomnicide; 03-09-08 at 11:00 AM.
-
06-09-08, 03:28 PM #2
Simple, Basic and Good Guide.
+Rep
-
06-09-08, 03:56 PM #3
-
06-09-08, 08:48 PM #4
Register to remove this adthank you very much =P