Hello everyone !
For those who read my previous posts, it seems I can't get things to work as intended since I have tried to implement my "Torrefaction" custom spell.
Don't get me wrong, it is actually working, and when the Balls or Flying Balls are roasting, the countdown progress bar I added as a Destructable (Blizzard, why didn't you call that destructible ?) displays perfectly, but for some impossible reason, the timing seems to be off.
I use a 1 second stand animation in my countdown bar model, from 0 to 1000 in the MDL, and as for destructable animation speed, I use 1 divided by the duration, and it seemed to work properly in the quick GUI map I tested it with.
But for some reason, in my Lua map, the timer (started with the duration in question) expires before the countdown bar has finished its animation, and I don't understand why, because the timer is started right after I create the destructable and set the animation speed.
A couple of screens of the effect of the Torrefaction ability :
On a Ball :
And on a Flying Ball :
So when the timer expires, the Burning Ball is removed, the original Ball is shown again, updating its health if needed, but the change happens usually before the progress bar you see in these screenshots has finished animating. The bar animation makes it go from full to nothing in exactly 1 second.
I fail to understand why this happens, and it cannot be related to the moment the ability takes effect because the animation and the timer are started at the same time (unless a destructable does not play its initial animation right when created ???)
Here is the full trigger for Torrefaction, I have hidden the actions for the other spells for readability :
If anyone has an idea about what is wrong, I would be immensely grateful, as a perfectionist, I can't really leave the progress bar like that :'(
For those who read my previous posts, it seems I can't get things to work as intended since I have tried to implement my "Torrefaction" custom spell.
Don't get me wrong, it is actually working, and when the Balls or Flying Balls are roasting, the countdown progress bar I added as a Destructable (Blizzard, why didn't you call that destructible ?) displays perfectly, but for some impossible reason, the timing seems to be off.
I use a 1 second stand animation in my countdown bar model, from 0 to 1000 in the MDL, and as for destructable animation speed, I use 1 divided by the duration, and it seemed to work properly in the quick GUI map I tested it with.
But for some reason, in my Lua map, the timer (started with the duration in question) expires before the countdown bar has finished its animation, and I don't understand why, because the timer is started right after I create the destructable and set the animation speed.
A couple of screens of the effect of the Torrefaction ability :
On a Ball :
And on a Flying Ball :
So when the timer expires, the Burning Ball is removed, the original Ball is shown again, updating its health if needed, but the change happens usually before the progress bar you see in these screenshots has finished animating. The bar animation makes it go from full to nothing in exactly 1 second.
I fail to understand why this happens, and it cannot be related to the moment the ability takes effect because the animation and the timer are started at the same time (unless a destructable does not play its initial animation right when created ???)
Here is the full trigger for Torrefaction, I have hidden the actions for the other spells for readability :
Lua:
function RoastDeathActions()
local r=GetTriggerUnit()
local bn,t=Roast[r][4],Roast[r][5]
PlayCleanSFX(SFXCubes, GetUnitX(r), GetUnitY(r), math.random()*0.4+0.2, math.random()*Pi2, 0, 3.0)
StoreBall(Roast[r][3], bn, math.floor((bn-1)/BallsPerLevel)+1)
DestroyTrigger(Roast[r][1])
RemoveDestructable(Roast[r][6])
RemoveUnit(r)
PauseTimer(t) -- If the Roasting Ball is killed, we don't need to let the Torrefaction timer run anymore
DestroyTimer(t)
DestroyTrigger(GetTriggeringTrigger())
return false
end
function SpellEffects()
local spellEffects=CreateTrigger()
for i=1, 4 do
if Playing[i] then
TriggerRegisterPlayerUnitEvent(spellEffects, Player(i-1), EVENT_PLAYER_UNIT_SPELL_EFFECT, nil)
end
end
TriggerAddCondition(spellEffects, Condition(function ()
local sId=GetSpellAbilityId()
----------- actions for other custom abilities
elseif (sId==SpellID[15]) then -- Torrefaction
local t,b,type,select=CreateTimer(),GetSpellTargetUnit(),BallType[5],__jarray(false)
local bn,bx,by,bz,ba,life=GetUnitUserData(b),GetUnitX(b),GetUnitY(b),BlzGetUnitZ(b)+GetUnitFlyHeight(b),GetUnitFacing(b),GetWidgetLife(b)
PlayCleanSFX(SFXTor, bx, by, 1.0, 0.0, 0, 1.5)
if IsFlying then
type=BallType[6]
end
for i=1, 4 do -- saving the selection state of the Ball for all players
if IsUnitSelected(b, Player(i-1)) then
select[i]=true
end
end
ShowUnit(b, false)
PauseUnit(b, true)
SetUnitInvulnerable(b, true)
DisableBallTriggers(bn)
local r,dur=CreateUnit(BallsMaster, type, bx, by, ba),10+2*GetUnitAbilityLevel(GetTriggerUnit(), sId)
countdown=CreateDestructableZ(CountdownID,bx,by,bz+80.0, 270.00, 1.00, 0)
SetDestructableAnimationSpeed(countdown, 1/dur)
SetDestructableInvulnerable(countdown, true)
SetUnitUserData(r, bn)
BlzSetUnitMaxHP(r, CurrentMaxHP)
SetWidgetLife(r, life)
local size=life*ResizeFactor
if (size<MinSize) then
size=MinSize
end
SetUnitScale(r, size, size, size)
for i=1, 4 do -- Selecting the Roasting Ball if the normal Ball was selected
if select[i] and (i==LocalPn) then
SelectUnit(r, true)
end
end
Roast[r]={CreateTrigger(), CreateTrigger(), b, bn, t, countdown} -- Initializing Roasting Ball data
TriggerRegisterUnitEvent(Roast[r][1], r, EVENT_UNIT_DAMAGED)
TriggerRegisterUnitEvent(Roast[r][2], r, EVENT_UNIT_DEATH)
TriggerAddCondition(Roast[r][1], Condition(DamagedBallActions)) -- Roasting Balls can be damaged like normal Balls
TriggerAddCondition(Roast[r][2], Condition(RoastDeathActions)) -- Roasting Balls require specific actions when killed
TimerData[t]={b, r} -- Setting up the data for the timer expiring at the end of the duration of Torrefaction.
TimerStart(t, dur, false, function()
local t=GetExpiredTimer()
local b,r=TimerData[t][1],TimerData[t][2]
DestroyTimer(t)
local life=GetWidgetLife(r)
SetWidgetLife(b, life)
local size,select=life*ResizeFactor,__jarray(false)
if (size<MinSize) then
size=MinSize
end
SetUnitScale(b, size, size, size)
for i=1, 4 do -- saving the selection state of the Roasting ball for all players
if IsUnitSelected(r, Player(i-1)) then
select[i]=true
end
end
PlayCleanSFX(SFXTor, GetUnitX(b), GetUnitY(b), 1.0, 0.0, 0, 1.5)
DestroyTrigger(Roast[r][1])
DestroyTrigger(Roast[r][2])
RemoveDestructable(Roast[r][6])
RemoveUnit(r)
EnableBallTriggers(bn)
SetUnitInvulnerable(b, false)
PauseUnit(b, false)
ShowUnit(b, true)
for i=1, 4 do -- Selecting the Ball if the Roasting Ball was selected
if select[i] and (i==LocalPn) then
SelectUnit(b, true)
end
end
local d=Destination[GetUnitUserData(b)]
IssueDelayedPointOrder(b, "move", WPx[d], WPy[d], 0.0)
end)
end
return false
end))
end
If anyone has an idea about what is wrong, I would be immensely grateful, as a perfectionist, I can't really leave the progress bar like that :'(