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

Go to the source code of this file.

Macros

#define AS_ROUND_DELAY   5

Functions

void as_round_think ()
bool assault_decreaser_sprite_visible (entity this, entity player, entity view)
void assault_new_round (entity this)
void assault_objective_decrease_use (entity this, entity actor, entity trigger)
void assault_objective_reset (entity this)
void assault_objective_use (entity this, entity actor, entity trigger)
void assault_roundstart_use (entity this, entity actor, entity trigger)
void assault_roundstart_use_this (entity this)
void assault_setenemytoobjective (entity this)
void assault_wall_think (entity this)
bool destructible_heal (entity targ, entity inflictor, float amount, float limit)
void havocbot_ast_reset_role (entity this)
void havocbot_goalrating_ast_targets (entity this, float ratingscale)
void havocbot_role_ast_defense (entity this)
void havocbot_role_ast_offense (entity this)
void havocbot_role_ast_setrole (entity this, float role)
 MUTATOR_HOOKFUNCTION (as, CheckRules_World)
 MUTATOR_HOOKFUNCTION (as, HavocBot_ChooseRole)
 MUTATOR_HOOKFUNCTION (as, OnEntityPreSpawn)
 MUTATOR_HOOKFUNCTION (as, PlayerSpawn)
 MUTATOR_HOOKFUNCTION (as, PlayHitsound)
 MUTATOR_HOOKFUNCTION (as, ReadLevelCvars)
 MUTATOR_HOOKFUNCTION (as, ReadyRestart_Deny)
 MUTATOR_HOOKFUNCTION (as, TeamBalance_CheckAllowedTeams)
 MUTATOR_HOOKFUNCTION (as, TurretSpawn)
 MUTATOR_HOOKFUNCTION (as, VehicleInit)
 spawnfunc (func_assault_destructible)
 spawnfunc (func_assault_wall)
 spawnfunc (info_player_attacker)
 spawnfunc (info_player_defender)
 spawnfunc (target_assault_roundend)
 spawnfunc (target_assault_roundstart)
 spawnfunc (target_objective)
 spawnfunc (target_objective_decrease)
void target_assault_roundend_reset (entity this)
void target_assault_roundend_use (entity this, entity actor, entity trigger)
void target_objective_decrease_activate (entity this)
void target_objective_decrease_findtarget (entity this)
vector target_objective_spawn_evalfunc (entity this, entity player, entity spot, vector current)
int WinningCondition_Assault ()

Variables

entity as_round
bool assault_turrets_teamswap_forbidden
entity ent_winning
entity sprite

Macro Definition Documentation

◆ AS_ROUND_DELAY

#define AS_ROUND_DELAY   5

Definition at line 12 of file sv_assault.qc.

Referenced by assault_new_round(), and WinningCondition_Assault().

Function Documentation

◆ as_round_think()

void as_round_think ( )

Definition at line 223 of file sv_assault.qc.

224{
225 game_stopped = false;
226 assault_new_round(as_round.ent_winning);
227 delete(as_round);
228 as_round = NULL;
229}
float game_stopped
Definition stats.qh:81
#define NULL
Definition post.qh:14
void assault_new_round(entity this)
entity as_round

References as_round, assault_new_round(), game_stopped, and NULL.

Referenced by WinningCondition_Assault().

◆ assault_decreaser_sprite_visible()

bool assault_decreaser_sprite_visible ( entity this,
entity player,
entity view )

Definition at line 98 of file sv_assault.qc.

99{
100 if(GetResource(this.assault_decreaser.enemy, RES_HEALTH) >= ASSAULT_VALUE_INACTIVE)
101 return false;
102
103 return true;
104}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
entity assault_decreaser
Definition sv_assault.qh:34
const int ASSAULT_VALUE_INACTIVE
Definition sv_assault.qh:6

References assault_decreaser, ASSAULT_VALUE_INACTIVE, entity(), and GetResource().

Referenced by target_objective_decrease_activate().

◆ assault_new_round()

void assault_new_round ( entity this)

Definition at line 196 of file sv_assault.qc.

