]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cheats.qc
Impulses: migration pathway
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cheats.qc
index 502340fd99e398f35946b9e8adc0194224065efa..996058f1d4f2c75439eda161044543eb70a43b96 100644 (file)
@@ -1,17 +1,15 @@
 #include "cheats.qh"
-#include "_all.qh"
 
 #include "g_damage.qh"
 #include "race.qh"
 #include "../common/triggers/teleporters.qh"
 
-#include "mutators/mutators_include.qh"
+#include "mutators/all.qh"
 
 #include "weapons/tracing.qh"
 
 #include "../common/constants.qh"
-#include "../common/deathtypes.qh"
-#include "../common/effects.qh"
+#include "../common/deathtypes/all.qh"
 #include "../common/util.qh"
 
 #include "../common/monsters/all.qh"
 
 #include "../common/triggers/func/breakable.qh"
 
-#include "../csqcmodellib/sv_model.qh"
+#include "../lib/csqcmodel/sv_model.qh"
 
-#include "../warpzonelib/anglestransform.qh"
-#include "../warpzonelib/util_server.qh"
+#include "../lib/warpzone/anglestransform.qh"
+#include "../lib/warpzone/util_server.qh"
 
 void CopyBody(float keepvelocity);
 
@@ -65,7 +63,7 @@ void CheatShutdownClient()
 }
 
 float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
