Projectiles w/ 0 Damage bug [more in post]

Bugs that have been investigated and resolved somehow.

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.
User avatar
Lord Misfit
Posts: 227
Joined: Wed Dec 27, 2006 8:13 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: Canton, OH
Contact:

Projectiles w/ 0 Damage bug [more in post]

Post by Lord Misfit »

Okay, here's the gist of it: I've made a projectile using properties of FastProjectile in order to have near instant speed. Some things to note on this: I have the damage set exactly to 0, but I also have +FORCEPAIN set, and it is set to a specfic damagetype called "GravityHP" which works with each of my monsters having a "Pain.GravityHP" state. Basically what I'm trying to do is make something that works like one of those spells in RPG games that removes a set % of the target's Health, and that's why there's no base damage from the actual projectile, as I'm using an ACS script within the "Pain.GravityHP" state to do the Health changes. The FastProjectile nature is so the spell-projectile nigh-instantly hits whatever I'm aiming at [I tried to use A_FireBullets and make a puff version, but it wasn't working out the way I was hoping, and this was already mostly working].

The problem/bug is that while most of my monsters are put into the Pain.GravityHP state the way they should, but it seems certain monsters which have their 'DamageFactor "Normal"' set to below "1" aren't even being forced into their pain states. I commented out these on the monsters and they went into pain states upon getting hit by the 0 damage projectiles again like all other monsters. For some reason, FastProjectiles inflicting 0 damage on monsters with their "normal" damagefactor set below 1 will never make said monsters go into their pain state even if the projectile has +FORCEPAIN set.

Is this a bug, or is it intentional behavior? Because I'd really like to know for sure. :o

Code for testing [since the wad this is in is way too big to break things down directly for a file right now].

Following code is the Gravity-Spell's projectile itself. Add this, and use summon or so to shoot if you need to for testing

Code: Select all

actor GravityHPBall : FastProjectile
{
 Damage (0)
 +PIERCEARMOR
 +FORCERADIUSDMG
 +FORCEPAIN
 +NODAMAGETHRUST
 +CANNOTPUSH
 +NOTIMEFREEZE
 RenderStyle Add
 DamageType "GravityHP"
 Alpha 0.0
 Speed 255
 Radius 6
 Height 8
 FastSpeed 255
 SeeSound "null"
 DeathSound "null"

 States
 {
  Spawn:
   TNT1 A 0
   TNT1 A 4
   loop
  Death:
   TNT1 A 0 
   TNT1 A 0 A_PlaySound("monster/diagra")
   TNT1 A 0 bright A_SpawnItem("DiabloistGravityHPTargeter")
   stop
 }
}
The following code is for the specfic painstate for the GravityHP attack. Put this in a code block for any monster you wish to test this out on.

Code: Select all

  Pain.GravityHP:
    TNT1 A 0 ACS_ExecuteAlways(71,0,0,0,0) // or you can replace the ACS_execute with your own action that you believe will best help you to determine they have entered the pain state, since you won't have the ACS script itself for the testing here.
    Goto See
Also, putting "Painchance "GravityHP", 255" in the offending monsters' code block doesn't help make it any more likely for them to be put into their pain state

And for any monster you want to test this out on, also add "damagefactor "normal" [somevalue under "1"]", and it should hopefully emulate the bug I think is here. You can also remove it to see if the projectile will work properly afterwords too. o.o

EDIT: Also, I was told 256 on Painchance was overflow, so I fixed that to 255, but it still didn't really change anything.

EDIT #2: CRAP. It's not just "FastProjectile" based attacks. Normal Projectiles are also falling prey to this bug/problem. o.o
Last edited by Lord Misfit on Mon Feb 28, 2011 11:44 am, edited 2 times in total.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: FastProjectiles w/ 0 Damage bug [more in post]

Post by NeuralStunner »

Have you tried putting the 0 in the Damage value in parentheses? As in "Damage (0)". I've had to do this before to make certain collisions work (with normal projectiles, even).
User avatar
Lord Misfit
Posts: 227
Joined: Wed Dec 27, 2006 8:13 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: Canton, OH
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Lord Misfit »

It was set to (0) before, actually. o.o

Also, I think I've found that if DamageFactor reduces the damage taken by the monster from said attack to under 1, it will not enforce +FORCEPAIN. This is very strange and bug-like to me because if there's no reduction-type damagefactors for a monster and a (0) damage projectile with +FORCEPAIN hits them it still forces them into their pain state like it should. >.>

I tested both a fastprojectile version of my attack and a normal style based on the DoomImpBall. I set the damage to (1) and then (2) on both. For (1), it didn't work, but for (2) it worked on 4 out of 5 of my enemies with reducing DamageFactors on them [0.75, 0.75, 0.5, 0.5 and 0.33 base damagefactors in that order, and only the 0.33 one failed to be put into pain]. However on the two with 0.5 damagefactor, I also have it they gain defense/attack buffs when put below 37.5% of their total health, and once THAT happens, those monsters no longer are forced into pain by the (2) damage version of either type of projectile.

Due to this, it seems to me there's a check for when damagefactor is being enforced that makes a projectile ignore it's +FORCEPAIN flag if the amount of damage it ends up inflicting on the monster in question is under 1 [or 0]. Still doesn't explain why a normal (0) damage projectile that hits a typical monster with no "DamageFactor"s given to it will still enforce +FORCEPAIN on said monsters though. :|
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49238
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Graf Zahl »

Lord Misfit wrote: but it seems certain monsters which have their 'DamageFactor "Normal"' set to below "1" aren't even being forced into their pain states.

Quoted to highlight the actual problem here. Yes, that's indeed not correct.
User avatar
Lord Misfit
Posts: 227
Joined: Wed Dec 27, 2006 8:13 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: Canton, OH
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Lord Misfit »

Sorry for the derpy-sounding response, maybe it's because I just woke up briefly and got a message about it and I'm not fully conscious, but does that mean you do or don't see this as a bug/problem? z.o; Brain's not fully turned on right now and about to fall back to sleep. :P
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49238
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Graf Zahl »

It looks like the damage factor checks are overriding the FORCEPAIN flag - which clearly is a bug.
User avatar
Lord Misfit
Posts: 227
Joined: Wed Dec 27, 2006 8:13 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: Canton, OH
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Lord Misfit »

Okay, thanks for clearing that up for me Graf. :)
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by NeuralStunner »

