1 string GotoMap(string m);
3 float FullTraceFraction(vector a, vector mi, vector ma, vector b)
16 while(vlen(c - b) > 1)
20 tracebox(c, mi, ma, b, MOVE_WORLDONLY, world);
25 black += vlen(trace_endpos - c);
29 n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
31 white += vlen(trace_endpos - c);
36 dprint("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
38 return white / (black + white);
41 float RadarMapAtPoint_Trace(float x, float y, float w, float h, float zmin, float zsize, float q)
46 ma = '1 0 0' * w + '0 1 0' * h;
47 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
48 b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * (zsize + zmin);
50 return FullTraceFraction(a, mi, ma, b);
52 float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, float zsize, float q)
59 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
62 dz = (zsize / q) * '0 0 1';
63 ma = '1 0 0' * w + '0 1 0' * h + dz;
64 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
66 if(x < world.absmin_x - w)
68 if(y < world.absmin_y - h)
70 if(x > world.absmax_x)
72 if(y > world.absmax_y)
76 for(i = 0; i < q; ++i)
79 v1 = v2 = o + dz * i + mi;
80 v1_x += random() * (ma_x - mi_x);
81 v1_y += random() * (ma_y - mi_y);
82 v1_z += random() * (ma_z - mi_z);
83 v2_x += random() * (ma_x - mi_x);
84 v2_y += random() * (ma_y - mi_y);
85 v2_z += random() * (ma_z - mi_z);
86 traceline(v1, v2, MOVE_WORLDONLY, world);
87 if(trace_startsolid || trace_fraction < 1)
92 float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, float zsize, float q)
99 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
102 dz = (zsize / q) * '0 0 1';
103 ma = '1 0 0' * w + '0 1 0' * h + dz;
104 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
106 if(x < world.absmin_x - w)
108 if(y < world.absmin_y - h)
110 if(x > world.absmax_x)
112 if(y > world.absmax_y)
116 for(i = 0; i < q; ++i)
118 tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world);
124 float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, float zsize, float q)
128 q *= 4; // choose q so it matches the regular algorithm in speed
131 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
134 ma = '1 0 0' * w + '0 1 0' * h;
135 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
136 b = '1 0 0' * w + '0 1 0' * h + '0 0 1' * zsize;
141 for(i = 0; i < q; ++i)
144 v_x = a_x + random() * b_x;
145 v_y = a_y + random() * b_y;
146 v_z = a_z + random() * b_z;
147 traceline(v, v, MOVE_WORLDONLY, world);
155 // FF is contained twice, to map 256 to FF too
156 // removes the need to bound()
157 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFFFF";
159 float RADAR_WIDTH_MAX = 2048;
160 float RADAR_HEIGHT_MAX = 2048;
161 float sharpen_buffer[RADAR_WIDTH_MAX * 3];
163 void sharpen_set(float x, float v)
165 sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
168 float sharpen_getpixel(float x, float y)
172 if(x >= RADAR_WIDTH_MAX)
178 return sharpen_buffer[x + y * RADAR_WIDTH_MAX];
181 float sharpen_get(float x, float a)
184 sum = sharpen_getpixel(x, 1);
188 sum -= sharpen_getpixel(x - 1, 0);
189 sum -= sharpen_getpixel(x - 1, 1);
190 sum -= sharpen_getpixel(x - 1, 2);
191 sum -= sharpen_getpixel(x + 1, 0);
192 sum -= sharpen_getpixel(x + 1, 1);
193 sum -= sharpen_getpixel(x + 1, 2);
194 sum -= sharpen_getpixel(x, 0);
195 sum -= sharpen_getpixel(x, 2);
196 return bound(0, sum * a, 1);
199 void sharpen_shift(float w)
202 for(i = 0; i < w; ++i)
204 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
205 sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
206 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
210 void sharpen_init(float w)
213 for(i = 0; i < w; ++i)
215 sharpen_buffer[i] = 0;
216 sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
217 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
224 if(radarmapper.count & 4)
228 else if(radarmapper.count & 2)
230 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"));
239 // size: pixel width/height
240 // maxs: cell width/height
242 void RadarMap_Think()
250 get_mi_min_max_texcoords(1);
251 self.mins = mi_picmin;
252 self.maxs_x = (mi_picmax_x - mi_picmin_x) / self.size_x;
253 self.maxs_y = (mi_picmax_y - mi_picmin_y) / self.size_y;
254 self.maxs_z = mi_max_z - mi_min_z;
255 print("Picture mins/maxs: ", ftos(self.maxs_x), " and ", ftos(self.maxs_y), " should match\n");
256 self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
257 if(!(self.count & 1))
259 self.cnt = fopen(self.netname, FILE_READ);
261 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ);
263 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ);
265 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ);
267 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ);
269 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ);
271 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ);
276 print(self.netname, " already exists, aborting (you may want to specify --force)\n");
281 self.cnt = fopen(self.netname, FILE_WRITE);
284 print("Error writing ", self.netname, "\n");
289 print("Writing to ", self.netname, "...\n");
290 fputs(self.cnt, "/* XPM */\n");
291 fputs(self.cnt, "static char *RadarMap[] = {\n");
292 fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
293 fputs(self.cnt, strcat("\"", ftos(self.size_x), " ", ftos(self.size_y), " 256 2\",\n"));
294 for(i = 0; i < 256; ++i)
296 si = substring(doublehex, i*2, 2);
297 fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n"));
300 self.nextthink = time;
301 sharpen_init(self.size_x);
303 else if(self.frame <= self.size_y)
305 // fill the sharpen buffer with this line
306 sharpen_shift(self.size_x);
313 for(x = 0; x < self.size_x; ++x)
315 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);
320 for(x = 0; x < self.size_x; ++x)
322 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);
327 for(x = 0; x < self.size_x; ++x)
329 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);
334 for(x = 0; x < self.size_x; ++x)
336 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);
342 // do we have enough lines?
345 // write a pixel line
346 fputs(self.cnt, "\"");
347 for(x = 0; x < self.size_x; ++x)
349 l = sharpen_get(x, self.ltime);
350 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
352 if(self.frame == self.size_y)
353 fputs(self.cnt, "\"\n");
356 fputs(self.cnt, "\",\n");
357 print(ftos(self.size_y - self.frame), " lines left\n");
361 // is this the last line? then write back the missing line
362 if(self.frame == self.size_y)
364 sharpen_shift(self.size_x);
365 // write a pixel line
366 fputs(self.cnt, "\"");
367 for(x = 0; x < self.size_x; ++x)
369 l = sharpen_get(x, self.ltime);
370 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
372 if(self.frame == self.size_y)
373 fputs(self.cnt, "\"\n");
376 fputs(self.cnt, "\",\n");
377 print(ftos(self.size_y - self.frame), " lines left\n");
382 self.nextthink = time;
387 fputs(self.cnt, "};\n");
389 print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
394 void RadarMap(float argc)
399 radarmapper = spawn();
400 radarmapper.classname = "radarmapper";
401 radarmapper.think = RadarMap_Think;
402 radarmapper.nextthink = time;
403 radarmapper.count = 8; // default to the --trace method, as it is faster now
404 radarmapper.ltime = 1;
405 radarmapper.size_x = 512;
406 radarmapper.size_y = 512;
407 radarmapper.size_z = 1;
409 for(i = 1; i < argc; ++i)
411 if(argv(i) == "--force")
412 radarmapper.count |= 1;
413 else if(argv(i) == "--loop")
414 radarmapper.count |= 2;
415 else if(argv(i) == "--quit")
416 radarmapper.count |= 4;
417 else if(argv(i) == "--block")
419 radarmapper.count &~= 24;
421 else if(argv(i) == "--trace")
423 radarmapper.count &~= 24;
424 radarmapper.count |= 8;
426 else if(argv(i) == "--sample")
428 radarmapper.count &~= 24;
429 radarmapper.count |= 16;
431 else if(argv(i) == "--lineblock")
433 radarmapper.count |= 24;
435 else if(argv(i) == "--flags") // for the recursive call
438 radarmapper.count = stof(argv(i));
440 else if(argv(i) == "--sharpen") // for the recursive call
443 radarmapper.ltime = stof(argv(i));
445 else if(argv(i) == "--res") // resolution
448 radarmapper.size_x = stof(argv(i));
450 radarmapper.size_y = stof(argv(i));
452 else if(argv(i) == "--qual") // quality multiplier
455 radarmapper.size_z = stof(argv(i));
461 print("Usage: sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n");
462 print("The quality factor Q is roughly proportional to the time taken.\n");
463 print("--trace supports no quality factor; its result should look like --block with infinite quality factor.\n");
469 print("Radarmap entity spawned.\n");
474 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
475 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
476 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
477 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
478 print("Solid bounding box size:");
480 tracebox('1 0 0' * world.absmin_x,
481 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
482 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
483 '1 0 0' * world.absmax_x,
487 print(" ", ftos(world.absmin_x));
489 print(" ", ftos(trace_endpos_x));
491 tracebox('0 1 0' * world.absmin_y,
492 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
493 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
494 '0 1 0' * world.absmax_y,
498 print(" ", ftos(world.absmin_y));
500 print(" ", ftos(trace_endpos_y));
502 tracebox('0 0 1' * world.absmin_z,
503 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
504 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
505 '0 0 1' * world.absmax_z,
509 print(" ", ftos(world.absmin_z));
511 print(" ", ftos(trace_endpos_z));
513 tracebox('1 0 0' * world.absmax_x,
514 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
515 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
516 '1 0 0' * world.absmin_x,
520 print(" ", ftos(world.absmax_x));
522 print(" ", ftos(trace_endpos_x));
524 tracebox('0 1 0' * world.absmax_y,
525 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
526 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
527 '0 1 0' * world.absmin_y,
531 print(" ", ftos(world.absmax_y));
533 print(" ", ftos(trace_endpos_y));
535 tracebox('0 0 1' * world.absmax_z,
536 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
537 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
538 '0 0 1' * world.absmin_z,
542 print(" ", ftos(world.absmax_z));
544 print(" ", ftos(trace_endpos_z));
549 void EffectIndexDump()
557 print("begin of effects list\n");
558 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
559 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
560 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
561 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
562 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
563 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
564 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
565 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
566 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
567 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
568 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
569 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
570 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
571 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
572 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
573 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
574 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
575 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
576 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
577 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
578 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
579 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
580 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
581 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
582 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
583 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
584 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
585 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
586 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
587 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
588 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
589 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
590 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
591 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
592 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
594 fh = fopen("effectinfo.txt", FILE_READ);
595 while((s = fgets(fh)))
597 tokenize(s); // tokenize_console would hit the loop counter :(
598 if(argv(0) == "effect")
600 if(db_get(d, argv(1)) != "1")
602 if(particleeffectnum(argv(1)) >= 0)
603 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
604 db_put(d, argv(1), "1");
608 print("end of effects list\n");
613 void make_mapinfo_Think()
615 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
617 print("Done rebuiling mapinfos.\n");
618 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
623 self.think = make_mapinfo_Think;
624 self.nextthink = time;
628 void GameCommand(string command)
635 argc = tokenize_console(command);
637 if(argv(0) == "help" || argc == 0)
639 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
640 print(" adminmsg clientnumber \"message\"\n");
641 print(" teamstatus\n");
642 print(" printstats\n");
643 print(" make_mapinfo\n");
644 print(" gametype dm|ctf|...\n");
645 print(" savedb filename\n");
646 print(" dumpdb filename\n");
647 print(" loaddb filename\n");
648 print(" allready\n");
649 print(" effectindexdump\n");
650 print(" radarmap [--force] [--quit | --loop] [sharpness]\n");
652 print(" cvar_changes\n");
653 print(" find classname\n");
654 GameCommand_Vote("help", world);
655 GameCommand_Ban("help");
656 GameCommand_Generic("help");
660 if(GameCommand_Vote(command, world))
663 if(GameCommand_Ban(command))
666 if(GameCommand_Generic(command))
669 if(argv(0) == "printstats")
675 if(argv(0) == "make_mapinfo")
678 e.classname = "make_mapinfo";
679 e.think = make_mapinfo_Think;
685 if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
687 CampaignLevelWarp(stof(argv(1)));
691 if(argv(0) == "gotomap") if(argc == 2)
693 print(GotoMap(argv(1)), "\n");
697 if(argv(0) == "gametype") if(argc == 2)
701 t = MapInfo_Type_FromString(s);
702 tsave = MapInfo_CurrentGametype();
705 MapInfo_SwitchGameType(t);
706 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
707 if(MapInfo_count > 0)
709 bprint("Game type successfully switched to ", s, "\n");
713 bprint("Cannot use this game type: no map for it found\n");
714 MapInfo_SwitchGameType(tsave);
715 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
719 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
723 if(argv(0) == "adminmsg")
726 entno = stof(argv(1));
728 if((entno < 1) | (entno > maxclients)) {
729 print("Player ", argv(1), " doesn't exist\n");
733 client = edict_num(entno);
735 if(client.flags & FL_CLIENT)
737 centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
738 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
739 print("Message sent to ", client.netname, "\n");
742 print("Client not found\n");
747 if(argv(0) == "savedb") if(argc == 2)
749 db_save(ServerProgsDB, argv(1));
750 print("DB saved.\n");
754 if(argv(0) == "dumpdb") if(argc == 2)
756 db_dump(ServerProgsDB, argv(1));
757 print("DB dumped.\n");
761 if(argv(0) == "loaddb") if(argc == 2)
763 db_close(ServerProgsDB);
764 ServerProgsDB = db_load(argv(1));
765 print("DB loaded.\n");
769 if (argv(0) == "nospectators")
773 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
775 if(plr.classname == "spectator" || plr.classname == "observer")
777 plr.spectatortime = time;
778 sprint(plr, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
781 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
785 if (argv(0) == "lockteams")
790 bprint("^1The teams are now locked.\n");
793 bprint("That command can only be used in a team-based gamemode.\n");
797 if (argv(0) == "unlockteams")
802 bprint("^1The teams are now unlocked.\n");
805 bprint("That command can only be used in a team-based gamemode.\n");
808 if (argv(0) == "movetoteam") if(argc == 3)
810 entno = stof(argv(1));
812 if(entno <= maxclients)
813 client = edict_num(entno);
814 if(client.flags & FL_CLIENT)
821 SV_ParseClientCommand(strcat("selectteam ", argv(2)));
826 print("Client not found\n");
829 if (argv(0) == "teamstatus")
831 Score_NicePrint(world);
834 if (argv(0) == "allready")
839 if (argv(0) == "effectindexdump")
844 if (argv(0) == "radarmap")
849 if (argv(0) == "bbox")
854 if (argv(0) == "cvar_changes")
859 if (argv(0) == "find") if(argc == 2)
861 for(client = world; (client = find(client, classname, argv(1))); )
862 print(etos(client), "\n");
865 if (argv(0) == "records")
867 strunzone(records_reply);
868 records_reply = strzone(getrecords());
869 print(records_reply);
873 if(argv(0) == "cointoss")
875 bprint("^3Throwing coin... Result: ");
877 bprint("^1heads ^3!\n");
879 bprint("^1tails ^3!\n");
883 if(argv(0) == "__FORCE_READY_RESTART")
889 if(argv(0) == "debug_shotorg")
891 debug_shotorg = stov(argv(1));
895 if(argv(0) == "gettaginfo") if(argc >= 4)
899 setmodel(e, (nextent(world)).weaponentity.model);
901 setmodel(e, argv(1));
902 e.frame = stof(argv(2));
903 i = gettagindex(e, argv(3));
906 v = gettaginfo(e, i);
907 print("model ", e.model, " frame ", ftos(e.frame), " tag ", argv(3));
908 print(" index = ", ftos(i));
909 print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
913 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
917 print("bone not found\n");
922 if(argv(0) == "time")
924 print("time = ", ftos(time), "\n");
925 print("frame start = ", ftos(gettime(GETTIME_FRAMESTART)), "\n");
926 print("realtime = ", ftos(gettime(GETTIME_REALTIME)), "\n");
927 print("hires = ", ftos(gettime(GETTIME_HIRES)), "\n");
928 print("uptime = ", ftos(gettime(GETTIME_UPTIME)), "\n");
929 print("localtime = ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
930 print("gmtime = ", strftime(FALSE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
934 if(argv(0) == "tracebug")
936 print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n");
939 vector org, delta, start, end, p, pos;
943 delta = world.maxs - world.mins;
945 start_x = org_x + random() * delta_x;
946 start_y = org_y + random() * delta_y;
947 start_z = org_z + random() * delta_z;
949 end_x = org_x + random() * delta_x;
950 end_y = org_y + random() * delta_y;
951 end_z = org_z + random() * delta_z;
953 start = stov(vtos(start));
954 end = stov(vtos(end));
956 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
957 if(!trace_startsolid)
960 tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
963 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
964 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
965 tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
967 // how much do we need to back off?
972 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
973 tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
976 if((safe + unsafe) * 0.5 == unsafe)
978 unsafe = (safe + unsafe) * 0.5;
982 if((safe + unsafe) * 0.5 == safe)
984 safe = (safe + unsafe) * 0.5;
988 print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
989 print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
991 tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
993 print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(trace_endpos), "\n");
995 print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(trace_endpos), "\n");
1002 if(argv(0) == "tracewalk")
1005 if(tracewalk(e, stov(argv(1)), e.mins, e.maxs, stov(argv(2)), MOVE_NORMAL))
1006 print("can walk\n");
1008 print("cannot walk\n");
1012 if(argv(0) == "onslaught_updatelinks")
1014 onslaught_updatelinks();
1015 print("ONS links updated\n");
1019 if(argv(0) == "bot_cmd")
1023 if(argv(1) == "help")
1027 bot_list_commands();
1028 print("\nsv_cmd bot_cmd reset #Clear the cmd queues of all bots\n");
1029 print("sv_cmd bot_cmd load <file> #Load script file\n");
1030 print("\nUse sv_cmd bot_cmd help <command> for more\n\n");
1034 bot_cmdhelp(argv(2));
1038 // Clear all bot queues
1039 if(argv(1) == "reset")
1045 // Load cmds from file
1046 if(argv(1) == "load" && argc == 3)
1049 fh = fopen(argv(2), FILE_READ);
1052 print("cannot open the file\n");
1057 while((s = fgets(fh)))
1059 argc = tokenize_console(s);
1061 if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
1063 // let's start at token 2 so we can skip sv_cmd bot_cmd
1064 bot = find_bot_by_number(stof(argv(2)));
1066 bot = find_bot_by_name(argv(2));
1068 bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
1071 localcmd(strcat(s, "\n"));
1076 print(ftos(i), " commands read\n");
1085 print("Usage: sv_cmd bot_cmd <bot name or number> <command> [argument]\n");
1086 print("Examples: bot_cmd <id> cc \"say something\"\n");
1087 print(" bot_cmd <id> presskey jump\n");
1088 print(" .. or sv_cmd bot_cmd help <command> for more\n");
1092 bot = find_bot_by_number(stof(argv(1)));
1094 bot = find_bot_by_name(argv(1));
1097 bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
1099 print(strcat("Error: Unable to find a bot with the name or number '",argv(1),"'\n"));
1104 if(argv(0) == "playerdemo")
1106 if(argv(1) == "read")
1108 entno = stof(argv(2));
1109 if((entno < 1) | (entno > maxclients)) {
1110 print("Player ", argv(2), " doesn't exist\n");
1113 client = edict_num(entno);
1114 if(clienttype(client) != CLIENTTYPE_BOT) {
1115 print("Player ", client.netname, " is not a bot\n");
1119 playerdemo_open_read(argv(3));
1122 else if(argv(1) == "write")
1124 entno = stof(argv(2));
1125 if((entno < 1) | (entno > maxclients)) {
1126 print("Player ", argv(2), " doesn't exist\n");
1129 client = edict_num(entno);
1131 playerdemo_open_write(argv(3));
1134 else if(argv(1) == "auto_read_and_write")
1138 cvar_set("bot_number", ftos(n));
1139 localcmd("wait; wait; wait\n");
1140 for(i = 0; i < n; ++i)
1141 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1142 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1145 else if(argv(1) == "auto_read")
1149 cvar_set("bot_number", ftos(n));
1150 localcmd("wait; wait; wait\n");
1151 for(i = 0; i < n; ++i)
1152 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1157 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");