Code: Select all
--NPCManager is required for setting basic NPC properties
local npcManager = require("npcManager")
--Create the library table
local paraGoombrat = {}
--NPC_ID is dynamic based on the name of the library file
local npcID = NPC_ID
--Defines NPC config for our NPC. You can remove superfluous definitions.
local paraGoombratSettings = {
id = npcID,
gfxheight = 48,
gfxwidth = 40,
gfxoffsetx = 0,
gfxoffsety = 0,
width = 32,
height = 32,
frames = 4,
framestyle = 0,
framespeed = 4,
isflying = true,
}
--Applies NPC settings
npcManager.setNpcSettings(paraGoombratSettings)
--Register the vulnerable harm types for this NPC. The first table defines the harm types the NPC should be affected by, while the second maps an effect to each, if desired.
npcManager.registerHarmTypes(npcID,
{
HARM_TYPE_JUMP,
HARM_TYPE_FROMBELOW,
HARM_TYPE_NPC,
HARM_TYPE_PROJECTILE_USED,
HARM_TYPE_LAVA,
HARM_TYPE_HELD,
HARM_TYPE_TAIL,
HARM_TYPE_SPINJUMP,
HARM_TYPE_OFFSCREEN,
HARM_TYPE_SWORD
},
{
[HARM_TYPE_JUMP]=753,
[HARM_TYPE_FROMBELOW]=754,
[HARM_TYPE_NPC]=754,
[HARM_TYPE_PROJECTILE_USED]=754,
[HARM_TYPE_LAVA]={id=13, xoffset=0.5, xoffsetBack = 0, yoffset=1, yoffsetBack = 1.5},
[HARM_TYPE_HELD]=754,
[HARM_TYPE_TAIL]=754,
[HARM_TYPE_SPINJUMP]=10,
[HARM_TYPE_OFFSCREEN]=10,
[HARM_TYPE_SWORD]=10,
}
);
function paraGoombrat.onPostNPCHarm(event, v, rsn, culprit)
if v.id == NPC_ID and rsn == 1 then
event.cancelled = true
v:transform(npcID - 1)
end
end
function paraGoombrat.onInitAPI()
npcManager.registerEvent(npcID, paraGoombrat, "onTickNPC")
npcManager.registerEvent(paraGoombrat, "onPostNPCHarm")
end
return paraGoombrat