4 float FLAGSCORE_PICKUP = 1;
5 float FLAGSCORE_RETURN = 5; // returned by owner team
6 float FLAGSCORE_RETURNROGUE = 10; // returned by rogue team
7 float FLAGSCORE_CAPTURE = 5;
8 float FLAGSCORE_CAPTURE_TEAM = 20;
12 float FLAG_DROPPED = 3;
19 self.mdl = self.model;
21 self.solid = SOLID_TRIGGER;
22 self.movetype = MOVETYPE_TOSS;
23 self.velocity = '0 0 0';
24 self.origin_z = self.origin_z + 6;
25 self.think = FlagThink;
26 self.touch = FlagTouch;
27 self.nextthink = time + 0.1;
29 self.mangle = self.angles;
30 self.effects = self.effects | EF_DIMLIGHT;
31 if (!droptofloor(0, 0))
33 dprint("Flag fell out of level at ", vtos(self.origin), "\n");
37 self.oldorigin = self.origin;
40 void(entity e) RegenFlag =
42 e.movetype = MOVETYPE_TOSS;
43 e.solid = SOLID_TRIGGER;
44 // TODO: play a sound here
45 sound (e, CHAN_AUTO, self.noise3, 1, ATTN_NONE);
46 setorigin(e, e.oldorigin);
50 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
53 void(entity e) ReturnFlag =
56 if (e.owner.flagcarried == e)
57 e.owner.flagcarried = world;
62 void(entity e) DropFlag =
68 dprint("FLAG: drop - no owner?!?!\n");
72 if (p.flagcarried != e)
74 dprint("FLAG: drop - owner is not carrying this flag??\n");
79 bprint(" lost the RED flag\n");
81 bprint(" lost the BLUE flag\n");
82 if (p.flagcarried == e)
83 p.flagcarried = world;
86 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
87 e.solid = SOLID_TRIGGER;
88 e.movetype = MOVETYPE_TOSS;
89 // setsize(e, '-16 -16 0', '16 16 74');
90 setorigin(e, p.origin - '0 0 24');
92 e.velocity = '0 0 300';
93 e.pain_finished = time + 30;
102 self.nextthink = time + 0.1;
104 if (self.cnt == FLAG_BASE)
107 if (self.cnt == FLAG_DROPPED)
109 if (time > self.pain_finished)
112 bprint("The RED flag has returned to base\n");
114 bprint("The BLUE flag has returned to base\n");
121 if (e.classname != "player" || (e.deadflag) || (e.flagcarried != self))
127 // borrowed from threewave CTF, because it would be way too much work
129 makevectors (e.angles);
131 v_z = 0 - v_z; // reverse z
135 if (e.frame >= 29 && e.frame <= 40)
137 if (e.frame >= 29 && e.frame <= 34)
140 if (e.frame == 29) f = f + 2;
141 else if (e.frame == 30) f = f + 8;
142 else if (e.frame == 31) f = f + 12;
143 else if (e.frame == 32) f = f + 11;
144 else if (e.frame == 33) f = f + 10;
145 else if (e.frame == 34) f = f + 4;
147 else if (e.frame >= 35 && e.frame <= 40)
150 if (e.frame == 35) f = f + 2;
151 else if (e.frame == 36) f = f + 10;
152 else if (e.frame == 37) f = f + 10;
153 else if (e.frame == 38) f = f + 8;
154 else if (e.frame == 39) f = f + 4;
155 else if (e.frame == 40) f = f + 2;
158 else if (e.frame >= 103 && e.frame <= 118)
160 if (e.frame >= 103 && e.frame <= 104) f = f + 6; //nailattack
161 else if (e.frame >= 105 && e.frame <= 106) f = f + 6; //light
162 else if (e.frame >= 107 && e.frame <= 112) f = f + 7; //rocketattack
163 else if (e.frame >= 112 && e.frame <= 118) f = f + 7; //shotattack
166 self.angles = e.angles + '0 0 -45';
167 setorigin (self, e.origin + '0 0 -16' - f*v + v_right * 22);
168 self.nextthink = time + 0.01;
171 float flagcaptimerecord;
172 .float flagpickuptime;
178 if (other.classname != "player")
180 if (other.health < 1) // ignore dead players
183 if (self.cnt == FLAG_CARRY)
186 if (self.cnt == FLAG_BASE)
187 if (other.team == self.team)
188 if (other.flagcarried) // he's got a flag
189 if (other.flagcarried.team != self.team) // capture
191 t = time - other.flagpickuptime;
192 if (flagcaptimerecord == 0)
194 if (other.flagcarried.team == 5)
195 bprint(other.netname, " captured the RED flag in ", ftos(t), " seconds\n");
197 bprint(other.netname, " captured the BLUE flag in ", ftos(t), " seconds\n");
198 flagcaptimerecord = t;
200 else if (t < flagcaptimerecord)
202 if (other.flagcarried.team == 5)
203 bprint(other.netname, " captured the RED flag in ", ftos(t), ", breaking the previous record of", ftos(flagcaptimerecord), " seconds\n");
205 bprint(other.netname, " captured the BLUE flag in ", ftos(t), ", breaking the previous record of", ftos(flagcaptimerecord), " seconds\n");
206 flagcaptimerecord = t;
210 if (other.flagcarried.team == 5)
211 bprint(other.netname, " captured the RED flag in ", ftos(t), ", failing to break the previous record of", ftos(flagcaptimerecord), " seconds\n");
213 bprint(other.netname, " captured the BLUE flag in ", ftos(t), ", failing to break the previous record of", ftos(flagcaptimerecord), " seconds\n");
215 other.frags = other.frags + FLAGSCORE_CAPTURE;
216 head = find(head, classname, "player");
219 if (head.team == self.goalentity.team)
220 head.frags = head.frags + FLAGSCORE_CAPTURE_TEAM;
221 head = find(head, classname, "player");
223 sound (self, CHAN_AUTO, self.noise2, 1, ATTN_NONE);
224 ReturnFlag(other.flagcarried);
226 if (self.cnt == FLAG_BASE)
227 if (other.team == 5 || other.team == 14) // only red and blue team can steal flags
228 if (other.team != self.team)
229 if (!other.flagcarried)
232 other.flagpickuptime = time; // used for timing runs
233 self.solid = SOLID_NOT;
234 setorigin(self, self.origin); // relink
236 other.flagcarried = self;
237 self.cnt = FLAG_CARRY;
238 if (other.flagcarried.team == 5)
239 bprint(other.netname, " got the RED flag\n");
241 bprint(other.netname, " got the BLUE flag\n");
242 other.frags = other.frags + FLAGSCORE_PICKUP;
243 sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
247 if (self.cnt == FLAG_DROPPED)
249 self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
250 if (other.team == self.team || (other.team != 5 && other.team != 14))
254 bprint(other.netname, " returned the RED flag\n");
256 bprint(other.netname, " returned the BLUE flag\n");
257 if (other.team == 5 || other.team == 14)
258 other.frags = other.frags + FLAGSCORE_RETURN;
260 other.frags = other.frags + FLAGSCORE_RETURNROGUE;
261 sound (self, CHAN_AUTO, self.noise1, 1, ATTN_NONE);
264 else if (!other.flagcarried)
267 other.flagpickuptime = time; // used for timing runs
268 self.solid = SOLID_NOT;
269 setorigin(self, self.origin); // relink
271 other.flagcarried = self;
272 self.cnt = FLAG_CARRY;
274 bprint(other.netname, " picked up the RED flag\n");
276 bprint(other.netname, " picked up the BLUE flag\n");
277 other.frags = other.frags + FLAGSCORE_PICKUP;
278 sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
283 /*QUAKED info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
284 CTF Starting point for a player
289 viewing angle when spawning
291 void() info_player_team1 = {};//self.team = 4;self.classname = "info_player_start";info_player_start();};
293 /*QUAKED info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
294 CTF Starting point for a player in
299 viewing angle when spawning
301 void() info_player_team2 = {};//self.team = 13;self.classname = "info_player_start";info_player_start();};
303 /*QUAKED item_flag_team1 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
304 CTF flag for team one (Red).
305 Multiple are allowed.
309 Angle the flag will point
312 model to use, note this needs red and blue as skins 0 and 1
313 (default models/ctf/flag.md3)
315 sound played when flag is picked up
316 (default ctf/take.wav)
318 sound played when flag is returned by a teammate
319 (default ctf/return.wav)
321 sound played when flag is captured
322 (default ctf/capture.wav)
324 sound played when flag is lost in the field and respawns itself
325 (default ctf/respawn.wav)
328 void() item_flag_team1 =
332 self.team = 5; // color 4 team (red)
333 self.items = IT_KEY2; // gold key (redish enough)
336 self.model = "models/ctf/flag.md3";
338 self.noise = "ctf/take.wav";
340 self.noise1 = "ctf/return.wav";
342 self.noise2 = "ctf/capture.wav";
344 self.noise3 = "ctf/respawn.wav";
345 precache_model (self.model);
346 setmodel (self, self.model);
347 precache_sound (self.noise);
348 precache_sound (self.noise1);
349 precache_sound (self.noise2);
350 precache_sound (self.noise3);
351 setsize(self, '-16 -16 0', '16 16 74');
352 self.nextthink = time + 0.2; // start after doors etc
353 self.think = place_flag;
356 /*QUAKED item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
357 CTF flag for team two (Blue).
358 Multiple are allowed.
362 Angle the flag will point
367 void() item_flag_team2 =
371 self.team = 14; // color 13 team (blue)
372 self.items = IT_KEY1; // silver key (bluish enough)
375 self.model = "models/ctf/flag.md3";
377 self.noise = "ctf/take.wav";
379 self.noise1 = "ctf/return.wav";
381 self.noise2 = "ctf/capture.wav";
383 self.noise3 = "ctf/respawn.wav";
384 precache_model (self.model);
385 setmodel (self, self.model);
386 precache_sound (self.noise);
387 precache_sound (self.noise1);
388 precache_sound (self.noise2);
389 precache_sound (self.noise3);
390 setsize(self, '-16 -16 0', '16 16 74');
391 self.nextthink = time + 0.2; // start after doors etc
392 self.think = place_flag;