Toggle vulnerability during spindash?

Status
Not open for further replies.

Lach

he/him
Kart Krew™️
Judge
I'm writing some lua code where the player can charge the spindash à la Sonic 2/S3K, where the first stage of the spindash acts as a pseudo-crouch, i.e. the player's dashspeed is 0. The whole code actually works really well for the most part, but of course the player is still technically spindashing when the crouch is active (again, when the dashspeed is 0). Is there any way to keep the player vulnerable to enemy touches (like crawlas) while the spindash is active?
 
something along these lines works i guess.
Code:
-- function to make sure enemies don't die from spindash and get the player damaged instead

local function spdamage(mo, inflictor)
	
	if mo and mo.valid and inflictor and inflictor.valid and inflictor.player
		if inflictor.player.pflags & PF_STARTDASH
			P_DamageMobj(inflictor, mo, mo)
			return false
		end
	end	
end

-- apply the above to all of the enemies.

do
	for i =1,#mobjinfo-1
		if mobjinfo[i].flags & MF_ENEMY|MF_BOSS
			addHook("ShouldDamage", spdamage, i)
		end
	end
end
 
That's... a surprisingly concise solution. I'll integrate it into my code and see if it works. Thank you!
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top