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;
20 self.t_width = 0.1; // frame animation rate
22 self.t_length = 119; // maximum frame
24 self.mdl = self.model;
26 self.solid = SOLID_TRIGGER;
27 self.movetype = MOVETYPE_TOSS;
28 self.velocity = '0 0 0';
29 self.origin_z = self.origin_z + 6;
30 self.think = FlagThink;
31 self.touch = FlagTouch;
32 self.nextthink = time + 0.1;
34 self.mangle = self.angles;
35 //self.effects = self.effects | EF_DIMLIGHT;
36 if (!droptofloor(0, 0))
38 dprint("Flag fell out of level at ", vtos(self.origin), "\n");
42 self.oldorigin = self.origin;
45 void(entity e) RegenFlag =
47 e.movetype = MOVETYPE_TOSS;
48 e.solid = SOLID_TRIGGER;
49 // TODO: play a sound here
50 sound (e, CHAN_AUTO, self.noise3, 1, ATTN_NONE);
51 setorigin(e, e.oldorigin);
55 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
58 void(entity e) ReturnFlag =
61 if (e.owner.flagcarried == e)
62 e.owner.flagcarried = world;
67 void(entity e) DropFlag =
73 dprint("FLAG: drop - no owner?!?!\n");
77 if (p.flagcarried != e)
79 dprint("FLAG: drop - owner is not carrying this flag??\n");
84 bprint("^7 lost the RED flag\n");
86 bprint("^7 lost the BLUE flag\n");
87 if (p.flagcarried == e)
88 p.flagcarried = world;
91 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
92 e.solid = SOLID_TRIGGER;
93 e.movetype = MOVETYPE_TOSS;
94 // setsize(e, '-16 -16 0', '16 16 74');
95 setorigin(e, p.origin - '0 0 24');
97 e.velocity = '0 0 300';
98 e.pain_finished = time + cvar("g_ctf_flag_returntime");//30;
103 if(self.delay > time)
105 self.delay = time + self.t_width;
106 if(self.nextthink > self.delay)
107 self.nextthink = self.delay;
109 self.frame = self.frame + 1;
110 if(self.frame > self.t_length)
120 self.nextthink = time + 0.1;
124 if (self.cnt == FLAG_BASE)
127 if (self.cnt == FLAG_DROPPED)
129 if (time > self.pain_finished)
132 bprint("The RED flag has returned to base\n");
134 bprint("The BLUE flag has returned to base\n");
141 if (e.classname != "player" || (e.deadflag) || (e.flagcarried != self))
147 // borrowed from threewave CTF, because it would be way too much work
149 makevectors (e.angles);
151 v_z = 0 - v_z; // reverse z
155 if (e.frame >= 29 && e.frame <= 40)
157 if (e.frame >= 29 && e.frame <= 34)
160 if (e.frame == 29) f = f + 2;
161 else if (e.frame == 30) f = f + 8;
162 else if (e.frame == 31) f = f + 12;
163 else if (e.frame == 32) f = f + 11;
164 else if (e.frame == 33) f = f + 10;
165 else if (e.frame == 34) f = f + 4;
167 else if (e.frame >= 35 && e.frame <= 40)
170 if (e.frame == 35) f = f + 2;
171 else if (e.frame == 36) f = f + 10;
172 else if (e.frame == 37) f = f + 10;
173 else if (e.frame == 38) f = f + 8;
174 else if (e.frame == 39) f = f + 4;
175 else if (e.frame == 40) f = f + 2;
178 else if (e.frame >= 103 && e.frame <= 118)
180 if (e.frame >= 103 && e.frame <= 104) f = f + 6; //nailattack
181 else if (e.frame >= 105 && e.frame <= 106) f = f + 6; //light
182 else if (e.frame >= 107 && e.frame <= 112) f = f + 7; //rocketattack
183 else if (e.frame >= 112 && e.frame <= 118) f = f + 7; //shotattack
186 self.angles = e.angles + '0 0 -45';
187 setorigin (self, e.origin + '0 0 0' - f*v + v_right * 22);
188 self.nextthink = time + 0.01;
191 float flagcaptimerecord;
192 .float flagpickuptime;
201 if (other.classname != "player")
203 if (other.health < 1) // ignore dead players
206 if (self.cnt == FLAG_CARRY)
209 if (self.cnt == FLAG_BASE)
210 if (other.team == self.team)
211 if (other.flagcarried) // he's got a flag
212 if (other.flagcarried.team != self.team) // capture
214 t = time - other.flagpickuptime;
215 if (flagcaptimerecord == 0)
217 if (other.flagcarried.team == 5)
218 bprint(other.netname, "^7 captured the RED flag in ", ftos(t), " seconds\n");
220 bprint(other.netname, "^7 captured the BLUE flag in ", ftos(t), " seconds\n");
221 flagcaptimerecord = t;
223 else if (t < flagcaptimerecord)
225 if (other.flagcarried.team == 5)
226 bprint(other.netname, "^7 captured the RED flag in ", ftos(t), ", breaking the previous record of ", ftos(flagcaptimerecord), " seconds\n");
228 bprint(other.netname, "^7 captured the BLUE flag in ", ftos(t), ", breaking the previous record of ", ftos(flagcaptimerecord), " seconds\n");
229 flagcaptimerecord = t;
233 if (other.flagcarried.team == 5)
234 bprint(other.netname, "^7 captured the RED flag in ", ftos(t), ", failing to break the previous record of ", ftos(flagcaptimerecord), " seconds\n");
236 bprint(other.netname, "^7 captured the BLUE flag in ", ftos(t), ", failing to break the previous record of ", ftos(flagcaptimerecord), " seconds\n");
239 other.frags = other.frags + cvar("g_ctf_flagscore_capture");//FLAGSCORE_CAPTURE;
240 head = find(head, classname, "player");
243 if (head.team == self.team)
244 head.frags = head.frags + cvar("g_ctf_flagscore_capture_team");//FLAGSCORE_CAPTURE_TEAM;
245 head = find(head, classname, "player");
247 sound (self, CHAN_AUTO, self.noise2, 1, ATTN_NONE);
248 ReturnFlag(other.flagcarried);
250 if (self.cnt == FLAG_BASE)
251 if (other.team == 5 || other.team == 14) // only red and blue team can steal flags
252 if (other.team != self.team)
253 if (!other.flagcarried)
256 other.flagpickuptime = time; // used for timing runs
257 self.solid = SOLID_NOT;
258 setorigin(self, self.origin); // relink
260 other.flagcarried = self;
261 self.cnt = FLAG_CARRY;
262 if (other.flagcarried.team == 5)
263 bprint(other.netname, "^7 got the RED flag\n");
265 bprint(other.netname, "^7 got the BLUE flag\n");
266 other.frags = other.frags + cvar("g_ctf_flagscore_pickup");//FLAGSCORE_PICKUP;
267 sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
269 player = find(world, classname, "player");
271 if(player.team == self.team) centerprint(player, "The enemy got your flag! Retrieve it!");
272 player = find(player, classname, "player");
278 if (self.cnt == FLAG_DROPPED)
280 self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
281 if (other.team == self.team || (other.team != 5 && other.team != 14))
285 bprint(other.netname, "^7 returned the RED flag\n");
287 bprint(other.netname, "^7 returned the BLUE flag\n");
288 if (other.team == 5 || other.team == 14)
289 other.frags = other.frags + cvar("g_ctf_flagscore_return");//FLAGSCORE_RETURN;
291 other.frags = other.frags + cvar("g_ctf_flagscore_return_rogue");//FLAGSCORE_RETURNROGUE;
292 sound (self, CHAN_AUTO, self.noise1, 1, ATTN_NONE);
295 else if (!other.flagcarried)
298 other.flagpickuptime = time; // used for timing runs
299 self.solid = SOLID_NOT;
300 setorigin(self, self.origin); // relink
302 other.flagcarried = self;
303 self.cnt = FLAG_CARRY;
305 bprint(other.netname, "^7 picked up the RED flag\n");
307 bprint(other.netname, "^7 picked up the BLUE flag\n");
308 other.frags = other.frags + cvar("g_ctf_flagscore_pickup");//FLAGSCORE_PICKUP;
309 sound (self, CHAN_AUTO, self.noise, 1, ATTN_NONE);
311 player = find(world, classname, "player");
313 if(player.team == self.team) centerprint(player, "The enemy got your flag! Retrieve it!");
314 player = find(player, classname, "player");
320 /*QUAKED info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
321 CTF Starting point for a player
326 viewing angle when spawning
328 void() info_player_team1 =
331 self.classname = "info_player_deathmatch";
333 //self.team = 4;self.classname = "info_player_start";info_player_start();};
335 /*QUAKED info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
336 CTF Starting point for a player in
341 viewing angle when spawning
343 void() info_player_team2 =
346 self.classname = "info_player_deathmatch";
348 //self.team = 13;self.classname = "info_player_start";info_player_start();};
350 /*QUAKED info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
351 CTF Starting point for a player in
356 viewing angle when spawning
358 void() info_player_team3 =
361 self.classname = "info_player_deathmatch";
365 /*QUAKED info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
366 CTF Starting point for a player in
371 viewing angle when spawning
373 void() info_player_team4 =
376 self.classname = "info_player_deathmatch";
382 /*QUAKED item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
383 CTF flag for team one (Red).
384 Multiple are allowed.
388 Angle the flag will point
391 model to use, note this needs red and blue as skins 0 and 1
392 (default models/ctf/flag.md3)
394 sound played when flag is picked up
395 (default ctf/take.wav)
397 sound played when flag is returned by a teammate
398 (default ctf/return.wav)
400 sound played when flag is captured
401 (default ctf/capture.wav)
403 sound played when flag is lost in the field and respawns itself
404 (default ctf/respawn.wav)
407 void() item_flag_team1 =
411 //if(!cvar("teamplay"))
412 // cvar_set("teamplay", "3");
414 self.team = 5; // color 4 team (red)
415 self.items = IT_KEY2; // gold key (redish enough)
418 self.model = "models/ctf/flag_red.md3";
420 self.noise = "ctf/take.wav";
422 self.noise1 = "ctf/return.wav";
424 self.noise2 = "ctf/capture.wav";
426 self.noise3 = "ctf/respawn.wav";
427 precache_model (self.model);
428 setmodel (self, self.model);
429 precache_sound (self.noise);
430 precache_sound (self.noise1);
431 precache_sound (self.noise2);
432 precache_sound (self.noise3);
433 setsize(self, '-16 -16 -37', '16 16 37');
434 setorigin(self, self.origin + '0 0 37');
435 self.nextthink = time + 0.2; // start after doors etc
436 self.think = place_flag;
440 //if(!self.glow_size)
441 // self.glow_size = 50;
443 self.effects = self.effects | EF_FULLBRIGHT | EF_LOWPRECISION;
446 /*QUAKED item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
447 CTF flag for team two (Blue).
448 Multiple are allowed.
452 Angle the flag will point
457 void() item_flag_team2 =
461 //if(!cvar("teamplay"))
462 // cvar_set("teamplay", "3");
464 self.team = 14; // color 13 team (blue)
465 self.items = IT_KEY1; // silver key (bluish enough)
468 self.model = "models/ctf/flag_blue.md3";
470 self.noise = "ctf/take.wav";
472 self.noise1 = "ctf/return.wav";
474 self.noise2 = "ctf/capture.wav";
476 self.noise3 = "ctf/respawn.wav";
477 precache_model (self.model);
478 setmodel (self, self.model);
479 precache_sound (self.noise);
480 precache_sound (self.noise1);
481 precache_sound (self.noise2);
482 precache_sound (self.noise3);
483 setsize(self, '-16 -16 -37', '16 16 37');
484 setorigin(self, self.origin + '0 0 37');
485 self.nextthink = time + 0.2; // start after doors etc
486 self.think = place_flag;
490 //if(!self.glow_size)
491 // self.glow_size = 50;
493 self.effects = self.effects | EF_FULLBRIGHT | EF_LOWPRECISION;
497 /*QUAKED ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
498 Team declaration for CTF gameplay, this allows you to decide what team
499 names and control point models are used in your map.
501 Note: If you use ctf_team entities you must define at least 2! However, unlike
502 domination, you don't need to make a blank one too.
506 Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)
508 Scoreboard color of the team (for example 4 is red and 13 is blue)
514 self.classname = "ctf_team";
515 self.team = self.cnt + 1;
518 // code from here on is just to support maps that don't have control point and team entities
519 void ctf_spawnteam (string teamname, float teamcolor)
521 local entity oldself;
524 self.classname = "ctf_team";
525 self.netname = teamname;
526 self.cnt = teamcolor;
533 // spawn some default teams if the map is not set up for ctf
534 void() ctf_spawnteams =
538 numteams = 2;//cvar("g_ctf_default_teams");
540 ctf_spawnteam("Red", 4);
541 ctf_spawnteam("Blue", 13);
544 void() ctf_delayedinit =
546 self.think = SUB_Remove;
547 self.nextthink = time;
548 // if no teams are found, spawn defaults
549 if (find(world, classname, "ctf_team") == world)
557 e.think = ctf_delayedinit;
558 e.nextthink = time + 0.1;