- Duke: Wrap calls that get player_struct::PlayerOldPosition.Z.

This commit is contained in:
Mitchell Richters 2022-11-15 18:41:04 +11:00 committed by Christoph Oelckers
parent 830480b8b9
commit e4dd69f5b0
6 changed files with 16 additions and 12 deletions

View file

@ -4437,7 +4437,7 @@ void movefta(void)
{
double r1 = zrand(32);
double r2 = zrand(52);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].PlayerOldPosition.Z - r1 }, ps[p].cursector);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].posoldZget() - r1 }, ps[p].cursector);
}
}
else

View file

@ -389,7 +389,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
case PLAYER_OPOSZ:
if (bSet) ps[iPlayer].posoldZset(lValue * zmaptoworld);
else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.Z * (1 / zmaptoworld)), sActor, sPlayer);
else SetGameVarID(lVar2, int(ps[iPlayer].posoldZget() * (1 / zmaptoworld)), sActor, sPlayer);
break;
case PLAYER_PYOFF:

View file

@ -109,7 +109,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang)
double scratch;
int j = findplayer(actor, &scratch);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
}
else
{
@ -165,7 +165,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
if (dist != 0)
zvel = (((ps[j].PlayerOldPosition.Z - spos.Z) * vel) / dist);
zvel = (((ps[j].posoldZget() - spos.Z) * vel) / dist);
if (badguy(actor) && (actor->spr.hitag & face_player_smart) != 0)
sang = actor->spr.angle + mapangle((krand() & 31) - 16);
@ -605,7 +605,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
#if 1
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
#else
// this is for pitch corrected velocity
auto dist = (ps[j].GetActor()->spr.pos - actor->spr.pos).Resized(vel);
@ -712,7 +712,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(DAngle22_5 / 4) - DAngle22_5 / 8;
@ -2043,7 +2043,7 @@ int operateTripbomb(int snum)
auto delta = hit.hitpos.XY() - p->posXY();
if (delta.LengthSquared() < (18.125 * 18.125))
{
p->posZset(p->PlayerOldPosition.Z);
p->posZset(p->posoldZget());
p->vel.Z = 0;
return 1;
}
@ -2585,7 +2585,7 @@ static void operateweapon(int snum, ESyncBits actions)
case TRIPBOMB_WEAPON: // Claymore in NAM
if (p->kickback_pic < 4)
{
p->posZset(p->PlayerOldPosition.Z);
p->posZset(p->posoldZget());
p->vel.Z = 0;
if (p->kickback_pic == 3)
fi.shoot(pact, HANDHOLDINGLASER);

View file

@ -526,7 +526,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8. - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;
@ -623,7 +623,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
}
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(22.5 / 4) - DAngle22_5 / 8;
@ -758,7 +758,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at
ang += DAngle22_5/8 - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;

View file

@ -436,7 +436,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1))
{
p->posZset(p->PlayerOldPosition.Z);
p->posZset(p->posoldZget());
p->vel.Z = 0;
}
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))

View file

@ -418,6 +418,10 @@ struct player_struct
{
PlayerOldPosition.Z = val;
}
double posoldZget()
{
return PlayerOldPosition.Z;
}
};
struct Cycler