diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4f60f59dd..37e70f28d 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +April 10, 2008 (Changes by Graf Zahl) +- Eliminated some more global variables (onmobj, DoRipping, LastRipped, + MissileActor, bulletpitch and linetarget.) + April 9, 2008 (Changes by Graf Zahl) - Replaced P_PathTraverse with an FPathTraverse class, rewrote all code using P_PathTraverse and got rid of a lot of global variables in the process. diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index d198022d5..80510ed43 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -748,8 +748,10 @@ CCMD (wdir) //----------------------------------------------------------------------------- CCMD(linetarget) { + AActor *linetarget; + if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; - P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, 0); + P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, &linetarget, 0); if (linetarget) { Printf("Target=%s, Health=%d, Spawnhealth=%d\n", diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 0d343eda0..70c0b465d 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -28,6 +28,7 @@ void A_Punch (AActor *actor) angle_t angle; int damage; int pitch; + AActor *linetarget; if (actor->player != NULL) { @@ -47,7 +48,7 @@ void A_Punch (AActor *actor) angle = actor->angle; angle += pr_punch.Random2() << 18; - pitch = P_AimLineAttack (actor, angle, MELEERANGE); + pitch = P_AimLineAttack (actor, angle, MELEERANGE, &linetarget); P_LineAttack (actor, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true); // turn to face target @@ -89,8 +90,7 @@ void A_FirePistol (AActor *actor) S_Sound (actor, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM); - P_BulletSlope (actor); - P_GunShot (actor, accurate, PClass::FindClass(NAME_BulletPuff)); + P_GunShot (actor, accurate, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (actor)); } // @@ -101,6 +101,7 @@ void A_Saw (AActor *actor) angle_t angle; int damage=0; player_t *player; + AActor *linetarget; int fullsound; int hitsound; @@ -140,7 +141,7 @@ void A_Saw (AActor *actor) // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states) P_LineAttack (actor, angle, MELEERANGE+1, - P_AimLineAttack (actor, angle, MELEERANGE+1), damage, + P_AimLineAttack (actor, angle, MELEERANGE+1, &linetarget), damage, GetDefaultByType(pufftype)->DamageType, pufftype); if (!linetarget) @@ -193,10 +194,10 @@ void A_FireShotgun (AActor *actor) } player->mo->PlayAttacking2 (); - P_BulletSlope (actor); + angle_t pitch = P_BulletSlope (actor); for (i=0 ; i<7 ; i++) - P_GunShot (actor, false, PClass::FindClass(NAME_BulletPuff)); + P_GunShot (actor, false, PClass::FindClass(NAME_BulletPuff), pitch); } // @@ -225,7 +226,7 @@ void A_FireShotgun2 (AActor *actor) player->mo->PlayAttacking2 (); - P_BulletSlope (actor); + angle_t pitch = P_BulletSlope (actor); for (i=0 ; i<20 ; i++) { @@ -242,7 +243,7 @@ void A_FireShotgun2 (AActor *actor) P_LineAttack (actor, angle, PLAYERMISSILERANGE, - bulletpitch + (pr_fireshotgun2.Random2() * 332063), damage, + pitch + (pr_fireshotgun2.Random2() * 332063), damage, NAME_None, NAME_BulletPuff); } } @@ -347,8 +348,7 @@ void A_FireCGun (AActor *actor) } player->mo->PlayAttacking2 (); - P_BulletSlope (actor); - P_GunShot (actor, !player->refire, PClass::FindClass(NAME_BulletPuff)); + P_GunShot (actor, !player->refire, PClass::FindClass(NAME_BulletPuff), P_BulletSlope (actor)); } // @@ -496,6 +496,7 @@ void A_BFGSpray (AActor *mo) const PClass *spraytype = NULL; int numrays = 40; int damagecnt = 15; + AActor *linetarget; int index = CheckIndex (3, NULL); if (index >= 0) @@ -523,7 +524,7 @@ void A_BFGSpray (AActor *mo) an = mo->angle - ANG90/2 + ANG90/numrays*i; // mo->target is the originator (player) of the missile - P_AimLineAttack (mo->target, an, 16*64*FRACUNIT, ANGLE_1*32); + P_AimLineAttack (mo->target, an, 16*64*FRACUNIT, &linetarget, ANGLE_1*32); if (!linetarget) continue; diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 2126285b4..c8c281e24 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -397,12 +397,13 @@ void A_M_Saw (AActor *self) { angle_t angle; int damage; + AActor *linetarget; damage = 2 * (pr_m_saw()%10+1); angle = self->angle + (pr_m_saw.Random2() << 18); P_LineAttack (self, angle, MELEERANGE+1, - P_AimLineAttack (self, angle, MELEERANGE+1), damage, + P_AimLineAttack (self, angle, MELEERANGE+1, &linetarget), damage, NAME_Melee, NAME_BulletPuff); if (!linetarget) @@ -447,6 +448,7 @@ void A_M_Punch (AActor *self) angle_t angle; int damage; int pitch; + AActor *linetarget; if (self->target == NULL) return; @@ -455,7 +457,7 @@ void A_M_Punch (AActor *self) A_FaceTarget (self); angle = self->angle + (pr_m_punch.Random2() << 18); - pitch = P_AimLineAttack (self, angle, MELEERANGE); + pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true); // turn to face target @@ -477,6 +479,7 @@ void A_M_BerserkPunch (AActor *self) angle_t angle; int damage; int pitch; + AActor *linetarget; if (self->target == NULL) return; @@ -485,7 +488,7 @@ void A_M_BerserkPunch (AActor *self) A_FaceTarget (self); angle = self->angle + (pr_m_punch.Random2() << 18); - pitch = P_AimLineAttack (self, angle, MELEERANGE); + pitch = P_AimLineAttack (self, angle, MELEERANGE, &linetarget); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true); // turn to face target diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 46243b6da..475b19e98 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -403,6 +403,7 @@ void A_BeakAttackPL1 (AActor *actor) int damage; int slope; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -411,7 +412,7 @@ void A_BeakAttackPL1 (AActor *actor) damage = 1 + (pr_beakatkpl1()&3); angle = player->mo->angle; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(ABeakPuff), true); if (linetarget) { @@ -435,6 +436,7 @@ void A_BeakAttackPL2 (AActor *actor) int damage; int slope; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -443,7 +445,7 @@ void A_BeakAttackPL2 (AActor *actor) damage = pr_beakatkpl2.HitDice (4); angle = player->mo->angle; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(ABeakPuff), true); if (linetarget) { diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index b6113dd6d..6f7e779b0 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -201,6 +201,7 @@ void A_StaffAttackPL1 (AActor *actor) int damage; int slope; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -216,7 +217,7 @@ void A_StaffAttackPL1 (AActor *actor) damage = 5+(pr_sap()&15); angle = player->mo->angle; angle += pr_sap.Random2() << 18; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AStaffPuff), true); if (linetarget) { @@ -239,6 +240,7 @@ void A_StaffAttackPL2 (AActor *actor) int damage; int slope; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -255,7 +257,7 @@ void A_StaffAttackPL2 (AActor *actor) damage = 18+(pr_sap2()&63); angle = player->mo->angle; angle += pr_sap2.Random2() << 18; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AStaffPuff2), true); if (linetarget) { @@ -447,14 +449,14 @@ void A_FireGoldWandPL1 (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - P_BulletSlope(mo); + angle_t pitch = P_BulletSlope(mo); damage = 7+(pr_fgw()&7); angle = mo->angle; if (player->refire) { angle += pr_fgw.Random2() << 18; } - P_LineAttack (mo, angle, PLAYERMISSILERANGE, bulletpitch, damage, NAME_None, RUNTIME_CLASS(AGoldWandPuff1)); + P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, RUNTIME_CLASS(AGoldWandPuff1)); S_Sound (player->mo, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); } @@ -485,16 +487,16 @@ void A_FireGoldWandPL2 (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - P_BulletSlope (mo); + angle_t pitch = P_BulletSlope(mo); momz = FixedMul (GetDefault()->Speed, - finetangent[FINEANGLES/4-((signed)bulletpitch>>ANGLETOFINESHIFT)]); + finetangent[FINEANGLES/4-((signed)pitch>>ANGLETOFINESHIFT)]); P_SpawnMissileAngle (mo, RUNTIME_CLASS(AGoldWandFX2), mo->angle-(ANG45/8), momz); P_SpawnMissileAngle (mo, RUNTIME_CLASS(AGoldWandFX2), mo->angle+(ANG45/8), momz); angle = mo->angle-(ANG45/8); for(i = 0; i < 5; i++) { damage = 1+(pr_fgw2()&7); - P_LineAttack (mo, angle, PLAYERMISSILERANGE, bulletpitch, damage, NAME_None, RUNTIME_CLASS(AGoldWandPuff2)); + P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, RUNTIME_CLASS(AGoldWandPuff2)); angle += ((ANG45/8)*2)/4; } S_Sound (player->mo, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); @@ -1339,6 +1341,7 @@ void A_FireMacePL2 (AActor *actor) { AActor *mo; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -1351,7 +1354,7 @@ void A_FireMacePL2 (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - mo = P_SpawnPlayerMissile (player->mo, RUNTIME_CLASS(AMaceFX4)); + mo = P_SpawnPlayerMissile (player->mo, 0,0,0, RUNTIME_CLASS(AMaceFX4), 0, &linetarget); if (mo) { mo->momx += player->mo->momx; @@ -1378,6 +1381,7 @@ void A_DeathBallImpact (AActor *ball) AActor *target; angle_t angle = 0; bool newAngle; + AActor *linetarget; if ((ball->z <= ball->floorz) && P_HitFloor (ball)) { // Landed in some sort of liquid @@ -1424,7 +1428,7 @@ void A_DeathBallImpact (AActor *ball) angle = 0; for (i = 0; i < 16; i++) { - P_AimLineAttack (ball, angle, 10*64*FRACUNIT); + P_AimLineAttack (ball, angle, 10*64*FRACUNIT, &linetarget); if (linetarget && ball->target != linetarget) { ball->tracer = linetarget; @@ -1624,6 +1628,7 @@ void A_GauntletAttack (AActor *actor) player_t *player; const PClass *pufftype; AInventory *power; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -1654,7 +1659,7 @@ void A_GauntletAttack (AActor *actor) angle += pr_gatk.Random2() << 18; pufftype = RUNTIME_CLASS(AGauntletPuff1); } - slope = P_AimLineAttack (player->mo, angle, dist); + slope = P_AimLineAttack (player->mo, angle, dist, &linetarget); P_LineAttack (player->mo, angle, dist, slope, damage, NAME_Melee, pufftype); if (!linetarget) { @@ -1973,14 +1978,14 @@ void A_FireBlasterPL1 (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - P_BulletSlope(actor); + angle_t pitch = P_BulletSlope(actor); damage = pr_fb1.HitDice (4); angle = actor->angle; if (player->refire) { angle += pr_fb1.Random2() << 18; } - P_LineAttack (actor, angle, PLAYERMISSILERANGE, bulletpitch, damage, NAME_None, RUNTIME_CLASS(ABlasterPuff)); + P_LineAttack (actor, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, RUNTIME_CLASS(ABlasterPuff)); S_Sound (actor, CHAN_WEAPON, "weapons/blastershoot", 1, ATTN_NORM); } @@ -2392,6 +2397,8 @@ void A_FireSkullRodPL1 (AActor *actor) void A_FireSkullRodPL2 (AActor *actor) { player_t *player; + AActor *MissileActor; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -2403,7 +2410,7 @@ void A_FireSkullRodPL2 (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - P_SpawnPlayerMissile (player->mo, RUNTIME_CLASS(AHornRodFX2)); + P_SpawnPlayerMissile (player->mo, 0,0,0, RUNTIME_CLASS(AHornRodFX2), 0, &linetarget, &MissileActor); // Use MissileActor instead of the return value from // P_SpawnPlayerMissile because we need to give info to the mobj // even if it exploded immediately. diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 177bbde2d..838f7d6d3 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -559,6 +559,7 @@ void SpawnSpiritTail (AActor *spirit) void A_CHolyAttack (AActor *actor) { player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -570,7 +571,7 @@ void A_CHolyAttack (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - AActor * missile = P_SpawnPlayerMissile (actor, RUNTIME_CLASS(AHolyMissile)); + AActor * missile = P_SpawnPlayerMissile (actor, 0,0,0, RUNTIME_CLASS(AHolyMissile), 0, &linetarget); if (missile != NULL) missile->tracer = linetarget; weapon->CHolyCount = 3; diff --git a/src/g_hexen/a_clericmace.cpp b/src/g_hexen/a_clericmace.cpp index 8fe893135..ce19eebb2 100644 --- a/src/g_hexen/a_clericmace.cpp +++ b/src/g_hexen/a_clericmace.cpp @@ -11,7 +11,7 @@ #include "gstrings.h" #include "a_hexenglobal.h" -extern void AdjustPlayerAngle (AActor *pmo); +extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget); static FRandom pr_atk ("CMaceAttack"); @@ -81,6 +81,7 @@ void A_CMaceAttack (AActor *actor) int slope; int i; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -91,21 +92,21 @@ void A_CMaceAttack (AActor *actor) for (i = 0; i < 16; i++) { angle = player->mo->angle+i*(ANG45/16); - slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget); if (linetarget) { P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff), true); - AdjustPlayerAngle (player->mo); + AdjustPlayerAngle (player->mo, linetarget); // player->mo->angle = R_PointToAngle2(player->mo->x, // player->mo->y, linetarget->x, linetarget->y); goto macedone; } angle = player->mo->angle-i*(ANG45/16); - slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, 2*MELEERANGE, &linetarget); if (linetarget) { P_LineAttack (player->mo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff), true); - AdjustPlayerAngle (player->mo); + AdjustPlayerAngle (player->mo, linetarget); // player->mo->angle = R_PointToAngle2(player->mo->x, // player->mo->y, linetarget->x, linetarget->y); goto macedone; @@ -115,7 +116,7 @@ void A_CMaceAttack (AActor *actor) player->mo->special1 = 0; angle = player->mo->angle; - slope = P_AimLineAttack (player->mo, angle, MELEERANGE); + slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff)); macedone: return; diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index fa052aa06..e00127d2f 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -188,6 +188,7 @@ void A_CStaffCheck (AActor *actor) int slope; int i; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -200,7 +201,7 @@ void A_CStaffCheck (AActor *actor) for (i = 0; i < 3; i++) { angle = pmo->angle+i*(ANG45/16); - slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE)); + slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget); if (linetarget) { P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, RUNTIME_CLASS(ACStaffPuff)); @@ -224,7 +225,7 @@ void A_CStaffCheck (AActor *actor) break; } angle = pmo->angle-i*(ANG45/16); - slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE)); + slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget); if (linetarget) { P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, RUNTIME_CLASS(ACStaffPuff)); diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index b2aec98ed..26ab1a013 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -23,7 +23,7 @@ void A_FAxeCheckReadyG (AActor *actor); void A_FAxeCheckUpG (AActor *actor); void A_FAxeAttack (AActor *actor); -extern void AdjustPlayerAngle (AActor *pmo); +extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget); EXTERN_CVAR (Int, cl_bloodtype) @@ -323,6 +323,7 @@ void A_FAxeAttack (AActor *actor) player_t *player; AWeapon *weapon; const PClass *pufftype; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -349,7 +350,7 @@ void A_FAxeAttack (AActor *actor) for (i = 0; i < 16; i++) { angle = pmo->angle+i*(ANG45/16); - slope = P_AimLineAttack (pmo, angle, AXERANGE); + slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget); if (linetarget) { P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true); @@ -357,12 +358,12 @@ void A_FAxeAttack (AActor *actor) { P_ThrustMobj (linetarget, angle, power); } - AdjustPlayerAngle (pmo); + AdjustPlayerAngle (pmo, linetarget); useMana++; goto axedone; } angle = pmo->angle-i*(ANG45/16); - slope = P_AimLineAttack (pmo, angle, AXERANGE); + slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget); if (linetarget) { P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true); @@ -370,7 +371,7 @@ void A_FAxeAttack (AActor *actor) { P_ThrustMobj (linetarget, angle, power); } - AdjustPlayerAngle (pmo); + AdjustPlayerAngle (pmo, linetarget); useMana++; goto axedone; } @@ -379,7 +380,7 @@ void A_FAxeAttack (AActor *actor) pmo->special1 = 0; angle = pmo->angle; - slope = P_AimLineAttack (pmo, angle, MELEERANGE); + slope = P_AimLineAttack (pmo, angle, MELEERANGE, &linetarget); P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true); axedone: diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index 5b8b4583d..fc3bce68a 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -15,7 +15,7 @@ const fixed_t HAMMER_RANGE = MELEERANGE+MELEERANGE/2; static FRandom pr_atk ("FHammerAtk"); -extern void AdjustPlayerAngle (AActor *pmo); +extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget); void A_FHammerAttack (AActor *actor); void A_FHammerThrow (AActor *actor); @@ -179,6 +179,7 @@ void A_FHammerAttack (AActor *actor) int slope; int i; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -191,11 +192,11 @@ void A_FHammerAttack (AActor *actor) for (i = 0; i < 16; i++) { angle = pmo->angle + i*(ANG45/32); - slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE); + slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget); if (linetarget) { P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff), true); - AdjustPlayerAngle(pmo); + AdjustPlayerAngle(pmo, linetarget); if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) { P_ThrustMobj (linetarget, angle, power); @@ -204,11 +205,11 @@ void A_FHammerAttack (AActor *actor) goto hammerdone; } angle = pmo->angle-i*(ANG45/32); - slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE); + slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget); if(linetarget) { P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff), true); - AdjustPlayerAngle(pmo); + AdjustPlayerAngle(pmo, linetarget); if (linetarget->flags3&MF3_ISMONSTER || linetarget->player) { P_ThrustMobj(linetarget, angle, power); @@ -219,7 +220,7 @@ void A_FHammerAttack (AActor *actor) } // didn't find any targets in meleerange, so set to throw out a hammer angle = pmo->angle; - slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE); + slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget); if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(AHammerPuff), true) != NULL) { pmo->special1 = false; diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index 8a2e07b6f..b9334985e 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -109,7 +109,7 @@ static FRandom pr_fpatk ("FPunchAttack"); #define MAX_ANGLE_ADJUST (5*ANGLE_1) -void AdjustPlayerAngle (AActor *pmo) +void AdjustPlayerAngle (AActor *pmo, AActor *linetarget) { angle_t angle; int difference; @@ -235,6 +235,7 @@ void A_FPunchAttack (AActor *actor) int i; player_t *player; const PClass *pufftype; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -248,7 +249,7 @@ void A_FPunchAttack (AActor *actor) for (i = 0; i < 16; i++) { angle = pmo->angle + i*(ANG45/16); - slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE); + slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget); if (linetarget) { pmo->special1++; @@ -263,11 +264,11 @@ void A_FPunchAttack (AActor *actor) { P_ThrustMobj (linetarget, angle, power); } - AdjustPlayerAngle (pmo); + AdjustPlayerAngle (pmo, linetarget); goto punchdone; } angle = pmo->angle-i * (ANG45/16); - slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE); + slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget); if (linetarget) { pmo->special1++; @@ -282,7 +283,7 @@ void A_FPunchAttack (AActor *actor) { P_ThrustMobj (linetarget, angle, power); } - AdjustPlayerAngle (pmo); + AdjustPlayerAngle (pmo, linetarget); goto punchdone; } } @@ -290,7 +291,7 @@ void A_FPunchAttack (AActor *actor) pmo->special1 = 0; angle = pmo->angle; - slope = P_AimLineAttack (pmo, angle, MELEERANGE); + slope = P_AimLineAttack (pmo, angle, MELEERANGE, &linetarget); P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true); punchdone: diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 847edfd4c..5a59d5e12 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -159,6 +159,7 @@ void A_FireConePL1 (AActor *actor) AActor *mo; bool conedone=false; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -177,7 +178,7 @@ void A_FireConePL1 (AActor *actor) for (i = 0; i < 16; i++) { angle = actor->angle+i*(ANG45/16); - slope = P_AimLineAttack (actor, angle, MELEERANGE); + slope = P_AimLineAttack (actor, angle, MELEERANGE, &linetarget); if (linetarget) { P_DamageMobj (linetarget, actor, actor, damage, NAME_Ice); diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index 21c0dfe0d..eb0dede3c 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -387,9 +387,10 @@ void A_MStaffAttack2 (AActor *actor) void MStaffSpawn (AActor *pmo, angle_t angle) { AActor *mo; + AActor *linetarget; mo = P_SpawnPlayerMissile (pmo, 0, 0, 8*FRACUNIT, - RUNTIME_CLASS(AMageStaffFX2), angle); + RUNTIME_CLASS(AMageStaffFX2), angle, &linetarget); if (mo) { mo->target = pmo; @@ -407,6 +408,7 @@ void A_MStaffAttack (AActor *actor) { angle_t angle; player_t *player; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -422,7 +424,7 @@ void A_MStaffAttack (AActor *actor) angle = actor->angle; // [RH] Let's try and actually track what the player aimed at - P_AimLineAttack (actor, angle, PLAYERMISSILERANGE, ANGLE_1*32); + P_AimLineAttack (actor, angle, PLAYERMISSILERANGE, &linetarget, ANGLE_1*32); if (linetarget == NULL) { BlockCheckLine.x = actor->x; diff --git a/src/g_hexen/a_magewand.cpp b/src/g_hexen/a_magewand.cpp index af9ede1e8..b9794ca46 100644 --- a/src/g_hexen/a_magewand.cpp +++ b/src/g_hexen/a_magewand.cpp @@ -124,7 +124,7 @@ void AMageWandMissile::Tick () PrevZ = z; // [RH] Ripping is a little different than it was in Hexen - DoRipping = true; + FCheckPosition tm(!!(flags2 & MF2_RIP)); // Handle movement if (momx || momy || (z != floorz) || momz) @@ -137,11 +137,10 @@ void AMageWandMissile::Tick () { if (changexy) { - LastRipped = NULL; // [RH] Do rip damage each step, like Hexen - if (!P_TryMove (this, x+xfrac,y+yfrac, true)) + tm.LastRipped = NULL; // [RH] Do rip damage each step, like Hexen + if (!P_TryMove (this, x+xfrac,y+yfrac, true, false, tm)) { // Blocked move P_ExplodeMissile (this, BlockingLine, BlockingMobj); - DoRipping = false; return; } } @@ -151,14 +150,12 @@ void AMageWandMissile::Tick () z = floorz; P_HitFloor (this); P_ExplodeMissile (this, NULL, NULL); - DoRipping = false; return; } if (z+height > ceilingz) { // Hit the ceiling z = ceilingz-height; P_ExplodeMissile (this, NULL, NULL); - DoRipping = false; return; } if (changexy) @@ -175,7 +172,7 @@ void AMageWandMissile::Tick () } } } - DoRipping = false; + // Advance the state if (tics != -1) { diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 3b0378e7e..84b399b21 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -16,7 +16,7 @@ static FRandom pr_snoutattack ("SnoutAttack"); static FRandom pr_pigattack ("PigAttack"); static FRandom pr_pigplayerthink ("PigPlayerThink"); -extern void AdjustPlayerAngle (AActor *); +extern void AdjustPlayerAngle (AActor *, AActor *); void A_SnoutAttack (AActor *actor); @@ -260,6 +260,7 @@ void A_SnoutAttack (AActor *actor) int slope; player_t *player; AActor *puff; + AActor *linetarget; if (NULL == (player = actor->player)) { @@ -268,12 +269,12 @@ void A_SnoutAttack (AActor *actor) damage = 3+(pr_snoutattack()&3); angle = player->mo->angle; - slope = P_AimLineAttack(player->mo, angle, MELEERANGE); + slope = P_AimLineAttack(player->mo, angle, MELEERANGE, &linetarget); puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(ASnoutPuff), true); S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM); if(linetarget) { - AdjustPlayerAngle(player->mo); + AdjustPlayerAngle(player->mo, linetarget); if(puff != NULL) { // Bit something S_Sound(player->mo, CHAN_VOICE, "PigAttack", 1, ATTN_NORM); diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 0198a6c2c..732eeba1c 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -199,6 +199,7 @@ void A_JabDagger (AActor *actor) int damage; int pitch; int power; + AActor *linetarget; power = MIN(10, actor->player->stamina / 10); damage = (pr_jabdagger() % (power + 8)) * (power + 2); @@ -209,7 +210,7 @@ void A_JabDagger (AActor *actor) } angle = actor->angle + (pr_jabdagger.Random2() << 18); - pitch = P_AimLineAttack (actor, angle, 80*FRACUNIT); + pitch = P_AimLineAttack (actor, angle, 80*FRACUNIT, &linetarget); P_LineAttack (actor, angle, 80*FRACUNIT, pitch, damage, NAME_Melee, RUNTIME_CLASS(AStrifeSpark), true); // turn to face target @@ -675,7 +676,7 @@ bool AAssaultGun::HandlePickup (AInventory *item) // //============================================================================ -void P_StrifeGunShot (AActor *mo, bool accurate) +void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch) { angle_t angle; int damage; @@ -688,7 +689,7 @@ void P_StrifeGunShot (AActor *mo, bool accurate) angle += pr_sgunshot.Random2() << (20 - mo->player->accuracy * 5 / 100); } - P_LineAttack (mo, angle, PLAYERMISSILERANGE, bulletpitch, damage, NAME_None, RUNTIME_CLASS(AStrifePuff)); + P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, RUNTIME_CLASS(AStrifePuff)); } //============================================================================ @@ -719,8 +720,7 @@ void A_FireAssaultGun (AActor *self) accurate = true; } - P_BulletSlope (self); - P_StrifeGunShot (self, accurate); + P_StrifeGunShot (self, accurate, P_BulletSlope (self)); } // Standing variant of the assault gun -------------------------------------- @@ -1303,13 +1303,13 @@ void A_FireMauler1 (AActor *self) S_Sound (self, CHAN_WEAPON, "weapons/mauler1", 1, ATTN_NORM); - P_BulletSlope (self); + int bpitch = P_BulletSlope (self); for (int i = 0; i < 20; ++i) { int damage = 5 * (pr_mauler1() % 3 + 1); angle_t angle = self->angle + (pr_mauler1.Random2() << 19); - int pitch = bulletpitch + (pr_mauler1.Random2() * 332063); + int pitch = bpitch + (pr_mauler1.Random2() * 332063); // Strife used a range of 2112 units for the mauler to signal that // it should use a different puff. ZDoom's default range is longer @@ -2185,6 +2185,7 @@ void A_FireSigil1 (AActor *actor) { AActor *spot; player_t *player = actor->player; + AActor *linetarget; if (player == NULL || player->ReadyWeapon == NULL) return; @@ -2192,7 +2193,7 @@ void A_FireSigil1 (AActor *actor) P_DamageMobj (actor, actor, NULL, 1*4, 0, DMG_NO_ARMOR); S_Sound (actor, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); - P_BulletSlope (actor); + P_BulletSlope (actor, &linetarget); if (linetarget != NULL) { spot = Spawn (linetarget->x, linetarget->y, ONFLOORZ, ALLOW_REPLACE); @@ -2283,6 +2284,7 @@ void A_FireSigil4 (AActor *actor) { AActor *spot; player_t *player = actor->player; + AActor *linetarget; if (player == NULL || player->ReadyWeapon == NULL) return; @@ -2290,10 +2292,10 @@ void A_FireSigil4 (AActor *actor) P_DamageMobj (actor, actor, NULL, 4*4, 0, DMG_NO_ARMOR); S_Sound (actor, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); - P_BulletSlope (actor); + P_BulletSlope (actor, &linetarget); if (linetarget != NULL) { - spot = P_SpawnPlayerMissile (actor, RUNTIME_CLASS(ASpectralLightningBigV1)); + spot = P_SpawnPlayerMissile (actor, 0,0,0, RUNTIME_CLASS(ASpectralLightningBigV1), 0, &linetarget); if (spot != NULL) { spot->tracer = linetarget; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index fc830b117..c8e74d12f 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -349,11 +349,13 @@ bool AActor::SuggestMissileAttack (fixed_t dist) bool P_HitFriend(AActor * self) { + AActor *linetarget; + if (self->flags&MF_FRIENDLY && self->target != NULL) { angle_t angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y); fixed_t dist = P_AproxDistance (self->x-self->target->x, self->y-self->target->y); - P_AimLineAttack (self, angle, dist, 0, true); + P_AimLineAttack (self, angle, dist, &linetarget, 0, true); if (linetarget != NULL && linetarget != self->target) { return self->IsFriend (linetarget); diff --git a/src/p_local.h b/src/p_local.h index aa0d84389..0358118a0 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -86,7 +86,6 @@ void P_UnPredictPlayer (); #define FLOATRANDZ (FIXED_MAX-1) extern fixed_t FloatBobOffsets[64]; -extern AActor *MissileActor; APlayerPawn *P_SpawnPlayer (mapthing2_t* mthing, bool tempplayer=false); @@ -120,7 +119,8 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl AActor *P_SpawnPlayerMissile (AActor* source, const PClass *type); AActor *P_SpawnPlayerMissile (AActor *source, const PClass *type, angle_t angle); -AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, const PClass *type, angle_t angle); +AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, const PClass *type, angle_t angle, + AActor **pLineTarget = NULL, AActor **MissileActor = NULL); void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheight=false); @@ -345,6 +345,17 @@ struct FCheckPosition bool touchmidtex; bool floatok; line_t *ceilingline; + AActor *stepthing; + // [RH] These are used by PIT_CheckThing and P_XYMovement to apply + // ripping damage once per tic instead of once per move. + bool DoRipping; + AActor *LastRipped; + + FCheckPosition(bool rip=false) + { + DoRipping = rip; + LastRipped = NULL; + } }; @@ -355,13 +366,9 @@ extern msecnode_t *sector_list; // phares 3/16/98 extern TArray spechit; -// [RH] These are used by PIT_CheckThing and P_XYMovement to apply -// ripping damage once per tic instead of once per move. -extern bool DoRipping; -extern AActor *LastRipped; bool P_TestMobjLocation (AActor *mobj); -bool P_TestMobjZ (AActor *mobj, bool quick=true); +bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm); bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y); AActor *P_CheckOnmobj (AActor *thing); @@ -380,9 +387,7 @@ void P_FindFloorCeiling (AActor *actor); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); -extern AActor* linetarget; // who got hit (or NULL) - -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, fixed_t vrange=0, bool forcenosmart=false); +fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, bool forcenosmart=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 *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, bool ismelee = false); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); diff --git a/src/p_map.cpp b/src/p_map.cpp index 87377ece7..b00f3e143 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -77,14 +77,9 @@ static FRandom pr_crunch ("DoCrunch"); // but don't process them until the move is proven valid TArray spechit; -AActor *onmobj; // generic global onmobj...used for landing on pods/players - // Temporary holder for thing_sectorlist threads msecnode_t* sector_list = NULL; // phares 3/16/98 -bool DoRipping; -AActor *LastRipped; - //========================================================================== // // PIT_FindFloorCeiling @@ -643,8 +638,6 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) // //========================================================================== -static AActor *stepthing; - bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { fixed_t topz; @@ -675,7 +668,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // if (abs(thing->x - tmx) <= thing->radius && // abs(thing->y - tmy) <= thing->radius) { - stepthing = thing; + tm.stepthing = thing; tm.floorz = topz; } } @@ -842,11 +835,11 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { return true; } - if (DoRipping && !(thing->flags5 & MF5_DONTRIP)) + if (tm.DoRipping && !(thing->flags5 & MF5_DONTRIP)) { - if (LastRipped != thing) + if (tm.LastRipped != thing) { - LastRipped = thing; + tm.LastRipped = thing; if (!(thing->flags & MF_NOBLOOD) && !(thing->flags2 & MF2_REFLECTIVE) && !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && @@ -1042,7 +1035,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm) thing->height = realheight + thing->MaxStepHeight; } - stepthing = NULL; + tm.stepthing = NULL; FRadiusThingsIterator it2(x, y, thing->radius); AActor *th; @@ -1125,7 +1118,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm) if (tm.ceilingz - tm.floorz < thing->height) return false; - if (stepthing != NULL || tm.touchmidtex) + if (tm.stepthing != NULL || tm.touchmidtex) { tm.dropoffz = thingdropoffz; } @@ -1150,10 +1143,11 @@ AActor *P_CheckOnmobj (AActor *thing) { fixed_t oldz; bool good; + AActor *onmobj; oldz = thing->z; P_FakeZMovement (thing); - good = P_TestMobjZ (thing, false); + good = P_TestMobjZ (thing, false, &onmobj); thing->z = oldz; return good ? NULL : onmobj; @@ -1165,11 +1159,14 @@ AActor *P_CheckOnmobj (AActor *thing) // //============================================================================= -bool P_TestMobjZ (AActor *actor, bool quick) +bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) { - onmobj = NULL; + AActor *onmobj = NULL; if (actor->flags & MF_NOCLIP) + { + if (pOnmobj) *pOnmobj = NULL; return true; + } FRadiusThingsIterator it(actor->x, actor->y, actor->radius); AActor *thing; @@ -1208,7 +1205,7 @@ bool P_TestMobjZ (AActor *actor, bool quick) if (quick) break; } - + if (pOnmobj) *pOnmobj = onmobj; return onmobj == NULL; } @@ -2306,7 +2303,6 @@ bool P_BounceWall (AActor *mo) // Aiming // //============================================================================ -AActor* linetarget; // who got hit (or NULL) struct aim_t { @@ -2316,6 +2312,7 @@ struct aim_t AActor* shootthing; fixed_t toppitch, bottompitch; + AActor * linetarget; AActor * thing_friend, * thing_other; angle_t pitch_friend, pitch_other; bool notsmart; @@ -2460,7 +2457,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // P_AimLineAttack // //============================================================================ -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, fixed_t vrange, bool forcenosmart) +fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, bool forcenosmart) { fixed_t x2; fixed_t y2; @@ -2502,7 +2499,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, fixed_t vr aim.notsmart = forcenosmart; aim.attackrange = distance; - linetarget = NULL; + aim.linetarget = NULL; // for smart aiming aim.thing_friend=aim.thing_other=NULL; @@ -2511,20 +2508,21 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, fixed_t vr aim.aimpitch=t1->pitch; aim.AimTraverse (t1->x, t1->y, x2, y2); - if (!linetarget) + if (!aim.linetarget) { if (aim.thing_other) { - linetarget=aim.thing_other; + aim.linetarget=aim.thing_other; aim.aimpitch=aim.pitch_other; } else if (aim.thing_friend) { - linetarget=aim.thing_friend; + aim.linetarget=aim.thing_friend; aim.aimpitch=aim.pitch_friend; } } - return linetarget ? aim.aimpitch : t1->pitch; + if (pLineTarget) *pLineTarget = aim.linetarget; + return aim.linetarget ? aim.aimpitch : t1->pitch; } @@ -4037,7 +4035,8 @@ void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) } else if ((thing->flags2 & MF2_PASSMOBJ) && !isgood && thing->z + thing->height < thing->ceilingz) { - if (!P_TestMobjZ (thing) && onmobj->z <= thing->z) + AActor *onmobj; + if (!P_TestMobjZ (thing, true, &onmobj) && onmobj->z <= thing->z) { thing->z = MIN (thing->ceilingz - thing->height, onmobj->z + onmobj->height); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 958c3d548..000022177 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -157,8 +157,6 @@ fixed_t FloatBobDiffs[64] = CVAR (Int, cl_pufftype, 0, CVAR_ARCHIVE); CVAR (Int, cl_bloodtype, 0, CVAR_ARCHIVE); -AActor *MissileActor; - // CODE -------------------------------------------------------------------- IMPLEMENT_POINTY_CLASS (AActor) @@ -1508,11 +1506,7 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // passes through more than one actor this tic, each one takes damage // and not just the first one. - if (mo->flags2 & MF2_RIP) - { - DoRipping = true; - LastRipped = NULL; - } + FCheckPosition tm(!!(mo->flags2 & MF2_RIP)); do { @@ -1524,7 +1518,6 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) */ // [RH] If walking on a slope, stay on the slope // killough 3/15/98: Allow objects to drop off - FCheckPosition tm; if (!P_TryMove (mo, ptryx, ptryy, true, walkplane, tm)) { // blocked move @@ -1631,13 +1624,11 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { S_SoundID (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE); } - DoRipping = false; return; } else { // Struck a player/creature P_ExplodeMissile (mo, NULL, BlockingMobj); - DoRipping = false; return; } } @@ -1651,7 +1642,6 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { S_SoundID (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE); } - DoRipping = false; return; } } @@ -1679,7 +1669,6 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) mo->tracer = mo->target; } mo->target = BlockingMobj; - DoRipping = false; return; } explode: @@ -1693,18 +1682,15 @@ explode: // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. mo->Destroy (); - DoRipping = false; return; } // [RH] Don't explode on horizon lines. if (mo->BlockingLine != NULL && mo->BlockingLine->special == Line_Horizon) { mo->Destroy (); - DoRipping = false; return; } P_ExplodeMissile (mo, mo->BlockingLine, BlockingMobj); - DoRipping = false; return; } else @@ -1734,8 +1720,6 @@ explode: } } while (++step <= steps); - DoRipping = false; - // Friction if (player && player->mo == mo && player->cheats & CF_NOMOMENTUM) @@ -4726,19 +4710,20 @@ AActor *P_SpawnPlayerMissile (AActor *source, const PClass *type, angle_t angle) } AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, - const PClass *type, angle_t angle) + const PClass *type, angle_t angle, AActor **pLineTarget, AActor **pMissileActor) { static const int angdiff[3] = { -1<<26, 1<<26, 0 }; int i; angle_t an; angle_t pitch; + AActor *linetarget; // see which target is to be aimed at i = 2; do { an = angle + angdiff[i]; - pitch = P_AimLineAttack (source, an, 16*64*FRACUNIT); + pitch = P_AimLineAttack (source, an, 16*64*FRACUNIT, &linetarget); if (source->player != NULL && level.IsFreelookAllowed() && @@ -4752,6 +4737,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, { an = angle; } + if (pLineTarget) *pLineTarget = linetarget; i = GetDefaultByType (type)->flags3; @@ -4781,7 +4767,8 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, z = source->floorz; } } - MissileActor = Spawn (type, source->x + x, source->y + y, z, ALLOW_REPLACE); + AActor *MissileActor = Spawn (type, source->x + x, source->y + y, z, ALLOW_REPLACE); + if (pMissileActor) *pMissileActor = MissileActor; P_PlaySpawnSound(MissileActor, source); MissileActor->target = source; MissileActor->angle = an; diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index bf0b120a7..7a473a3c1 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -45,8 +45,6 @@ // PUBLIC DATA DEFINITIONS ------------------------------------------------- -angle_t bulletpitch; - // [SO] 1=Weapons states are all 1 tick // 2=states with a function 1 tick, others 0 ticks. CVAR(Int, sv_fastweapons, false, CVAR_SERVERINFO); @@ -632,18 +630,20 @@ void A_GunFlash (AActor *actor) // the height of the intended target // -void P_BulletSlope (AActor *mo) +angle_t P_BulletSlope (AActor *mo, AActor **pLineTarget) { static const int angdiff[3] = { -1<<26, 1<<26, 0 }; int i; angle_t an; + angle_t pitch; + AActor *linetarget; // see which target is to be aimed at i = 2; do { an = mo->angle + angdiff[i]; - bulletpitch = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + pitch = P_AimLineAttack (mo, an, 16*64*FRACUNIT, &linetarget); if (mo->player != NULL && level.IsFreelookAllowed() && @@ -652,13 +652,14 @@ void P_BulletSlope (AActor *mo) break; } } while (linetarget == NULL && --i >= 0); + return pitch; } // // P_GunShot // -void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype) +void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype, angle_t pitch) { angle_t angle; int damage; @@ -671,7 +672,7 @@ void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype) angle += pr_gunshot.Random2 () << 18; } - P_LineAttack (mo, angle, PLAYERMISSILERANGE, bulletpitch, damage, NAME_None, pufftype); + P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, pufftype); } void A_Light0 (AActor *actor) diff --git a/src/p_pspr.h b/src/p_pspr.h index 0553f3766..2e2e87c89 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -90,8 +90,8 @@ void P_BringUpWeapon (player_s *player); void P_FireWeapon (player_s *player); void P_DropWeapon (player_s *player); void P_BobWeapon (player_s *player, pspdef_t *psp, fixed_t *x, fixed_t *y); -void P_BulletSlope (AActor *mo); -void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype); +angle_t P_BulletSlope (AActor *mo, AActor **pLineTarget = NULL); +void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype, angle_t pitch); void A_WeaponReady (AActor *actor); void A_ReFire (AActor *actor); @@ -103,6 +103,4 @@ void A_Light0 (AActor *actor); void A_Light1 (AActor *actor); void A_Light2 (AActor *actor); -extern angle_t bulletpitch; - #endif // __P_PSPR_H__ diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 36215d536..e74359194 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -540,8 +540,7 @@ void A_JumpIfCloser(AActor * self) else { // Does the player aim at something that can be shot? - P_BulletSlope(self); - target = linetarget; + P_BulletSlope(self, &target); } if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! @@ -1016,9 +1015,8 @@ void A_FireBullets (AActor *self) static_cast(self)->PlayAttacking2 (); - P_BulletSlope(self); + bslope = P_BulletSlope(self); bangle = self->angle; - bslope = bulletpitch; PuffType = PClass::FindClass(PuffTypeName); if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff); @@ -1063,6 +1061,7 @@ void A_FireCustomMissile (AActor * self) player_t *player=self->player; AWeapon * weapon=player->ReadyWeapon; + AActor *linetarget; if (UseAmmo && weapon) { @@ -1080,7 +1079,7 @@ void A_FireCustomMissile (AActor * self) if (AimAtAngle) shootangle+=Angle; - AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle); + AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget); // automatic handling of seeker missiles if (misl) { @@ -1129,12 +1128,13 @@ void A_CustomPunch (AActor *self) angle_t angle; int pitch; + AActor * linetarget; if (!norandom) Damage *= (pr_cwpunch()%8+1); angle = self->angle + (pr_cwpunch.Random2() << 18); if (Range == 0) Range = MELEERANGE; - pitch = P_AimLineAttack (self, angle, Range); + pitch = P_AimLineAttack (self, angle, Range, &linetarget); // only use ammo when actually hitting something! if (UseAmmo && linetarget && weapon) @@ -2164,8 +2164,7 @@ void A_JumpIfTargetInLOS(AActor * self) else { // Does the player aim at something that can be shot? - P_BulletSlope(self); - target = linetarget; + P_BulletSlope(self, &target); } // No target - return