- A_FPunchAttack no longer thrusts targets with INT_MAX mass.

- Folded duplicated code from A_FPunchAttack into a separate function.

SVN r3680 (trunk)
This commit is contained in:
Randy Heit 2012-06-09 04:00:39 +00:00
parent 6db4164794
commit 2c6763d750
1 changed files with 53 additions and 59 deletions

View File

@ -49,6 +49,48 @@ void AdjustPlayerAngle (AActor *pmo, AActor *linetarget)
} }
} }
//============================================================================
//
// TryPunch
//
// Returns true if an actor was punched, false if not.
//
//============================================================================
static bool TryPunch(APlayerPawn *pmo, angle_t angle, int damage, fixed_t power)
{
const PClass *pufftype;
AActor *linetarget;
int slope;
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget);
if (linetarget != NULL)
{
if (++pmo->special1 >= 3)
{
damage <<= 1;
power *= 3;
pufftype = PClass::FindClass ("HammerPuff");
}
else
{
pufftype = PClass::FindClass ("PunchPuff");
}
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget != NULL)
{
if (linetarget->player != NULL ||
(linetarget->Mass != INT_MAX && (linetarget->flags3 & MF3_ISMONSTER)))
{
P_ThrustMobj (linetarget, angle, power);
}
AdjustPlayerAngle (pmo, linetarget);
return true;
}
}
return false;
}
//============================================================================ //============================================================================
// //
// A_FPunchAttack // A_FPunchAttack
@ -57,14 +99,10 @@ void AdjustPlayerAngle (AActor *pmo, AActor *linetarget)
DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
{ {
angle_t angle;
int damage; int damage;
int slope;
fixed_t power; fixed_t power;
int i; int i;
player_t *player; player_t *player;
const PClass *pufftype;
AActor *linetarget;
if (NULL == (player = self->player)) if (NULL == (player = self->player))
{ {
@ -74,63 +112,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
damage = 40+(pr_fpatk()&15); damage = 40+(pr_fpatk()&15);
power = 2*FRACUNIT; power = 2*FRACUNIT;
pufftype = PClass::FindClass ("PunchPuff");
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
angle = pmo->angle + i*(ANG45/16); if (TryPunch(pmo, pmo->angle + i*(ANG45/16), damage, power) ||
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget); TryPunch(pmo, pmo->angle - i*(ANG45/16), damage, power))
if (linetarget) { // hit something
{ if (pmo->special1 >= 3)
pmo->special1++;
if (pmo->special1 == 3)
{
damage <<= 1;
power = 6*FRACUNIT;
pufftype = PClass::FindClass ("HammerPuff");
}
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget != NULL)
{
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{
P_ThrustMobj (linetarget, angle, power);
}
AdjustPlayerAngle (pmo, linetarget);
goto punchdone;
}
}
angle = pmo->angle-i * (ANG45/16);
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget);
if (linetarget)
{
pmo->special1++;
if (pmo->special1 == 3)
{
damage <<= 1;
power = 6*FRACUNIT;
pufftype = PClass::FindClass ("HammerPuff");
}
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget != NULL)
{
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{
P_ThrustMobj (linetarget, angle, power);
}
AdjustPlayerAngle (pmo, linetarget);
goto punchdone;
}
}
}
// didn't find any creatures, so try to strike any walls
pmo->special1 = 0;
angle = pmo->angle;
slope = P_AimLineAttack (pmo, angle, MELEERANGE, &linetarget);
P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
punchdone:
if (pmo->special1 == 3)
{ {
pmo->special1 = 0; pmo->special1 = 0;
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire2")); P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire2"));
@ -138,4 +125,11 @@ punchdone:
} }
return; return;
} }
}
// didn't find any creatures, so try to strike any walls
pmo->special1 = 0;
AActor *linetarget;
int slope = P_AimLineAttack (pmo, pmo->angle, MELEERANGE, &linetarget);
P_LineAttack (pmo, pmo->angle, MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass("PunchPuff"), true);
}