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