mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 20:01:34 +00:00
SERVER: Minor optimization for round stings
This commit is contained in:
parent
6c769b4e36
commit
1075512ceb
2 changed files with 24 additions and 17 deletions
|
@ -449,16 +449,22 @@ void() PlayerPreThink =
|
||||||
|
|
||||||
// refuel/cool flamethrowers
|
// refuel/cool flamethrowers
|
||||||
if (self.ltime < time) {
|
if (self.ltime < time) {
|
||||||
if (self.weapons[0].weapon_magazine == 0 && !self.cooldown) {
|
// FIXME: Weapon hardcode definition.
|
||||||
|
float weapon_slot = Weapon_PlayerHasWeapon(self, W_M2, true);
|
||||||
|
|
||||||
|
if (!weapon_slot)
|
||||||
|
return;
|
||||||
|
|
||||||
|
weapon_slot--;
|
||||||
|
if (self.weapons[weapon_slot].weapon_magazine == 0 && !self.cooldown) {
|
||||||
self.cooldown = true;
|
self.cooldown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.cooldown && self.weapons[0].weapon_magazine > 20)
|
if (self.cooldown && self.weapons[weapon_slot].weapon_magazine > 20)
|
||||||
self.cooldown = false;
|
self.cooldown = false;
|
||||||
|
|
||||||
if (GetFiretype(self.weapon) == FIRETYPE_FLAME &&
|
if (self.weapons[weapon_slot].weapon_magazine < getWeaponMag(self.weapon)) {
|
||||||
self.weapons[0].weapon_magazine < getWeaponMag(self.weapon)) {
|
self.weapons[weapon_slot].weapon_magazine += 1;
|
||||||
self.weapons[0].weapon_magazine += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ltime = time + 0.1;
|
self.ltime = time + 0.1;
|
||||||
|
|
|
@ -95,19 +95,20 @@ float() getZombieTotal = {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void(string s) playSoundAtPlayers =
|
//
|
||||||
|
// Rounds_PlayTransition(sound_path)
|
||||||
|
// A nice wrapper for sound() that checks if
|
||||||
|
// music is playing and proceeds if not.
|
||||||
|
//
|
||||||
|
void(string sound_path) Rounds_PlayTransition =
|
||||||
{
|
{
|
||||||
// Don't play any round stuff while there's a song egg happening.
|
// Don't play any round stuff while there's a song egg happening.
|
||||||
if (music_override > time)
|
if (music_override > time)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
local entity p;
|
// Pick a random player because it needs a source.
|
||||||
p = find(world,classname,"player");
|
entity some_player = find(world, classname, "player");
|
||||||
while(p)
|
sound(some_player, CHAN_AUTO, sound_path, 1, ATTN_NONE);
|
||||||
{
|
|
||||||
sound(p,CHAN_AUTO,s,1,ATTN_NONE);
|
|
||||||
p = find(p,classname,"player");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void() updateDogRound =
|
void() updateDogRound =
|
||||||
|
@ -141,10 +142,10 @@ void() EndRound =
|
||||||
rounds_change = 4;
|
rounds_change = 4;
|
||||||
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
||||||
if (gotdog && rounds == dogRound) {
|
if (gotdog && rounds == dogRound) {
|
||||||
playSoundAtPlayers("sounds/rounds/droundend.wav");
|
Rounds_PlayTransition("sounds/rounds/droundend.wav");
|
||||||
dogWave = false;
|
dogWave = false;
|
||||||
} else {
|
} else {
|
||||||
playSoundAtPlayers("sounds/rounds/eround.wav");
|
Rounds_PlayTransition("sounds/rounds/eround.wav");
|
||||||
}
|
}
|
||||||
round_changetime = time + 10;
|
round_changetime = time + 10;
|
||||||
|
|
||||||
|
@ -181,11 +182,11 @@ void() NewRound =
|
||||||
if (rounds != 0)
|
if (rounds != 0)
|
||||||
{
|
{
|
||||||
if (gotdog && rounds == (dogRound - 1)) {
|
if (gotdog && rounds == (dogRound - 1)) {
|
||||||
playSoundAtPlayers("sounds/rounds/droundstart.wav");
|
Rounds_PlayTransition("sounds/rounds/droundstart.wav");
|
||||||
dogWave = true;
|
dogWave = true;
|
||||||
dog_round_count++;
|
dog_round_count++;
|
||||||
} else {
|
} else {
|
||||||
playSoundAtPlayers("sounds/rounds/nround.wav");
|
Rounds_PlayTransition("sounds/rounds/nround.wav");
|
||||||
}
|
}
|
||||||
rounds_change = 6;
|
rounds_change = 6;
|
||||||
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
||||||
|
|
Loading…
Reference in a new issue