diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 5c802da29..89265a4f1 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2173,7 +2173,7 @@ static void greenslime(DDukeActor *actor) return; } - actor->spr.pos.Z = ps[p].pos.Z + 8 + (ps[p].pyoff - actor->temp_data[2] - (ps[p].horizon.horiz.asq16() >> 12)) * zinttoworld; + actor->spr.pos.Z = ps[p].pos.Z + 8 + ps[p].pyoff - (actor->temp_data[2] - (ps[p].horizon.horiz.asq16() >> 12)) * zinttoworld; if (actor->temp_data[2] > 512) actor->temp_data[2] -= 128; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 53788facd..226ddfa81 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -393,13 +393,13 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_PYOFF: - if (bSet) ps[iPlayer].pyoff = lValue; - else SetGameVarID(lVar2, ps[iPlayer].pyoff, sActor, sPlayer); + if (bSet) ps[iPlayer].pyoff = lValue * zmaptoworld; + else SetGameVarID(lVar2, ps[iPlayer].pyoff / zmaptoworld, sActor, sPlayer); break; case PLAYER_OPYOFF: - if (bSet) ps[iPlayer].opyoff = lValue; - else SetGameVarID(lVar2, ps[iPlayer].opyoff, sActor, sPlayer); + if (bSet) ps[iPlayer].opyoff = lValue * zmaptoworld; + else SetGameVarID(lVar2, ps[iPlayer].opyoff / zmaptoworld, sActor, sPlayer); break; case PLAYER_POSXV: diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index e1e2636f1..23b0aedbd 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -845,7 +845,7 @@ static void shootlaser(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) zvel = -ps[p].horizon.sum().asq16() >> 11; else zvel = 0; - hitscan(vec3_t( sx, sy, sz - ps[p].pyoff ), sectp, { bcos(sa), bsin(sa), zvel << 6 }, hit, CLIPMASK1); + hitscan(vec3_t( sx, sy, sz - ps[p].pyoff * zworldtoint ), sectp, { bcos(sa), bsin(sa), zvel << 6 }, hit, CLIPMASK1); j = 0; if (hit.actor()) return; @@ -1020,7 +1020,7 @@ void shoot_d(DDukeActor* actor, int atwith) { sx = ps[p].player_int_pos().X; sy = ps[p].player_int_pos().Y; - sz = ps[p].player_int_pos().Z + ps[p].pyoff + (4 << 8); + sz = ps[p].player_int_pos().Z + ps[p].pyoff * zworldtoint + (4 << 8); sa = ps[p].angle.ang.Buildang(); ps[p].crack_time = CRACK_TIME; @@ -1680,7 +1680,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -7); + p->pyoff = DAngle::fromBuild(p->pycount).Sin(); if (p->jetpack_on && S_CheckActorSoundPlaying(pact, DUKE_SCREAM)) { @@ -1763,7 +1763,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int i = 34; p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -6); + p->pyoff = DAngle::fromBuild(p->pycount).Sin() * 2; } else i = 12; @@ -1939,7 +1939,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -7); + p->pyoff = DAngle::fromBuild(p->pycount).Sin(); if (!S_CheckActorSoundPlaying(pact, DUKE_UNDERWATER)) S_PlayActorSound(DUKE_UNDERWATER, pact); @@ -3050,7 +3050,10 @@ HORIZONLY: { p->pycount += 52; p->pycount &= 2047; - p->pyoff = abs(pact->spr.xvel * bsin(p->pycount)) / 1596; + p->pyoff = DAngle::fromBuild(p->pycount).Sin() * pact->spr.xvel; + + const double factor = 64. / 1596; // What is 1596? + p->pyoff = abs(pact->spr.xvel * DAngle::fromBuild(p->pycount).Sin()) * factor; } } else if (psectlotag != 2 && psectlotag != 1) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 54125f8b6..5ffaa2cc8 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -836,7 +836,7 @@ void shoot_r(DDukeActor* actor, int atwith) sx = ps[p].player_int_pos().X; sy = ps[p].player_int_pos().Y; - sz = ps[p].player_int_pos().Z + ps[p].pyoff + (4 << 8); + sz = ps[p].player_int_pos().Z + ps[p].pyoff * zworldtoint + (4 << 8); sa = ps[p].angle.ang.Buildang(); if (isRRRA()) ps[p].crack_time = CRACK_TIME; @@ -2079,7 +2079,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int i = 34; p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -6); + p->pyoff = DAngle::fromBuild(p->pycount).Sin() * 2; } else i = 12; @@ -2297,7 +2297,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -7); + p->pyoff = DAngle::fromBuild(p->pycount).Sin(); if (!S_CheckActorSoundPlaying(pact, DUKE_UNDERWATER)) S_PlayActorSound(DUKE_UNDERWATER, pact); @@ -3603,7 +3603,7 @@ void processinput_r(int snum) { p->pycount += 32; p->pycount &= 2047; - p->pyoff = bsin(p->pycount, -(p->SeaSick ? 2 : 7)); + p->pyoff = DAngle::fromBuild(p->pycount).Sin() * (p->SeaSick? 32 : 1); } if (psectlotag == ST_2_UNDERWATER) @@ -3886,8 +3886,8 @@ HORIZONLY: { p->pycount += 52; p->pycount &= 2047; - p->pyoff = - abs(pact->spr.xvel * bsin(p->pycount)) / 1596; + const double factor = 64. / 1596; // What is 1596? + p->pyoff = abs(pact->spr.xvel * DAngle::fromBuild(p->pycount).Sin()) * factor; } } else if (psectlotag != ST_2_UNDERWATER && psectlotag != 1 && (!isRRRA() || !p->sea_sick_stat)) diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index ccaf0ee88..56d299ef1 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -339,7 +339,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) } else if (p->over_shoulder_on == 0) { - if (cl_viewbob) cposz += interpolatedvalue(p->opyoff, p->pyoff, smoothratio); + if (cl_viewbob) cposz += interpolatedvaluef(p->opyoff, p->pyoff, smoothratio) * zworldtoint; viewer = p->GetActor(); } else diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 133dd7042..4f37d1d7d 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -439,7 +439,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) ang = ps[snum].angle.ang - DAngle::fromBuild((krand() & 63) + 8); //Fine tune act->temp_data[0] = krand() & 1; - act->spr.pos.Z = 3 + ps[snum].pos.Z + ps[snum].pyoff * zinttoworld - (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().asbuildf() * (1/16.)) + (!isshell ? 3 : 0); act->spr.zvel = -(krand() & 255); } else diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 6c69b67f9..8eaf42cfb 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -229,7 +229,6 @@ struct player_struct // From here on it is unaltered from JFDuke with the exception of a few fields that are no longer needed and were removed. int numloogs, oloogcnt, loogcnt; int invdisptime; - int pyoff, opyoff; int last_pissed_time; int player_par, visibility; int bobcounter; @@ -237,6 +236,7 @@ struct player_struct int aim_mode, ftt; + double pyoff, opyoff; double truefz, truecz; sectortype* cursector; sectortype* one_parallax_sectnum; // wall + sector references. diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index c9b4512ca..e00799c86 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -159,7 +159,7 @@ struct DukePlayer // From here on it is unaltered from JFDuke with the exception of a few fields that are no longer needed and were removed. native int numloogs, loogcnt; native int invdisptime; - native int pyoff, opyoff; + native double pyoff, opyoff; native int last_pissed_time; native double truefz, truecz; native int player_par, visibility;