Bouncing projectile, poison damage, and SpecialMissileHit()

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!)
D2JK
Posts: 543
Joined: Sat Aug 30, 2014 8:21 am

Bouncing projectile, poison damage, and SpecialMissileHit()

Post by D2JK »

Hi all,

Background: a long while ago, I created a projectile which uses the PoisonDamage property apply a damage-over-time effect. Since this was of "fire" type, I also wanted the initial applications of the "poison" to start a visual burning effect, using particle effects and a thinker for this purpose. This thinker would only be created if the monster had no existing PoisonDamageDuration on it when the projectile hit. Now, since poison damage seems to be already applied by the time the projectile's Death-state and its actions are reached, I needed to work around this problem by performing the relevant checks earlier in SpecialMissileHit function instead, and saving the result in a custom class variable which I could later compare against, in the Death state (see code below).

Code: Select all

override int SpecialMissileHit(actor victim) {
    lastVictim = victim;
    lastVictimHasPoisonDuration = victim.PoisonDurationReceived;

    return Super.SpecialMissileHit(victim);
}
So today I wanted to apply the same concept to a new, bouncing projectile. I was surprised to find out that for a bouncing projectile (namely, using BounceType "Hexen"), even my above workaround would not work; if the projectile can bounce and a monster is hit, then in the last call to SpecialMissileHit(), the poison damage seems to be already applied. It does not matter whether or not this was a direct hit (ie. no actual bouncing having happened after the projectile was shot). If I simply comment out the BounceType property, then the PoisonDamage will not yet be applied in the last call to SpecialMissileHit, so in that case, my previous workaround will work again.

I have to think about how I work around this problem for bouncing projectiles as well. Perhaps even more checks and new class variables to hold the results are required (of course, better ideas and suggestions are welcome).

But I'm also a bit curious if this change in timing of PoisonDamage application (relative to the last SpecialMissileHit call) is intended to happen for bouncing projectiles, and what exactly explains it?
D2JK
Posts: 543
Joined: Sat Aug 30, 2014 8:21 am

Re: Bouncing projectile, poison damage, and SpecialMissileHit()

Post by D2JK »

Actually, it crossed my mind to try reading the poison damage, duration and period properties of the projectile itself. Since this turned out to be possible in ZScript, I was able to simplify the code by instead checking if the monster's (blockingMObj) PoisonDurationReceived after the hit is equal to projectile's PoisonDuration value. This check works for my purposes since I'm using the ADDITIVEPOISONDURATION flag in these projectiles.

Problem solved, thanks all.

Return to “Scripting”