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