- fixed: All melee attack functions only used the target acquired by P_AimLineAttack for all subsequent calculations, not the actual victim of the attack.

SVN r2373 (trunk)
This commit is contained in:
Christoph Oelckers 2010-06-13 11:14:01 +00:00
parent f73fe072f6
commit e535b40a9e
14 changed files with 39 additions and 25 deletions

View file

@ -52,7 +52,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
angle += pr_punch.Random2() << 18; angle += pr_punch.Random2() << 18;
pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true);
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &linetarget);
// turn to face target // turn to face target
if (linetarget) if (linetarget)

View file

@ -264,7 +264,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
P_LineAttack (self, angle, MELEERANGE+1, P_LineAttack (self, angle, MELEERANGE+1,
P_AimLineAttack (self, angle, MELEERANGE+1, &linetarget), damage, P_AimLineAttack (self, angle, MELEERANGE+1, &linetarget), damage,
NAME_Melee, pufftype); NAME_Melee, pufftype, false, &linetarget);
if (!linetarget) if (!linetarget)
{ {
@ -318,7 +318,7 @@ static void MarinePunch(AActor *self, int damagemul)
A_FaceTarget (self); A_FaceTarget (self);
angle = self->angle + (pr_m_punch.Random2() << 18); angle = self->angle + (pr_m_punch.Random2() << 18);
pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &linetarget);
// turn to face target // turn to face target
if (linetarget) if (linetarget)

View file

@ -175,7 +175,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
damage = 1 + (pr_beakatkpl1()&3); damage = 1 + (pr_beakatkpl1()&3);
angle = player->mo->angle; angle = player->mo->angle;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
if (linetarget) if (linetarget)
{ {
player->mo->angle = R_PointToAngle2 (player->mo->x, player->mo->angle = R_PointToAngle2 (player->mo->x,
@ -208,7 +208,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
damage = pr_beakatkpl2.HitDice (4); damage = pr_beakatkpl2.HitDice (4);
angle = player->mo->angle; angle = player->mo->angle;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
if (linetarget) if (linetarget)
{ {
player->mo->angle = R_PointToAngle2 (player->mo->x, player->mo->angle = R_PointToAngle2 (player->mo->x,

View file

@ -85,7 +85,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
angle = self->angle; angle = self->angle;
angle += pr_sap.Random2() << 18; angle += pr_sap.Random2() << 18;
slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); slope = P_AimLineAttack (self, angle, MELEERANGE, &linetarget);
P_LineAttack (self, angle, MELEERANGE, slope, damage, NAME_Melee, puff, true); P_LineAttack (self, angle, MELEERANGE, slope, damage, NAME_Melee, puff, true, &linetarget);
if (linetarget) if (linetarget)
{ {
//S_StartSound(player->mo, sfx_stfhit); //S_StartSound(player->mo, sfx_stfhit);
@ -273,7 +273,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
pufftype = PClass::FindClass("GauntletPuff1"); pufftype = PClass::FindClass("GauntletPuff1");
} }
slope = P_AimLineAttack (self, angle, dist, &linetarget); slope = P_AimLineAttack (self, angle, dist, &linetarget);
P_LineAttack (self, angle, dist, slope, damage, NAME_Melee, pufftype); P_LineAttack (self, angle, dist, slope, damage, NAME_Melee, pufftype, false, &linetarget);
if (!linetarget) if (!linetarget)
{ {
if (pr_gatk() > 64) if (pr_gatk() > 64)

View file

@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget); slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget);
if (linetarget) if (linetarget)
{ {
P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true, &linetarget);
AdjustPlayerAngle (player->mo, linetarget); AdjustPlayerAngle (player->mo, linetarget);
// player->mo->angle = R_PointToAngle2(player->mo->x, // player->mo->angle = R_PointToAngle2(player->mo->x,
// player->mo->y, linetarget->x, linetarget->y); // player->mo->y, linetarget->x, linetarget->y);
@ -46,7 +46,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget); slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget);
if (linetarget) if (linetarget)
{ {
P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true, &linetarget);
AdjustPlayerAngle (player->mo, linetarget); AdjustPlayerAngle (player->mo, linetarget);
// player->mo->angle = R_PointToAngle2(player->mo->x, // player->mo->angle = R_PointToAngle2(player->mo->x,
// player->mo->y, linetarget->x, linetarget->y); // player->mo->y, linetarget->x, linetarget->y);

View file

@ -70,7 +70,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
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)
{ {
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, pmo->angle = R_PointToAngle2 (pmo->x, pmo->y,
linetarget->x, linetarget->y); linetarget->x, linetarget->y);
if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER) if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER)
@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D); slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff")); P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, pmo->angle = R_PointToAngle2 (pmo->x, pmo->y,
linetarget->x, linetarget->y); linetarget->x, linetarget->y);
if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER) if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)

View file

@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget); slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true); P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{ {
P_ThrustMobj (linetarget, angle, power); P_ThrustMobj (linetarget, angle, power);
@ -238,7 +238,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget); slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true); P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget->flags3&MF3_ISMONSTER) if (linetarget->flags3&MF3_ISMONSTER)
{ {
P_ThrustMobj (linetarget, angle, power); P_ThrustMobj (linetarget, angle, power);

View file

@ -49,7 +49,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
if (linetarget) if (linetarget)
{ {
P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true, &linetarget);
AdjustPlayerAngle(pmo, linetarget); AdjustPlayerAngle(pmo, linetarget);
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{ {
@ -62,7 +62,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D); slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
if(linetarget) if(linetarget)
{ {
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true); P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true, &linetarget);
AdjustPlayerAngle(pmo, linetarget); AdjustPlayerAngle(pmo, linetarget);
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{ {

View file

@ -165,7 +165,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
power = 6*FRACUNIT; power = 6*FRACUNIT;
pufftype = PClass::FindClass ("HammerPuff"); pufftype = PClass::FindClass ("HammerPuff");
} }
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true); P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{ {
P_ThrustMobj (linetarget, angle, power); P_ThrustMobj (linetarget, angle, power);
@ -184,7 +184,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
power = 6*FRACUNIT; power = 6*FRACUNIT;
pufftype = PClass::FindClass ("HammerPuff"); pufftype = PClass::FindClass ("HammerPuff");
} }
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true); P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
{ {
P_ThrustMobj (linetarget, angle, power); P_ThrustMobj (linetarget, angle, power);

View file

@ -75,7 +75,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack)
damage = 3+(pr_snoutattack()&3); damage = 3+(pr_snoutattack()&3);
angle = player->mo->angle; angle = player->mo->angle;
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, &linetarget); slope = P_AimLineAttack(player->mo, angle, MELEERANGE, &linetarget);
puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true); puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true, &linetarget);
S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM); S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM);
if(linetarget) if(linetarget)
{ {

View file

@ -110,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
angle = self->angle + (pr_jabdagger.Random2() << 18); angle = self->angle + (pr_jabdagger.Random2() << 18);
pitch = P_AimLineAttack (self, angle, 80*FRACUNIT, &linetarget); pitch = P_AimLineAttack (self, angle, 80*FRACUNIT, &linetarget);
P_LineAttack (self, angle, 80*FRACUNIT, pitch, damage, NAME_Melee, "StrifeSpark", true); P_LineAttack (self, angle, 80*FRACUNIT, pitch, damage, NAME_Melee, "StrifeSpark", true, &linetarget);
// turn to face target // turn to face target
if (linetarget) if (linetarget)

View file

@ -418,8 +418,8 @@ enum
ALF_CHECKCONVERSATION = 8, ALF_CHECKCONVERSATION = 8,
}; };
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false, AActor **victim = NULL);
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false); AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false, AActor **victim = NULL);
void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch);
void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch);
void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version

View file

@ -3297,7 +3297,7 @@ static bool CheckForSpectral (FTraceResults &res)
//========================================================================== //==========================================================================
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
int pitch, int damage, FName damageType, const PClass *pufftype, bool ismeleeattack) int pitch, int damage, FName damageType, const PClass *pufftype, bool ismeleeattack, AActor **victim)
{ {
fixed_t vx, vy, vz, shootz; fixed_t vx, vy, vz, shootz;
FTraceResults trace; FTraceResults trace;
@ -3308,6 +3308,11 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
AActor *puff = NULL; AActor *puff = NULL;
int flags = ismeleeattack? PF_MELEERANGE : 0; int flags = ismeleeattack? PF_MELEERANGE : 0;
if (victim != NULL)
{
*victim = NULL;
}
angle >>= ANGLETOFINESHIFT; angle >>= ANGLETOFINESHIFT;
pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT; pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT;
@ -3490,6 +3495,10 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
} }
P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, flags); P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, flags);
} }
if (victim != NULL)
{
*victim = trace.Actor;
}
} }
if (trace.CrossedWater) if (trace.CrossedWater)
{ {
@ -3511,16 +3520,20 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
} }
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
int pitch, int damage, FName damageType, FName pufftype, bool ismeleeattack) int pitch, int damage, FName damageType, FName pufftype, bool ismeleeattack, AActor **victim)
{ {
const PClass * type = PClass::FindClass(pufftype); const PClass * type = PClass::FindClass(pufftype);
if (victim != NULL)
{
*victim = NULL;
}
if (type == NULL) if (type == NULL)
{ {
Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars()); Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars());
} }
else else
{ {
return P_LineAttack(t1, angle, distance, pitch, damage, damageType, type, ismeleeattack); return P_LineAttack(t1, angle, distance, pitch, damage, damageType, type, ismeleeattack, victim);
} }
return NULL; return NULL;
} }

View file

@ -1167,7 +1167,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
P_LineAttack (self, angle, Range, pitch, Damage, NAME_None, PuffType, true); P_LineAttack (self, angle, Range, pitch, Damage, NAME_None, PuffType, true, &linetarget);
// turn to face target // turn to face target
if (linetarget) if (linetarget)