[nexuiz-commits] r8551 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Jan 25 12:03:56 EST 2010
Author: div0
Date: 2010-01-25 12:03:53 -0500 (Mon, 25 Jan 2010)
New Revision: 8551
Modified:
trunk/data/qcsrc/server/campaign.qc
trunk/data/qcsrc/server/cheats.qc
trunk/data/qcsrc/server/cheats.qh
trunk/data/qcsrc/server/clientcommands.qc
Log:
Migrate cmd cheats too
Modified: trunk/data/qcsrc/server/campaign.qc
===================================================================
--- trunk/data/qcsrc/server/campaign.qc 2010-01-25 17:03:41 UTC (rev 8550)
+++ trunk/data/qcsrc/server/campaign.qc 2010-01-25 17:03:53 UTC (rev 8551)
@@ -241,7 +241,7 @@
void CampaignLevelWarp(float n)
{
- if(!sv_cheats)
+ if(!sv_cheats) // can this even work?
return;
CampaignFile_Unload();
CampaignFile_Load(n, 1);
Modified: trunk/data/qcsrc/server/cheats.qc
===================================================================
--- trunk/data/qcsrc/server/cheats.qc 2010-01-25 17:03:41 UTC (rev 8550)
+++ trunk/data/qcsrc/server/cheats.qc 2010-01-25 17:03:53 UTC (rev 8551)
@@ -12,7 +12,7 @@
#define CHIMPULSE_TELEPORT 143
#define CHIMPULSE_R00T 148
-float CheatsAllowed(float i, string cmd) // the cheat gets passed as argument for possible future ACL checking
+float CheatsAllowed(float i, float argc) // the cheat gets passed as argument for possible future ACL checking
{
if(i == CHIMPULSE_CLONE_MOVING || i == CHIMPULSE_CLONE_STANDING)
if(self.lip < sv_clones)
@@ -28,7 +28,7 @@
float CheatImpulse(float i)
{
- if not(CheatsAllowed(i, string_null))
+ if not(CheatsAllowed(i, 0))
return 0;
switch(i)
{
@@ -158,7 +158,7 @@
sprint(self, "UR DEAD AHAHAH))\n");
else
sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
- return 0;
+ break;
case CHIMPULSE_TELEPORT:
if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((sv_cheats >= 2) ? 100000 : 100), 1024, 256))
{
@@ -169,7 +169,7 @@
}
else
sprint(self, "Emergency teleport could not find a good location, forget it!\n");
- return 0;
+ break;
case CHIMPULSE_R00T:
FOR_EACH_PLAYER(e)
{
@@ -206,9 +206,323 @@
return 0;
}
-float CheatCommand(string cmd)
+float CheatCommand(float argc)
{
- if not(CheatsAllowed(0, cmd))
+ if not(CheatsAllowed(0, argc))
return 0;
+ string cmd;
+ cmd = argv(0);
+ switch(cmd)
+ {
+ entity e;
+ float effectnum, f;
+ vector start, end;
+ entity oldself;
+
+ case "pointparticles":
+ if(argc == 5)
+ {
+ // arguments:
+ // effectname
+ // origin (0..1, on crosshair line)
+ // velocity
+ // howmany
+ effectnum = particleeffectnum(argv(1));
+ f = stof(argv(2));
+ start = (1-f) * self.origin + f * self.cursor_trace_endpos;
+ end = stov(argv(3));
+ f = stof(argv(4));
+ pointparticles(effectnum, start, end, f);
+ return 1;
+ }
+ sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
+ break;
+ case "trailparticles":
+ if(argc == 2)
+ {
+ // arguments:
+ // effectname
+ effectnum = particleeffectnum(argv(1));
+ W_SetupShot(self, FALSE, FALSE, "",0);
+ traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
+ trailparticles(self, effectnum, w_shotorg, trace_endpos);
+ return 1;
+ }
+ sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
+ break;
+ case "make":
+ if(argc == 3)
+ {
+ // arguments:
+ // modelname mode
+ f = stof(argv(2));
+ W_SetupShot(self, FALSE, FALSE, "", 0);
+ traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
+ if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
+ {
+ sprint(self, "cannot make stuff there (bad surface)\n");
+ }
+ else
+ {
+ e = spawn();
+ e.model = strzone(argv(1));
+ e.mdl = "rocket_explode";
+ e.health = 1000;
+ setorigin(e, trace_endpos);
+ e.effects = EF_NOMODELFLAGS;
+ if(f == 1)
+ {
+ e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
+ e.angles = AnglesTransform_Multiply(e.angles, '-90 0 0'); // so unrotated models work
+ }
+ oldself = self;
+ self = e;
+ spawnfunc_func_breakable();
+ self = oldself;
+ // now, is it valid?
+ if(f == 0)
+ {
+ tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_NORMAL, e);
+ if(trace_startsolid)
+ {
+ remove(e);
+ sprint(self, "cannot make stuff there (no space)\n");
+ }
+ else
+ return 1;
+ }
+ else
+ return 1;
+ }
+ }
+ else
+ sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
+ break;
+ case "penalty":
+ if(argc == 3)
+ {
+ race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
+ return 1;
+ }
+ sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
+ break;
+ case "dragbox_spawn":
+ e = spawn();
+ e.classname = "dragbox_box";
+ e.think = DragBox_Think;
+ e.nextthink = time;
+ e.solid = -1; // black
+ setmodel(e, "null"); // network it
+ if(argc == 4)
+ e.cnt = stof(argv(1));
+ else
+ e.cnt = max(0, drag_lastcnt);
+
+ e.aiment = spawn();
+ e.aiment.classname = "dragbox_corner_1";
+ e.aiment.owner = e;
+ setmodel(e.aiment, "models/marker.md3");
+ e.aiment.skin = 0;
+ setsize(e.aiment, '0 0 0', '0 0 0');
+ if(argc == 4)
+ setorigin(e.aiment, stov(argv(2)));
+ else
+ setorigin(e.aiment, self.cursor_trace_endpos);
+
+ e.enemy = spawn();
+ e.enemy.classname = "dragbox_corner_2";
+ e.enemy.owner = e;
+ setmodel(e.enemy, "models/marker.md3");
+ e.enemy.skin = 1;
+ setsize(e.enemy, '0 0 0', '0 0 0');
+ end = normalize(self.cursor_trace_start - e.aiment.origin);
+ end_x = (end_x > 0) * 2 - 1;
+ end_y = (end_y > 0) * 2 - 1;
+ end_z = (end_z > 0) * 2 - 1;
+ if(argc == 4)
+ setorigin(e.enemy, stov(argv(3)));
+ else
+ setorigin(e.enemy, e.aiment.origin + 32 * end);
+
+ e.killindicator = spawn();
+ e.killindicator.classname = "drag_digit";
+ e.killindicator.owner = e;
+ setattachment(e.killindicator, e, "");
+ setorigin(e.killindicator, '0 0 -8');
+ e.killindicator.killindicator = spawn();
+ e.killindicator.killindicator.classname = "drag_digit";
+ e.killindicator.killindicator.owner = e;
+ setattachment(e.killindicator.killindicator, e, "");
+ setorigin(e.killindicator.killindicator, '0 0 8');
+ return 1;
+ case "dragpoint_spawn":
+ e = spawn();
+ e.classname = "dragpoint";
+ e.think = DragBox_Think;
+ e.nextthink = time;
+ e.solid = 0; // nothing special
+ setmodel(e, "models/marker.md3");
+ setsize(e, PL_MIN, PL_MAX);
+ e.skin = 2;
+ if(argc == 3)
+ e.cnt = stof(argv(1));
+ else
+ e.cnt = drag_lastcnt;
+ if(argc == 3)
+ setorigin(e, stov(argv(2)));
+ else
+ {
+ setorigin(e, self.cursor_trace_endpos + normalize(self.cursor_trace_start - self.cursor_trace_endpos));
+ move_out_of_solid(e);
+ }
+
+ e.killindicator = spawn();
+ e.killindicator.classname = "drag_digit";
+ e.killindicator.owner = e;
+ setattachment(e.killindicator, e, "");
+ setorigin(e.killindicator, '0 0 40');
+ e.killindicator.killindicator = spawn();
+ e.killindicator.killindicator.classname = "drag_digit";
+ e.killindicator.killindicator.owner = e;
+ setattachment(e.killindicator.killindicator, e, "");
+ setorigin(e.killindicator.killindicator, '0 0 56');
+ return 1;
+ case "drag_remove":
+ RandomSelection_Init();
+ for(e = world; (e = find(e, classname, "dragbox_box")); )
+ RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+ for(e = world; (e = find(e, classname, "dragpoint")); )
+ RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+ if(RandomSelection_chosen_ent)
+ {
+ remove(RandomSelection_chosen_ent.killindicator.killindicator);
+ remove(RandomSelection_chosen_ent.killindicator);
+ if(RandomSelection_chosen_ent.aiment)
+ remove(RandomSelection_chosen_ent.aiment);
+ if(RandomSelection_chosen_ent.enemy)
+ remove(RandomSelection_chosen_ent.enemy);
+ remove(RandomSelection_chosen_ent);
+ }
+ return 1;
+ case "drag_setcnt":
+ if(argc == 2)
+ {
+ RandomSelection_Init();
+ for(e = world; (e = find(e, classname, "dragbox_box")); )
+ RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+ for(e = world; (e = find(e, classname, "dragpoint")); )
+ RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+ if(RandomSelection_chosen_ent)
+ {
+ if(substring(argv(1), 0, 1) == "*")
+ RandomSelection_chosen_ent.cnt = drag_lastcnt = RandomSelection_chosen_ent.cnt + stof(substring(argv(1), 1, -1));
+ else
+ RandomSelection_chosen_ent.cnt = drag_lastcnt = stof(argv(1));
+ }
+ return 1;
+ }
+ else
+ sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
+ break;
+ case "drag_save":
+ if(argc == 2)
+ {
+ f = fopen(argv(1), FILE_WRITE);
+ fputs(f, "cmd drag_clear\n");
+ for(e = world; (e = find(e, classname, "dragbox_box")); )
+ {
+ fputs(f, strcat("cmd dragbox_spawn ", ftos(e.cnt), " \"", vtos(e.aiment.origin), "\" \"", vtos(e.enemy.origin), "\"\n"));
+ }
+ for(e = world; (e = find(e, classname, "dragpoint")); )
+ {
+ fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
+ }
+ fclose(f);
+ return 1;
+ }
+ else
+ sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+ break;
+ case "drag_saveraceent":
+ if(argc == 2)
+ {
+ f = fopen(argv(1), FILE_WRITE);
+ for(e = world; (e = find(e, classname, "dragbox_box")); )
+ {
+ fputs(f, "{\n");
+ fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
+ fputs(f, strcat("\"origin\" \"", ftos(e.absmin_x), " ", ftos(e.absmin_y), " ", ftos(e.absmin_z), "\"\n"));
+ fputs(f, strcat("\"maxs\" \"", ftos(e.absmax_x - e.absmin_x), " ", ftos(e.absmax_y - e.absmin_y), " ", ftos(e.absmax_z - e.absmin_z), "\"\n"));
+ fputs(f, strcat("\"cnt\" \"", ftos(e.cnt), "\"\n"));
+ fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
+ fputs(f, "}\n");
+ }
+ for(e = world; (e = find(e, classname, "dragpoint")); )
+ {
+ start = '0 0 0';
+ effectnum = 0;
+ for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
+ {
+ if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
+ {
+ start = start + oldself.origin;
+ ++effectnum;
+ }
+ }
+ start *= 1 / effectnum;
+ fputs(f, "{\n");
+ fputs(f, "\"classname\" \"info_player_race\"\n");
+ fputs(f, strcat("\"angle\" \"", ftos(vectoyaw(start - e.origin)), "\"\n"));
+ fputs(f, strcat("\"origin\" \"", ftos(e.origin_x), " ", ftos(e.origin_y), " ", ftos(e.origin_z), "\"\n"));
+ if(e.cnt == -2)
+ {
+ fputs(f, "\"target\" \"checkpoint0\"\n");
+ fputs(f, "\"race_place\" \"0\"\n");
+ }
+ else if(e.cnt == -1)
+ {
+ fputs(f, "\"target\" \"checkpoint0\"\n");
+ fputs(f, "\"race_place\" \"-1\"\n");
+ }
+ else
+ {
+ fputs(f, strcat("\"target\" \"checkpoint", ftos(e.cnt), "\"\n"));
+ if(e.cnt == 0)
+ {
+ // these need race_place
+ // counting...
+ effectnum = 1;
+ for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
+ if(oldself.cnt == 0)
+ {
+ if(vlen(oldself.origin - start) < vlen(e.origin - start))
+ ++effectnum;
+ else if(vlen(oldself.origin - start) == vlen(e.origin - start) && num_for_edict(oldself) < num_for_edict(e))
+ ++effectnum;
+ }
+ fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
+ }
+ }
+ fputs(f, "}\n");
+ }
+ fclose(f);
+ return 1;
+ }
+ else
+ sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+ break;
+ case "drag_clear":
+ for(e = world; (e = find(e, classname, "dragbox_box")); )
+ remove(e);
+ for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
+ remove(e);
+ for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
+ remove(e);
+ for(e = world; (e = find(e, classname, "dragpoint")); )
+ remove(e);
+ for(e = world; (e = find(e, classname, "drag_digit")); )
+ remove(e);
+ return 1;
+ }
return 0;
}
Modified: trunk/data/qcsrc/server/cheats.qh
===================================================================
--- trunk/data/qcsrc/server/cheats.qh 2010-01-25 17:03:41 UTC (rev 8550)
+++ trunk/data/qcsrc/server/cheats.qh 2010-01-25 17:03:53 UTC (rev 8551)
@@ -1,2 +1,2 @@
float CheatImpulse(float i);
-float CheatCommand(string cmd);
+float CheatCommand(float argc);
Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc 2010-01-25 17:03:41 UTC (rev 8550)
+++ trunk/data/qcsrc/server/clientcommands.qc 2010-01-25 17:03:53 UTC (rev 8551)
@@ -158,9 +158,8 @@
void SV_ParseClientCommand(string s) {
string cmd;
- float tokens, f, effectnum;
- vector start, end;
- entity e, oldself;
+ float tokens;
+ entity e;
tokens = tokenize_console(s);
@@ -406,309 +405,7 @@
Score_NicePrint(self);
} else if(cmd == "cvar_changes") {
sprint(self, cvar_changes);
- } else if(cmd == "pointparticles") {
- if((sv_cheats || self.maycheat) && tokens == 5)
- {
- // arguments:
- // effectname
- // origin (0..1, on crosshair line)
- // velocity
- // howmany
- effectnum = particleeffectnum(argv(1));
- f = stof(argv(2));
- start = (1-f) * self.origin + f * self.cursor_trace_endpos;
- end = stov(argv(3));
- f = stof(argv(4));
- pointparticles(effectnum, start, end, f);
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
- } else if(cmd == "trailparticles") {
- if((sv_cheats || self.maycheat) && tokens == 2)
- {
- // arguments:
- // effectname
- effectnum = particleeffectnum(argv(1));
- W_SetupShot(self, FALSE, FALSE, "",0);
- traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
- trailparticles(self, effectnum, w_shotorg, trace_endpos);
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
- } else if(cmd == "make") {
- if((sv_cheats || self.maycheat) && tokens == 3)
- {
- // arguments:
- // modelname mode
- f = stof(argv(2));
- W_SetupShot(self, FALSE, FALSE, "", 0);
- traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
- if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
- {
- sprint(self, "cannot make stuff there (bad surface)\n");
- }
- else
- {
- oldself = self;
- self = spawn();
- self.model = strzone(argv(1));
- self.mdl = "rocket_explode";
- self.health = 1000;
- setorigin(self, trace_endpos);
- self.effects = EF_NOMODELFLAGS;
- if(f == 1)
- {
- self.angles = fixedvectoangles2(trace_plane_normal, v_forward);
- self.angles = AnglesTransform_Multiply(self.angles, '-90 0 0'); // so unrotated models work
- }
- spawnfunc_func_breakable();
- // now, is it valid?
- if(f == 0)
- {
- tracebox(self.origin, self.mins, self.maxs, self.origin, MOVE_NORMAL, self);
- if(trace_startsolid)
- {
- sprint(oldself, "cannot make stuff there (no space)\n");
- remove(self);
- }
- }
- self = oldself;
- }
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
- } else if(cmd == "penalty") {
- if((sv_cheats || self.maycheat) && tokens == 3)
- race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
- } else if(cmd == "dragbox_spawn") {
- if(sv_cheats || self.maycheat)
- {
- e = spawn();
- e.classname = "dragbox_box";
- e.think = DragBox_Think;
- e.nextthink = time;
- e.solid = -1; // black
- setmodel(e, "null"); // network it
- if(tokens == 4)
- e.cnt = stof(argv(1));
- else
- e.cnt = max(0, drag_lastcnt);
-
- e.aiment = spawn();
- e.aiment.classname = "dragbox_corner_1";
- e.aiment.owner = e;
- setmodel(e.aiment, "models/marker.md3");
- e.aiment.skin = 0;
- setsize(e.aiment, '0 0 0', '0 0 0');
- if(tokens == 4)
- setorigin(e.aiment, stov(argv(2)));
- else
- setorigin(e.aiment, self.cursor_trace_endpos);
-
- e.enemy = spawn();
- e.enemy.classname = "dragbox_corner_2";
- e.enemy.owner = e;
- setmodel(e.enemy, "models/marker.md3");
- e.enemy.skin = 1;
- setsize(e.enemy, '0 0 0', '0 0 0');
- end = normalize(self.cursor_trace_start - e.aiment.origin);
- end_x = (end_x > 0) * 2 - 1;
- end_y = (end_y > 0) * 2 - 1;
- end_z = (end_z > 0) * 2 - 1;
- if(tokens == 4)
- setorigin(e.enemy, stov(argv(3)));
- else
- setorigin(e.enemy, e.aiment.origin + 32 * end);
-
- e.killindicator = spawn();
- e.killindicator.classname = "drag_digit";
- e.killindicator.owner = e;
- setattachment(e.killindicator, e, "");
- setorigin(e.killindicator, '0 0 -8');
- e.killindicator.killindicator = spawn();
- e.killindicator.killindicator.classname = "drag_digit";
- e.killindicator.killindicator.owner = e;
- setattachment(e.killindicator.killindicator, e, "");
- setorigin(e.killindicator.killindicator, '0 0 8');
- }
- else
- sprint(self, "Usage: sv_cheats 1; r_showbboxes 1.5; restart; cmd dragbox_spawn\n");
- } else if(cmd == "dragpoint_spawn") {
- if(sv_cheats || self.maycheat)
- {
- e = spawn();
- e.classname = "dragpoint";
- e.think = DragBox_Think;
- e.nextthink = time;
- e.solid = 0; // nothing special
- setmodel(e, "models/marker.md3");
- setsize(e, PL_MIN, PL_MAX);
- e.skin = 2;
- if(tokens == 3)
- e.cnt = stof(argv(1));
- else
- e.cnt = drag_lastcnt;
- if(tokens == 3)
- setorigin(e, stov(argv(2)));
- else
- {
- setorigin(e, self.cursor_trace_endpos + normalize(self.cursor_trace_start - self.cursor_trace_endpos));
- move_out_of_solid(e);
- }
-
- e.killindicator = spawn();
- e.killindicator.classname = "drag_digit";
- e.killindicator.owner = e;
- setattachment(e.killindicator, e, "");
- setorigin(e.killindicator, '0 0 40');
- e.killindicator.killindicator = spawn();
- e.killindicator.killindicator.classname = "drag_digit";
- e.killindicator.killindicator.owner = e;
- setattachment(e.killindicator.killindicator, e, "");
- setorigin(e.killindicator.killindicator, '0 0 56');
- }
- else
- sprint(self, "Usage: sv_cheats 1; r_showbboxes 1.5; restart; cmd dragbox_spawn\n");
- } else if(cmd == "drag_remove") {
- if(sv_cheats || self.maycheat)
- {
- RandomSelection_Init();
- for(e = world; (e = find(e, classname, "dragbox_box")); )
- RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
- for(e = world; (e = find(e, classname, "dragpoint")); )
- RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
- if(RandomSelection_chosen_ent)
- {
- remove(RandomSelection_chosen_ent.killindicator.killindicator);
- remove(RandomSelection_chosen_ent.killindicator);
- if(RandomSelection_chosen_ent.aiment)
- remove(RandomSelection_chosen_ent.aiment);
- if(RandomSelection_chosen_ent.enemy)
- remove(RandomSelection_chosen_ent.enemy);
- remove(RandomSelection_chosen_ent);
- }
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_remove\n");
- } else if(cmd == "drag_setcnt") {
- if((sv_cheats || self.maycheat) && tokens >= 2)
- {
- RandomSelection_Init();
- for(e = world; (e = find(e, classname, "dragbox_box")); )
- RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
- for(e = world; (e = find(e, classname, "dragpoint")); )
- RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
- if(RandomSelection_chosen_ent)
- {
- if(substring(argv(1), 0, 1) == "*")
- RandomSelection_chosen_ent.cnt = drag_lastcnt = RandomSelection_chosen_ent.cnt + stof(substring(argv(1), 1, -1));
- else
- RandomSelection_chosen_ent.cnt = drag_lastcnt = stof(argv(1));
- }
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
- } else if(cmd == "drag_save") {
- if((sv_cheats || self.maycheat) && tokens >= 2)
- {
- f = fopen(argv(1), FILE_WRITE);
- fputs(f, "cmd drag_clear\n");
- for(e = world; (e = find(e, classname, "dragbox_box")); )
- {
- fputs(f, strcat("cmd dragbox_spawn ", ftos(e.cnt), " \"", vtos(e.aiment.origin), "\" \"", vtos(e.enemy.origin), "\"\n"));
- }
- for(e = world; (e = find(e, classname, "dragpoint")); )
- {
- fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
- }
- fclose(f);
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
- } else if(cmd == "drag_saveraceent") {
- if((sv_cheats || self.maycheat) && tokens >= 2)
- {
- f = fopen(argv(1), FILE_WRITE);
- for(e = world; (e = find(e, classname, "dragbox_box")); )
- {
- fputs(f, "{\n");
- fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
- fputs(f, strcat("\"origin\" \"", ftos(e.absmin_x), " ", ftos(e.absmin_y), " ", ftos(e.absmin_z), "\"\n"));
- fputs(f, strcat("\"maxs\" \"", ftos(e.absmax_x - e.absmin_x), " ", ftos(e.absmax_y - e.absmin_y), " ", ftos(e.absmax_z - e.absmin_z), "\"\n"));
- fputs(f, strcat("\"cnt\" \"", ftos(e.cnt), "\"\n"));
- fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
- fputs(f, "}\n");
- }
- for(e = world; (e = find(e, classname, "dragpoint")); )
- {
- start = '0 0 0';
- effectnum = 0;
- for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
- {
- if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
- {
- start = start + oldself.origin;
- ++effectnum;
- }
- }
- start *= 1 / effectnum;
- fputs(f, "{\n");
- fputs(f, "\"classname\" \"info_player_race\"\n");
- fputs(f, strcat("\"angle\" \"", ftos(vectoyaw(start - e.origin)), "\"\n"));
- fputs(f, strcat("\"origin\" \"", ftos(e.origin_x), " ", ftos(e.origin_y), " ", ftos(e.origin_z), "\"\n"));
- if(e.cnt == -2)
- {
- fputs(f, "\"target\" \"checkpoint0\"\n");
- fputs(f, "\"race_place\" \"0\"\n");
- }
- else if(e.cnt == -1)
- {
- fputs(f, "\"target\" \"checkpoint0\"\n");
- fputs(f, "\"race_place\" \"-1\"\n");
- }
- else
- {
- fputs(f, strcat("\"target\" \"checkpoint", ftos(e.cnt), "\"\n"));
- if(e.cnt == 0)
- {
- // these need race_place
- // counting...
- effectnum = 1;
- for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
- if(oldself.cnt == 0)
- {
- if(vlen(oldself.origin - start) < vlen(e.origin - start))
- ++effectnum;
- else if(vlen(oldself.origin - start) == vlen(e.origin - start) && num_for_edict(oldself) < num_for_edict(e))
- ++effectnum;
- }
- fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
- }
- }
- fputs(f, "}\n");
- }
- fclose(f);
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
- } else if(cmd == "drag_clear") {
- if(sv_cheats || self.maycheat)
- {
- for(e = world; (e = find(e, classname, "dragbox_box")); )
- remove(e);
- for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
- remove(e);
- for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
- remove(e);
- for(e = world; (e = find(e, classname, "dragpoint")); )
- remove(e);
- for(e = world; (e = find(e, classname, "drag_digit")); )
- remove(e);
- }
- else
- sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_clear\n");
+ } else if(CheatCommand(tokens)) {
} else {
//if(ctf_clientcommand())
// return;
More information about the nexuiz-commits
mailing list