From e535b40a9e1f8415d3fdf3ecebe81c859817fe66 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Jun 2010 11:14:01 +0000 Subject: [PATCH] - 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) --- src/g_doom/a_doomweaps.cpp | 3 ++- src/g_doom/a_scriptedmarine.cpp | 4 ++-- src/g_heretic/a_chicken.cpp | 4 ++-- src/g_heretic/a_hereticweaps.cpp | 4 ++-- src/g_hexen/a_clericmace.cpp | 4 ++-- src/g_hexen/a_clericstaff.cpp | 4 ++-- src/g_hexen/a_fighteraxe.cpp | 4 ++-- src/g_hexen/a_fighterhammer.cpp | 4 ++-- src/g_hexen/a_fighterplayer.cpp | 4 ++-- src/g_hexen/a_pig.cpp | 2 +- src/g_strife/a_strifeweapons.cpp | 2 +- src/p_local.h | 4 ++-- src/p_map.cpp | 19 ++++++++++++++++--- src/thingdef/thingdef_codeptr.cpp | 2 +- 14 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 026da4c5e2..7cd53b49c2 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -52,7 +52,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) angle += pr_punch.Random2() << 18; 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 if (linetarget) diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 150b7eb795..a6dd7f7b92 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -264,7 +264,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) P_LineAttack (self, angle, MELEERANGE+1, P_AimLineAttack (self, angle, MELEERANGE+1, &linetarget), damage, - NAME_Melee, pufftype); + NAME_Melee, pufftype, false, &linetarget); if (!linetarget) { @@ -318,7 +318,7 @@ static void MarinePunch(AActor *self, int damagemul) A_FaceTarget (self); angle = self->angle + (pr_m_punch.Random2() << 18); 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 if (linetarget) diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 86e71774fa..a8b8c98d33 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -175,7 +175,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) damage = 1 + (pr_beakatkpl1()&3); angle = player->mo->angle; 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) { player->mo->angle = R_PointToAngle2 (player->mo->x, @@ -208,7 +208,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2) damage = pr_beakatkpl2.HitDice (4); angle = player->mo->angle; 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) { player->mo->angle = R_PointToAngle2 (player->mo->x, diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index f17e725452..ad01150899 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -85,7 +85,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) angle = self->angle; angle += pr_sap.Random2() << 18; 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) { //S_StartSound(player->mo, sfx_stfhit); @@ -273,7 +273,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) pufftype = PClass::FindClass("GauntletPuff1"); } 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 (pr_gatk() > 64) diff --git a/src/g_hexen/a_clericmace.cpp b/src/g_hexen/a_clericmace.cpp index d834dcd1be..9cb512286c 100644 --- a/src/g_hexen/a_clericmace.cpp +++ b/src/g_hexen/a_clericmace.cpp @@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &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); // player->mo->angle = R_PointToAngle2(player->mo->x, // 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); 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); // player->mo->angle = R_PointToAngle2(player->mo->x, // player->mo->y, linetarget->x, linetarget->y); diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 03b8c75184..8dc8c09162 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -70,7 +70,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) slope = P_AimLineAttack (pmo, 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, 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, linetarget->x, linetarget->y); 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); 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, linetarget->x, linetarget->y); if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER) diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index 281d20c2c2..7dd5ac06e8 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) slope = P_AimLineAttack (pmo, angle, AXERANGE, &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) { P_ThrustMobj (linetarget, angle, power); @@ -238,7 +238,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) slope = P_AimLineAttack (pmo, angle, AXERANGE, &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) { P_ThrustMobj (linetarget, angle, power); diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index 2c457c0357..ddfab12d46 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -49,7 +49,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D); 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); 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); 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); if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) { diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index ba1bc9e821..078a063e03 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -165,7 +165,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) power = 6*FRACUNIT; 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) { P_ThrustMobj (linetarget, angle, power); @@ -184,7 +184,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) power = 6*FRACUNIT; 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) { P_ThrustMobj (linetarget, angle, power); diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 21d2ab9369..437a336a38 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -75,7 +75,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) damage = 3+(pr_snoutattack()&3); angle = player->mo->angle; 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); if(linetarget) { diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 97526bf67a..bf5cb124eb 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -110,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) angle = self->angle + (pr_jabdagger.Random2() << 18); 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 if (linetarget) diff --git a/src/p_local.h b/src/p_local.h index fc9068cd0a..2092f8f4f8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -418,8 +418,8 @@ enum 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, FName 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 **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, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version diff --git a/src/p_map.cpp b/src/p_map.cpp index 4888f84795..40344db830 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3297,7 +3297,7 @@ static bool CheckForSpectral (FTraceResults &res) //========================================================================== 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; FTraceResults trace; @@ -3308,6 +3308,11 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor *puff = NULL; int flags = ismeleeattack? PF_MELEERANGE : 0; + if (victim != NULL) + { + *victim = NULL; + } + angle >>= 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); } + if (victim != NULL) + { + *victim = trace.Actor; + } } 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, - 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); + if (victim != NULL) + { + *victim = NULL; + } if (type == NULL) { Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars()); } 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; } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index c76c5842d9..a4977eaa6c 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1167,7 +1167,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) 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 if (linetarget)