]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_ctf.qh
client: pass compilation units test
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ctf.qh
1 #pragma once
2
3 #ifdef SVQC
4 // used in cheats.qc
5 void ctf_RespawnFlag(entity flag);
6
7 // score rule declarations
8 const int ST_CTF_CAPS = 1;
9 const int SP_CTF_CAPS = 4;
10 const int SP_CTF_CAPTIME = 5;
11 const int SP_CTF_PICKUPS = 6;
12 const int SP_CTF_DROPS = 7;
13 const int SP_CTF_FCKILLS = 8;
14 const int SP_CTF_RETURNS = 9;
15
16 CLASS(Flag, Pickup)
17     ATTRIB(Flag, m_mins, vector, PL_MIN_CONST + '0 0 -13')
18     ATTRIB(Flag, m_maxs, vector, PL_MAX_CONST + '0 0 -13')
19 ENDCLASS(Flag)
20 Flag CTF_FLAG; STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
21 void ctf_FlagTouch() { SELFPARAM(); ITEM_HANDLE(Pickup, CTF_FLAG, this, other); }
22
23 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
24
25 const float FLAG_SCALE = 0.6;
26
27 const float FLAG_THINKRATE = 0.2;
28 const float FLAG_TOUCHRATE = 0.5;
29 const float WPFE_THINKRATE = 0.5;
30
31 const vector FLAG_DROP_OFFSET = ('0 0 32');
32 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
33 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
34 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
35 const vector FLAG_FLOAT_OFFSET = ('0 0 32');
36 const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
37
38 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
39 const float VEHICLE_FLAG_SCALE = 1.0;
40
41 // waypoint colors
42 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
43 #define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
44 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
45
46 // sounds
47 #define snd_flag_taken noise
48 #define snd_flag_returned noise1
49 #define snd_flag_capture noise2
50 #define snd_flag_respawn noise3
51 .string snd_flag_dropped;
52 .string snd_flag_touch;
53 .string snd_flag_pass;
54
55 // effects
56 .string toucheffect;
57 .string passeffect;
58 .string capeffect;
59
60 // list of flags on the map
61 entity ctf_worldflaglist;
62 .entity ctf_worldflagnext;
63 .entity ctf_staleflagnext;
64
65 // waypoint sprites
66 .entity bot_basewaypoint; // flag waypointsprite
67 .entity wps_helpme;
68 .entity wps_flagbase;
69 .entity wps_flagcarrier;
70 .entity wps_flagdropped;
71 .entity wps_enemyflagcarrier;
72 .float wps_helpme_time;
73 bool wpforenemy_announced;
74 float wpforenemy_nextthink;
75
76 // statuses
77 const int FLAG_BASE = 1;
78 const int FLAG_DROPPED = 2;
79 const int FLAG_CARRY = 3;
80 const int FLAG_PASSING = 4;
81
82 const int DROP_NORMAL = 1;
83 const int DROP_THROW = 2;
84 const int DROP_PASS = 3;
85 const int DROP_RESET = 4;
86
87 const int PICKUP_BASE = 1;
88 const int PICKUP_DROPPED = 2;
89
90 const int CAPTURE_NORMAL = 1;
91 const int CAPTURE_DROPPED = 2;
92
93 const int RETURN_TIMEOUT = 1;
94 const int RETURN_DROPPED = 2;
95 const int RETURN_DAMAGE = 3;
96 const int RETURN_SPEEDRUN = 4;
97 const int RETURN_NEEDKILL = 5;
98
99 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
100
101 // flag properties
102 #define ctf_spawnorigin dropped_origin
103 bool ctf_stalemate; // indicates that a stalemate is active
104 float ctf_captimerecord; // record time for capturing the flag
105 .float ctf_pickuptime;
106 .float ctf_droptime;
107 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
108 .entity ctf_dropper; // don't allow spam of dropping the flag
109 .int max_flag_health;
110 .float next_take_time;
111 .bool ctf_flagdamaged;
112 int ctf_teams;
113
114 // passing/throwing properties
115 .float pass_distance;
116 .entity pass_sender;
117 .entity pass_target;
118 .float throw_antispam;
119 .float throw_prevtime;
120 .int throw_count;
121
122 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
123 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
124 float ctf_captureshield_min_negscore; // punish at -20 points
125 float ctf_captureshield_max_ratio; // punish at most 30% of each team
126 float ctf_captureshield_force; // push force of the shield
127
128 // 1 flag ctf
129 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
130
131 // bot player logic
132 const int HAVOCBOT_CTF_ROLE_NONE = 0;
133 const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
134 const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
135 const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
136 const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
137 const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
138 const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
139
140 .bool havocbot_cantfindflag;
141
142 vector havocbot_ctf_middlepoint;
143 float havocbot_ctf_middlepoint_radius;
144
145 void havocbot_role_ctf_setrole(entity bot, int role);
146
147 // team checking
148 #define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
149 #define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
150
151 // networked flag statuses
152 .int ctf_flagstatus = _STAT(CTF_FLAGSTATUS);
153 #endif
154
155 const int CTF_RED_FLAG_TAKEN                    = 1;
156 const int CTF_RED_FLAG_LOST                             = 2;
157 const int CTF_RED_FLAG_CARRYING                 = 3;
158 const int CTF_BLUE_FLAG_TAKEN                   = 4;
159 const int CTF_BLUE_FLAG_LOST                    = 8;
160 const int CTF_BLUE_FLAG_CARRYING                = 12;
161 const int CTF_YELLOW_FLAG_TAKEN                 = 16;
162 const int CTF_YELLOW_FLAG_LOST                  = 32;
163 const int CTF_YELLOW_FLAG_CARRYING              = 48;
164 const int CTF_PINK_FLAG_TAKEN                   = 64;
165 const int CTF_PINK_FLAG_LOST                    = 128;
166 const int CTF_PINK_FLAG_CARRYING                = 192;
167 const int CTF_NEUTRAL_FLAG_TAKEN                = 256;
168 const int CTF_NEUTRAL_FLAG_LOST                 = 512;
169 const int CTF_NEUTRAL_FLAG_CARRYING             = 768;
170 const int CTF_FLAG_NEUTRAL                              = 2048;
171 const int CTF_SHIELDED                                  = 4096;