multi hit npcs
Posted: Fri Jul 17, 2020 6:45 am
how do i make npcs have more than 1 hp
Code: Select all
local multiHitNPCs = {
[1] = 2,
[2] = 3,
}
function onNPCHarm(eventObj,npc,reason,culprit)
if not multiHitNPCs[npc.id] or (reason == HARM_TYPE_LAVA or reason == HARM_TYPE_OFFSCREEN) then return end
local data = npc.data
if npc:mem(0x156,FIELD_WORD) > 0 then
eventObj.cancelled = true
return
end
data.health = (data.health or multiHitNPCs[npc.id]) - 1
if data.health > 0 then
npc:mem(0x156,FIELD_WORD,20) -- Invincibility time
eventObj.cancelled = true
end
end
Code: Select all
local multiHitNPCs = {
[2] = 3,
[4] = 2,
}
thanksMrDoubleA wrote: ↑Sun Aug 09, 2020 3:52 pmIt's not all too hard to do! Put this into your luna.lua file:
... and replace that list in "multiHitNPCs". For example, if you wanted red goombas (ID 2) to take 3 hits and green koopas (ID 4) to take 2 hits, you'd do:Code: Select all
local multiHitNPCs = { [1] = 2, [2] = 3, } function onNPCHarm(eventObj,npc,reason,culprit) if not multiHitNPCs[npc.id] or npc:mem(0x156,FIELD_WORD) > 0 or (reason == HARM_TYPE_LAVA or reason == HARM_TYPE_OFFSCREEN) then return end local config = NPC.config[v.id] local data = v.data data.health = (data.health or config.health) - 1 if data.health > 0 then npc:mem(0x156,FIELD_WORD,20) -- Invincibility time eventObj.cancelled = true end end
Code: Select all
local multiHitNPCs = { [2] = 3, [4] = 2, }