"Modern iteration" of giant piranha plants? SMBX2 uses Redigit's Big Piranha Plants which take6 hits from fireballs, 2 hits from other npcs and 3 hits from link's stab, so
this code which roughly translates to this in a npc-n.lua:
Code: Select all
local multihit = {}
function multihit.onNPCHarm(e, v, r, c)
if v.id == NPC_ID then
if r ~= 1 and r ~= 2 and r ~= 6 then
v.data.hits = v.data.hits or 0
if v.ai3 <= lunatime.tick() then -- invulnerability frames
if r == 3 then -- npc hit
if c and c.isValid and type(c) == "NPC" and c.id == 13 then
SFX.play(39)
v.data.hits = v.data.hits + 1
v.ai3 = lunatime.tick() + 10
if v.ai2 == 2 then v.ai1 = 50 end -- this is for retracting into the pipe. the current basegame plants might use a different variable for this
else
v.data.hits = v.data.hits + 3
SFX.play(39)
v.ai3 = lunatime.tick() + 30
if v.ai2 == 2 then v.ai1 = 50 end -- this is for retracting into the pipe. the current basegame plants might use a different variable for this
end
elseif r == 10 then -- link stab
v.data.hits = v.data.hits + 2
v.ai3 = lunatime.tick() + 10
if v.ai2 == 2 then v.ai1 = 50 end -- this is for retracting into the pipe. the current basegame plants might use a different variable for this
end
end
If v.data.hits < 6 then e.cancelled = true end
end
end
end
registerEvent(multihit, "onNPCHarm")
return multihit