Lord Misfit wrote:It was set to (0) before, actually. o.o
It was worth a shot. Hopefully this can be tracked down easily enough, though.

Is this a similar situation to A_Explode requiring at least 1 Damage to enforce Pain? Just asking because I was hoping it too might see a solution in the process. ;)
User avatar
Lord Misfit
Posts: 227
Joined: Wed Dec 27, 2006 8:13 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: Canton, OH
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Lord Misfit »

Just a little curious, has anything new happened concerning this particular bug? o.o
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49238
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Graf Zahl »

No, because currently none of the developers is actively working on fixing bugs and for the foreseeable future that's not going to change. I don't have any time at the moment and Randy also seems to be busy with other things.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Projectiles w/ 0 Damage bug [more in post]

Post by FDARI »

What is the correct behaviour for damage factor? I'd expect it to treat the resultant amount of damage (may be 0) exactly as it would an equal amount of unmodified damage.

In P_DamageMobj the following seem effectively to have precedence over +FORCEPAIN:
  • Health at 0 or lower: Dead, rightly feel no pain. Returns from the function before pain processing.*
    *Death after damage also avoids painhandling.
  • Spectral (when damage does not apply to spectral being): Returns.
  • Invulnerability (when not foiled by damage flags or inflicting actor +FOILINVUL): Returns. *
    * Is this behaviour different for players? Damage processings seems to continue normally unless the player has PPF_NOTHRUSTWHENINVUL.
    *Player invulnerability turns out to be fully handled later in code, but the inflictor flag MF3_FOILINVUL seems ineffective against players.
  • Actor is dormant (and damage is not forced): Returns.
  • Some more spectral complexity that I don't think is relevant. (Altought if DoSpecialDamage returns -1 pain processing will be omitted.)
  • If PowerDamage or PowerProtection cause damage to change to 0, the function returns.
  • DamageFactor appears to be very special:
    - First, any type specific damage factor is applied. If it reduces damage to 0 or less, the function returns.
    - Then, a general damage factor (probably 1 by default) is applied. If it reduces damage to 0 or less, the function returns.
  • Any non-forced damage will now go through TakeSpecialDamage. A result of -1 causes immediate return.
  • If damage is reduced to 0 or less by team-damage factor, the function returns.
  • If monster damage is reduced to 0 or less by armour, the function returns.
  • If wound-state is executed, pain-state is not.
There is one explicit check of forcepain: When armour reduces damage sustained by a player, to 0 or less. If forcepain is checked, a jump to the label "dopain" is executed. The dopain label is found after checks for NOPAIN and PAINLESS flags, so if pain is not supposed to be inflicted, 0 damage will cause pain anyway.

I think the "dopain" label is an attempt at the quick fix I had in mind, but perhaps not the ideal one. In any of the above scenarios where pain should be a possibility, "return" could be replaced with "goto checkpain", which would be a label immediately before the full pain-handling code. (Starting by checking the +NOPAIN and +PAINLESS flags, which are ignored when jumping with "goto Dopain".)
Мichаеlis
Posts: 95
Joined: Thu Mar 18, 2010 12:36 pm

Re: Projectiles w/ 0 Damage bug [more in post]

Post by Мichаеlis »

FDARI wrote: Invulnerability (when not foiled by damage flags or inflicting actor +FOILINVUL): Returns. *
*Player invulnerability turns out to be fully handled later in code, but the inflictor flag MF3_FOILINVUL seems ineffective against players.
Isn't it expected behavior?
[wiki]Actor_flags#Projectile[/wiki]
FOILINVUL
Can hurt invulnerable monsters (but not players).
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Projectiles w/ 0 Damage bug [more in post]

Post by FDARI »

Expected and documented I see. I read the code, not the wiki. What I'd like to know is which of the occurences above that cause unexpected behaviour. Damage factor reducing damage to 0 is one such.

EDIT: More specifically; in what cases where the code jumps out with "return" should "FORCEPAIN" be checked first?
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Projectiles w/ 0 Damage bug [more in post]

Post by FDARI »

I've made a patch, completely untested for now.

Enclosed is a list of intended changes, to help you verify that I've done what I think I've done, and to help the devs find changes that should not have been made.
Spoiler: Changes
What sort of bugs might be introduced in this version?

Checks for friendly fire and invulnerabilities are not the first that are made. It may be that all checks that may cause "return" should be performed before any checks that may cause "goto checkforcepain" (replaces dopain, which missed a few points).

I haven't the time and capacity to investigate and correct that right now.

Ladies and gentlemen; please review.
Attachments
p_damagemobj.bug.zdoom.txt
(10.55 KiB) Downloaded 33 times
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Projectiles w/ 0 Damage bug [more in post]

Post by NeuralStunner »

This is making me wish for a flag to force pain checks for 0-damage attacks. (As in, an actor would still "roll" for Pain even when taking no damage from the flagged projectile/puff.)

Actually I'd be fine with a way to allow +FORCEPAIN on 0-damage [wiki]A_Explode[/wiki] calls...
Post Reply

Return to “Closed Bugs [GZDoom]”