Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_invasion.qc File Reference
Include dependency graph for sv_invasion.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ClearWinners ()
bool Invasion_CheckPlayers ()
bool Invasion_CheckWinner ()
void invasion_DelayedInit (entity this)
entity invasion_GetWaveEntity (int wavenum)
void invasion_Initialize ()
Monster invasion_PickMonster (int supermonster_count)
entity invasion_PickSpawn ()
void Invasion_RoundStart ()
void invasion_ScoreRules ()
void invasion_SpawnChosenMonster (Monster mon)
void invasion_SpawnMonsters (int supermonster_count)
 MUTATOR_HOOKFUNCTION (inv, AccuracyTargetValid)
 MUTATOR_HOOKFUNCTION (inv, AllowMobButcher)
 MUTATOR_HOOKFUNCTION (inv, AllowMobSpawning)
 MUTATOR_HOOKFUNCTION (inv, BotShouldAttack)
 MUTATOR_HOOKFUNCTION (inv, CheckRules_World)
 MUTATOR_HOOKFUNCTION (inv, Damage_Calculate)
 MUTATOR_HOOKFUNCTION (inv, MonsterDies)
 MUTATOR_HOOKFUNCTION (inv, MonsterSpawn)
 MUTATOR_HOOKFUNCTION (inv, PlayerRegen)
 MUTATOR_HOOKFUNCTION (inv, PlayerSpawn)
 MUTATOR_HOOKFUNCTION (inv, SetStartItems)
 MUTATOR_HOOKFUNCTION (inv, SV_StartFrame)
 spawnfunc (invasion_spawnpoint)
 spawnfunc (invasion_wave)
 spawnfunc (target_invasion_roundend)
void target_invasion_roundend_use (entity this, entity actor, entity trigger)
int WinningCondition_Invasion ()

Variables

int autocvar_g_invasion_monster_count
float autocvar_g_invasion_round_timelimit
float autocvar_g_invasion_spawn_delay
float autocvar_g_invasion_spawnpoint_spawn_delay
float autocvar_g_invasion_warmup
bool autocvar_g_invasion_zombies_only
bool inv_endreached
bool inv_warning_shown
bool victent_present

Function Documentation

◆ ClearWinners()

void ClearWinners ( )

Definition at line 1534 of file world.qc.

1535{
1536 FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), { it.winning = 0; });
1537}
#define IS_PLAYER(s)
Definition player.qh:243
#define INGAME(it)
Definition sv_rules.qh:24
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References FOREACH_CLIENT, INGAME, and IS_PLAYER.

Referenced by WinningCondition_Invasion().

◆ Invasion_CheckPlayers()

bool Invasion_CheckPlayers ( )

Definition at line 314 of file sv_invasion.qc.

315{
316 return true;
317}

Referenced by invasion_DelayedInit().

◆ Invasion_CheckWinner()

bool Invasion_CheckWinner ( )

Definition at line 243 of file sv_invasion.qc.

244{
246 {
247 IL_EACH(g_monsters, true,
248 {
249 Monster_Remove(it);
250 });
252
253 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
254 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
256 return 1;
257 }
258
259 float total_alive_monsters = 0, supermonster_count = 0;
260
261 IL_EACH(g_monsters, GetResource(it, RES_HEALTH) > 0,
262 {
263 if(it.monsterdef.spawnflags & MON_FLAG_SUPERMONSTER)
264 ++supermonster_count;
265 ++total_alive_monsters;
266 });
267
268 if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < inv_maxspawned)
269 {
270 if(time >= inv_lastcheck)
271 {
272 invasion_SpawnMonsters(supermonster_count);
274 }
275
276 return 0;
277 }
278
279 if(inv_numspawned < 1)
280 return 0; // nothing has spawned yet
281
283 return 0;
284
285 entity winner = NULL;
286 float winning_score = 0;
287
289 float cs = GameRules_scoring_add(it, KILLS, 0);
290 if(cs > winning_score)
291 {
292 winning_score = cs;
293 winner = it;
294 }
295 });
296
297 IL_EACH(g_monsters, true,
298 {
299 Monster_Remove(it);
300 });
302
303 if(winner)
304 {
305 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_PLAYER_WIN, winner.netname);
306 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_PLAYER_WIN, winner.netname);
307 }
308
310
311 return 1;
312}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
float time
#define IL_EACH(this, cond, body)
#define IL_CLEAR(this)
Remove all elements.
const int MON_FLAG_SUPERMONSTER
Definition monster.qh:12
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define NULL
Definition post.qh:14
void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
#define round_handler_GetEndTime()
float autocvar_g_invasion_warmup
float autocvar_g_invasion_round_timelimit
float autocvar_g_invasion_spawn_delay
void invasion_SpawnMonsters(int supermonster_count)
int inv_numkilled
int inv_maxspawned
int inv_numspawned
int inv_maxcurrent
float inv_lastcheck
void Monster_Remove(entity this)
IntrusiveList g_monsters
#define GameRules_scoring_add(client, fld, value)
Definition sv_rules.qh:85

