]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cheats.qc
More loops
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cheats.qc
index dc6d63b0c863710396bb092f24dbf8211b428bcf..2a8e5d57135532cdda13eccecfa1606b2c522d3c 100644 (file)
@@ -29,12 +29,11 @@ void CopyBody(float keepvelocity);
 
 #ifdef NOCHEATS
 
-float CheatImpulse(float i) { return 0; }
+float CheatImpulse(int imp) { return 0; }
 float CheatCommand(float argc) { return 0; }
 float CheatFrame() { return 0; }
 void CheatInit() { cheatcount_total = world.cheatcount; }
 void CheatShutdown() { }
-void CheatInitClient() { }
 void CheatShutdownClient() { }
 void Drag_MoveDrag(entity from, entity to) { }
 
@@ -54,10 +53,6 @@ void CheatShutdown()
 {
 }
 
-void CheatInitClient()
-{
-}
-
 void CheatShutdownClient()
 {
 }
@@ -71,7 +66,7 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
                return 0;
 
        // sv_clones
-       if(i == CHIMPULSE_CLONE_MOVING || i == CHIMPULSE_CLONE_STANDING)
+       if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse)
                if(self.lip < sv_clones)
                        return 1;
 
@@ -139,19 +134,18 @@ spawnfunc(info_autoscreenshot)
        // this one just has to exist
 }
 
