Can monster melee attacks poison the player?

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!)
Post Reply
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Can monster melee attacks poison the player?

Post by Heisanevilgenius »

I'm specifically looking for a way to use A_CustomComboAttack to poison a player, but only with melee. The projectile would not poison them. Since melee monster attacks don't use puffs, I'm not sure how to implement it.
User avatar
Player701
 
 
Posts: 1707
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Can monster melee attacks poison the player?

Post by Player701 »

If you can use ZScript, it is not that difficult a task to code a function that does exactly what you want:

Code: Select all

void A_CustomPoisonComboAttack(class<Actor> projType, int meleeDamage, sound meleeSound)
{
    if (Target != null && CheckMeleeRange())
    {
        A_StartSound(meleeSound, CHAN_WEAPON);
        int newdam = Target.DamageMobj(self, self, meleeDamage, 'Melee');
        Target.TraceBleed(newdam > 0 ? newdam : damage, self);
        Target.PoisonMobj(self, self, PoisonDamage, PoisonDuration, PoisonPeriod, PoisonDamageType);
    }
    else
    {
        A_SpawnProjectile(projType);
    }
}
In melee, this attack will play the meleeSound sound, do meleeDamage damage to the target, and also poison them according to the calling actor's poison damage properites. Otherwise, if the target is not in melee range, it will fire a projectile of type projType. If you want the melee attack to only do poison damage and not regular damage, simply remove the calls to DamageMobj and TraceBleed (you may then also remove the meleeDamage argument as it won't be needed for anything anymore).

Usage example:

Code: Select all

class TestImp : DoomImp replaces DoomImp
{
    Default
    {
        PoisonDamage 2;
    }

    States
    {
        Melee:
        Missile:
            TROO EF 8 A_FaceTarget;
            TROO G 6 A_CustomPoisonComboAttack('DoomImpBall', random(1, 8) * 3, "imp/melee");
            Goto See;
    }

    void A_CustomPoisonComboAttack(class<Actor> projType, int meleeDamage, sound meleeSound)
    {
        if (Target != null && CheckMeleeRange())
        {
            A_StartSound(MeleeSound, CHAN_WEAPON);
            int newdam = Target.DamageMobj(self, self, meleeDamage, 'Melee');
            Target.TraceBleed(newdam > 0 ? newdam : damage, self);
            Target.PoisonMobj(self, self, PoisonDamage, PoisonDuration, PoisonPeriod, PoisonDamageType);
        }
        else
        {
            A_SpawnProjectile(projType);
        }
    }
}
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Can monster melee attacks poison the player?

Post by Heisanevilgenius »

Fantastic, thank you!
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Can monster melee attacks poison the player?

Post by Heisanevilgenius »

So, a weird side effect is that these monsters now infight when they hit each other with their projectiles... I'm not sure why that is. I'm not even sure they do damage to each other. They just keep attacking each other in a big endless brawl.
User avatar
Player701
 
 
Posts: 1707
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Can monster melee attacks poison the player?

Post by Player701 »

Heisanevilgenius wrote: Thu Apr 24, 2025 1:46 pm So, a weird side effect is that these monsters now infight when they hit each other with their projectiles...
I'm unable to reproduce this with my example code. It must be caused by something else in your code.
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Can monster melee attacks poison the player?

Post by Heisanevilgenius »

How strange. Okay, thank you.
Heisanevilgenius
Posts: 93
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Can monster melee attacks poison the player?

Post by Heisanevilgenius »

Yeah, you're right. The problem is not the custom attack. It must be something weird with the projectile. I'll have to look into it further. Thanks again.
Post Reply

Return to “Scripting”