diff --git a/src/actor.h b/src/actor.h index 46d9ae0465..b371fdaee8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1265,6 +1265,10 @@ public: { z = newz; } + void AddZ(fixed_t newz, bool moving = true) + { + z += newz; + } // These are not for general use as they do not link the actor into the world! void SetXY(fixed_t xx, fixed_t yy) diff --git a/src/g_hexen/a_flies.cpp b/src/g_hexen/a_flies.cpp index 683cbebe1d..05c4ef94c0 100644 --- a/src/g_hexen/a_flies.cpp +++ b/src/g_hexen/a_flies.cpp @@ -83,7 +83,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) self->angle = ang; self->args[0]++; ang >>= ANGLETOFINESHIFT; - if (!P_TryMove(self, self->x + 6 * finecosine[ang], self->y + 6 * finesine[ang], true)) + if (!P_TryMove(self, self->X() + 6 * finecosine[ang], self->Y() + 6 * finesine[ang], true)) { self->SetIdle(true); return; @@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) self->vely += (pr_fly() - 128) << BOBTOFINESHIFT; } int zrand = pr_fly(); - if (targ->z + 5*FRACUNIT < self->z && zrand > 150) + if (targ->Z() + 5*FRACUNIT < self->Z() && zrand > 150) { zrand = -zrand; } diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index 6bafd383c3..a427daa47d 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -41,7 +41,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) self->special1 = self->args[2]; // Reset frequency count - mo = Spawn (fogs[pr_fogspawn()%3], self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn (fogs[pr_fogspawn()%3], self->Pos(), ALLOW_REPLACE); if (mo) { @@ -80,7 +80,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) if ((self->args[3] % 4) == 0) { weaveindex = self->special2; - self->z += finesine[weaveindex << BOBTOFINESHIFT] * 4; + self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 4); self->special2 = (weaveindex + 1) & 63; } diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 498b4e9554..e2b8c9ed27 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -232,7 +232,6 @@ void ASorcBall1::DoFireSpell () DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) { AActor *mo; - fixed_t z; self->SpawnState += 2; // [RH] Don't spawn balls again A_SlowBalls(self); @@ -240,17 +239,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) self->args[3] = SORC_NORMAL; self->args[4] = SORCBALL_INITIAL_SPEED; // Initial orbit speed self->special1 = ANGLE_1; - z = self->z - self->floorclip + self->height; + + fixedvec3 pos = self->PosPlusZ(-self->floorclip + self->height); - mo = Spawn("SorcBall1", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall1", pos, NO_REPLACE); if (mo) { mo->target = self; mo->special2 = SORCFX4_RAPIDFIRE_TIME; } - mo = Spawn("SorcBall2", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall2", pos, NO_REPLACE); if (mo) mo->target = self; - mo = Spawn("SorcBall3", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall3", pos, NO_REPLACE); if (mo) mo->target = self; } @@ -271,7 +271,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) } ASorcBall *actor; - int x,y; angle_t angle, baseangle; int mode = self->target->args[3]; AHeresiarch *parent = barrier_cast(self->target); @@ -370,9 +369,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) S_Sound (actor, CHAN_BODY, "SorcererBallWoosh", 1, ATTN_NORM); } actor->special1 = angle; // Set previous angle - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - actor->SetOrigin (x, y, parent->z - parent->floorclip + parent->height); + + fixedvec3 pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + -parent->floorclip + parent->height); + actor->SetOrigin (pos, true); actor->floorz = parent->floorz; actor->ceilingz = parent->ceilingz; } @@ -540,8 +542,7 @@ void ASorcBall2::CastSorcererSpell () AActor *parent = target; AActor *mo; - fixed_t z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - mo = Spawn("SorcFX2", x, y, z, ALLOW_REPLACE); + mo = Spawn("SorcFX2", PosPlusZ(-parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT), ALLOW_REPLACE); parent->flags2 |= MF2_REFLECTIVE|MF2_INVULNERABLE; parent->args[0] = SORC_DEFENSE_TIME; if (mo) mo->target = parent; @@ -667,7 +668,7 @@ void A_SorcOffense2(AActor *actor) mo->special2 = 35*5/2; // 5 seconds dist = mo->AproxDistance(dest) / mo->Speed; if(dist < 1) dist = 1; - mo->velz = (dest->z - mo->z) / dist; + mo->velz = (dest->Z() - mo->Z()) / dist; } } @@ -695,23 +696,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBossAttack) DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) { - fixed_t x,y,z; fixed_t dist = 5*FRACUNIT; - angle_t angle = self->angle >> ANGLETOFINESHIFT; fixed_t speed = self->Speed; angle_t rangle; AActor *mo; int ix; - x = self->x + FixedMul(dist,finecosine[angle]); - y = self->y + FixedMul(dist,finesine[angle]); - z = self->z - self->floorclip + (self->height>>1); + fixedvec3 pos = self->Vec3Angle(dist, self->angle, -self->floorclip + (self->height >> 1)); for (ix=0; ix<5; ix++) { - mo = Spawn("SorcSpark1", x, y, z, ALLOW_REPLACE); + mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE); if (mo) { - rangle = angle + ((pr_heresiarch()%5) << 1); + rangle = (self->angle >> ANGLETOFINESHIFT) + ((pr_heresiarch()%5) << 1); mo->velx = FixedMul(pr_heresiarch()%speed, finecosine[rangle]); mo->vely = FixedMul(pr_heresiarch()%speed, finesine[rangle]); mo->velz = FRACUNIT*2; @@ -755,7 +752,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) { AActor *mo; - mo = Spawn(self->GetClass(), self->x, self->y, self->z, NO_REPLACE); + mo = Spawn(self->GetClass(), self->Pos(), NO_REPLACE); if (mo) { mo->target = self->target; @@ -763,7 +760,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) mo->special1 = self->angle; // Set angle mo->SetState (mo->FindState("Orbit")); } - mo = Spawn(self->GetClass(), self->x, self->y, self->z, NO_REPLACE); + mo = Spawn(self->GetClass(), self->Pos(), NO_REPLACE); if (mo) { mo->target = self->target; @@ -785,7 +782,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) { angle_t angle; - fixed_t x,y,z; + fixedvec3 pos; AActor *parent = self->target; // [RH] If no parent, then disappear @@ -818,26 +815,28 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) { self->special1 += ANGLE_1*10; angle = ((angle_t)self->special1) >> ANGLETOFINESHIFT; - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - z += FixedMul(15*FRACUNIT,finecosine[angle]); + pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT); + pos.z += FixedMul(15*FRACUNIT,finecosine[angle]); // Spawn trailer - Spawn("SorcFX2T1", x, y, z, ALLOW_REPLACE); + Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } else // Clock wise { self->special1 -= ANGLE_1*10; angle = ((angle_t)self->special1) >> ANGLETOFINESHIFT; - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - z += FixedMul(20*FRACUNIT,finesine[angle]); + pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT); + pos.z += FixedMul(20*FRACUNIT,finesine[angle]); // Spawn trailer - Spawn("SorcFX2T1", x, y, z, ALLOW_REPLACE); + Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } - self->SetOrigin (x, y, z); + self->SetOrigin (pos, true); self->floorz = parent->floorz; self->ceilingz = parent->ceilingz; } @@ -853,7 +852,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) { AActor *mo; - mo = Spawn("Bishop", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn("Bishop", self->Pos(), ALLOW_REPLACE); if (mo) { if (!P_TestMobjLocation(mo)) @@ -878,7 +877,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) DEFINE_ACTION_FUNCTION(AActor, A_SorcererBishopEntry) { - Spawn("SorcFX3Explosion", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn("SorcFX3Explosion", self->Pos(), ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); } diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index ad10a464c1..19cb4f7525 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -60,7 +60,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) for(i = (pr_pottery()&3)+3; i; i--) { - mo = Spawn ("PotteryBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("PotteryBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + (pr_pottery()%5)); @@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) || !(GetDefaultByType (type)->flags3 & MF3_ISMONSTER)) { // Only spawn monsters if not -nomonsters - Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + Spawn (type, self->Pos(), ALLOW_REPLACE); } } } @@ -132,7 +132,7 @@ IMPLEMENT_CLASS (AZCorpseLynchedNoHeart) void AZCorpseLynchedNoHeart::PostBeginPlay () { Super::PostBeginPlay (); - Spawn ("BloodPool", x, y, floorz, ALLOW_REPLACE); + Spawn ("BloodPool", X(), Y(), floorz, ALLOW_REPLACE); } //============================================================================ @@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseBloodDrip) { if (pr_drip() <= 128) { - Spawn ("CorpseBloodDrip", self->x, self->y, self->z + self->height/2, ALLOW_REPLACE); + Spawn ("CorpseBloodDrip", self->PosPlusZ(self->height/2), ALLOW_REPLACE); } } @@ -162,7 +162,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) for (i = (pr_foo()&3)+3; i; i--) { - mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("CorpseBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + (pr_foo()%3)); @@ -172,7 +172,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) } } // Spawn a skull - mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("CorpseBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + 3); @@ -198,9 +198,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) for (i = (pr_leaf()&3)+1; i; i--) { mo = Spawn (pr_leaf()&1 ? PClass::FindClass ("Leaf1") : PClass::FindClass ("Leaf2"), - self->x + (pr_leaf.Random2()<<14), - self->y + (pr_leaf.Random2()<<14), - self->z + (pr_leaf()<<14), ALLOW_REPLACE); + self->Vec3Offset( + (pr_leaf.Random2()<<14), + (pr_leaf.Random2()<<14), + (pr_leaf()<<14)), ALLOW_REPLACE); if (mo) { P_ThrustMobj (mo, self->angle, (pr_leaf()<<9)+3*FRACUNIT); @@ -277,9 +278,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) for (i = 0; i < 10; i++) { - mo = Spawn ("ZArmorChunk", self->x+((pr_soaexplode()-128)<<12), - self->y+((pr_soaexplode()-128)<<12), - self->z+(pr_soaexplode()*self->height/256), ALLOW_REPLACE); + mo = Spawn ("ZArmorChunk", self->Vec3Offset( + ((pr_soaexplode()-128)<<12), + ((pr_soaexplode()-128)<<12), + (pr_soaexplode()*self->height/256)), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + i); @@ -295,7 +297,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) || !(GetDefaultByType (type)->flags3 & MF3_ISMONSTER)) { // Only spawn monsters if not -nomonsters - Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + Spawn (type, self->Pos(), ALLOW_REPLACE); } } S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_NORM); diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index 9d8360d4d5..75be577bf7 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -35,10 +35,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) dist = ((pr_iceguylook()-128)*self->radius)>>7; an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - Spawn (WispTypes[pr_iceguylook()&1], - self->x+FixedMul(dist, finecosine[an]), - self->y+FixedMul(dist, finesine[an]), - self->z+60*FRACUNIT, ALLOW_REPLACE); + Spawn(WispTypes[pr_iceguylook() & 1], self->Vec3Offset( + FixedMul(dist, finecosine[an]), + FixedMul(dist, finesine[an]), + 60 * FRACUNIT), ALLOW_REPLACE); } } @@ -60,10 +60,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) dist = ((pr_iceguychase()-128)*self->radius)>>7; an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - mo = Spawn (WispTypes[pr_iceguychase()&1], - self->x+FixedMul(dist, finecosine[an]), - self->y+FixedMul(dist, finesine[an]), - self->z+60*FRACUNIT, ALLOW_REPLACE); + mo = Spawn(WispTypes[pr_iceguychase() & 1], self->Vec3Offset( + FixedMul(dist, finecosine[an]), + FixedMul(dist, finesine[an]), + 60 * FRACUNIT), ALLOW_REPLACE); if (mo) { mo->velx = self->velx; @@ -82,22 +82,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) { - fixed_t an; - if(!self->target) { return; } - an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - P_SpawnMissileXYZ(self->x+FixedMul(self->radius>>1, - finecosine[an]), self->y+FixedMul(self->radius>>1, - finesine[an]), self->z+40*FRACUNIT, self, self->target, - PClass::FindClass ("IceGuyFX")); - an = (self->angle-ANG90)>>ANGLETOFINESHIFT; - P_SpawnMissileXYZ(self->x+FixedMul(self->radius>>1, - finecosine[an]), self->y+FixedMul(self->radius>>1, - finesine[an]), self->z+40*FRACUNIT, self, self->target, - PClass::FindClass ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle+ANG90, 40*FRACUNIT), self, self->target, PClass::FindClass ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle-ANG90, 40*FRACUNIT), self, self->target, PClass::FindClass ("IceGuyFX")); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); } @@ -129,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) for (i = 0; i < 8; i++) { - mo = P_SpawnMissileAngleZ (self, self->z+3*FRACUNIT, + mo = P_SpawnMissileAngleZ (self, self->Z()+3*FRACUNIT, PClass::FindClass("IceGuyFX2"), i*ANG45, (fixed_t)(-0.3*FRACUNIT)); if (mo) { diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index a941f1a65e..fb833fdedc 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) spot = iterator.Next (); if (spot != NULL) { - P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false); } P_StartScript (self, NULL, 249, NULL, NULL, 0, 0); @@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) self->tracer = spot; if (spot) { - P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false); } } } @@ -248,7 +248,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile) DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) { - fixed_t x,y,z; angle_t ang; int numcommands; @@ -256,10 +255,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) // Shoot stream of lightning to ceiling ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; - x = self->x + KORAX_COMMAND_OFFSET * finecosine[ang]; - y = self->y + KORAX_COMMAND_OFFSET * finesine[ang]; - z = self->z + KORAX_COMMAND_HEIGHT*FRACUNIT; - Spawn("KoraxBolt", x, y, z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + KORAX_COMMAND_OFFSET * finecosine[ang], + KORAX_COMMAND_OFFSET * finesine[ang], + KORAX_COMMAND_HEIGHT*FRACUNIT); + Spawn("KoraxBolt", pos, ALLOW_REPLACE); if (self->health <= (self->SpawnHealth() >> 1)) { @@ -310,14 +310,13 @@ void KoraxFire (AActor *actor, const PClass *type, int arm) }; angle_t ang; - fixed_t x,y,z; - ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) - >> ANGLETOFINESHIFT; - x = actor->x + extension[arm] * finecosine[ang]; - y = actor->y + extension[arm] * finesine[ang]; - z = actor->z - actor->floorclip + armheight[arm]; - P_SpawnKoraxMissile (x, y, z, actor, actor->target, type); + ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) >> ANGLETOFINESHIFT; + fixedvec3 pos = actor->Vec3Offset( + extension[arm] * finecosine[ang], + extension[arm] * finesine[ang], + -actor->floorclip + armheight[arm]); + P_SpawnKoraxMissile (pos.x, pos.y, pos.z, actor, actor->target, type); } //============================================================================ @@ -372,11 +371,11 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) actor->vely = FixedMul (actor->Speed, finesine[angle]); if (!(level.time&15) - || actor->z > target->z+(target->GetDefault()->height) - || actor->z+actor->height < target->z) + || actor->Z() > target->Z()+(target->GetDefault()->height) + || actor->Top() < target->Z()) { - newZ = target->z+((pr_kspiritseek()*target->GetDefault()->height)>>8); - deltaZ = newZ-actor->z; + newZ = target->Z()+((pr_kspiritseek()*target->GetDefault()->height)>>8); + deltaZ = newZ-actor->Z(); if (abs(deltaZ) > 15*FRACUNIT) { if(deltaZ > 0) @@ -453,11 +452,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise) fixed_t z; // Spawn a child upward - z = self->z + KORAX_BOLT_HEIGHT; + z = self->Z() + KORAX_BOLT_HEIGHT; if ((z + KORAX_BOLT_HEIGHT) < self->ceilingz) { - mo = Spawn("KoraxBolt", self->x, self->y, z, ALLOW_REPLACE); + mo = Spawn("KoraxBolt", self->X(), self->Y(), z, ALLOW_REPLACE); if (mo) { mo->special1 = KORAX_BOLT_LIFETIME; @@ -499,6 +498,6 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z, { dist = 1; } - th->velz = (dest->z-z+(30*FRACUNIT))/dist; + th->velz = (dest->Z()-z+(30*FRACUNIT))/dist; return (P_CheckMissileSpawn(th, source->radius) ? th : NULL); } diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 6356fbb2ff..f9d98c78f6 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) // every so many calls, spawn a new missile in its set directions if (spawndir & SHARDSPAWN_LEFT) { - mo = P_SpawnMissileAngleZSpeed (self, self->z, RUNTIME_CLASS(AFrostMissile), self->angle+(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle+(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -132,7 +132,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_RIGHT) { - mo = P_SpawnMissileAngleZSpeed (self, self->z, RUNTIME_CLASS(AFrostMissile), self->angle-(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle-(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -144,7 +144,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_UP) { - mo = P_SpawnMissileAngleZSpeed (self, self->z+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, 0, (15+2*spermcount)<target); if (mo) { @@ -159,7 +159,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_DOWN) { - mo = P_SpawnMissileAngleZSpeed (self, self->z-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, 0, (15+2*spermcount)<target); if (mo) { diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index a13e3a2741..88c6dba8be 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -151,12 +151,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) { return; } - self->z = self->floorz; + self->SetZ(self->floorz); target = self->lastenemy->tracer; } else if (self->flags3 & MF3_CEILINGHUGGER) { - self->z = self->ceilingz-self->height; + self->SetZ(self->ceilingz-self->height); target = self->tracer; } if (self->flags3 & MF3_FLOORHUGGER) @@ -228,9 +228,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) { deltaZ = -10*FRACUNIT; } - mo = Spawn(lightning, self->x+((pr_zap()-128)*self->radius/256), - self->y+((pr_zap()-128)*self->radius/256), - self->z+deltaZ, ALLOW_REPLACE); + mo = Spawn(lightning, + self->Vec3Offset( + ((pr_zap() - 128)*self->radius / 256), + ((pr_zap() - 128)*self->radius / 256), + deltaZ), ALLOW_REPLACE); if (mo) { mo->lastenemy = self; @@ -329,7 +331,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LastZap) AActor *mo; - mo = Spawn(lightning, self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn(lightning, self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->FindState (NAME_Death)); diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index 97a658a15d..4df037fc2c 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -140,8 +140,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &linetarget, ANGLE_1*32); if (linetarget == NULL) { - BlockCheckLine.x = self->x; - BlockCheckLine.y = self->y; + BlockCheckLine.x = self->X(); + BlockCheckLine.y = self->Y(); BlockCheckLine.dx = -finesine[angle >> ANGLETOFINESHIFT]; BlockCheckLine.dy = -finecosine[angle >> ANGLETOFINESHIFT]; linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck); @@ -202,7 +202,7 @@ static AActor *FrontBlockCheck (AActor *mo, int index, void *) { if (link->Me != mo) { - if (P_PointOnDivlineSide (link->Me->x, link->Me->y, &BlockCheckLine) == 0 && + if (P_PointOnDivlineSide (link->Me->X(), link->Me->Y(), &BlockCheckLine) == 0 && mo->IsOkayToAttack (link->Me)) { return link->Me; @@ -222,7 +222,7 @@ void MStaffSpawn2 (AActor *actor, angle_t angle) { AActor *mo; - mo = P_SpawnMissileAngleZ (actor, actor->z+40*FRACUNIT, + mo = P_SpawnMissileAngleZ (actor, actor->Z()+40*FRACUNIT, RUNTIME_CLASS(AMageStaffFX2), angle, 0); if (mo) { diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 437a336a38..21d141b0cd 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -96,7 +96,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) DEFINE_ACTION_FUNCTION(AActor, A_PigPain) { CALL_ACTION(A_Pain, self); - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { self->velz = FRACUNIT*7/2; } diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index cf552897fe..39b4382e30 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -202,9 +202,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) for (int i = countof(GibTypes)-1; i >= 0; --i) { - mo = Spawn (GibTypes[i], - self->x+((pr_serpentgibs()-128)<<12), - self->y+((pr_serpentgibs()-128)<<12), + fixedvec2 pos = self->Vec2Offset( + ((pr_serpentgibs() - 128) << 12), + ((pr_serpentgibs() - 128) << 12)); + + mo = Spawn (GibTypes[i], pos.x, pos.y, self->floorz+FRACUNIT, ALLOW_REPLACE); if (mo) { @@ -256,7 +258,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DelayGib) DEFINE_ACTION_FUNCTION(AActor, A_SerpentHeadCheck) { - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { if (Terrains[P_GetThingFloorType(self)].IsLiquid) { diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index 9c9f9ab204..90729a77db 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -95,7 +95,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitDn) self->flags2 = MF2_NOTELEPORT|MF2_FLOORCLIP; self->renderflags = RF_INVISIBLE; static_cast(self)->DirtClump = - Spawn("DirtClump", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn("DirtClump", self->Pos(), ALLOW_REPLACE); } @@ -140,7 +140,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustLower) DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) { AActor *thing; - FBlockThingsIterator it(FBoundingBox(self->x, self->y, self->radius)); + FBlockThingsIterator it(FBoundingBox(self->X(), self->Y(), self->radius)); while ((thing = it.Next())) { if (!thing->intersects(self)) diff --git a/src/g_hexen/a_summon.cpp b/src/g_hexen/a_summon.cpp index cbb8a38542..0fffb6e4ce 100644 --- a/src/g_hexen/a_summon.cpp +++ b/src/g_hexen/a_summon.cpp @@ -51,13 +51,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) { AMinotaurFriend *mo; - mo = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn (self->Pos(), ALLOW_REPLACE); if (mo) { if (P_TestMobjLocation(mo) == false || !self->tracer) { // Didn't fit - change back to artifact mo->Destroy (); - AActor *arti = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + AActor *arti = Spawn (self->Pos(), ALLOW_REPLACE); if (arti) arti->flags |= MF_DROPPED; return; } @@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) } // Make smoke puff - Spawn ("MinotaurSmoke", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn ("MinotaurSmoke", self->Pos(), ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM); } } diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index 2bf99640b5..14edd75197 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -51,7 +51,7 @@ static void TeloSpawn (AActor *source, const char *type) { AActor *fx; - fx = Spawn (type, source->x, source->y, source->z, ALLOW_REPLACE); + fx = Spawn (type, source->Pos(), ALLOW_REPLACE); if (fx) { fx->special1 = TELEPORT_LIFE; // Lifetime countdown diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index b339f14be2..312585cdfb 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -29,12 +29,12 @@ static FRandom pr_wraithfx4 ("WraithFX4"); DEFINE_ACTION_FUNCTION(AActor, A_WraithInit) { - self->z += 48<AddZ(48<z + self->height > self->ceilingz) + if (self->Top() > self->ceilingz) { - self->z = self->ceilingz - self->height; + self->SetZ(self->ceilingz - self->height); } self->special1 = 0; // index into floatbob @@ -110,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) for (i = 2; i; --i) { - mo = Spawn ("WraithFX2", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("WraithFX2", self->Pos(), ALLOW_REPLACE); if(mo) { if (pr_wraithfx2 ()<128) @@ -147,12 +147,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3) while (numdropped-- > 0) { - mo = Spawn ("WraithFX3", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx3()-128)<<11, + (pr_wraithfx3()-128)<<11, + (pr_wraithfx3()<<10)); + + mo = Spawn ("WraithFX3", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx3()-128)<<11; - mo->y += (pr_wraithfx3()-128)<<11; - mo->z += (pr_wraithfx3()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } @@ -195,23 +199,31 @@ void A_WraithFX4 (AActor *self) if (spawn4) { - mo = Spawn ("WraithFX4", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()<<10)); + + mo = Spawn ("WraithFX4", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx4()-128)<<12; - mo->y += (pr_wraithfx4()-128)<<12; - mo->z += (pr_wraithfx4()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } if (spawn5) { - mo = Spawn ("WraithFX5", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()<<10)); + + mo = Spawn ("WraithFX5", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx4()-128)<<11; - mo->y += (pr_wraithfx4()-128)<<11; - mo->z += (pr_wraithfx4()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } @@ -226,7 +238,7 @@ void A_WraithFX4 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) { int weaveindex = self->special1; - self->z += finesine[weaveindex << BOBTOFINESHIFT] * 8; + self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // if (self->floorclip > 0) // { diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index c2348a9e3a..bf795fb331 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -186,8 +186,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) S_Sound (self, CHAN_WEAPON, "minotaur/sight", 1, ATTN_NORM); } dist = self->AproxDistance (target); - if (target->z+target->height > self->z - && target->z+target->height < self->z+self->height + if (target->Top() > self->Z() + && target->Top() < self->Top() && dist < (friendly ? 16*64*FRACUNIT : 8*64*FRACUNIT) && dist > 1*64*FRACUNIT && pr_minotaurdecide() < 150) @@ -205,7 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) self->vely = FixedMul (MNTR_CHARGE_SPEED, finesine[angle]); self->special1 = TICRATE/2; // Charge duration } - else if (target->z == target->floorz + else if (target->Z() == target->floorz && dist < 9*64*FRACUNIT && pr_minotaurdecide() < (friendly ? 100 : 220)) { // Floor fire attack @@ -244,7 +244,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) { type = PClass::FindClass ("PunchPuff"); } - puff = Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + puff = Spawn (type, self->Pos(), ALLOW_REPLACE); puff->velz = 2*FRACUNIT; self->special1--; } @@ -285,7 +285,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); return; } - z = self->z + 40*FRACUNIT; + z = self->Z() + 40*FRACUNIT; const PClass *fx = PClass::FindClass("MinotaurFX1"); if (fx) { @@ -369,10 +369,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) AActor *mo; fixed_t x, y; - self->z = self->floorz; - x = self->x + (pr_fire.Random2 () << 10); - y = self->y + (pr_fire.Random2 () << 10); - mo = Spawn("MinotaurFX3", x, y, self->floorz, ALLOW_REPLACE); + self->SetZ(self->floorz); + fixedvec2 pos = self->Vec2Offset( + (pr_fire.Random2 () << 10), + (pr_fire.Random2 () << 10)); + mo = Spawn("MinotaurFX3", pos.x, pos.y, self->floorz, ALLOW_REPLACE); mo->target = self->target; mo->velx = 1; // Force block checking P_CheckMissileSpawn (mo, self->radius); diff --git a/src/p_local.h b/src/p_local.h index 8c4a94bfc3..4e2172a525 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -148,6 +148,10 @@ void P_ExplodeMissile (AActor *missile, line_t *explodeline, AActor *target); AActor *P_SpawnMissile (AActor* source, AActor* dest, const PClass *type, AActor* owner = NULL); AActor *P_SpawnMissileZ (AActor* source, fixed_t z, AActor* dest, const PClass *type); AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, const PClass *type, bool checkspawn = true, AActor *owner = NULL); +inline AActor *P_SpawnMissileXYZ(const fixedvec3 &pos, AActor *source, AActor *dest, const PClass *type, bool checkspawn = true, AActor *owner = NULL) +{ + return P_SpawnMissileXYZ(pos.x, pos.y, pos.z, source, dest, type, checkspawn, owner); +} AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, angle_t angle, fixed_t velz); AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed); AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz);