Consider the following code:
Code below is supposed to spawn MT_TNTDUST in 16 directions in a 360 degree circle when the player hits the floor.
However if we land on top of a monitor, this code triggers endlessly.
Flame Edit 3/8/2020:
From my understanding, the intended behavior of MFE_JUSTHITFLOOR flag should only trigger true for one tic and then false for the next tic upon landing. This is the case when touching the actual sector floor (Ie, when the Player's Z value is less than or equal to that of the Player's Floor Z value), but not when standing on top of an object. I identified this through additional testing and playing around in devmode.
Code below is supposed to spawn MT_TNTDUST in 16 directions in a 360 degree circle when the player hits the floor.
Code:
addHook("PlayerThink", function(p)
if p and p.valid and not p.spectator
and p.mo and p.mo.valid
local zpos = P_FloorzAtPos(p.mo.x,
p.mo.y,
p.mo.z,
p.mo.height)
if (p.mo.eflags & MFE_JUSTHITFLOOR) and P_IsObjectOnGround(p.mo)
for i = 1, 16 do
local fa = i*ANGLE_22h
local mobj = P_SpawnMobj(p.mo.x + FixedMul(cos(fa), (p.mo.radius)),
p.mo.y + FixedMul(sin(fa), (p.mo.radius)),
zpos + FRACUNIT,
MT_TNTDUST)
mobj.angle = fa
mobj.flags = ($|MF_NOGRAVITY)
P_InstaThrust(mobj, mobj.angle, FRACUNIT)
end
end
end
end)
However if we land on top of a monitor, this code triggers endlessly.
Flame Edit 3/8/2020:
From my understanding, the intended behavior of MFE_JUSTHITFLOOR flag should only trigger true for one tic and then false for the next tic upon landing. This is the case when touching the actual sector floor (Ie, when the Player's Z value is less than or equal to that of the Player's Floor Z value), but not when standing on top of an object. I identified this through additional testing and playing around in devmode.
Attachments
Last edited: