#257 there should be no sound when respawning

This commit is contained in:
drian
2021-04-19 08:32:19 +02:00
parent d48a4d30c0
commit 8149539ce8
4 changed files with 14 additions and 15 deletions
+1 -1
View File
@@ -643,7 +643,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
if(m_botmode) BotManager.RespawnBots();
}
addmsg(SV_SPAWN, "rii", player1->lifesequence, player1->weaponsel->type);
player1->weaponswitch(player1->primweap);
player1->weaponswitch(player1->primweap, false);
player1->weaponchanging -= weapon::weaponchangetime/2;
if(player1->lifesequence==0) player1->resetstats(); //NEW
break;
+2 -2
View File
@@ -538,14 +538,14 @@ public:
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); }
void weaponswitch(weapon *w)
void weaponswitch(weapon *w, bool sound = true)
{
if(!w) return;
extern int lastmillis;
weaponsel->ondeselecting();
weaponchanging = lastmillis;
nextweaponsel = w;
w->onselecting();
w->onselecting(sound);
}
int skin(int t = -1) { return nextskin[team_base(t < 0 ? team : t)]; }
void setskin(int t, int s)
+7 -8
View File
@@ -430,7 +430,6 @@ void intersectgeometry(const vec &from, vec &to) // check line for contact with
float distmin = 1.0f, vdelta[4];
sqr *r[2], *s, *nb[4];
if(fabs(d.x) + fabs(d.y) < 2.0f) d.mul((distmin = 32.0f));
loop(xy, 2) // first check x == const planes and then y == const planes
{
float dxy = xy ? d.y : d.x, fromxy = xy ? from.y : from.x;
@@ -1050,11 +1049,11 @@ void weapon::updatetimers(int millis)
if(gunwait) gunwait = max(gunwait - (millis-owner->lastaction), 0);
}
void weapon::onselecting()
void weapon::onselecting(bool sound)
{
updatelastaction(owner);
bool local = (owner == player1);
audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL);
if(sound) audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL);
}
void weapon::renderhudmodel() { renderhudmodel(owner->lastaction); }
@@ -1345,11 +1344,11 @@ void grenades::renderstats()
bool grenades::selectable() { return weapon::selectable() && state != GST_INHAND && mag; }
void grenades::reset() { throwmillis = 0; cookingmillis = 0; if(owner == player1) quicknade = false; state = GST_NONE; }
void grenades::onselecting()
void grenades::onselecting(bool sound)
{
reset();
bool local = (owner == player1);
audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL);
if(sound) audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL);
}
void grenades::onownerdies()
@@ -1511,7 +1510,7 @@ 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() { weapon::onselecting(); scoped = false; player1->scoping = false; }
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::renderhudmodel() { if(!scoped) weapon::renderhudmodel(); }
@@ -1585,9 +1584,9 @@ void akimbo::onammopicked()
}
}
void akimbo::onselecting()
void akimbo::onselecting(bool sound)
{
gun::onselecting();
gun::onselecting(sound);
akimbolastaction[0] = akimbolastaction[1] = lastmillis;
}
+4 -4
View File
@@ -35,7 +35,7 @@ struct weapon
virtual void renderhudmodel();
virtual void renderaimhelp(bool teamwarning);
virtual void onselecting();
virtual void onselecting(bool sound);
virtual void ondeselecting() {}
virtual void onammopicked() {}
virtual void onownerdies() {}
@@ -72,7 +72,7 @@ struct grenades : weapon
bool selectable();
void reset();
bool busy();
void onselecting();
void onselecting(bool sound);
void onownerdies();
void removebounceent(bounceent *b);
int flashtime() const;
@@ -110,7 +110,7 @@ struct sniperrifle : gun
int dynspread();
float dynrecoil();
bool selectable();
void onselecting();
void onselecting(bool sound);
void ondeselecting();
void onownerdies();
void renderhudmodel();
@@ -160,7 +160,7 @@ struct akimbo : gun
void attackfx(const vec &from, const vec &to, int millis);
void onammopicked();
void onselecting();
void onselecting(bool sound);
bool selectable();
void updatetimers(int millis);
void reset();