-float CheatImpulse(float i)
+float CheatImpulse(int imp)
 {SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
-       switch(i)
+       switch(imp)
        {
                entity e, e2;
 
-               case CHIMPULSE_SPEEDRUN_INIT: // deploy personal waypoint
+               case CHIMPULSE_SPEEDRUN_INIT.impulse: // deploy personal waypoint
                        // shared with regular waypoint init, so this is not a cheat by itself
                        if(!self.personal)
                        {
-                               self.personal = spawn();
-                               self.personal.classname = "personal_wp";
+                               self.personal = new(personal_wp);
                        }
                        self.personal.origin = self.origin;
                        self.personal.v_angle = self.v_angle;
@@ -174,8 +168,8 @@ float CheatImpulse(float i)
                        self.personal.invincible_finished = self.invincible_finished;
                        self.personal.teleport_time = time;
                        break; // this part itself doesn't cheat, so let's not count this
-               case CHIMPULSE_CLONE_MOVING:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_CLONE_MOVING.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        makevectors (self.v_angle);
                        self.velocity = self.velocity + v_forward * 300;
                        CopyBody(1);
@@ -183,18 +177,18 @@ float CheatImpulse(float i)
                        self.velocity = self.velocity - v_forward * 300;
                        DID_CHEAT();
                        break;
-               case CHIMPULSE_CLONE_STANDING:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_CLONE_STANDING.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        CopyBody(0);
                        self.lip += 1;
                        DID_CHEAT();
                        break;
-               case CHIMPULSE_GIVE_ALL:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_GIVE_ALL.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        CheatCommand(tokenize_console("give all"));
                        break; // already counted as cheat
-               case CHIMPULSE_SPEEDRUN:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_SPEEDRUN.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        if(self.personal)
                        {
                                self.speedrunning = true;
@@ -239,8 +233,8 @@ float CheatImpulse(float i)
                        else
                                sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
                        break;
-               case CHIMPULSE_TELEPORT:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_TELEPORT.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        if(self.movetype == MOVETYPE_NOCLIP)
                        {
                                e = find(world, classname, "info_autoscreenshot");
@@ -268,13 +262,10 @@ float CheatImpulse(float i)
                        }
                        sprint(self, "Emergency teleport could not find a good location, forget it!\n");
                        break;
-               case CHIMPULSE_R00T:
-                       IS_CHEAT(i, 0, 0);
+               case CHIMPULSE_R00T.impulse:
+                       IS_CHEAT(imp, 0, 0);
                        RandomSelection_Init();
-                       FOR_EACH_PLAYER(e)
-                               if(e.deadflag == DEAD_NO)
-                                       if(DIFF_TEAM(e, self))
-                                               RandomSelection_Add(e, 0, string_null, 1, 1);
+                       FOREACH_CLIENT(IS_PLAYER(it) && it.deadflag == DEAD_NO && DIFF_TEAM(it, self), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
                        if(RandomSelection_chosen_ent)
                                e = RandomSelection_chosen_ent;
                        else
@@ -402,8 +393,7 @@ float CheatCommand(float argc)
                        break;
                case "dragbox_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       entity e = spawn();
-                       e.classname = "dragbox_box";
+                       entity e = new(dragbox_box);
                        e.think = DragBox_Think;
                        e.nextthink = time;
                        e.solid = -1; // black
@@ -413,8 +403,7 @@ float CheatCommand(float argc)
                        else
                                e.cnt = max(0, drag_lastcnt);
 
-                       e.aiment = spawn();
-                       e.aiment.classname = "dragbox_corner_1";
+                       e.aiment = new(dragbox_corner_1);
                        e.aiment.owner = e;
                        setmodel(e.aiment, MDL_MARKER);
                        e.aiment.skin = 0;
@@ -427,8 +416,7 @@ float CheatCommand(float argc)
                                setorigin(e.aiment, trace_endpos);
                        }
 
-                       e.enemy = spawn();
-                       e.enemy.classname = "dragbox_corner_2";
+                       e.enemy = new(dragbox_corner_2);
                        e.enemy.owner = e;
                        setmodel(e.enemy, MDL_MARKER);
                        e.enemy.skin = 1;
@@ -442,13 +430,11 @@ float CheatCommand(float argc)
                        else
                                setorigin(e.enemy, e.aiment.origin + 32 * end);
 
-                       e.killindicator = spawn();
-                       e.killindicator.classname = "drag_digit";
+                       e.killindicator = new(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 = new(drag_digit);
                        e.killindicator.killindicator.owner = e;
                        setattachment(e.killindicator.killindicator, e, "");
                        setorigin(e.killindicator.killindicator, '0 0 8');
@@ -457,8 +443,7 @@ float CheatCommand(float argc)
                }
                case "dragpoint_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       entity e = spawn();
-                       e.classname = "dragpoint";
+                       entity e = new(dragpoint);
                        e.think = DragBox_Think;
                        e.nextthink = time;
                        e.solid = 0; // nothing special
@@ -478,13 +463,11 @@ float CheatCommand(float argc)
                                move_out_of_solid(e);
                        }
 
-                       e.killindicator = spawn();
-                       e.killindicator.classname = "drag_digit";
+                       e.killindicator = new(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 = new(drag_digit);
                        e.killindicator.killindicator.owner = e;
                        setattachment(e.killindicator.killindicator, e, "");
                        setorigin(e.killindicator.killindicator, '0 0 56');
@@ -608,7 +591,7 @@ float CheatCommand(float argc)
                                                        {
                                                                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))
+                                                               else if(vlen(oldself.origin - start) == vlen(e.origin - start) && etof(oldself) < etof(e))
                                                                        ++effectnum;
                                                        }
                                                        fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
@@ -713,9 +696,8 @@ float CheatCommand(float argc)
                        break;
                case "teleporttotarget":
                        IS_CHEAT(0, argc, 0);
-                       setself(spawn());
+                       setself(new(cheattriggerteleport));
                        setorigin(self, self.origin);
-                       self.classname = "cheattriggerteleport";
                        self.target = argv(1);
                        teleport_findtarget();
                        if(!wasfreed(self))
@@ -1025,9 +1007,9 @@ void Drag_Update(entity dragger)
        draggee.ltime = max(servertime + serverframetime, draggee.ltime); // fixes func_train breakage
 
        vector vecs = '0 0 0';
-       int slot = 0; // TODO: unhardcode
-       if(dragger.weaponentity[slot].movedir_x > 0)
-               vecs = dragger.weaponentity[slot].movedir;
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       if(dragger.(weaponentity).movedir.x > 0)
+               vecs = dragger.(weaponentity).movedir;
 
        vector dv = v_right * -vecs_y + v_up * vecs_z;
 
@@ -1077,7 +1059,8 @@ void DragBox_Think()
                self.maxs_y = fabs(self.aiment.origin.y - self.enemy.origin.y) * 0.5;
                self.maxs_z = fabs(self.aiment.origin.z - self.enemy.origin.z) * 0.5;
                self.mins = -1 * self.maxs;
-               setorigin(self, self.origin); setsize(self, self.mins, self.maxs); // link edict
+               setorigin(self, self.origin);
+               setsize(self, self.mins, self.maxs); // link edict
        }
 
        if(self.cnt == -1) // actually race_place -1