From d8a64716803cc3aa87c0cc34e647b23689029837 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 27 Sep 2022 13:09:20 +1000 Subject: [PATCH] - Add `fixedhoriz::Tan()` and replace most `asbuildf()` calls with it. --- source/core/fixedhorizon.h | 1 + source/core/gameinput.h | 12 +++--- source/games/blood/src/blood.h | 2 +- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 26 ++++++------- source/games/duke/src/player_r.cpp | 20 +++++----- source/games/duke/src/player_w.cpp | 4 +- source/games/duke/src/spawn.cpp | 2 +- source/games/exhumed/src/exhumed.h | 2 +- source/games/exhumed/src/gun.cpp | 4 +- source/games/exhumed/src/player.cpp | 2 +- source/games/sw/src/game.h | 2 +- source/games/sw/src/jweapon.cpp | 8 ++-- source/games/sw/src/weapon.cpp | 58 ++++++++++++++--------------- source/games/sw/src/weapon.h | 2 +- 16 files changed, 74 insertions(+), 75 deletions(-) diff --git a/source/core/fixedhorizon.h b/source/core/fixedhorizon.h index 573bb9fff..93c2d02b3 100644 --- a/source/core/fixedhorizon.h +++ b/source/core/fixedhorizon.h @@ -84,6 +84,7 @@ public: constexpr short asbuild() const { return FixedToInt(value); } constexpr double asbuildf() const { return FixedToFloat(value); } constexpr fixed_t asq16() const { return value; } + constexpr double Tan() const { return FixedToFloat<23>(value); } double Degrees() const { return HorizToPitch(value); } int Sgn() const { return ::Sgn(value); } diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 8968e75a1..c08d3e06a 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -44,14 +44,14 @@ struct PlayerHorizon bool movementlocked() { return targetset() || inputdisabled; } // Draw code helpers. - double horizsumfrac(double const interpfrac) { return (!SyncInput() ? sum() : interpolatedsum(interpfrac)).asbuildf() * (1. / 16.); } + double horizsumfrac(double const interpfrac) { return (!SyncInput() ? sum() : interpolatedsum(interpfrac)).Tan() * 8.; } // Ticrate playsim adjustment setters and processor. void addadjustment(fixedhoriz const value) { if (!SyncInput()) { - adjustment += value.asbuildf(); + adjustment += value.Degrees(); } else { @@ -79,11 +79,11 @@ struct PlayerHorizon { if (targetset()) { - auto delta = (target - horiz).asbuildf(); + auto delta = (target - horiz).Degrees(); - if (abs(delta) > 1) + if (abs(delta) > 0.45) { - horiz += buildfhoriz(scaleAdjust * delta); + horiz += pitchhoriz(scaleAdjust * delta); } else { @@ -93,7 +93,7 @@ struct PlayerHorizon } else if (adjustment) { - horiz += buildfhoriz(scaleAdjust * adjustment); + horiz += pitchhoriz(scaleAdjust * adjustment); } } diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index beca3047f..3775d9ee8 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -139,7 +139,7 @@ struct GameInterface : public ::GameInterface void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 80., horiz.asbuildf() * 0.625 - 16); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 80., horiz.Tan() * 80.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; void EnterPortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index f816f4f00..8a285537b 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -55,7 +55,7 @@ struct GameInterface : public ::GameInterface void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 64., horiz.asbuildf() * 0.5); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 64., horiz.Tan() * 64.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 65c581e92..1a2d77b4d 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -241,7 +241,7 @@ DDukeActor* aim(DDukeActor* actor, int abase) // This is a reimplementation of how it was solved in RedNukem. if (plr->curr_weapon == PISTOL_WEAPON && !isWW2GI()) { - double zvel = -plr->horizon.sum().asbuildf() / 8; + double zvel = -plr->horizon.sum().Tan() * 16.; HitInfo hit{}; hitscan(plr->pos.plusZ(4), actor->sector(), DVector3(actor->spr.angle.ToVector() * 1024, zvel), hit, CLIPMASK1); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 515fb4feb..b30b8786f 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -113,7 +113,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang) } else { - zvel = -ps[p].horizon.sum().asbuildf() * (98 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 49.; pos += (ang + DAngle1 * 61).ToVector() * (1024 / 448.); pos.Z += 3; } @@ -182,7 +182,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng } else { - zvel = -ps[p].horizon.sum().asbuildf() * (81./256.); + zvel = -ps[p].horizon.sum().Tan() * 40.5; // WTF??? DAngle myang = DAngle90 - (DAngle180 - abs(abs(VecToAngle(spos.XY() - ps[p].pos.XY()) - sang) - DAngle180)); @@ -242,7 +242,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (p >= 0) { - zvel = -ps[p].horizon.sum().asbuildf() * 0.125; + zvel = -ps[p].horizon.sum().Tan() * 16.; pos.Z += 6; ang += DAngle1 * 2.64; } @@ -374,14 +374,14 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int if (aimed == nullptr) { // no target - zvel = -ps[p].horizon.sum().asbuildf() / 8; + zvel = -ps[p].horizon.sum().Tan() * 16.; } zvel += (zRange / 2) - krandf(zRange); } else if (aimed == nullptr) { ang += DAngle22_5 / 8 - randomAngle(22.5 / 4); - zvel = -ps[p].horizon.sum().asbuildf() / 8; + zvel = -ps[p].horizon.sum().Tan() * 16.; zvel += 0.5 - krandf(1); } @@ -606,7 +606,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a ang = VecToAngle(aimed->spr.pos.XY() - pos.XY()); } else - zvel = -ps[p].horizon.sum().asbuildf() * (98 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 49.; } else { @@ -717,7 +717,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw ang = VecToAngle(aimed->spr.pos.XY() - pos.XY()); } else - zvel = -ps[p].horizon.sum().asbuildf() * (81 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 40.5; if (atwith == RPG) S_PlayActorSound(RPG_SHOOT, actor); @@ -861,7 +861,7 @@ static void shootlaser(DDukeActor* actor, int p, DVector3 pos, DAngle ang) HitInfo hit{}; if (p >= 0) - zvel = -ps[p].horizon.sum().asbuildf() * 0.125; + zvel = -ps[p].horizon.sum().Tan() * 16.; else zvel = 0; hitscan(pos, sectp, DVector3(ang.ToVector() * 1024, zvel * 64), hit, CLIPMASK1); @@ -958,7 +958,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) else { ang += DAngle22_5 / 8 - randomAngle(22.5 / 4); - zvel = -ps[p].horizon.sum().asbuildf() * 0.125; + zvel = -ps[p].horizon.sum().Tan() * 16.; zvel += 0.5 - krandf(1); } @@ -1051,7 +1051,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle ang = VecToAngle(aimed->spr.pos.XY() - pos.XY()); } else - zvel = -ps[p].horizon.sum().asbuildf() * (98 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 49.; } else if (actor->spr.statnum != 3) { @@ -2048,7 +2048,7 @@ int operateTripbomb(int snum) auto p = &ps[snum]; HitInfo hit{}; - hitscan(p->pos, p->cursector, DVector3(p->angle.ang.ToVector() * 1024, -p->horizon.sum().asbuildf() * 0.125), hit, CLIPMASK1); + hitscan(p->pos, p->cursector, DVector3(p->angle.ang.ToVector() * 1024, -p->horizon.sum().Tan() * 16.), hit, CLIPMASK1); if (hit.hitSector == nullptr || hit.actor()) return 0; @@ -2236,12 +2236,12 @@ static void operateweapon(int snum, ESyncBits actions) if (p->on_ground && (actions & SB_CROUCH)) { vel = 15/16.; - zvel = p->horizon.sum().asbuildf() * (20 / 256.); + zvel = p->horizon.sum().Tan() * 10.; } else { vel = 140/16.; - zvel = -4 - p->horizon.sum().asbuildf() * (20 / 256.); + zvel = -4 - p->horizon.sum().Tan() * 10.; } auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 4a4ed5db6..fafff213a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -91,7 +91,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a if (p >= 0) { - zvel = -ps[p].horizon.sum().asbuildf() * 0.125; + zvel = -ps[p].horizon.sum().Tan() * 16.; pos.Z += 6; ang += DAngle1 * 2.64; } @@ -224,7 +224,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int if (aimed == nullptr) { ang += DAngle22_5 / 8 - randomAngle(22.5 / 4); - zvel = -ps[p].horizon.sum().asbuildf() / 8; + zvel = -ps[p].horizon.sum().Tan() * 16.; zvel += 0.5 - krandf(1); } } @@ -234,7 +234,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int ang += DAngle22_5 / 2 - randomAngle(22.5); else ang += DAngle22_5 / 8 - randomAngle(22.5 / 4); - if (aimed == nullptr) zvel = -ps[p].horizon.sum().asbuildf() / 8; + if (aimed == nullptr) zvel = -ps[p].horizon.sum().Tan() * 16.; zvel += 0.5 - krandf(1); } pos.Z -= 2; @@ -512,7 +512,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a } else { - zvel = -ps[p].horizon.sum().asbuildf() * (98 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 49.; } } else @@ -628,7 +628,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw ang = VecToAngle(aimed->spr.pos.XY() - pos.XY()); } else - zvel = -ps[p].horizon.sum().asbuildf() * (81 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 40.5; if (atwith == RPG) S_PlayActorSound(RPG_SHOOT, actor); @@ -782,7 +782,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at ang = VecToAngle(aimed->spr.pos.XY() - pos.XY()); } else - zvel = -ps[p].horizon.sum().asbuildf() * (98 / 256.); + zvel = -ps[p].horizon.sum().Tan() * 49.; } else { @@ -2743,12 +2743,12 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) if (p->on_ground && (actions & SB_CROUCH)) { vel = 15 / 16.; - zvel = p->horizon.sum().asbuildf() * (20 / 256.); + zvel = p->horizon.sum().Tan() * 10.; } else { vel = 140 / 16.; - zvel = -4 - p->horizon.sum().asbuildf() * (20 / 256.); + zvel = -4 - p->horizon.sum().Tan() * 10.; } auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, @@ -3150,12 +3150,12 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) { vel = 15 / 16.; - zvel = p->horizon.sum().asbuildf() * (20 / 256.); + zvel = p->horizon.sum().Tan() * 10.; } else { vel = 2.; - zvel = -4 - p->horizon.sum().asbuildf() * (20 / 256.); + zvel = -4 - p->horizon.sum().Tan() * 10.; } CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, POWDERKEG, -16, 9, 9, p->angle.ang, vel * 2, zvel, pact, 1); diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 9be7e4c74..605cb6376 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -333,12 +333,12 @@ void operateweapon_ww(int snum, ESyncBits actions) if (p->on_ground && (actions & SB_CROUCH)) { vel = 15 / 16.; - zvel = p->horizon.sum().asbuildf() * (20 / 256.); + zvel = p->horizon.sum().Tan() * 10.; } else { vel = 140 / 16.; - zvel = -4 - p->horizon.sum().asbuildf() * (20 / 256.); + zvel = -4 - p->horizon.sum().Tan() * 10.; } auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 36186427c..424c33b58 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -405,7 +405,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) ang = ps[snum].angle.ang - mapangle((krand() & 63) + 8); //Fine tune act->temp_data[0] = krand() & 1; - act->spr.pos.Z = 3 + ps[snum].pos.Z + ps[snum].pyoff - (ps[snum].horizon.sum().asbuildf() * (1/16.)) + (!isshell ? 3 : 0); + act->spr.pos.Z = 3 + ps[snum].pos.Z + ps[snum].pyoff - (ps[snum].horizon.sum().Tan() * 8.) + (!isshell ? 3 : 0); act->vel.Z = -krandf(1); } else diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 1d0e92726..d8015e381 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -235,7 +235,7 @@ struct GameInterface : public ::GameInterface fixed_t playerHorizMax() override { return IntToFixed(150); } void WarpToCoords(double x, double y, double z, DAngle ang, int horz) override; void ToggleThirdPerson() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 96., horiz.asbuildf() * 0.75); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 96., horiz.Tan() * 96.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; int GetCurrentSkill() override; std::pair GetCoordinates() override; diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index d5ede337e..213b3eaef 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -747,7 +747,7 @@ loc_flag: // loc_27266: case kWeaponSword: { - nHeight -= PlayerList[nLocalPlayer].horizon.horiz.asbuildf() * 0.25; + nHeight -= PlayerList[nLocalPlayer].horizon.horiz.Tan() * 32.; thePos.Z += nHeight; @@ -852,7 +852,7 @@ loc_flag: } case kWeaponPistol: { - double h = PlayerList[nLocalPlayer].horizon.horiz.asbuildf() / 64.; + double h = PlayerList[nLocalPlayer].horizon.horiz.Tan() * 2.; nHeight -= h; DExhumedActor* target = nullptr; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index c38627475..e1acd83ac 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -2500,7 +2500,7 @@ sectdone: if (cl_slopetilting && !pPlayer->bPlayerPan && !pPlayer->bLockPan) { - double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).asbuildf() * 0.25; + double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).Tan() * 32.; if (nVertPan != 0) { pPlayer->horizon.addadjustment(buildfhoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.)); diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index d2ac5cd25..a99c0e2f7 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1883,7 +1883,7 @@ struct GameInterface : public ::GameInterface void WarpToCoords(double x, double y, double z, DAngle ang, int horz) override; void ToggleThirdPerson() override; void SwitchCoopView() override; - DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 128., horiz.asbuildf()); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 128., horiz.Tan() * 128.); } void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double smoothRatio) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 2ba3af3d1..186fc5965 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1289,7 +1289,7 @@ int PlayerInitChemBomb(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - actorNew->vel.Z -= pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z -= pp->horizon.horiz.Tan() * HORIZ_MULTF; oclipdist = plActor->native_clipdist(); plActor->set_const_clipdist(0); @@ -1664,7 +1664,7 @@ int PlayerInitCaltrops(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - actorNew->vel.Z -= pp->horizon.horiz.asbuildf() * 0.5; + actorNew->vel.Z -= pp->horizon.horiz.Tan() * HORIZ_MULTF; oclipdist = plActor->native_clipdist(); plActor->set_const_clipdist(0); @@ -1826,7 +1826,7 @@ int InitBloodSpray(DSWActor* actor, bool dogib, short velocity) actorNew->user.floor_dist = 3; actorNew->user.Counter = 0; - actorNew->vel.Z = (-10 - RandomRange(50)) * HORIZ_MULTF; + actorNew->vel.Z = (-10 - RandomRange(50)) * 0.5; UpdateChange(actorNew, 0.5); @@ -2209,7 +2209,7 @@ int SpawnShell(DSWActor* actor, int ShellNum) if (actor->user.PlayerP) { - actorNew->vel.Z = -actor->user.PlayerP->horizon.horiz.asbuildf() * HORIZ_MULTF * (1. / 3.); + actorNew->vel.Z = -actor->user.PlayerP->horizon.horiz.Tan() * (HORIZ_MULTF / 3.); } switch (actorNew->user.ID) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index cfd73427a..9333009e2 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -12063,7 +12063,7 @@ void InitSpellNapalm(PLAYER* pp) actor->spr.xrepeat = 32; actor->spr.yrepeat = 32; actor->set_const_clipdist(0); - actor->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actor->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actor->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actor->user.Flags2 |= (SPR2_BLUR_TAPER_FAST); @@ -12195,7 +12195,7 @@ int InitSpellMirv(PLAYER* pp) actorNew->spr.xrepeat = 72; actorNew->spr.yrepeat = 72; actorNew->set_const_clipdist(32 >> 2); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -12329,7 +12329,7 @@ int InitSwordAttack(PLAYER* pp) { HitInfo hit{}; - double daz = -pp->horizon.horiz.asbuildf() * (2000 / 256.) + (RandomRangeF(24000 / 256.) - 12000 / 256.); + double daz = -pp->horizon.horiz.Tan() * 1000. + (RandomRangeF(24000 / 256.) - 12000 / 256.); DAngle daang = pp->angle.ang; FAFhitscan(pp->pos, pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, daz), hit, CLIPMASK_MISSILE); @@ -12506,7 +12506,7 @@ int InitFistAttack(PLAYER* pp) // all this is to break glass { HitInfo hit{}; - double daz = -pp->horizon.horiz.asbuildf() * (2000 / 256.) + (RandomRangeF(24000 / 256.) - 12000 / 256.); + double daz = -pp->horizon.horiz.Tan() * 1000. + (RandomRangeF(24000 / 256.) - 12000 / 256.); auto daang = pp->angle.ang; FAFhitscan(pp->pos, pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, daz), hit, CLIPMASK_MISSILE); @@ -13069,7 +13069,7 @@ int InitStar(PLAYER* pp) actorNew->spr.shade = -25; actorNew->set_const_clipdist(32 >> 2); // zvel was overflowing with this calculation - had to move to a local long var - double zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + STAR_HORIZ_ADJ) / 256.); + double zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + STAR_HORIZ_ADJ) * 0.5); actorNew->user.ceiling_dist = (1); actorNew->user.floor_dist = (1); @@ -13120,7 +13120,7 @@ int InitStar(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew2)) actorNew2->user.Flags |= SPR_UNDERWATER; - zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + STAR_HORIZ_ADJ) / 256.); + zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + STAR_HORIZ_ADJ) * 0.5); actorNew2->vel.Z = zvel * 0.5; if (MissileSetPos(actorNew2, DoStar, 1000)) @@ -13170,7 +13170,7 @@ void InitHeartAttack(PLAYER* pp) actorNew->spr.xrepeat = 52; actorNew->spr.yrepeat = 52; actorNew->set_const_clipdist(0); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->user.Flags2 |= (SPR2_DONT_TARGET_OWNER); actorNew->spr.cstat |= (CSTAT_SPRITE_INVISIBLE); @@ -13314,7 +13314,7 @@ int InitShotgun(PLAYER* pp) } else { - daz = -pp->horizon.horiz.asbuildf() * (2000 / 256.); + daz = -pp->horizon.horiz.Tan() * 1000.; daang = pp->angle.ang; } @@ -13477,7 +13477,7 @@ int InitLaser(PLAYER* pp) actorNew->set_const_clipdist(64 >> 2);; // the slower the missile travels the less of a zvel it needs - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF * 0.25; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * 16.; actorNew->user.WeaponNum = actor->user.WeaponNum; actorNew->user.Radius = 200; @@ -13573,7 +13573,7 @@ int InitRail(PLAYER* pp) actorNew->spr.yrepeat = 52; actorNew->spr.xrepeat = 52; actorNew->spr.shade = -15; - zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + 17) / 256.); + zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + 17) * 0.5); actorNew->user.RotNum = 5; NewStateGroup(actorNew, &sg_Rail[0]); @@ -13739,7 +13739,7 @@ int InitRocket(PLAYER* pp) actorNew->spr.yrepeat = 90; actorNew->spr.xrepeat = 90; actorNew->spr.shade = -15; - zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + 35) / 256.); + zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + 35) * 0.5); actorNew->set_const_clipdist(64 >> 2); @@ -13847,7 +13847,7 @@ int InitBunnyRocket(PLAYER* pp) actorNew->spr.yrepeat = 64; actorNew->spr.xrepeat = 64; actorNew->spr.shade = -15; - zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + 35) / 256.); + zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + 35) * 0.5); actorNew->set_const_clipdist(64 >> 2); @@ -13950,7 +13950,7 @@ int InitNuke(PLAYER* pp) actorNew->spr.yrepeat = 128; actorNew->spr.xrepeat = 128; actorNew->spr.shade = -15; - zvel = -pp->horizon.horiz.asbuildf() * ((HORIZ_MULT + 36) / 256.); + zvel = -pp->horizon.horiz.Tan() * ((HORIZ_MULT + 36) * 0.5); actorNew->set_const_clipdist(64 >> 2); // Set to red palette @@ -14133,7 +14133,7 @@ int InitMicro(PLAYER* pp) actorNew->spr.yrepeat = 24; actorNew->spr.xrepeat = 24; actorNew->spr.shade = -15; - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->set_const_clipdist(64 >> 2); // randomize zvelocity @@ -15361,7 +15361,7 @@ int InitTracerUzi(PLAYER* pp) return 0; } - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * actorNew->vel.X * (1. / 128.); + actorNew->vel.Z = -pp->horizon.horiz.Tan() * actorNew->vel.X; plActor->set_native_clipdist(oclipdist); @@ -15390,7 +15390,7 @@ int InitTracerTurret(DSWActor* actor, DSWActor* Operator, fixedhoriz horiz) // Inserting and setting up variables auto actorNew = SpawnActor(STAT_MISSILE, 0, s_Tracer, actor->sector(), - actor->spr.pos.plusZ(-MulScaleF(horiz.asbuildf(), 72, 8)), actor->spr.angle, TRACER_VELOCITY); + actor->spr.pos.plusZ(-horiz.Tan() * 36.), actor->spr.angle, TRACER_VELOCITY); actorNew->spr.hitag = LUMINOUS; //Always full brightness if (Operator!= nullptr) @@ -15408,7 +15408,7 @@ int InitTracerTurret(DSWActor* actor, DSWActor* Operator, fixedhoriz horiz) actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); actorNew->spr.cstat |= (CSTAT_SPRITE_INVISIBLE); - actorNew->vel.Z = -horiz.asbuildf() * actorNew->vel.X * (1. / 128.); + actorNew->vel.Z = -horiz.Tan() * actorNew->vel.X; WeaponAutoAim(actor, actorNew, DAngle22_5 / 4, false); @@ -15629,7 +15629,7 @@ int InitUzi(PLAYER* pp) else { daang = pp->angle.ang + mapangle(RandomRange(24) - 12); - daz = -pp->horizon.horiz.asbuildf() * (2000/256.) + (RandomRangeF(24000/256.) - 12000/256.); + daz = -pp->horizon.horiz.Tan() * 1000. + (RandomRangeF(24000/256.) - 12000/256.); } DVector3 vect(daang.ToVector() * 1024, daz); @@ -15804,7 +15804,7 @@ int InitTankShell(DSWActor* actor, PLAYER* pp) actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); actorNew->spr.cstat |= (CSTAT_SPRITE_INVISIBLE); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * actorNew->vel.X * (1. / 128.); + actorNew->vel.Z = -pp->horizon.horiz.Tan() * actorNew->vel.X; WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -15873,7 +15873,7 @@ int InitTurretMicro(DSWActor* actor, PLAYER* pp) actorNew->spr.yrepeat = 24; actorNew->spr.xrepeat = 24; actorNew->spr.shade = -15; - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF + RandomRangeF(8) - 5; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF + RandomRangeF(8) - 5; actorNew->set_const_clipdist(64 >> 2); @@ -15943,7 +15943,7 @@ int InitTurretRocket(DSWActor* actor, PLAYER* pp) actorNew->user.Flags2 |= (SPR2_SO_MISSILE); actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * actorNew->vel.X * (1. / 128.); + actorNew->vel.Z = -pp->horizon.horiz.Tan() * actorNew->vel.X; WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -15983,7 +15983,7 @@ int InitTurretFireball(DSWActor* actor, PLAYER* pp) actorNew->user.Flags2 |= (SPR2_SO_MISSILE); actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * actorNew->vel.X * (1. / 128.); + actorNew->vel.Z = -pp->horizon.horiz.Tan() * actorNew->vel.X; WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -16021,7 +16021,7 @@ int InitTurretRail(DSWActor* actor, PLAYER* pp) actorNew->spr.yrepeat = 52; actorNew->spr.xrepeat = 52; actorNew->spr.shade = -15; - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->user.RotNum = 5; NewStateGroup(actorNew, &sg_Rail[0]); @@ -16069,7 +16069,7 @@ int InitTurretLaser(DSWActor* actor, PLAYER* pp) actorNew->spr.shade = -15; // the slower the missile travels the less of a zvel it needs - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF * 0.25; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * 16.; actorNew->user.Radius = 200; actorNew->user.ceiling_dist = (1); @@ -16116,9 +16116,7 @@ int InitSobjMachineGun(DSWActor* actor, PLAYER* pp) } else { - double horiz = max(pp->horizon.horiz.asbuildf(), -25.); - - daz = -(2000/256) * horiz + RandomRangeF(80) - 40; + daz = -1000 * max(pp->horizon.horiz.Tan(), -0.1953125) + RandomRangeF(80) - 40; daang = actor->spr.angle; } @@ -16816,7 +16814,7 @@ int InitGrenade(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; SAVE_CLIP; actor->set_const_clipdist(0); @@ -16934,7 +16932,7 @@ int InitMine(PLAYER* pp) actorNew->spr.xrepeat = 32; actorNew->spr.shade = -15; actorNew->set_const_clipdist(128 >> 2); - actorNew->vel.Z = -pp->horizon.horiz.asbuildf() * HORIZ_MULTF; + actorNew->vel.Z = -pp->horizon.horiz.Tan() * HORIZ_MULTF; actorNew->user.WeaponNum = actor->user.WeaponNum; actorNew->user.Radius = 200; actorNew->user.ceiling_dist = (5); @@ -17069,7 +17067,7 @@ int InitFireball(PLAYER* pp) actorNew->user.ceiling_dist = (6); actorNew->user.floor_dist = (6); - double zvel = -pp->horizon.horiz.asbuildf() * (240. / 256.); + double zvel = -pp->horizon.horiz.Tan() * 120.; // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index a84fd0c67..3f0a1f68d 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -31,7 +31,7 @@ BEGIN_SW_NS #define NEW_ELECTRO 1 #define HORIZ_MULT 128 -constexpr double HORIZ_MULTF = 0.5; +constexpr double HORIZ_MULTF = 64.; inline DAngle AngToSprite(DSWActor* actor, DSWActor* other) {