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 = 2048;
161 float RADAR_HEIGHT_MAX = 2048;
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");
475 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
476 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
477 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
478 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
479 print("Solid bounding box size:");
481 tracebox('1 0 0' * world.absmin_x,
482 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
483 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
484 '1 0 0' * world.absmax_x,
488 print(" ", ftos(world.absmin_x));
490 print(" ", ftos(trace_endpos_x));
492 tracebox('0 1 0' * world.absmin_y,
493 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
494 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
495 '0 1 0' * world.absmax_y,
499 print(" ", ftos(world.absmin_y));
501 print(" ", ftos(trace_endpos_y));
503 tracebox('0 0 1' * world.absmin_z,
504 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
505 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
506 '0 0 1' * world.absmax_z,
510 print(" ", ftos(world.absmin_z));
512 print(" ", ftos(trace_endpos_z));
514 tracebox('1 0 0' * world.absmax_x,
515 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
516 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
517 '1 0 0' * world.absmin_x,
521 print(" ", ftos(world.absmax_x));
523 print(" ", ftos(trace_endpos_x));
525 tracebox('0 1 0' * world.absmax_y,
526 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
527 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
528 '0 1 0' * world.absmin_y,
532 print(" ", ftos(world.absmax_y));
534 print(" ", ftos(trace_endpos_y));
536 tracebox('0 0 1' * world.absmax_z,
537 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
538 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
539 '0 0 1' * world.absmin_z,
543 print(" ", ftos(world.absmax_z));
545 print(" ", ftos(trace_endpos_z));
550 void EffectIndexDump()
558 print("begin of effects list\n");
559 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
560 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
561 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
562 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
563 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
564 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
565 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
566 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
567 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
568 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
569 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
570 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
571 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
572 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
573 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
574 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
575 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
576 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
577 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
578 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
579 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
580 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
581 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
582 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
583 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
584 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
585 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
586 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
587 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
588 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
589 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
590 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
591 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
592 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
593 db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
594 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
596 fh = fopen("effectinfo.txt", FILE_READ);
597 while((s = fgets(fh)))
599 tokenize(s); // tokenize_console would hit the loop counter :(
600 if(argv(0) == "effect")
602 if(db_get(d, argv(1)) != "1")
604 if(particleeffectnum(argv(1)) >= 0)
605 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
606 db_put(d, argv(1), "1");
610 print("end of effects list\n");
615 void make_mapinfo_Think()
617 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
619 print("Done rebuiling mapinfos.\n");
620 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
625 self.think = make_mapinfo_Think;
626 self.nextthink = time;
630 void changematchtime(float delta, float mi, float ma)
638 if(autocvar_timelimit < 0)
642 mi = 10; // at least ten sec in the future
643 cur = time - game_starttime;
645 mi += cur; // from current time!
647 lim = autocvar_timelimit * 60;
652 return; // cannot increase any further
654 new = min(ma, lim + delta);
655 else // already above maximum: FAIL
660 if(lim == 0) // infinite: try reducing to max, if we are allowed to
662 else if(lim > mi) // above minimum: decrease
663 new = max(mi, lim + delta);
664 else // already below minimum: FAIL
668 cvar_set("timelimit", ftos(new));
671 void GameCommand(string command)
678 argc = tokenize_console(command);
680 if(argv(0) == "help" || argc == 0)
682 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
683 print(" adminmsg clientnumber \"message\" [infobartime]\n");
684 print(" teamstatus\n");
685 print(" printstats\n");
686 print(" make_mapinfo\n");
687 print(" gametype dm|ctf|...\n");
688 print(" savedb filename\n");
689 print(" dumpdb filename\n");
690 print(" loaddb filename\n");
691 print(" allready\n");
692 print(" effectindexdump\n");
693 print(" radarmap [--force] [--quit | --loop] [sharpness]\n");
695 print(" cvar_changes\n");
696 print(" cvar_purechanges\n");
697 print(" find classname\n");
698 print(" extendmatchtime\n");
699 print(" reducematchtime\n");
700 GameCommand_Vote("help", world);
701 GameCommand_Ban("help");
702 GameCommand_Generic("help");
706 if(GameCommand_Vote(command, world))
709 if(GameCommand_Ban(command))
712 if(GameCommand_Generic(command))
715 if(argv(0) == "printstats")
721 if(argv(0) == "make_mapinfo")
724 e.classname = "make_mapinfo";
725 e.think = make_mapinfo_Think;
731 if(argv(0) == "gotomap") if(argc == 2)
733 print(GotoMap(argv(1)), "\n");
737 if(argv(0) == "gametype") if(argc == 2)
741 t = MapInfo_Type_FromString(s);
742 tsave = MapInfo_CurrentGametype();
745 MapInfo_SwitchGameType(t);
746 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
747 if(MapInfo_count > 0)
749 bprint("Game type successfully switched to ", s, "\n");
753 bprint("Cannot use this game type: no map for it found\n");
754 MapInfo_SwitchGameType(tsave);
755 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
759 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
763 if(argv(0) == "adminmsg")
764 if(argc >= 3 && argc <= 4)
766 entno = stof(argv(1));
768 if((entno < 1) | (entno > maxclients)) {
769 print("Player ", argv(1), " doesn't exist\n");
773 client = edict_num(entno);
775 if(client.flags & FL_CLIENT)
780 s = strreplace(s, "\n", "");
781 s = strreplace(s, "\\", "\\\\");
782 s = strreplace(s, "$", "$$");
783 s = strreplace(s, "\"", "\\\"");
784 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
788 centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
789 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
791 print("Message sent to ", client.netname, "\n");
794 print("Client not found\n");
799 if(argv(0) == "savedb") if(argc == 2)
801 db_save(ServerProgsDB, argv(1));
802 print("DB saved.\n");
806 if(argv(0) == "dumpdb") if(argc == 2)
808 db_dump(ServerProgsDB, argv(1));
809 print("DB dumped.\n");
813 if(argv(0) == "loaddb") if(argc == 2)
815 db_close(ServerProgsDB);
816 ServerProgsDB = db_load(argv(1));
817 print("DB loaded.\n");
821 if (argv(0) == "nospectators")
825 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
827 if(plr.classname == "spectator" || plr.classname == "observer")
829 plr.spectatortime = time;
830 sprint(plr, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
833 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
837 if (argv(0) == "lockteams")
842 bprint("^1The teams are now locked.\n");
845 bprint("That command can only be used in a team-based gamemode.\n");
849 if (argv(0) == "unlockteams")
854 bprint("^1The teams are now unlocked.\n");
857 bprint("That command can only be used in a team-based gamemode.\n");
860 if(argv(0) == "movetoteam") if(argc == 3 || argc == 4) {
861 // sv_cmd movetoteam player_id team_colour
862 // sv_cmd movetoteam player_id team_colour type_of_move
865 // 0 (00) automove centerprint, admin message
866 // 1 (01) automove centerprint, no admin message
867 // 2 (10) no centerprint, admin message
868 // 3 (11) no centerprint, no admin message
870 if(!teams_matter) { // death match
871 print("Currently not playing a team game\n");
875 entno = stof(argv(1));
877 // player_id is out of range
878 if((entno < 1) | (entno > maxclients)) {
879 print("Player ", argv(1), " doesn't exist\n");
883 client = edict_num(entno);
885 // player entity is not a client
886 if not(client.flags & FL_CLIENT) {
887 print("Player ", argv(1), " doesn't exist\n");
891 // find the team to move the player to
895 save = client.team_forced;
896 client.team_forced = 0;
898 team_colour = ColourToNumber(argv(2));
900 if(team_colour == client.team) { // player already on the team
901 print("Player ", argv(1), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), "\n");
902 // keep the forcing undone
904 } else if(team_colour == 0) // auto team
905 team_colour = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
907 CheckAllowedTeams(client);
909 client.team_forced = save;
911 switch(team_colour) {
914 print("Sorry, there isn't a red team\n");
921 print("Sorry, there isn't a blue team\n");
928 print("Sorry, there isn't a yellow team\n");
935 print("Sorry, there isn't a pink team\n");
941 print("Sorry, team ", argv(2), " doesn't exist\n");
944 print("Player ", argv(1), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_colour), "\n");
946 client.team_forced = 0;
947 MoveToTeam(client, team_colour, 6, stof(argv(3)));
951 if (argv(0) == "teamstatus")
953 Score_NicePrint(world);
956 if (argv(0) == "allready")
961 if (argv(0) == "effectindexdump")
966 if (argv(0) == "radarmap")
971 if (argv(0) == "bbox")
976 if (argv(0) == "cvar_changes")
981 if (argv(0) == "cvar_purechanges")
983 print(cvar_purechanges);
986 if (argv(0) == "find") if(argc == 2)
988 for(client = world; (client = find(client, classname, argv(1))); )
989 print(etos(client), "\n");
992 if (argv(0) == "records")
994 for (i = 0; i < 10; ++i)
995 print(records_reply[i]);
998 if (argv(0) == "ladder")
1000 print(ladder_reply);
1003 if (argv(0) == "rankings")
1005 strunzone(rankings_reply);
1006 rankings_reply = strzone(getrankings());
1007 print(rankings_reply);
1011 if(argv(0) == "cointoss")
1013 bprint("^3Throwing coin... Result: ");
1015 bprint("^1heads ^3!\n");
1017 bprint("^1tails ^3!\n");
1021 if(argv(0) == "__FORCE_READY_RESTART")
1027 if(argv(0) == "debug_shotorg")
1029 debug_shotorg = stov(argv(1));
1030 debug_shotorg_y = -debug_shotorg_y;
1034 if(argv(0) == "gettaginfo") if(argc >= 4)
1038 setmodel(e, (nextent(world)).weaponentity.model);
1041 precache_model(argv(1));
1042 setmodel(e, argv(1));
1044 e.frame = stof(argv(2));
1045 if(substring(argv(3), 0, 1) == "#")
1046 i = stof(substring(argv(3), 1, -1));
1048 i = gettagindex(e, argv(3));
1051 v = gettaginfo(e, i);
1052 print("model ", e.model, " frame ", ftos(e.frame), " tag ", gettaginfo_name);
1053 print(" index ", ftos(i), " parent ", ftos(gettaginfo_parent), "\n");
1054 print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
1055 print(" offset = ", ftos(gettaginfo_offset_x), " ", ftos(gettaginfo_offset_y), " ", ftos(gettaginfo_offset_z), "\n");
1056 print(" forward = ", ftos(gettaginfo_forward_x), " ", ftos(gettaginfo_forward_y), " ", ftos(gettaginfo_forward_z), "\n");
1057 print(" right = ", ftos(gettaginfo_right_x), " ", ftos(gettaginfo_right_y), " ", ftos(gettaginfo_right_z), "\n");
1058 print(" up = ", ftos(gettaginfo_up_x), " ", ftos(gettaginfo_up_y), " ", ftos(gettaginfo_up_z), "\n");
1062 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
1066 print("bone not found\n");
1071 if(argv(0) == "time")
1073 print("time = ", ftos(time), "\n");
1074 print("frame start = ", ftos(gettime(GETTIME_FRAMESTART)), "\n");
1075 print("realtime = ", ftos(gettime(GETTIME_REALTIME)), "\n");
1076 print("hires = ", ftos(gettime(GETTIME_HIRES)), "\n");
1077 print("uptime = ", ftos(gettime(GETTIME_UPTIME)), "\n");
1078 print("localtime = ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
1079 print("gmtime = ", strftime(FALSE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
1083 if(argv(0) == "tracebug")
1085 print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n");
1088 vector org, delta, start, end, p, q, q0, pos;
1089 float safe, unsafe, dq, dqf;
1092 delta = world.maxs - world.mins;
1094 start_x = org_x + random() * delta_x;
1095 start_y = org_y + random() * delta_y;
1096 start_z = org_z + random() * delta_z;
1098 end_x = org_x + random() * delta_x;
1099 end_y = org_y + random() * delta_y;
1100 end_z = org_z + random() * delta_z;
1102 start = stov(vtos(start));
1103 end = stov(vtos(end));
1105 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1106 if(!trace_startsolid)
1109 tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
1110 if(trace_startsolid || trace_fraction == 1)
1112 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1113 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1114 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1116 if(trace_startsolid)
1118 // how much do we need to back off?
1123 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1124 tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
1125 if(trace_startsolid)
1127 if((safe + unsafe) * 0.5 == unsafe)
1129 unsafe = (safe + unsafe) * 0.5;
1133 if((safe + unsafe) * 0.5 == safe)
1135 safe = (safe + unsafe) * 0.5;
1139 print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
1140 print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
1142 tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
1143 if(trace_startsolid)
1144 print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1146 print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1155 q = p + normalize(end - p) * (dq + dqf);
1158 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1159 if(trace_startsolid)
1160 error("THIS ONE cannot happen");
1161 if(trace_fraction > 0)
1162 dq += dqf * trace_fraction;
1168 print("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1169 print("could go ", ftos(dq), " units further to ", vtos(q), "\n");
1177 if(argv(0) == "tracebug2")
1182 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1184 if(trace_fraction == 1)
1186 print("not above ground, aborting\n");
1190 for(i = 0; i < 100000; ++i)
1195 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1196 if(trace_startsolid)
1198 if(trace_fraction == 1)
1201 print("bug 2: ", ftos(dv_x), " ", ftos(dv_y), " ", ftos(dv_z));
1202 print(" (", ftos(asin(dv_z / vlen(dv)) * 180 / M_PI), " degrees)\n");
1206 print("highest possible dist: ", ftos(f), "\n");
1210 if(argv(0) == "tracewalk")
1213 if(tracewalk(e, stov(argv(1)), e.mins, e.maxs, stov(argv(2)), MOVE_NORMAL))
1214 print("can walk\n");
1216 print("cannot walk\n");
1220 if(argv(0) == "onslaught_updatelinks")
1222 onslaught_updatelinks();
1223 print("ONS links updated\n");
1227 if(argv(0) == "bot_cmd")
1231 if(argv(1) == "help")
1235 bot_list_commands();
1236 print("\nsv_cmd bot_cmd reset #Clear the cmd queues of all bots\n");
1237 print("sv_cmd bot_cmd load <file> #Load script file\n");
1238 print("\nUse sv_cmd bot_cmd help <command> for more\n\n");
1242 bot_cmdhelp(argv(2));
1246 // Clear all bot queues
1247 if(argv(1) == "reset")
1253 // Load cmds from file
1254 if(argv(1) == "load" && argc == 3)
1257 fh = fopen(argv(2), FILE_READ);
1260 print("cannot open the file\n");
1265 while((s = fgets(fh)))
1267 argc = tokenize_console(s);
1269 if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
1271 // let's start at token 2 so we can skip sv_cmd bot_cmd
1272 bot = find_bot_by_number(stof(argv(2)));
1274 bot = find_bot_by_name(argv(2));
1276 bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
1279 localcmd(strcat(s, "\n"));
1284 print(ftos(i), " commands read\n");
1293 print("Usage: sv_cmd bot_cmd <bot name or number> <command> [argument]\n");
1294 print("Examples: bot_cmd <id> cc \"say something\"\n");
1295 print(" bot_cmd <id> presskey jump\n");
1296 print(" .. or sv_cmd bot_cmd help <command> for more\n");
1300 bot = find_bot_by_number(stof(argv(1)));
1302 bot = find_bot_by_name(argv(1));
1305 bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
1307 print(strcat("Error: Unable to find a bot with the name or number '",argv(1),"'\n"));
1312 if(argv(0) == "playerdemo")
1314 if(argv(1) == "read")
1316 entno = stof(argv(2));
1317 if((entno < 1) | (entno > maxclients)) {
1318 print("Player ", argv(2), " doesn't exist\n");
1321 client = edict_num(entno);
1322 if(clienttype(client) != CLIENTTYPE_BOT) {
1323 print("Player ", client.netname, " is not a bot\n");
1327 playerdemo_open_read(argv(3));
1330 else if(argv(1) == "write")
1332 entno = stof(argv(2));
1333 if((entno < 1) | (entno > maxclients)) {
1334 print("Player ", argv(2), " doesn't exist\n");
1337 client = edict_num(entno);
1339 playerdemo_open_write(argv(3));
1342 else if(argv(1) == "auto_read_and_write")
1346 cvar_set("bot_number", ftos(n));
1347 localcmd("wait; wait; wait\n");
1348 for(i = 0; i < n; ++i)
1349 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1350 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1353 else if(argv(1) == "auto_read")
1357 cvar_set("bot_number", ftos(n));
1358 localcmd("wait; wait; wait\n");
1359 for(i = 0; i < n; ++i)
1360 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1365 if(argv(0) == "anticheat")
1367 entno = stof(argv(1));
1368 if((entno < 1) | (entno > maxclients)) {
1369 print("Player ", argv(1), " doesn't exist\n");
1372 client = edict_num(entno);
1373 if(clienttype(client) != CLIENTTYPE_REAL && clienttype(client) != CLIENTTYPE_BOT) {
1374 print("Player ", client.netname, " is not active\n");
1382 if(argv(0) == "defer_clear")
1385 entno = stof(argv(1));
1387 // player_id is out of range
1388 if((entno < 1) | (entno > maxclients)) {
1389 print("Player ", argv(1), " doesn't exist\n");
1393 client = edict_num(entno);
1395 if not(client.flags & FL_CLIENT) {
1396 print("Player ", argv(1), " doesn't exist\n");
1400 if(clienttype(client) == CLIENTTYPE_BOT) {
1401 print("Player ", argv(1), " (", client.netname, ") is a bot\n");
1405 stuffcmd(client, "defer clear\n");
1406 print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n");
1410 if(argv(0) == "defer_clear_all")
1412 FOR_EACH_CLIENTSLOT(client)
1413 GameCommand(strcat("defer_clear ", ftos(num_for_edict(client))));
1417 if(argv(0) == "delrec")
1420 race_deleteTime(argv(2), stof(argv(1)));
1422 race_deleteTime(GetMapname(), stof(argv(1)));
1427 if(argv(0) == "showtraceline")
1430 src = stov(argv(1));
1431 dst = stov(argv(2));
1432 traceline(src, dst, MOVE_NORMAL, world);
1433 trailparticles(world, particleeffectnum("TR_NEXUIZPLASMA"), src, trace_endpos);
1434 trailparticles(world, particleeffectnum("TR_CRYLINKPLASMA"), trace_endpos, dst);
1438 if(argv(0) == "extendmatchtime")
1440 changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1444 if(argv(0) == "reducematchtime")
1446 changematchtime(autocvar_timelimit_decrement*-60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1450 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");