197{
198 // up round counter
199 this.winning = this.winning + 1;
200
201 // swap attacker/defender roles
204 else
206
208 {
209 if(it.team_saved == NUM_TEAM_1)
210 it.team_saved = NUM_TEAM_2;
211 else if(it.team_saved == NUM_TEAM_2)
212 it.team_saved = NUM_TEAM_1;
213 });
214
215 // reset the level with a countdown
216 cvar_set("timelimit", ftos(ceil(time - AS_ROUND_DELAY - game_starttime) / 60));
217 bprint("Starting second round...\n");
218 ReadyRestart_force(true); // sets game_starttime
219}
#define IS_CLIENT(s)
Definition player.qh:242
float game_starttime
Definition stats.qh:82
float time
#define IL_EACH(this, cond, body)
void cvar_set(string name, string value)
float ceil(float f)
void bprint(string text,...)
string ftos(float f)
void ReadyRestart_force(bool is_fake_round_start)
Definition vote.qc:441
IntrusiveList g_saved_team
Definition vote.qh:79
#define AS_ROUND_DELAY
Definition sv_assault.qc:12
int assault_attacker_team
Definition sv_assault.qh:53
const int NUM_TEAM_2
Definition teams.qh:14
const int NUM_TEAM_1
Definition teams.qh:13
float winning
Definition world.qh:131

References AS_ROUND_DELAY, assault_attacker_team, bprint(), ceil(), cvar_set(), entity(), ftos(), g_saved_team, game_starttime, IL_EACH, IS_CLIENT, NUM_TEAM_1, NUM_TEAM_2, ReadyRestart_force(), time, and winning.

Referenced by as_round_think().

◆ assault_objective_decrease_use()

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

Definition at line 44 of file sv_assault.qc.

45{
46 if(actor.team != assault_attacker_team)
47 {
48 // wrong team triggered decrease
49 return;
50 }
51
52 if(trigger.assault_sprite)
53 {
55 if(trigger.classname == "func_assault_destructible")
56 trigger.sprite = NULL; // TODO: just unsetting it?!
57 }
58 else
59 return; // already activated! cannot activate again!
60
61 float hlth = GetResource(this.enemy, RES_HEALTH);
62 if (hlth < ASSAULT_VALUE_INACTIVE)
63 {
64 if (hlth - this.dmg > 0.5)
65 {
66 GameRules_scoring_add_team(actor, SCORE, this.dmg);
67 TakeResource(this.enemy, RES_HEALTH, this.dmg);
68 }
69 else
70 {
71 GameRules_scoring_add_team(actor, SCORE, hlth);
72 GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
73 SetResourceExplicit(this.enemy, RES_HEALTH, -1);
74
75 if(this.enemy.message)
76 FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); });
77
78 SUB_UseTargets(this.enemy, this, trigger);
79 }
80 }
81}
float dmg
Definition breakable.qc:12
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
#define IS_PLAYER(s)
Definition player.qh:243
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
void centerprint(string text,...)
entity enemy
Definition sv_ctf.qh:153
#define GameRules_scoring_add_team(client, fld, value)
Definition sv_rules.qh:89
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50
void WaypointSprite_Disown(entity wp, float fadetime)
float waypointsprite_deadlifetime

References assault_attacker_team, ASSAULT_VALUE_INACTIVE, centerprint(), dmg, enemy, entity(), FOREACH_CLIENT, GameRules_scoring_add_team, GetResource(), IS_PLAYER, NULL, SetResourceExplicit(), SUB_UseTargets(), TakeResource(), waypointsprite_deadlifetime, and WaypointSprite_Disown().

Referenced by spawnfunc().

◆ assault_objective_reset()

void assault_objective_reset ( entity this)

Definition at line 38 of file sv_assault.qc.

39{
41}

References ASSAULT_VALUE_INACTIVE, entity(), and SetResourceExplicit().

Referenced by spawnfunc().

◆ assault_objective_use()

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

Definition at line 15 of file sv_assault.qc.

16{
17 // activate objective
18 SetResourceExplicit(this, RES_HEALTH, 100);
19 //print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
20 //print("Activator is ", actor.classname, "\n");
21
22 IL_EACH(g_assault_objectivedecreasers, it.target == this.targetname,
23 {
24 target_objective_decrease_activate(it);
25 });
26}
IntrusiveList g_assault_objectivedecreasers
Definition sv_assault.qh:11

References entity(), g_assault_objectivedecreasers, IL_EACH, and SetResourceExplicit().

Referenced by spawnfunc().

◆ assault_roundstart_use()

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

Definition at line 153 of file sv_assault.qc.

