Xonotic
sv_lms.qc File Reference
+ Include dependency graph for sv_lms.qc:

Go to the source code of this file.

Functions

void ClearWinners ()
 
bool lms_AddPlayer (entity player)
 
void lms_extralife (entity this)
 
void lms_Initialize ()
 
int LMS_NewPlayerLives ()
 
void lms_RemovePlayer (entity player)
 
 MUTATOR_HOOKFUNCTION (lms, reset_map_global)
 
 MUTATOR_HOOKFUNCTION (lms, reset_map_players)
 
 MUTATOR_HOOKFUNCTION (lms, ReadLevelCvars)
 
 MUTATOR_HOOKFUNCTION (lms, PutClientInServer)
 
 MUTATOR_HOOKFUNCTION (lms, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION (lms, ForbidSpawn)
 
 MUTATOR_HOOKFUNCTION (lms, PlayerDies)
 
 MUTATOR_HOOKFUNCTION (lms, ClientDisconnect)
 
 MUTATOR_HOOKFUNCTION (lms, MakePlayerObserver)
 
 MUTATOR_HOOKFUNCTION (lms, ClientConnect)
 
 MUTATOR_HOOKFUNCTION (lms, PlayerPreThink)
 
 MUTATOR_HOOKFUNCTION (lms, PlayerRegen)
 
 MUTATOR_HOOKFUNCTION (lms, ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION (lms, GiveFragsForKill)
 
 MUTATOR_HOOKFUNCTION (lms, SetStartItems)
 
 MUTATOR_HOOKFUNCTION (lms, ForbidPlayerScore_Clear)
 
 MUTATOR_HOOKFUNCTION (lms, FilterItemDefinition)
 
 MUTATOR_HOOKFUNCTION (lms, OnEntityPreSpawn)
 
 MUTATOR_HOOKFUNCTION (lms, ItemTouch)
 
 MUTATOR_HOOKFUNCTION (lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION (lms, ClientCommand_Spectate)
 
 MUTATOR_HOOKFUNCTION (lms, CheckRules_World)
 
 MUTATOR_HOOKFUNCTION (lms, SetWeaponArena)
 
 MUTATOR_HOOKFUNCTION (lms, AddPlayerScore)
 
int WinningCondition_LMS ()
 

Variables

int autocvar_g_lms_extra_lives
 
bool autocvar_g_lms_items
 
bool autocvar_g_lms_join_anytime
 
int autocvar_g_lms_last_join
 
bool autocvar_g_lms_regenerate
 
bool autocvar_g_lms_rot
 

Function Documentation

◆ ClearWinners()

void ClearWinners ( )

Definition at line 1422 of file world.qc.

References FOREACH_CLIENT, INGAME, and IS_PLAYER.

Referenced by CheckRules_World(), LMS_NewPlayerLives(), WinningCondition_LMS(), WinningCondition_RanOutOfSpawns(), and WinningCondition_Scores().

1423 {
1424  FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), { it.winning = 0; });
1425 }
#define INGAME(it)
Definition: sv_rules.qh:20
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the caller graph for this function:

◆ lms_AddPlayer()

bool lms_AddPlayer ( entity  player)

Definition at line 160 of file sv_lms.qc.

References GameRules_scoring_add, INGAME, INGAME_STATUS_JOINED, INGAME_STATUS_JOINING, INGAME_STATUS_SET, LMS_NewPlayerLives(), time, and warmup_stage.

Referenced by MUTATOR_HOOKFUNCTION().

161 {
162  if (!INGAME(player))
163  {
164  int lives = GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives());
165  if(lives <= 0)
166  return false;
167  if (time < game_starttime)
169  else
170  INGAME_STATUS_SET(player, INGAME_STATUS_JOINING); // this is just to delay setting health and armor that can't be done here
171  }
172  if (warmup_stage || time <= game_starttime)
173  {
174  if(player.lms_spectate_warning)
175  {
176  player.lms_spectate_warning = 0;
177  GameRules_scoring_add(player, LMS_RANK, -GameRules_scoring_add(player, LMS_RANK, 0));
178  int lives = GameRules_scoring_add(player, LMS_LIVES, 0);
179  if(lives <= 0)
180  GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives());
181  }
182  }
183  else
184  {
185  if(GameRules_scoring_add(player, LMS_LIVES, 0) <= 0)
186  {
187  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_LMS_NOLIVES);
188  return false;
189  }
190  }
191  return true;
192 }
#define INGAME(it)
Definition: sv_rules.qh:20
#define INGAME_STATUS_SET(it, s)
Definition: sv_rules.qh:17
#define INGAME_STATUS_JOINED
Definition: sv_rules.qh:13
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
int LMS_NewPlayerLives()
Definition: sv_lms.qc:17
float time
Definition: csprogsdefs.qc:16
#define INGAME_STATUS_JOINING
Definition: sv_rules.qh:12
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lms_extralife()

