Giving 10 Max Health without Healing player to Full

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Zemini7
Posts: 4
Joined: Wed Apr 13, 2022 11:02 am

Giving 10 Max Health without Healing player to Full

Post by Zemini7 »

Very long time lurker, first time poster ... I think my older account got deactcivated. Anyways google search has brought me to these forums many times in search for answers to fix my megawad. However this one still seems to be be either impossible or very complicated in the scripting world. I am not very good with ACS, so any help will be much appreciated.

Question: How can I create a health item (think Zelda Hearts, Metroid Energy Tanks) that add to max health (solved) but the item does NOT bring the player health back to full. This has created some balancing errors. Right not my solution is to give these items towards the end of maps but even so in later levels it makes the wad too easy since a single item can give hundreds of health at once. The sooner i can solve this the faster I can really start playtesting for balance.

Item in question within Decorate

actor VitalitySerum : UpgradeStamina 16485
{

//$Category Powerups
//$Title "Vitality Serum"
Radius 20
Scale 0.9
Inventory.Amount 10 //this controls how much health boost you receive
Inventory.MaxAmount 666 //this controls how high your health can get
+COUNTITEM
+INVENTORY.ALWAYSPICKUP
Inventory.PickupMessage "You have increased your maximum total health by 10!"
States
{
Spawn:
VSRM ABCD 6 Bright
loop
}
}

I believe the solution is ACS but my experience with that is very limited. I suppose it would go something like this.

1. Store current health
2. Pick up item (which also heals you to full)
3. return to previous stored health
4. Give 10 HP (or 1,5, ect depending on the value of this energy tank)

Is this even possible? Thanks for anyone help.
Zemini7
Posts: 4
Joined: Wed Apr 13, 2022 11:02 am

Re: Giving 10 Max Health without Healing player to Full

Post by Zemini7 »

Jack Krausser made this for me in Zscript from the UDB discord.

Class MaxHealthPack : Inventory
{
Int MaxHPBonus;
Property MaxHPBonus : MaxHPBonus;
Default
{
Inventory.MaxAmount 1;
Inventory.PickUpMessage "BonusHealth: +25";
MaxHealthPack.MaxHPBonus 25;
}

Override Bool TryPickUp(in out Actor toucher)
{
Bool Success = False;
Let P = PlayerPawn(toucher);
If(P)
{
P.BonusHealth += MaxHPBonus;
P.GiveBody(MaxHPBonus);
Success = True;
}
Success |= Super.TryPickUp(toucher);
If(Success)
GoAwayAndDie();
Return Success;
}

States
{
Spawn:
MEDI A -1;
Stop;
}
}

Seems to work if i inherit onto decorate by just replacing UpgradeStamina into MaxHealthPack. More testing needed.
User avatar
ramon.dexter
Posts: 1290
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Giving 10 Max Health without Healing player to Full

Post by ramon.dexter »

Please, lern how to format code using Code tags. Please, learn how to indent code. It really helps with readability.

Something like this:

Code: Select all

Class MaxHealthPack : Inventory
{
    Int MaxHPBonus;
    Property MaxHPBonus : MaxHPBonus;
    Default
    {
        Inventory.MaxAmount 1;
        Inventory.PickUpMessage "BonusHealth: +25";
        MaxHealthPack.MaxHPBonus 25;
    }

    Override Bool TryPickUp(in out Actor toucher)
    {
        Bool Success = False;
        Let P = PlayerPawn(toucher);
        If(P)
        {
            P.BonusHealth += MaxHPBonus;
            P.GiveBody(MaxHPBonus);
            Success = True;
        }
        Success |= Super.TryPickUp(toucher);
        If(Success)
        GoAwayAndDie();
        Return Success;
    }

    States
    {
        Spawn:
            MEDI A -1;
            Stop;
    }
}
..look much better, don't you think?

Edit: Also, this health raise could be achieved using Strife's UpgradeStamina inventory item. Strife had very basic rpg stats, accuracy and stamina. Raise of stamina permanently raises player's health, while raising accuracy raises, well, accuracy used with strife's weapon functions. So the accuracy part will not do anything if you are using doom/heretic/hexen weapon functions.

But with zscript you can easily create your own weapon functions.
Zemini7
Posts: 4
Joined: Wed Apr 13, 2022 11:02 am

Re: Giving 10 Max Health without Healing player to Full

Post by Zemini7 »

problem with Strife item was that it was healing me to full. Right now the zscript one is working so far.
User avatar
ramon.dexter
Posts: 1290
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Giving 10 Max Health without Healing player to Full

Post by ramon.dexter »

Which strife item are you speaking about?

Return to “Scripting”