Xonotic
sv_campcheck.qc File Reference
#include "sv_campcheck.qh"
+ Include dependency graph for sv_campcheck.qc:

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (campcheck, PlayerDies)
 
 MUTATOR_HOOKFUNCTION (campcheck, Damage_Calculate)
 
 MUTATOR_HOOKFUNCTION (campcheck, PlayerPreThink)
 
 MUTATOR_HOOKFUNCTION (campcheck, CopyBody)
 
 MUTATOR_HOOKFUNCTION (campcheck, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION (campcheck, BuildMutatorsString)
 
 REGISTER_MUTATOR (campcheck, expr_evaluate(autocvar_g_campcheck))
 

Variables

string autocvar_g_campcheck
 
float autocvar_g_campcheck_damage
 
float autocvar_g_campcheck_distance
 
float autocvar_g_campcheck_interval
 
bool autocvar_g_campcheck_typecheck
 
float campcheck_nextcheck
 
vector campcheck_prevorigin
 
float campcheck_traveled_distance
 

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
PlayerDies   
)

Definition at line 16 of file sv_campcheck.qc.

References entity(), and M_ARGV.

17 {
18  entity frag_target = M_ARGV(2, entity);
19 
20  Kill_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CPID_CAMPCHECK);
21 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [2/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
Damage_Calculate   
)

Definition at line 23 of file sv_campcheck.qc.

References autocvar_g_campcheck_distance, entity(), IS_PLAYER, and M_ARGV.

24 {
25  entity frag_attacker = M_ARGV(1, entity);
26  entity frag_target = M_ARGV(2, entity);
27 
28  if(frag_attacker != frag_target && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
29  {
30  frag_target.campcheck_traveled_distance = autocvar_g_campcheck_distance;
31  frag_attacker.campcheck_traveled_distance = autocvar_g_campcheck_distance;
32  }
33 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
float autocvar_g_campcheck_distance
Definition: sv_campcheck.qc:5
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
PlayerPreThink   
)

Definition at line 35 of file sv_campcheck.qc.

References autocvar_g_balance_armor_blockpercent, autocvar_g_campaign, autocvar_g_campcheck_damage, autocvar_g_campcheck_distance, autocvar_g_campcheck_interval, autocvar_g_campcheck_typecheck, bound(), campaign_bots_may_start, Damage(), DMG_NOWEP, entity(), fabs(), GetResource(), IS_DEAD, IS_PLAYER, IS_REAL_CLIENT, M_ARGV, NULL, PHYS_INPUT_BUTTON_CHAT, RES_HEALTH, round_handler_IsActive, round_handler_IsRoundStarted, time, vec2, vector(), vlen(), warmup_stage, and weaponLocked().

36 {
37  entity player = M_ARGV(0, entity);
38  bool checked = false;
39 
41  if(!game_stopped && !warmup_stage && time >= game_starttime)
42  if(IS_PLAYER(player) && !IS_DEAD(player) && !STAT(FROZEN, player))
44  if(IS_REAL_CLIENT(player)) // only apply to real clients (bots may "camp" due to missing waypoints in the map, but that's no reason to constantly kill them, clones can't move)
45  if(!weaponLocked(player))
46  {
47  // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
48  vector dist = vec2(player.campcheck_prevorigin - player.origin);
49  player.campcheck_traveled_distance += fabs(vlen(dist));
50 
52  {
53  player.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
54  player.campcheck_traveled_distance = 0;
55  }
56 
57  if(time > player.campcheck_nextcheck)
58  {
59  if(player.campcheck_traveled_distance < autocvar_g_campcheck_distance)
60  {
61  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CAMPCHECK);
62  if(player.vehicle)
63  Damage(player.vehicle, NULL, NULL, autocvar_g_campcheck_damage * 2, DEATH_CAMP.m_id, DMG_NOWEP, player.vehicle.origin, '0 0 0');
64  else
65  {
66  float max_dmg = GetResource(player, RES_HEALTH) + GetResource(player, RES_ARMOR) * autocvar_g_balance_armor_blockpercent + 5;
67  Damage(player, NULL, NULL, bound(0, autocvar_g_campcheck_damage, max_dmg), DEATH_CAMP.m_id, DMG_NOWEP, player.origin, '0 0 0');
68  }
69  }
70  player.campcheck_nextcheck = time + autocvar_g_campcheck_interval;
71  player.campcheck_traveled_distance = 0;
72  }
73 
74  checked = true;
75  }
76 
77  if(!checked)
78  player.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date
79 
80  player.campcheck_prevorigin = player.origin;
81 }
#define round_handler_IsActive()
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition: player.qh:155
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define round_handler_IsRoundStarted()
#define DMG_NOWEP
Definition: damage.qh:126
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
float autocvar_g_campcheck_interval
Definition: sv_campcheck.qc:6
RES_HEALTH
Definition: ent_cs.qc:126
bool weaponLocked(entity player)
#define NULL
Definition: post.qh:17
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
bool autocvar_g_campcheck_typecheck
Definition: sv_campcheck.qc:7
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
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define vec2(...)
Definition: vector.qh:90
bool autocvar_g_campaign
Definition: campaign.qh:6
float autocvar_g_balance_armor_blockpercent
Definition: damage.qh:21
float autocvar_g_campcheck_distance
Definition: sv_campcheck.qc:5
float time
Definition: csprogsdefs.qc:16
float autocvar_g_campcheck_damage
Definition: sv_campcheck.qc:4
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [4/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
CopyBody   
)

Definition at line 83 of file sv_campcheck.qc.

References entity(), and M_ARGV.

84 {
85  entity player = M_ARGV(0, entity);
86  entity clone = M_ARGV(1, entity);
87 
88  clone.campcheck_prevorigin = player.campcheck_prevorigin;
89 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [5/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
PlayerSpawn   
)

Definition at line 91 of file sv_campcheck.qc.

References autocvar_g_campcheck_interval, entity(), M_ARGV, and time.

92 {
93  entity player = M_ARGV(0, entity);
94 
95  player.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
96  player.campcheck_traveled_distance = 0;
97 }
entity() spawn
float autocvar_g_campcheck_interval
Definition: sv_campcheck.qc:6
#define M_ARGV(x, type)
Definition: events.qh:17
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [6/6]

MUTATOR_HOOKFUNCTION ( campcheck  ,
BuildMutatorsString   
)

Definition at line 99 of file sv_campcheck.qc.

References M_ARGV, and strcat().

100 {
101  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":CampCheck");
102 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( campcheck  ,
expr_evaluate(autocvar_g_campcheck  
)

Variable Documentation

◆ autocvar_g_campcheck

string autocvar_g_campcheck

Definition at line 3 of file sv_campcheck.qc.

◆ autocvar_g_campcheck_damage

float autocvar_g_campcheck_damage

Definition at line 4 of file sv_campcheck.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_campcheck_distance

float autocvar_g_campcheck_distance

Definition at line 5 of file sv_campcheck.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_campcheck_interval

float autocvar_g_campcheck_interval

Definition at line 6 of file sv_campcheck.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_campcheck_typecheck

bool autocvar_g_campcheck_typecheck

Definition at line 7 of file sv_campcheck.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ campcheck_nextcheck

float campcheck_nextcheck

Definition at line 11 of file sv_campcheck.qc.

◆ campcheck_prevorigin

vector campcheck_prevorigin

Definition at line 14 of file sv_campcheck.qc.

◆ campcheck_traveled_distance

float campcheck_traveled_distance

Definition at line 12 of file sv_campcheck.qc.