deice wrote: ↑Sat Dec 02, 2023 7:46 am
since the "quake" setting doesn't work for npcs that don't use the "bro" ai script, here's some code that roughly recreates the effect for mouser:
Code: Select all
local stun = require("playerstun")
local EARTHQUAKE_STRENGTH = 15
local STUN_DURATION = 130
local function playerGroundCheck(p)
return ((p:isOnGround() and p.speedY == 0) or p:mem(0x48, FIELD_WORD) > 0 or p:mem(0x176, FIELD_WORD) > 0)
end
function onTick()
for _, v in NPC.iterate(262) do
if(v.isValid and v.despawnTimer > 0) then
v.data.__previousFallSpeed = v.data.__previousFallSpeed or 0
if(v.speedY == 0 and v.data.__previousFallSpeed ~= 0) then
Defines.earthquake = EARTHQUAKE_STRENGTH
SFX.play(37)
for p, pp in ipairs(Player.get()) do
if(pp.section == v.section and playerGroundCheck(pp)) then
stun.stunPlayer(p, STUN_DURATION)
end
end
end
v.data.__previousFallSpeed = v.speedY
end
end
end
It worked for the first two tries, but now I get this:
Do note that I placed and modified this for an npc-n.lua file.
Edit: Its not this. Something else has happened.
Edit2: One corrupted txt file deletion later, and it works like a charm now. Thanks!