154{
155 SUB_UseTargets(this, this, trigger);
156
157 // (Re)spawn all turrets
158 IL_EACH(g_turrets, true,
159 {
161 {
162 // Swap turret teams
163 if(it.team == NUM_TEAM_1)
164 it.team = NUM_TEAM_2;
165 else
166 it.team = NUM_TEAM_1;
167 }
168
169 // Doubles as teamchange
170 turret_respawn(it);
171 });
172}
bool assault_turrets_teamswap_forbidden
void turret_respawn(entity this)
IntrusiveList g_turrets

References assault_turrets_teamswap_forbidden, entity(), g_turrets, IL_EACH, NUM_TEAM_1, NUM_TEAM_2, SUB_UseTargets(), and turret_respawn().

Referenced by assault_roundstart_use_this(), and spawnfunc().

◆ assault_roundstart_use_this()

void assault_roundstart_use_this ( entity this)

Definition at line 173 of file sv_assault.qc.

174{
176}
void assault_roundstart_use(entity this, entity actor, entity trigger)

References assault_roundstart_use(), entity(), and NULL.

Referenced by spawnfunc().

◆ assault_setenemytoobjective()

void assault_setenemytoobjective ( entity this)

Definition at line 83 of file sv_assault.qc.

84{
85 IL_EACH(g_assault_objectives, it.targetname == this.target,
86 {
87 if(this.enemy == NULL)
88 this.enemy = it;
89 else
90 objerror(this, "more than one objective as target - fix the map!");
91 break;
92 });
93
94 if(this.enemy == NULL)
95 objerror(this, "no objective as target - fix the map!");
96}
#define objerror
Definition pre.qh:8
IntrusiveList g_assault_objectives
Definition sv_assault.qh:12

References enemy, entity(), g_assault_objectives, IL_EACH, NULL, and objerror.

Referenced by spawnfunc(), and target_objective_decrease_findtarget().

◆ assault_wall_think()

void assault_wall_think ( entity this)

Definition at line 178 of file sv_assault.qc.

179{
180 if(GetResource(this.enemy, RES_HEALTH) < 0)
181 {
182 this.model = "";
183 this.solid = SOLID_NOT;
184 }
185 else
186 {
187 this.model = this.mdl;
188 this.solid = SOLID_BSP;
189 }
190
191 this.nextthink = time + 0.2;
192}
string mdl
Definition item.qh:89
const float SOLID_NOT
float nextthink
const float SOLID_BSP
model
Definition ent_cs.qc:139
solid
Definition ent_cs.qc:165

References enemy, entity(), GetResource(), mdl, model, nextthink, solid, SOLID_BSP, SOLID_NOT, and time.

Referenced by spawnfunc().

◆ destructible_heal()

bool destructible_heal ( entity targ,
entity inflictor,
float amount,
float limit )

Definition at line 333 of file sv_assault.qc.

334{
335 float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
336 float hlth = GetResource(targ, RES_HEALTH);
337 if (hlth <= 0 || hlth >= true_limit)
338 return false;
339
340 GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
341 if(targ.sprite)
342 {
343 WaypointSprite_UpdateHealth(targ.sprite, GetResource(targ, RES_HEALTH));
344 }
346 return true;
347}
void func_breakable_colormod(entity this)
Definition breakable.qc:81
const int RES_LIMIT_NONE
Definition resources.qh:60
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.
void WaypointSprite_UpdateHealth(entity e, float f)

References entity(), func_breakable_colormod(), GetResource(), GiveResourceWithLimit(), RES_LIMIT_NONE, and WaypointSprite_UpdateHealth().

Referenced by spawnfunc().

◆ havocbot_ast_reset_role()

void havocbot_ast_reset_role ( entity this)

Definition at line 549 of file sv_assault.qc.

550{
551 if(IS_DEAD(this))
552 return;
553
554 if(this.team == assault_attacker_team)
556 else
558}
int team
Definition main.qh:188
#define IS_DEAD(s)
Definition player.qh:245
void havocbot_role_ast_setrole(entity this, float role)
const int HAVOCBOT_AST_ROLE_OFFENSE
Definition sv_assault.qh:40
const int HAVOCBOT_AST_ROLE_DEFENSE
Definition sv_assault.qh:39

References assault_attacker_team, entity(), HAVOCBOT_AST_ROLE_DEFENSE, HAVOCBOT_AST_ROLE_OFFENSE, havocbot_role_ast_setrole(), IS_DEAD, and team.

