Xonotic
sv_ctf.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ctf.qh"
7 
9  ATTRIB(Flag, m_mins, vector, (PL_MIN_CONST + '0 0 -13') * 1.4); // scaling be damned
10  ATTRIB(Flag, m_maxs, vector, (PL_MAX_CONST + '0 0 -13') * 1.4);
11 ENDCLASS(Flag)
12 Flag CTF_FLAG;
13 void ctf_Initialize();
14 
17 
19 {
22  {
23  GameRules_teams(true);
24  GameRules_limit_score(autocvar_capturelimit_override);
25  GameRules_limit_lead(autocvar_captureleadlimit_override);
26 
28  }
29  return 0;
30 }
31 
32 // used in cheats.qc
33 void ctf_RespawnFlag(entity flag);
34 
35 // score rule declarations
36 const int ST_CTF_CAPS = 1;
37 
38 void ctf_FlagTouch(entity this, entity toucher) { ITEM_HANDLE(Pickup, CTF_FLAG, this, toucher); }
39 
40 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
41 
42 const float FLAG_SCALE = 0.6;
43 
44 const float FLAG_THINKRATE = 0.2;
45 const float FLAG_TOUCHRATE = 0.5;
46 const float WPFE_THINKRATE = 0.5;
47 
48 const vector FLAG_DROP_OFFSET = ('0 0 32');
49 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
50 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
51 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
52 const int FLAG_FLOAT_OFFSET_Z = 32;
53 const int FLAG_PASS_ARC_OFFSET_Z = -10;
54 
55 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
56 const float VEHICLE_FLAG_SCALE = 1.0;
57 
58 // waypoint colors
59 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
60 #define WPCOLOR_FLAGCARRIER(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
61 //#define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
62 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
63 
64 // sounds
65 #define snd_flag_taken noise
66 #define snd_flag_returned noise1
67 #define snd_flag_capture noise2
68 #define snd_flag_respawn noise3
71 .string snd_flag_pass;
72 
73 // score fields
74 .float score_assist;
76 .float score_drop; // note: negated
77 .float score_pickup;
78 .float score_return;
79 .float score_team_capture; // shouldn't be too high
80 
81 // property set on objects to point to the flag they're carrying (if any)
82 .entity flagcarried;
83 
84 // effects
85 .string toucheffect;
86 .string passeffect;
87 .string capeffect;
88 
89 // list of flags on the map
93 
94 // waypoint sprites
95 .entity wps_helpme;
96 .entity wps_flagbase;
104 
105 // statuses
106 const int FLAG_BASE = 1;
107 const int FLAG_DROPPED = 2;
108 const int FLAG_CARRY = 3;
109 const int FLAG_PASSING = 4;
110 
111 const int DROP_NORMAL = 1;
112 const int DROP_THROW = 2;
113 const int DROP_PASS = 3;
114 const int DROP_RESET = 4;
115 
116 const int PICKUP_BASE = 1;
117 const int PICKUP_DROPPED = 2;
118 
119 const int CAPTURE_NORMAL = 1;
120 const int CAPTURE_DROPPED = 2;
121 
122 const int RETURN_TIMEOUT = 1;
123 const int RETURN_DROPPED = 2;
124 const int RETURN_DAMAGE = 3;
125 const int RETURN_SPEEDRUN = 4;
126 const int RETURN_NEEDKILL = 5;
127 
128 bool ctf_Stalemate_Customize(entity this, entity client);
129 
130 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
131 
132 // flag properties
133 #define ctf_spawnorigin dropped_origin
134 bool ctf_stalemate; // indicates that a stalemate is active
135 float ctf_captimerecord; // record time for capturing the flag
138 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
139 .entity ctf_dropper; // don't allow spam of dropping the flag
143 .entity enemy; // when flag is back in the base, it remembers last player who carried/touched the flag, useful to bots
144 
145 // passing/throwing properties
147 .entity pass_sender;
148 .entity pass_target;
152 
153 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
154 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
155 float ctf_captureshield_min_negscore; // punish at -20 points
156 float ctf_captureshield_max_ratio; // punish at most 30% of each team
157 float ctf_captureshield_force; // push force of the shield
158 
159 // 1 flag ctf
160 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
161 
162 // bot player logic
170 
172 
173 void havocbot_role_ctf_setrole(entity bot, int role);
174 
175 // team checking
176 #define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
177 #define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
float throw_prevtime
Definition: sv_ctf.qh:150
const float WPFE_THINKRATE
Definition: sv_ctf.qh:46
const vector FLAG_DROP_OFFSET
Definition: sv_ctf.qh:48
bool wpforenemy_announced
Definition: sv_ctf.qh:102
const int FLAG_CARRY
Definition: sv_ctf.qh:108
float wps_helpme_time
Definition: sv_ctf.qh:101
const int RETURN_DAMAGE
Definition: sv_ctf.qh:124
entity ctf_worldflagnext
Definition: sv_ctf.qh:91
bool ctf_Stalemate_Customize(entity this, entity client)
Definition: sv_ctf.qc:822
#define MUTATOR_STATIC()
Definition: base.qh:288
float score_return
Definition: sv_ctf.qh:78
const int HAVOCBOT_CTF_ROLE_MIDDLE
Definition: sv_ctf.qh:165
CLASS(Object) Object
Definition: oo.qh:318
string toucheffect
Definition: sv_ctf.qh:85
int throw_count
Definition: sv_ctf.qh:151
void ctf_Initialize()
Definition: sv_ctf.qc:2820
const int DROP_NORMAL
Definition: sv_ctf.qh:111
const int FLAG_PASSING
Definition: sv_ctf.qh:109
entity wps_flagbase
Definition: sv_ctf.qh:96
const int FLAG_DROPPED
Definition: sv_ctf.qh:107
const float FLAG_TOUCHRATE
Definition: sv_ctf.qh:45
void ctf_RespawnFlag(entity flag)
Definition: sv_ctf.qc:1163
entity() spawn
const int FLAG_FLOAT_OFFSET_Z
Definition: sv_ctf.qh:52
const int HAVOCBOT_CTF_ROLE_RETRIEVER
Definition: sv_ctf.qh:168
const vector FLAG_WAYPOINT_OFFSET
Definition: sv_ctf.qh:51
string capeffect
Definition: sv_ctf.qh:87
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
Definition: sv_ctf.qh:8
#define false
Definition: csprogsdefs.qh:6
const int PICKUP_DROPPED
Definition: sv_ctf.qh:117
float ctf_captureshield_force
Definition: sv_ctf.qh:157
entity flagcarried
Definition: sv_ctf.qh:82
float score_team_capture
Definition: sv_ctf.qh:79
const int RETURN_NEEDKILL
Definition: sv_ctf.qh:126
float ctf_droptime
Definition: sv_ctf.qh:137
float next_take_time
Definition: sv_ctf.qh:140
Definition: pickup.qh:22
entity ctf_staleflagnext
Definition: sv_ctf.qh:92
string passeffect
Definition: sv_ctf.qh:86
const int ST_CTF_CAPS
Definition: sv_ctf.qh:36
bool havocbot_cantfindflag
Definition: sv_ctf.qh:171
const int HAVOCBOT_CTF_ROLE_CARRIER
Definition: sv_ctf.qh:167
string snd_flag_touch
Definition: sv_ctf.qh:70
const int FLAG_BASE
Definition: sv_ctf.qh:106
#define ATTRIB(...)
Definition: oo.qh:136
const vector VEHICLE_FLAG_OFFSET
Definition: sv_ctf.qh:55
entity wps_enemyflagcarrier
Definition: sv_ctf.qh:100
float score_drop
Definition: sv_ctf.qh:76
const int HAVOCBOT_CTF_ROLE_NONE
Definition: sv_ctf.qh:163
const int HAVOCBOT_CTF_ROLE_ESCORT
Definition: sv_ctf.qh:169
bool ctf_flagdamaged_byworld
Definition: sv_ctf.qh:141
bool ctf_captureshielded
Definition: sv_ctf.qh:154
entity enemy
Definition: sv_ctf.qh:143
float wpforenemy_nextthink
Definition: sv_ctf.qh:103
entity pass_target
Definition: sv_ctf.qh:148
const int HAVOCBOT_CTF_ROLE_OFFENSE
Definition: sv_ctf.qh:166
const float VEHICLE_FLAG_SCALE
Definition: sv_ctf.qh:56
void GameRules_teams(bool value)
Definition: sv_rules.qc:6
string snd_flag_dropped
Definition: sv_ctf.qh:69
int autocvar_captureleadlimit_override
Definition: sv_ctf.qh:15
REGISTER_MUTATOR(ctf, false)
Definition: sv_ctf.qh:18
const vector FLAG_CARRY_OFFSET
Definition: sv_ctf.qh:49
entity wps_helpme
Definition: sv_ctf.qh:95
const int CAPTURE_NORMAL
Definition: sv_ctf.qh:119
int ctf_teams
Definition: sv_ctf.qh:142
const int FLAG_PASS_ARC_OFFSET_Z
Definition: sv_ctf.qh:53
float ctf_captureshield_min_negscore
Definition: sv_ctf.qh:155
const int HAVOCBOT_CTF_ROLE_DEFENSE
Definition: sv_ctf.qh:164
float score_pickup
Definition: sv_ctf.qh:77
const float FLAG_SCALE
Definition: sv_ctf.qh:42
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float FLAG_THINKRATE
Definition: sv_ctf.qh:44
void havocbot_role_ctf_setrole(entity bot, int role)
Definition: sv_ctf.qc:2102
const int DROP_RESET
Definition: sv_ctf.qh:114
float ctf_captimerecord
Definition: sv_ctf.qh:135
const int DROP_PASS
Definition: sv_ctf.qh:113
#define ITEM_HANDLE(signal,...)
Definition: item.qh:103
Flag CTF_FLAG
Definition: sv_ctf.qh:12
entity wps_flagcarrier
Definition: sv_ctf.qh:97
#define ENDCLASS(cname)
Definition: oo.qh:269
float throw_antispam
Definition: sv_ctf.qh:149
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
entity wps_flagdropped
Definition: sv_ctf.qh:98
float score_capture
Definition: sv_ctf.qh:75
const int DROP_THROW
Definition: sv_ctf.qh:112
entity pass_sender
Definition: sv_ctf.qh:147
int autocvar_capturelimit_override
Definition: sv_ctf.qh:16
entity wps_flagreturn
Definition: sv_ctf.qh:99
float ctf_pickuptime
Definition: sv_ctf.qh:136
float ctf_captureshield_max_ratio
Definition: sv_ctf.qh:156
const int PICKUP_BASE
Definition: sv_ctf.qh:116
string snd_flag_pass
Definition: sv_ctf.qh:71
void ctf_FlagTouch(entity this, entity toucher)
Definition: sv_ctf.qh:38
float pass_distance
Definition: sv_ctf.qh:146
void ctf_Handle_Throw(entity player, entity receiver, float droptype)
const int RETURN_SPEEDRUN
Definition: sv_ctf.qh:125
#define MUTATOR_ONADD
Definition: base.qh:284
entity ctf_worldflaglist
Definition: sv_ctf.qh:90
const int RETURN_TIMEOUT
Definition: sv_ctf.qh:122
entity ctf_dropper
Definition: sv_ctf.qh:139
float score_assist
Definition: sv_ctf.qh:74
bool ctf_stalemate
Definition: sv_ctf.qh:134
bool ctf_oneflag
Definition: sv_ctf.qh:160
const int CAPTURE_DROPPED
Definition: sv_ctf.qh:120
const int RETURN_DROPPED
Definition: sv_ctf.qh:123
int ctf_status
Definition: sv_ctf.qh:138