1 string GotoMap(string m);
2 void race_deleteTime(string map, float pos);
4 float FullTraceFraction(vector a, vector mi, vector ma, vector b)
17 while(vlen(c - b) > 1)
21 tracebox(c, mi, ma, b, MOVE_WORLDONLY, world);
26 black += vlen(trace_endpos - c);
30 n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
32 white += vlen(trace_endpos - c);
37 dprint("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
39 return white / (black + white);
42 float RadarMapAtPoint_Trace(float x, float y, float w, float h, float zmin, float zsize, float q)
47 ma = '1 0 0' * w + '0 1 0' * h;
48 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
49 b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * (zsize + zmin);
51 return FullTraceFraction(a, mi, ma, b);
53 float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, float zsize, float q)
60 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
63 dz = (zsize / q) * '0 0 1';
64 ma = '1 0 0' * w + '0 1 0' * h + dz;
65 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
67 if(x < world.absmin_x - w)
69 if(y < world.absmin_y - h)
71 if(x > world.absmax_x)
73 if(y > world.absmax_y)
77 for(i = 0; i < q; ++i)
80 v1 = v2 = o + dz * i + mi;
81 v1_x += random() * (ma_x - mi_x);
82 v1_y += random() * (ma_y - mi_y);
83 v1_z += random() * (ma_z - mi_z);
84 v2_x += random() * (ma_x - mi_x);
85 v2_y += random() * (ma_y - mi_y);
86 v2_z += random() * (ma_z - mi_z);
87 traceline(v1, v2, MOVE_WORLDONLY, world);
88 if(trace_startsolid || trace_fraction < 1)
93 float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, float zsize, float q)
100 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
103 dz = (zsize / q) * '0 0 1';
104 ma = '1 0 0' * w + '0 1 0' * h + dz;
105 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
107 if(x < world.absmin_x - w)
109 if(y < world.absmin_y - h)
111 if(x > world.absmax_x)
113 if(y > world.absmax_y)
117 for(i = 0; i < q; ++i)
119 tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world);
125 float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, float zsize, float q)
129 q *= 4; // choose q so it matches the regular algorithm in speed
132 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
135 ma = '1 0 0' * w + '0 1 0' * h;
136 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
137 b = '1 0 0' * w + '0 1 0' * h + '0 0 1' * zsize;
142 for(i = 0; i < q; ++i)
145 v_x = a_x + random() * b_x;
146 v_y = a_y + random() * b_y;
147 v_z = a_z + random() * b_z;
148 traceline(v, v, MOVE_WORLDONLY, world);
156 // FF is contained twice, to map 256 to FF too
157 // removes the need to bound()
158 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFFFF";
160 float RADAR_WIDTH_MAX = 512;
161 float RADAR_HEIGHT_MAX = 512;
162 float sharpen_buffer[RADAR_WIDTH_MAX * 3];
164 void sharpen_set(float x, float v)
166 sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
169 float sharpen_getpixel(float x, float y)
173 if(x >= RADAR_WIDTH_MAX)
179 return sharpen_buffer[x + y * RADAR_WIDTH_MAX];
182 float sharpen_get(float x, float a)
185 sum = sharpen_getpixel(x, 1);
189 sum -= sharpen_getpixel(x - 1, 0);
190 sum -= sharpen_getpixel(x - 1, 1);
191 sum -= sharpen_getpixel(x - 1, 2);
192 sum -= sharpen_getpixel(x + 1, 0);
193 sum -= sharpen_getpixel(x + 1, 1);
194 sum -= sharpen_getpixel(x + 1, 2);
195 sum -= sharpen_getpixel(x, 0);
196 sum -= sharpen_getpixel(x, 2);
197 return bound(0, sum * a, 1);
200 void sharpen_shift(float w)
203 for(i = 0; i < w; ++i)
205 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
206 sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
207 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
211 void sharpen_init(float w)
214 for(i = 0; i < w; ++i)
216 sharpen_buffer[i] = 0;
217 sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
218 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
225 if(radarmapper.count & 4)
229 else if(radarmapper.count & 2)
231 localcmd(strcat("defer 1 \"sv_cmd radarmap --flags ", ftos(radarmapper.count), strcat(" --res ", ftos(radarmapper.size_x), " ", ftos(radarmapper.size_y), " --sharpen ", ftos(radarmapper.ltime), " --qual ", ftos(radarmapper.size_z)), "\"\n"));
240 // size: pixel width/height
241 // maxs: cell width/height
243 void RadarMap_Think()
251 get_mi_min_max_texcoords(1);
252 self.mins = mi_picmin;
253 self.maxs_x = (mi_picmax_x - mi_picmin_x) / self.size_x;
254 self.maxs_y = (mi_picmax_y - mi_picmin_y) / self.size_y;
255 self.maxs_z = mi_max_z - mi_min_z;
256 print("Picture mins/maxs: ", ftos(self.maxs_x), " and ", ftos(self.maxs_y), " should match\n");
257 self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
258 if(!(self.count & 1))
260 self.cnt = fopen(self.netname, FILE_READ);
262 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ);
264 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ);
266 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ);
268 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ);
270 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ);
272 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ);
277 print(self.netname, " already exists, aborting (you may want to specify --force)\n");
282 self.cnt = fopen(self.netname, FILE_WRITE);
285 print("Error writing ", self.netname, "\n");
290 print("Writing to ", self.netname, "...\n");
291 fputs(self.cnt, "/* XPM */\n");
292 fputs(self.cnt, "static char *RadarMap[] = {\n");
293 fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
294 fputs(self.cnt, strcat("\"", ftos(self.size_x), " ", ftos(self.size_y), " 256 2\",\n"));
295 for(i = 0; i < 256; ++i)
297 si = substring(doublehex, i*2, 2);
298 fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n"));
301 self.nextthink = time;
302 sharpen_init(self.size_x);
304 else if(self.frame <= self.size_y)
306 // fill the sharpen buffer with this line
307 sharpen_shift(self.size_x);
314 for(x = 0; x < self.size_x; ++x)
316 l = RadarMapAtPoint_Block(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
321 for(x = 0; x < self.size_x; ++x)
323 l = RadarMapAtPoint_Trace(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
328 for(x = 0; x < self.size_x; ++x)
330 l = RadarMapAtPoint_Sample(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
335 for(x = 0; x < self.size_x; ++x)
337 l = RadarMapAtPoint_LineBlock(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
343 // do we have enough lines?
346 // write a pixel line
347 fputs(self.cnt, "\"");
348 for(x = 0; x < self.size_x; ++x)
350 l = sharpen_get(x, self.ltime);
351 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
353 if(self.frame == self.size_y)
354 fputs(self.cnt, "\"\n");
357 fputs(self.cnt, "\",\n");
358 print(ftos(self.size_y - self.frame), " lines left\n");
362 // is this the last line? then write back the missing line
363 if(self.frame == self.size_y)
365 sharpen_shift(self.size_x);
366 // write a pixel line
367 fputs(self.cnt, "\"");
368 for(x = 0; x < self.size_x; ++x)
370 l = sharpen_get(x, self.ltime);
371 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
373 if(self.frame == self.size_y)
374 fputs(self.cnt, "\"\n");
377 fputs(self.cnt, "\",\n");
378 print(ftos(self.size_y - self.frame), " lines left\n");
383 self.nextthink = time;
388 fputs(self.cnt, "};\n");
390 print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
395 void RadarMap(float argc)
400 radarmapper = spawn();
401 radarmapper.classname = "radarmapper";
402 radarmapper.think = RadarMap_Think;
403 radarmapper.nextthink = time;
404 radarmapper.count = 8; // default to the --trace method, as it is faster now
405 radarmapper.ltime = 1;
406 radarmapper.size_x = 512;
407 radarmapper.size_y = 512;
408 radarmapper.size_z = 1;
410 for(i = 1; i < argc; ++i)
412 if(argv(i) == "--force")
413 radarmapper.count |= 1;
414 else if(argv(i) == "--loop")
415 radarmapper.count |= 2;
416 else if(argv(i) == "--quit")
417 radarmapper.count |= 4;
418 else if(argv(i) == "--block")
420 radarmapper.count &~= 24;
422 else if(argv(i) == "--trace")
424 radarmapper.count &~= 24;
425 radarmapper.count |= 8;
427 else if(argv(i) == "--sample")
429 radarmapper.count &~= 24;
430 radarmapper.count |= 16;
432 else if(argv(i) == "--lineblock")
434 radarmapper.count |= 24;
436 else if(argv(i) == "--flags") // for the recursive call
439 radarmapper.count = stof(argv(i));
441 else if(argv(i) == "--sharpen") // for the recursive call
444 radarmapper.ltime = stof(argv(i));
446 else if(argv(i) == "--res") // resolution
449 radarmapper.size_x = stof(argv(i));
451 radarmapper.size_y = stof(argv(i));
453 else if(argv(i) == "--qual") // quality multiplier
456 radarmapper.size_z = stof(argv(i));
462 print("Usage: sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n");
463 print("The quality factor Q is roughly proportional to the time taken.\n");
464 print("--trace supports no quality factor; its result should look like --block with infinite quality factor.\n");
470 print("Radarmap entity spawned.\n");
473 void EffectIndexDump()
481 print("begin of effects list\n");
482 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
483 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
484 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
485 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
486 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
487 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
488 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
489 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
490 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
491 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
492 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
493 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
494 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
495 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
496 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
497 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
498 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
499 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
500 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
501 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
502 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
503 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
504 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
505 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
506 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
507 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
508 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
509 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
510 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
511 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
512 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
513 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
514 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
515 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
516 db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
517 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
519 fh = fopen("effectinfo.txt", FILE_READ);
520 while((s = fgets(fh)))
522 tokenize(s); // tokenize_console would hit the loop counter :(
523 if(argv(0) == "effect")
525 if(db_get(d, argv(1)) != "1")
527 if(particleeffectnum(argv(1)) >= 0)
528 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
529 db_put(d, argv(1), "1");
533 print("end of effects list\n");
538 void make_mapinfo_Think()
540 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
542 print("Done rebuiling mapinfos.\n");
543 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
548 self.think = make_mapinfo_Think;
549 self.nextthink = time;
553 void changematchtime(float delta, float mi, float ma)
561 if(autocvar_timelimit < 0)
565 mi = 10; // at least ten sec in the future
566 cur = time - game_starttime;
568 mi += cur; // from current time!
570 lim = autocvar_timelimit * 60;
575 return; // cannot increase any further
577 new = min(ma, lim + delta);
578 else // already above maximum: FAIL
583 if(lim == 0) // infinite: try reducing to max, if we are allowed to
585 else if(lim > mi) // above minimum: decrease
586 new = max(mi, lim + delta);
587 else // already below minimum: FAIL
591 cvar_set("timelimit", ftos(new / 60));
594 float g_clientmodel_genericsendentity (entity to, float sf);
595 void modelbug_make_svqc();
596 void modelbug_make_csqc()
598 Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
599 self.think = modelbug_make_svqc;
600 self.nextthink = time + 1;
601 setorigin(self, self.origin - '0 0 8');
603 void modelbug_make_svqc()
605 self.SendEntity = func_null;
606 self.think = modelbug_make_csqc;
607 self.nextthink = time + 1;
608 setorigin(self, self.origin + '0 0 8');
615 setorigin(e, nextent(world).origin);
616 precache_model("models_portal.md3");
617 setmodel(e, "models/portal.md3");
618 e.think = modelbug_make_svqc;
619 e.nextthink = time + 1;
622 // ===================
624 // ===================
625 #define GC_REQUEST_HELP 1
626 #define GC_REQUEST_COMMAND 2
627 #define GC_REQUEST_USAGE 3
629 void GameCommand_adminmsg(float request, string command)
632 float argc = tokenize_console(command);
633 float entno = stof(argv(1));
639 case GC_REQUEST_HELP:
640 print(" adminmsg - Send an admin message to a client directly\n");
643 case GC_REQUEST_COMMAND:
644 if(argc >= 3 && argc <= 4) {
645 if((entno < 0) | (entno > maxclients)) {
646 print("Player ", argv(1), " doesn't exist\n");
650 for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
652 client = edict_num(i);
653 if(client.flags & FL_CLIENT)
658 s = strreplace("\n", "", s);
659 s = strreplace("\\", "\\\\", s);
660 s = strreplace("$", "$$", s);
661 s = strreplace("\"", "\\\"", s);
662 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
666 centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
667 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
669 dprint("Message sent to ", client.netname, "\n");
673 if(!n) { print("Client not found\n"); }
678 case GC_REQUEST_USAGE:
679 print("\nUsage: sv_cmd adminmsg clientnumber \"message\" [infobartime]\n");
680 print(" If infobartime is provided, the message will be sent to infobar.\n");
681 print(" Otherwise, it will just be sent as a centerprint message.\n");
682 print("Examples: adminmsg 4 \"this message will last for ten seconds\" 10\n");
683 print(" adminmsg 2 \"this message will be a centerprint\"\n");
688 void GameCommand_allready(float request)
692 case GC_REQUEST_HELP:
693 print(" allready - Restart the server and reset the players\n");
696 case GC_REQUEST_COMMAND:
701 case GC_REQUEST_USAGE:
702 print("\nUsage: sv_cmd allready\n");
703 print(" No arguments required.\n");
708 void GameCommand_allspec(float request)
714 case GC_REQUEST_HELP:
715 print(" allspec - Force all players to spectate\n");
718 case GC_REQUEST_COMMAND:
719 FOR_EACH_PLAYER(client)
721 PutObserverInServer();
724 if(i) { bprint(strcat("Successfully forced all players to spectate (", ftos(i), ")\n")); } // should a message be added if no players were found?
728 case GC_REQUEST_USAGE:
729 print("\nUsage: sv_cmd allspec\n");
730 print(" No arguments required.\n");
735 void GameCommand_anticheat(float request, string command)
738 float argc = tokenize_console(command);
739 float entno = stof(argv(1));
743 case GC_REQUEST_HELP:
744 print(" anticheat - Create an anticheat report for a client\n");
747 case GC_REQUEST_COMMAND:
748 if((entno < 1) | (entno > maxclients)) {
749 print("Player ", argv(1), " doesn't exist\n");
752 client = edict_num(entno);
753 if(clienttype(client) != CLIENTTYPE_REAL && clienttype(client) != CLIENTTYPE_BOT) {
754 print("Player ", client.netname, " is not active\n");
762 case GC_REQUEST_USAGE:
763 print("\nUsage: sv_cmd anticheat clientnumber\n");
764 print(" Where clientnumber is the entity number\n");
769 void GameCommand_bbox(float request)
773 case GC_REQUEST_HELP:
774 print(" bbox - Print large amounts of information about bboxes\n");
777 case GC_REQUEST_COMMAND:
778 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
779 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
780 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
781 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
782 print("Solid bounding box size:");
784 tracebox('1 0 0' * world.absmin_x,
785 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
786 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
787 '1 0 0' * world.absmax_x,
791 print(" ", ftos(world.absmin_x));
793 print(" ", ftos(trace_endpos_x));
795 tracebox('0 1 0' * world.absmin_y,
796 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
797 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
798 '0 1 0' * world.absmax_y,
802 print(" ", ftos(world.absmin_y));
804 print(" ", ftos(trace_endpos_y));
806 tracebox('0 0 1' * world.absmin_z,
807 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
808 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
809 '0 0 1' * world.absmax_z,
813 print(" ", ftos(world.absmin_z));
815 print(" ", ftos(trace_endpos_z));
817 tracebox('1 0 0' * world.absmax_x,
818 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
819 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
820 '1 0 0' * world.absmin_x,
824 print(" ", ftos(world.absmax_x));
826 print(" ", ftos(trace_endpos_x));
828 tracebox('0 1 0' * world.absmax_y,
829 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
830 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
831 '0 1 0' * world.absmin_y,
835 print(" ", ftos(world.absmax_y));
837 print(" ", ftos(trace_endpos_y));
839 tracebox('0 0 1' * world.absmax_z,
840 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
841 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
842 '0 0 1' * world.absmin_z,
846 print(" ", ftos(world.absmax_z));
848 print(" ", ftos(trace_endpos_z));
854 case GC_REQUEST_USAGE:
855 print("\nUsage: sv_cmd bbox\n");
856 print(" No arguments required.\n");
861 void GameCommand(string command)
863 // ===== TODO list =====
864 // Finish adding the rest of the commands
866 // Add ifdef to stuffto so that is can only be used when the game code is compiled for it
867 //(this way it's more obscure and harder to abuse on normal servers)
869 entity client, tmp_entity;
871 float search_request_type;
873 float argc = tokenize_console(command);
875 if(argv(0) == "help")
879 print("\nUsage: sv_cmd COMMAND..., where possible commands are:\n");
880 GameCommand_adminmsg(GC_REQUEST_HELP, command);
881 GameCommand_allready(GC_REQUEST_HELP);
882 GameCommand_allspec(GC_REQUEST_HELP);
883 GameCommand_anticheat(GC_REQUEST_HELP, command);
884 GameCommand_bbox(GC_REQUEST_HELP);
885 print(" teamstatus\n");
886 print(" printstats\n");
887 print(" make_mapinfo\n");
888 print(" gametype dm|ctf|...\n");
889 print(" savedb filename\n");
890 print(" dumpdb filename\n");
891 print(" loaddb filename\n");
892 print(" allready\n");
893 print(" effectindexdump\n");
894 print(" radarmap [--force] [--quit | --loop] [sharpness]\n");
896 print(" cvar_changes\n");
897 print(" cvar_purechanges\n");
898 print(" find classname\n");
899 print(" extendmatchtime\n");
900 print(" reducematchtime\n");
901 GameCommand_Vote("help", world);
902 GameCommand_Ban("help");
903 GameCommand_Generic("help");
904 print("For help about specific commands, type sv_cmd help COMMAND\n");
908 search_request_type = GC_REQUEST_USAGE; // Instead of trying to call a command, we're going to see detailed information about it
910 else if(GameCommand_Vote(command, world))
912 return; // handled by server/vote.qc
914 else if(GameCommand_Ban(command))
916 return; // handled by server/ipban.qc
918 else if(GameCommand_Generic(command))
920 return; // handled by common/gamecommand.qc
923 search_request_type = GC_REQUEST_COMMAND; // continue as usual and scan for normal commands
925 switch( ((argv(0) == "help") ? argv(1) : argv(0)) ) // if first argument is help, then search for the second argument. Else, search for first.
927 case "adminmsg": GameCommand_adminmsg(search_request_type, command); break;
928 case "allready": GameCommand_allready(search_request_type); break;
929 case "allspec": GameCommand_allspec(search_request_type); break;
930 case "anticheat": GameCommand_anticheat(search_request_type, command); break;
931 case "bbox": GameCommand_bbox(search_request_type); break;
934 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");