From 0f8e2441a1d6edc1b807e266d42af7a35a0c5cdf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 May 2012 11:17:27 +0000 Subject: [PATCH] - changed spectral missiles to use FriendPlayer instead of health to distinguish between player spawned and monster spawned versions. Also moved most of this into the basic missile spawning functions instead of littering all spectral missile spawning functions with these initializations. SVN r3651 (trunk) --- src/g_hexen/a_flechette.cpp | 5 ---- src/g_strife/a_alienspectres.cpp | 2 +- src/g_strife/a_entityboss.cpp | 1 - src/g_strife/a_programmer.cpp | 2 +- src/g_strife/a_spectral.cpp | 6 ++-- src/g_strife/a_strifeweapons.cpp | 8 ++--- src/p_interaction.cpp | 4 +-- src/p_mobj.cpp | 50 +++++++++++++++++++++++++++++-- src/thingdef/thingdef_codeptr.cpp | 21 ++++++------- 9 files changed, 68 insertions(+), 31 deletions(-) diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 780b6d1ea..779b9424c 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -196,11 +196,6 @@ bool AArtiPoisonBagShooter::Use (bool pickup) { mo->tracer = Owner->target; } - // set the health value so that the missile works properly - if (mo->flags4 & MF4_SPECTRAL) - { - mo->health = -2; - } return true; } } diff --git a/src/g_strife/a_alienspectres.cpp b/src/g_strife/a_alienspectres.cpp index 169889b2e..4626891bb 100644 --- a/src/g_strife/a_alienspectres.cpp +++ b/src/g_strife/a_alienspectres.cpp @@ -66,7 +66,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) foo->velz = -12*FRACUNIT; foo->target = self; - foo->health = -2; + foo->FriendPlayer = 0; foo->tracer = self->target; self->angle -= ANGLE_180 / 20 * 10; diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index f69d43fc6..3dfeb3b5a 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -29,7 +29,6 @@ void A_SpectralMissile (AActor *self, const char *missilename) if (missile != NULL) { missile->tracer = self->target; - missile->health = -2; P_CheckMissileSpawn(missile); } } diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 6a65ef9e3..0f843c55c 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -109,7 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) { spot->threshold = 25; spot->target = self; - spot->health = -2; + spot->FriendPlayer = 0; spot->tracer = self->target; } } diff --git a/src/g_strife/a_spectral.cpp b/src/g_strife/a_spectral.cpp index 1272d35f8..6e2e6488e 100644 --- a/src/g_strife/a_spectral.cpp +++ b/src/g_strife/a_spectral.cpp @@ -31,7 +31,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) AActor *foo = Spawn("SpectralLightningHTail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); foo->angle = self->angle; - foo->health = self->health; + foo->FriendPlayer = self->FriendPlayer; } DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning) @@ -69,13 +69,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) flash->target = self->target; flash->velz = -18*FRACUNIT; - flash->health = self->health; + flash->FriendPlayer = self->FriendPlayer; flash = Spawn(NAME_SpectralLightningV2, self->x, self->y, ONCEILINGZ, ALLOW_REPLACE); flash->target = self->target; flash->velz = -18*FRACUNIT; - flash->health = self->health; + flash->FriendPlayer = self->FriendPlayer; } // In Strife, this number is stored in the data segment, but it doesn't seem to be diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 957a5371a..1194f9237 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -530,15 +530,15 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target) { if (source->flags & MF_MISSILE && source->flags4 & MF4_SPECTRAL) { - other->health = source->health; + other->FriendPlayer = source->FriendPlayer; } else if (target->player != NULL) { - other->health = -1; + other->FriendPlayer = int(target->player - players) + 1; } else { - other->health = -2; + other->FriendPlayer = 0; } } @@ -925,7 +925,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) } if (spot != NULL) { - spot->health = -1; + spot->FriendPlayer = int(player-players)+1; spot->target = self; } } diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index de77f2712..955f1eec3 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -981,12 +981,12 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage { if (player != NULL) { - if (!deathmatch && inflictor->health == -1) + if (!deathmatch && inflictor->FriendPlayer > 0) return; } else if (target->flags4 & MF4_SPECTRAL) { - if (inflictor->health == -2 && !target->IsHostile(inflictor)) + if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor)) return; } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8ba0a9441..b48ef9732 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5295,6 +5295,18 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, th->angle = R_PointToAngle2 (0, 0, th->velx, th->vely); + if (th->flags4 & MF4_SPECTRAL) + { + if (owner->player != NULL) + { + th->FriendPlayer = int(owner->player - players) + 1; + } + else + { + th->FriendPlayer = 0; + } + } + return (!checkspawn || P_CheckMissileSpawn (th)) ? th : NULL; } @@ -5319,6 +5331,19 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const dist = 1; th->velz = (dest->z - source->z) / dist; + + if (th->flags4 & MF4_SPECTRAL) + { + if (owner->player != NULL) + { + th->FriendPlayer = int(owner->player - players) + 1; + } + else + { + th->FriendPlayer = 0; + } + } + P_CheckMissileSpawn(th); return th; } @@ -5401,6 +5426,19 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, mo->velx = FixedMul (speed, finecosine[angle]); mo->vely = FixedMul (speed, finesine[angle]); mo->velz = velz; + + if (mo->flags4 & MF4_SPECTRAL) + { + if (owner->player != NULL) + { + mo->FriendPlayer = int(owner->player - players) + 1; + } + else + { + mo->FriendPlayer = 0; + } + } + return (!checkspawn || P_CheckMissileSpawn(mo)) ? mo : NULL; } @@ -5512,8 +5550,16 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, MissileActor->velz = (fixed_t)vec.Z; if (MissileActor->flags4 & MF4_SPECTRAL) - MissileActor->health = -1; - + { + if (source->player != NULL) + { + MissileActor->FriendPlayer = int(source->player - players) + 1; + } + else + { + MissileActor->FriendPlayer = 0; + } + } if (P_CheckMissileSpawn (MissileActor)) { return MissileActor; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 71e166116..4d31f869a 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -333,11 +333,6 @@ static void DoAttack (AActor *self, bool domelee, bool domissile, { missile->tracer=self->target; } - // set the health value so that the missile works properly - if (missile->flags4&MF4_SPECTRAL) - { - missile->health=-2; - } P_CheckMissileSpawn(missile); } } @@ -967,10 +962,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) // automatic handling of seeker missiles missile->tracer=self->target; } - // set the health value so that the missile works properly + // we must redo the spectral check here because the owner is set after spawning so the FriendPlayer value may be wrong if (missile->flags4&MF4_SPECTRAL) { - missile->health=-2; + if (missile->target != NULL && missile->target->player != NULL) + { + missile->FriendPlayer = int(missile->target->player - players) + 1; + } + else + { + missile->FriendPlayer = 0; + } } P_CheckMissileSpawn(missile); } @@ -1121,11 +1123,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) { missile->tracer=self->target; } - // set the health value so that the missile works properly - if (missile->flags4&MF4_SPECTRAL) - { - missile->health=-2; - } P_CheckMissileSpawn(missile); } }