- Duke: Move displaychaingun_ww() lambda to new weapon offsets.

This commit is contained in:
Mitchell Richters 2022-10-14 09:17:21 +11:00 committed by Christoph Oelckers
parent 35a26a1cb5
commit c7274ff5fb

View file

@ -510,93 +510,68 @@ void displayweapon_d(int snum, double interpfrac)
auto displaychaingun_ww = [&]() auto displaychaingun_ww = [&]()
{ {
if (*kb > 0) offsets.X += weapon_xoffset;
gun_pos -= BobVal(kickback_pic * 128.) * 4; offsets.Y -= gun_pos;
if (*kb > 0 && p->GetActor()->spr.pal != 1) weapon_xoffset += 1 - (rand() & 3); if (*kb > 0)
offsets.Y += BobVal(kickback_pic * 128.) * 4;
if (*kb > 0 && p->GetActor()->spr.pal != 1)
offsets.X += 1 - (rand() & 3);
if (*kb == 0) if (*kb == 0)
{ {
// hud_drawpal(weapon_xoffset+168-look_anghalf,looking_arc+260-gun_pos, hud_drawpal(178 + offsets.X, 233 + offsets.Y, CHAINGUN + 1, shade, o, pal, angle);
// CHAINGUN,gs,o,pal);
hud_drawpal(weapon_xoffset + 178 - look_anghalf, looking_arc + 233 - gun_pos, CHAINGUN + 1, shade, o, pal);
} }
else if (*kb <= aplWeaponTotalTime(CHAINGUN_WEAPON, snum)) else if (*kb <= aplWeaponTotalTime(CHAINGUN_WEAPON, snum))
{ {
hud_drawpal(weapon_xoffset + 188 - look_anghalf, looking_arc + 243 - gun_pos, CHAINGUN + 2, shade, o, pal); hud_drawpal(188 + offsets.X, 243 + offsets.Y, CHAINGUN + 2, shade, o, pal, angle);
} }
// else we are in 'reload time'
// divide reload time into fifths.
// 1) move weapon up/right, hand on clip (2519)
// 2) move weapon up/right, hand removing clip (2518)
// 3) hold weapon up/right, hand removed clip (2517)
// 4) hold weapon up/right, hand inserting clip (2518)
// 5) move weapon down/left, clip inserted (2519)
else else
{ {
int iFifths = (aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 5; // else we are in 'reload time', divide reload time into fifths.
if (iFifths < 1) // 1) move weapon up/right, hand on clip (2519)
{ // 2) move weapon up/right, hand removing clip (2518)
iFifths = 1; // 3) hold weapon up/right, hand removed clip (2517)
} // 4) hold weapon up/right, hand inserting clip (2518)
if (*kb < // 5) move weapon down/left, clip inserted (2519)
(iFifths
+ aplWeaponTotalTime(p->curr_weapon, snum) double adj;
) int pic;
) const int iFifths = max((aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 5, 1);
if (*kb < (iFifths + aplWeaponTotalTime(p->curr_weapon, snum)))
{ {
// first segment // first segment
// pic = 2519;
gun_pos += 80 - (10 * (aplWeaponTotalTime(p->curr_weapon, snum) + iFifths - kickback_pic)); adj = 80 - (10 * (aplWeaponTotalTime(p->curr_weapon, snum) + iFifths - kickback_pic));
weapon_xoffset += 80 - (10 * (aplWeaponTotalTime(p->curr_weapon, snum) + iFifths - kickback_pic));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2519, shade, o, pal);
} }
else if (*kb < else if (*kb < (iFifths * 2 + aplWeaponTotalTime(p->curr_weapon, snum)))
(iFifths * 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{ {
// second segment // second segment (down)
// down pic = 2518;
gun_pos += 80; //5*(iFifthsp->kickback_pic-aplWeaponTotalTime(p->curr_weapon, snum)); //D adj = 80;
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2518, shade, o, pal);
} }
else if (*kb < else if (*kb < (iFifths * 3 + aplWeaponTotalTime(p->curr_weapon, snum)))
(iFifths * 3
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{ {
// third segment // third segment (up)
// up pic = 2517;
gun_pos += 80;//5*(iFifths*2); adj = 80;
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2517, shade, o, pal);
} }
else if (*kb < else if (*kb < (iFifths * 4 + aplWeaponTotalTime(p->curr_weapon, snum)))
(iFifths * 4
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{ {
// fourth segment // fourth segment (down)
// down pic = 2518;
gun_pos += 80; //5*(aplWeaponTotalTime(p->curr_weapon, snum)- p->kickback_pic); //D adj = 80;
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2518, shade, o, pal);
} }
else else
{ {
// move back down
// up and left // up and left
gun_pos += 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); pic = 2519;
weapon_xoffset += 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); adj = 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic);
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2519, shade, o, pal);
} }
hud_drawpal(168 + offsets.X + adj, 260 + offsets.Y - adj, pic, shade, o, pal, angle);
} }
}; };