Referenced by havocbot_role_ast_defense(), havocbot_role_ast_offense(), MUTATOR_HOOKFUNCTION(), and void().

◆ havocbot_goalrating_ast_targets()

void havocbot_goalrating_ast_targets ( entity this,
float ratingscale )

dprint("waypoints around target were found\n");

Definition at line 398 of file sv_assault.qc.

399{
400 IL_EACH(g_assault_destructibles, it.bot_attack,
401 {
402 if (it.target == "")
403 continue;
404
405 bool found = false;
406 entity destr = it;
407 IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
408 {
409 float hlth = GetResource(it.enemy, RES_HEALTH);
410 if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE)
411 {
412 found = true;
413 break;
414 }
415 });
416
417 if(!found)
418 continue;
419
420 vector p = 0.5 * (it.absmin + it.absmax);
421
422 // Find and rate waypoints around it
423 found = false;
424 entity best = NULL;
425 float bestvalue = FLOAT_MAX;
426 entity des = it;
427 for (float radius = 500; radius <= 1500 && !found; radius += 500)
428 {
429 FOREACH_ENTITY_RADIUS(p, radius, it.classname == "waypoint" && !(it.wpflags & WAYPOINTFLAG_GENERATED),
430 {
431 if(checkpvs(it.origin, des))
432 {
433 found = true;
434 if(it.cnt < bestvalue)
435 {
436 best = it;
437 bestvalue = it.cnt;
438 }
439 }
440 });
441 }
442
443 if(best)
444 {
446 // te_lightning2(NULL, '0 0 0', best.origin);
447 // te_knightspike(best.origin);
448
449 navigation_routerating(this, best, ratingscale, 4000);
450 best.cnt += 1;
451
452 this.havocbot_attack_time = 0;
453
454 if(checkpvs(this.origin + this.view_ofs, it))
455 if(checkpvs(this.origin + this.view_ofs, best))
456 {
457 // dprint("increasing attack time for this target\n");
458 this.havocbot_attack_time = time + 2;
459 }
460 }
461 });
462}
void navigation_routerating(entity this, entity e, float f, float rangebias)
const int WAYPOINTFLAG_GENERATED
Definition api.qh:11
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float radius
Definition impulse.qh:11
float checkpvs(vector viewpos, entity viewee)
vector origin
const float FLOAT_MAX
Definition float.qh:3
best
Definition all.qh:82
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
vector view_ofs
Definition progsdefs.qc:151
vector
Definition self.qh:92
IntrusiveList g_assault_destructibles
Definition sv_assault.qh:10
float havocbot_attack_time
Definition sv_assault.qh:42

References best, entity(), FLOAT_MAX, FOREACH_ENTITY_RADIUS, g_assault_destructibles, IL_EACH, NULL, radius, vector, and WAYPOINTFLAG_GENERATED.

Referenced by havocbot_role_ast_defense(), and havocbot_role_ast_offense().

◆ havocbot_role_ast_defense()

void havocbot_role_ast_defense ( entity this)

Definition at line 499 of file sv_assault.qc.

500{
501 if(IS_DEAD(this))
502 {
503 this.havocbot_attack_time = 0;
505 return;
506 }
507
508 // Set the role timeout if necessary
509 if (!this.havocbot_role_timeout)
510 this.havocbot_role_timeout = time + 120;
511
512 if (time > this.havocbot_role_timeout)
513 {
515 return;
516 }
517
519 return;
520
522 {
523 // role: defense
525 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 3000);
527 havocbot_goalrating_items(this, 30000, this.origin, 10000);
529
531 }
532}
void navigation_goalrating_start(entity this)
void navigation_goalrating_timeout_set(entity this)
Definition navigation.qc:20
bool navigation_goalrating_timeout(entity this)
Definition navigation.qc:44
void navigation_goalrating_end(entity this)
float havocbot_role_timeout
Definition api.qh:46
void havocbot_ast_reset_role(entity this)
void havocbot_goalrating_ast_targets(entity this, float ratingscale)
void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius)
Definition roles.qc:106
void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius)
Definition roles.qc:176

