no extreme death for weapon using with Zscript

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
User avatar
Lagi
Posts: 676
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

no extreme death for weapon using with Zscript

Post by Lagi »

Im using zcript to simulate autoaim melee attack, ala hexen.

my melee weapons are doing lots of damage to a stun enemies (as intended), but this gib them, which looks odd when you poke monster with sitck and he explode in fountain of blood.
Spoiler:
I was trying without a success to prevent certain weak melee weapon to ever deal XDeath to enemies. Any ideas how to achieve it?

Adding this flag doesnt work, check all code below
NOEXTREMEDEATH
This projectile or puff never gibs its victim.
==========================

i put this in weapon attack sprite seqeunce block instead A_Custompunch

Code: Select all

stff m 3 A_GiveInventory ("Func_StaffAttack")
decorate "function"

Code: Select all

    Actor Func_StaffAttack : HexenMeleeWeapon
    {
       States
       {
       Pickup: 
		   TNT1 A 0 A_HexenPunch(random(20, 35),100, "staffpuff3")
          Stop
       }
    }

ACTOR staffpuff3 : StaffPuff
{
	+NOEXTREMEDEATH 
}

zscript (full):

Code: Select all

class HexenMeleeWeapon  : CustomInventory
{
 


    private action bool TryPunch(double angle, int damage, int power, int range, class<Actor> pufftype)
    {
        Class<Actor> pufftype;
        FTranslatedLineTarget t;

        double slope = AimLineAttack (angle, range, t, 0., ALF_CHECK3D);
        if (t.linetarget != null)
        {
            LineAttack (angle, range, slope, damage, 'Melee', pufftype, true, t);
            if (t.linetarget != null)
            {
                // The mass threshold has been changed to CommanderKeen's value which has been used most often for 'unmovable' stuff.
                if (t.linetarget.player != null || (t.linetarget.Mass < 10000000 && (t.linetarget.bIsMonster)))
                {
                    if (!t.linetarget.bDontThrust)
                    {
                        t.linetarget.Thrust(power, t.attackAngleFromSource);
                    }
                }
                AdjustPlayerAngle(t);
                return true;
            }
        }
        return false;
    }

    action void A_HexenPunch(int damage, int range = 0, class<Actor> pufftype = 'StaffPuff', sound hitsound = "", sound misssound = "")
    {
        if (player == null)
        {
            return;
        }

        if (range == 0)
        {
            range = DEFMELEERANGE;
        }

        if (pufftype == null)
        {
            pufftype = 'StaffPuff';
        }

        for (int i = 0; i < 16; i++)
        {
            if (TryPunch(angle + i*(45./16), damage, 2, range, pufftype) || TryPunch(angle - i*(45./16), damage, 2, range, pufftype))
            {
                // hit something           
                A_StartSound (hitsound, CHAN_WEAPON);
                return;
            }
        }

        A_StartSound (misssound, CHAN_WEAPON);
        double slope = AimLineAttack (angle, range, null, 0., ALF_CHECK3D);
        LineAttack (angle, range, slope, damage, 'Melee', pufftype, true);
    }
}
Post Reply

Return to “Scripting”