References autocvar_g_invasion_round_timelimit, autocvar_g_invasion_spawn_delay, autocvar_g_invasion_warmup, entity(), FOREACH_CLIENT, g_monsters, GameRules_scoring_add, GetResource(), IL_CLEAR, IL_EACH, inv_lastcheck, inv_maxcurrent, inv_maxspawned, inv_numkilled, inv_numspawned, invasion_SpawnMonsters(), IS_PLAYER, MON_FLAG_SUPERMONSTER, Monster_Remove(), NULL, round_handler_GetEndTime, round_handler_Init(), Send_Notification(), and time.

Referenced by invasion_DelayedInit().

◆ invasion_DelayedInit()

void invasion_DelayedInit ( entity this)

Definition at line 482 of file sv_invasion.qc.

483{
485 cvar_set("fraglimit", "0");
486
487 independent_players = 1; // to disable extra useless scores
488
490
492
494 {
497
498 inv_roundcnt = 0;
499 inv_maxrounds = 15; // 15?
500 }
501}
void cvar_set(string name, string value)
void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, void() roundStart_func)
bool independent_players
Definition client.qh:310
bool Invasion_CheckPlayers()
void Invasion_RoundStart()
void invasion_ScoreRules()
bool Invasion_CheckWinner()
const int INV_TYPE_ROUND
const int INV_TYPE_HUNT
int inv_roundcnt
int autocvar_g_invasion_type
Definition sv_invasion.qh:5
int inv_maxrounds
const int INV_TYPE_STAGE

References autocvar_g_invasion_round_timelimit, autocvar_g_invasion_type, autocvar_g_invasion_warmup, cvar_set(), entity(), independent_players, inv_maxrounds, inv_roundcnt, INV_TYPE_HUNT, INV_TYPE_ROUND, INV_TYPE_STAGE, Invasion_CheckPlayers(), Invasion_CheckWinner(), Invasion_RoundStart(), invasion_ScoreRules(), round_handler_Init(), and round_handler_Spawn().

Referenced by invasion_Initialize().

◆ invasion_GetWaveEntity()

entity invasion_GetWaveEntity ( int wavenum)

Definition at line 156 of file sv_invasion.qc.

157{
158 IL_EACH(g_invasion_waves, it.cnt == wavenum,
159 {
160 return it; // found one
161 });
162
163 // if no specific one is found, find the last existing wave ent
164 entity best = NULL;
165 IL_EACH(g_invasion_waves, it.cnt <= wavenum,
166 {
167 if(!best || it.cnt > best.cnt)
168 best = it;
169 });
170
171 return best;
172}
best
Definition all.qh:82
IntrusiveList g_invasion_waves
Definition sv_invasion.qh:8

References best, entity(), g_invasion_waves, IL_EACH, and NULL.

Referenced by invasion_SpawnChosenMonster().

◆ invasion_Initialize()

void invasion_Initialize ( )

Definition at line 503 of file sv_invasion.qc.

504{
506}
const int INITPRIO_GAMETYPE
Definition constants.qh:94
void invasion_DelayedInit(entity this)
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References InitializeEntity(), INITPRIO_GAMETYPE, invasion_DelayedInit(), and NULL.

Referenced by REGISTER_MUTATOR().

◆ invasion_PickMonster()

Monster invasion_PickMonster ( int supermonster_count)

Definition at line 126 of file sv_invasion.qc.

