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