Skip to content

Lua: ShouldDamage/MobjDamage/MobjDeath hotfix

Monster Iestyn requested to merge lua-damage-hooks-hotfix into next

This fixes the target is 'nil' sort of errors people have been reporting lately with these hooks, particularly if they had multiple instances of these hooks or loaded a particular combo of addons at once. Turns out specifically it broke if you had both a generic kind and type-specific kind of one of these hooks!

Long story short, it was some support for "damagetype" being accidentally left out that lead to this. If you had a generic type of one of the three hooks, it mucked up the type-specific hooks such that the function args you receive are then all offset to the next arg slot!

MobjDamage: target = userdata: 13BAB0E8, inflictor = userdata: 13BAA548, source = userdata: 13BAA548, damage = 1, damagetype = nil
MobjDamage: target = nil, inflictor = userdata: 13BAB0E8, source = userdata: 13BAA548, damage = userdata: 13BAA548, damagetype = 1

(The script I used to test this was luatest-mobjdamagebug.lua)

Merge request reports