127{
129
130 FOREACH(Monsters, it != MON_Null,
131 {
133 || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
134 continue;
136 continue;
137 RandomSelection_AddEnt(it, 1, 1);
138 });
139
141}
#define FOREACH(list, cond, body)
Definition iter.qh:19
const int MONSTER_TYPE_PASSIVE
Definition monster.qh:18
const int MONSTER_TYPE_FLY
Definition monster.qh:9
const int MONSTER_TYPE_UNDEAD
Definition monster.qh:19
const int MON_FLAG_HIDDEN
Definition monster.qh:20
const int MONSTER_TYPE_SWIM
Definition monster.qh:10
const int MONSTER_SIZE_QUAKE
Definition monster.qh:17
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
#define RandomSelection_AddEnt(e, weight, priority)
Definition random.qh:14
entity RandomSelection_chosen_ent
Definition random.qh:5
bool autocvar_g_invasion_zombies_only

References autocvar_g_invasion_zombies_only, FOREACH, MON_FLAG_HIDDEN, MON_FLAG_SUPERMONSTER, MONSTER_SIZE_QUAKE, MONSTER_TYPE_FLY, MONSTER_TYPE_PASSIVE, MONSTER_TYPE_SWIM, MONSTER_TYPE_UNDEAD, RandomSelection_AddEnt, RandomSelection_chosen_ent, and RandomSelection_Init().

Referenced by invasion_SpawnMonsters().

◆ invasion_PickSpawn()

entity invasion_PickSpawn ( )

Definition at line 143 of file sv_invasion.qc.

144{
146
148 {
149 RandomSelection_AddEnt(it, 1, ((time < it.spawnshieldtime) ? 0.2 : 1)); // give recently used spawnpoints a very low rating
151 });
152
154}
float autocvar_g_invasion_spawnpoint_spawn_delay
IntrusiveList g_invasion_spawns
Definition sv_invasion.qh:9

References autocvar_g_invasion_spawnpoint_spawn_delay, entity(), g_invasion_spawns, IL_EACH, RandomSelection_AddEnt, RandomSelection_chosen_ent, RandomSelection_Init(), and time.

Referenced by invasion_SpawnChosenMonster().

◆ Invasion_RoundStart()

void Invasion_RoundStart ( )

Definition at line 319 of file sv_invasion.qc.

320{
321 int numplayers = 0;
323 it.player_blocked = false;
324 ++numplayers;
325 });
326
328 inv_roundcnt += 1; // a limiter to stop crazy counts
329
331
332 inv_maxcurrent = 0;
333 inv_numspawned = 0;
334 inv_numkilled = 0;
335
337}
float rint(float f)
float max(float f,...)
int numplayers
Definition scoreboard.qh:26
int autocvar_g_invasion_monster_count
float inv_monsterskill

References autocvar_g_invasion_monster_count, FOREACH_CLIENT, inv_maxcurrent, inv_maxrounds, inv_maxspawned, inv_monsterskill, inv_numkilled, inv_numspawned, inv_roundcnt, IS_PLAYER, max(), numplayers, and rint().

Referenced by invasion_DelayedInit().

◆ invasion_ScoreRules()

void invasion_ScoreRules ( )

Definition at line 474 of file sv_invasion.qc.

475{
477 GameRules_scoring(0, 0, 0, {
478 field(SP_KILLS, "kills", SFL_SORT_PRIO_PRIMARY);
479 });
480}
const int SFL_SORT_PRIO_PRIMARY
Definition scores.qh:134
#define GameRules_score_enabled(value)
Definition sv_rules.qh:41
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition sv_rules.qh:58

References GameRules_score_enabled, GameRules_scoring, and SFL_SORT_PRIO_PRIMARY.

Referenced by invasion_DelayedInit().

◆ invasion_SpawnChosenMonster()

void invasion_SpawnChosenMonster ( Monster mon)

Definition at line 174 of file sv_invasion.qc.

