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;
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:241
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:242
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:52
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 332 of file sv_assault.qc.

333{
334 float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
335 float hlth = GetResource(targ, RES_HEALTH);
336 if (hlth <= 0 || hlth >= true_limit)
337 return false;
338
339 GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
340 if(targ.sprite)
341 {
342 WaypointSprite_UpdateHealth(targ.sprite, GetResource(targ, RES_HEALTH));
343 }
345 return true;
346}
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 548 of file sv_assault.qc.

549{
550 if(IS_DEAD(this))
551 return;
552
553 if(this.team == assault_attacker_team)
555 else
557}
int team
Definition main.qh:188
#define IS_DEAD(s)
Definition player.qh:244
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 397 of file sv_assault.qc.

398{
399 IL_EACH(g_assault_destructibles, it.bot_attack,
400 {
401 if (it.target == "")
402 continue;
403
404 bool found = false;
405 entity destr = it;
406 IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
407 {
408 float hlth = GetResource(it.enemy, RES_HEALTH);
409 if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE)
410 {
411 found = true;
412 break;
413 }
414 });
415
416 if(!found)
417 continue;
418
419 vector p = 0.5 * (it.absmin + it.absmax);
420
421 // Find and rate waypoints around it
422 found = false;
423 entity best = NULL;
424 float bestvalue = FLOAT_MAX;
425 entity des = it;
426 for (float radius = 500; radius <= 1500 && !found; radius += 500)
427 {
428 FOREACH_ENTITY_RADIUS(p, radius, it.classname == "waypoint" && !(it.wpflags & WAYPOINTFLAG_GENERATED),
429 {
430 if(checkpvs(it.origin, des))
431 {
432 found = true;
433 if(it.cnt < bestvalue)
434 {
435 best = it;
436 bestvalue = it.cnt;
437 }
438 }
439 });
440 }
441
442 if(best)
443 {
445 // te_lightning2(NULL, '0 0 0', best.origin);
446 // te_knightspike(best.origin);
447
448 navigation_routerating(this, best, ratingscale, 4000);
449 ++best.cnt;
450
451 this.havocbot_attack_time = 0;
452
453 if(checkpvs(this.origin + this.view_ofs, it))
454 if(checkpvs(this.origin + this.view_ofs, best))
455 {
456 // dprint("increasing attack time for this target\n");
457 this.havocbot_attack_time = time + 2;
458 }
459 }
460 });
461}
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:84
#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 498 of file sv_assault.qc.

499{
500 if(IS_DEAD(this))
501 {
502 this.havocbot_attack_time = 0;
504 return;
505 }
506
507 // Set the role timeout if necessary
508 if (!this.havocbot_role_timeout)
509 this.havocbot_role_timeout = time + 120;
510
511 if (time > this.havocbot_role_timeout)
512 {
514 return;
515 }
516
518 return;
519
521 {
522 // role: defense
524 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 3000);
526 havocbot_goalrating_items(this, 30000, this.origin, 10000);
528
530 }
531}
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 463 of file sv_assault.qc.

464{
465 if(IS_DEAD(this))
466 {
467 this.havocbot_attack_time = 0;
469 return;
470 }
471
472 // Set the role timeout if necessary
473 if (!this.havocbot_role_timeout)
474 this.havocbot_role_timeout = time + 120;
475
476 if (time > this.havocbot_role_timeout)
477 {
479 return;
480 }
481
483 return;
484
486 {
487 // role: offense
489 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 650);
491 havocbot_goalrating_items(this, 30000, this.origin, 10000);
493
495 }
496}

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 533 of file sv_assault.qc.

534{
535 switch(role)
536 {
538 this.havocbot_role = havocbot_role_ast_defense;
539 this.havocbot_role_timeout = 0;
540 break;
542 this.havocbot_role = havocbot_role_ast_offense;
543 this.havocbot_role_timeout = 0;
544 break;
545 }
546}
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 607 of file sv_assault.qc.

608{
609 M_ARGV(0, float) = WinningCondition_Assault();
610 return true;
611}
#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 585 of file sv_assault.qc.

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

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

◆ MUTATOR_HOOKFUNCTION() [3/10]

MUTATOR_HOOKFUNCTION ( as ,
OnEntityPreSpawn  )