void lms_extralife ( entity  this)

Definition at line 436 of file sv_lms.qc.

References StartItem().

Referenced by MUTATOR_HOOKFUNCTION().

437 {
438  StartItem(this, ITEM_ExtraLife);
439 }
void StartItem(entity this, GameItem def)
Definition: items.qc:1148
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lms_Initialize()

void lms_Initialize ( )

Definition at line 531 of file sv_lms.qc.

References lms_lowest_lives.

Referenced by REGISTER_MUTATOR().

532 {
533  lms_lowest_lives = 999;
534 }
int lms_lowest_lives
Definition: sv_lms.qh:35
+ Here is the caller graph for this function:

◆ LMS_NewPlayerLives()

int LMS_NewPlayerLives ( )

Definition at line 17 of file sv_lms.qc.

References autocvar_g_lms_join_anytime, autocvar_g_lms_last_join, bound(), ClearWinners(), floor(), lms_lowest_lives, and max().

Referenced by lms_AddPlayer(), and WinningCondition_LMS().

18 {
19  int fl = floor(autocvar_fraglimit);
20  if(fl == 0 || fl > 999)
21  fl = 999;
22 
23  // first player has left the game for dying too much? Nobody else can get in.
24  if(lms_lowest_lives < 1)
25  return 0;
26 
29  return 0;
30 
31  return bound(1, lms_lowest_lives, fl);
32 }
int lms_lowest_lives
Definition: sv_lms.qh:35
bool autocvar_g_lms_join_anytime
Definition: sv_lms.qc:10
int autocvar_g_lms_last_join
Definition: sv_lms.qc:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lms_RemovePlayer()

void lms_RemovePlayer ( entity  player)

Definition at line 256 of file sv_lms.qc.

References CS(), FOREACH_CLIENT, FRAGS_PLAYER, FRAGS_PLAYER_OUT_OF_GAME, FRAGS_SPECTATOR, GameRules_scoring_add, if(), INGAME, IS_PLAYER, killcount, NULL, time, TRANSMUTE(), and warmup_stage.

Referenced by MUTATOR_HOOKFUNCTION().

257 {
258  if (warmup_stage || time < game_starttime)
259  return;
260 
261  float player_rank = GameRules_scoring_add(player, LMS_RANK, 0);
262  if (!player_rank)
263  {
264  if (player.lms_spectate_warning < 2)
265  {
266  player.frags = FRAGS_PLAYER_OUT_OF_GAME;
267  int pl_cnt = 0;
268  FOREACH_CLIENT(IS_PLAYER(it) && it.frags == FRAGS_PLAYER, {
269  pl_cnt++;
270  });
271  GameRules_scoring_add(player, LMS_RANK, pl_cnt + 1);
272  }
273  else if (INGAME(player))
274  {
275  int min_forfeiter_rank = 665; // different from 666
276  FOREACH_CLIENT(it != player, {
277  // update rank of other players that were eliminated
278  if (it.frags == FRAGS_PLAYER_OUT_OF_GAME)
279  {
280  float it_rank = GameRules_scoring_add(it, LMS_RANK, 0);
281  if (it_rank > player_rank && it_rank <= 256)
282  GameRules_scoring_add(it, LMS_RANK, -1);
283  if (it_rank > 256 && it_rank <= min_forfeiter_rank)
284  min_forfeiter_rank = it_rank - 1;
285  }
286  else if (it.frags != FRAGS_SPECTATOR)
287  {
288  float tl = GameRules_scoring_add(it, LMS_LIVES, 0);
289  if(tl < lms_lowest_lives)
290  lms_lowest_lives = tl;
291  }
292  });
293  GameRules_scoring_add(player, LMS_RANK, min_forfeiter_rank);
294  if(!warmup_stage)
295  GameRules_scoring_add(player, LMS_LIVES, -GameRules_scoring_add(player, LMS_LIVES, 0));
296  player.frags = FRAGS_PLAYER_OUT_OF_GAME;
297  TRANSMUTE(Observer, player);
298  }
299  }
300 
301  if (CS(player).killcount != FRAGS_SPECTATOR && player.lms_spectate_warning < 3)
302  {
303  if (GameRules_scoring_add(player, LMS_RANK, 0) > 0 && player.lms_spectate_warning < 2)
304  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
305  else
306  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_FORFEIT, player.netname);
307  }
308 }
#define INGAME(it)
Definition: sv_rules.qh:20
TRANSMUTE(Player, this)
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
int killcount
Definition: client.qh:317
const int FRAGS_PLAYER
Definition: constants.qh:3
#define NULL
Definition: post.qh:17
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
const int FRAGS_SPECTATOR
Definition: constants.qh:4
if(IS_DEAD(this))
Definition: impulse.qc:92
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MUTATOR_HOOKFUNCTION() [1/24]

