• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Scripting Bosses

Status
Not open for further replies.

DndTheTroll

Respected Member
Hello.

I'm wondering if someone can make a tutorial or even tell us how to script bosses from A to Z will be great and much appreciated.

You'll not just help me, You'll help a lot of people that need it.

Thanks in advance
 

Tommy

Founder
First, you will need to look at the RegisterCreatureEvent hooks: http://wiki.emudevs.com/doku.php?id=eluna_hooks_registercreatureevent

Afterwards, you can begin your scripting progress with looking at the Unit Methods to use on several creature hooks.

To start by saying, you could use my program Faded and I developed from Nomsoftware. The program is called Lua Express. You can add your own methods, server hooks and other auto complete wording you want. It can be found here: http://emudevs.com/showthread.php/7-Win-Lua-Express-v2-0-1-2

It might have a few bugs, but it is great for quick coding. Now, I'll code you a nice template to use as a beginner. Just a pointer, using the CREATURE_EVENT_AIUPDATE would be nice to use because the creature gets updated every 100ms (I think); however, we have RegisterEvent for that. RegisterEvent is more clean to use, I'll use it in this example.

I might be a little rusty on Lua so bare with me!

Code:
local BOSS_ID = 90000

function MyBoss_EnterCombat(event, creature, target) -- CREATURE EVENT ON ENTER COMBAT
creature:RegisterEvent(MyBoss_CastSpell, 5000, 0); -- Infinite calls
end

function MyBoss_LeaveCombat(event, creature) -- CREATURE EVENT ON LEAVE COMBAT
end

function MyBoss_TargetDied(event, creature, victim) -- CREATURE EVENT TARGET DIED
end

function MyBoss_Died(event, creature, killer) -- CREATURE EVENT ON DIED
end

function MyBoss_CastSpell(event, delay, calls, creature)
creature:CastSpellOnTarget(30021, creature:GetVictim())
end

RegisterCreatureEvent(BOSS_ID, 1, MyBoss_EnterCombat)
RegisterCreatureEvent(BOSS_ID, 2, MyBoss_LeaveCombat)
RegisterCreatureEvent(BOSS_ID, 3, MyBoss_TargetDied)
RegisterCreatureEvent(BOSS_ID, 4, MyBoss_Died)

Test that and see how it goes!
 

DndTheTroll

Respected Member
I'll test that.. really thank you! and much appreciated <3

also i want to know how to make it cast spell every period of time

and to make him do something like when he reach 75% of hp and so on
 

Tommy

Founder
Look at the Unit Methods. :p

GetHealthPct() - Returns current health percent

Example:

Code:
if (creature:GetHealthPct() > 75)
-- Do something
end
 

DndTheTroll

Respected Member
Look at the Unit Methods. :p

GetHealthPct() - Returns current health percent

Example:

Code:
if (creature:GetHealthPct() > 75)
-- Do something
end

I already did that but when i make the boss say something when he reach 70% hp he keep saying the same thing
 

Tommy

Founder
I already did that but when i make the boss say something when he reach 70% hp he keep saying the same thing

Well, that will obviously spam because it is checking if it is above 75% health, so it will spam until he gets below that amount. There's plenty of ways to do this, you could do "==", "<=", etc.
 

DndTheTroll

Respected Member
Probably because he loses health too fast. You either might want to use creature:RegisterEvent and have 1 call so it calls it one time after getting to the specific health percent.

oh yea 1 sec let me try it :)

but how to make registerevent to be applied 1 time?
 

Tommy

Founder
oh yea 1 sec let me try it :)

but how to make registerevent to be applied 1 time?

Being skeptical about it spamming? XD

You can make a local variable called phases and each time it reaches that percent increment the phase by one. For example:

Code:
local phase = 0

if (creature:GetHealthPct() <= 85 and phase == 0)
phase = 1
-- do whatever
end
 

Tommy

Founder
Still doesn't work :\

I tried ON_AIUPDATE it worked for 1 time only and didn't work again :\

One time only is good, right? You said it spammed. XD

I'm going to go to bed, maybe when I get up if it hasn't been solved yet I can help in the morning.
 

Tommy

Founder
Well for one, you aren't suppose to put functions inside of a function.

Here, I updated it:

Code:
print("[Eluna] ..Loading Illidan")

local boss_id = 22917
local event_done = false
local phase = 0

