Share and discuss custom LunaLua code and content packs for SMBX2.
Moderator: Userbase Moderators
|
|
|
|
-
AlanLive2020
- Buster Beetle

- Posts: 98
- Joined: Fri Nov 27, 2020 8:15 am
- Flair: The guy with no social skills or self-esteem :')
Postby AlanLive2020 » Fri Dec 24, 2021 12:02 pm
Recently i learned about this fan game called mario editor (which is also a 2d mario level editor). One interesting thing is had was the mario galaxy/odyssey health system. I decided to make a version of it for smbx. I also decided to make a 2 player version, which is quite unique imo. I like the 2 player mode in smbx, but i feel like the two players are too independent of each other.
2 Player mode:
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.
More info is in comments inside the code. There is a 1 player, and 2 player version. It isn't much, i just wanted to know what yall think
Download: https://www.mediafire.com/file/rhn2oht2 ... t.rar/file
|
|
|
|
|
|
|
|
|
-
Alucard648
- Blooper

- Posts: 171
- Joined: Sun Aug 16, 2015 3:45 am
Postby Alucard648 » Fri Dec 24, 2021 4:45 pm
2. I think, if one falls into pit or gets insta-killed in any way, both players should die instantly. Same goes for daredevil comet challenges.
|
|
|
|
|
|
|
|
|
-
AlanLive2020
- Buster Beetle

- Posts: 98
- Joined: Fri Nov 27, 2020 8:15 am
- Flair: The guy with no social skills or self-esteem :')
Postby AlanLive2020 » Fri Dec 24, 2021 4:49 pm
Alucard648 wrote: ↑Fri Dec 24, 2021 4:45 pm
2. I think, if one falls into pit or gets insta-killed in any way, both players should die instantly. Same goes for daredevil comet challenges.
Well the issue is there is a lot of pushing and shoving in multiplayer. I didnt wanna punish the players too much for it. Daredevil mode still kills both if this happens tho.
Edit: You can change the penalty for insta-kills in the code itself if you feel like it.
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 530
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Tue Dec 28, 2021 7:18 am
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!
|
|
|
|
|
|
|
|
|
-
AlanLive2020
- Buster Beetle

- Posts: 98
- Joined: Fri Nov 27, 2020 8:15 am
- Flair: The guy with no social skills or self-esteem :')
Postby AlanLive2020 » Tue Dec 28, 2021 5:59 pm
marioman2007 wrote: ↑Tue Dec 28, 2021 7:18 am
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!
Thank you. The reason i made both players die upon reaching 0 health is because i wanted both players to have to work togheter more, but i could make a version without that change. I also could just disable respawning.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 2 guests
|