I was told that I should report this by one of the mods so here it goes:
I remember that in older versions of ZDoom and GZdoom, in order to make enemy attacks and projectiles heal the player, all you had to do was change the "Damage" flag to a negative number. Now it seems like that no longer works. This is a feature that is needed for a small mod I created.
Is this a bug or was this intentionally removed?
Custom enemy attacks no longer heal players
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
Re: Custom enemy attacks no longer heal players
Why can't you heal with more conventional means? Like, givin' a health pack for the lazy, or using more direct approaches?
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
Re: Custom enemy attacks no longer heal players
It was for a mod I created a while ago. The Pain Elemental's new attack purposely healed players by shooting a fireball that heals players by 5 HP.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Custom enemy attacks no longer heal players
This was changed because dealing negative damage is totally undefined behavior. If it worked it was by happenstance but even then it tended to do things that were just wrong.
-
- Posts: 4949
- Joined: Sun Nov 14, 2010 12:59 am
Re: Custom enemy attacks no longer heal players
But there is an explicit code for this, for projectiles only anyways, in PIT_CheckThing.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Custom enemy attacks no longer heal players
The relevant check is in P_DamageMobj.At the end of the day the damage infliction code cannot handle negative values. It has always been undefined behavior but some more recent changes made it impossible to keep this case working.
- 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
- Contact:
Re: Custom enemy attacks no longer heal players
Can't there be a check added to the beginning of DamageMobj to deal with negatives? There've got to be a lot of old (or not even necessarily that old) mods that were written on the assumption that this would work.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Custom enemy attacks no longer heal players
There is a check at the beginning to exit if the value is negative. I haven't tracked down the reason but rest assured, it was necessary because some changes to that function could no longer handle it.