Page 1 of 1

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

Posted: Sun Aug 30, 2020 6:01 am
by Megaiwer
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.

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

Posted: Sun Aug 30, 2020 6:26 am
by Emral
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

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

Posted: Sun Aug 30, 2020 7:14 pm
by Megaiwer
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!