LightHitPoint.lua: HealthPoint's modern cousin.

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

Moderator: Userbase Moderators

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9860
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

LightHitPoint.lua: HealthPoint's modern cousin.

Postby Emral » Sat Jul 27, 2019 7:24 pm

Made in a few hours. Definitely improveable and not too customizable at the moment.

Download:
https://pastebin.com/TmBbVz3G

Demo:
https://www.youtube.com/watch?v=3yZSJNPa7u8
2:25

How to use:
Load the library and it works by default!
Syke! Nothing is preset. You have to register the HP yourself at the moment.
In the future I want it to work with the health variable in NPC config, but that's for basegame.

Customization options:
lhp.iFrames: Unified amount of invulnerability frames across all IDs (25 by default)
lhp.setHarmtypeDamage(Harmtype, value): Sets damage multiplier for specific harm types.
lhp.setHarmtypeSound(Harmtype, value): Sets sound effect for harm types. By default, onNPCHarm cancelling also cancels the SFX, so this adds that back in.
lhp.setNPCDamage(NPCID, value): Sets damage which a specific NPC does when it's determined to be the NPC causing the damage. Stuff like fireballs, hammers, etc...
lhp.setHP(NPCID, value): Sets HP for a specific ID of NPC.
lhp.drawHPBar(npc) draws the HP bar and can be overridden in user code
lhp.registerCallback(npcID, func) lets you register an onHarm callback for a given NPC ID.
The onHarm overload is as follows:
harmFunction(npc, harmReason, culprit, currentHP, damage)
if the harm function returns something, it must be a number. This number will override the damage dealt to the NPC. If nothing is returned, damage is not altered. Return 0 to cancel any damage being dealt.

The HP bar will empty before "vanilla hp" is touched, so it can be considered to be something more akin to armour.
Have fun!
Last edited by Emral on Fri Oct 28, 2022 10:38 pm, edited 1 time in total.

lolcode
Fighter Fly
Fighter Fly
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby lolcode » Thu Jul 23, 2020 10:50 am

Can you please make an example level?

lolcode
Fighter Fly
Fighter Fly
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby lolcode » Sat Aug 08, 2020 2:58 am

the lolie wrote:
Thu Jul 23, 2020 10:50 am
Can you please make an example level?
please do it

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9860
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby Emral » Sat Aug 08, 2020 3:01 am

It wouldn't contain any information not already present in the first post. I don't think it would help you if you cannot apply the customization options above.
Like you load the library and then set the damages. If you explain what part is difficult maybe I can help explain that in more detail.
If you could share what you have tried so far that would also help.

lolcode
Fighter Fly
Fighter Fly
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby lolcode » Sat Aug 08, 2020 6:18 am

i just bad at lunalua but i want to make custom boss

Added in 15 minutes 13 seconds:
i just need npc to have more than 1 hp

lolcode
Fighter Fly
Fighter Fly
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby lolcode » Mon Aug 10, 2020 4:43 am

Enjl wrote:
Sat Aug 08, 2020 3:01 am
It wouldn't contain any information not already present in the first post. I don't think it would help you if you cannot apply the customization options above.
Like you load the library and then set the damages. If you explain what part is difficult maybe I can help explain that in more detail.
If you could share what you have tried so far that would also help.
if im able to see where do i put it and how do i customize it...
then i will be able to use it
(sorry for bad grammar)

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9860
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby Emral » Mon Aug 10, 2020 4:55 am

The installation is exactly the same as with any other library. Drop it in the level folder and load it with require into a variable.
local lhp = require("lighthitpoint")
And then you just access the fields of lhp for customization.

lolcode
Fighter Fly
Fighter Fly
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby lolcode » Mon Aug 10, 2020 5:16 am

where do i put local lhp = require("lighthitpoint")
(im kinda stupid)

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9860
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby Emral » Mon Aug 10, 2020 12:42 pm

the lolie wrote:
Mon Aug 10, 2020 5:16 am
where do i put local lhp = require("lighthitpoint")
(im kinda stupid)
Your luna.lua file which is in the episode folder if you want it to run in every level, and in a level's level folder if you only want it to run in a single level. All this info is on the wiki and in the video tutorials, for reference.

ditditdit
Dolphin
Dolphin
Posts: 92
Joined: Sun Jan 02, 2022 4:25 pm
Flair: e
Pronouns: she/they
Contact:

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby ditditdit » Tue Mar 15, 2022 10:45 am

May I build on this to create a very different module?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9860
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LightHitPoint.lua: HealthPoint's modern cousin.

Postby Emral » Fri Oct 28, 2022 10:38 pm

Updated the library:
lhp.drawHPBar(npc) is now an exposed function and can be overridden in user code
lhp.registerCallback(npcID, func) is a new function that lets you register an onHarm callback for a given NPC ID.
The onHarm overload is as follows:
harmFunction(npc, harmReason, culprit, currentHP, damage)

if the harm function returns something, it must be a number. This number will override the damage dealt to the NPC. If nothing is returned, damage is not altered. Return 0 to cancel any damage being dealt.


Return to “LunaLua”

Who is online

Users browsing this forum: AdvancedTrash and 4 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari