mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 03:41:15 +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
|
||||
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;
|
||||
}
|
||||
|
||||
if (self.cooldown && self.weapons[0].weapon_magazine > 20)
|
||||
if (self.cooldown && self.weapons[weapon_slot].weapon_magazine > 20)
|
||||
self.cooldown = false;
|
||||
|
||||
if (GetFiretype(self.weapon) == FIRETYPE_FLAME &&
|
||||
self.weapons[0].weapon_magazine < getWeaponMag(self.weapon)) {
|
||||
self.weapons[0].weapon_magazine += 1;
|
||||
if (self.weapons[weapon_slot].weapon_magazine < getWeaponMag(self.weapon)) {
|
||||
self.weapons[weapon_slot].weapon_magazine += 1;
|
||||
}
|
||||
|
||||
self.ltime = time + 0.1;
|
||||
|
|
|
@ -95,19 +95,20 @@ float() getZombieTotal = {
|
|||
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.
|
||||
if (music_override > time)
|
||||
return;
|
||||
|
||||
local entity p;
|
||||
p = find(world,classname,"player");
|
||||
while(p)
|
||||
{
|
||||
sound(p,CHAN_AUTO,s,1,ATTN_NONE);
|
||||
p = find(p,classname,"player");
|
||||
}
|
||||
// Pick a random player because it needs a source.
|
||||
entity some_player = find(world, classname, "player");
|
||||
sound(some_player, CHAN_AUTO, sound_path, 1, ATTN_NONE);
|
||||
}
|
||||
|
||||
void() updateDogRound =
|
||||
|
@ -141,10 +142,10 @@ void() EndRound =
|
|||
rounds_change = 4;
|
||||
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
||||
if (gotdog && rounds == dogRound) {
|
||||
playSoundAtPlayers("sounds/rounds/droundend.wav");
|
||||
Rounds_PlayTransition("sounds/rounds/droundend.wav");
|
||||
dogWave = false;
|
||||
} else {
|
||||
playSoundAtPlayers("sounds/rounds/eround.wav");
|
||||
Rounds_PlayTransition("sounds/rounds/eround.wav");
|
||||
}
|
||||
round_changetime = time + 10;
|
||||
|
||||
|
@ -181,11 +182,11 @@ void() NewRound =
|
|||
if (rounds != 0)
|
||||
{
|
||||
if (gotdog && rounds == (dogRound - 1)) {
|
||||
playSoundAtPlayers("sounds/rounds/droundstart.wav");
|
||||
Rounds_PlayTransition("sounds/rounds/droundstart.wav");
|
||||
dogWave = true;
|
||||
dog_round_count++;
|
||||
} else {
|
||||
playSoundAtPlayers("sounds/rounds/nround.wav");
|
||||
Rounds_PlayTransition("sounds/rounds/nround.wav");
|
||||
}
|
||||
rounds_change = 6;
|
||||
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
||||
|
|
Loading…
Reference in a new issue