175{
176 entity monster;
179
180 string tospawn = "";
181 if(wave_ent && wave_ent.spawnmob && wave_ent.spawnmob != "")
182 {
184 FOREACH_WORD(wave_ent.spawnmob, true,
185 {
186 RandomSelection_AddString(it, 1, 1);
187 });
188
190 }
191
192 if(spawn_point == NULL)
193 {
195 {
196 inv_warning_shown = true;
197 LOG_TRACE("Warning: couldn't find any invasion_spawnpoint spawnpoints, attempting to spawn monsters in random locations");
198 }
199 entity e = spawn();
200 setsize(e, mon.m_mins, mon.m_maxs);
201
203 {
204 monster = spawnmonster(e, tospawn, mon, NULL, NULL, e.origin, false, false, 2);
205 monster.angles_x = monster.angles_z = 0;
206 }
207 else
208 {
209 delete(e);
210 return;
211 }
212 }
213 else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
214 monster = spawnmonster(spawn(), ((spawn_point.spawnmob && spawn_point.spawnmob != "") ? spawn_point.spawnmob : tospawn), mon, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
215
216 if(!monster)
217 return;
218
219 StatusEffects_remove(STATUSEFFECT_SpawnShield, monster, STATUSEFFECT_REMOVE_NORMAL);
220
221 if(spawn_point)
222 {
223 if(spawn_point.target_range)
224 monster.target_range = spawn_point.target_range;
225 monster.target2 = spawn_point.target2;
226 }
227
228 if(monster.monster_attack)
230 monster.monster_attack = false; // it's the player's job to kill all the monsters
231
233 monster.spawnflags |= MONSTERFLAG_MINIBOSS; // last round spawns minibosses
234}
vector m_mins
hitbox size
Definition monster.qh:50
vector m_maxs
hitbox size
Definition monster.qh:52
float Q3SURFACEFLAG_SKY
float DPCONTENTS_SKY
float DPCONTENTS_DONOTENTER
float DPCONTENTS_SOLID
float DPCONTENTS_CORPSE
float DPCONTENTS_BODY
float DPCONTENTS_PLAYERCLIP
float DPCONTENTS_SLIME
float DPCONTENTS_LAVA
#define spawn
#define spawn_point(name, color)
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
#define LOG_TRACE(...)
Definition log.qh:76
@ STATUSEFFECT_REMOVE_NORMAL
Effect is being removed by a function, calls regular removal mechanics.
Definition all.qh:28
string RandomSelection_chosen_string
Definition random.qh:7
void StatusEffects_remove(StatusEffect this, entity actor, int removal_type)
entity invasion_GetWaveEntity(int wavenum)
bool inv_warning_shown
entity invasion_PickSpawn()
IntrusiveList g_monster_targets
const int MONSTERFLAG_MINIBOSS
entity spawnmonster(entity e, string monster, Monster monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
Definition sv_spawn.qc:14
float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
Definition world.qc:1231

References DPCONTENTS_BODY, DPCONTENTS_CORPSE, DPCONTENTS_DONOTENTER, DPCONTENTS_LAVA, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SKY, DPCONTENTS_SLIME, DPCONTENTS_SOLID, entity(), FOREACH_WORD, g_monster_targets, IL_REMOVE(), inv_maxrounds, inv_roundcnt, inv_warning_shown, invasion_GetWaveEntity(), invasion_PickSpawn(), LOG_TRACE, Monster::m_maxs, Monster::m_mins, MONSTERFLAG_MINIBOSS, MoveToRandomMapLocation(), NULL, Q3SURFACEFLAG_SKY, RandomSelection_chosen_string, RandomSelection_Init(), spawn, spawn_point, spawnmonster(), STATUSEFFECT_REMOVE_NORMAL, and StatusEffects_remove().

Referenced by invasion_SpawnMonsters().

◆ invasion_SpawnMonsters()

void invasion_SpawnMonsters ( int supermonster_count)

Definition at line 236 of file sv_invasion.qc.

237{
238 Monster chosen_monster = invasion_PickMonster(supermonster_count);
239
240 invasion_SpawnChosenMonster(chosen_monster);
241}
Monster invasion_PickMonster(int supermonster_count)
void invasion_SpawnChosenMonster(Monster mon)

References invasion_PickMonster(), and invasion_SpawnChosenMonster().

Referenced by Invasion_CheckWinner().

◆ MUTATOR_HOOKFUNCTION() [1/12]

MUTATOR_HOOKFUNCTION ( inv ,
AccuracyTargetValid  )

Definition at line 443 of file sv_invasion.qc.

444{
446
448 return MUT_ACCADD_INVALID;
450}
#define M_ARGV(x, type)
Definition events.qh:17
@ MUT_ACCADD_INDIFFERENT
Definition events.qh:862
@ MUT_ACCADD_INVALID
Definition events.qh:861
entity frag_target
Definition sv_ctf.qc:2321
#define IS_MONSTER(v)
Definition utils.qh:21

References entity(), frag_target, IS_MONSTER, M_ARGV, MUT_ACCADD_INDIFFERENT, and MUT_ACCADD_INVALID.

◆ MUTATOR_HOOKFUNCTION() [2/12]

MUTATOR_HOOKFUNCTION ( inv ,
AllowMobButcher  )

Definition at line 468 of file sv_invasion.qc.

469{
470 M_ARGV(0, string) = "This command does not work during an invasion!";
471 return true;
472}

References M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [3/12]

MUTATOR_HOOKFUNCTION ( inv ,
AllowMobSpawning  )

Definition at line 452 of file sv_invasion.qc.

453{
454 // monster spawning disabled during an invasion
455 M_ARGV(1, string) = "You cannot spawn monsters during an invasion!";
456 return true;
457}

References M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [4/12]

MUTATOR_HOOKFUNCTION ( inv ,
BotShouldAttack  )

Definition at line 426 of file sv_invasion.qc.

427{
428 entity targ = M_ARGV(1, entity);
429
430 if(!IS_MONSTER(targ))
431 return true;
432}

References entity(), IS_MONSTER, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [5/12]

MUTATOR_HOOKFUNCTION ( inv ,
CheckRules_World  )

Definition at line 459 of file sv_invasion.qc.

460{
462 return false;
463
464 M_ARGV(0, float) = WinningCondition_Invasion();
465 return true;
466}
int WinningCondition_Invasion()

References autocvar_g_invasion_type, CheckRules_World(), INV_TYPE_ROUND, M_ARGV, and WinningCondition_Invasion().

◆ MUTATOR_HOOKFUNCTION() [6/12]

MUTATOR_HOOKFUNCTION ( inv ,
Damage_Calculate  )

Definition at line 409 of file sv_invasion.qc.

410{
411 entity frag_attacker = M_ARGV(1, entity);
413 float frag_damage = M_ARGV(4, float);
415
416 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target) && frag_attacker != frag_target)
417 {
418 frag_damage = 0;
419 frag_force = '0 0 0';
420
421 M_ARGV(4, float) = frag_damage;
423 }
424}
vector
Definition self.qh:92
float frag_damage
Definition sv_ctf.qc:2322
vector frag_force
Definition sv_ctf.qc:2323

