[Library] Stats.lua - A basic RPG mechanics script

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby ShadowXeldron » Tue May 24, 2022 9:37 am

RadMetalMarioSMIX wrote:
Mon May 23, 2022 2:55 pm
For registering NPCs do I put it in the global and/or level Luna.lua file?
Would that also apply to healing Items?

P.S. Is there anything this isn’t compatible with?
Not sure about incompatabilities since I tested it on its own. You can register NPCs in both the local and global Luna.lua files, for example what I've done for my project is register common NPCs in the golbal script and level-specific ones in the level script. The same applies for healing items, although I would usually do those in the global file.

RadMetalMarioSMIX
Buster Beetle
Buster Beetle
Posts: 87
Joined: Sat Mar 14, 2015 6:42 pm
Flair: What kind of grave is this?
Pronouns: he/him

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby RadMetalMarioSMIX » Wed May 25, 2022 7:03 pm

Okay, thank you.

MarioChallengerX2
Buster Beetle
Buster Beetle
Posts: 89
Joined: Sat Dec 31, 2022 4:34 pm
Pronouns: he/him

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby MarioChallengerX2 » Thu Apr 20, 2023 8:21 pm

Hey, how would I make this work with fall damage.lua?

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby ShadowXeldron » Fri Apr 21, 2023 5:58 am

MarioChallengerX2 wrote:
Thu Apr 20, 2023 8:21 pm
Hey, how would I make this work with fall damage.lua?
I don't think you can unfortunately. I might be able to implement a function on my end that allows you to define custom damage values however.

MarioChallengerX2
Buster Beetle
Buster Beetle
Posts: 89
Joined: Sat Dec 31, 2022 4:34 pm
Pronouns: he/him

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby MarioChallengerX2 » Mon Apr 24, 2023 11:44 am

Dragon0307 wrote:
Fri Apr 21, 2023 5:58 am
MarioChallengerX2 wrote:
Thu Apr 20, 2023 8:21 pm
Hey, how would I make this work with fall damage.lua?
I don't think you can unfortunately. I might be able to implement a function on my end that allows you to define custom damage values however.
That would be useful. Hey, do you have discord? Because I might want to contact you if I need help using this. (I'm debating whether or not I should use it for MAFAB 3.

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby ShadowXeldron » Wed Apr 26, 2023 6:36 am

MarioChallengerX2 wrote:
Mon Apr 24, 2023 11:44 am
Dragon0307 wrote:
Fri Apr 21, 2023 5:58 am
MarioChallengerX2 wrote:
Thu Apr 20, 2023 8:21 pm
Hey, how would I make this work with fall damage.lua?
I don't think you can unfortunately. I might be able to implement a function on my end that allows you to define custom damage values however.
That would be useful. Hey, do you have discord? Because I might want to contact you if I need help using this. (I'm debating whether or not I should use it for MAFAB 3.
I probably wouldn't use this for MAFAB, since it uses SaveData (which isn't ideal for contests) and it's meant for full size episodes that are built around it. If you're dead set on using it then I'd recommend modifying the script to not use SaveData. If what you want for your submission is just the player health system, I guess I could to do a stripped down version with just that.

I've also managed to get the custom player damage function up and running, so when I squeeze in a few more functions that I want there should be a new version up.

As for my Discord, it's
Spoiler: show
ShadowXeldron#0146

lancergaming125
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Aug 09, 2024 7:05 pm
Pronouns: he/him

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby lancergaming125 » Mon Aug 26, 2024 11:26 pm

all of this is nice but is there a combat system for smbx2 that has RPG style Turn based combat? id like to do a M&L style episode but i dont know lua and cant find any turn based combat systems on the forum. if you know of any please private message me a link to the turn based rpg lua.

yoshibro75
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Tue Jun 25, 2024 8:34 pm
Pronouns: he/him

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby yoshibro75 » Wed Sep 04, 2024 11:04 pm

Very cool! A suggestion I have would to be to show the damage numbers when damaging an enemy like in Super Paper Mario.

Paka_Mzuri
Shy Guy
Shy Guy
Posts: 8
Joined: Fri Jan 17, 2025 9:56 pm
Pronouns: He/Him or They/Them

Re: [Library] Stats.lua - A basic RPG mechanics script

Postby Paka_Mzuri » Sun Jan 26, 2025 4:04 am

ShadowXeldron wrote:
Fri Apr 01, 2022 6:48 am
Spoiler: show
DrMekar wrote:
Mon Mar 28, 2022 2:11 pm
Alright. I did another Question though, which would be how I combine that with LightHitPoint.Lua. I always found that nice, but
didn't want to include, since it's kinda 'unfair' to only allow the Enemies to have HP Bars.

Also I would like the Player to heal, when consuming specific Powerups. I saw the Heal Function, but I'm unsure how to use it.
Sorry for the late reply (since I can't get SMBX2 working on any of my devices right now for some reason; probably a Wine update broke it), but I'm actually using LightHitPoint in my project as well. You can just assign the LightHitPoint values normally, and doing. However, I am changing the amount of damage the player can do every frame since it's the only way I could think of getting damage output to scale with the player's level before I implemented onLevelUp:
--HARM TYPES
local function onDraw()
lhp.setHarmtypeDamage(HARM_TYPE_JUMP, stat.level * 0.75) -- When Mario jumps on an enemy
lhp.setHarmtypeDamage(HARM_TYPE_FROMBELOW, stat.level * 3) -- When Mario hits a block, damaging enemies on it.
lhp.setHarmtypeDamage(HARM_TYPE_TAIL, stat.level * 1.5) -- When Mario uses a Tanooki spin.
lhp.setHarmtypeDamage(HARM_TYPE_SPINJUMP, stat.level * 1) -- When Mario spin jumps.
lhp.setHarmtypeDamage(HARM_TYPE_SWORD, stat.level * 0.75) -- When Link stabs someone.

--NPC HARM DAMAGE

lhp.setNPCDamage(13, stat.level * 1.25) --Fireballs
lhp.setNPCDamage(171, stat.level * 3) --Player Hammers
end


This is the exact code I'm using for the damage values in my episode. Feel free to change those values if you want.

A plan for later versions is to add integration with LightHitPoint so that you can assign everything in a single line, as well as finding some use for the currently unused defence stat.

I haven't been able to test it yet due to the aforementioned issues with accessing SMBX2, but this script should heal you by 5 HP whenever you grab an SMB3 Super Mushroom. Feel free to repurpose it for other items.

Code: Select all

function onNPCKill(t,k,h) -- t = Event Token, k = Killed NPC, h = Harm Type
    if h == HARM_TYPE_VANISH and k.id == 9
        stats.heal(5)
    end
end
So I'm trying to add this to an episode im working on, and for my episode, I use the Zelda Heart item to act as a healing item. the issue is that whenever the heart is collected, it goes into the reserve box, letting it be infinitely reused to restore health! Is there any way I can only let it go into reserve if your at full health?
Last edited by ElectriKong on Mon Jan 27, 2025 12:35 pm, edited 1 time in total.
Reason: Spoilered Large Quote


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari