mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- yet more refactoring.
Note about A_SkelMissile: The direct change of the missile's position was changed to use SetOrigin. If this is later supposed to be portal-aware, such direct coordinate changes are a no-go to ensure that everything is properly maintained.
This commit is contained in:
parent
2b5e5b6bc3
commit
57ab1387f2
11 changed files with 59 additions and 51 deletions
18
src/actor.h
18
src/actor.h
|
@ -1247,6 +1247,11 @@ public:
|
||||||
{
|
{
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
fixedvec3 Pos() const
|
||||||
|
{
|
||||||
|
fixedvec3 ret = { X(), Y(), Z() };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
fixed_t Top() const
|
fixed_t Top() const
|
||||||
{
|
{
|
||||||
return z + height;
|
return z + height;
|
||||||
|
@ -1256,6 +1261,19 @@ public:
|
||||||
z = newz;
|
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)
|
||||||
|
{
|
||||||
|
x = xx;
|
||||||
|
y = yy;
|
||||||
|
}
|
||||||
|
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
|
||||||
|
{
|
||||||
|
x = xx;
|
||||||
|
y = yy;
|
||||||
|
z = zz;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FActorIterator
|
class FActorIterator
|
||||||
|
|
|
@ -2319,10 +2319,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const AActor *def = GetDefaultByType (typeinfo);
|
const AActor *def = GetDefaultByType (typeinfo);
|
||||||
fixedvec3 spawnpos = source->Vec3Offset(
|
fixedvec3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->angle, 8 * FRACUNIT);
|
||||||
FixedMul (def->radius * 2 + source->radius, finecosine[source->angle>>ANGLETOFINESHIFT]),
|
|
||||||
FixedMul (def->radius * 2 + source->radius, finesine[source->angle>>ANGLETOFINESHIFT]),
|
|
||||||
8 * FRACUNIT);
|
|
||||||
|
|
||||||
AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE);
|
AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE);
|
||||||
if (spawned != NULL)
|
if (spawned != NULL)
|
||||||
|
|
|
@ -82,8 +82,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget)
|
||||||
|
|
||||||
A_FaceTarget (self);
|
A_FaceTarget (self);
|
||||||
|
|
||||||
fog = Spawn (fire, self->target->X(), self->target->Y(),
|
fog = Spawn (fire, self->target->Pos(), ALLOW_REPLACE);
|
||||||
self->target->Z(), ALLOW_REPLACE);
|
|
||||||
|
|
||||||
self->tracer = fog;
|
self->tracer = fog;
|
||||||
fog->target = self;
|
fog->target = self;
|
||||||
|
|
|
@ -185,7 +185,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound)
|
||||||
|
|
||||||
if (spawntype != NULL)
|
if (spawntype != NULL)
|
||||||
{
|
{
|
||||||
fog = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE);
|
fog = Spawn (spawntype, targ->Pos(), ALLOW_REPLACE);
|
||||||
if (fog != NULL) S_Sound (fog, CHAN_BODY, sound, 1, ATTN_NORM);
|
if (fog != NULL) S_Sound (fog, CHAN_BODY, sound, 1, ATTN_NORM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound)
|
||||||
spawntype = PClass::FindClass(SpawnName);
|
spawntype = PClass::FindClass(SpawnName);
|
||||||
if (spawntype != NULL)
|
if (spawntype != NULL)
|
||||||
{
|
{
|
||||||
newmobj = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE);
|
newmobj = Spawn (spawntype, targ->Pos(), ALLOW_REPLACE);
|
||||||
if (newmobj != NULL)
|
if (newmobj != NULL)
|
||||||
{
|
{
|
||||||
// Make the new monster hate what the boss eye hates
|
// Make the new monster hate what the boss eye hates
|
||||||
|
|
|
@ -153,9 +153,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom)
|
||||||
for (j = -n; j <= n; j += 8)
|
for (j = -n; j <= n; j += 8)
|
||||||
{
|
{
|
||||||
AActor *mo;
|
AActor *mo;
|
||||||
target->x = self->X() + (i << FRACBITS); // Aim in many directions from source
|
target->SetXYZ(
|
||||||
target->y = self->Y() + (j << FRACBITS);
|
self->X() + (i << FRACBITS), // Aim in many directions from source
|
||||||
target->z = self->Z() + (P_AproxDistance(i,j) * vrange); // Aim up fairly high
|
self->Y() + (j << FRACBITS),
|
||||||
|
self->Z() + (P_AproxDistance(i,j) * vrange)); // Aim up fairly high
|
||||||
if ((flags & MSF_Classic) || // Flag explicitely set, or no flags and compat options
|
if ((flags & MSF_Classic) || // Flag explicitely set, or no flags and compat options
|
||||||
(flags == 0 && (self->state->DefineFlags & SDF_DEHACKED) && (i_compatflags & COMPATF_MUSHROOM)))
|
(flags == 0 && (self->state->DefineFlags & SDF_DEHACKED) && (i_compatflags & COMPATF_MUSHROOM)))
|
||||||
{ // Use old function for MBF compatibility
|
{ // Use old function for MBF compatibility
|
||||||
|
|
|
@ -26,13 +26,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
A_FaceTarget (self);
|
A_FaceTarget (self);
|
||||||
missile = P_SpawnMissileZ (self, self->z + 48*FRACUNIT,
|
missile = P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT,
|
||||||
self->target, PClass::FindClass("RevenantTracer"));
|
self->target, PClass::FindClass("RevenantTracer"));
|
||||||
|
|
||||||
if (missile != NULL)
|
if (missile != NULL)
|
||||||
{
|
{
|
||||||
missile->x += missile->velx;
|
missile->SetOrigin(missile->X() + missile->velx, missile->Y() + missile->vely, missile->Z(), false);
|
||||||
missile->y += missile->vely;
|
|
||||||
missile->tracer = self->target;
|
missile->tracer = self->target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,10 +59,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// spawn a puff of smoke behind the rocket
|
// spawn a puff of smoke behind the rocket
|
||||||
P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->x, self->y, self->z, 0, 3);
|
P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->X(), self->Y(), self->Z(), 0, 3);
|
||||||
|
|
||||||
smoke = Spawn ("RevenantTracerSmoke", self->x - self->velx,
|
smoke = Spawn ("RevenantTracerSmoke", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE);
|
||||||
self->y - self->vely, self->z, ALLOW_REPLACE);
|
|
||||||
|
|
||||||
smoke->velz = FRACUNIT;
|
smoke->velz = FRACUNIT;
|
||||||
smoke->tics -= pr_tracer()&3;
|
smoke->tics -= pr_tracer()&3;
|
||||||
|
@ -109,11 +107,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -140,20 +140,20 @@ void P_DSparilTeleport (AActor *actor)
|
||||||
DSpotState *state = DSpotState::GetSpotState();
|
DSpotState *state = DSpotState::GetSpotState();
|
||||||
if (state == NULL) return;
|
if (state == NULL) return;
|
||||||
|
|
||||||
spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->x, actor->y, 128*FRACUNIT, 0);
|
spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->X(), actor->Y(), 128*FRACUNIT, 0);
|
||||||
if (spot == NULL) return;
|
if (spot == NULL) return;
|
||||||
|
|
||||||
prevX = actor->x;
|
prevX = actor->X();
|
||||||
prevY = actor->y;
|
prevY = actor->Y();
|
||||||
prevZ = actor->z;
|
prevZ = actor->Z();
|
||||||
if (P_TeleportMove (actor, spot->x, spot->y, spot->z, false))
|
if (P_TeleportMove (actor, spot->X(), spot->Y(), spot->Z(), false))
|
||||||
{
|
{
|
||||||
mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE);
|
mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE);
|
||||||
if (mo) mo->Translation = actor->Translation;
|
if (mo) mo->Translation = actor->Translation;
|
||||||
S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
||||||
actor->SetState (actor->FindState("Teleport"));
|
actor->SetState (actor->FindState("Teleport"));
|
||||||
S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
|
||||||
actor->z = actor->floorz;
|
actor->SetZ(actor->floorz, false);
|
||||||
actor->angle = spot->angle;
|
actor->angle = spot->angle;
|
||||||
actor->velx = actor->vely = actor->velz = 0;
|
actor->velx = actor->vely = actor->velz = 0;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark)
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
mo = Spawn("Sorcerer2FXSpark", self->x, self->y, self->z, ALLOW_REPLACE);
|
mo = Spawn("Sorcerer2FXSpark", self->Pos(), ALLOW_REPLACE);
|
||||||
mo->velx = pr_bluespark.Random2() << 9;
|
mo->velx = pr_bluespark.Random2() << 9;
|
||||||
mo->vely = pr_bluespark.Random2() << 9;
|
mo->vely = pr_bluespark.Random2() << 9;
|
||||||
mo->velz = FRACUNIT + (pr_bluespark()<<8);
|
mo->velz = FRACUNIT + (pr_bluespark()<<8);
|
||||||
|
|
|
@ -47,8 +47,8 @@ bool AArtiTomeOfPower::Use (bool pickup)
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb)
|
DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb)
|
||||||
{
|
{
|
||||||
self->z += 32*FRACUNIT;
|
self->SetZ(self->Z() + 32*FRACUNIT, false);
|
||||||
self->PrevZ = self->z; // no interpolation!
|
self->PrevZ = self->Z(); // no interpolation!
|
||||||
self->RenderStyle = STYLE_Add;
|
self->RenderStyle = STYLE_Add;
|
||||||
self->alpha = FRACUNIT;
|
self->alpha = FRACUNIT;
|
||||||
P_RadiusAttack (self, self->target, 128, 128, self->DamageType, RADF_HURTSOURCE);
|
P_RadiusAttack (self, self->target, 128, 128, self->DamageType, RADF_HURTSOURCE);
|
||||||
|
@ -69,9 +69,7 @@ bool AArtiTimeBomb::Use (bool pickup)
|
||||||
{
|
{
|
||||||
angle_t angle = Owner->angle >> ANGLETOFINESHIFT;
|
angle_t angle = Owner->angle >> ANGLETOFINESHIFT;
|
||||||
AActor *mo = Spawn("ActivatedTimeBomb",
|
AActor *mo = Spawn("ActivatedTimeBomb",
|
||||||
Owner->x + 24*finecosine[angle],
|
Vec3Angle(24*FRACUNIT, Owner->angle, - Owner->floorclip), ALLOW_REPLACE);
|
||||||
Owner->y + 24*finesine[angle],
|
|
||||||
Owner->z - Owner->floorclip, ALLOW_REPLACE);
|
|
||||||
mo->target = Owner;
|
mo->target = Owner;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1220,9 +1220,7 @@ void G_FinishTravel ()
|
||||||
pawn->angle = pawndup->angle;
|
pawn->angle = pawndup->angle;
|
||||||
pawn->pitch = pawndup->pitch;
|
pawn->pitch = pawndup->pitch;
|
||||||
}
|
}
|
||||||
pawn->x = pawndup->x;
|
pawn->SetXYZ(pawndup->X(), pawndup->Y(), pawndup->Z());
|
||||||
pawn->y = pawndup->y;
|
|
||||||
pawn->z = pawndup->z;
|
|
||||||
pawn->velx = pawndup->velx;
|
pawn->velx = pawndup->velx;
|
||||||
pawn->vely = pawndup->vely;
|
pawn->vely = pawndup->vely;
|
||||||
pawn->velz = pawndup->velz;
|
pawn->velz = pawndup->velz;
|
||||||
|
|
|
@ -451,9 +451,7 @@ void P_RunEffect (AActor *actor, int effects)
|
||||||
{
|
{
|
||||||
// Grenade trail
|
// Grenade trail
|
||||||
|
|
||||||
fixedvec3 pos = actor->Vec3Offset(
|
fixedvec3 pos = actor->Vec3Angle(-actor->radius * 2, moveangle,
|
||||||
-FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2),
|
|
||||||
-FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2),
|
|
||||||
-(actor->height >> 3) * (actor->velz >> 16) + (2 * actor->height) / 3);
|
-(actor->height >> 3) * (actor->velz >> 16) + (2 * actor->height) / 3);
|
||||||
|
|
||||||
P_DrawSplash2 (6, pos.x, pos.y, pos.z,
|
P_DrawSplash2 (6, pos.x, pos.y, pos.z,
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog,
|
||||||
}
|
}
|
||||||
while (spot != NULL)
|
while (spot != NULL)
|
||||||
{
|
{
|
||||||
mobj = Spawn (kind, spot->X(), spot->Y(), spot->Z(), ALLOW_REPLACE);
|
mobj = Spawn (kind, spot->Pos(), ALLOW_REPLACE);
|
||||||
|
|
||||||
if (mobj != NULL)
|
if (mobj != NULL)
|
||||||
{
|
{
|
||||||
|
@ -123,11 +123,11 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
|
||||||
{
|
{
|
||||||
fixed_t oldx, oldy, oldz;
|
fixed_t oldx, oldy, oldz;
|
||||||
|
|
||||||
oldx = source->x;
|
oldx = source->X();
|
||||||
oldy = source->y;
|
oldy = source->Y();
|
||||||
oldz = source->z;
|
oldz = source->Z();
|
||||||
|
|
||||||
source->SetOrigin (x, y, z);
|
source->SetOrigin (x, y, z, false);
|
||||||
if (P_TestMobjLocation (source))
|
if (P_TestMobjLocation (source))
|
||||||
{
|
{
|
||||||
if (fog)
|
if (fog)
|
||||||
|
@ -146,7 +146,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source->SetOrigin (oldx, oldy, oldz);
|
source->SetOrigin (oldx, oldy, oldz, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fixed_t z = spot->z;
|
fixed_t z = spot->Z();
|
||||||
if (defflags3 & MF3_FLOORHUGGER)
|
if (defflags3 & MF3_FLOORHUGGER)
|
||||||
{
|
{
|
||||||
z = ONFLOORZ;
|
z = ONFLOORZ;
|
||||||
|
@ -231,7 +231,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
|
||||||
{
|
{
|
||||||
z -= spot->floorclip;
|
z -= spot->floorclip;
|
||||||
}
|
}
|
||||||
mobj = Spawn (kind, spot->x, spot->y, z, ALLOW_REPLACE);
|
mobj = Spawn (kind, spot->X(), spot->Y(), z, ALLOW_REPLACE);
|
||||||
|
|
||||||
if (mobj)
|
if (mobj)
|
||||||
{
|
{
|
||||||
|
@ -254,8 +254,9 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
|
||||||
|
|
||||||
if (targ != NULL)
|
if (targ != NULL)
|
||||||
{
|
{
|
||||||
fixed_t spot[3] = { targ->x, targ->y, targ->z+targ->height/2 };
|
fixedvec3 vect = mobj->Vec3To(targ);
|
||||||
FVector3 aim(float(spot[0] - mobj->x), float(spot[1] - mobj->y), float(spot[2] - mobj->z));
|
vect.z += targ->height / 2;
|
||||||
|
FVector3 aim = vect;
|
||||||
|
|
||||||
if (leadTarget && speed > 0 && (targ->velx | targ->vely | targ->velz))
|
if (leadTarget && speed > 0 && (targ->velx | targ->vely | targ->velz))
|
||||||
{
|
{
|
||||||
|
@ -435,7 +436,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser)
|
||||||
thing->flags |= MF_SOLID;
|
thing->flags |= MF_SOLID;
|
||||||
thing->height = info->height; // [RH] Use real height
|
thing->height = info->height; // [RH] Use real height
|
||||||
thing->radius = info->radius; // [RH] Use real radius
|
thing->radius = info->radius; // [RH] Use real radius
|
||||||
if (!P_CheckPosition (thing, thing->x, thing->y))
|
if (!P_CheckPosition (thing, thing->X(), thing->Y()))
|
||||||
{
|
{
|
||||||
thing->flags = oldflags;
|
thing->flags = oldflags;
|
||||||
thing->radius = oldradius;
|
thing->radius = oldradius;
|
||||||
|
@ -477,7 +478,7 @@ bool P_Thing_CanRaise(AActor *thing)
|
||||||
thing->height = info->height;
|
thing->height = info->height;
|
||||||
thing->radius = info->radius;
|
thing->radius = info->radius;
|
||||||
|
|
||||||
bool check = P_CheckPosition (thing, thing->x, thing->y);
|
bool check = P_CheckPosition (thing, thing->X(), thing->Y());
|
||||||
|
|
||||||
// Restore checked properties
|
// Restore checked properties
|
||||||
thing->flags = oldflags;
|
thing->flags = oldflags;
|
||||||
|
@ -690,8 +691,8 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
|
||||||
caller = temp;
|
caller = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t oldx = caller->x;
|
fixed_t oldx = caller->X();
|
||||||
fixed_t oldy = caller->y;
|
fixed_t oldy = caller->Y();
|
||||||
fixed_t oldz = caller->z;
|
fixed_t oldz = caller->z;
|
||||||
zofs += FixedMul(reference->height, heightoffset);
|
zofs += FixedMul(reference->height, heightoffset);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue