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