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.

no extreme death for weapon using with Zscript

Postby Lagi » Thu Sep 09, 2021 2:55 pm

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 allExpand view
stff m 3 A_GiveInventory ("Func_StaffAttack")


decorate "function"
Code: Select allExpand view
    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 allExpand view
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);
    }
}
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Return to Scripting

Who is online

Users browsing this forum: No registered users and 3 guests