Creating a custom Koopa Shell NPC with a spiky top

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Lithobraker
Fighter Fly
Fighter Fly
Posts: 31
Joined: Sat Mar 09, 2019 1:41 am

Creating a custom Koopa Shell NPC with a spiky top

Postby Lithobraker » Fri Jun 26, 2020 10:48 am

I'm currently trying to make a custom shell NPC which behaves like koopa shells in every way- except that when you land on it from above, it causes damage.
It seems the spiny behavior is working, but oddly enough I can't get it to work like a shell, even with isShell=true .
I did get the custom Koopa to spawn this shell in the way I want, but for some reason it seems that shell AI is harder than simply setting isShell to true.
I've referenced the official documentation, but literally the only information about "isShell" is that it determines "if this NPC is a shell". Apparently, that doesn't mean what I think it means, even though "isWalker" worked exactly as I expected it to.

Being inside its hitbox just causes this particle effect to constantly appear. It can be picked up, but not thrown. It also constantly animates as if moving.
Image

This is the NPC's .lua file in its entirety:
Spoiler: show

Code: Select all

--NPCManager is required for setting basic NPC properties
local npcManager = require("npcManager")

--Create the library table
local koopatrolshellNPC = {}
--NPC_ID is dynamic based on the name of the library file
local npcID = NPC_ID
local deathEffectID = (npcID+1)

--Defines NPC config for our NPC. You can remove superfluous definitions.
local koopatrolshellNPCSettings = {
	id = npcID,
	--Sprite size
	gfxheight = 44,
	gfxwidth = 36,
	--Hitbox size. Bottom-center-bound to sprite size.
	width = 32,
	height = 32,
	--Sprite offset from hitbox for adjusting hitbox anchor on sprite.
	gfxoffsetx = 0,
	gfxoffsety = 0,
	--Frameloop-related
	frames = 4,
	framestyle = 0,
	framespeed = 8, --# frames between frame change
	--Movement speed. Only affects speedX by default.
	speed = 1,
	--Collision-related
	npcblock = true,
	npcblocktop = false, --Misnomer, affects whether thrown NPCs bounce off the NPC.
	playerblock = false,
	playerblocktop = false, --Also handles other NPCs walking atop this NPC.

	nohurt=false,
	nogravity = false,
	noblockcollision = false,
	nofireball = true,
	noiceball = true,
	noyoshi= false,
	nowaterphysics = false,
	--Various interactions
	jumphurt = true, --If true, spiny-like
	spinjumpsafe = true, --If true, prevents player hurt when spinjumping
	harmlessgrab = false, --Held NPC hurts other NPCs if false
	harmlessthrown = false, --Thrown NPC hurts other NPCs if false

	grabside=true,
	grabtop=false,

	--Identity-related flags. Apply various vanilla AI based on the flag:
	--isbot = false,
	--isvegetable = false,
	--isshoe = false,
	--isyoshi = false,
	--isinteractable = false,
	--iscoin = false,
	--isvine = false,
	--iscollectablegoal = false,
	--isflying = false,
	--iswaternpc = false,
	isshell = true,

	--Emits light if the Darkness feature is active:
	--lightradius = 100,
	--lightbrightness = 1,
	--lightoffsetx = 0,
	--lightoffsety = 0,
	--lightcolor = Color.white,

	--Define custom properties below
 	deathEffectID = deathEffectID, -- The ID of the effect spawned when the enemy is killed, or can be nil for none.
}

--Applies NPC settings
npcManager.setNpcSettings(koopatrolshellNPCSettings)

--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]=10,
		[HARM_TYPE_FROMBELOW]= deathEffectID,
		[HARM_TYPE_NPC]= deathEffectID,
		--[HARM_TYPE_PROJECTILE_USED]= 10,
		[HARM_TYPE_LAVA]={id=13, xoffset=0.5, xoffsetBack = 0, yoffset=1, yoffsetBack = 1.5},
		[HARM_TYPE_HELD]= deathEffectID,
		--[HARM_TYPE_TAIL]=10,
		--[HARM_TYPE_SPINJUMP]=10,
		--[HARM_TYPE_OFFSCREEN]=10,
		[HARM_TYPE_SWORD]= deathEffectID,
		[HARM_TYPE_EXT_HAMMER] = deathEffectID,
	}
);

return koopatrolshellNPC
Added in 47 minutes 35 seconds:
Update- Setting any vanilla shell's jumphurt to true in an npc.txt file causes almost all of the same effects, except for the shell animating while idle.
I thought, then, that it was my shell's jumphurt causing the problems, but no. Whether or not jumphurt is true or false- and also independent of spinjumpsafe, and grabside, the NPC behaves exactly the same, minus causing damage when stomped on.

MrDoubleA
Edward
Edward
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: Creating a custom Koopa Shell NPC with a spiky top

Postby MrDoubleA » Sat Jun 27, 2020 3:05 pm

isshell does not cause any kicking behaviour, and you'd need lua for that. Additionally, a shell's frames property must be set to 0 to work properly.

Lithobraker
Fighter Fly
Fighter Fly
Posts: 31
Joined: Sat Mar 09, 2019 1:41 am

Re: Creating a custom Koopa Shell NPC with a spiky top

Postby Lithobraker » Sat Jun 27, 2020 3:12 pm

MrDoubleA wrote:
Sat Jun 27, 2020 3:05 pm
isshell does not cause any kicking behaviour, and you'd need lua for that. Additionally, a shell's frames property must be set to 0 to work properly.
Makes sense. I'll make do with modifying a vanilla shell, then.
It's probably better not to have a shell which can harm the player, anyway!


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 6 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari