- Joined
- Jun 26, 2020
- Messages
- 1,928
Hello, I'm using the lua damage engine 2.0, and recently I got an error that I'm not sure when exactly happens, but at least happens when I start casting an ability based in channel that has a unit target, the error is in here:
The value
I don't know if the reason is because I touched something that I shouldn't, but the system is too complex to me to figure it out.
Lua:
local breakCheck = {} ---@type function[]
local override ---@type boolean
breakCheck[_DAMAGING] = function() return override or current.userType == _TYPE_PURE end
breakCheck[_ARMOR] = function() return current.damage <= 0.00 end
breakCheck[_LETHAL] = function() return hasLethal and Damage.life > _DEATH_VAL end
---@return boolean
local function damageOrAfter() return current.damageType == DAMAGE_TYPE_UNKNOWN end
breakCheck[_DAMAGED] = damageOrAfter
breakCheck[_AFTER] = damageOrAfter
local function defaultCheck() end
---Common function to run any major event in the system.
---@param head damageEventRegistry
---@return boolean ran_yn
local function runEvent(head)
local check = breakCheck[head] or defaultCheck
if dreaming or check() then
return
end
userIndex = head.next
if userIndex ~= head then
Damage.enable(false)
enableT(t3)
dreaming = true
--print("Start of event running")
repeat
if not userIndex.trigFrozen and userIndex.filters[userIndex.eFilter] and checkConfig() and not hasSource or (head ~= _SOURCE or (userIndex.minAOE and sourceAOE > userIndex.minAOE)) then
userIndex.func()
end
userIndex = userIndex.next
until userIndex == head or check()
--print("End of event running")
dreaming = nil
Damage.enable(true)
disableT(t3)
end
return true
end
current
is nil and is used, using my Lua GetStackTrace I found the error comes from this event (look where I commented the word "HERE"):
Lua:
t1 = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_DAMAGING)
TriggerAddCondition(t1, Filter(function()
local d = createFromEvent()
--print("Pre-damage event running for " .. GetUnitName(GetTriggerUnit()))
if alarmSet then
if totem then --WarCraft 3 didn't run the DAMAGED event despite running the DAMAGING event.
if d.damageType == DAMAGE_TYPE_SPIRIT_LINK or d.damageType == DAMAGE_TYPE_DEFENSIVE or d.damageType == DAMAGE_TYPE_PLANT then
lastInstance = current
totem = nil
canKick = nil
else
failsafeClear() --HERE | Not an overlapping event - just wrap it up
end
else
finish() --wrap up any previous damage index
end
if _USE_EXTRA then
if d.source ~= originalSource then
onAOEEnd()
originalSource = d.source
originalTarget = d.target
elseif d.target == originalTarget then
sourceStacks = sourceStacks + 1
elseif not IsUnitInGroup(d.target, Damage.targets) then
sourceAOE = sourceAOE + 1
end
end
else
alarmSet = true
Timed.call(
function()
alarmSet, dreaming = nil, nil
Damage.enable(true)
if totem then
failsafeClear() -- AND HERE | WarCraft 3 didn't run the DAMAGED event despite running the DAMAGING event.
else
canKick = true
kicking = nil
finish()
end
onAOEEnd()
current = nil
--print("Timer wrapped up")
end)
if _USE_EXTRA then
originalSource = d.source
originalTarget = d.target
end
end
if _USE_EXTRA then GroupAddUnit(Damage.targets, d.target) end
if doPreEvents(d, true) then
runEvent(_ZERO)
canKick = true
finish()
end
totem = not lastInstance or attacksImmune[d.attackType] or damagesImmune[d.damageType] or not CheckUnitType(d.target, UNIT_TYPE_MAGIC_IMMUNE)
end))
Last edited: