]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cheats.qc
Merge branch 'master' into Lyberta/TeamplayOverhaul
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cheats.qc
index 94816a1a77d9606f33b8cb5a90a7131425ca2502..04172b5eb2b59d74de854c3c1d440ad4c5f7827a 100644 (file)
@@ -1,10 +1,16 @@
 #include "cheats.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
+#include <server/resources.qh>
+
 #include "g_damage.qh"
+#include "player.qh"
 #include "race.qh"
-#include "../common/triggers/teleporters.qh"
+#include "../common/mapobjects/teleporters.qh"
 
-#include "mutators/all.qh"
+#include <server/mutators/_mod.qh>
 
 #include "weapons/tracing.qh"
 
 
 #include <common/physics/player.qh>
 
-#include "../common/monsters/all.qh"
+#include "../common/monsters/_mod.qh"
 
-#include "../common/weapons/all.qh"
+#include <common/weapons/_all.qh>
 
-#include "../common/triggers/subs.qh"
+#include "../common/mapobjects/subs.qh"
+#include <common/mapobjects/triggers.qh>
 
-#include "../common/triggers/func/breakable.qh"
+#include "../common/mapobjects/func/breakable.qh"
 
 #include "../lib/csqcmodel/sv_model.qh"
 
 #include "../lib/warpzone/anglestransform.qh"
 #include "../lib/warpzone/util_server.qh"
 
-void CopyBody(entity this, float keepvelocity);
-
 #ifdef NOCHEATS
 
 float CheatImpulse(entity this, int imp) { return 0; }
@@ -77,13 +82,13 @@ float CheatsAllowed(entity this, float i, float argc, float fr) // the cheat get
 
        // if we get here, player is not allowed to cheat. Log it.
        if(i)
-               bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", this.netname, i);
+               bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", playername(this, false), i);
        else if(argc)
-               bprintf("Player %s^7 tried to use cheat '%s'\n", this.netname, argv(0));
+               bprintf("Player %s^7 tried to use cheat '%s'\n", playername(this, false), argv(0));
        else if(fr)
-               bprintf("Player %s^7 tried to use cheat frame %d\n", this.netname, fr);
+               bprintf("Player %s^7 tried to use cheat frame %d\n", playername(this, false), fr);
        else
-               bprintf("Player %s^7 tried to use an unknown cheat\n", this.netname);
+               bprintf("Player %s^7 tried to use an unknown cheat\n", playername(this, false));
 
        return 0;
 }
@@ -107,10 +112,10 @@ float num_autoscreenshot;
 void info_autoscreenshot_findtarget(entity this)
 {
        entity e;
-       e = find(world, targetname, this.target);
+       e = find(NULL, targetname, this.target);
        if(!e)
        {
-               objerror("Missing target. FAIL!");
+               objerror(this, "Missing target. FAIL!");
                return;
        }
        vector a = vectoangles(e.origin - this.origin);
@@ -123,7 +128,7 @@ spawnfunc(info_autoscreenshot)
 {
        if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot)
        {
-               objerror("Too many info_autoscreenshot entitites. FAIL!");
+               objerror(this, "Too many info_autoscreenshot entitites. FAIL!");
                return;
        }
        if(this.target != "")
@@ -147,15 +152,15 @@ float CheatImpulse(entity this, int imp)
                        this.personal.origin = this.origin;
                        this.personal.v_angle = this.v_angle;
                        this.personal.velocity = this.velocity;
-                       this.personal.ammo_rockets = this.ammo_rockets;
-                       this.personal.ammo_nails = this.ammo_nails;
-                       this.personal.ammo_cells = this.ammo_cells;
-                       this.personal.ammo_plasma = this.ammo_plasma;
-                       this.personal.ammo_shells = this.ammo_shells;
-                       this.personal.ammo_fuel = this.ammo_fuel;
-                       this.personal.health = this.health;
-                       this.personal.armorvalue = this.armorvalue;
-                       this.personal.weapons = this.weapons;
+                       SetResourceAmount(this.personal, RESOURCE_ROCKETS, GetResourceAmount(this, RESOURCE_ROCKETS));
+                       SetResourceAmount(this.personal, RESOURCE_BULLETS, GetResourceAmount(this, RESOURCE_BULLETS));
+                       SetResourceAmount(this.personal, RESOURCE_CELLS, GetResourceAmount(this, RESOURCE_CELLS));
+                       SetResourceAmount(this.personal, RESOURCE_PLASMA, GetResourceAmount(this, RESOURCE_PLASMA));
+                       SetResourceAmount(this.personal, RESOURCE_SHELLS, GetResourceAmount(this, RESOURCE_SHELLS));
+                       SetResourceAmount(this.personal, RESOURCE_FUEL, GetResourceAmount(this, RESOURCE_FUEL));
+                       SetResourceAmount(this.personal, RESOURCE_HEALTH, max(1, GetResourceAmount(this, RESOURCE_HEALTH)));
+                       SetResourceAmount(this.personal, RESOURCE_ARMOR, GetResourceAmount(this, RESOURCE_ARMOR));
+                       STAT(WEAPONS, this.personal) = STAT(WEAPONS, this);
                        this.personal.items = this.items;
                        this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
                        this.personal.pauserothealth_finished = this.pauserothealth_finished;
@@ -164,7 +169,7 @@ float CheatImpulse(entity this, int imp)
                        this.personal.strength_finished = this.strength_finished;
                        this.personal.invincible_finished = this.invincible_finished;
                        this.personal.teleport_time = time;
-                       break; // this part itthis doesn't cheat, so let's not count this
+                       break; // this part itself doesn't cheat, so let's not count this
                case CHIMPULSE_CLONE_MOVING.impulse:
                        IS_CHEAT(this, imp, 0, 0);
                        makevectors (this.v_angle);
@@ -185,7 +190,8 @@ float CheatImpulse(entity this, int imp)
                        CheatCommand(this, tokenize_console("give all"));
                        break; // already counted as cheat
                case CHIMPULSE_SPEEDRUN.impulse:
-                       IS_CHEAT(this, imp, 0, 0);
+                       if(!autocvar_g_allow_checkpoints)
+                               IS_CHEAT(this, imp, 0, 0);
                        if(this.personal)
                        {
                                this.speedrunning = true;
@@ -205,15 +211,15 @@ float CheatImpulse(entity this, int imp)
                                        MUTATOR_CALLHOOK(AbortSpeedrun, this);
                                }
 
-                               this.ammo_rockets = this.personal.ammo_rockets;
-                               this.ammo_nails = this.personal.ammo_nails;
-                               this.ammo_cells = this.personal.ammo_cells;
-                               this.ammo_plasma = this.personal.ammo_plasma;
-                               this.ammo_shells = this.personal.ammo_shells;
-                               this.ammo_fuel = this.personal.ammo_fuel;
-                               this.health = this.personal.health;
-                               this.armorvalue = this.personal.armorvalue;
-                               this.weapons = this.personal.weapons;
+                               SetResourceAmount(this, RESOURCE_ROCKETS, GetResourceAmount(this.personal, RESOURCE_ROCKETS));
+                               SetResourceAmount(this, RESOURCE_BULLETS, GetResourceAmount(this.personal, RESOURCE_BULLETS));
+                               SetResourceAmount(this, RESOURCE_CELLS, GetResourceAmount(this.personal, RESOURCE_CELLS));
+                               SetResourceAmount(this, RESOURCE_PLASMA, GetResourceAmount(this.personal, RESOURCE_PLASMA));
+                               SetResourceAmount(this, RESOURCE_SHELLS, GetResourceAmount(this.personal, RESOURCE_SHELLS));
+                               SetResourceAmount(this, RESOURCE_FUEL, GetResourceAmount(this.personal, RESOURCE_FUEL));
+                               SetResourceAmount(this, RESOURCE_HEALTH, GetResourceAmount(this.personal, RESOURCE_HEALTH));
+                               SetResourceAmount(this, RESOURCE_ARMOR, GetResourceAmount(this.personal, RESOURCE_ARMOR));
+                               STAT(WEAPONS, this) = STAT(WEAPONS, this.personal);
                                this.items = this.personal.items;
                                this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
                                this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
@@ -222,7 +228,8 @@ float CheatImpulse(entity this, int imp)
                                this.strength_finished = time + this.personal.strength_finished - this.personal.teleport_time;
                                this.invincible_finished = time + this.personal.invincible_finished - this.personal.teleport_time;
 
-                               DID_CHEAT();
+                               if(!autocvar_g_allow_checkpoints)
+                                       DID_CHEAT();
                                break;
                        }
                        if(IS_DEAD(this))