MUTATOR_HOOKFUNCTION ( lms  ,
reset_map_global   
)

Definition at line 120 of file sv_lms.qc.

References lms_lowest_lives.

121 {
122  lms_lowest_lives = 999;
123 }
int lms_lowest_lives
Definition: sv_lms.qh:35

◆ MUTATOR_HOOKFUNCTION() [2/24]

MUTATOR_HOOKFUNCTION ( lms  ,
reset_map_players   
)

Definition at line 125 of file sv_lms.qc.

References CS(), FOREACH_CLIENT, FRAGS_PLAYER, FRAGS_PLAYER_OUT_OF_GAME, GameRules_scoring_add, INGAME_STATUS_CLEAR, killcount, PutClientInServer(), and TRANSMUTE().

126 {
127  FOREACH_CLIENT(true, {
128  if (it.frags == FRAGS_PLAYER_OUT_OF_GAME)
129  {
130  // players who forfeited (rank >= 256) become spectators
131  if (it.lms_spectate_warning == 2)
132  it.frags = FRAGS_SPECTATOR;
133  else
134  it.frags = FRAGS_PLAYER;
135  }
136 
137  CS(it).killcount = 0;
139  it.lms_spectate_warning = 0;
140  GameRules_scoring_add(it, LMS_RANK, -GameRules_scoring_add(it, LMS_RANK, 0));
141  GameRules_scoring_add(it, LMS_LIVES, -GameRules_scoring_add(it, LMS_LIVES, 0));
142 
143  if (it.frags != FRAGS_PLAYER)
144  continue;
145 
146  TRANSMUTE(Player, it);
147  PutClientInServer(it);
148  });
149 }
TRANSMUTE(Player, this)
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
int killcount
Definition: client.qh:317
const int FRAGS_PLAYER
Definition: constants.qh:3
#define INGAME_STATUS_CLEAR(it)
Definition: sv_rules.qh:18
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
PutClientInServer(this)
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ReadLevelCvars   
)

Definition at line 153 of file sv_lms.qc.

References sv_ready_restart_after_countdown.

154 {
155  // incompatible
157 }
bool sv_ready_restart_after_countdown
Definition: world.qh:119

◆ MUTATOR_HOOKFUNCTION() [4/24]

MUTATOR_HOOKFUNCTION ( lms  ,
PutClientInServer   
)

Definition at line 194 of file sv_lms.qc.

References CS(), entity(), GameRules_scoring_add, IS_BOT_CLIENT, jointime, lms_AddPlayer(), M_ARGV, time, TRANSMUTE(), and warmup_stage.

195 {
196  entity player = M_ARGV(0, entity);
197  if (!warmup_stage && (IS_BOT_CLIENT(player) || CS(player).jointime != time))
198  {
199  if (GameRules_scoring_add(player, LMS_RANK, 0) || !lms_AddPlayer(player))
200  TRANSMUTE(Observer, player);
201  }
202 }
TRANSMUTE(Player, this)
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
float jointime
Definition: client.qh:64
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
float time
Definition: csprogsdefs.qc:16
bool lms_AddPlayer(entity player)
Definition: sv_lms.qc:160
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [5/24]

MUTATOR_HOOKFUNCTION ( lms  ,
PlayerSpawn   
)

Definition at line 204 of file sv_lms.qc.

References entity(), FOREACH_CLIENT, GameRules_scoring_add, GetResource(), INGAME_JOINING, INGAME_STATUS_JOINED, INGAME_STATUS_SET, IS_DEAD, IS_PLAYER, M_ARGV, max(), RES_HEALTH, SetResource(), start_armorvalue, start_health, time, and warmup_stage.

