Forum > Serverside Modding

[LUA] Unit:GetHealthPct Not Working

<< < (2/2)

schlumpf:
What is the behavior you expect? What is the behavior you get?

Diemen:
As i explained in my first post  i want the script to check the boss its hp %  
Under a certain amount i want to start the next phase.
In this case it is a Druid boss.
When she enters combat she has to buff herself with Motw and Thorns , then turn into a cat and start attacking till her hp is under 90%
Then she has to turn into a moonkin and continue fighting untill the next phase.

The problem is that the server does read the script but won't check the boss her hp.
She enters combat , buffs , turns into a cat , turn into a moonkin an then the script is done.
I added a say function to check wich phase she was , she yells  phase 1 gestart  and so on.
But she goes from start to the last phase in about 5 seconds.

I hope this is clear enough  :D

schlumpf:
Try something called "debugging":

--- Code: ---function enter_combat (Unit, Event)
  Unit:RegisterEvent ("health_check", 1000, 0)
end
function leave_combat (Unit, Event, player)
  Unit:RemoveEvents()
end

function health_check (Unit, Event)
  Unit:SendChatMessage (14, 0, "GetHealthPct: " .. Unit::GetHealthPct())
  if Unit:GetHealthPct() <= 50 then
    Unit:SendChatMessage (14, 0, "health below 50%")
  end
end

RegisterUnitEvent (90016, 1, "enter_combat")
RegisterUnitEvent (90016, 2, "leave_combat")
RegisterUnitEvent (90016, 4, "leave_combat")
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version