@@ -232,15 +239,15 @@ float CheatImpulse(entity this, int imp)
                        break;
                case CHIMPULSE_TELEPORT.impulse:
                        IS_CHEAT(this, imp, 0, 0);
-                       if(this.movetype == MOVETYPE_NOCLIP)
+                       if(this.move_movetype == MOVETYPE_NOCLIP)
                        {
-                               e = find(world, classname, "info_autoscreenshot");
+                               e = find(NULL, classname, "info_autoscreenshot");
                                if(e)
                                {
                                        sprint(this, "Emergency teleport used info_autoscreenshot location\n");
                                        setorigin(this, e.origin);
                                        this.angles = e.angles;
-                                       remove(e);
+                                       delete(e);
                                        // should we? this.angles_x = -this.angles_x;
                                        this.fixangle = true;
                                        this.velocity = '0 0 0';
@@ -262,7 +269,7 @@ float CheatImpulse(entity this, int imp)
                case CHIMPULSE_R00T.impulse:
                        IS_CHEAT(this, imp, 0, 0);
                        RandomSelection_Init();
-                       FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
+                       FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), { RandomSelection_AddEnt(it, 1, 1); });
                        if(RandomSelection_chosen_ent)
                                e = RandomSelection_chosen_ent;
                        else
@@ -273,10 +280,10 @@ float CheatImpulse(entity this, int imp)
 
                        e2 = spawn();
                        setorigin(e2, e.origin);
-                       RadiusDamage(e2, this, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
-                       remove(e2);
+                       RadiusDamage(e2, this, 1000, 0, 128, NULL, NULL, 500, DEATH_CHEAT.m_id, DMG_NOWEP, e);
+                       delete(e2);
 
-                       LOG_INFO("404 Sportsmanship not found.\n");
+                       LOG_INFO("404 Sportsmanship not found.");
                        DID_CHEAT();
                        break;
        }
@@ -284,7 +291,6 @@ float CheatImpulse(entity this, int imp)
        END_CHEAT_FUNCTION();
 }
 
-void DragBox_Think(entity this);
 float drag_lastcnt;
 float CheatCommand(entity this, int argc)
 {
@@ -295,7 +301,6 @@ float CheatCommand(entity this, int argc)
        {
                float effectnum, f;
                vector start, end;
-               entity oldself;
 
                case "pointparticles":
                        IS_CHEAT(this, 0, argc, 0);
@@ -324,8 +329,8 @@ float CheatCommand(entity this, int argc)
                                // arguments:
                                //   effectname
                                effectnum = _particleeffectnum(argv(1));
-                               W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
-                               traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this);
+                               W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0, 0);
+                               traceline(w_shotorg, w_shotorg + w_shotdir * max_shot_distance, MOVE_NORMAL, this);
                                __trailparticles(this, effectnum, w_shotorg, trace_endpos);
                                DID_CHEAT();
                                break;
@@ -339,7 +344,7 @@ float CheatCommand(entity this, int argc)
                                // arguments:
                                //   modelname mode
                                f = stof(argv(2));