205 {
206  entity player = M_ARGV(0, entity);
207 
208  if (warmup_stage || time < game_starttime)
209  return true;
210 
211  if (INGAME_JOINING(player))
212  {
213  // spawn player with the same amount of health / armor
214  // as the least healthy player with the least number of lives
215  int pl_lives = GameRules_scoring_add(player, LMS_LIVES, 0);
216  float min_health = start_health;
217  float min_armorvalue = start_armorvalue;
218  FOREACH_CLIENT(it != player && IS_PLAYER(it) && !IS_DEAD(it) && GameRules_scoring_add(it, LMS_LIVES, 0) == pl_lives, {
219  if (GetResource(it, RES_HEALTH) < min_health)
220  min_health = GetResource(it, RES_HEALTH);
221  if (GetResource(it, RES_ARMOR) < min_armorvalue)
222  min_armorvalue = GetResource(it, RES_ARMOR);
223  });
224  if (min_health != start_health)
225  SetResource(player, RES_HEALTH, max(1, min_health));
226  if (min_armorvalue != start_armorvalue)
227  SetResource(player, RES_ARMOR, min_armorvalue);
229  }
230 }
#define INGAME_STATUS_SET(it, s)
Definition: sv_rules.qh:17
#define INGAME_STATUS_JOINED
Definition: sv_rules.qh:13
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
RES_HEALTH
Definition: ent_cs.qc:126
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
Definition: cl_resources.qc:26
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float start_health
Definition: world.qh:98
float time
Definition: csprogsdefs.qc:16
float start_armorvalue
Definition: world.qh:99
#define INGAME_JOINING(it)
Definition: sv_rules.qh:22
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [6/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ForbidSpawn   
)

Definition at line 232 of file sv_lms.qc.

References entity(), lms_AddPlayer(), M_ARGV, and warmup_stage.

233 {
234  entity player = M_ARGV(0, entity);
235 
236  if (warmup_stage || lms_AddPlayer(player))
237  return false;
238 
239  return true;
240 }
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define M_ARGV(x, type)
Definition: events.qh:17
bool lms_AddPlayer(entity player)
Definition: sv_lms.qc:160
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [7/24]

MUTATOR_HOOKFUNCTION ( lms  ,
PlayerDies   
)

Definition at line 242 of file sv_lms.qc.

References entity(), GameRules_scoring_add, M_ARGV, RESPAWN_FORCE, RESPAWN_SILENT, and time.

243 {
244  entity frag_target = M_ARGV(2, entity);
245 
246  float tl = GameRules_scoring_add(frag_target, LMS_LIVES, 0);
247  if (tl <= 0)
248  {
249  frag_target.respawn_flags = RESPAWN_SILENT;
250  // prevent unwanted sudden rejoin as spectator and movement of spectator camera
251  frag_target.respawn_time = time + 2;
252  }
253  frag_target.respawn_flags |= RESPAWN_FORCE;
254 }
const int RESPAWN_FORCE
Definition: client.qh:330
entity() spawn
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
#define M_ARGV(x, type)
Definition: events.qh:17
float time
Definition: csprogsdefs.qc:16
const int RESPAWN_SILENT
Definition: client.qh:331
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [8/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ClientDisconnect   
)

Definition at line 310 of file sv_lms.qc.

References entity(), INGAME_STATUS_CLEAR, lms_RemovePlayer(), and M_ARGV.

311 {
312  entity player = M_ARGV(0, entity);
313 
314  // no further message other than the disconnect message
315  player.lms_spectate_warning = 3;
316 
317  lms_RemovePlayer(player);
318  INGAME_STATUS_CLEAR(player);
319 }
entity() spawn
void lms_RemovePlayer(entity player)
Definition: sv_lms.qc:256
#define M_ARGV(x, type)
Definition: events.qh:17
#define INGAME_STATUS_CLEAR(it)
Definition: sv_rules.qh:18
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [9/24]

MUTATOR_HOOKFUNCTION ( lms  ,
MakePlayerObserver   
)

Definition at line 321 of file sv_lms.qc.

References entity(), FRAGS_SPECTATOR, GameRules_scoring_add, INGAME_STATUS_CLEAR, IS_PLAYER, lms_RemovePlayer(), M_ARGV, time, TRANSMUTE(), and warmup_stage.

