gzdoom/wadsrc/static/zscript/doom/weaponfist.txt
Christoph Oelckers a851a5d151 - fixed: For melee attacks with a short attack range P_AimLineAttack must check for hits from above and below.
This is necessary to be in line with P_LineAttack which does check for those.
2018-06-03 17:49:00 +02:00

80 lines
No EOL
1.5 KiB
Text

// --------------------------------------------------------------------------
//
// Fist
//
// --------------------------------------------------------------------------
class Fist : Weapon
{
Default
{
Weapon.SelectionOrder 3700;
Weapon.Kickback 100;
Obituary "$OB_MPFIST";
Tag "$TAG_FIST";
+WEAPON.WIMPY_WEAPON
+WEAPON.MELEEWEAPON
}
States
{
Ready:
PUNG A 1 A_WeaponReady;
Loop;
Deselect:
PUNG A 1 A_Lower;
Loop;
Select:
PUNG A 1 A_Raise;
Loop;
Fire:
PUNG B 4;
PUNG C 4 A_Punch;
PUNG D 5;
PUNG C 4;
PUNG B 5 A_ReFire;
Goto Ready;
}
}
//===========================================================================
//
// Code (must be attached to Actor)
//
//===========================================================================
extend class Actor
{
action void A_Punch()
{
FTranslatedLineTarget t;
if (player != null)
{
Weapon weap = player.ReadyWeapon;
if (weap != null && !weap.bDehAmmo && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
{
if (!weap.DepleteAmmo (weap.bAltFire))
return;
}
}
int damage = random[Punch](1, 10) << 1;
if (FindInventory("PowerStrength"))
damage *= 10;
double ang = angle + Random2[Punch]() * (5.625 / 256);
double pitch = AimLineAttack (ang, DEFMELEERANGE, null, 0., ALF_CHECK3D);
LineAttack (ang, DEFMELEERANGE, pitch, damage, 'Melee', "BulletPuff", LAF_ISMELEEATTACK, t);
// turn to face target
if (t.linetarget)
{
A_PlaySound ("*fist", CHAN_WEAPON);
angle = t.angleFromSource;
}
}
}