diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index bbf8f9ab..a767c6bc 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -944,7 +944,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) case SV_WEAPCHANGE: { int gun = getint(p); - if(d) d->selectweapon(gun); + if(d) d->selectweapon(gun,d!=player1); break; } diff --git a/source/src/entity.h b/source/src/entity.h index 2538790c..af6a0790 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -534,7 +534,14 @@ public: curskin = nextskin[team_base(team)]; } - void selectweapon(int w) { if (weaponsel) prevweaponsel = weaponsel; weaponsel = weapons[(gunselect = w)]; if (!prevweaponsel) prevweaponsel = weaponsel; } + void selectweapon(int w, bool other = false) + { + if(weaponsel) prevweaponsel = weaponsel; + weaponsel = weapons[(gunselect = w)]; + if(!prevweaponsel) prevweaponsel = weaponsel; + if(other && (prevweaponsel != weaponsel)) weaponswitch(weaponsel, true); + } + void setprimary(int w) { primweap = weapons[(primary = w)]; } void setnextprimary(int w) { nextprimweap = weapons[(nextprimary = w)]; } bool isspectating() { return state==CS_SPECTATE || (state==CS_DEAD && spectatemode > SM_NONE); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index d6771bc3..281688f0 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -1510,8 +1510,8 @@ int sniperrifle::dynspread() float sniperrifle::dynrecoil() { return scoped && lastmillis - scoped_since > SCOPESETTLETIME ? info.recoil / 3 : info.recoil; } bool sniperrifle::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } void sniperrifle::onselecting(bool sound) { weapon::onselecting(sound); scoped = false; player1->scoping = false; } -void sniperrifle::ondeselecting() { scoped = false; player1->scoping = false; } -void sniperrifle::onownerdies() { scoped = false; player1->scoping = false; shots = 0; } +void sniperrifle::ondeselecting() { scoped = false; owner->scoping = false; } +void sniperrifle::onownerdies() { shots = 0; scoped = false; owner->scoping = false; } void sniperrifle::renderhudmodel() { if(!scoped) weapon::renderhudmodel(); } void sniperrifle::renderaimhelp(bool teamwarning) @@ -1577,7 +1577,7 @@ void akimbo::onammopicked() if(akimboautoswitch || owner->weaponsel->type==GUN_PISTOL) { if(player1->weapons[GUN_GRENADE]->busy()) player1->attacking = false; - owner->weaponswitch(this); + player1->weaponswitch(this); } addmsg(SV_AKIMBO, "ri", lastmillis); }