Definition at line 620 of file sv_assault.qc.

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

References entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [4/10]

MUTATOR_HOOKFUNCTION ( as ,
PlayerSpawn  )

Definition at line 560 of file sv_assault.qc.

561{
562 entity player = M_ARGV(0, entity);
563
564 if(player.team == assault_attacker_team)
565 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_ATTACKING);
566 else
567 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_DEFENDING);
568}
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 593 of file sv_assault.qc.

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

References entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [6/10]

MUTATOR_HOOKFUNCTION ( as ,
ReadLevelCvars  )

Definition at line 613 of file sv_assault.qc.

614{
615 // incompatible
616 warmup_stage = 0;
618}
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 634 of file sv_assault.qc.

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

References assault_turrets_teamswap_forbidden, and autocvar_g_campaign.

◆ MUTATOR_HOOKFUNCTION() [8/10]

MUTATOR_HOOKFUNCTION ( as ,
TeamBalance_CheckAllowedTeams  )

Definition at line 600 of file sv_assault.qc.

601{
602 // assault always has 2 teams
603 M_ARGV(0, float) = BIT(0) | BIT(1);
604 return true;
605}
#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 570 of file sv_assault.qc.

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

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

◆ MUTATOR_HOOKFUNCTION() [10/10]

MUTATOR_HOOKFUNCTION ( as ,
VehicleInit  )

Definition at line 578 of file sv_assault.qc.

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

References entity(), M_ARGV, and time.

◆ spawnfunc() [1/8]

spawnfunc ( func_assault_destructible )

Definition at line 348 of file sv_assault.qc.

349{
350 if (!g_assault) { delete(this); return; }
351
352 this.spawnflags = 3;
353 this.event_heal = destructible_heal;
355
357 this.team = NUM_TEAM_2;
358 else
359 this.team = NUM_TEAM_1;
360
362}
#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 364 of file sv_assault.qc.

365{
366 if (!g_assault) { delete(this); return; }
367
368 this.mdl = this.model;
369 _setmodel(this, this.mdl);
370 this.solid = SOLID_BSP;
372 this.nextthink = time;
374}
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:2230

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 287 of file sv_assault.qc.

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

References g_assault, NUM_TEAM_1, and team.

◆ spawnfunc() [4/8]

spawnfunc ( info_player_defender )

Definition at line 295 of file sv_assault.qc.

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

References g_assault, NUM_TEAM_2, and team.

◆ spawnfunc() [5/8]

spawnfunc ( target_assault_roundend )

Definition at line 376 of file sv_assault.qc.

377{
378 if (!g_assault) { delete(this); return; }
379
380 this.winning = 0; // round not yet won by attackers
382 this.cnt = 0; // first round
384}
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 303 of file sv_assault.qc.

304{
305 if (!g_assault) { delete(this); return; }
306
309 this.reset = assault_objective_reset;
310 this.reset(this);
312}
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 314 of file sv_assault.qc.

315{
316 if (!g_assault) { delete(this); return; }
317
319
320 if(!this.dmg)
321 this.dmg = 101;
322
326 this.enemy = NULL;
327
329}
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 = find(NULL, classname, "target_assault_roundend");
252 if(ent)
253 {
254 if(ent.winning) // round end has been triggered by attacking team
255 {
256 bprint(Team_ColoredFullName(assault_attacker_team), " destroyed the objective in ", process_time(2, ceil(time - game_starttime)), "\n");
258
260
261 // in campaign the game ends when the player destroys the objective, there's no second round
262 if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round or the only round in campaign
263 {
264 status = WINNING_YES;
265 }
266 else
267 {
268 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ASSAULT_OBJ_DESTROYED, ceil(time - game_starttime));
269 as_round = new(as_round);
270 as_round.think = as_round_think;
271 as_round.ent_winning = ent;
272 as_round.nextthink = time + AS_ROUND_DELAY;
273 game_stopped = true;
274
275 // make sure timelimit isn't hit while the game is blocked
276 if(autocvar_timelimit > 0)
278 cvar_set("timelimit", ftos(autocvar_timelimit + AS_ROUND_DELAY / 60));
279 }
280 }
281 }
282
283 return status;
284}
#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:440
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
Definition scores.qc:108
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:1540
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