References entity(), frag_damage, frag_force, frag_target, IS_PLAYER, M_ARGV, and vector.

◆ MUTATOR_HOOKFUNCTION() [7/12]

MUTATOR_HOOKFUNCTION ( inv ,
MonsterDies  )

Definition at line 339 of file sv_invasion.qc.

340{
342 entity frag_attacker = M_ARGV(1, entity);
343
344 if(!(frag_target.spawnflags & MONSTERFLAG_RESPAWNED))
345 {
347 {
348 inv_numkilled += 1;
349 inv_maxcurrent -= 1;
350 }
351
352 if(IS_PLAYER(frag_attacker))
353 {
354 if(SAME_TEAM(frag_attacker, frag_target))
355 GameRules_scoring_add(frag_attacker, KILLS, -1);
356 else
357 GameRules_scoring_add(frag_attacker, KILLS, +1);
358 }
359 }
360}
const int MONSTERFLAG_RESPAWNED
#define SAME_TEAM(a, b)
Definition teams.qh:241

References autocvar_g_invasion_type, entity(), frag_target, GameRules_scoring_add, inv_maxcurrent, inv_numkilled, INV_TYPE_ROUND, IS_PLAYER, M_ARGV, MONSTERFLAG_RESPAWNED, and SAME_TEAM.

◆ MUTATOR_HOOKFUNCTION() [8/12]

MUTATOR_HOOKFUNCTION ( inv ,
MonsterSpawn  )

Definition at line 362 of file sv_invasion.qc.

