- Strife game code refactored for coordinates.

This commit is contained in:
Christoph Oelckers 2016-01-19 11:50:07 +01:00
parent c02d922014
commit 9f78bcd1e6
21 changed files with 124 additions and 115 deletions

View file

@ -1252,6 +1252,15 @@ public:
fixedvec3 ret = { X(), Y(), Z() }; fixedvec3 ret = { X(), Y(), Z() };
return ret; return ret;
} }
fixedvec3 InterpolatedPosition(fixed_t ticFrac) const
{
fixedvec3 ret;
ret.x = PrevX + FixedMul (ticFrac, X() - PrevX);
ret.y = PrevY + FixedMul (ticFrac, Y() - PrevY);
ret.z = PrevZ + FixedMul (ticFrac, Z() - PrevZ);
return ret;
}
fixedvec3 PosPlusZ(fixed_t zadd) const fixedvec3 PosPlusZ(fixed_t zadd) const
{ {
fixedvec3 ret = { X(), Y(), Z() + zadd }; fixedvec3 ret = { X(), Y(), Z() + zadd };

View file

@ -826,9 +826,9 @@ static void DrawCoordinates(player_t * CPlayer)
if (!map_point_coordinates || !automapactive) if (!map_point_coordinates || !automapactive)
{ {
x=CPlayer->mo->x; x=CPlayer->mo->X();
y=CPlayer->mo->y; y=CPlayer->mo->Y();
z=CPlayer->mo->z; z=CPlayer->mo->Z();
} }
else else
{ {

View file

@ -1286,7 +1286,8 @@ void DBaseStatusBar::Draw (EHudState state)
y -= height * 2; y -= height * 2;
} }
value = &CPlayer->mo->z; fixedvec3 pos = CPlayer->mo->Pos();
value = &pos.z;
for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i) for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i)
{ {
mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS);

View file

@ -22,7 +22,7 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target);
DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall)
{ {
AActor *foo = Spawn("AlienChunkSmall", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); AActor *foo = Spawn("AlienChunkSmall", self->PosPlusZ(10*FRACUNIT), ALLOW_REPLACE);
if (foo != NULL) if (foo != NULL)
{ {
@ -40,7 +40,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall)
DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge) DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge)
{ {
AActor *foo = Spawn("AlienChunkLarge", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); AActor *foo = Spawn("AlienChunkLarge", self->PosPlusZ(10*FRACUNIT), ALLOW_REPLACE);
if (foo != NULL) if (foo != NULL)
{ {
@ -62,7 +62,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack)
if (self->target == NULL) if (self->target == NULL)
return; return;
AActor *foo = Spawn("SpectralLightningV2", self->x, self->y, self->z + 32*FRACUNIT, ALLOW_REPLACE); AActor *foo = Spawn("SpectralLightningV2", self->PosPlusZ(32*FRACUNIT), ALLOW_REPLACE);
foo->velz = -12*FRACUNIT; foo->velz = -12*FRACUNIT;
foo->target = self; foo->target = self;

View file

@ -80,22 +80,22 @@ AInventory *ACoin::CreateTossable ()
if (Amount >= 50) if (Amount >= 50)
{ {
Amount -= 50; Amount -= 50;
tossed = static_cast<ACoin*>(Spawn("Gold50", Owner->x, Owner->y, Owner->z, NO_REPLACE)); tossed = static_cast<ACoin*>(Spawn("Gold50", Owner->Pos(), NO_REPLACE));
} }
else if (Amount >= 25) else if (Amount >= 25)
{ {
Amount -= 25; Amount -= 25;
tossed = static_cast<ACoin*>(Spawn("Gold25", Owner->x, Owner->y, Owner->z, NO_REPLACE)); tossed = static_cast<ACoin*>(Spawn("Gold25", Owner->Pos(), NO_REPLACE));
} }
else if (Amount >= 10) else if (Amount >= 10)
{ {
Amount -= 10; Amount -= 10;
tossed = static_cast<ACoin*>(Spawn("Gold10", Owner->x, Owner->y, Owner->z, NO_REPLACE)); tossed = static_cast<ACoin*>(Spawn("Gold10", Owner->Pos(), NO_REPLACE));
} }
else if (Amount > 1 || (ItemFlags & IF_KEEPDEPLETED)) else if (Amount > 1 || (ItemFlags & IF_KEEPDEPLETED))
{ {
Amount -= 1; Amount -= 1;
tossed = static_cast<ACoin*>(Spawn("Coin", Owner->x, Owner->y, Owner->z, NO_REPLACE)); tossed = static_cast<ACoin*>(Spawn("Coin", Owner->Pos(), NO_REPLACE));
} }
else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED) else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED)
{ {

View file

@ -27,18 +27,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose)
{ {
A_FaceTarget (self); A_FaceTarget (self);
self->angle -= ANGLE_180/16; self->angle -= ANGLE_180/16;
P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile"));
} }
else else
{ {
if (P_CheckMissileRange (self)) if (P_CheckMissileRange (self))
{ {
A_FaceTarget (self); A_FaceTarget (self);
P_SpawnMissileZAimed (self, self->z + 56*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); P_SpawnMissileZAimed (self, self->Z() + 56*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile"));
self->angle -= ANGLE_45/32; self->angle -= ANGLE_45/32;
P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile"));
self->angle += ANGLE_45/16; self->angle += ANGLE_45/16;
P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile"));
self->angle -= ANGLE_45/16; self->angle -= ANGLE_45/16;
self->reactiontime += 15; self->reactiontime += 15;
} }
@ -49,7 +49,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose)
DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft)
{ {
self->angle += ANGLE_90/16; self->angle += ANGLE_90/16;
AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile"));
if (misl != NULL) if (misl != NULL)
{ {
misl->velz += FRACUNIT; misl->velz += FRACUNIT;
@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft)
DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight) DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight)
{ {
self->angle -= ANGLE_90/16; self->angle -= ANGLE_90/16;
AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile"));
if (misl != NULL) if (misl != NULL)
{ {
misl->velz += FRACUNIT; misl->velz += FRACUNIT;

View file

@ -24,7 +24,7 @@ void A_SpectralMissile (AActor *self, const char *missilename)
{ {
if (self->target != NULL) if (self->target != NULL)
{ {
AActor *missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT),
self, self->target, PClass::FindClass(missilename), false); self, self->target, PClass::FindClass(missilename), false);
if (missile != NULL) if (missile != NULL)
{ {
@ -70,7 +70,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityAttack)
DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity)
{ {
AActor *entity = Spawn("EntityBoss", self->x, self->y, self->z + 70*FRACUNIT, ALLOW_REPLACE); AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70*FRACUNIT), ALLOW_REPLACE);
if (entity != NULL) if (entity != NULL)
{ {
entity->angle = self->angle; entity->angle = self->angle;
@ -89,13 +89,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath)
AActor *spot = self->tracer; AActor *spot = self->tracer;
if (spot == NULL) spot = self; if (spot == NULL) spot = self;
fixed_t SpawnX = spot->x; fixedvec3 pos = spot->Vec3Angle(secondRadius, self->angle, self->tracer? 70*FRACUNIT : 0);
fixed_t SpawnY = spot->y;
fixed_t SpawnZ = spot->z + (self->tracer? 70*FRACUNIT : 0);
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), second = Spawn("EntitySecond", pos, ALLOW_REPLACE);
SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE);
second->CopyFriendliness(self, true); second->CopyFriendliness(self, true);
//second->target = self->target; //second->target = self->target;
A_FaceTarget (second); A_FaceTarget (second);
@ -103,18 +100,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath)
second->velx += FixedMul (finecosine[an], 320000); second->velx += FixedMul (finecosine[an], 320000);
second->vely += FixedMul (finesine[an], 320000); second->vely += FixedMul (finesine[an], 320000);
pos = spot->Vec3Angle(secondRadius, self->angle + ANGLE_90, self->tracer? 70*FRACUNIT : 0);
an = (self->angle + ANGLE_90) >> ANGLETOFINESHIFT; an = (self->angle + ANGLE_90) >> ANGLETOFINESHIFT;
second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), second = Spawn("EntitySecond", pos, ALLOW_REPLACE);
SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE);
second->CopyFriendliness(self, true); second->CopyFriendliness(self, true);
//second->target = self->target; //second->target = self->target;
second->velx = FixedMul (secondRadius, finecosine[an]) << 2; second->velx = FixedMul (secondRadius, finecosine[an]) << 2;
second->vely = FixedMul (secondRadius, finesine[an]) << 2; second->vely = FixedMul (secondRadius, finesine[an]) << 2;
A_FaceTarget (second); A_FaceTarget (second);
pos = spot->Vec3Angle(secondRadius, self->angle - ANGLE_90, self->tracer? 70*FRACUNIT : 0);
an = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; an = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), second = Spawn("EntitySecond", pos, ALLOW_REPLACE);
SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE);
second->CopyFriendliness(self, true); second->CopyFriendliness(self, true);
//second->target = self->target; //second->target = self->target;
second->velx = FixedMul (secondRadius, finecosine[an]) << 2; second->velx = FixedMul (secondRadius, finecosine[an]) << 2;

View file

@ -35,9 +35,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide)
{ {
self->SetState (self->FindState("Grenade")); self->SetState (self->FindState("Grenade"));
} }
if (self->target->z != self->z) if (self->target->Z() != self->Z())
{ {
if (self->z + self->height + 54*FRACUNIT < self->ceilingz) if (self->Top() + 54*FRACUNIT < self->ceilingz)
{ {
self->SetState (self->FindState("Jump")); self->SetState (self->FindState("Jump"));
} }
@ -53,20 +53,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack)
A_FaceTarget (self); A_FaceTarget (self);
self->z += 32*FRACUNIT; self->AddZ(32*FRACUNIT);
self->angle -= ANGLE_45/32; self->angle -= ANGLE_45/32;
proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot")); proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindClass("InquisitorShot"));
if (proj != NULL) if (proj != NULL)
{ {
proj->velz += 9*FRACUNIT; proj->velz += 9*FRACUNIT;
} }
self->angle += ANGLE_45/16; self->angle += ANGLE_45/16;
proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot")); proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindClass("InquisitorShot"));
if (proj != NULL) if (proj != NULL)
{ {
proj->velz += 16*FRACUNIT; proj->velz += 16*FRACUNIT;
} }
self->z -= 32*FRACUNIT; self->AddZ(-32*FRACUNIT);
} }
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
return; return;
S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM);
self->z += 64*FRACUNIT; self->AddZ(64*FRACUNIT);
A_FaceTarget (self); A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
speed = self->Speed * 2/3; speed = self->Speed * 2/3;
@ -91,7 +91,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
{ {
dist = 1; dist = 1;
} }
self->velz = (self->target->z - self->z) / dist; self->velz = (self->target->Z() - self->Z()) / dist;
self->reactiontime = 60; self->reactiontime = 60;
self->flags |= MF_NOGRAVITY; self->flags |= MF_NOGRAVITY;
} }
@ -102,7 +102,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand)
if (self->reactiontime < 0 || if (self->reactiontime < 0 ||
self->velx == 0 || self->velx == 0 ||
self->vely == 0 || self->vely == 0 ||
self->z <= self->floorz) self->Z() <= self->floorz)
{ {
self->SetState (self->SeeState); self->SetState (self->SeeState);
self->reactiontime = 0; self->reactiontime = 0;
@ -119,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand)
DEFINE_ACTION_FUNCTION(AActor, A_TossArm) DEFINE_ACTION_FUNCTION(AActor, A_TossArm)
{ {
AActor *foo = Spawn("InquisitorArm", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE);
foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22); foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22);
foo->velx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3; foo->velx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3;
foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3; foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3;

View file

@ -21,16 +21,14 @@ IMPLEMENT_CLASS (ALoreShot)
int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype)
{ {
FVector3 thrust;
if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST)) if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST))
{ {
thrust.X = float(target->x - victim->x); fixedvec3 fixthrust = victim->Vec3To(target);
thrust.Y = float(target->y - victim->y); TVector3<double> thrust(fixthrust.x, fixthrust.y, fixthrust.z);
thrust.Z = float(target->z - victim->z);
thrust.MakeUnit(); thrust.MakeUnit();
thrust *= float((255*50*FRACUNIT) / (victim->Mass ? victim->Mass : 1)); thrust *= double((255*50*FRACUNIT) / (victim->Mass ? victim->Mass : 1));
victim->velx += fixed_t(thrust.X); victim->velx += fixed_t(thrust.X);
victim->vely += fixed_t(thrust.Y); victim->vely += fixed_t(thrust.Y);
@ -42,7 +40,7 @@ int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype)
DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain) DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain)
{ {
S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM); S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM);
Spawn("LoreShot2", self->x, self->y, self->z, ALLOW_REPLACE); Spawn("LoreShot2", self->Pos(), ALLOW_REPLACE);
Spawn("LoreShot2", self->x - (self->velx >> 1), self->y - (self->vely >> 1), self->z - (self->velz >> 1), ALLOW_REPLACE); Spawn("LoreShot2", self->Vec3Offset(-(self->velx >> 1), -(self->vely >> 1), -(self->velz >> 1)), ALLOW_REPLACE);
Spawn("LoreShot2", self->x - self->velx, self->y - self->vely, self->z - self->velz, ALLOW_REPLACE); Spawn("LoreShot2", self->Vec3Offset(-self->velx, -self->vely, -self->velz), ALLOW_REPLACE);
} }

View file

@ -104,7 +104,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning)
if (self->target == NULL) if (self->target == NULL)
return; return;
spot = Spawn("SpectralLightningSpot", self->target->x, self->target->y, self->target->floorz, ALLOW_REPLACE); spot = Spawn("SpectralLightningSpot", self->target->X(), self->target->Y(), self->target->floorz, ALLOW_REPLACE);
if (spot != NULL) if (spot != NULL)
{ {
spot->threshold = 25; spot->threshold = 25;
@ -122,7 +122,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning)
DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase)
{ {
AActor *foo = Spawn("ProgrammerBase", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE);
if (foo != NULL) if (foo != NULL)
{ {
foo->angle = self->angle + ANGLE_180 + (pr_prog.Random2() << 22); foo->angle = self->angle + ANGLE_180 + (pr_prog.Random2() << 22);

View file

@ -75,8 +75,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
AActor *rebel; AActor *rebel;
angle_t an; angle_t an;
rebel = Spawn("Rebel1", self->x, self->y, self->floorz, ALLOW_REPLACE); rebel = Spawn("Rebel1", self->X(), self->Y(), self->floorz, ALLOW_REPLACE);
if (!P_TryMove (rebel, rebel->x, rebel->y, true)) if (!P_TryMove (rebel, rebel->X(), rebel->Y(), true))
{ {
rebel->Destroy (); rebel->Destroy ();
return; return;
@ -112,7 +112,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
rebel->SetState (rebel->SeeState); rebel->SetState (rebel->SeeState);
rebel->angle = self->angle; rebel->angle = self->angle;
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
Spawn<ATeleportFog> (rebel->x + 20*finecosine[an], rebel->y + 20*finesine[an], rebel->z + TELEFOGHEIGHT, ALLOW_REPLACE); Spawn<ATeleportFog> (rebel->Vec3Offset(20*finecosine[an], 20*finesine[an], TELEFOGHEIGHT), ALLOW_REPLACE);
if (--self->health < 0) if (--self->health < 0)
{ {
self->SetState(self->FindState(NAME_Death)); self->SetState(self->FindState(NAME_Death));

View file

@ -27,7 +27,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob)
{ {
minz = maxz; minz = maxz;
} }
if (minz < self->z) if (minz < self->Z())
{ {
self->velz -= FRACUNIT; self->velz -= FRACUNIT;
} }
@ -35,7 +35,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob)
{ {
self->velz += FRACUNIT; self->velz += FRACUNIT;
} }
self->reactiontime = (minz >= self->z) ? 4 : 0; self->reactiontime = (minz >= self->Z()) ? 4 : 0;
} }
DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack)
@ -48,16 +48,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack)
return; return;
} }
missile = P_SpawnMissileZAimed (self, self->z + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2")); missile = P_SpawnMissileZAimed (self, self->Z() + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2"));
if (missile != NULL && (missile->velx | missile->vely) != 0) if (missile != NULL && (missile->velx | missile->vely) != 0)
{ {
for (int i = 8; i > 1; --i) for (int i = 8; i > 1; --i)
{ {
trail = Spawn("SentinelFX1", trail = Spawn("SentinelFX1",
self->x + FixedMul (missile->radius * i, finecosine[missile->angle >> ANGLETOFINESHIFT]), self->Vec3Angle(missile->radius*i, missile->angle, (missile->velz / 4 * i)), ALLOW_REPLACE);
self->y + FixedMul (missile->radius * i, finesine[missile->angle >> ANGLETOFINESHIFT]),
missile->z + (missile->velz / 4 * i), ALLOW_REPLACE);
if (trail != NULL) if (trail != NULL)
{ {
trail->target = self; trail->target = self;
@ -67,7 +65,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack)
P_CheckMissileSpawn (trail, self->radius); P_CheckMissileSpawn (trail, self->radius);
} }
} }
missile->z += missile->velz >> 2; missile->AddZ(missile->velz >> 2);
} }
} }

