[Open Assets] Basic Health System

This content may be freely modified and/or maintained by anyone.
Status
Not open for further replies.

clairebun

Community Noise Maker
Sonic Team Junior
This is a simple script which adds a basic health system to the game. I made this mostly to get away from Sonic's ring system, but it could also be a resource for anyone working on a mod or character that would benefit from it.

3o6Zt710EQJZCLkRVe.gif


* Characters by default have 3 max HP. Health goes down by 1 every time the player gets hit, but no rings are spilled. The player dies when HP reaches 0.
* Players can restore HP by hitting super ring monitors. HP is also restored at the beginning of each level.
* Multiability characters have 1 less HP, characters with GlideAndClimb have 1 more HP. (E.G. Knuckles has 4, Sonic and Tails 3)

Credits: Some code borrowed/modified from Tripel's Tails Guy wad.
 

Attachments

  • health.rar
    1.3 KB · Views: 1,312
Last edited:
Pretty neat but im not completely sold on losing all your rings on your final Health Point.
 
This is a pretty neat Lua script, it might be better to remove the rings from the HUD so it wont confuse people thinking they'll live with 1 ring though.
 
Pretty neat but im not completely sold on losing all your rings on your final Health Point.

?

This is a pretty neat Lua script, it might be better to remove the rings from the HUD so it wont confuse people thinking they'll live with 1 ring though.

Rings are intact because they're still used for gaining extra lives.
 
Pretty simple. There's a block of code in LUA_HP which defines a function called "calculate_hp_stat" -- this is responsible for giving characters their HP value. If you want to tweak it to work with one character, just replace lines 7-25 with this:

Code:
local function calculate_hp_stat(player)
	if not(player.mo)
		return(nil)
	elseif(player.pflags & PF_NIGHTSMODE)
		return(nil)
	elseif(player.mo.skin == "sonic")
		return(3)
	end
end

Replace "sonic" with your skin of choice, and replace "3" with the HP of your choosing -- only that character will receive the HP stat, and the others will play normally.

If you're curious: The code that you'd have just replaced there was mostly fluff to demonstrate how you can customize the HP values per character. That's of course only useful if you're making HP a broad mechanic. This replacement code keeps only some of the nil checks, which prevent the script from trying to give other objects health, or players health during NiGHTs special stages. The last elseif excludes any other character from using the function besides the one you've defined.

I'm only explaining that because that code chunk in the WAD is rather minimally commented. Sorry about that.
 
Last edited:
Status
Not open for further replies.

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

Back
Top