A_Blast, how much damage is dealt on collision?
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!)
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!)
A_Blast, how much damage is dealt on collision?
Does anyone happen to know how exactly A_Blast calculates how much damage is dealt when the affected actor collides with something/someone?
Re: A_Blast, how much damage is dealt on collision?
It's based on the actor's mass.
The collider will inflict damage to the collidee equal to 1 + 1/100th of the collider's mass.
Reciprocally, the collidee will inflict damage to the collider equal to 1/4th of (1+1/100th the collidee's mass).
tm.thing is the collider (blasted thing) and thing is the collidee (the impact target for the blasted thing).
Also when a thing is blasted into a wall, it takes damage equal to its own mass divided by 32:
(The ">>" symbol is a right bitshift, >>5 means bits are shifted right by five points, which amounts to dividing by 2 to the power of 5.)
The collider will inflict damage to the collidee equal to 1 + 1/100th of the collider's mass.
Reciprocally, the collidee will inflict damage to the collider equal to 1/4th of (1+1/100th the collidee's mass).
Code: Select all
// Check for blasted thing running into another
if ((tm.thing->flags2 & MF2_BLASTED) && (thing->flags & MF_SHOOTABLE))
{
if (!(thing->flags2 & MF2_BOSS) && (thing->flags3 & MF3_ISMONSTER) && !(thing->flags3 & MF3_DONTBLAST))
{
// ideally this should take the mass factor into account
thing->Vel += tm.thing->Vel.XY();
if (fabs(thing->Vel.X) + fabs(thing->Vel.Y) > 3.)
{
int newdam;
damage = (tm.thing->Mass / 100) + 1;
newdam = P_DamageMobj(thing, tm.thing, tm.thing, damage, tm.thing->DamageType);
P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing);
damage = (thing->Mass / 100) + 1;
newdam = P_DamageMobj(tm.thing, thing, thing, damage >> 2, tm.thing->DamageType);
P_TraceBleed(newdam > 0 ? newdam : damage, tm.thing, thing);
}
return false;
}
}
Also when a thing is blasted into a wall, it takes damage equal to its own mass divided by 32:
Code: Select all
if (tm.thing->flags2 & MF2_BLASTED)
{
P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee);
}
Last edited by Gez on Sat Nov 21, 2020 2:43 am, edited 1 time in total.
Re: A_Blast, how much damage is dealt on collision?
Hm, I have just tested it on Ettins and something seems off. The Ettin that was blasted into another Ettin suffers 10 damage, and the Ettin that was standing when the first one was blasted into him suffers 4 damage. And when they are blasted into architecture the damage seems to be rather random (though almost always (but not always) divisible by 5), or I can't understand the pattern: the distance seems to have no significance.
Re: A_Blast, how much damage is dealt on collision?
It appears I have found a bug (though I don't understand what in the code is causing it), or even two.
1. The damage to both the collider and the collidee is applied 2 times. If you blast the victim into architecture, the damage is applied 2 times at the minimum, sometimes many times more (more than ten times).
2. The collider and collidee become "entangled". After you have collided one into another once, you can blast one while the other is nowhere near your field of view, and the other gets blasted too.
I think I need to report it.
1. The damage to both the collider and the collidee is applied 2 times. If you blast the victim into architecture, the damage is applied 2 times at the minimum, sometimes many times more (more than ten times).
2. The collider and collidee become "entangled". After you have collided one into another once, you can blast one while the other is nowhere near your field of view, and the other gets blasted too.
I think I need to report it.