PDA

View Full Version : question about lua script



oren22a
01-02-09, 07:26 PM
hi this is my first thread i have a simple question for u guys...

i saw this code for example:
(its not my code it just for example..)


function Leviathan_Morph1(pUnit,Event)
if pUnit:GetHealthPct() <= 75 then
print "Group through stage 1"
pUnit:RemoveEvents()
pUnit:SetModel(18945)
pUnit:SendChatMessage(12, 0, "You think you are a match for me? Pfft, what about if I do.... THIS?")
pUnit:SetScale(0.3)
pUnit:CastSpell(25431)
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFirecone", 18000, 0)
pUnit:RegisterEvent("Leviathan_SpellFireball", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFireRain", 8000, 0)
pUnit:RegisterEvent("Leviathan_SpellSteal", 20000, 0)
pUnit:RegisterEvent("Leviathan_Morph2", 1000, 0)
end
end
--Morph two, Ahune The Frost Lord display ID, IceFrostPhase enabled, 50 to 25 percent--
function Leviathan_Morph2(pUnit,Event)
if pUnit:GetHealthPct() <= 50 then
print "Group through stage 2"
pUnit:RemoveEvents()
pUnit:SetModel(23344)
pUnit:SendChatMessage(12, 0, "Hah, you think that you may triumph over me, but you are only halfway through this igneous shell of steel!")
pUnit:SetScale(0.3)
pUnit:CastSpell(7301)
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFrostbolt", 11000, 0)
pUnit:RegisterEvent("Leviathan_SpellBreath", 20000, 0)
pUnit:RegisterEvent("Leviathan_SpellClaw", 8000, 0)
pUnit:RegisterEvent("Leviathan_SpellCone", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellPlague", 17000, 0)
pUnit:RegisterEvent("Leviathan_Morph3", 1000, 0)


and i have a little question about the "pUnit:GetHealthPct() " command:
at the end of morph1 it "throws" to morph2 which first thing checks for bosses hp...

1. what will happen if boss hp is still over 50% while morph2 is triggered?
it will melee endless? or loop itself and cast again the same spells?

2. is triggering the function as: function Leviathan_Morph2(pUnit,Event)
will "inject" the function to the memory and once the boss hp will go under 50% it will auto trigger the rest of the function? or i need to re-trigger it again somehow in a period of time?
:0

im sorry i know its noobish q, but i just have to know lol :)
thank in advance to all helpers.. :)

oren22a
02-02-09, 02:33 PM
any1?

runiker
02-02-09, 09:20 PM
As a general rule for all scripts most languages will keep looping the same script untill a it is told to stop or change. this part of the code

pUnit:RemoveEvents() found at the first thing once it sees the units health has hit below 50% this will remove all actions before it and run only the 50% ones.So i think the short answer is this the script reads all lines of code in order so imputing it once would only work. So far this script should work if it had a baseline trigger. Hope this helps.

oren22a
02-02-09, 11:48 PM
thank you! :) it do helps

oren22a
03-02-09, 11:58 AM
so.... basiclly ur saying that:
morph1 will cast all the spells as it should be.
then it will check the unit's hp
if its not reached the 50% as it should....morph1 will run again?
and once the unit hp will go 50% it will proc morph2 function automaticlly?