View file

@ -28,7 +28,7 @@ void ASpectralMonster::Touch (AActor *toucher)
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail)
{ {
AActor *foo = Spawn("SpectralLightningHTail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE);
foo->angle = self->angle; foo->angle = self->angle;
foo->FriendPlayer = self->FriendPlayer; foo->FriendPlayer = self->FriendPlayer;
@ -61,17 +61,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning)
self->velx += pr_zap5.Random2(3) << FRACBITS; self->velx += pr_zap5.Random2(3) << FRACBITS;
self->vely += pr_zap5.Random2(3) << FRACBITS; self->vely += pr_zap5.Random2(3) << FRACBITS;
x = self->x + pr_zap5.Random2(3) * FRACUNIT * 50; fixedvec2 pos = self->Vec2Offset(
y = self->y + pr_zap5.Random2(3) * FRACUNIT * 50; pr_zap5.Random2(3) * FRACUNIT * 50,
pr_zap5.Random2(3) * FRACUNIT * 50);
flash = Spawn (self->threshold > 25 ? PClass::FindClass(NAME_SpectralLightningV2) : flash = Spawn (self->threshold > 25 ? PClass::FindClass(NAME_SpectralLightningV2) :
PClass::FindClass(NAME_SpectralLightningV1), x, y, ONCEILINGZ, ALLOW_REPLACE); PClass::FindClass(NAME_SpectralLightningV1), pos.x, pos.y, ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target; flash->target = self->target;
flash->velz = -18*FRACUNIT; flash->velz = -18*FRACUNIT;
flash->FriendPlayer = self->FriendPlayer; flash->FriendPlayer = self->FriendPlayer;
flash = Spawn(NAME_SpectralLightningV2, self->x, self->y, ONCEILINGZ, ALLOW_REPLACE); flash = Spawn(NAME_SpectralLightningV2, self->X(), self->Y(), ONCEILINGZ, ALLOW_REPLACE);
flash->target = self->target; flash->target = self->target;
flash->velz = -18*FRACUNIT; flash->velz = -18*FRACUNIT;
@ -128,11 +129,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2)
} }
if (dest->height >= 56*FRACUNIT) if (dest->height >= 56*FRACUNIT)
{ {
slope = (dest->z+40*FRACUNIT - self->z) / dist; slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist;
} }
else else
{ {
slope = (dest->z + self->height*2/3 - self->z) / dist; slope = (dest->Z() + self->height*2/3 - self->Z()) / dist;
} }
if (slope < self->velz) if (slope < self->velz)
{ {

View file

@ -17,7 +17,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide)
{ {
self->SetState (self->FindState("SeeFloor")); self->SetState (self->FindState("SeeFloor"));
} }
else if (self->ceilingz - self->height > self->z) else if (self->ceilingz > self->Top())
{ {
self->SetState (self->FindState("Drop")); self->SetState (self->FindState("Drop"));
} }

View file

@ -580,7 +580,7 @@ IMPLEMENT_CLASS (AMeat)
DEFINE_ACTION_FUNCTION(AActor, A_TossGib) DEFINE_ACTION_FUNCTION(AActor, A_TossGib)
{ {
const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat";
AActor *gib = Spawn (gibtype, self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); AActor *gib = Spawn (gibtype, self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE);
angle_t an; angle_t an;
int speed; int speed;
@ -628,7 +628,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain)
{ {
sector_t *sec = self->Sector; sector_t *sec = self->Sector;
if (self->z == sec->floorplane.ZatPoint(self)) if (self->Z() == sec->floorplane.ZatPoint(self))
{ {
if (sec->special == Damage_InstantDeath) if (sec->special == Damage_InstantDeath)
{ {
@ -681,7 +681,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns)
DEFINE_ACTION_FUNCTION(AActor, A_DropFire) DEFINE_ACTION_FUNCTION(AActor, A_DropFire)
{ {
AActor *drop = Spawn("FireDroplet", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); AActor *drop = Spawn("FireDroplet", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE);
drop->velz = -FRACUNIT; drop->velz = -FRACUNIT;
P_RadiusAttack (self, self, 64, 64, NAME_Fire, 0); P_RadiusAttack (self, self, 64, 64, NAME_Fire, 0);
} }

View file

@ -360,8 +360,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight)
AActor *trail; AActor *trail;
S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM); S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM);
P_SpawnPuff (self, PClass::FindClass("MiniMissilePuff"), self->x, self->y, self->z, self->angle - ANGLE_180, 2, PF_HITTHING); P_SpawnPuff (self, PClass::FindClass("MiniMissilePuff"), self->Pos(), self->angle - ANGLE_180, 2, PF_HITTHING);
trail = Spawn("RocketTrail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); trail = Spawn("RocketTrail", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE);
if (trail != NULL) if (trail != NULL)
{ {
trail->velz = FRACUNIT; trail->velz = FRACUNIT;
@ -516,10 +516,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave)
self->angle += ANGLE_180; self->angle += ANGLE_180;
// If the torpedo hit the ceiling, it should still spawn the wave // If the torpedo hit the ceiling, it should still spawn the wave
savedz = self->z; savedz = self->Z();
if (wavedef && self->ceilingz - self->z < wavedef->height) if (wavedef && self->ceilingz - self->Z() < wavedef->height)
{ {
self->z = self->ceilingz - wavedef->height; self->SetZ(self->ceilingz - wavedef->height);
} }
for (int i = 0; i < 80; ++i) for (int i = 0; i < 80; ++i)
@ -527,12 +527,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave)
self->angle += ANGLE_45/10; self->angle += ANGLE_45/10;
P_SpawnSubMissile (self, PClass::FindClass("MaulerTorpedoWave"), self->target); P_SpawnSubMissile (self, PClass::FindClass("MaulerTorpedoWave"), self->target);
} }
self->z = savedz; self->SetZ(savedz);
} }
AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target) AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target)
{ {
AActor *other = Spawn (type, source->x, source->y, source->z, ALLOW_REPLACE); AActor *other = Spawn (type, source->Pos(), ALLOW_REPLACE);
if (other == NULL) if (other == NULL)
{ {
@ -619,20 +619,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination)
yofs = -yofs; yofs = -yofs;
} }
fixed_t x = self->x + (xofs << FRACBITS); fixedvec2 pos = self->Vec2Offset(xofs << FRACBITS, yofs << FRACBITS);
fixed_t y = self->y + (yofs << FRACBITS); sector_t * sector = P_PointInSector(pos.x, pos.y);
sector_t * sector = P_PointInSector(x, y);
// The sector's floor is too high so spawn the flame elsewhere. // The sector's floor is too high so spawn the flame elsewhere.
if (sector->floorplane.ZatPoint(x, y) > self->z + self->MaxStepHeight) if (sector->floorplane.ZatPoint(pos.x, pos.y) > self->Z() + self->MaxStepHeight)
{ {
x = self->x; pos.x = self->X();
y = self->y; pos.y = self->Y();
} }
AActor *drop = Spawn<APhosphorousFire> ( AActor *drop = Spawn<APhosphorousFire> (
x, y, pos.x, pos.y,
self->z + 4*FRACUNIT, ALLOW_REPLACE); self->Z() + 4*FRACUNIT, ALLOW_REPLACE);
if (drop != NULL) if (drop != NULL)
{ {
drop->velx = self->velx + ((pr_phburn.Random2 (7)) << FRACBITS); drop->velx = self->velx + ((pr_phburn.Random2 (7)) << FRACBITS);
@ -677,9 +676,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
if (grenadetype != NULL) if (grenadetype != NULL)
{ {
self->z += 32*FRACUNIT; self->AddZ(32*FRACUNIT);
grenade = P_SpawnSubMissile (self, grenadetype, self); grenade = P_SpawnSubMissile (self, grenadetype, self);
self->z -= 32*FRACUNIT; self->AddZ(-32*FRACUNIT);
if (grenade == NULL) if (grenade == NULL)
return; return;
@ -690,15 +689,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
grenade->velz = FixedMul (finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT; grenade->velz = FixedMul (finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT;
fixedvec2 offset;
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
tworadii = self->radius + grenade->radius; tworadii = self->radius + grenade->radius;
grenade->x += FixedMul (finecosine[an], tworadii); offset.x = FixedMul (finecosine[an], tworadii);
grenade->y += FixedMul (finesine[an], tworadii); offset.y = FixedMul (finesine[an], tworadii);
an = self->angle + Angle; an = self->angle + Angle;
an >>= ANGLETOFINESHIFT; an >>= ANGLETOFINESHIFT;
grenade->x += FixedMul (finecosine[an], 15*FRACUNIT); offset.x += FixedMul (finecosine[an], 15*FRACUNIT);
grenade->y += FixedMul (finesine[an], 15*FRACUNIT); offset.y += FixedMul (finesine[an], 15*FRACUNIT);
fixedvec2 newpos = grenade->Vec2Offset(offset.x, offset.y);
grenade->SetOrigin(newpos.x, newpos.y, grenade->Z(), false);
} }
} }
@ -923,7 +927,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1)
P_BulletSlope (self, &linetarget); P_BulletSlope (self, &linetarget);
if (linetarget != NULL) if (linetarget != NULL)
{ {
spot = Spawn("SpectralLightningSpot", linetarget->x, linetarget->y, linetarget->floorz, ALLOW_REPLACE); spot = Spawn("SpectralLightningSpot", linetarget->X(), linetarget->Y(), linetarget->floorz, ALLOW_REPLACE);
if (spot != NULL) if (spot != NULL)
{ {
spot->tracer = linetarget; spot->tracer = linetarget;
@ -931,7 +935,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1)
} }
else else
{ {
spot = Spawn("SpectralLightningSpot", self->x, self->y, self->z, ALLOW_REPLACE); spot = Spawn("SpectralLightningSpot", self->Pos(), ALLOW_REPLACE);
if (spot != NULL) if (spot != NULL)
{ {
spot->velx += 28 * finecosine[self->angle >> ANGLETOFINESHIFT]; spot->velx += 28 * finecosine[self->angle >> ANGLETOFINESHIFT];
@ -989,7 +993,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3)
spot = P_SpawnSubMissile (self, PClass::FindClass("SpectralLightningBall1"), self); spot = P_SpawnSubMissile (self, PClass::FindClass("SpectralLightningBall1"), self);
if (spot != NULL) if (spot != NULL)
{ {
spot->z = self->z + 32*FRACUNIT; spot->SetZ(self->Z() + 32*FRACUNIT);
} }
} }
self->angle -= (ANGLE_180/20)*10; self->angle -= (ANGLE_180/20)*10;

View file

@ -20,10 +20,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
{ {
fixed_t spawnx, spawny; fixed_t spawnx, spawny;
spawnx = self->x + (pr_bang4cloud.Random2() & 3) * 10240; fixedvec3 pos = self->Vec3Offset((pr_bang4cloud.Random2() & 3) * 10240, (pr_bang4cloud.Random2() & 3) * 10240, 0);
spawny = self->y + (pr_bang4cloud.Random2() & 3) * 10240;
Spawn("Bang4Cloud", spawnx, spawny, self->z, ALLOW_REPLACE); Spawn("Bang4Cloud", pos, ALLOW_REPLACE);
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -97,7 +96,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut)
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
foo = Spawn("Rubble1", self->x, self->y, self->z, ALLOW_REPLACE); foo = Spawn("Rubble1", self->Pos(), ALLOW_REPLACE);
if (foo != NULL) if (foo != NULL)
{ {
int t = pr_lightout() & 15; int t = pr_lightout() & 15;

View file

@ -98,8 +98,8 @@ static int WriteTHINGS (FILE *file)
mapthinghexen_t mt = { 0, 0, 0, 0, 0, 0, 0, 0, {0} }; mapthinghexen_t mt = { 0, 0, 0, 0, 0, 0, 0, 0, {0} };
AActor *mo = players[consoleplayer].mo; AActor *mo = players[consoleplayer].mo;
mt.x = LittleShort(short(mo->x >> FRACBITS)); mt.x = LittleShort(short(mo->X() >> FRACBITS));
mt.y = LittleShort(short(mo->y >> FRACBITS)); mt.y = LittleShort(short(mo->Y() >> FRACBITS));
mt.angle = LittleShort(short(MulScale32 (mo->angle >> ANGLETOFINESHIFT, 360))); mt.angle = LittleShort(short(MulScale32 (mo->angle >> ANGLETOFINESHIFT, 360)));
mt.type = LittleShort((short)1); mt.type = LittleShort((short)1);
mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); mt.flags = LittleShort((short)(7|224|MTF_SINGLE));

View file

@ -1224,9 +1224,10 @@ void R_DrawSkyBoxes ()
extralight = 0; extralight = 0;
R_SetVisibility (sky->args[0] * 0.25f); R_SetVisibility (sky->args[0] * 0.25f);
viewx = sky->PrevX + FixedMul(r_TicFrac, sky->x - sky->PrevX); fixedvec3 viewpos = sky->InterpolatedPosition(r_TicFrac);
viewy = sky->PrevY + FixedMul(r_TicFrac, sky->y - sky->PrevY); viewx = viewpos.x;
viewz = sky->PrevZ + FixedMul(r_TicFrac, sky->z - sky->PrevZ); viewy = viewpos.y;
viewz = viewpos.z;
viewangle = savedangle + sky->PrevAngle + FixedMul(r_TicFrac, sky->angle - sky->PrevAngle); viewangle = savedangle + sky->PrevAngle + FixedMul(r_TicFrac, sky->angle - sky->PrevAngle);
R_CopyStackedViewParameters(); R_CopyStackedViewParameters();
@ -1235,8 +1236,8 @@ void R_DrawSkyBoxes ()
{ {
extralight = pl->extralight; extralight = pl->extralight;
R_SetVisibility (pl->visibility); R_SetVisibility (pl->visibility);
viewx = pl->viewx - sky->Mate->x + sky->x; viewx = pl->viewx - sky->Mate->X() + sky->X();
viewy = pl->viewy - sky->Mate->y + sky->y; viewy = pl->viewy - sky->Mate->Y() + sky->Y();
viewz = pl->viewz; viewz = pl->viewz;
viewangle = pl->viewangle; viewangle = pl->viewangle;
} }

View file

@ -670,9 +670,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
} }
// [RH] Interpolate the sprite's position to make it look smooth // [RH] Interpolate the sprite's position to make it look smooth
fx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac);
fy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); fx = pos.x;
fz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ) + thing->GetBobOffset(r_TicFrac); fy = pos.y;
fz = pos.z +thing->GetBobOffset(r_TicFrac);
tex = NULL; tex = NULL;
voxel = NULL; voxel = NULL;
@ -1145,12 +1146,12 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
{ {
if(!(rover->top.plane->a) && !(rover->top.plane->b)) if(!(rover->top.plane->a) && !(rover->top.plane->b))
{ {
if(rover->top.plane->Zat0() <= thing->z) fakefloor = rover; if(rover->top.plane->Zat0() <= thing->Z()) fakefloor = rover;
} }
} }
if(!(rover->bottom.plane->a) && !(rover->bottom.plane->b)) if(!(rover->bottom.plane->a) && !(rover->bottom.plane->b))
{ {
if(rover->bottom.plane->Zat0() >= thing->z + thing->height) fakeceiling = rover; if(rover->bottom.plane->Zat0() >= thing->Top()) fakeceiling = rover;
} }
} }
R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling); R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling);

View file

@ -587,8 +587,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
player - players == consoleplayer && player - players == consoleplayer &&
camera == player->mo && camera == player->mo &&
!demoplayback && !demoplayback &&
iview->nviewx == camera->x && iview->nviewx == camera->X() &&
iview->nviewy == camera->y && iview->nviewy == camera->Y() &&
!(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) && !(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) &&
player->playerstate == PST_LIVE && player->playerstate == PST_LIVE &&
player->mo->reactiontime == 0 && player->mo->reactiontime == 0 &&
@ -839,9 +839,9 @@ void R_SetupFrame (AActor *actor)
} }
else else
{ {
iview->nviewx = camera->x; iview->nviewx = camera->X();
iview->nviewy = camera->y; iview->nviewy = camera->Y();
iview->nviewz = camera->player ? camera->player->viewz : camera->z + camera->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight); iview->nviewz = camera->player ? camera->player->viewz : camera->Z() + camera->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight);
viewsector = camera->Sector; viewsector = camera->Sector;
r_showviewer = false; r_showviewer = false;
} }