Originally Posted by
Dimonoff
Who can help? Why this code does not work?
-snip-
Bot does not want to skip this step , when the player has Stagger but no buff Shuffle. It just stops
That's because ShuffleTime will return nil when Shuffle isn't up. You can either check that Shuffle is up before calculating ShuffleTime which would look like this:
PHP Code:
local SPELL = 119582
local Shuffle,_,_,_,_,_,ShuffleTime = UnitBuffID("player", 115307)
local HStagger = UnitDebuffID("player", 124273)
local MStagger = UnitDebuffID("player", 124274)
local LStagger = UnitDebuffID("player", 124275)
if PQR_SpellAvailable(SPELL) and PlayerCombat then
if HStagger then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
if MStagger and Shuffle and ShuffleTime - GetTime() >= 2 then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
if LStagger and Shuffle and ShuffleTime - GetTime() >= 8 then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
end
Or you can return 0 for ShuffleTime when Shuffle isn't up which would look like this:
PHP Code:
local SPELL = 119582
local Shuffle,_,_,_,_,_,ShuffleTime = UnitBuffID("player", 115307)
local HStagger = UnitDebuffID("player", 124273)
local MStagger = UnitDebuffID("player", 124274)
local LStagger = UnitDebuffID("player", 124275)
if Shuffle then
ShuffleTime = ShuffleTime - GetTime()
else
ShuffleTime = 0
end
if PQR_SpellAvailable(SPELL) and PlayerCombat then
if HStagger then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
if MStagger and ShuffleTime >= 2 then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
if LStagger and ShuffleTime >= 8 then
CastSpellByName(GetSpellInfo(SPELL),nil)
return true
end
end