322 {
323  entity player = M_ARGV(0, entity);
324  bool is_forced = M_ARGV(1, bool);
325 
326  if (!IS_PLAYER(player))
327  return true;
328 
329  if (warmup_stage || time <= game_starttime)
330  {
331  GameRules_scoring_add(player, LMS_LIVES, -GameRules_scoring_add(player, LMS_LIVES, 0));
332  player.frags = FRAGS_SPECTATOR;
333  TRANSMUTE(Observer, player);
334  INGAME_STATUS_CLEAR(player);
335  }
336  else
337  {
338  if (is_forced)
339  player.lms_spectate_warning = 2;
340  if (!GameRules_scoring_add(player, LMS_RANK, 0))
341  lms_RemovePlayer(player);
342  }
343  return true; // prevent team reset
344 }
TRANSMUTE(Player, this)
entity() spawn
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
void lms_RemovePlayer(entity player)
Definition: sv_lms.qc:256
bool warmup_stage
Definition: main.qh:103
#define M_ARGV(x, type)
Definition: events.qh:17
#define INGAME_STATUS_CLEAR(it)
Definition: sv_rules.qh:18
const int FRAGS_SPECTATOR
Definition: constants.qh:4
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [10/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ClientConnect   
)

Definition at line 346 of file sv_lms.qc.

References entity(), FRAGS_SPECTATOR, and M_ARGV.