363{
364 entity mon = M_ARGV(0, entity);
366
368 return false; // allowed
369
370 if(!(mon.spawnflags & MONSTERFLAG_SPAWNED))
371 return true;
372
373 if(!(mon.spawnflags & MONSTERFLAG_RESPAWNED))
374 {
375 inv_numspawned += 1;
376 inv_maxcurrent += 1;
377 }
378
379 mon.monster_skill = inv_monsterskill;
380
381 if(mon.monsterdef.spawnflags & MON_FLAG_SUPERMONSTER)
382 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_INVASION_SUPERMONSTER, mon.m_name);
383}
float DPCONTENTS_BOTCLIP
float DPCONTENTS_MONSTERCLIP
const int MONSTERFLAG_SPAWNED

References autocvar_g_invasion_type, DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_MONSTERCLIP, DPCONTENTS_SOLID, entity(), inv_maxcurrent, inv_monsterskill, inv_numspawned, INV_TYPE_HUNT, M_ARGV, MON_FLAG_SUPERMONSTER, MONSTERFLAG_RESPAWNED, MONSTERFLAG_SPAWNED, NULL, and Send_Notification().

◆ MUTATOR_HOOKFUNCTION() [9/12]

MUTATOR_HOOKFUNCTION ( inv ,
PlayerRegen  )

Definition at line 394 of file sv_invasion.qc.

395{
396 // no regeneration in invasion, regardless of the gametype
397 return true;
398}

◆ MUTATOR_HOOKFUNCTION() [10/12]

MUTATOR_HOOKFUNCTION ( inv ,
PlayerSpawn  )

Definition at line 400 of file sv_invasion.qc.

401{
402 entity player = M_ARGV(0, entity);
403
404 if(player.bot_attack)
405 IL_REMOVE(g_bot_targets, player);
406 player.bot_attack = false;
407}
IntrusiveList g_bot_targets
Definition api.qh:149

References entity(), g_bot_targets, IL_REMOVE(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [11/12]

MUTATOR_HOOKFUNCTION ( inv ,
SetStartItems  )

Definition at line 434 of file sv_invasion.qc.

435{
437 {
438 start_health = 200;
439 start_armorvalue = 200;
440 }
441}
float start_armorvalue
Definition world.qh:97
float start_health
Definition world.qh:96

References autocvar_g_invasion_type, INV_TYPE_ROUND, start_armorvalue, and start_health.

◆ MUTATOR_HOOKFUNCTION() [12/12]

MUTATOR_HOOKFUNCTION ( inv ,
SV_StartFrame  )

Definition at line 385 of file sv_invasion.qc.

386{
388 return; // uses map spawned monsters
389
390 monsters_total = inv_maxspawned; // TODO: make sure numspawned never exceeds maxspawned
392}
int monsters_killed
int monsters_total

References autocvar_g_invasion_type, inv_maxspawned, inv_numkilled, INV_TYPE_ROUND, monsters_killed, and monsters_total.

◆ spawnfunc() [1/3]

spawnfunc ( invasion_spawnpoint )

Definition at line 65 of file sv_invasion.qc.

66{
67 if(!g_invasion) { delete(this); return; }
68
70}
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
bool g_invasion
Definition sv_invasion.qh:6

References g_invasion, g_invasion_spawns, and IL_PUSH().

◆ spawnfunc() [2/3]

spawnfunc ( invasion_wave )

Definition at line 58 of file sv_invasion.qc.

59{
60 if(!g_invasion) { delete(this); return; }
61
63}

References g_invasion, g_invasion_waves, and IL_PUSH().

◆ spawnfunc() [3/3]

spawnfunc ( target_invasion_roundend )

Definition at line 45 of file sv_invasion.qc.

46{
47 if(!g_invasion) { delete(this); return; }
48
49 victent_present = true; // a victory entity is present, we don't need to rely on monster count TODO: merge this with the intrusive list (can check empty)
50
51 if(!this.count) { this.count = 0.7; } // require at least 70% of the players to reach the end before triggering victory
52
54
56}
float count
Definition powerups.qc:22
#define use
bool victent_present
void target_invasion_roundend_use(entity this, entity actor, entity trigger)
IntrusiveList g_invasion_roundends
Definition sv_invasion.qh:7

References count, g_invasion, g_invasion_roundends, IL_PUSH(), target_invasion_roundend_use(), use, and victent_present.

◆ target_invasion_roundend_use()

void target_invasion_roundend_use ( entity this,
entity actor,
entity trigger )

Definition at line 25 of file sv_invasion.qc.

26{
27 if(!IS_PLAYER(actor)) { return; }
28
29 actor.inv_endreached = true;
30
31 int plnum = 0;
32 int realplnum = 0;
33 // let's not count bots
35 ++realplnum;
36 if(it.inv_endreached)
37 ++plnum;
38 });
39 if(plnum < ceil(realplnum * min(1, this.count))) // 70% of players
40 return;
41
42 this.winning = true;
43}
float ceil(float f)
float min(float f,...)
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
float winning
Definition world.qh:131