References entity(), havocbot_ast_reset_role(), havocbot_attack_time, havocbot_goalrating_ast_targets(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_items(), havocbot_role_timeout, IS_DEAD, navigation_goalrating_end(), navigation_goalrating_start(), navigation_goalrating_timeout(), navigation_goalrating_timeout_set(), origin, and time.

Referenced by havocbot_role_ast_setrole(), and void().

◆ havocbot_role_ast_offense()

void havocbot_role_ast_offense ( entity this)

Definition at line 464 of file sv_assault.qc.

465{
466 if(IS_DEAD(this))
467 {
468 this.havocbot_attack_time = 0;
470 return;
471 }
472
473 // Set the role timeout if necessary
474 if (!this.havocbot_role_timeout)
475 this.havocbot_role_timeout = time + 120;
476
477 if (time > this.havocbot_role_timeout)
478 {
480 return;
481 }
482
484 return;
485
487 {
488 // role: offense
490 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 650);
492 havocbot_goalrating_items(this, 30000, this.origin, 10000);
494
496 }
497}

References entity(), havocbot_ast_reset_role(), havocbot_attack_time, havocbot_goalrating_ast_targets(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_items(), havocbot_role_timeout, IS_DEAD, navigation_goalrating_end(), navigation_goalrating_start(), navigation_goalrating_timeout(), navigation_goalrating_timeout_set(), origin, and time.

Referenced by havocbot_role_ast_setrole(), and void().

◆ havocbot_role_ast_setrole()

void havocbot_role_ast_setrole ( entity this,
float role )

Definition at line 534 of file sv_assault.qc.

535{
536 switch(role)
537 {
539 this.havocbot_role = havocbot_role_ast_defense;
540 this.havocbot_role_timeout = 0;
541 break;
543 this.havocbot_role = havocbot_role_ast_offense;
544 this.havocbot_role_timeout = 0;
545 break;
546 }
547}
void havocbot_role_ast_defense(entity this)
void havocbot_role_ast_offense(entity this)

References entity(), HAVOCBOT_AST_ROLE_DEFENSE, HAVOCBOT_AST_ROLE_OFFENSE, havocbot_role_ast_defense(), havocbot_role_ast_offense(), and havocbot_role_timeout.

Referenced by havocbot_ast_reset_role().

◆ MUTATOR_HOOKFUNCTION() [1/10]

MUTATOR_HOOKFUNCTION ( as ,
CheckRules_World  )

Definition at line 608 of file sv_assault.qc.

609{
610 M_ARGV(0, float) = WinningCondition_Assault();
611 return true;
612}
#define M_ARGV(x, type)
Definition events.qh:17
int WinningCondition_Assault()

References CheckRules_World(), M_ARGV, and WinningCondition_Assault().

◆ MUTATOR_HOOKFUNCTION() [2/10]

MUTATOR_HOOKFUNCTION ( as ,
HavocBot_ChooseRole  )

Definition at line 586 of file sv_assault.qc.

587{
588 entity bot = M_ARGV(0, entity);
589
591 return true;
592}

References entity(), havocbot_ast_reset_role(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [3/10]

MUTATOR_HOOKFUNCTION ( as ,
OnEntityPreSpawn  )

Definition at line 621 of file sv_assault.qc.

622{
623 entity ent = M_ARGV(0, entity);
624
625 switch(ent.classname)
626 {
627 case "info_player_team1":
628 case "info_player_team2":
629 case "info_player_team3":
630 case "info_player_team4":
631 return true;
632 }
633}

References entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [4/10]

MUTATOR_HOOKFUNCTION ( as ,
PlayerSpawn  )

Definition at line 561 of file sv_assault.qc.

562{
563 entity player = M_ARGV(0, entity);
564
565 if(player.team == assault_attacker_team)
566 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_ATTACKING);
567 else
568 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_DEFENDING);
569}
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573

References assault_attacker_team, entity(), M_ARGV, and Send_Notification().

◆ MUTATOR_HOOKFUNCTION() [5/10]

MUTATOR_HOOKFUNCTION ( as ,
PlayHitsound  )

Definition at line 594 of file sv_assault.qc.

595{
596 entity frag_victim = M_ARGV(0, entity);
597
598 return (frag_victim.classname == "func_assault_destructible");
599}

References entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [6/10]

MUTATOR_HOOKFUNCTION ( as ,
ReadLevelCvars  )

Definition at line 614 of file sv_assault.qc.

615{
616 // incompatible
617 warmup_stage = 0;
619}
bool warmup_stage
Definition main.qh:120
bool sv_ready_restart_after_countdown
Definition world.qh:116

References sv_ready_restart_after_countdown, and warmup_stage.