function Gruul_OnEntering_Combat(event, creature, target)
    creature:SendUnitSay("Welcome to the Hell", 0)
    target = creature:GetTarget()
    
    if (creature:GetHealthPct() <= 70 and not event_done) then
        creature:SendUnitYell("Well, I'll use all my powers now!", 0)
        event_done = true
    end
    creature:RegisterEvent(GustofWind, 20000, 0) -- 20 seconds
    creature:RegisterEvent(MortalStrike, 3000, 0) -- 20 seconds
    creature:RegisterEvent(BladeStorm, 10000, 0) -- 20 seconds
    --creature:RegisterEvent(IllidanSay, 500000, 0) -- 500 seconds
end

function GustofWind(eventID, delay, pCall)
    target = creature:GetTarget()
    creature:CastSpell(target, 6982, true)
end

function MortalStrike(eventID, delay, pCall)
    target = creature:GetTarget()
    creature:CastSpell(target, 47486, true)
end

function BladeStorm(eventID, delay, pCall)
    target = creature:GetTarget()
    creature:CastSpell(target, 46924, true)
end

--local function Illi_update(event, creature, diff)
--if (creature:GetHealthPct() <= 70 and not event_done) then
--creature:SendUnitYell("Well, I'll use all my powers now!", 0)
--event_done = true
--end
--end

function CREATURE_EVENT_ON_TARGET_DIED(event, creature, victim)
    creature:SendUnitSay("As I said don't play with me!", 0)
end

function CREATURE_EVENT_ON_DIED(event, creature, killer)
    creature:SendUnitSay("I'll back again!", 0)
end

RegisterCreatureEvent(boss_id, 1, Gruul_OnEntering_Combat)
RegisterCreatureEvent(boss_id, 3, CREATURE_EVENT_ON_TARGET_DIED)
RegisterCreatureEvent(boss_id, 4, CREATURE_EVENT_ON_DIED)
--RegisterCreatureEvent(boss_id, 7, Illi_update)


Now time for bed. :D
 

Tommy

Founder
Updated the script. I forgot 'creature' as an argument in your spell functions for your 'RegisterEvent' method.

Code:
print("[Eluna] ..Loading Illidan")

local boss_id = 22917
local event_done = false
local phase = 0

function Gruul_OnEntering_Combat(event, creature, target)
    creature:SendUnitSay("Welcome to the Hell", 0)
    target = creature:GetTarget()
    
    if (creature:GetHealthPct() <= 70 and not event_done) then
        creature:SendUnitYell("Well, I'll use all my powers now!", 0)
        event_done = true
    end
    creature:RegisterEvent(GustofWind, 20000, 0) -- 20 seconds
    creature:RegisterEvent(MortalStrike, 3000, 0) -- 20 seconds
    creature:RegisterEvent(BladeStorm, 10000, 0) -- 20 seconds
    --creature:RegisterEvent(IllidanSay, 500000, 0) -- 500 seconds
end

function GustofWind(eventID, delay, pCall, creature)
    target = creature:GetTarget()
    creature:CastSpell(target, 6982, true)
end

function MortalStrike(eventID, delay, pCall, creature)
    target = creature:GetTarget()
    creature:CastSpell(target, 47486, true)
end

function BladeStorm(eventID, delay, pCall, creature)
    target = creature:GetTarget()
    creature:CastSpell(target, 46924, true)
end

--local function Illi_update(event, creature, diff)
--if (creature:GetHealthPct() <= 70 and not event_done) then
--creature:SendUnitYell("Well, I'll use all my powers now!", 0)
--event_done = true
--end
--end

function CREATURE_EVENT_ON_TARGET_DIED(event, creature, victim)
    creature:SendUnitSay("As I said don't play with me!", 0)
end

function CREATURE_EVENT_ON_DIED(event, creature, killer)
    creature:SendUnitSay("I'll back again!", 0)
end

RegisterCreatureEvent(boss_id, 1, Gruul_OnEntering_Combat)
RegisterCreatureEvent(boss_id, 3, CREATURE_EVENT_ON_TARGET_DIED)
RegisterCreatureEvent(boss_id, 4, CREATURE_EVENT_ON_DIED)
--RegisterCreatureEvent(boss_id, 7, Illi_update)
 
Status
Not open for further replies.
Top