Skip to content

Commit

Permalink
trigger weaponswitch for others (issue #257)
Browse files Browse the repository at this point in the history
  • Loading branch information
flowtron committed Jun 19, 2021
1 parent ed75cde commit d37e73a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/src/clients2c.cpp
Expand Up @@ -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;
}

Expand Down
9 changes: 8 additions & 1 deletion source/src/entity.h
Expand Up @@ -534,7 +534,14 @@ class playerent : public dynent, public playerstate
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); }
Expand Down
6 changes: 3 additions & 3 deletions source/src/weapon.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d37e73a

Please sign in to comment.