AlanLive2020 wrote: ↑Fri Dec 24, 2021 12:02 pm
1. Both people share the same health (if one person takes damage, both lose health)
2. If one person falls into a pit, that costs 2 health, unless they had invincibility frames, in that case, it costs only 1.
3. Players are forced to respawn (only if the other player is in the ground).
4. If health reaches 0, both players die.
1. seems too punishing, I can understand how it would feel when your sibling/friend is not good at smbx and gets hit too much times.
2. I hope there will be a feature to bounce the player very high to allow them to get again on safe ground.
3. nothing to say here.
4. like point "1", I would only kill the player whose HP is 0, not both of them
also there are multiple ways to make NPCs grant HP-
if it's a basegame NPC then you could do-
Code: Select all
local PowerUpsTable = table.map{9, 184, 185, 249, 250}
function health1P.onNPCKill(eventObj, killedNPC, killReason)
if (PowerUpsTable[killedNPC.id]) then
if health < 3 then -- prevent the counter to exceed max health
health = health + 1
end
end
end
you can change the table "PowerUpsTable" to include/exclude NPCs as per as your liking.
Of course you need to register the event
if it's a custom NPC then you need to make variable "health" global by renaming it to "health1P.health" and then
Code: Select all
--NPCManager is required for setting basic NPC properties
local npcManager = require("npcManager")
local health1P = require("health1P")
--Create the library table
local Heart = {}
--NPC_ID is dynamic based on the name of the library file
local npcID = NPC_ID
--Defines NPC config for our NPC. You can remove superfluous definitions.
local HeartSettings = {
id = npcID,
--Sprite size
gfxheight = 32,
gfxwidth = 32,
--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 = 1,
framestyle = 0,
framespeed = 8, --# frames between frame change
--Movement speed. Only affects speedX by default.
speed = 0,
--Collision-related
npcblock = false,
npcblocktop = false, --Misnomer, affects whether thrown NPCs bounce off the NPC.
playerblock = false,
playerblocktop = false, --Also handles other NPCs walking atop this NPC.
nohurt=true,
nogravity = false,
noblockcollision = false,
nofireball = true,
noiceball = true,
noyoshi= false,
nowaterphysics = false,
--Various interactions
jumphurt = false, --If true, spiny-like
spinjumpsafe = false, --If true, prevents player hurt when spinjumping
harmlessgrab = true, --Held NPC hurts other NPCs if false
harmlessthrown = false, --Thrown NPC hurts other NPCs if false
grabside=false,
grabtop=false,
isinteractable = true,
}
npcManager.setNpcSettings(HeartSettings)
npcManager.registerHarmTypes(npcID, {}, {})
function Heart.onTickNPC(v)
--Don't act during time freeze
if Defines.levelFreeze then return end
local data = v.data
--If despawned
if v.despawnTimer <= 0 then
--Reset our properties, if necessary
data.initialized = false
return
end
--Initialize
if not data.initialized then
--Initialize necessary data.
data.initialized = true
end
end
function Heart.onPostNPCKill(v,reason)
if v.id ~= npcID then
return
end
if npcManager.collected(v,reason) then
if health < 3 then -- prevent the counter to exceed max health
health = health + 1
end
Misc.givePoints( 6, v, true)
end
end
--Register events
function Heart.onInitAPI()
npcManager.registerEvent(npcID, Heart, "onTickNPC")
registerEvent(Heart, "onPostNPCKill", "onPostNPCKill")
end
--Gotta return the library table!
return Heart
(beware, I might have made some typos)
Anyways, nice to see someone else making a galaxy/odyssey styled health meter. Keep it up!