Modifying an NPC to not be destroyed after being thrown at another NPC

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

Moderator: Userbase Moderators

Megaiwer
Koopa
Koopa
Posts: 15
Joined: Sun Jun 07, 2015 6:46 am

Modifying an NPC to not be destroyed after being thrown at another NPC

Postby Megaiwer » Sun Aug 30, 2020 6:01 am

Hello! I wanted to make a bob-omb survive the impact after hitting another NPC. I tried to change its properties but it did not work. I'm sorry to bother you, but I want to ask for your help.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Modifying an NPC to not be destroyed after being thrown at another NPC

Postby Emral » Sun Aug 30, 2020 6:26 am

you can create a function onNPCHarm in your luna.lua script:

Note: I'm not sure on BOMB_ID, and I don't know if it needs to check HARM_TYPE_NPC, HARM_TYPE_PROJECTILE_USED or HARM_TYPE_HELD. Substitute those to find the right combination and it ought to work.

Code: Select all

local BOMB_ID = *insert the ID of the Bomb NPC here. IDK which of the 5 bobomb npcs you are referring to

function onNPCHarm(eventToken, harmedNPC, killReason, culpritOrNil)
	if harmedNPC.id == BOMB_ID and killReason == HARM_TYPE_PROJECTILE_USED then
		eventToken.cancelled = true -- prevent the NPC from taking damage.
	end
end

Megaiwer
Koopa
Koopa
Posts: 15
Joined: Sun Jun 07, 2015 6:46 am

Re: Modifying an NPC to not be destroyed after being thrown at another NPC

Postby Megaiwer » Sun Aug 30, 2020 7:14 pm

Enjl wrote:
Sun Aug 30, 2020 6:26 am
you can create a function onNPCHarm in your luna.lua script:

Note: I'm not sure on BOMB_ID, and I don't know if it needs to check HARM_TYPE_NPC, HARM_TYPE_PROJECTILE_USED or HARM_TYPE_HELD. Substitute those to find the right combination and it ought to work.

Code: Select all

local BOMB_ID = *insert the ID of the Bomb NPC here. IDK which of the 5 bobomb npcs you are referring to

function onNPCHarm(eventToken, harmedNPC, killReason, culpritOrNil)
	if harmedNPC.id == BOMB_ID and killReason == HARM_TYPE_PROJECTILE_USED then
		eventToken.cancelled = true -- prevent the NPC from taking damage.
	end
end
Thank you very much, this is exactly what I needed!


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari