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 + cvar("g_ctf_flag_returntime");//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 0' - 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 + cvar("g_ctf_flagscore_capture");//FLAGSCORE_CAPTURE;
216 head = find(head, classname, "player");
219 if (head.team == self.team)
220 head.frags = head.frags + cvar("g_ctf_flagscore_capture_team");//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 + cvar("g_ctf_flagscore_pickup");//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 + cvar("g_ctf_flagscore_return");//FLAGSCORE_RETURN;
260 other.frags = other.frags + cvar("g_ctf_flagscore_return_rogue");//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 + cvar("g_ctf_flagscore_pickup");//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 =
294 self.classname = "info_player_deathmatch";
296 //self.team = 4;self.classname = "info_player_start";info_player_start();};
298 /*QUAKED info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
299 CTF Starting point for a player in
304 viewing angle when spawning
306 void() info_player_team2 =
309 self.classname = "info_player_deathmatch";
311 //self.team = 13;self.classname = "info_player_start";info_player_start();};
313 /*QUAKED info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
314 CTF Starting point for a player in
319 viewing angle when spawning
321 void() info_player_team3 =
324 self.classname = "info_player_deathmatch";
328 /*QUAKED info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
329 CTF Starting point for a player in
334 viewing angle when spawning
336 void() info_player_team4 =
339 self.classname = "info_player_deathmatch";
345 /*QUAKED item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
346 CTF flag for team one (Red).
347 Multiple are allowed.
351 Angle the flag will point
354 model to use, note this needs red and blue as skins 0 and 1
355 (default models/ctf/flag.md3)
357 sound played when flag is picked up
358 (default ctf/take.wav)
360 sound played when flag is returned by a teammate
361 (default ctf/return.wav)
363 sound played when flag is captured
364 (default ctf/capture.wav)
366 sound played when flag is lost in the field and respawns itself
367 (default ctf/respawn.wav)
370 void() item_flag_team1 =
374 //if(!cvar("teamplay"))
375 // cvar_set("teamplay", "3");
377 self.team = 5; // color 4 team (red)
378 self.items = IT_KEY2; // gold key (redish enough)
381 self.model = "models/ctf/flag_red.md3";
383 self.noise = "ctf/take.wav";
385 self.noise1 = "ctf/return.wav";
387 self.noise2 = "ctf/capture.wav";
389 self.noise3 = "ctf/respawn.wav";
390 precache_model (self.model);
391 setmodel (self, self.model);
392 precache_sound (self.noise);
393 precache_sound (self.noise1);
394 precache_sound (self.noise2);
395 precache_sound (self.noise3);
396 setsize(self, '-16 -16 -37', '16 16 37');
397 setorigin(self, self.origin + '0 0 37');
398 self.nextthink = time + 0.2; // start after doors etc
399 self.think = place_flag;
407 /*QUAKED item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
408 CTF flag for team two (Blue).
409 Multiple are allowed.
413 Angle the flag will point
418 void() item_flag_team2 =
422 //if(!cvar("teamplay"))
423 // cvar_set("teamplay", "3");
425 self.team = 14; // color 13 team (blue)
426 self.items = IT_KEY1; // silver key (bluish enough)
429 self.model = "models/ctf/flag_blue.md3";
431 self.noise = "ctf/take.wav";
433 self.noise1 = "ctf/return.wav";
435 self.noise2 = "ctf/capture.wav";
437 self.noise3 = "ctf/respawn.wav";
438 precache_model (self.model);
439 setmodel (self, self.model);
440 precache_sound (self.noise);
441 precache_sound (self.noise1);
442 precache_sound (self.noise2);
443 precache_sound (self.noise3);
444 setsize(self, '-16 -16 -37', '16 16 37');
445 setorigin(self, self.origin + '0 0 37');
446 self.nextthink = time + 0.2; // start after doors etc
447 self.think = place_flag;
456 /*QUAKED ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
457 Team declaration for CTF gameplay, this allows you to decide what team
458 names and control point models are used in your map.
460 Note: If you use ctf_team entities you must define at least 2! However, unlike
461 domination, you don't need to make a blank one too.
465 Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)
467 Scoreboard color of the team (for example 4 is red and 13 is blue)
473 self.classname = "ctf_team";
474 self.team = self.cnt + 1;
477 // code from here on is just to support maps that don't have control point and team entities
478 void ctf_spawnteam (string teamname, float teamcolor)
480 local entity oldself;
483 self.classname = "ctf_team";
484 self.netname = teamname;
485 self.cnt = teamcolor;
492 // spawn some default teams if the map is not set up for ctf
493 void() ctf_spawnteams =
497 numteams = 2;//cvar("g_ctf_default_teams");
499 ctf_spawnteam("Red", 4);
500 ctf_spawnteam("Blue", 13);
503 void() ctf_delayedinit =
505 self.think = SUB_Remove;
506 self.nextthink = time;
507 // if no teams are found, spawn defaults
508 if (find(world, classname, "ctf_team") == world)
516 e.think = ctf_delayedinit;
517 e.nextthink = time + 0.1;