-                               W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
+                               W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0, 0);
                                traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, this);
                                if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
                                {
@@ -350,7 +355,7 @@ float CheatCommand(entity this, int argc)
                                        entity e = spawn();
                                        e.model = strzone(argv(1));
                                        e.mdl = "rocket_explode";
-                                       e.health = 1000;
+                                       SetResourceAmountExplicit(e, RESOURCE_HEALTH, 1000);
                                        setorigin(e, trace_endpos);
                                        e.effects = EF_NOMODELFLAGS;
                                        if(f == 1)
@@ -358,14 +363,14 @@ float CheatCommand(entity this, int argc)
                                                e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
                                                e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work
                                        }
-                                       WITHSELF(e, spawnfunc_func_breakable(e));
+                                       spawnfunc_func_breakable(e);
                                        // now, is it valid?
                                        if(f == 0)
                                        {
                                                tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_NORMAL, e);
                                                if(trace_startsolid)
                                                {
-                                                       remove(e);
+                                                       delete(e);
                                                        sprint(this, "cannot make stuff there (no space)\n");
                                                }
                                                else
@@ -445,7 +450,7 @@ float CheatCommand(entity this, int argc)
                        e.nextthink = time;
                        e.solid = 0; // nothing special
                        setmodel(e, MDL_MARKER);
-                       setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
+                       setsize(e, STAT(PL_MIN, this), STAT(PL_MAX, this));
                        e.skin = 2;
                        if(argc == 3)
                                e.cnt = stof(argv(1));
@@ -475,19 +480,19 @@ float CheatCommand(entity this, int argc)
                        IS_CHEAT(this, 0, argc, 0);
                        RandomSelection_Init();
                        crosshair_trace(this);