◆ MUTATOR_HOOKFUNCTION() [7/10]

MUTATOR_HOOKFUNCTION ( as ,
ReadyRestart_Deny  )

Definition at line 635 of file sv_assault.qc.

636{
637 // Readyrestart is forbidden because Assault is actually played in 2 different games, called
638 // rounds, where the map is completely restarted and the timelimit of the second round is set
639 // to the time the previous attacker team took to destroy the main objective
640 // In campaign it's allowed because Assault is played in a single game / round
642 {
644 return false;
645 }
646 return true;
647}
bool autocvar_g_campaign
Definition menu.qc:747

References assault_turrets_teamswap_forbidden, and autocvar_g_campaign.

◆ MUTATOR_HOOKFUNCTION() [8/10]

MUTATOR_HOOKFUNCTION ( as ,
TeamBalance_CheckAllowedTeams  )

Definition at line 601 of file sv_assault.qc.

602{
603 // assault always has 2 teams
604 M_ARGV(0, float) = BIT(0) | BIT(1);
605 return true;
606}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8

References BIT, M_ARGV, and TeamBalance_CheckAllowedTeams().

◆ MUTATOR_HOOKFUNCTION() [9/10]

MUTATOR_HOOKFUNCTION ( as ,
TurretSpawn  )

Definition at line 571 of file sv_assault.qc.

572{
573 entity turret = M_ARGV(0, entity);
574
575 if(!turret.team || turret.team == FLOAT_MAX)
576 turret.team = assault_attacker_team; // this gets reversed when match starts (assault_roundstart_use)
577}

References assault_attacker_team, entity(), FLOAT_MAX, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [10/10]

MUTATOR_HOOKFUNCTION ( as ,
VehicleInit  )

Definition at line 579 of file sv_assault.qc.

580{
581 entity veh = M_ARGV(0, entity);
582
583 veh.nextthink = time + 0.5;
584}

References entity(), M_ARGV, and time.

◆ spawnfunc() [1/8]

spawnfunc ( func_assault_destructible )

Definition at line 349 of file sv_assault.qc.

350{
351 if (!g_assault) { delete(this); return; }
352
353 this.spawnflags = 3;
354 this.event_heal = destructible_heal;
356
358 this.team = NUM_TEAM_2;
359 else
360 this.team = NUM_TEAM_1;
361
363}
#define g_assault
Definition assault.qh:27
void func_breakable_setup(entity this)
Definition breakable.qc:317
int spawnflags
Definition ammo.qh:15
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
bool destructible_heal(entity targ, entity inflictor, float amount, float limit)

References assault_attacker_team, destructible_heal(), func_breakable_setup(), g_assault, g_assault_destructibles, IL_PUSH(), NUM_TEAM_1, NUM_TEAM_2, spawnflags, and team.

◆ spawnfunc() [2/8]

spawnfunc ( func_assault_wall )

Definition at line 365 of file sv_assault.qc.

366{
367 if (!g_assault) { delete(this); return; }
368
369 this.mdl = this.model;
370 _setmodel(this, this.mdl);
371 this.solid = SOLID_BSP;
373 this.nextthink = time;
375}
const int INITPRIO_FINDTARGET
Definition constants.qh:96
#define setthink(e, f)
void assault_setenemytoobjective(entity this)
Definition sv_assault.qc:83
void assault_wall_think(entity this)
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References assault_setenemytoobjective(), assault_wall_think(), g_assault, InitializeEntity(), INITPRIO_FINDTARGET, mdl, model, nextthink, setthink, solid, SOLID_BSP, and time.

◆ spawnfunc() [3/8]

spawnfunc ( info_player_attacker )

Definition at line 288 of file sv_assault.qc.

289{
290 if (!g_assault) { delete(this); return; }
291
292 this.team = NUM_TEAM_1; // red, gets swapped every round
293 spawnfunc_info_player_deathmatch(this);
294}

References g_assault, NUM_TEAM_1, and team.

◆ spawnfunc() [4/8]

spawnfunc ( info_player_defender )

Definition at line 296 of file sv_assault.qc.

297{
298 if (!g_assault) { delete(this); return; }
299
300 this.team = NUM_TEAM_2; // blue, gets swapped every round
301 spawnfunc_info_player_deathmatch(this);
302}

References g_assault, NUM_TEAM_2, and team.

◆ spawnfunc() [5/8]

