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