347 {
348  entity player = M_ARGV(0, entity);
349  player.frags = FRAGS_SPECTATOR;
350 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
const int FRAGS_SPECTATOR
Definition: constants.qh:4
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [11/24]

MUTATOR_HOOKFUNCTION ( lms  ,
PlayerPreThink   
)

Definition at line 352 of file sv_lms.qc.

References DEAD_DYING, DEAD_RESPAWNING, entity(), and M_ARGV.

353 {
354  entity player = M_ARGV(0, entity);
355 
356  if(player.deadflag == DEAD_DYING)
357  player.deadflag = DEAD_RESPAWNING;
358 }
float DEAD_DYING
Definition: progsdefs.qc:275
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
float DEAD_RESPAWNING
Definition: progsdefs.qc:278
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [12/24]

MUTATOR_HOOKFUNCTION ( lms  ,
PlayerRegen   
)

Definition at line 360 of file sv_lms.qc.

References autocvar_g_lms_regenerate, autocvar_g_lms_rot, and M_ARGV.

361 {
363  M_ARGV(2, float) = 0;
364  if(!autocvar_g_lms_rot)
365  M_ARGV(3, float) = 0;
367 }
bool autocvar_g_lms_rot
Definition: sv_lms.qc:14
#define M_ARGV(x, type)
Definition: events.qh:17
bool autocvar_g_lms_regenerate
Definition: sv_lms.qc:13

◆ MUTATOR_HOOKFUNCTION() [13/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ForbidThrowCurrentWeapon   
)

Definition at line 369 of file sv_lms.qc.

370 {
371  // forbode!
372  return true;
373 }

◆ MUTATOR_HOOKFUNCTION() [14/24]

MUTATOR_HOOKFUNCTION ( lms  ,
GiveFragsForKill   
)

Definition at line 375 of file sv_lms.qc.

References entity(), FOREACH_CLIENT, FRAGS_PLAYER, FRAGS_PLAYER_OUT_OF_GAME, GameRules_scoring_add, IS_PLAYER, lms_lowest_lives, M_ARGV, time, and warmup_stage.

376 {
377  entity frag_target = M_ARGV(1, entity);
378 
379  if (!warmup_stage && time > game_starttime)
380  {
381  // remove a life
382  int tl = GameRules_scoring_add(frag_target, LMS_LIVES, -1);
383  if(tl < lms_lowest_lives)
384  lms_lowest_lives = tl;
385  if(tl <= 0)
386  {
387  int pl_cnt = 0;
388  FOREACH_CLIENT(IS_PLAYER(it) && it.frags == FRAGS_PLAYER, {
389  pl_cnt++;
390  });
391  frag_target.frags = FRAGS_PLAYER_OUT_OF_GAME;
392  GameRules_scoring_add(frag_target, LMS_RANK, pl_cnt);
393  }
394  }
395  M_ARGV(2, float) = 0; // frag score
396 
397  return true;
398 }
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
const int FRAGS_PLAYER
Definition: constants.qh:3
#define M_ARGV(x, type)
Definition: events.qh:17
int lms_lowest_lives
Definition: sv_lms.qh:35
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [15/24]

MUTATOR_HOOKFUNCTION ( lms  ,
SetStartItems   
)

Definition at line 400 of file sv_lms.qc.

References cvar(), start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_plasma, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_items, warmup_start_ammo_cells, warmup_start_ammo_fuel, warmup_start_ammo_nails, warmup_start_ammo_plasma, warmup_start_ammo_rockets, warmup_start_ammo_shells, warmup_start_armorvalue, and warmup_start_health.

401 {
402  start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
403  if(!cvar("g_use_ammunition"))
404  start_items |= IT_UNLIMITED_AMMO;
405 
406  start_health = warmup_start_health = cvar("g_lms_start_health");
407  start_armorvalue = warmup_start_armorvalue = cvar("g_lms_start_armor");
408  start_ammo_shells = warmup_start_ammo_shells = cvar("g_lms_start_ammo_shells");
409  start_ammo_nails = warmup_start_ammo_nails = cvar("g_lms_start_ammo_nails");
410  start_ammo_rockets = warmup_start_ammo_rockets = cvar("g_lms_start_ammo_rockets");
411  start_ammo_cells = warmup_start_ammo_cells = cvar("g_lms_start_ammo_cells");
412  start_ammo_plasma = warmup_start_ammo_plasma = cvar("g_lms_start_ammo_plasma");
413  start_ammo_fuel = warmup_start_ammo_fuel = cvar("g_lms_start_ammo_fuel");
414 }
float start_ammo_rockets
Definition: world.qh:87
float start_ammo_fuel
Definition: world.qh:90
float warmup_start_ammo_shells
Definition: world.qh:104
int start_items
Definition: world.qh:84
float start_ammo_shells
Definition: world.qh:85
float warmup_start_ammo_plasma
Definition: world.qh:108
float warmup_start_ammo_cells
Definition: world.qh:107
float warmup_start_ammo_fuel
Definition: world.qh:109
float start_ammo_cells
Definition: world.qh:88
float warmup_start_armorvalue
Definition: world.qh:111
float start_health
Definition: world.qh:98
float warmup_start_ammo_rockets
Definition: world.qh:106
float start_ammo_nails
Definition: world.qh:86
float warmup_start_health
Definition: world.qh:110
float start_armorvalue
Definition: world.qh:99
float start_ammo_plasma
Definition: world.qh:89
float warmup_start_ammo_nails
Definition: world.qh:105
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [16/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ForbidPlayerScore_Clear   
)

Definition at line 416 of file sv_lms.qc.

417 {
418  // don't clear player score
419  return true;
420 }

◆ MUTATOR_HOOKFUNCTION() [17/24]

MUTATOR_HOOKFUNCTION ( lms  ,
FilterItemDefinition   
)

Definition at line 422 of file sv_lms.qc.

References autocvar_g_lms_extra_lives, autocvar_g_lms_items, autocvar_g_pickup_items, entity(), and M_ARGV.

423 {
425  return false;
426 
427  entity definition = M_ARGV(0, entity);
428 
429  if (autocvar_g_lms_extra_lives && definition == ITEM_ExtraLife)
430  {
431  return false;
432  }
433  return (autocvar_g_pickup_items <= 0); // only allow items if explicitly enabled
434 }
int autocvar_g_lms_extra_lives
Definition: sv_lms.qc:9
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
bool autocvar_g_lms_items
Definition: sv_lms.qc:12
int autocvar_g_pickup_items
Definition: items.qh:11
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [18/24]

MUTATOR_HOOKFUNCTION ( lms  ,
OnEntityPreSpawn   
)

Definition at line 441 of file sv_lms.qc.

References autocvar_g_lms_extra_lives, autocvar_g_powerups, entity(), lms_extralife(), M_ARGV, MUTATOR_RETURNVALUE, setorigin(), setthink, spawn(), and time.

442 {
443  if (MUTATOR_RETURNVALUE) return false;
444  if (!autocvar_g_powerups) return false;
445  if (!autocvar_g_lms_extra_lives) return false;
446 
447  entity ent = M_ARGV(0, entity);
448 
449  // Can't use .itemdef here
450  if (ent.classname != "item_health_mega") return false;
451 
452  entity e = spawn();
454 
455  e.nextthink = time + 0.1;
456  e.spawnflags = ent.spawnflags;
457  e.noalign = ent.noalign;
458  setorigin(e, ent.origin);
459 
460  return true;
461 }
int autocvar_g_lms_extra_lives
Definition: sv_lms.qc:9
entity() spawn
void lms_extralife(entity this)
Definition: sv_lms.qc:436
int autocvar_g_powerups
Definition: sv_powerups.qh:7
#define MUTATOR_RETURNVALUE
Definition: base.qh:303
#define M_ARGV(x, type)
Definition: events.qh:17
setorigin(ent, v)
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [19/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ItemTouch   
)

Definition at line 463 of file sv_lms.qc.

References autocvar_g_lms_extra_lives, entity(), GameRules_scoring_add, M_ARGV, MUT_ITEMTOUCH_CONTINUE, MUT_ITEMTOUCH_PICKUP, and MUTATOR_RETURNVALUE.

464 {
465  if(MUTATOR_RETURNVALUE) return false;
466 
467  entity item = M_ARGV(0, entity);
468  entity toucher = M_ARGV(1, entity);
469 
470  if(item.itemdef == ITEM_ExtraLife)
471  {
472  Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES, autocvar_g_lms_extra_lives);
474  return MUT_ITEMTOUCH_PICKUP;
475  }
476 
477  return MUT_ITEMTOUCH_CONTINUE;
478 }
int autocvar_g_lms_extra_lives
Definition: sv_lms.qc:9
entity() spawn
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
#define MUTATOR_RETURNVALUE
Definition: base.qh:303
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [20/24]

