diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 604ea1980..15a6c0ce0 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -271,9 +271,10 @@ int animateaccess(int gs,int snum) void displayweapon_d(int snum, double smoothratio) { - int gun_pos, looking_arc, cw; - int weapon_xoffset, i, j; + int looking_arc, cw; + int i, j; int o,pal; + double weapon_sway, weapon_xoffset, gun_pos; signed char gs; struct player_struct *p; @@ -284,6 +285,7 @@ void displayweapon_d(int snum, double smoothratio) o = 0; looking_arc = abs(p->getlookang())/9; + weapon_sway = p->oweapon_sway + (((p->weapon_sway - p->oweapon_sway) * smoothratio) / MaxSmoothRatio); gs = sprite[p->i].shade; if(gs > 24) gs = 24; @@ -296,11 +298,11 @@ void displayweapon_d(int snum, double smoothratio) gun_pos = 80-(p->weapon_pos*p->weapon_pos); weapon_xoffset = (160)-90; - weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); + weapon_xoffset -= (sintable[((xs_CRoundToInt(weapon_sway)>>1)+512)&2047]/(1024+512)); weapon_xoffset -= 58 + p->weapon_ang; if( sprite[p->i].xrepeat < 32 ) - gun_pos -= abs(sintable[(p->weapon_sway<<2)&2047]>>9); - else gun_pos -= abs(sintable[(p->weapon_sway>>1)&2047]>>10); + gun_pos -= abs(sintable[(xs_CRoundToInt(weapon_sway)<<2)&2047]>>9); + else gun_pos -= abs(sintable[(xs_CRoundToInt(weapon_sway)>>1)&2047]>>10); gun_pos -= (p->hard_landing<<3); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 9e7b61e90..9a75c03b6 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2732,13 +2732,14 @@ void processinput_d(int snum) if (p->on_crane >= 0) goto HORIZONLY; + p->oweapon_sway = p->weapon_sway; if (s->xvel < 32 || p->on_ground == 0 || p->bobcounter == 1024) { if ((p->weapon_sway & 2047) > (1024 + 96)) p->weapon_sway -= 96; else if ((p->weapon_sway & 2047) < (1024 - 96)) p->weapon_sway += 96; - else p->weapon_sway = 1024; + else p->oweapon_sway = p->weapon_sway = 1024; } else p->weapon_sway = p->bobcounter; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index d3f8abbd6..fedcfe063 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3627,6 +3627,7 @@ void processinput_r(int snum) if (p->on_crane >= 0) goto HORIZONLY; + p->oweapon_sway = p->weapon_sway; if (s->xvel < 32 || p->on_ground == 0 || p->bobcounter == 1024) { if ((p->weapon_sway & 2047) > (1024 + 96)) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index f86c7758f..6100c33ff 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -122,7 +122,7 @@ struct player_struct int bobposx, bobposy, oposx, oposy, oposz, pyoff, opyoff; int posxv, posyv, poszv, last_pissed_time, truefz, truecz; int player_par, visibility; - int bobcounter, weapon_sway; + int bobcounter, weapon_sway, oweapon_sway; int pals_time, randomflamex, crack_time; int aim_mode, auto_aim, ftt;