-                       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(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));
+                       for(entity e = NULL; (e = find(e, classname, "dragbox_box")); )
+                               RandomSelection_AddEnt(e, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
+                       for(entity e = NULL; (e = find(e, classname, "dragpoint")); )
+                               RandomSelection_AddEnt(e, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        if(RandomSelection_chosen_ent)
                        {
-                               remove(RandomSelection_chosen_ent.killindicator.killindicator);
-                               remove(RandomSelection_chosen_ent.killindicator);
+                               delete(RandomSelection_chosen_ent.killindicator.killindicator);
+                               delete(RandomSelection_chosen_ent.killindicator);
                                if(RandomSelection_chosen_ent.aiment)
-                                       remove(RandomSelection_chosen_ent.aiment);
+                                       delete(RandomSelection_chosen_ent.aiment);
                                if(RandomSelection_chosen_ent.enemy)
-                                       remove(RandomSelection_chosen_ent.enemy);
-                               remove(RandomSelection_chosen_ent);
+                                       delete(RandomSelection_chosen_ent.enemy);
+                               delete(RandomSelection_chosen_ent);
                        }
                        DID_CHEAT();
                        break;
@@ -497,10 +502,10 @@ float CheatCommand(entity this, int argc)
                        {
                                RandomSelection_Init();
                                crosshair_trace(this);
-                               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(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));
+                               for(entity e = NULL; (e = find(e, classname, "dragbox_box")); )
+                                       RandomSelection_AddEnt(e, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
+                               for(entity e = NULL; (e = find(e, classname, "dragpoint")); )
+                                       RandomSelection_AddEnt(e, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                if(RandomSelection_chosen_ent)
                                {
                                        if(substring(argv(1), 0, 1) == "*")
@@ -519,11 +524,11 @@ float CheatCommand(entity this, int argc)
                        {
                                f = fopen(argv(1), FILE_WRITE);
                                fputs(f, "cmd drag_clear\n");
-                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = NULL; (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(entity e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = NULL; (e = find(e, classname, "dragpoint")); )
                                {
                                        fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
                                }
@@ -538,7 +543,7 @@ float CheatCommand(entity this, int argc)
                        if(argc == 2)
                        {
                                f = fopen(argv(1), FILE_WRITE);
-                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = NULL; (e = find(e, classname, "dragbox_box")); )
                                {
                                        fputs(f, "{\n");
                                        fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
@@ -548,15 +553,15 @@ float CheatCommand(entity this, int argc)
                                        fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
                                        fputs(f, "}\n");
                                }
-                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = NULL; (e = find(e, classname, "dragpoint")); )
                                {
                                        start = '0 0 0';
                                        effectnum = 0;
-                                       for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
+                                       for(entity ent = NULL; (ent = find(ent, classname, "dragbox_box")); )
                                        {
-                                               if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
+                                               if(e.cnt <= 0 && ent.cnt == 0 || e.cnt == ent.cnt)
                                                {
-                                                       start = start + oldself.origin;
+                                                       start = start + ent.origin;
                                                        ++effectnum;
                                                }
                                        }
@@ -583,12 +588,12 @@ float CheatCommand(entity this, int argc)
                                                        // these need race_place
                                                        // counting...
                                                        effectnum = 1;
-                                                       for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
-                                                       if(oldself.cnt == 0)
+                                                       for(entity ent = NULL; (ent = find(ent, classname, "dragpoint")); )
+                                                       if(ent.cnt == 0)
                                                        {
-                                                               if(vlen(oldself.origin - start) < vlen(e.origin - start))
+                                                               if(vlen2(ent.origin - start) < vlen2(e.origin - start))
                                                                        ++effectnum;
-                                                               else if(vlen(oldself.origin - start) == vlen(e.origin - start) && etof(oldself) < etof(e))
+                                                               else if(vlen2(ent.origin - start) == vlen2(e.origin - start) && etof(ent) < etof(e))
                                                                        ++effectnum;
                                                        }
                                                        fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
@@ -604,16 +609,16 @@ float CheatCommand(entity this, int argc)
                        break;
                case "drag_clear":
                        IS_CHEAT(this, 0, argc, 0);
-                       for(entity e = world; (e = find(e, classname, "dragbox_box")); )
-                               remove(e);
-                       for(entity e = world; (e = find(e, classname, "dragbox_corner_1")); )
-                               remove(e);
-                       for(entity e = world; (e = find(e, classname, "dragbox_corner_2")); )
-                               remove(e);
-                       for(entity e = world; (e = find(e, classname, "dragpoint")); )
-                               remove(e);
-                       for(entity e = world; (e = find(e, classname, "drag_digit")); )
-                               remove(e);
+                       for(entity e = NULL; (e = find(e, classname, "dragbox_box")); )
+                               delete(e);
+                       for(entity e = NULL; (e = find(e, classname, "dragbox_corner_1")); )
+                               delete(e);
+                       for(entity e = NULL; (e = find(e, classname, "dragbox_corner_2")); )
+                               delete(e);
+                       for(entity e = NULL; (e = find(e, classname, "dragpoint")); )
+                               delete(e);
+                       for(entity e = NULL; (e = find(e, classname, "drag_digit")); )
+                               delete(e);
                        DID_CHEAT();
                        break;
                case "god":
@@ -640,29 +645,29 @@ float CheatCommand(entity this, int argc)
                        break;
                case "noclip":
                        IS_CHEAT(this, 0, argc, 0);
-                       if(this.movetype != MOVETYPE_NOCLIP)
+                       if(this.move_movetype != MOVETYPE_NOCLIP)
                        {
-                               this.movetype = MOVETYPE_NOCLIP;
+                               set_movetype(this, MOVETYPE_NOCLIP);
                                sprint(this, "noclip ON\n");
                                DID_CHEAT();
                        }
                        else
                        {
-                               this.movetype = MOVETYPE_WALK;
+                               set_movetype(this, MOVETYPE_WALK);
                                sprint(this, "noclip OFF\n");
                        }
                        break;
                case "fly":
                        IS_CHEAT(this, 0, argc, 0);
-                       if(this.movetype != MOVETYPE_FLY)
+                       if(this.move_movetype != MOVETYPE_FLY)
                        {
-                               this.movetype = MOVETYPE_FLY;
+                               set_movetype(this, MOVETYPE_FLY);
                                sprint(this, "flymode ON\n");
                                DID_CHEAT();
                        }
                        else
                        {
-                               this.movetype = MOVETYPE_WALK;
+                               set_movetype(this, MOVETYPE_WALK);
                                sprint(this, "flymode OFF\n");
                        }
                        break;
@@ -676,7 +681,7 @@ float CheatCommand(entity this, int argc)
                        entity e = spawn();
                        e.target = argv(1);
                        SUB_UseTargets(e, this, NULL);
-                       remove(e);
+                       delete(e);
                        DID_CHEAT();
                        break;
                case "killtarget":
@@ -684,7 +689,7 @@ float CheatCommand(entity this, int argc)
                        entity e2 = spawn();
                        e2.killtarget = argv(1);
                        SUB_UseTargets(e2, this, NULL);
-                       remove(e2);
+                       delete(e2);
                        DID_CHEAT();
                        break;
                case "teleporttotarget":
@@ -696,7 +701,7 @@ float CheatCommand(entity this, int argc)
                        if(!wasfreed(ent))
                        {
                                Simple_TeleportPlayer(ent, this);
-                               remove(ent);
+                               delete(ent);
                                DID_CHEAT();
                        }
                        break;
@@ -705,18 +710,6 @@ float CheatCommand(entity this, int argc)
        END_CHEAT_FUNCTION();
 }
 
-float Drag(entity this, float force_allow_pick, float ischeat);
-void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
-void Drag_Finish(entity dragger);
-float Drag_IsDraggable(entity draggee);
-float Drag_MayChangeAngles(entity draggee);
-void Drag_MoveForward(entity dragger);
-void Drag_SetSpeed(entity dragger, float s);
-void Drag_MoveBackward(entity dragger);
-void Drag_Update(entity dragger);
-float Drag_CanDrag(entity dragger);
-float Drag_IsDragging(entity dragger);
-void Drag_MoveDrag(entity from, entity to);
 .entity dragentity;
 
 float CheatFrame(entity this)
@@ -734,7 +727,8 @@ float CheatFrame(entity this)
                        if(this.maycheat || (gamestart_sv_cheats && autocvar_sv_cheats))
                        {
                                // use cheat dragging if cheats are enabled
-                               crosshair_trace_plusvisibletriggers(this);
+                               //if(Drag_IsDragging(this))
+                                       //crosshair_trace_plusvisibletriggers(this);
                                Drag(this, true, true);
                        }
                        else
@@ -778,21 +772,21 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                        {
                                if(PHYS_INPUT_BUTTON_DRAG(this))
                                {
-                                       if(this.impulse == 10 || this.impulse == 15 || this.impulse == 18)
+                                       if(CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18)
                                        {
                                                Drag_MoveForward(this);
-                                               this.impulse = 0;
+                                               CS(this).impulse = 0;
                                        }
-                                       else if(this.impulse == 12 || this.impulse == 16 || this.impulse == 19)
+                                       else if(CS(this).impulse == 12 || CS(this).impulse == 16 || CS(this).impulse == 19)
                                        {
                                                Drag_MoveBackward(this);
-                                               this.impulse = 0;
+                                               CS(this).impulse = 0;
                                        }
-                                       else if(this.impulse >= 1 && this.impulse <= 9)
+                                       else if(CS(this).impulse >= 1 && CS(this).impulse <= 9)
                                        {
-                                               Drag_SetSpeed(this, this.impulse - 1);
+                                               Drag_SetSpeed(this, CS(this).impulse - 1);
                                        }
-                                       else if(this.impulse == 14)
+                                       else if(CS(this).impulse == 14)
                                        {
                                                Drag_SetSpeed(this, 9);
                                        }
@@ -820,7 +814,7 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                                                        // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
                                                        // it goes out of range while slinging it around.
 
-                                                       if(vlen(this.origin - e.origin) <= autocvar_g_grab_range)
+                                                       if(vdist(this.origin - e.origin, <=, autocvar_g_grab_range))
                                                        {
                                                                switch(e.grab)
                                                                {
@@ -868,9 +862,9 @@ void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
 {
        float tagscale;
 
-       draggee.dragmovetype = draggee.movetype;
+       draggee.dragmovetype = draggee.move_movetype;
        draggee.draggravity = draggee.gravity;
-       draggee.movetype = MOVETYPE_WALK;
+       set_movetype(draggee, MOVETYPE_WALK);
        draggee.gravity = 0.00001;
        UNSET_ONGROUND(draggee);
        draggee.draggedby = dragger;
@@ -880,7 +874,7 @@ void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
        dragger.dragdistance = vlen(touchpoint - dragger.origin - dragger.view_ofs);
        dragger.draglocalangle = draggee.angles.y - dragger.v_angle.y;
        touchpoint = touchpoint - gettaginfo(draggee, 0);
-       tagscale = pow(vlen(v_forward), -2);
+       tagscale = (vlen(v_forward) ** -2);
        dragger.draglocalvector_x = touchpoint * v_forward * tagscale;
        dragger.draglocalvector_y = touchpoint * v_right * tagscale;
        dragger.draglocalvector_z = touchpoint * v_up * tagscale;
@@ -893,12 +887,12 @@ void Drag_Finish(entity dragger)
        entity draggee;
        draggee = dragger.dragentity;
        if(dragger)
-               dragger.dragentity = world;
-       draggee.draggedby = world;
-       draggee.movetype = draggee.dragmovetype;
+               dragger.dragentity = NULL;
+       draggee.draggedby = NULL;
+       set_movetype(draggee, draggee.dragmovetype);
        draggee.gravity = draggee.draggravity;
 
-       switch(draggee.movetype)
+       switch(draggee.move_movetype)
        {
                case MOVETYPE_TOSS:
                case MOVETYPE_WALK:
@@ -913,7 +907,7 @@ void Drag_Finish(entity dragger)
                        break;
        }
 
-       if((draggee.flags & FL_ITEM) && (vlen(draggee.velocity) < 32))
+       if((draggee.flags & FL_ITEM) && (vdist(draggee.velocity, <, 32)))
        {
                draggee.velocity = '0 0 0';
                SET_ONGROUND(draggee); // floating items are FUN
@@ -923,7 +917,7 @@ void Drag_Finish(entity dragger)
 float Drag_IsDraggable(entity draggee)
 {
        // TODO add more checks for bad stuff here
-       if(draggee == world)
+       if(draggee == NULL)
                return false;
        if(draggee.classname == "func_bobbing")
                return false;
@@ -962,7 +956,7 @@ void Drag_MoveForward(entity dragger)
 
 void Drag_SetSpeed(entity dragger, float s)
 {
-       dragger.dragspeed = pow(2, s);
+       dragger.dragspeed = (2 ** s);
 }
 
 void Drag_MoveBackward(entity dragger)
@@ -1019,7 +1013,7 @@ float Drag_IsDragging(entity dragger)
                return false;
        if(wasfreed(dragger.dragentity) || dragger.dragentity.draggedby != dragger)
        {
-               dragger.dragentity = world;
+               dragger.dragentity = NULL;
                return false;
        }
        if(!Drag_CanDrag(dragger) || !Drag_IsDraggable(dragger.dragentity))
@@ -1036,7 +1030,7 @@ void Drag_MoveDrag(entity from, entity to)
        {
                to.draggedby = from.draggedby;
                to.draggedby.dragentity = to;
-               from.draggedby = world;
+               from.draggedby = NULL;
        }
 }