MUTATOR_HOOKFUNCTION ( lms  ,
Bot_FixCount  ,
CBC_ORDER_EXCLUSIVE   
)

Definition at line 480 of file sv_lms.qc.

References FOREACH_CLIENT, INGAME, IS_REAL_CLIENT, and M_ARGV.

481 {
483  if (INGAME(it) && it.lms_spectate_warning < 2)
484  ++M_ARGV(0, int); // activerealplayers
485  ++M_ARGV(1, int); // realplayers
486  });
487 
488  return true;
489 }
#define INGAME(it)
Definition: sv_rules.qh:20
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [21/24]

MUTATOR_HOOKFUNCTION ( lms  ,
ClientCommand_Spectate   
)

Definition at line 491 of file sv_lms.qc.

References entity(), FRAGS_PLAYER_OUT_OF_GAME, FRAGS_SPECTATOR, M_ARGV, MUT_SPECCMD_CONTINUE, MUT_SPECCMD_RETURN, sprint(), time, and warmup_stage.

492 {
493  entity player = M_ARGV(0, entity);
494 
495  if(warmup_stage || time < game_starttime || player.lms_spectate_warning)
496  {
497  // for the forfeit message...
498  player.lms_spectate_warning = 2;
499  }
500  else
501  {
502  if(player.frags != FRAGS_SPECTATOR && player.frags != FRAGS_PLAYER_OUT_OF_GAME)
503  {
504  player.lms_spectate_warning = 1;
505  sprint(player, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
506  }
507  return MUT_SPECCMD_RETURN;
508  }
509  return MUT_SPECCMD_CONTINUE;
510 }
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define M_ARGV(x, type)
Definition: events.qh:17
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
const int FRAGS_SPECTATOR
Definition: constants.qh:4
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [22/24]

MUTATOR_HOOKFUNCTION ( lms  ,
CheckRules_World   
)

Definition at line 512 of file sv_lms.qc.

References M_ARGV, and WinningCondition_LMS().

513 {
514  M_ARGV(0, float) = WinningCondition_LMS();
515  return true;
516 }
#define M_ARGV(x, type)
Definition: events.qh:17
int WinningCondition_LMS()
Definition: sv_lms.qc:39
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [23/24]

MUTATOR_HOOKFUNCTION ( lms  ,
SetWeaponArena   
)

Definition at line 518 of file sv_lms.qc.

References autocvar_g_lms_weaponarena, and M_ARGV.

519 {
520  if(M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
521  M_ARGV(0, string) = autocvar_g_lms_weaponarena;
522 }
#define M_ARGV(x, type)
Definition: events.qh:17
string autocvar_g_lms_weaponarena
Definition: sv_lms.qh:12

◆ MUTATOR_HOOKFUNCTION() [24/24]

MUTATOR_HOOKFUNCTION ( lms  ,
AddPlayerScore   
)

Definition at line 524 of file sv_lms.qc.

References entity(), and M_ARGV.

525 {
526  if(game_stopped)
527  if(M_ARGV(0, entity) == SP_LMS_RANK) // score field
528  return true; // allow writing to this field in intermission as it is needed for newly joining players
529 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ WinningCondition_LMS()

int WinningCondition_LMS ( )

Definition at line 39 of file sv_lms.qc.

References autocvar_g_campaign, campaign_bots_may_start, ClearWinners(), entity(), FOREACH_CLIENT, FRAGS_PLAYER, GameRules_scoring_add, IS_PLAYER, IS_REAL_CLIENT, LMS_NewPlayerLives(), LOG_TRACE, NULL, SetWinners(), time, warmup_stage, winning, WINNING_NEVER, WINNING_NO, WINNING_YES, WinningConditionHelper(), WinningConditionHelper_secondscore, WinningConditionHelper_topscore, and WinningConditionHelper_winner.

Referenced by MUTATOR_HOOKFUNCTION().

40 {
41  if (warmup_stage || time <= game_starttime)
42  return WINNING_NO;
43 
44  entity first_player = NULL;
45  int totalplayers = 0;
46  FOREACH_CLIENT(IS_PLAYER(it) && it.frags == FRAGS_PLAYER, {
47  if (!totalplayers)
48  first_player = it;
49  ++totalplayers;
50  });
51 
52  if (totalplayers)
53  {
54  if (totalplayers > 1)
55  {
56  // two or more active players - continue with the game
57 
59  {
61  float pl_lives = GameRules_scoring_add(it, LMS_LIVES, 0);
62  if (!pl_lives)
63  return WINNING_YES; // human player lost, game over
64  break;
65  });
66  }
67  }
68  else
69  {
70  // exactly one player?
71 
72  ClearWinners();
73  SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
74 
75  if (LMS_NewPlayerLives())
76  {
77  // game still running (that is, nobody got removed from the game by a frag yet)? then continue
78  return WINNING_NO;
79  }
80  else
81  {
82  // a winner!
83  // and assign him his first place
84  GameRules_scoring_add(first_player, LMS_RANK, 1);
85  return WINNING_YES;
86  }
87  }
88  }
89  else
90  {
91  // nobody is playing at all...
92  if (LMS_NewPlayerLives())
93  {
94  // wait for players...
95  }
96  else
97  {
98  // SNAFU (maybe a draw game?)
99  ClearWinners();
100  LOG_TRACE("No players, ending game.");
101  return WINNING_YES;
102  }
103  }
104 
105  // When we get here, we have at least two players who are actually LIVING,
106  // now check if the top two players have equal score.
108 
109  ClearWinners();
111  WinningConditionHelper_winner.winning = true;
113  return WINNING_NEVER;
114 
115  // Top two have different scores? Way to go for our beloved TIMELIMIT!
116  return WINNING_NO;
117 }
void ClearWinners()
Definition: world.qc:1422
void SetWinners(.float field, float value)
Definition: world.qc:1407
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool warmup_stage
Definition: main.qh:103
const int WINNING_YES
Definition: world.qh:136
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
entity WinningConditionHelper_winner
the winning player, or NULL if none
Definition: scores.qh:113
const int FRAGS_PLAYER
Definition: constants.qh:3
float WinningConditionHelper_secondscore
second highest score
Definition: scores.qh:109
#define NULL
Definition: post.qh:17
const int WINNING_NEVER
Definition: world.qh:137
int LMS_NewPlayerLives()
Definition: sv_lms.qc:17
bool campaign_bots_may_start
campaign mode: bots shall spawn but wait for the player to spawn before they do anything in other gam...
Definition: campaign.qh:27
#define LOG_TRACE(...)
Definition: log.qh:81
const int WINNING_NO
Definition: world.qh:135
bool autocvar_g_campaign
Definition: campaign.qh:6
float WinningConditionHelper_topscore
highest score
Definition: scores.qh:108
float time
Definition: csprogsdefs.qc:16
float winning
Definition: world.qh:134
#define IS_PLAYER(v)
Definition: utils.qh:9
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
Definition: scores.qc:415
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_lms_extra_lives

int autocvar_g_lms_extra_lives

Definition at line 9 of file sv_lms.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_lms_items

bool autocvar_g_lms_items

Definition at line 12 of file sv_lms.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_lms_join_anytime

bool autocvar_g_lms_join_anytime

Definition at line 10 of file sv_lms.qc.

Referenced by LMS_NewPlayerLives().

◆ autocvar_g_lms_last_join

int autocvar_g_lms_last_join

Definition at line 11 of file sv_lms.qc.

Referenced by LMS_NewPlayerLives().

◆ autocvar_g_lms_regenerate

bool autocvar_g_lms_regenerate

Definition at line 13 of file sv_lms.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_lms_rot

bool autocvar_g_lms_rot

Definition at line 14 of file sv_lms.qc.

Referenced by MUTATOR_HOOKFUNCTION().