-{
+{SELFPARAM();
        // dead people cannot cheat
        if(self.deadflag != DEAD_NO)
                return 0;
@@ -73,7 +71,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;
 
@@ -115,7 +113,7 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
 
 float num_autoscreenshot;
 void info_autoscreenshot_findtarget()
-{
+{SELFPARAM();
        entity e;
        e = find(world, targetname, self.target);
        if(!e)
@@ -129,7 +127,7 @@ void info_autoscreenshot_findtarget()
        self.angles_y = a.y;
        // we leave Rick Roll alone
 }
-void spawnfunc_info_autoscreenshot()
+spawnfunc(info_autoscreenshot)
 {
        if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot)
        {
@@ -142,18 +140,17 @@ void spawnfunc_info_autoscreenshot()
 }
 
 float CheatImpulse(float i)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
        switch(i)
        {
                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;
@@ -176,7 +173,7 @@ 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:
+               case CHIMPULSE_CLONE_MOVING.impulse:
                        IS_CHEAT(i, 0, 0);
                        makevectors (self.v_angle);
                        self.velocity = self.velocity + v_forward * 300;
@@ -185,17 +182,17 @@ float CheatImpulse(float i)
                        self.velocity = self.velocity - v_forward * 300;
                        DID_CHEAT();
                        break;
-               case CHIMPULSE_CLONE_STANDING:
+               case CHIMPULSE_CLONE_STANDING.impulse:
                        IS_CHEAT(i, 0, 0);
                        CopyBody(0);
                        self.lip += 1;
                        DID_CHEAT();
                        break;
-               case CHIMPULSE_GIVE_ALL:
+               case CHIMPULSE_GIVE_ALL.impulse:
                        IS_CHEAT(i, 0, 0);
                        CheatCommand(tokenize_console("give all"));
                        break; // already counted as cheat
-               case CHIMPULSE_SPEEDRUN:
+               case CHIMPULSE_SPEEDRUN.impulse:
                        IS_CHEAT(i, 0, 0);
                        if(self.personal)
                        {
@@ -241,7 +238,7 @@ float CheatImpulse(float i)
                        else
                                sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
                        break;
-               case CHIMPULSE_TELEPORT:
+               case CHIMPULSE_TELEPORT.impulse:
                        IS_CHEAT(i, 0, 0);
                        if(self.movetype == MOVETYPE_NOCLIP)
                        {
@@ -270,7 +267,7 @@ float CheatImpulse(float i)
                        }
                        sprint(self, "Emergency teleport could not find a good location, forget it!\n");
                        break;
-               case CHIMPULSE_R00T:
+               case CHIMPULSE_R00T.impulse:
                        IS_CHEAT(i, 0, 0);
                        RandomSelection_Init();
                        FOR_EACH_PLAYER(e)
@@ -282,15 +279,15 @@ float CheatImpulse(float i)
                        else
                                e = self;
 
-                       Send_Effect("rocket_explode", e.origin, '0 0 0', 1);
-                       sound(e, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                       Send_Effect(EFFECT_ROCKET_EXPLODE, e.origin, '0 0 0', 1);
+                       sound(e, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
                        e2 = spawn();
                        setorigin(e2, e.origin);
-                       RadiusDamage(e2, self, 1000, 0, 128, world, world, 500, DEATH_CHEAT, e);
+                       RadiusDamage(e2, self, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
                        remove(e2);
 
-                       print("404 Sportsmanship not found.\n");
+                       LOG_INFO("404 Sportsmanship not found.\n");
                        DID_CHEAT();
                        break;
        }
@@ -301,13 +298,12 @@ float CheatImpulse(float i)
 void DragBox_Think();
 float drag_lastcnt;
 float CheatCommand(float argc)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
        string cmd;
        cmd = argv(0);
        switch(cmd)
        {
-               entity e;
                float effectnum, f;
                vector start, end;
                entity oldself;
@@ -326,7 +322,7 @@ float CheatCommand(float argc)
                                start = (1-f) * self.origin + f * trace_endpos;
                                end = stov(argv(3));
                                f = stof(argv(4));
-                               Send_Effect(argv(1), start, end, f);
+                               Send_Effect_(argv(1), start, end, f);
                                DID_CHEAT();
                                break;
                        }
@@ -338,10 +334,10 @@ float CheatCommand(float argc)
                        {
                                // arguments:
                                //   effectname
-                               effectnum = particleeffectnum(argv(1));
+                               effectnum = _particleeffectnum(argv(1));
                                W_SetupShot(self, false, false, "", CH_WEAPON_A, 0);
                                traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
-                               trailparticles(self, effectnum, w_shotorg, trace_endpos);
+                               __trailparticles(self, effectnum, w_shotorg, trace_endpos);
                                DID_CHEAT();
                                break;
                        }
@@ -362,7 +358,7 @@ float CheatCommand(float argc)
                                }
                                else
                                {
-                                       e = spawn();
+                                       entity e = spawn();
                                        e.model = strzone(argv(1));
                                        e.mdl = "rocket_explode";
                                        e.health = 1000;
@@ -373,10 +369,7 @@ float CheatCommand(float argc)
                                                e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
                                                e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work
                                        }
-                                       oldself = self;
-                                       self = e;
-                                       spawnfunc_func_breakable();
-                                       self = oldself;
+                                       WITH(entity, self, e, spawnfunc_func_breakable(e));
                                        // now, is it valid?
                                        if(f == 0)
                                        {
@@ -406,23 +399,21 @@ float CheatCommand(float argc)
                        }
                        sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
                        break;
-               case "dragbox_spawn":
+               case "dragbox_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       e = spawn();
-                       e.classname = "dragbox_box";
+                       entity e = new(dragbox_box);
                        e.think = DragBox_Think;
                        e.nextthink = time;
                        e.solid = -1; // black
-                       setmodel(e, "null"); // network it
+                       setmodel(e, MDL_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 = new(dragbox_corner_1);
                        e.aiment.owner = e;
-                       setmodel(e.aiment, "models/marker.md3");
+                       setmodel(e.aiment, MDL_MARKER);
                        e.aiment.skin = 0;
                        setsize(e.aiment, '0 0 0', '0 0 0');
                        if(argc == 4)
@@ -433,10 +424,9 @@ 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, "models/marker.md3");
+                       setmodel(e.enemy, MDL_MARKER);
                        e.enemy.skin = 1;
                        setsize(e.enemy, '0 0 0', '0 0 0');
                        end = normalize(self.origin + self.view_ofs - e.aiment.origin);
@@ -448,26 +438,24 @@ 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');
                        DID_CHEAT();
                        break;
-               case "dragpoint_spawn":
+               }
+               case "dragpoint_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       e = spawn();
-                       e.classname = "dragpoint";
+                       entity e = new(dragpoint);
                        e.think = DragBox_Think;
                        e.nextthink = time;
                        e.solid = 0; // nothing special
-                       setmodel(e, "models/marker.md3");
+                       setmodel(e, MDL_MARKER);
                        setsize(e, PL_MIN, PL_MAX);
                        e.skin = 2;
                        if(argc == 3)
@@ -483,25 +471,24 @@ 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');
                        DID_CHEAT();
                        break;
+               }
                case "drag_remove":
                        IS_CHEAT(0, argc, 0);
                        RandomSelection_Init();
                        crosshair_trace(self);
-                       for(e = world; (e = find(e, classname, "dragbox_box")); )
+                       for(entity 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 - trace_endpos));
-                       for(e = world; (e = find(e, classname, "dragpoint")); )
+                       for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        if(RandomSelection_chosen_ent)
                        {
@@ -521,9 +508,9 @@ float CheatCommand(float argc)
                        {
                                RandomSelection_Init();
                                crosshair_trace(self);
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity 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 - trace_endpos));
-                               for(e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                        RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                if(RandomSelection_chosen_ent)
                                {
@@ -543,11 +530,11 @@ float CheatCommand(float argc)
                        {
                                f = fopen(argv(1), FILE_WRITE);
                                fputs(f, "cmd drag_clear\n");
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity 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")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                {
                                        fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
                                }
@@ -562,7 +549,7 @@ float CheatCommand(float argc)
                        if(argc == 2)
                        {
                                f = fopen(argv(1), FILE_WRITE);
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                {
                                        fputs(f, "{\n");
                                        fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
@@ -572,7 +559,7 @@ float CheatCommand(float argc)
                                        fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
                                        fputs(f, "}\n");
                                }
-                               for(e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                {
                                        start = '0 0 0';
                                        effectnum = 0;
@@ -628,15 +615,15 @@ float CheatCommand(float argc)
                        break;
                case "drag_clear":
                        IS_CHEAT(0, argc, 0);
-                       for(e = world; (e = find(e, classname, "dragbox_box")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_corner_1")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_corner_2")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragpoint")); )
+                       for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "drag_digit")); )
+                       for(entity e = world; (e = find(e, classname, "drag_digit")); )
                                remove(e);
                        DID_CHEAT();
                        break;
@@ -697,43 +684,37 @@ float CheatCommand(float argc)
                        break;
                case "usetarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(spawn());
                        self.target = argv(1);
-                       activator = e;
+                       activator = this;
                        SUB_UseTargets();
                        remove(self);
-                       self = e;
+                       setself(this);
                        DID_CHEAT();
                        break;
                case "killtarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(spawn());
                        self.killtarget = argv(1);
-                       activator = e;
+                       activator = this;
                        SUB_UseTargets();
                        remove(self);
-                       self = e;
+                       setself(this);
                        DID_CHEAT();
                        break;
                case "teleporttotarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(new(cheattriggerteleport));
                        setorigin(self, self.origin);
-                       self.classname = "cheattriggerteleport";
                        self.target = argv(1);
                        teleport_findtarget();
                        if(!wasfreed(self))
                        {
-                               Simple_TeleportPlayer(self, e);
+                               Simple_TeleportPlayer(self, this);
                                remove(self);
-                               self = e;
                                DID_CHEAT();
                        }
-                       else
-                               self = e;
+                       setself(this);
                        break;
        }
 
@@ -755,7 +736,7 @@ void Drag_MoveDrag(entity from, entity to);
 .entity dragentity;
 
 float CheatFrame()
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
 
        // Dragging can be used as either a cheat, or a function for some objects. If sv_cheats is active,
@@ -799,7 +780,7 @@ float CheatFrame()
 .float dragmovetype;
 
 float Drag(float force_allow_pick, float ischeat)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
 
        // returns true when an entity has been picked up
@@ -1033,7 +1014,14 @@ void Drag_Update(entity dragger)
 
        draggee.ltime = max(servertime + serverframetime, draggee.ltime); // fixes func_train breakage
 
-       te_lightning1(dragger, dragger.origin + dragger.view_ofs, curorigin);
+       vector vecs = '0 0 0';
+       .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;
+
+       te_lightning1(draggee, dragger.origin + dragger.view_ofs + dv, curorigin);
 }
 
 float Drag_CanDrag(entity dragger)
@@ -1069,7 +1057,7 @@ void Drag_MoveDrag(entity from, entity to)
 }
 
 void DragBox_Think()
-{
+{SELFPARAM();
        if(self.aiment && self.enemy)
        {
                self.origin_x = (self.aiment.origin.x + self.enemy.origin.x) * 0.5;
@@ -1085,19 +1073,19 @@ void DragBox_Think()
        if(self.cnt == -1) // actually race_place -1
        {
                // show "10 10" for qualifying spawns
-               setmodel(self.killindicator, "models/sprites/10.spr32");
-               setmodel(self.killindicator.killindicator, "models/sprites/10.spr32");
+               setmodel(self.killindicator, MDL_NUM(10));
+               setmodel(self.killindicator.killindicator, MDL_NUM(10));
        }
        else if(self.cnt == -2) // actually race_place 0
        {
                // show "10 0" for loser spawns
-               setmodel(self.killindicator, "models/sprites/10.spr32");
-               setmodel(self.killindicator.killindicator, "models/sprites/0.spr32");
+               setmodel(self.killindicator, MDL_NUM(10));
+               setmodel(self.killindicator.killindicator, MDL_NUM(0));
        }
        else
        {
-               setmodel(self.killindicator, strcat("models/sprites/", ftos(self.cnt % 10), ".spr32"));
-               setmodel(self.killindicator.killindicator, strcat("models/sprites/", ftos(floor(self.cnt / 10)), ".spr32"));
+               setmodel(self.killindicator, MDL_NUM(self.cnt % 10));
+               setmodel(self.killindicator.killindicator, MDL_NUM(floor(self.cnt / 10)));
        }
 
        self.nextthink = time;