spawnfunc ( target_assault_roundend )

Definition at line 377 of file sv_assault.qc.

378{
379 if (!g_assault) { delete(this); return; }
380
381 this.winning = 0; // round not yet won by attackers
383 this.cnt = 0; // first round
385}
float cnt
Definition powerups.qc:24
#define use
void target_assault_roundend_reset(entity this)
void target_assault_roundend_use(entity this, entity actor, entity trigger)

References cnt, g_assault, target_assault_roundend_reset(), target_assault_roundend_use(), use, and winning.

◆ spawnfunc() [6/8]

spawnfunc ( target_assault_roundstart )

◆ spawnfunc() [7/8]

spawnfunc ( target_objective )

Definition at line 304 of file sv_assault.qc.

305{
306 if (!g_assault) { delete(this); return; }
307
310 this.reset = assault_objective_reset;
311 this.reset(this);
313}
spawn_evalfunc_t spawn_evalfunc
void assault_objective_use(entity this, entity actor, entity trigger)
Definition sv_assault.qc:15
vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
Definition sv_assault.qc:28
void assault_objective_reset(entity this)
Definition sv_assault.qc:38

References assault_objective_reset(), assault_objective_use(), g_assault, g_assault_objectives, IL_PUSH(), spawn_evalfunc, target_objective_spawn_evalfunc(), and use.

◆ spawnfunc() [8/8]

spawnfunc ( target_objective_decrease )

Definition at line 315 of file sv_assault.qc.

316{
317 if (!g_assault) { delete(this); return; }
318
320
321 if(!this.dmg)
322 this.dmg = 101;
323
327 this.enemy = NULL;
328
330}
float max_health
void assault_objective_decrease_use(entity this, entity actor, entity trigger)
Definition sv_assault.qc:44
void target_objective_decrease_findtarget(entity this)

References assault_objective_decrease_use(), ASSAULT_VALUE_INACTIVE, dmg, enemy, g_assault, g_assault_objectivedecreasers, IL_PUSH(), InitializeEntity(), INITPRIO_FINDTARGET, max_health, NULL, SetResourceExplicit(), target_objective_decrease_findtarget(), and use.

◆ target_assault_roundend_reset()

void target_assault_roundend_reset ( entity this)

Definition at line 140 of file sv_assault.qc.

141{
142 //print("round end reset\n");
143 ++this.cnt; // up round counter
144 this.winning = false; // up round
145}

References cnt, entity(), and winning.

Referenced by spawnfunc().

◆ target_assault_roundend_use()

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

Definition at line 147 of file sv_assault.qc.

148{
149 this.winning = 1; // round has been won by attackers
150}

References entity(), and winning.

Referenced by spawnfunc().

◆ target_objective_decrease_activate()

void target_objective_decrease_activate ( entity this)

Definition at line 106 of file sv_assault.qc.

107{
108 entity spr;
109 this.owner = NULL;
111 {
112 if(it.assault_sprite != NULL)
113 {
115 if(it.classname == "func_assault_destructible")
116 it.sprite = NULL; // TODO: just unsetting it?!
117 }
118
119 spr = WaypointSprite_SpawnFixed(WP_AssaultDefend, 0.5 * (it.absmin + it.absmax), it, assault_sprite, RADARICON_OBJECTIVE);
120 spr.assault_decreaser = this;
121 spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
123 if(it.classname == "func_assault_destructible")
124 {
125 WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy);
126 WaypointSprite_UpdateMaxHealth(spr, it.max_health);
127 WaypointSprite_UpdateHealth(spr, GetResource(it, RES_HEALTH));
128 it.sprite = spr;
129 }
130 else
131 WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultPush, WP_AssaultPush);
132 });
133}
entity owner
Definition main.qh:87
#define FOREACH_ENTITY_STRING(fld, match, body)
Definition iter.qh:184
bool assault_decreaser_sprite_visible(entity this, entity player, entity view)
Definition sv_assault.qc:98
entity assault_sprite
Definition sv_assault.qh:35
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55
void WaypointSprite_UpdateSprites(entity e, entity _m1, entity _m2, entity _m3)
void WaypointSprite_UpdateMaxHealth(entity e, float f)
entity WaypointSprite_SpawnFixed(entity spr, vector ofs, entity own,.entity ownfield, entity icon)
void WaypointSprite_UpdateRule(entity e, float t, float r)
const int SPRITERULE_TEAMPLAY

