mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- consolidated some nearly identical code repetitions in Hexen's attack functions.
This commit is contained in:
parent
c390b98966
commit
4bb0ca5889
3 changed files with 45 additions and 88 deletions
|
@ -36,27 +36,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
|
||||||
damage = 25+(pr_maceatk()&15);
|
damage = 25+(pr_maceatk()&15);
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
angle = player->mo->angle+i*(ANG45/16);
|
for (int j = 1; j >= -1; j -= 2)
|
||||||
slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget);
|
{
|
||||||
|
angle = player->mo->angle + j*i*(ANG45 / 16);
|
||||||
|
slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, &linetarget);
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, hammertime, true, &linetarget);
|
P_LineAttack(player->mo, angle, 2 * MELEERANGE, slope, damage, NAME_Melee, hammertime, true, &linetarget);
|
||||||
if (linetarget != NULL)
|
if (linetarget != NULL)
|
||||||
{
|
{
|
||||||
AdjustPlayerAngle (player->mo, linetarget);
|
AdjustPlayerAngle(player->mo, linetarget);
|
||||||
goto macedone;
|
goto macedone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
angle = player->mo->angle-i*(ANG45/16);
|
|
||||||
slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget);
|
|
||||||
if (linetarget)
|
|
||||||
{
|
|
||||||
P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, hammertime, true, &linetarget);
|
|
||||||
if (linetarget != NULL)
|
|
||||||
{
|
|
||||||
AdjustPlayerAngle (player->mo, linetarget);
|
|
||||||
goto macedone;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// didn't find any creatures, so try to strike any walls
|
// didn't find any creatures, so try to strike any walls
|
||||||
|
|
|
@ -70,7 +70,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
||||||
puff = PClass::FindActor("CStaffPuff");
|
puff = PClass::FindActor("CStaffPuff");
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
angle = pmo->angle + i*(ANG45 / 16);
|
for (int j = 1; j >= -1; j -= 2)
|
||||||
|
{
|
||||||
|
angle = pmo->angle + j*i*(ANG45 / 16);
|
||||||
slope = P_AimLineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
|
slope = P_AimLineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
|
@ -98,32 +100,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
||||||
weapon->DepleteAmmo(weapon->bAltFire, false);
|
weapon->DepleteAmmo(weapon->bAltFire, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
angle = pmo->angle - i*(ANG45 / 16);
|
|
||||||
slope = P_AimLineAttack(player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
|
|
||||||
if (linetarget)
|
|
||||||
{
|
|
||||||
P_LineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, puff, false, &linetarget);
|
|
||||||
if (linetarget != NULL)
|
|
||||||
{
|
|
||||||
pmo->angle = pmo->AngleTo(linetarget);
|
|
||||||
if ((linetarget->player && (!linetarget->IsTeammate(pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
|
|
||||||
{
|
|
||||||
newLife = player->health + (damage >> 4);
|
|
||||||
newLife = newLife > max ? max : newLife;
|
|
||||||
if (newLife > player->health)
|
|
||||||
{
|
|
||||||
pmo->health = player->health = newLife;
|
|
||||||
}
|
|
||||||
P_SetPsprite(player, ps_weapon, weapon->FindState("Drain"));
|
|
||||||
}
|
|
||||||
if (weapon != NULL)
|
|
||||||
{
|
|
||||||
weapon->DepleteAmmo(weapon->bAltFire, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -236,37 +236,24 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
|
||||||
}
|
}
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
angle = pmo->angle+i*(ANG45/16);
|
for (int j = 1; j >= -1; j -= 2)
|
||||||
slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget);
|
{
|
||||||
|
angle = pmo->angle + j*i*(ANG45 / 16);
|
||||||
|
slope = P_AimLineAttack(pmo, angle, AXERANGE, &linetarget);
|
||||||
if (linetarget)
|
if (linetarget)
|
||||||
{
|
{
|
||||||
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
|
P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
|
||||||
if (linetarget != NULL)
|
if (linetarget != NULL)
|
||||||
{
|
{
|
||||||
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
||||||
{
|
{
|
||||||
P_ThrustMobj (linetarget, angle, power);
|
P_ThrustMobj(linetarget, angle, power);
|
||||||
}
|
}
|
||||||
AdjustPlayerAngle (pmo, linetarget);
|
AdjustPlayerAngle(pmo, linetarget);
|
||||||
useMana++;
|
useMana++;
|
||||||
goto axedone;
|
goto axedone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
angle = pmo->angle-i*(ANG45/16);
|
|
||||||
slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget);
|
|
||||||
if (linetarget)
|
|
||||||
{
|
|
||||||
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
|
|
||||||
if (linetarget != NULL)
|
|
||||||
{
|
|
||||||
if (linetarget->flags3&MF3_ISMONSTER)
|
|
||||||
{
|
|
||||||
P_ThrustMobj (linetarget, angle, power);
|
|
||||||
}
|
|
||||||
AdjustPlayerAngle (pmo, linetarget);
|
|
||||||
useMana++;
|
|
||||||
goto axedone;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// didn't find any creatures, so try to strike any walls
|
// didn't find any creatures, so try to strike any walls
|
||||||
|
|
Loading…
Reference in a new issue