References ceil(), count, entity(), FOREACH_CLIENT, IS_PLAYER, IS_REAL_CLIENT, min(), and winning.

Referenced by spawnfunc().

◆ WinningCondition_Invasion()

int WinningCondition_Invasion ( )

Definition at line 76 of file sv_invasion.qc.

77{
78 WinningConditionHelper(NULL); // set worldstatus
79
80 int status = WINNING_NO;
81
83 {
85
86 int found = 0;
88 {
89 ++found;
90 if(it.winning)
91 {
92 bprint("Invasion: round completed.\n");
93 // winners already set
94
95 status = WINNING_YES;
96 break;
97 }
98 });
99
100 if(!found)
101 status = WINNING_YES; // just end it? TODO: should warn mapper!
102 }
104 {
105 ClearWinners();
106
107 int found = 0; // NOTE: this ends the round if no monsters are placed
108 IL_EACH(g_monsters, !(it.spawnflags & MONSTERFLAG_RESPAWNED),
109 {
110 ++found;
111 });
112
113 if(found <= 0)
114 {
115 FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it),
116 {
117 it.winning = true;
118 });
119 status = WINNING_YES;
120 }
121 }
122
123 return status;
124}
#define IS_DEAD(s)
Definition player.qh:245
void bprint(string text,...)
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
Definition scores.qc:443
void ClearWinners()
Definition world.qc:1534
bool inv_endreached
void SetWinners(.float field, float value)
Definition world.qc:1519
const int WINNING_NO
Definition world.qh:132
const int WINNING_YES
Definition world.qh:133

References autocvar_g_invasion_type, bprint(), ClearWinners(), FOREACH_CLIENT, g_invasion_roundends, g_monsters, IL_EACH, inv_endreached, INV_TYPE_HUNT, INV_TYPE_STAGE, IS_DEAD, IS_PLAYER, MONSTERFLAG_RESPAWNED, NULL, SetWinners(), WINNING_NO, WINNING_YES, and WinningConditionHelper().

Referenced by MUTATOR_HOOKFUNCTION().

Variable Documentation

◆ autocvar_g_invasion_monster_count

int autocvar_g_invasion_monster_count

Definition at line 16 of file sv_invasion.qc.

Referenced by Invasion_RoundStart().

◆ autocvar_g_invasion_round_timelimit

float autocvar_g_invasion_round_timelimit

Definition at line 13 of file sv_invasion.qc.

Referenced by Invasion_CheckWinner(), and invasion_DelayedInit().

◆ autocvar_g_invasion_spawn_delay

float autocvar_g_invasion_spawn_delay

Definition at line 18 of file sv_invasion.qc.

Referenced by Invasion_CheckWinner().

◆ autocvar_g_invasion_spawnpoint_spawn_delay

float autocvar_g_invasion_spawnpoint_spawn_delay

Definition at line 14 of file sv_invasion.qc.

Referenced by invasion_PickSpawn().

◆ autocvar_g_invasion_warmup

float autocvar_g_invasion_warmup

Definition at line 15 of file sv_invasion.qc.

Referenced by Invasion_CheckWinner(), and invasion_DelayedInit().

◆ autocvar_g_invasion_zombies_only

bool autocvar_g_invasion_zombies_only

Definition at line 17 of file sv_invasion.qc.

Referenced by invasion_PickMonster().

◆ inv_endreached

bool inv_endreached

Definition at line 21 of file sv_invasion.qc.

Referenced by WinningCondition_Invasion().

◆ inv_warning_shown

bool inv_warning_shown

Definition at line 23 of file sv_invasion.qc.

Referenced by invasion_SpawnChosenMonster().

◆ victent_present

bool victent_present

Definition at line 20 of file sv_invasion.qc.

Referenced by spawnfunc().