Making Healing Weapon Item that sets the player health to 50

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
User avatar
Z.Franz
Posts: 35
Joined: Fri Jun 12, 2015 3:46 am
Location: Italy

Making Healing Weapon Item that sets the player health to 50

Post by Z.Franz »

Hi all, again.
I'm still working on that survival horror mod and I'm still here asking for your help on something. Damn :(
So, I made 2 healing items in form of weapons because that's what I was going for (bandages and herbs).
Everything works, as long as I make both items give health that gets added to the player's health pool on the "fire" state.
What I'm wondering and asking any of you kind souls is if there's a way to make the item set the player health to a fixed amount (instead of adding) without "breaking" effects happening due to "A_JumpIfHealthLower" and without making it a different item to use with the "use item" key (basically, no Hexen-type healing).
To clarify on that last point, I already set the max health of the "PlayerPawn" to 80, which is the maximum amount of health I want the player to be able to heal with the best of the 2 healing items (bandages). At 75% health or lower, until 20%, the player suffers from bleeding damage. If I set the amount of "maxhealth" to 75, modify the best healing item (bandages) to give 75 health plus 5 healthbonuses, and then modify the worst healing item (herbs) to heal 75, the bleeding won't start until the player takes damage.
In the ideal situation, the lesser healing item would set the player health to 50%, so it still suffers from the open wound, while the best one sets the player health to 80% (this last thing I was able to achieve with the aforementioned changing of "Player.MaxHealth" to 80)
Sort of like Left 4 Dead.

As always, thank you all guys. Cheers! :D
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Making Healing Weapon Item that sets the player health t

Post by Blue Shadow »

Have you tried [wiki]A_SetHealth[/wiki]?
User avatar
Z.Franz
Posts: 35
Joined: Fri Jun 12, 2015 3:46 am
Location: Italy

Re: Making Healing Weapon Item that sets the player health t

Post by Z.Franz »

Yep, I tried it. On 2 out of 3 engine versions I tested it on, it crashed the game on startup saying that it's an invalid parameter or something like that.
On the only engine where it worked (GZDoom 3.0), when called, it didn't do anything.

I realized I didn't say what engine I'm developing for:
Main version is for Zandronum 1.3 - because that's the version where I've made most of the mods for my enjoyment .
I'm also making a custom version on Zandronum 3.0 and GZDoom 3.0, mainly because they are the closest thing to D-Touch, in terms of usuable DECORATE definitions(like A_GetHurt on player states for the bleeding effect).
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Making Healing Weapon Item that sets the player health t

Post by Blue Shadow »

Z.Franz wrote:Main version is for Zandronum 1.3 - because that's the version where I've made most of the mods for my enjoyment .
I'm also making a custom version on Zandronum 3.0 and GZDoom 3.0, mainly because they are the closest thing to D-Touch, in terms of usuable DECORATE definitions(like A_GetHurt on player states for the bleeding effect).
You may have to take the [wiki]ACS[/wiki] route, then, with [wiki]SetActorProperty[/wiki].
On the only engine where it worked (GZDoom 3.0), when called, it didn't do anything.
How did you use it?
User avatar
Z.Franz
Posts: 35
Joined: Fri Jun 12, 2015 3:46 am
Location: Italy

Re: Making Healing Weapon Item that sets the player health t

Post by Z.Franz »

Well, damn. I was hoping I would never have to use ACS again...

Regarding A_SetHealth, If I remember correctly (I changed the code days ago), I first tried putting it in the "Fire" state of the weapon and then on the "Pickup" state of the "inventory item"(item aptly called "RestoringLittleHealth" that inherits from "Health") that actually is given to the player when the "weapon" is fired. I may have had to put it on player states, but I didn't think it was worth the time, since it wasn't working on any version of Zandronum.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Making Healing Weapon Item that sets the player health t

Post by Matt »

HealThing(max(0,50-health)) should work in Decorate...
User avatar
Z.Franz
Posts: 35
Joined: Fri Jun 12, 2015 3:46 am
Location: Italy

Re: Making Healing Weapon Item that sets the player health t

Post by Z.Franz »

Matt wrote:HealThing(max(0,50-health)) should work in Decorate...
I gave it a shot, but both versions of Zandronum tell me <<Call to unknown function 'max'>> and won't load the wad.

EDIT: seems to work now that I've put it like this: "PISG D 2 HealThing(50, 50)"
Last edited by Z.Franz on Mon Mar 26, 2018 10:13 am, edited 1 time in total.
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm

Re: Making Healing Weapon Item that sets the player health t

Post by Mikk- »

Unfortunately Zandronum is a bit behind on the times, and doesn't support a number of features that GzDOOM has.
User avatar
Z.Franz
Posts: 35
Joined: Fri Jun 12, 2015 3:46 am
Location: Italy

Re: Making Healing Weapon Item that sets the player health t

Post by Z.Franz »

Z.Franz wrote:
Matt wrote:HealThing(max(0,50-health)) should work in Decorate...
EDIT: seems to work now that I've put it like this: "PISG D 2 HealThing(50, 50)"
Ok, to close the topic, this seems to have worked on all 3 versions and doesn't corrupt savegames, so yeah!
Thank you all guys, you all were, as always, a big help! :D

Return to “Scripting”