References assault_attacker_team, assault_decreaser_sprite_visible(), assault_sprite, entity(), FOREACH_ENTITY_STRING, GetResource(), NULL, owner, SPRITERULE_TEAMPLAY, target, targetname, waypointsprite_deadlifetime, WaypointSprite_Disown(), WaypointSprite_SpawnFixed(), WaypointSprite_UpdateHealth(), WaypointSprite_UpdateMaxHealth(), WaypointSprite_UpdateRule(), and WaypointSprite_UpdateSprites().

◆ target_objective_decrease_findtarget()

void target_objective_decrease_findtarget ( entity this)

Definition at line 135 of file sv_assault.qc.

136{
138}

References assault_setenemytoobjective(), and entity().

Referenced by spawnfunc().

◆ target_objective_spawn_evalfunc()

vector target_objective_spawn_evalfunc ( entity this,
entity player,
entity spot,
vector current )

Definition at line 28 of file sv_assault.qc.

29{
30 float hlth = GetResource(this, RES_HEALTH);
31 if (hlth < 0 || hlth >= ASSAULT_VALUE_INACTIVE)
32 return '-1 0 0';
33 return current;
34}

References ASSAULT_VALUE_INACTIVE, entity(), GetResource(), and vector.

Referenced by spawnfunc().

◆ WinningCondition_Assault()

int WinningCondition_Assault ( )

Definition at line 233 of file sv_assault.qc.

234{
235 if(as_round)
236 return WINNING_NO;
237
238 WinningConditionHelper(NULL); // set worldstatus
239
240 int status = WINNING_NO;
241 // as the timelimit has not yet passed just assume the defending team will win
243 {
245 }
246 else
247 {
249 }
250
251 entity ent;
252 ent = find(NULL, classname, "target_assault_roundend");
253 if(ent)
254 {
255 if(ent.winning) // round end has been triggered by attacking team
256 {
257 bprint(Team_ColoredFullName(assault_attacker_team), " destroyed the objective in ", process_time(2, ceil(time - game_starttime)), "\n");
259
261
262 // in campaign the game ends when the player destroys the objective, there's no second round
263 if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round or the only round in campaign
264 {
265 status = WINNING_YES;
266 }
267 else
268 {
269 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ASSAULT_OBJ_DESTROYED, ceil(time - game_starttime));
270 as_round = new(as_round);
271 as_round.think = as_round_think;
272 as_round.ent_winning = ent;
273 as_round.nextthink = time + AS_ROUND_DELAY;
274 game_stopped = true;
275
276 // make sure timelimit isn't hit while the game is blocked
277 if(autocvar_timelimit > 0)
279 cvar_set("timelimit", ftos(autocvar_timelimit + AS_ROUND_DELAY / 60));
280 }
281 }
282 }
283
284 return status;
285}
#define autocvar_timelimit
Definition stats.qh:92
ERASEABLE string process_time(float outputtype, int seconds)
Definition counting.qh:120
string classname
entity find(entity start,.string field, string match)
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
Definition scores.qc:443
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
Definition scores.qc:107
void as_round_think()
const int ST_ASSAULT_OBJECTIVES
Definition sv_assault.qh:8
#define Team_ColoredFullName(teamid)
Definition teams.qh:232
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 as_round, AS_ROUND_DELAY, as_round_think(), assault_attacker_team, autocvar_g_campaign, autocvar_timelimit, bprint(), ceil(), classname, cvar_set(), entity(), find(), ftos(), game_starttime, game_stopped, NULL, NUM_TEAM_1, NUM_TEAM_2, process_time(), Send_Notification(), SetWinners(), ST_ASSAULT_OBJECTIVES, team, Team_ColoredFullName, TeamScore_AddToTeam(), time, WINNING_NO, WINNING_YES, and WinningConditionHelper().

Referenced by MUTATOR_HOOKFUNCTION().

Variable Documentation

◆ as_round

entity as_round

Definition at line 221 of file sv_assault.qc.

Referenced by as_round_think(), and WinningCondition_Assault().

◆ assault_turrets_teamswap_forbidden

bool assault_turrets_teamswap_forbidden

Definition at line 152 of file sv_assault.qc.

Referenced by assault_roundstart_use(), and MUTATOR_HOOKFUNCTION().

◆ ent_winning

entity ent_winning

Definition at line 222 of file sv_assault.qc.

◆ sprite