Merge branch 'terencehill/lms_itemtimes_fix' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 4 Jan 2016 12:00:21 +0000 (12:00 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 4 Jan 2016 12:00:21 +0000 (12:00 +0000)
LMS itemtimes fix

See merge request !266

188 files changed:
.gitlab-ci.yml [new file with mode: 0644]
qcsrc/client/commands/cl_cmd.qc
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/defs.qh
qcsrc/client/hud/hud.qc
qcsrc/client/hud/panel/ammo.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/mapvoting.qc
qcsrc/client/player_skeleton.qc
qcsrc/client/shownames.qc
qcsrc/client/teamradar.qc
qcsrc/client/view.qc
qcsrc/client/wall.qc
qcsrc/client/wall.qh
qcsrc/client/weapons/projectile.qc
qcsrc/client/weapons/projectile.qh
qcsrc/common/animdecide.qc
qcsrc/common/command/generic.qc
qcsrc/common/constants.qh
qcsrc/common/csqcmodel_settings.qh
qcsrc/common/effects/qc/casings.qc
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/effects/qc/modeleffects.qc
qcsrc/common/effects/qc/rubble.qh
qcsrc/common/ent_cs.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/items/item.qh
qcsrc/common/items/item/pickup.qh
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/monsters/monster.qh
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/shambler.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/monster/zombie.qc
qcsrc/common/monsters/spawn.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/monsters/sv_monsters.qh
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/damagetext/damagetext.qc
qcsrc/common/mutators/mutator/dodging/dodging.qc
qcsrc/common/mutators/mutator/midair/midair.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/net.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/mutators/mutator/physical_items/physical_items.qc
qcsrc/common/mutators/mutator/sandbox/sandbox.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
qcsrc/common/physics/movelib.qc
qcsrc/common/physics/movelib.qh
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/push.qc
qcsrc/common/t_items.qc
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door_secret.qc
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/common/triggers/func/rainsnow.qc
qcsrc/common/triggers/misc/corner.qc
qcsrc/common/triggers/misc/laser.qc
qcsrc/common/triggers/misc/teleport_dest.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/keylock.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/triggers/triggers.qc
qcsrc/common/triggers/triggers.qh
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret.qh
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/flac_weapon.qc
qcsrc/common/turrets/turret/fusionreactor.qc
qcsrc/common/turrets/turret/hellion.qc
qcsrc/common/turrets/turret/hellion_weapon.qc
qcsrc/common/turrets/turret/hk.qc
qcsrc/common/turrets/turret/hk_weapon.qc
qcsrc/common/turrets/turret/mlrs.qc
qcsrc/common/turrets/turret/phaser.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/common/turrets/turret/tesla.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle.qh
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/racer_weapon.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc
qcsrc/common/viewloc.qc
qcsrc/common/viewloc.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/lib/csqcmodel/cl_model.qc
qcsrc/lib/csqcmodel/cl_model.qh
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/lib/csqcmodel/interpolate.qc
qcsrc/lib/csqcmodel/interpolate.qh
qcsrc/lib/csqcmodel/sv_model.qc
qcsrc/lib/net.qh
qcsrc/lib/test.qc
qcsrc/lib/test.qh
qcsrc/lib/warpzone/client.qc
qcsrc/lib/warpzone/common.qc
qcsrc/lib/warpzone/server.qc
qcsrc/lib/yenc.qh
qcsrc/menu/item/button.qc
qcsrc/menu/item/container.qc
qcsrc/menu/item/listbox.qc
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/cvarlist.qc
qcsrc/menu/xonotic/demolist.qc
qcsrc/menu/xonotic/dialog_firstrun.qc
qcsrc/menu/xonotic/dialog_monstertools.qc
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/dialog_multiplayer_profile.qc
qcsrc/menu/xonotic/dialog_sandboxtools.qc
qcsrc/menu/xonotic/dialog_settings_game_crosshair.qc
qcsrc/menu/xonotic/dialog_settings_game_hud.qc
qcsrc/menu/xonotic/dialog_settings_game_messages.qc
qcsrc/menu/xonotic/dialog_settings_game_model.qc
qcsrc/menu/xonotic/dialog_settings_game_view.qc
qcsrc/menu/xonotic/dialog_settings_game_weapons.qc
qcsrc/menu/xonotic/dialog_settings_misc.qc
qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc
qcsrc/menu/xonotic/dialog_settings_user.qc
qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc
qcsrc/menu/xonotic/dialog_teamselect.qc
qcsrc/menu/xonotic/hudskinlist.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/playermodel.qc
qcsrc/menu/xonotic/screenshotlist.qc
qcsrc/menu/xonotic/slider_decibels.qc
qcsrc/menu/xonotic/soundlist.qc
qcsrc/qcc.sh
qcsrc/server/anticheat.qc
qcsrc/server/bot/aim.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/cl_player.qh
qcsrc/server/command/common.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_hook.qc
qcsrc/server/g_subs.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/portals.qc
qcsrc/server/steerlib.qc
qcsrc/server/steerlib.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/throwing.qh
qcsrc/server/weapons/tracing.qc

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644 (file)
index 0000000..bd671bf
--- /dev/null
@@ -0,0 +1,22 @@
+before_script:
+  - git clone --depth=1 --branch=master https://gitlab.com/xonotic/darkplaces.git darkplaces
+  - cd darkplaces && make sv-debug -j $(nproc)
+  - cd ..
+  - export ENGINE="$PWD/darkplaces/darkplaces-dedicated -xonotic"
+
+  - git clone --depth=1 --branch=master https://gitlab.com/xonotic/gmqcc.git gmqcc
+  - cd gmqcc && make -j $(nproc)
+  - cd ..
+  - export QCC="$PWD/gmqcc/gmqcc"
+
+  - ln -s $PWD data/xonotic-data.pk3dir
+  - mkdir maps && wget -O maps/gitlab-ci.bsp https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/_init/_init.bsp
+
+build:
+  script:
+    - make
+    - while read line; do
+        echo $line;
+        if [[ $line == "All tests OK" ]]; then exit 0; fi;
+      done < <(${ENGINE} +developer 1 +map gitlab-ci +sv_cmd runtest +exit)
+    - exit 1
index 6481d6b..873cef2 100644 (file)
@@ -23,13 +23,13 @@ void DrawDebugModel(entity this)
 {
        if (time - floor(time) > 0.5)
        {
-               PolyDrawModel(self);
-               self.drawmask = 0;
+               PolyDrawModel(this);
+               this.drawmask = 0;
        }
        else
        {
-               self.renderflags = 0;
-               self.drawmask = MASK_NORMAL;
+               this.renderflags = 0;
+               this.drawmask = MASK_NORMAL;
        }
 }
 
index 64e0eca..4a04eb5 100644 (file)
@@ -11,7 +11,7 @@
 .float death_time;
 .int modelflags;
 
-void CSQCModel_Hook_PreDraw(bool isplayer);
+void CSQCModel_Hook_PreDraw(entity this, bool isplayer);
 
 .bool isplayermodel;
 
@@ -19,66 +19,66 @@ void CSQCModel_Hook_PreDraw(bool isplayer);
 .int lodmodelindex0;
 .int lodmodelindex1;
 .int lodmodelindex2;
-void CSQCPlayer_LOD_Apply()
-{SELFPARAM();
+void CSQCPlayer_LOD_Apply(entity this)
+{
        // LOD model loading
-       if(self.lodmodelindex0 != self.modelindex)
+       if(this.lodmodelindex0 != this.modelindex)
        {
-               string modelname = self.model;
+               string modelname = this.model;
                string s;
 
-               vector mi = self.mins;
-               vector ma = self.maxs;
+               vector mi = this.mins;
+               vector ma = this.maxs;
 
                // set modelindex
-               self.lodmodelindex0 = self.modelindex;
-               self.lodmodelindex1 = self.modelindex;
-               self.lodmodelindex2 = self.modelindex;
+               this.lodmodelindex0 = this.modelindex;
+               this.lodmodelindex1 = this.modelindex;
+               this.lodmodelindex2 = this.modelindex;
 
                // FIXME: this only supports 3-letter extensions
                s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
                if(fexists(s))
                {
                        precache_model(s);
-                       _setmodel(self, s);
-                       if(self.modelindex)
-                               self.lodmodelindex1 = self.modelindex;
+                       _setmodel(this, s);
+                       if(this.modelindex)
+                               this.lodmodelindex1 = this.modelindex;
                }
 
                s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
                if(fexists(s))
                {
                        precache_model(s);
-                       _setmodel(self, s);
-                       if(self.modelindex)
-                               self.lodmodelindex2 = self.modelindex;
+                       _setmodel(this, s);
+                       if(this.modelindex)
+                               this.lodmodelindex2 = this.modelindex;
                }
 
-               _setmodel(self, modelname); // make everything normal again
-               setsize(self, mi, ma);
+               _setmodel(this, modelname); // make everything normal again
+               setsize(this, mi, ma);
        }
 
        // apply LOD
        if(autocvar_cl_playerdetailreduction <= 0)
        {
                if(autocvar_cl_playerdetailreduction <= -2)
-                       self.modelindex = self.lodmodelindex2;
+                       this.modelindex = this.lodmodelindex2;
                else if(autocvar_cl_playerdetailreduction <= -1)
-                       self.modelindex = self.lodmodelindex1;
+                       this.modelindex = this.lodmodelindex1;
                else
-                       self.modelindex = self.lodmodelindex0;
+                       this.modelindex = this.lodmodelindex0;
        }
        else
        {
-               float distance = vlen(self.origin - view_origin);
+               float distance = vlen(this.origin - view_origin);
                float f = (distance * current_viewzoom + 100.0) * autocvar_cl_playerdetailreduction;
                f *= 1.0 / bound(0.01, view_quality, 1);
                if(f > autocvar_cl_loddistance2)
-                       self.modelindex = self.lodmodelindex2;
+                       this.modelindex = this.lodmodelindex2;
                else if(f > autocvar_cl_loddistance1)
-                       self.modelindex = self.lodmodelindex1;
+                       this.modelindex = this.lodmodelindex1;
                else
-                       self.modelindex = self.lodmodelindex0;
+                       this.modelindex = this.lodmodelindex0;
        }
 }
 
@@ -108,30 +108,30 @@ int forceplayermodels_goodmodelindex;
 .vector glowmod;
 .vector old_glowmod;
 
-void CSQCPlayer_ModelAppearance_PreUpdate()
-{SELFPARAM();
-       self.model = self.forceplayermodels_savemodel;
-       self.modelindex = self.forceplayermodels_savemodelindex;
-       self.skin = self.forceplayermodels_saveskin;
-       self.colormap = self.forceplayermodels_savecolormap;
+void CSQCPlayer_ModelAppearance_PreUpdate(entity this)
+{
+       this.model = this.forceplayermodels_savemodel;
+       this.modelindex = this.forceplayermodels_savemodelindex;
+       this.skin = this.forceplayermodels_saveskin;
+       this.colormap = this.forceplayermodels_savecolormap;
 }
-void CSQCPlayer_ModelAppearance_PostUpdate()
-{SELFPARAM();
-       self.forceplayermodels_savemodel = self.model;
-       self.forceplayermodels_savemodelindex = self.modelindex;
-       self.forceplayermodels_saveskin = self.skin;
-       self.forceplayermodels_savecolormap = self.colormap;
-
-       if(self.forceplayermodels_savemodel != self.forceplayermodels_isgoodmodel_mdl)
+void CSQCPlayer_ModelAppearance_PostUpdate(entity this)
+{
+       this.forceplayermodels_savemodel = this.model;
+       this.forceplayermodels_savemodelindex = this.modelindex;
+       this.forceplayermodels_saveskin = this.skin;
+       this.forceplayermodels_savecolormap = this.colormap;
+
+       if(this.forceplayermodels_savemodel != this.forceplayermodels_isgoodmodel_mdl)
        {
-               self.forceplayermodels_isgoodmodel = fexists(self.forceplayermodels_savemodel);
-               self.forceplayermodels_isgoodmodel_mdl = self.forceplayermodels_savemodel;
-               if(!self.forceplayermodels_isgoodmodel)
-                       LOG_INFOF("Warning: missing model %s has been used\n", self.forceplayermodels_savemodel);
+               this.forceplayermodels_isgoodmodel = fexists(this.forceplayermodels_savemodel);
+               this.forceplayermodels_isgoodmodel_mdl = this.forceplayermodels_savemodel;
+               if(!this.forceplayermodels_isgoodmodel)
+                       LOG_INFOF("Warning: missing model %s has been used\n", this.forceplayermodels_savemodel);
        }
 }
-void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
-{SELFPARAM();
+void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
+{
        // FORCEMODEL
        // which one is ALWAYS good?
        if (!forceplayermodels_goodmodel)
@@ -145,17 +145,17 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
        }
 
        // first, try finding it from the server
-       if(self.forceplayermodels_savemodelindex && self.forceplayermodels_savemodel != "null")
+       if(this.forceplayermodels_savemodelindex && this.forceplayermodels_savemodel != "null")
        {
                if(islocalplayer)
                {
                        if(!isdemo()) // this is mainly cheat protection; not needed for demos
                        {
                                // trust server's idea of "own player model"
-                               forceplayermodels_modelisgoodmodel = self.forceplayermodels_isgoodmodel;
-                               forceplayermodels_model = self.forceplayermodels_savemodel;
-                               forceplayermodels_modelindex = self.forceplayermodels_savemodelindex;
-                               forceplayermodels_skin = self.forceplayermodels_saveskin;
+                               forceplayermodels_modelisgoodmodel = this.forceplayermodels_isgoodmodel;
+                               forceplayermodels_model = this.forceplayermodels_savemodel;
+                               forceplayermodels_modelindex = this.forceplayermodels_savemodelindex;
+                               forceplayermodels_skin = this.forceplayermodels_saveskin;
                                forceplayermodels_attempted = 1;
                        }
                }
@@ -190,7 +190,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
        // apply it
        bool isfriend;
        int cm;
-       cm = self.forceplayermodels_savecolormap;
+       cm = this.forceplayermodels_savecolormap;
        cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(cm - 1, "colors")) + 1024);
 
        if(teamplay)
@@ -200,27 +200,27 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
 
        if(autocvar_cl_forcemyplayermodel != "" && forceplayermodels_myisgoodmodel && isfriend)
        {
-               self.model = forceplayermodels_mymodel;
-               self.modelindex = forceplayermodels_mymodelindex;
-               self.skin = autocvar_cl_forcemyplayerskin;
+               this.model = forceplayermodels_mymodel;
+               this.modelindex = forceplayermodels_mymodelindex;
+               this.skin = autocvar_cl_forcemyplayerskin;
        }
        else if(autocvar_cl_forceplayermodels && forceplayermodels_modelisgoodmodel)
        {
-               self.model = forceplayermodels_model;
-               self.modelindex = forceplayermodels_modelindex;
-               self.skin = forceplayermodels_skin;
+               this.model = forceplayermodels_model;
+               this.modelindex = forceplayermodels_modelindex;
+               this.skin = forceplayermodels_skin;
        }
-       else if(self.forceplayermodels_isgoodmodel)
+       else if(this.forceplayermodels_isgoodmodel)
        {
-               self.model = self.forceplayermodels_savemodel;
-               self.modelindex = self.forceplayermodels_savemodelindex;
-               self.skin = self.forceplayermodels_saveskin;
+               this.model = this.forceplayermodels_savemodel;
+               this.modelindex = this.forceplayermodels_savemodelindex;
+               this.skin = this.forceplayermodels_saveskin;
        }
        else
        {
-               self.model = forceplayermodels_goodmodel;
-               self.modelindex = forceplayermodels_goodmodelindex;
-               self.skin = self.forceplayermodels_saveskin;
+               this.model = forceplayermodels_goodmodel;
+               this.modelindex = forceplayermodels_goodmodelindex;
+               this.skin = this.forceplayermodels_saveskin;
        }
 
        // forceplayercolors too
@@ -260,45 +260,45 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
                if(cm == 1024 + 17 * myteam)
                {
                        if(forcecolor_friend)
-                               self.colormap = forcecolor_friend;
+                               this.colormap = forcecolor_friend;
                }
                else
                {
                        if(forcecolor_enemy)
-                               self.colormap = forcecolor_enemy;
+                               this.colormap = forcecolor_enemy;
                }
        }
        else
        {
                if(autocvar_cl_forcemyplayercolors && islocalplayer)
-                       self.colormap = 1024 + autocvar_cl_forcemyplayercolors;
+                       this.colormap = 1024 + autocvar_cl_forcemyplayercolors;
                else if(autocvar_cl_forceplayercolors)
-                       self.colormap = player_localnum + 1;
+                       this.colormap = player_localnum + 1;
        }
 
        // GLOWMOD AND DEATH FADING
-       if(self.colormap > 0)
-               self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? self.colormap : stof(getplayerkeyvalue(self.colormap - 1, "colors"))) & 0x0F, true) * 2;
+       if(this.colormap > 0)
+               this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : stof(getplayerkeyvalue(this.colormap - 1, "colors"))) & 0x0F, true) * 2;
        else
-               self.glowmod = '1 1 1';
+               this.glowmod = '1 1 1';
 
        if(autocvar_cl_deathglow > 0)
        {
-               if(self.csqcmodel_isdead)
+               if(this.csqcmodel_isdead)
                {
                        // Fade out to black now...
-                       if(self.old_glowmod == '0 0 0') { self.old_glowmod = self.glowmod; }
-                       self.colormap = 0;
+                       if(this.old_glowmod == '0 0 0') { this.old_glowmod = this.glowmod; }
+                       this.colormap = 0;
 
-                       self.glowmod = self.old_glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1);
-                       self.glowmod_x = max(self.glowmod.x, 0.0001);
-                       self.glowmod_y = max(self.glowmod.y, 0.0001);
-                       self.glowmod_z = max(self.glowmod.z, 0.0001);
+                       this.glowmod = this.old_glowmod * bound(0, 1 - (time - this.death_time) / autocvar_cl_deathglow, 1);
+                       this.glowmod_x = max(this.glowmod.x, 0.0001);
+                       this.glowmod_y = max(this.glowmod.y, 0.0001);
+                       this.glowmod_z = max(this.glowmod.z, 0.0001);
                }
-               else if(self.old_glowmod != '0 0 0') { self.old_glowmod = '0 0 0'; }
+               else if(this.old_glowmod != '0 0 0') { this.old_glowmod = '0 0 0'; }
        }
 
-       //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (self.csqcmodel_isdead ? "DEAD" : "ALIVE"), self.colormap, vtos(self.glowmod));
+       //printf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (this.csqcmodel_isdead ? "DEAD" : "ALIVE"), this.colormap, vtos(this.glowmod));
 }
 
 // FEATURE: fallback frames
@@ -311,22 +311,22 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
 .int csqcmodel_framecount;
 
 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
-void CSQCPlayer_FallbackFrame_PreUpdate()
-{SELFPARAM();
-       self.frame = self.csqcmodel_saveframe;
-       self.frame2 = self.csqcmodel_saveframe2;
+void CSQCPlayer_FallbackFrame_PreUpdate(entity this)
+{
+       this.frame = this.csqcmodel_saveframe;
+       this.frame2 = this.csqcmodel_saveframe2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
-       self.frame3 = self.csqcmodel_saveframe3;
-       self.frame4 = self.csqcmodel_saveframe4;
+       this.frame3 = this.csqcmodel_saveframe3;
+       this.frame4 = this.csqcmodel_saveframe4;
 #endif
 }
-void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
-{SELFPARAM();
-       self.csqcmodel_saveframe = self.frame;
-       self.csqcmodel_saveframe2 = self.frame2;
+void CSQCPlayer_FallbackFrame_PostUpdate(entity this, bool isnew)
+{
+       this.csqcmodel_saveframe = this.frame;
+       this.csqcmodel_saveframe2 = this.frame2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
-       self.csqcmodel_saveframe3 = self.frame3;
-       self.csqcmodel_saveframe4 = self.frame4;
+       this.csqcmodel_saveframe3 = this.frame3;
+       this.csqcmodel_saveframe4 = this.frame4;
 #endif
 
        // hack for death animations: set their frametime to zero in case a
@@ -334,8 +334,8 @@ void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
        if(isnew)
        {
 #define FIX_FRAMETIME(f,ft) MACRO_BEGIN {                                                                                                                                                      \
-               if(IS_DEAD_FRAME(self.f) && self.ft != 0 && self.death_time != 0)                                                                                       \
-                       self.ft = self.death_time;                                                                                                                                                              \
+               if(IS_DEAD_FRAME(this.f) && this.ft != 0 && this.death_time != 0)                                                                                       \
+                       this.ft = this.death_time;                                                                                                                                                              \
 } MACRO_END
                FIX_FRAMETIME(frame, frame1time);
                FIX_FRAMETIME(frame2, frame2time);
@@ -344,17 +344,17 @@ void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
                FIX_FRAMETIME(frame4, frame4time);
 #endif
        }
-       self.csqcmodel_isdead = IS_DEAD_FRAME(self.frame);
+       this.csqcmodel_isdead = IS_DEAD_FRAME(this.frame);
 }
-void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
-{SELFPARAM();
-       self.csqcmodel_isdead = boolean(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
+void CSQCPlayer_AnimDecide_PostUpdate(entity this, bool isnew)
+{
+       this.csqcmodel_isdead = boolean(this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
 }
-int CSQCPlayer_FallbackFrame(int f)
-{SELFPARAM();
-       if(frameduration(self.modelindex, f) > 0)
+int CSQCPlayer_FallbackFrame(entity this, int f)
+{
+       if(frameduration(this.modelindex, f) > 0)
                return f; // goooooood
-       if(frameduration(self.modelindex, 1) <= 0)
+       if(frameduration(this.modelindex, 1) <= 0)
                return f; // this is a static model. We can't fix it if we wanted to
        switch(f)
        {
@@ -367,16 +367,16 @@ int CSQCPlayer_FallbackFrame(int f)
                case 29: return 4; // anim_duckwalkbackright -> anim_duckwalk
                case 30: return 4; // anim_duckwalkbackleft -> anim_duckwalk
        }
-       LOG_INFOF("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, self.model);
+       LOG_INFOF("Frame %d missing in model %s, and we have no fallback - FAIL!\n", f, this.model);
        return f;
 }
-void CSQCPlayer_FallbackFrame_Apply()
-{SELFPARAM();
-       self.frame = CSQCPlayer_FallbackFrame(self.frame);
-       self.frame2 = CSQCPlayer_FallbackFrame(self.frame2);
+void CSQCPlayer_FallbackFrame_Apply(entity this)
+{
+       this.frame = CSQCPlayer_FallbackFrame(this, this.frame);
+       this.frame2 = CSQCPlayer_FallbackFrame(this, this.frame2);
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
-       self.frame3 = CSQCPlayer_FallbackFrame(self.frame3);
-       self.frame4 = CSQCPlayer_FallbackFrame(self.frame4);
+       this.frame3 = CSQCPlayer_FallbackFrame(this, this.frame3);
+       this.frame4 = CSQCPlayer_FallbackFrame(this, this.frame4);
 #endif
 }
 
@@ -384,76 +384,76 @@ void CSQCPlayer_FallbackFrame_Apply()
 .entity tag_entity;
 .int tag_entity_lastmodelindex;
 .int tag_index;
-void CSQCModel_AutoTagIndex_Apply()
-{SELFPARAM();
-       if(self.tag_entity && wasfreed(self.tag_entity))
-               self.tag_entity = world;
+void CSQCModel_AutoTagIndex_Apply(entity this)
+{
+       if(this.tag_entity && wasfreed(this.tag_entity))
+               this.tag_entity = world;
 
-       viewloc_SetTags();
+       viewloc_SetTags(this);
 
-       MUTATOR_CALLHOOK(TagIndex_Update, self);
+       MUTATOR_CALLHOOK(TagIndex_Update, this);
 
-       if(self.tag_networkentity)
+       if(this.tag_networkentity)
        {
                // we are ATTACHED!
                bool changed = 0;
-               if(self.tag_entity.entnum != self.tag_networkentity)
+               if(this.tag_entity.entnum != this.tag_networkentity)
                {
-                       self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
+                       this.tag_entity = findfloat(world, entnum, this.tag_networkentity);
                        changed = 1;
                }
 
                // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
-               if(self.tag_entity.classname == "csqcmodel")
+               if(this.tag_entity.classname == "csqcmodel")
                {
-                       WITH(entity, self, self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
+                       CSQCModel_Hook_PreDraw(this.tag_entity, (this.entnum >= 1 && this.entnum <= maxclients));
                }
 
-               if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
+               if(this.tag_entity.modelindex != this.tag_entity_lastmodelindex)
                {
-                       self.tag_entity_lastmodelindex = self.tag_entity.modelindex;
+                       this.tag_entity_lastmodelindex = this.tag_entity.modelindex;
                        changed = 1;
                }
                if(changed)
                {
-                       if(self.tag_entity)
+                       if(this.tag_entity)
                        {
                                // the best part is: IT EXISTS
-                               if(substring(self.model, 0, 14) == "models/weapons")
+                               if(substring(this.model, 0, 14) == "models/weapons")
                                {
-                                       if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
+                                       if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
                                        {
-                                               self.tag_index = gettagindex(self.tag_entity, "weapon");
-                                               if(!self.tag_index)
-                                                       self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
-                                               if(!self.tag_index)
+                                               this.tag_index = gettagindex(this.tag_entity, "weapon");
+                                               if(!this.tag_index)
+                                                       this.tag_index = gettagindex(this.tag_entity, "tag_weapon");
+                                               if(!this.tag_index)
                                                {
                                                        // we need to prevent this from 'appening
-                                                       self.tag_entity = world;
-                                                       self.drawmask = 0;
+                                                       this.tag_entity = world;
+                                                       this.drawmask = 0;
                                                        LOG_TRACE("h_ model lacks weapon attachment, but v_ model is attached to it\n");
                                                }
                                        }
-                                       else if(self.tag_entity.isplayermodel)
+                                       else if(this.tag_entity.isplayermodel)
                                        {
-                                               skeleton_loadinfo(self.tag_entity);
-                                               self.tag_index = self.tag_entity.bone_weapon;
+                                               skeleton_loadinfo(this.tag_entity);
+                                               this.tag_index = this.tag_entity.bone_weapon;
                                        }
                                }
 
-                               if(substring(self.tag_entity.model, 0, 14) == "models/weapons")
+                               if(substring(this.tag_entity.model, 0, 14) == "models/weapons")
                                {
-                                       self.tag_index = gettagindex(self.tag_entity, "shot");
-                                       if(!self.tag_index)
-                                               self.tag_index = gettagindex(self.tag_entity, "tag_shot");
+                                       this.tag_index = gettagindex(this.tag_entity, "shot");
+                                       if(!this.tag_index)
+                                               this.tag_index = gettagindex(this.tag_entity, "tag_shot");
                                }
 
-                               MUTATOR_CALLHOOK(TagIndex_Apply, self);
+                               MUTATOR_CALLHOOK(TagIndex_Apply, this);
                        }
                        else
                        {
                                // damn, see you next frame
-                               self.drawmask = 0;
+                               this.drawmask = 0;
                        }
                }
        }
@@ -479,117 +479,117 @@ const int MF_TRACER3 = BIT(7); // purple trail
 .int csqcmodel_effects;
 .int csqcmodel_modelflags;
 .int csqcmodel_traileffect;
-void CSQCModel_Effects_PreUpdate()
-{SELFPARAM();
-       self.effects = self.csqcmodel_effects;
-       self.modelflags = self.csqcmodel_modelflags;
-       self.traileffect = self.csqcmodel_traileffect;
+void CSQCModel_Effects_PreUpdate(entity this)
+{
+       this.effects = this.csqcmodel_effects;
+       this.modelflags = this.csqcmodel_modelflags;
+       this.traileffect = this.csqcmodel_traileffect;
 }
 void Reset_ArcBeam();
-void CSQCModel_Effects_PostUpdate()
-{SELFPARAM();
-       if (self == csqcplayer) {
-               if (self.csqcmodel_teleported) {
+void CSQCModel_Effects_PostUpdate(entity this)
+{
+       if (this == csqcplayer) {
+               if (this.csqcmodel_teleported) {
                        Reset_ArcBeam();
                }
        }
-       self.csqcmodel_effects = self.effects;
-       self.csqcmodel_modelflags = self.modelflags;
-       self.csqcmodel_traileffect = self.traileffect;
-       self.effects = 0;
-       self.modelflags = 0;
-       if(self.csqcmodel_teleported)
-               Projectile_ResetTrail(self, self.origin);
+       this.csqcmodel_effects = this.effects;
+       this.csqcmodel_modelflags = this.modelflags;
+       this.csqcmodel_traileffect = this.traileffect;
+       this.effects = 0;
+       this.modelflags = 0;
+       if(this.csqcmodel_teleported)
+               Projectile_ResetTrail(this, this.origin);
 }
 .int snd_looping;
-void CSQCModel_Effects_Apply()
-{SELFPARAM();
-       int eff = self.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
-       int tref = self.csqcmodel_traileffect;
+void CSQCModel_Effects_Apply(entity this)
+{
+       int eff = this.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
+       int tref = this.csqcmodel_traileffect;
 
-       self.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
-       self.effects = 0;
-       self.traileffect = 0;
+       this.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
+       this.effects = 0;
+       this.traileffect = 0;
 
        if(eff & EF_BRIGHTFIELD)
                tref = EFFECT_TR_NEXUIZPLASMA.m_id;
        // ignoring EF_MUZZLEFLASH
        if(eff & EF_BRIGHTLIGHT)
-               adddynamiclight(self.origin, 400, '3 3 3');
+               adddynamiclight(this.origin, 400, '3 3 3');
        if(eff & EF_DIMLIGHT)
-               adddynamiclight(self.origin, 200, '1.5 1.5 1.5');
-       if((eff & EF_NODRAW) || (self.alpha < 0))
-               self.drawmask = 0;
+               adddynamiclight(this.origin, 200, '1.5 1.5 1.5');
+       if((eff & EF_NODRAW) || (this.alpha < 0))
+               this.drawmask = 0;
        if(eff & EF_ADDITIVE)
-               self.renderflags |= RF_ADDITIVE;
+               this.renderflags |= RF_ADDITIVE;
        if(eff & EF_BLUE)
-               adddynamiclight(self.origin, 200, '0.15 0.15 1.5');
+               adddynamiclight(this.origin, 200, '0.15 0.15 1.5');
        if(eff & EF_RED)
-               adddynamiclight(self.origin, 200, '1.5 0.15 0.15');
+               adddynamiclight(this.origin, 200, '1.5 0.15 0.15');
        // ignoring EF_NOGUNBOB
        if(eff & EF_FULLBRIGHT)
-               self.renderflags |= RF_FULLBRIGHT;
+               this.renderflags |= RF_FULLBRIGHT;
        if(eff & EF_FLAME)
-               pointparticles(EFFECT_EF_FLAME, self.origin, '0 0 0', bound(0, frametime, 0.1));
+               pointparticles(EFFECT_EF_FLAME, this.origin, '0 0 0', bound(0, frametime, 0.1));
        if(eff & EF_STARDUST)
-               pointparticles(EFFECT_EF_STARDUST, self.origin, '0 0 0', bound(0, frametime, 0.1));
+               pointparticles(EFFECT_EF_STARDUST, this.origin, '0 0 0', bound(0, frametime, 0.1));
        if(eff & EF_NOSHADOW)
-               self.renderflags |= RF_NOSHADOW;
+               this.renderflags |= RF_NOSHADOW;
        if(eff & EF_NODEPTHTEST)
-               self.renderflags |= RF_DEPTHHACK;
+               this.renderflags |= RF_DEPTHHACK;
        // ignoring EF_SELECTABLE
        if(eff & EF_DOUBLESIDED)
-               self.effects |= EF_DOUBLESIDED;
+               this.effects |= EF_DOUBLESIDED;
        if(eff & EF_NOSELFSHADOW)
-               self.effects |= EF_NOSELFSHADOW;
+               this.effects |= EF_NOSELFSHADOW;
        if(eff & EF_DYNAMICMODELLIGHT)
-               self.renderflags |= RF_DYNAMICMODELLIGHT;
+               this.renderflags |= RF_DYNAMICMODELLIGHT;
        // ignoring EF_UNUSED18, EF_UNUSED19, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, EF_LOWPRECISION
-       if(self.csqcmodel_modelflags & MF_ROCKET)
+       if(this.csqcmodel_modelflags & MF_ROCKET)
                tref = EFFECT_TR_ROCKET.m_id;
-       if(self.csqcmodel_modelflags & MF_GRENADE)
+       if(this.csqcmodel_modelflags & MF_GRENADE)
                tref = EFFECT_TR_GRENADE.m_id;
-       if(self.csqcmodel_modelflags & MF_GIB)
+       if(this.csqcmodel_modelflags & MF_GIB)
                tref = EFFECT_TR_BLOOD.m_id;
-       if(self.csqcmodel_modelflags & MF_ROTATE)
+       if(this.csqcmodel_modelflags & MF_ROTATE)
        {
-               self.renderflags |= RF_USEAXIS;
-               makevectors(self.angles + '0 100 0' * fmod(time, 3.6));
+               this.renderflags |= RF_USEAXIS;
+               makevectors(this.angles + '0 100 0' * fmod(time, 3.6));
        }
-       if(self.csqcmodel_modelflags & MF_TRACER)
+       if(this.csqcmodel_modelflags & MF_TRACER)
                tref = EFFECT_TR_WIZSPIKE.m_id;
-       if(self.csqcmodel_modelflags & MF_ZOMGIB)
+       if(this.csqcmodel_modelflags & MF_ZOMGIB)
                tref = EFFECT_TR_SLIGHTBLOOD.m_id;
-       if(self.csqcmodel_modelflags & MF_TRACER2)
+       if(this.csqcmodel_modelflags & MF_TRACER2)
                tref = EFFECT_TR_KNIGHTSPIKE.m_id;
-       if(self.csqcmodel_modelflags & MF_TRACER3)
+       if(this.csqcmodel_modelflags & MF_TRACER3)
                tref = EFFECT_TR_VORESPIKE.m_id;
 
-       self.traileffect = tref;
+       this.traileffect = tref;
 
-       if(self.drawmask)
-               Projectile_DrawTrail(self, self.origin);
+       if(this.drawmask)
+               Projectile_DrawTrail(this, this.origin);
        else
-               Projectile_ResetTrail(self, self.origin);
+               Projectile_ResetTrail(this, this.origin);
 
-       if(self.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
-               self.renderflags |= RF_ADDITIVE;
+       if(this.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST)
+               this.renderflags |= RF_ADDITIVE;
                // also special in CSQCPlayer_GlowMod_Apply
 
-       if(self.csqcmodel_modelflags & MF_ROCKET)
+       if(this.csqcmodel_modelflags & MF_ROCKET)
        {
-               if(!self.snd_looping)
+               if(!this.snd_looping)
                {
-                       sound(self, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_g_jetpack_attenuation);
-                       self.snd_looping = CH_TRIGGER_SINGLE;
+                       sound(this, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_g_jetpack_attenuation);
+                       this.snd_looping = CH_TRIGGER_SINGLE;
                }
        }
        else
        {
-               if(self.snd_looping)
+               if(this.snd_looping)
                {
-                       sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
-                       self.snd_looping = 0;
+                       sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
+                       this.snd_looping = 0;
                }
        }
 }
@@ -605,132 +605,132 @@ void CSQCModel_Effects_Apply()
 .int anim_saveframe2;
 .int anim_saveframe2time;
 .int anim_prev_pmove_flags;
-void CSQCModel_Hook_PreDraw(bool isplayer)
-{SELFPARAM();
-       if(self.csqcmodel_predraw_run == framecount)
+void CSQCModel_Hook_PreDraw(entity this, bool isplayer)
+{
+       if(this.csqcmodel_predraw_run == framecount)
                return;
-       self.csqcmodel_predraw_run = framecount;
+       this.csqcmodel_predraw_run = framecount;
 
-       if(!self.modelindex || self.model == "null")
+       if(!this.modelindex || this.model == "null")
        {
-               self.drawmask = 0;
+               this.drawmask = 0;
                return;
        }
        else
-               self.drawmask = MASK_NORMAL;
+               this.drawmask = MASK_NORMAL;
 
-       if(self.isplayermodel) // this checks if it's a player MODEL!
+       if(this.isplayermodel) // this checks if it's a player MODEL!
        {
-               CSQCPlayer_ModelAppearance_Apply(self.entnum == player_localnum + 1);
-               CSQCPlayer_LOD_Apply();
+               CSQCPlayer_ModelAppearance_Apply(this, this.entnum == player_localnum + 1);
+               CSQCPlayer_LOD_Apply(this);
 
                if(!isplayer)
                {
-                       skeleton_loadinfo(self);
-                       bool doblend = (self.bone_upperbody >= 0);
-                       CSQCPlayer_FallbackFrame_Apply();
+                       skeleton_loadinfo(this);
+                       bool doblend = (this.bone_upperbody >= 0);
+                       CSQCPlayer_FallbackFrame_Apply(this);
                        if(doblend)
                        {
-                               skeleton_from_frames(self, self.csqcmodel_isdead);
+                               skeleton_from_frames(this, this.csqcmodel_isdead);
                        }
                        else
                        {
-                               free_skeleton_from_frames(self);
+                               free_skeleton_from_frames(this);
                                // just in case, clear these (we're animating in frame and frame3)
-                               self.lerpfrac = 0;
-                               self.lerpfrac4 = 0;
+                               this.lerpfrac = 0;
+                               this.lerpfrac4 = 0;
                        }
                }
                else
                {
                        // we know that frame3 and frame4 fields, used by InterpolateAnimation, are left alone - but that is all we know!
-                       skeleton_loadinfo(self);
-                       bool doblend = (self.bone_upperbody >= 0);
+                       skeleton_loadinfo(this);
+                       bool doblend = (this.bone_upperbody >= 0);
                        bool onground = 0;
-                       if(self == csqcplayer)
+                       if(this == csqcplayer)
                        {
-                               if(IS_ONGROUND(self))
+                               if(IS_ONGROUND(this))
                                        onground = 1;
-                               self.anim_prev_pmove_flags = self.flags;
-                               if(self.flags & FL_DUCKED)
-                                       animdecide_setstate(self, self.anim_state | ANIMSTATE_DUCK, false);
-                               else if(self.anim_state & ANIMSTATE_DUCK)
-                                       animdecide_setstate(self, self.anim_state - ANIMSTATE_DUCK, false);
+                               this.anim_prev_pmove_flags = this.flags;
+                               if(this.flags & FL_DUCKED)
+                                       animdecide_setstate(this, this.anim_state | ANIMSTATE_DUCK, false);
+                               else if(this.anim_state & ANIMSTATE_DUCK)
+                                       animdecide_setstate(this, this.anim_state - ANIMSTATE_DUCK, false);
                        }
                        else
                        {
-                               tracebox(self.origin + '0 0 1', self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
+                               tracebox(this.origin + '0 0 1', this.mins, this.maxs, this.origin - '0 0 4', MOVE_NORMAL, this);
                                if(trace_startsolid || trace_fraction < 1)
                                        onground = 1;
                        }
-                       animdecide_load_if_needed(self);
-                       animdecide_setimplicitstate(self, onground);
-                       animdecide_setframes(self, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
+                       animdecide_load_if_needed(this);
+                       animdecide_setimplicitstate(this, onground);
+                       animdecide_setframes(this, doblend, anim_frame, anim_frame1time, anim_frame2, anim_frame2time);
                        int sf = 0;
-                       if(self.anim_saveframe != self.anim_frame || self.anim_saveframe1time != self.anim_frame1time)
+                       if(this.anim_saveframe != this.anim_frame || this.anim_saveframe1time != this.anim_frame1time)
                                sf |= CSQCMODEL_PROPERTY_FRAME;
-                       if(self.anim_saveframe2 != self.anim_frame2 || self.anim_saveframe2time != self.anim_frame2time)
+                       if(this.anim_saveframe2 != this.anim_frame2 || this.anim_saveframe2time != this.anim_frame2time)
                                sf |= CSQCMODEL_PROPERTY_FRAME2;
-                       self.anim_saveframe = self.anim_frame;
-                       self.anim_saveframe1time = self.anim_frame1time;
-                       self.anim_saveframe2 = self.anim_frame2;
-                       self.anim_saveframe2time = self.anim_frame2time;
+                       this.anim_saveframe = this.anim_frame;
+                       this.anim_saveframe1time = this.anim_frame1time;
+                       this.anim_saveframe2 = this.anim_frame2;
+                       this.anim_saveframe2time = this.anim_frame2time;
                        // Note: we always consider lerpfrac "changed", as it uses fixed values every time anyway.
                        // This ensures that .frame etc. are always written.
-                       CSQCModel_InterpolateAnimation_2To4_PreNote(sf | CSQCMODEL_PROPERTY_LERPFRAC);
-                       self.lerpfrac = (doblend ? 0.5 : 0);
-                       self.frame = self.anim_frame;
-                       self.frame1time = self.anim_frame1time;
-                       self.frame2 = self.anim_frame2;
-                       self.frame2time = self.anim_frame2time;
-                       CSQCModel_InterpolateAnimation_2To4_Note(sf | CSQCMODEL_PROPERTY_LERPFRAC, false);
-                       CSQCModel_InterpolateAnimation_2To4_Do();
+                       CSQCModel_InterpolateAnimation_2To4_PreNote(this, sf | CSQCMODEL_PROPERTY_LERPFRAC);
+                       this.lerpfrac = (doblend ? 0.5 : 0);
+                       this.frame = this.anim_frame;
+                       this.frame1time = this.anim_frame1time;
+                       this.frame2 = this.anim_frame2;
+                       this.frame2time = this.anim_frame2time;
+                       CSQCModel_InterpolateAnimation_2To4_Note(this, sf | CSQCMODEL_PROPERTY_LERPFRAC, false);
+                       CSQCModel_InterpolateAnimation_2To4_Do(this);
                        if(doblend)
                        {
-                               skeleton_from_frames(self, self.csqcmodel_isdead);
+                               skeleton_from_frames(this, this.csqcmodel_isdead);
                        }
                        else
                        {
-                               free_skeleton_from_frames(self);
+                               free_skeleton_from_frames(this);
                                // just in case, clear these (we're animating in frame and frame3)
-                               self.lerpfrac = 0;
-                               self.lerpfrac4 = 0;
+                               this.lerpfrac = 0;
+                               this.lerpfrac4 = 0;
                        }
                }
        }
 
-       CSQCModel_AutoTagIndex_Apply();
+       CSQCModel_AutoTagIndex_Apply(this);
 
-       CSQCModel_Effects_Apply();
+       CSQCModel_Effects_Apply(this);
 }
 
-void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{SELFPARAM();
+void CSQCModel_Hook_PreUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
+{
        // interpolate v_angle
-       self.iflags |= IFLAG_V_ANGLE_X;
+       this.iflags |= IFLAG_V_ANGLE_X;
        // revert to values from server
-       CSQCModel_Effects_PreUpdate();
-       if(self.isplayermodel)
+       CSQCModel_Effects_PreUpdate(this);
+       if(this.isplayermodel)
        {
                if(!isplayer)
-                       CSQCPlayer_FallbackFrame_PreUpdate();
-               CSQCPlayer_ModelAppearance_PreUpdate();
+                       CSQCPlayer_FallbackFrame_PreUpdate(this);
+               CSQCPlayer_ModelAppearance_PreUpdate(this);
        }
 }
 
-void CSQCModel_Hook_PostUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{SELFPARAM();
+void CSQCModel_Hook_PostUpdate(entity this, bool isnew, bool isplayer, bool islocalplayer)
+{
        // is it a player model? (shared state)
-       self.isplayermodel = (substring(self.model, 0, 14) == "models/player/" || substring(self.model, 0, 17) == "models/ok_player/" || (substring(self.model, 0, 16) == "models/monsters/" && (self.entnum >= 1 && self.entnum <= maxclients)));
+       this.isplayermodel = (substring(this.model, 0, 14) == "models/player/" || substring(this.model, 0, 17) == "models/ok_player/" || (substring(this.model, 0, 16) == "models/monsters/" && (this.entnum >= 1 && this.entnum <= maxclients)));
 
        // save values set by server
-       if(self.isplayermodel)
+       if(this.isplayermodel)
        {
-               CSQCPlayer_ModelAppearance_PostUpdate();
+               CSQCPlayer_ModelAppearance_PostUpdate(this);
                if(isplayer)
-                       CSQCPlayer_AnimDecide_PostUpdate(isnew);
+                       CSQCPlayer_AnimDecide_PostUpdate(this, isnew);
                else
-                       CSQCPlayer_FallbackFrame_PostUpdate(isnew);
+                       CSQCPlayer_FallbackFrame_PostUpdate(this, isnew);
        }
-       CSQCModel_Effects_PostUpdate();
+       CSQCModel_Effects_PostUpdate(this);
 }
index 3e959b0..d3db0eb 100644 (file)
@@ -95,7 +95,7 @@ float ticrate;
 const float MIN_DAMAGEEXTRARADIUS = 2;
 const float MAX_DAMAGEEXTRARADIUS = 16;
 .float damageextraradius;
-.void(float thisdmg, int hittype, vector org, vector thisforce) event_damage;
+.void(entity this, float thisdmg, int hittype, vector org, vector thisforce) event_damage;
 
 // only for Porto
 float angles_held_status;
index 7b1aed1..b0f2b9e 100644 (file)
@@ -418,7 +418,7 @@ void HUD_Vehicle()
        if(hud == HUD_BUMBLEBEE_GUN)
                CSQC_BUMBLE_GUN_HUD();
        else {
-               Vehicle info = get_vehicleinfo(hud);
+               Vehicle info = Vehicles_from(hud);
                info.vr_hud(info);
        }
 }
index 96343d6..6c0621f 100644 (file)
@@ -141,7 +141,7 @@ void HUD_Ammo()
        columns = ceil((total_ammo_count)/rows);
        ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
 
-       vector offset = '0 0 0'; // fteqcc sucks
+       vector offset = '0 0 0';
        float newSize;
        if(ammo_size.x/ammo_size.y > 3)
        {
index 9cfebb8..19cfb55 100644 (file)
@@ -336,16 +336,16 @@ void HUD_Weapons()
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                // retrieve information about the current weapon to be drawn
-               setself(weaponorder[i]);
-               weapon_id = self.impulse;
-               isCurrent = (self == switchweapon);
+               entity it = weaponorder[i];
+               weapon_id = it.impulse;
+               isCurrent = (it == switchweapon);
 
                // skip if this weapon doesn't exist
-               if(!self || weapon_id < 0) { continue; }
+               if(!it || weapon_id < 0) { continue; }
 
                // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
                if(autocvar_hud_panel_weapons_onlyowned)
-               if (!((weapons_stat & WepSet_FromWeapon(self)) || (self.m_id == complain_weapon)))
+               if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon)))
                        continue;
 
                // figure out the drawing position of weapon
@@ -360,7 +360,7 @@ void HUD_Weapons()
                // draw the weapon accuracy
                if(autocvar_hud_panel_weapons_accuracy)
                {
-                       float panel_weapon_accuracy = weapon_accuracy[self.m_id-WEP_FIRST];
+                       float panel_weapon_accuracy = weapon_accuracy[it.m_id-WEP_FIRST];
                        if(panel_weapon_accuracy >= 0)
                        {
                                color = Accuracy_GetColor(panel_weapon_accuracy);
@@ -369,13 +369,13 @@ void HUD_Weapons()
                }
 
                // drawing all the weapon items
-               if(weapons_stat & WepSet_FromWeapon(self))
+               if(weapons_stat & WepSet_FromWeapon(it))
                {
                        // draw the weapon image
                        if(isCurrent)
-                               drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(weapon_pos, it.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                        else
-                               drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
 
                        // draw weapon label string
                        switch(autocvar_hud_panel_weapons_label)
@@ -389,7 +389,7 @@ void HUD_Weapons()
                                        break;
 
                                case 3: // weapon name
-                                       drawstring(weapon_pos, strtolower(self.m_name), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, strtolower(it.m_name), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
 
                                default: // nothing
@@ -397,14 +397,14 @@ void HUD_Weapons()
                        }
 
                        // draw ammo status bar
-                       if(autocvar_hud_panel_weapons_ammo && (self.ammo_field != ammo_none))
+                       if(autocvar_hud_panel_weapons_ammo && (it.ammo_field != ammo_none))
                        {
                                float ammo_full;
-                               a = getstati(GetAmmoStat(self.ammo_field)); // how much ammo do we have?
+                               a = getstati(GetAmmoStat(it.ammo_field)); // how much ammo do we have?
 
                                if(a > 0)
                                {
-                                       switch(self.ammo_field)
+                                       switch(it.ammo_field)
                                        {
                                                case ammo_shells:  ammo_full = autocvar_hud_panel_weapons_ammo_full_shells;  break;
                                                case ammo_nails:   ammo_full = autocvar_hud_panel_weapons_ammo_full_nails;   break;
@@ -437,11 +437,11 @@ void HUD_Weapons()
                }
                else // draw a "ghost weapon icon" if you don't have the weapon
                {
-                       drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
                }
 
                // draw the complain message
-               if(self.m_id == complain_weapon)
+               if(it.m_id == complain_weapon)
                {
                        if(fadetime)
                                a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
index a1cb0c3..7682198 100644 (file)
@@ -327,11 +327,23 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 // --------------------------------------------------------------------------
 // BEGIN OPTIONAL CSQC FUNCTIONS
 
-void Ent_Remove();
-
-void Ent_RemovePlayerScore()
+.void(entity) predraw_qc;
+void PreDraw_self()
 {
        SELFPARAM();
+       if (this.predraw_qc) this.predraw_qc(this);
+}
+
+void setpredraw(entity this, void(entity) pdfunc)
+{
+       this.predraw = PreDraw_self;
+       this.predraw_qc = pdfunc;
+}
+
+void Ent_Remove(entity this);
+
+void Ent_RemovePlayerScore(entity this)
+{
        if(this.owner) {
                SetTeam(this.owner, -1);
                this.owner.gotscores = 0;
@@ -359,7 +371,7 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
                //print("A CSQC entity changed its owner!\n");
                LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
                isNew = true;
-               Ent_Remove();
+               Ent_Remove(this);
        }
 #endif
 
@@ -736,7 +748,7 @@ void CSQC_Ent_Update(bool isnew)
                if (t != this.enttype || isnew)
                {
                        LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
-                       Ent_Remove();
+                       Ent_Remove(this);
                        clearentity(this);
                        isnew = true;
                }
@@ -769,10 +781,9 @@ void CSQC_Ent_Update(bool isnew)
 // Destructor, but does NOT deallocate the entity by calling remove(). Also
 // used when an entity changes its type. For an entity that someone interacts
 // with others, make sure it can no longer do so.
-void Ent_Remove()
+void Ent_Remove(entity this)
 {
-       SELFPARAM();
-       if(this.entremove) this.entremove();
+       if(this.entremove) this.entremove(this);
 
        if(this.skeletonindex)
        {
@@ -802,7 +813,7 @@ void CSQC_Ent_Remove()
                LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
                return;
        }
-       if (this.enttype) Ent_Remove();
+       if (this.enttype) Ent_Remove(this);
        remove(this);
 }
 
index 6a0285d..31db3f8 100644 (file)
@@ -14,6 +14,8 @@ const float DATABUF_PING = 0;
 
 #define DATABUF_NEXT (5*maxclients)
 
+void setpredraw(entity this, void(entity) pdfunc);
+
 // --------------------------------------------------------------------------
 // Onslaught
 
@@ -87,7 +89,7 @@ entity teamslots[17];    // 17 teams (including "spectator team")
 
 .void(entity) draw;
 .void(entity) draw2d;
-.void() entremove;
+.void(entity) entremove;
 float drawframetime;
 vector view_origin, view_forward, view_right, view_up;
 
index 48d0843..30c938a 100644 (file)
@@ -853,7 +853,7 @@ void MapVote_UpdateVotes()
 
 NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew)
 {
-       make_pure(self);
+       make_pure(this);
        int sf = ReadByte();
        return = true;
 
index d6b2b0d..7fa065c 100644 (file)
@@ -176,14 +176,14 @@ void skeleton_from_frames(entity e, float is_dead)
 
        if(!is_dead)
        {
-               if(self == csqcplayer)
-                       self.v_angle_x = input_angles_x;
+               if(e == csqcplayer)
+                       e.v_angle_x = input_angles_x;
                int i;
                for(i = 0; i < MAX_AIM_BONES; ++i)
                {
                        if(e.(bone_aim[i]))
                        {
-                               vector aim = '1 0 0' * bound(-90, self.v_angle.x, 90) * e.(bone_aimweight[i]);
+                               vector aim = '1 0 0' * bound(-90, e.v_angle.x, 90) * e.(bone_aimweight[i]);
                                vector org = skel_get_boneabs(s, e.(bone_aim[i]));
                                vector ang_cur = fixedvectoangles2(v_forward, v_up);
                                vector ang = AnglesTransform_Multiply(aim, ang_cur);
index 050944d..826083b 100644 (file)
@@ -8,14 +8,14 @@
 
 #include "../lib/csqcmodel/cl_model.qh"
 
-// self.isactive = player is in range and coordinates/status (health and armor) are up to date
-// self.origin = player origin
-// self.healthvalue
-// self.armorvalue
-// self.sameteam = player is on same team as local client
-// self.fadedelay = time to wait before name tag starts fading in for enemies
-// self.pointtime = last time you pointed at this player
-// self.csqcmodel_isdead = value of csqcmodel_isdead to know when the player is dead or not
+// this.isactive = player is in range and coordinates/status (health and armor) are up to date
+// this.origin = player origin
+// this.healthvalue
+// this.armorvalue
+// this.sameteam = player is on same team as local client
+// this.fadedelay = time to wait before name tag starts fading in for enemies
+// this.pointtime = last time you pointed at this player
+// this.csqcmodel_isdead = value of csqcmodel_isdead to know when the player is dead or not
 
 LinkedList shownames_ent;
 STATIC_INIT(shownames_ent)
index a745bcd..96fd5ee 100644 (file)
@@ -198,29 +198,29 @@ NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
 {
        int sendflags = ReadByte();
 
-       InterpolateOrigin_Undo(self);
+       InterpolateOrigin_Undo(this);
 
-       self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
-       self.classname = "radarlink";
+       this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+       this.classname = "radarlink";
 
        if(sendflags & 1)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+               setorigin(this, this.origin);
        }
 
        if(sendflags & 2)
        {
-               self.velocity_x = ReadCoord();
-               self.velocity_y = ReadCoord();
-               self.velocity_z = ReadCoord();
+               this.velocity_x = ReadCoord();
+               this.velocity_y = ReadCoord();
+               this.velocity_z = ReadCoord();
        }
 
        if(sendflags & 4)
        {
-               self.team = ReadByte();
+               this.team = ReadByte();
        }
 
        return = true;
index 207a468..4eab4c5 100644 (file)
@@ -293,7 +293,7 @@ void viewmodel_draw(entity this)
                e.colormap = 256 + c;  // colormap == 0 is black, c == 0 is white
                e.glowmod = g;
                e.csqcmodel_effects = fx;
-               WITH(entity, self, e, CSQCModel_Effects_Apply());
+               CSQCModel_Effects_Apply(e);
        }
        {
                static string name_last;
@@ -745,19 +745,19 @@ vector liquidcolor_prev;
 
 float eventchase_current_distance;
 float eventchase_running;
-bool WantEventchase()
-{SELFPARAM();
+bool WantEventchase(entity this)
+{
        if(autocvar_cl_orthoview)
                return false;
        if(intermission)
                return true;
-       if(self.viewloc)
+       if(this.viewloc)
                return true;
        if(spectatee_status >= 0)
        {
                if(hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0))
                        return true;
-               if(MUTATOR_CALLHOOK(WantEventchase, self))
+               if(MUTATOR_CALLHOOK(WantEventchase, this))
                        return true;
                if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
                        return true;
@@ -766,7 +766,7 @@ bool WantEventchase()
                        if(autocvar_cl_eventchase_death == 2)
                        {
                                // don't stop eventchase once it's started (even if velocity changes afterwards)
-                               if(self.velocity == '0 0 0' || eventchase_running)
+                               if(this.velocity == '0 0 0' || eventchase_running)
                                        return true;
                        }
                        else return true;
@@ -779,7 +779,7 @@ void HUD_Crosshair_Vehicle()
 {
        if(hud != HUD_BUMBLEBEE_GUN)
        {
-               Vehicle info = get_vehicleinfo(hud);
+               Vehicle info = Vehicles_from(hud);
                info.vr_crosshair(info);
        }
 }
@@ -864,7 +864,7 @@ void HUD_Crosshair()
 {SELFPARAM();
        static float rainbow_last_flicker;
        static vector rainbow_prev_color;
-       entity e = self;
+       entity e = this;
        float f, i, j;
        vector v;
        if(!scoreboard_active && !camera_active && intermission != 2 &&
@@ -1404,8 +1404,8 @@ void CSQC_UpdateView(float w, float h)
        else
                view_quality = 1;
 
-       button_attack2 = PHYS_INPUT_BUTTON_ATCK2(self);
-       button_zoom = PHYS_INPUT_BUTTON_ZOOM(self);
+       button_attack2 = PHYS_INPUT_BUTTON_ATCK2(this);
+       button_zoom = PHYS_INPUT_BUTTON_ZOOM(this);
 
        vf_size = getpropertyvec(VF_SIZE);
        vf_min = getpropertyvec(VF_MIN);
@@ -1459,6 +1459,19 @@ void CSQC_UpdateView(float w, float h)
                float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST));
                entity gen = world;
 
+               float vehicle_viewdist = 0;
+               vector vehicle_viewofs = '0 0 0';
+
+               if(vehicle_chase)
+               {
+                       if(hud != HUD_BUMBLEBEE_GUN)
+                       {
+                               Vehicle info = Vehicles_from(hud);
+                               vehicle_viewdist = info.height;
+                               vehicle_viewofs = info.view_ofs;
+                       }
+               }
+
                if(ons_roundlost)
                {
                        FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, LAMBDA(
@@ -1468,17 +1481,27 @@ void CSQC_UpdateView(float w, float h)
                        if(!gen)
                                ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
                }
-               if(WantEventchase() || (!autocvar_cl_orthoview && ons_roundlost))
+               if(WantEventchase(self) || (!autocvar_cl_orthoview && ons_roundlost))
                {
                        eventchase_running = true;
 
+                       entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1));
+                       if(!local_player)
+                               local_player = self; // fall back!
+
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
                        if(ons_roundlost) { current_view_origin = gen.origin; }
 
                        // detect maximum viewoffset and use it
                        vector view_offset = autocvar_cl_eventchase_viewoffset;
-                       if(vehicle_chase && autocvar_cl_eventchase_vehicle_viewoffset) { view_offset = autocvar_cl_eventchase_vehicle_viewoffset; }
+                       if(vehicle_chase)
+                       {
+                               if(vehicle_viewofs)
+                                       view_offset = vehicle_viewofs;
+                               else
+                                       view_offset = autocvar_cl_eventchase_vehicle_viewoffset;
+                       }
                        if(ons_roundlost) { view_offset = autocvar_cl_eventchase_generator_viewoffset; }
 
                        if(view_offset)
@@ -1495,7 +1518,13 @@ void CSQC_UpdateView(float w, float h)
 
                        // make the camera smooth back
                        float chase_distance = autocvar_cl_eventchase_distance;
-                       if(vehicle_chase && autocvar_cl_eventchase_vehicle_distance) { chase_distance = autocvar_cl_eventchase_vehicle_distance; }
+                       if(vehicle_chase)
+                       {
+                               if(vehicle_viewofs)
+                                       chase_distance = vehicle_viewdist;
+                               else
+                                       chase_distance = autocvar_cl_eventchase_vehicle_distance;
+                       }
                        if(ons_roundlost) { chase_distance = autocvar_cl_eventchase_generator_distance; }
 
                        if(autocvar_cl_eventchase_speed && eventchase_current_distance < chase_distance)
@@ -1509,7 +1538,7 @@ void CSQC_UpdateView(float w, float h)
                        WarpZone_TraceBox(current_view_origin, autocvar_cl_eventchase_mins, autocvar_cl_eventchase_maxs, eventchase_target_origin, MOVE_WORLDONLY, self);
 
                        // If the boxtrace fails, revert back to line tracing.
-                       if(!self.viewloc)
+                       if(!local_player.viewloc)
                        if(trace_startsolid)
                        {
                                eventchase_target_origin = (current_view_origin - (v_forward * eventchase_current_distance));
@@ -1518,7 +1547,7 @@ void CSQC_UpdateView(float w, float h)
                        }
                        else { setproperty(VF_ORIGIN, trace_endpos); }
 
-                       if(!self.viewloc)
+                       if(!local_player.viewloc)
                                setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
                }
                else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
@@ -1810,7 +1839,7 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       FOREACH_ENTITY(it.draw, LAMBDA(WITH(entity, self, it, it.draw(it))));
+       FOREACH_ENTITY(it.draw, LAMBDA(it.draw(it)));
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -2140,7 +2169,7 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       FOREACH_ENTITY(it.draw2d, LAMBDA(WITH(entity, self, it, it.draw2d(it))));
+       FOREACH_ENTITY(it.draw2d, LAMBDA(it.draw2d(it)));
        Draw_ShowNames_All();
        Debug_Draw();
 
index f83c70c..b94fddd 100644 (file)
@@ -9,44 +9,44 @@
 .float scale;
 .vector movedir;
 
-void Ent_Wall_PreDraw()
-{SELFPARAM();
-       if (self.inactive)
+void Ent_Wall_PreDraw(entity this)
+{
+       if (this.inactive)
        {
-               self.alpha = 0;
+               this.alpha = 0;
        }
        else
        {
                vector org = getpropertyvec(VF_ORIGIN);
-               if(!checkpvs(org, self))
-                       self.alpha = 0;
-               else if(self.fade_start || self.fade_end) {
+               if(!checkpvs(org, this))
+                       this.alpha = 0;
+               else if(this.fade_start || this.fade_end) {
                        vector offset = '0 0 0';
-                       offset_z = self.fade_vertical_offset;
-                       float player_dist = vlen(org - self.origin - 0.5 * (self.mins + self.maxs) + offset);
-                       if (self.fade_end == self.fade_start)
+                       offset_z = this.fade_vertical_offset;
+                       float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset);
+                       if (this.fade_end == this.fade_start)
                        {
-                               if (player_dist >= self.fade_start)
-                                       self.alpha = 0;
+                               if (player_dist >= this.fade_start)
+                                       this.alpha = 0;
                                else
-                                       self.alpha = 1;
+                                       this.alpha = 1;
                        }
                        else
                        {
-                               self.alpha = (self.alpha_min + self.alpha_max * bound(0,
-                                                          (self.fade_end - player_dist)
-                                                          / (self.fade_end - self.fade_start), 1)) / 100.0;
+                               this.alpha = (this.alpha_min + this.alpha_max * bound(0,
+                                                          (this.fade_end - player_dist)
+                                                          / (this.fade_end - this.fade_start), 1)) / 100.0;
                        }
                }
                else
                {
-                       self.alpha = 1;
+                       this.alpha = 1;
                }
        }
-       if(self.alpha <= 0)
-               self.drawmask = 0;
+       if(this.alpha <= 0)
+               this.drawmask = 0;
        else
-               self.drawmask = MASK_NORMAL;
+               this.drawmask = MASK_NORMAL;
 }
 
 void Ent_Wall_Draw(entity this)
@@ -54,64 +54,64 @@ void Ent_Wall_Draw(entity this)
        float f;
        var .vector fld;
 
-       if(self.bgmscriptangular)
+       if(this.bgmscriptangular)
                fld = angles;
        else
                fld = origin;
-       self.(fld) = self.saved;
+       this.(fld) = this.saved;
 
-       if(self.lodmodelindex1)
+       if(this.lodmodelindex1)
        {
                if(autocvar_cl_modeldetailreduction <= 0)
                {
-                       if(self.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
-                               self.modelindex = self.lodmodelindex2;
+                       if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
+                               this.modelindex = this.lodmodelindex2;
                        else if(autocvar_cl_modeldetailreduction <= -1)
-                               self.modelindex = self.lodmodelindex1;
+                               this.modelindex = this.lodmodelindex1;
                        else
-                               self.modelindex = self.lodmodelindex0;
+                               this.modelindex = this.lodmodelindex0;
                }
                else
                {
-                       float distance = vlen(NearestPointOnBox(self, view_origin) - view_origin);
+                       float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin);
                        f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
                        f *= 1.0 / bound(0.01, view_quality, 1);
-                       if(self.lodmodelindex2 && f > self.loddistance2)
-                               self.modelindex = self.lodmodelindex2;
-                       else if(f > self.loddistance1)
-                               self.modelindex = self.lodmodelindex1;
+                       if(this.lodmodelindex2 && f > this.loddistance2)
+                               this.modelindex = this.lodmodelindex2;
+                       else if(f > this.loddistance1)
+                               this.modelindex = this.lodmodelindex1;
                        else
-                               self.modelindex = self.lodmodelindex0;
+                               this.modelindex = this.lodmodelindex0;
                }
        }
 
-       InterpolateOrigin_Do(self);
+       InterpolateOrigin_Do(this);
 
-       self.saved = self.(fld);
+       this.saved = this.(fld);
 
-       f = doBGMScript(self);
+       f = doBGMScript(this);
        if(f >= 0)
        {
-               if(self.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
-                       self.alpha = 1 + self.lip * f;
+               if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
+                       this.alpha = 1 + this.lip * f;
                else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
-                       self.alpha = 1 - self.lip * (1 - f);
-               self.(fld) = self.(fld) + self.movedir * f;
+                       this.alpha = 1 - this.lip * (1 - f);
+               this.(fld) = this.(fld) + this.movedir * f;
        }
        else
-               self.alpha = 1;
+               this.alpha = 1;
 
-       if(self.alpha >= ALPHA_MIN_VISIBLE)
-               self.drawmask = MASK_NORMAL;
+       if(this.alpha >= ALPHA_MIN_VISIBLE)
+               this.drawmask = MASK_NORMAL;
        else
-               self.drawmask = 0;
+               this.drawmask = 0;
 }
 
-void Ent_Wall_Remove()
-{SELFPARAM();
-       if(self.bgmscript)
-               strunzone(self.bgmscript);
-       self.bgmscript = string_null;
+void Ent_Wall_Remove(entity this)
+{
+       if(this.bgmscript)
+               strunzone(this.bgmscript);
+       this.bgmscript = string_null;
 }
 
 NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
@@ -119,116 +119,116 @@ NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
        int f;
        var .vector fld;
 
-       InterpolateOrigin_Undo(self);
-       self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
+       InterpolateOrigin_Undo(this);
+       this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
 
-       if(self.bgmscriptangular)
+       if(this.bgmscriptangular)
                fld = angles;
        else
                fld = origin;
-       self.(fld) = self.saved;
+       this.(fld) = this.saved;
 
        f = ReadByte();
 
        if(f & 1)
        {
                if(f & 0x40)
-                       self.colormap = ReadShort();
+                       this.colormap = ReadShort();
                else
-                       self.colormap = 0;
+                       this.colormap = 0;
        }
 
        if(f & 2)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+               setorigin(this, this.origin);
        }
 
        if(f & 4)
        {
                if(f & 0x10)
                {
-                       self.angles_x = ReadAngle();
-                       self.angles_y = ReadAngle();
-                       self.angles_z = ReadAngle();
+                       this.angles_x = ReadAngle();
+                       this.angles_y = ReadAngle();
+                       this.angles_z = ReadAngle();
                }
                else
-                       self.angles = '0 0 0';
+                       this.angles = '0 0 0';
        }
 
        if(f & 8)
        {
                if(f & 0x80)
                {
-                       self.lodmodelindex0 = ReadShort();
-                       self.loddistance1 = ReadShort();
-                       self.lodmodelindex1 = ReadShort();
-                       self.loddistance2 = ReadShort();
-                       self.lodmodelindex2 = ReadShort();
+                       this.lodmodelindex0 = ReadShort();
+                       this.loddistance1 = ReadShort();
+                       this.lodmodelindex1 = ReadShort();
+                       this.loddistance2 = ReadShort();
+                       this.lodmodelindex2 = ReadShort();
                }
                else
                {
-                       self.modelindex = ReadShort();
-                       self.loddistance1 = 0;
-                       self.loddistance2 = 0;
+                       this.modelindex = ReadShort();
+                       this.loddistance1 = 0;
+                       this.loddistance2 = 0;
                }
-               self.solid = ReadByte();
-               self.scale = ReadShort() / 256.0;
+               this.solid = ReadByte();
+               this.scale = ReadShort() / 256.0;
                if(f & 0x20)
                {
-                       self.mins_x = ReadCoord();
-                       self.mins_y = ReadCoord();
-                       self.mins_z = ReadCoord();
-                       self.maxs_x = ReadCoord();
-                       self.maxs_y = ReadCoord();
-                       self.maxs_z = ReadCoord();
+                       this.mins_x = ReadCoord();
+                       this.mins_y = ReadCoord();
+                       this.mins_z = ReadCoord();
+                       this.maxs_x = ReadCoord();
+                       this.maxs_y = ReadCoord();
+                       this.maxs_z = ReadCoord();
                }
                else
-                       self.mins = self.maxs = '0 0 0';
-               setsize(self, self.mins, self.maxs);
+                       this.mins = this.maxs = '0 0 0';
+               setsize(this, this.mins, this.maxs);
 
-               if(self.bgmscript)
-                       strunzone(self.bgmscript);
-               self.bgmscript = ReadString();
-               if(substring(self.bgmscript, 0, 1) == "<")
+               if(this.bgmscript)
+                       strunzone(this.bgmscript);
+               this.bgmscript = ReadString();
+               if(substring(this.bgmscript, 0, 1) == "<")
                {
-                       self.bgmscript = strzone(substring(self.bgmscript, 1, -1));
-                       self.bgmscriptangular = 1;
+                       this.bgmscript = strzone(substring(this.bgmscript, 1, -1));
+                       this.bgmscriptangular = 1;
                }
                else
                {
-                       self.bgmscript = strzone(self.bgmscript);
-                       self.bgmscriptangular = 0;
+                       this.bgmscript = strzone(this.bgmscript);
+                       this.bgmscriptangular = 0;
                }
-               if(self.bgmscript != "")
+               if(this.bgmscript != "")
                {
-                       self.bgmscriptattack = ReadByte() / 64.0;
-                       self.bgmscriptdecay = ReadByte() / 64.0;
-                       self.bgmscriptsustain = ReadByte() / 255.0;
-                       self.bgmscriptrelease = ReadByte() / 64.0;
-                       self.movedir_x = ReadCoord();
-                       self.movedir_y = ReadCoord();
-                       self.movedir_z = ReadCoord();
-                       self.lip = ReadByte() / 255.0;
+                       this.bgmscriptattack = ReadByte() / 64.0;
+                       this.bgmscriptdecay = ReadByte() / 64.0;
+                       this.bgmscriptsustain = ReadByte() / 255.0;
+                       this.bgmscriptrelease = ReadByte() / 64.0;
+                       this.movedir_x = ReadCoord();
+                       this.movedir_y = ReadCoord();
+                       this.movedir_z = ReadCoord();
+                       this.lip = ReadByte() / 255.0;
                }
-               self.fade_start = ReadShort();
-               self.fade_end = ReadShort();
-               self.alpha_max = ReadShort();
-               self.alpha_min = ReadShort();
-               self.inactive = ReadShort();
-               self.fade_vertical_offset = ReadShort();
-               BGMScript_InitEntity(self);
+               this.fade_start = ReadShort();
+               this.fade_end = ReadShort();
+               this.alpha_max = ReadShort();
+               this.alpha_min = ReadShort();
+               this.inactive = ReadShort();
+               this.fade_vertical_offset = ReadShort();
+               BGMScript_InitEntity(this);
        }
 
        return = true;
 
        InterpolateOrigin_Note(this);
 
-       self.saved = self.(fld);
+       this.saved = this.(fld);
 
-       self.entremove = Ent_Wall_Remove;
-       self.draw = Ent_Wall_Draw;
-       self.predraw = Ent_Wall_PreDraw;
+       this.entremove = Ent_Wall_Remove;
+       this.draw = Ent_Wall_Draw;
+       setpredraw(this, Ent_Wall_PreDraw);
 }
index 16f87fd..f93eb3a 100644 (file)
@@ -18,6 +18,6 @@ class(Wall) .vector saved;
 
 void Ent_Wall_Draw(entity this);
 
-void Ent_Wall_Remove();
+void Ent_Wall_Remove(entity this);
 
 #endif
index 4ebe4af..c0f644b 100644 (file)
 .float scale;
 .vector colormod;
 
-void SUB_Stop()
+void SUB_Stop(entity this)
+{
+       this.move_velocity = this.move_avelocity = '0 0 0';
+       this.move_movetype = MOVETYPE_NONE;
+}
+
+void SUB_Stop_self()
 {
        SELFPARAM();
-       self.move_velocity = self.move_avelocity = '0 0 0';
-       self.move_movetype = MOVETYPE_NONE;
+       SUB_Stop(this);
 }
 
 void Projectile_ResetTrail(entity this, vector to)
@@ -59,44 +64,44 @@ void Projectile_Draw(entity this)
        float t;
        float a;
 
-       f = self.move_flags;
+       f = this.move_flags;
 
-       if (self.count & 0x80)
+       if (this.count & 0x80)
        {
-               // self.move_flags &= ~FL_ONGROUND;
-               if (self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
-                       Movetype_Physics_NoMatchServer(self);
+               // this.move_flags &= ~FL_ONGROUND;
+               if (this.move_movetype == MOVETYPE_NONE || this.move_movetype == MOVETYPE_FLY)
+                       Movetype_Physics_NoMatchServer(this);
                // the trivial movetypes do not have to match the
                // server's ticrate as they are ticrate independent
                // NOTE: this assumption is only true if MOVETYPE_FLY
                // projectiles detonate on impact. If they continue
                // moving, we might still be ticrate dependent.
                else
-                       Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
-               if (!(self.move_flags & FL_ONGROUND))
-                       if (self.velocity != '0 0 0')
-                               self.move_angles = self.angles = vectoangles(self.velocity);
+                       Movetype_Physics_MatchServer(this, autocvar_cl_projectiles_sloppy);
+               if (!(this.move_flags & FL_ONGROUND))
+                       if (this.velocity != '0 0 0')
+                               this.move_angles = this.angles = vectoangles(this.velocity);
        }
        else
        {
-               InterpolateOrigin_Do(self);
+               InterpolateOrigin_Do(this);
        }
 
-       if (self.count & 0x80)
+       if (this.count & 0x80)
        {
-               drawn = (time >= self.spawntime - 0.02);
-               t = max(time, self.spawntime);
+               drawn = (time >= this.spawntime - 0.02);
+               t = max(time, this.spawntime);
        }
        else
        {
-               drawn = (self.iflags & IFLAG_VALID);
+               drawn = (this.iflags & IFLAG_VALID);
                t = time;
        }
 
        if (!(f & FL_ONGROUND))
        {
                rot = '0 0 0';
-               switch (self.cnt)
+               switch (this.cnt)
                {
                        /*
                        case PROJECTILE_GRENADE:
@@ -113,25 +118,25 @@ void Projectile_Draw(entity this)
                                break;
                }
 
-               if (Projectile_isnade(self.cnt))
-                       rot = self.avelocity;
+               if (Projectile_isnade(this.cnt))
+                       rot = this.avelocity;
 
-               self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
+               this.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(this.angles), rot * (t - this.spawntime)));
        }
 
        vector ang;
-       ang = self.angles;
+       ang = this.angles;
        ang.x = -ang.x;
        makevectors(ang);
 
-       a = 1 - (time - self.fade_time) * self.fade_rate;
-       self.alpha = bound(0, self.alphamod * a, 1);
-       if (self.alpha <= 0)
+       a = 1 - (time - this.fade_time) * this.fade_rate;
+       this.alpha = bound(0, this.alphamod * a, 1);
+       if (this.alpha <= 0)
                drawn = 0;
-       self.renderflags = 0;
+       this.renderflags = 0;
 
-       trailorigin = self.origin;
-       switch (self.cnt)
+       trailorigin = this.origin;
+       switch (this.cnt)
        {
                case PROJECTILE_GRENADE:
                case PROJECTILE_GRENADE_BOUNCING:
@@ -141,46 +146,44 @@ void Projectile_Draw(entity this)
                        break;
        }
 
-       if (Projectile_isnade(self.cnt))
+       if (Projectile_isnade(this.cnt))
                trailorigin += v_up * 4;
 
        if (drawn)
-               Projectile_DrawTrail(self, trailorigin);
+               Projectile_DrawTrail(this, trailorigin);
        else
-               Projectile_ResetTrail(self, trailorigin);
+               Projectile_ResetTrail(this, trailorigin);
 
-       self.drawmask = 0;
+       this.drawmask = 0;
 
        if (!drawn)
                return;
 
-       switch (self.cnt)
+       switch (this.cnt)
        {
                // Possibly add dlights here.
                default:
                        break;
        }
 
-       self.drawmask = MASK_NORMAL;
+       this.drawmask = MASK_NORMAL;
 }
 
 void loopsound(entity e, int ch, string samp, float vol, float attn)
 {
-       SELFPARAM();
-       if (self.silent)
+       if (e.silent)
                return;
 
        _sound(e, ch, samp, vol, attn);
        e.snd_looping = ch;
 }
 
-void Ent_RemoveProjectile()
+void Ent_RemoveProjectile(entity this)
 {
-       SELFPARAM();
-       if (self.count & 0x80)
+       if (this.count & 0x80)
        {
-               tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
-               Projectile_DrawTrail(self, trace_endpos);
+               tracebox(this.origin, this.mins, this.maxs, this.origin + this.velocity * 0.05, MOVE_NORMAL, this);
+               Projectile_DrawTrail(this, trace_endpos);
        }
 }
 
@@ -201,286 +204,286 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
        // projectiles don't send angles, because they always follow the velocity
 
        int f = ReadByte();
-       self.count = (f & 0x80);
-       self.flags |= FL_PROJECTILE;
-       self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN;
-       self.solid = SOLID_TRIGGER;
-       // self.effects = EF_NOMODELFLAGS;
+       this.count = (f & 0x80);
+       this.flags |= FL_PROJECTILE;
+       this.iflags = (this.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN;
+       this.solid = SOLID_TRIGGER;
+       // this.effects = EF_NOMODELFLAGS;
 
        // this should make collisions with bmodels more exact, but it leads to
        // projectiles no longer being able to lie on a bmodel
-       self.move_nomonsters = MOVE_WORLDONLY;
+       this.move_nomonsters = MOVE_WORLDONLY;
        if (f & 0x40)
-               self.move_flags |= FL_ONGROUND;
+               this.move_flags |= FL_ONGROUND;
        else
-               self.move_flags &= ~FL_ONGROUND;
+               this.move_flags &= ~FL_ONGROUND;
 
-       if (!self.move_time)
+       if (!this.move_time)
        {
                // for some unknown reason, we don't need to care for
                // sv_gameplayfix_delayprojectiles here.
-               self.move_time = time;
-               self.spawntime = time;
+               this.move_time = time;
+               this.spawntime = time;
        }
        else
        {
-               self.move_time = max(self.move_time, time);
+               this.move_time = max(this.move_time, time);
        }
 
-       if (!(self.count & 0x80))
-               InterpolateOrigin_Undo(self);
+       if (!(this.count & 0x80))
+               InterpolateOrigin_Undo(this);
 
        if (f & 1)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
-               if (self.count & 0x80)
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+               setorigin(this, this.origin);
+               if (this.count & 0x80)
                {
-                       self.velocity_x = ReadCoord();
-                       self.velocity_y = ReadCoord();
-                       self.velocity_z = ReadCoord();
+                       this.velocity_x = ReadCoord();
+                       this.velocity_y = ReadCoord();
+                       this.velocity_z = ReadCoord();
                        if (f & 0x10)
-                               self.gravity = ReadCoord();
+                               this.gravity = ReadCoord();
                        else
-                               self.gravity = 0;  // none
-                       self.move_origin = self.origin;
-                       self.move_velocity = self.velocity;
+                               this.gravity = 0;  // none
+                       this.move_origin = this.origin;
+                       this.move_velocity = this.velocity;
                }
 
-               if (time == self.spawntime || (self.count & 0x80) || (f & 0x08))
+               if (time == this.spawntime || (this.count & 0x80) || (f & 0x08))
                {
-                       self.trail_oldorigin = self.origin;
-                       if (!(self.count & 0x80))
-                               InterpolateOrigin_Reset();
+                       this.trail_oldorigin = this.origin;
+                       if (!(this.count & 0x80))
+                               InterpolateOrigin_Reset(this);
                }
 
                if (f & 0x20)
                {
-                       self.fade_time = time + ReadByte() * ticrate;
-                       self.fade_rate = 1 / (ReadByte() * ticrate);
+                       this.fade_time = time + ReadByte() * ticrate;
+                       this.fade_rate = 1 / (ReadByte() * ticrate);
                }
                else
                {
-                       self.fade_time = 0;
-                       self.fade_rate = 0;
+                       this.fade_time = 0;
+                       this.fade_rate = 0;
                }
 
-               self.team = ReadByte() - 1;
+               this.team = ReadByte() - 1;
        }
 
        if (f & 2)
        {
-               self.cnt = ReadByte();
+               this.cnt = ReadByte();
 
-               self.silent = (self.cnt & 0x80);
-               self.cnt = (self.cnt & 0x7F);
+               this.silent = (this.cnt & 0x80);
+               this.cnt = (this.cnt & 0x7F);
 
-               self.scale = 1;
-               self.traileffect = 0;
-               switch (self.cnt)
+               this.scale = 1;
+               this.traileffect = 0;
+               switch (this.cnt)
                {
-                       #define HANDLE(id) case PROJECTILE_##id: setmodel(self, MDL_PROJECTILE_##id);
-                       HANDLE(ELECTRO)            self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-                       HANDLE(ROCKET)             self.traileffect = EFFECT_TR_ROCKET.m_id; self.scale = 2; break;
-                       HANDLE(CRYLINK)            self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
-                       HANDLE(CRYLINK_BOUNCING)   self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
-                       HANDLE(ELECTRO_BEAM)       self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-                       HANDLE(GRENADE)            self.traileffect = EFFECT_TR_GRENADE.m_id; break;
-                       HANDLE(GRENADE_BOUNCING)   self.traileffect = EFFECT_TR_GRENADE.m_id; break;
-                       HANDLE(MINE)               self.traileffect = EFFECT_TR_GRENADE.m_id; break;
-                       HANDLE(BLASTER)            self.traileffect = EFFECT_Null.m_id; break;
-                       HANDLE(HLAC)               self.traileffect = EFFECT_Null.m_id; break;
-                       HANDLE(PORTO_RED)          self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
-                       HANDLE(PORTO_BLUE)         self.traileffect = EFFECT_TR_WIZSPIKE.m_id; self.scale = 4; break;
-                       HANDLE(HOOKBOMB)           self.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
-                       HANDLE(HAGAR)              self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
-                       HANDLE(HAGAR_BOUNCING)     self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break;
-                       HANDLE(FIREBALL)           self.modelindex = 0; self.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
-                       HANDLE(FIREMINE)           self.modelindex = 0; self.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
-                       HANDLE(TAG)                self.traileffect = EFFECT_TR_ROCKET.m_id; break;
-                       HANDLE(FLAC)               self.scale = 0.4; self.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
-                       HANDLE(SEEKER)             self.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
-
-                       HANDLE(MAGE_SPIKE)         self.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
-                       HANDLE(SHAMBLER_LIGHTNING) self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-
-                       HANDLE(RAPTORBOMB)         self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
-                       HANDLE(RAPTORBOMBLET)      self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = EFFECT_Null.m_id; break;
-                       HANDLE(RAPTORCANNON)       self.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
-
-                       HANDLE(SPIDERROCKET)       self.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
-                       HANDLE(WAKIROCKET)         self.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
-                       HANDLE(WAKICANNON)         self.traileffect = EFFECT_Null.m_id; break;
-
-                       HANDLE(BUMBLE_GUN)         self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-                       HANDLE(BUMBLE_BEAM)        self.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
-
-                       HANDLE(RPC)                self.traileffect = EFFECT_TR_ROCKET.m_id; break;
-
-                       HANDLE(ROCKETMINSTA_LASER) self.traileffect = EFFECT_ROCKETMINSTA_LASER(self.team).m_id; break;
+#define HANDLE(id) case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);
+                       HANDLE(ELECTRO)            this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+                       HANDLE(ROCKET)             this.traileffect = EFFECT_TR_ROCKET.m_id; this.scale = 2; break;
+                       HANDLE(CRYLINK)            this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+                       HANDLE(CRYLINK_BOUNCING)   this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+                       HANDLE(ELECTRO_BEAM)       this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+                       HANDLE(GRENADE)            this.traileffect = EFFECT_TR_GRENADE.m_id; break;
+                       HANDLE(GRENADE_BOUNCING)   this.traileffect = EFFECT_TR_GRENADE.m_id; break;
+                       HANDLE(MINE)               this.traileffect = EFFECT_TR_GRENADE.m_id; break;
+                       HANDLE(BLASTER)            this.traileffect = EFFECT_Null.m_id; break;
+                       HANDLE(HLAC)               this.traileffect = EFFECT_Null.m_id; break;
+                       HANDLE(PORTO_RED)          this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
+                       HANDLE(PORTO_BLUE)         this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
+                       HANDLE(HOOKBOMB)           this.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
+                       HANDLE(HAGAR)              this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
+                       HANDLE(HAGAR_BOUNCING)     this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
+                       HANDLE(FIREBALL)           this.modelindex = 0; this.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
+                       HANDLE(FIREMINE)           this.modelindex = 0; this.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
+                       HANDLE(TAG)                this.traileffect = EFFECT_TR_ROCKET.m_id; break;
+                       HANDLE(FLAC)               this.scale = 0.4; this.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
+                       HANDLE(SEEKER)             this.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
+
+                       HANDLE(MAGE_SPIKE)         this.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
+                       HANDLE(SHAMBLER_LIGHTNING) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+
+                       HANDLE(RAPTORBOMB)         this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
+                       HANDLE(RAPTORBOMBLET)      this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
+                       HANDLE(RAPTORCANNON)       this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
+
+                       HANDLE(SPIDERROCKET)       this.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
+                       HANDLE(WAKIROCKET)         this.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
+                       HANDLE(WAKICANNON)         this.traileffect = EFFECT_Null.m_id; break;
+
+                       HANDLE(BUMBLE_GUN)         this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+                       HANDLE(BUMBLE_BEAM)        this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
+
+                       HANDLE(RPC)                this.traileffect = EFFECT_TR_ROCKET.m_id; break;
+
+                       HANDLE(ROCKETMINSTA_LASER) this.traileffect = EFFECT_ROCKETMINSTA_LASER(this.team).m_id; break;
 #undef HANDLE
                        default:
-                               if (MUTATOR_CALLHOOK(Ent_Projectile, self))
+                               if (MUTATOR_CALLHOOK(Ent_Projectile, this))
                                        break;
 
                                error("Received invalid CSQC projectile, can't work with this!");
                                break;
                }
 
-               self.mins = '0 0 0';
-               self.maxs = '0 0 0';
-               self.colormod = '0 0 0';
-               self.move_touch = SUB_Stop;
-               self.move_movetype = MOVETYPE_TOSS;
-               self.alphamod = 1;
+               this.mins = '0 0 0';
+               this.maxs = '0 0 0';
+               this.colormod = '0 0 0';
+               this.move_touch = SUB_Stop_self;
+               this.move_movetype = MOVETYPE_TOSS;
+               this.alphamod = 1;
 
-               switch (self.cnt)
+               switch (this.cnt)
                {
                        case PROJECTILE_ELECTRO:
                                // only new engines support sound moving with object
-                               loopsound(self, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
-                               self.mins = '0 0 -4';
-                               self.maxs = '0 0 -4';
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
-                               self.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
-                               self.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
+                               loopsound(this, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
+                               this.mins = '0 0 -4';
+                               this.maxs = '0 0 -4';
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
+                               this.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
+                               this.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
                                break;
                        case PROJECTILE_RPC:
                        case PROJECTILE_ROCKET:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(ROCKET_FLY), VOL_BASE, ATTEN_NORM);
-                               self.mins = '-3 -3 -3';
-                               self.maxs = '3 3 3';
+                               loopsound(this, CH_SHOTS_SINGLE, SND(ROCKET_FLY), VOL_BASE, ATTEN_NORM);
+                               this.mins = '-3 -3 -3';
+                               this.maxs = '3 3 3';
                                break;
                        case PROJECTILE_GRENADE:
-                               self.mins = '-3 -3 -3';
-                               self.maxs = '3 3 3';
+                               this.mins = '-3 -3 -3';
+                               this.maxs = '3 3 3';
                                break;
                        case PROJECTILE_GRENADE_BOUNCING:
-                               self.mins = '-3 -3 -3';
-                               self.maxs = '3 3 3';
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
-                               self.move_bounce_factor = WEP_CVAR(mortar, bouncefactor);
-                               self.move_bounce_stopspeed = WEP_CVAR(mortar, bouncestop);
+                               this.mins = '-3 -3 -3';
+                               this.maxs = '3 3 3';
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
+                               this.move_bounce_factor = WEP_CVAR(mortar, bouncefactor);
+                               this.move_bounce_stopspeed = WEP_CVAR(mortar, bouncestop);
                                break;
                        case PROJECTILE_SHAMBLER_LIGHTNING:
-                               self.mins = '-8 -8 -8';
-                               self.maxs = '8 8 8';
-                               self.scale = 2.5;
-                               self.avelocity = randomvec() * 720;
+                               this.mins = '-8 -8 -8';
+                               this.maxs = '8 8 8';
+                               this.scale = 2.5;
+                               this.avelocity = randomvec() * 720;
                                break;
                        case PROJECTILE_MINE:
-                               self.mins = '-4 -4 -4';
-                               self.maxs = '4 4 4';
+                               this.mins = '-4 -4 -4';
+                               this.maxs = '4 4 4';
                                break;
                        case PROJECTILE_PORTO_RED:
-                               self.colormod = '2 1 1';
-                               self.alphamod = 0.5;
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
+                               this.colormod = '2 1 1';
+                               this.alphamod = 0.5;
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
                                break;
                        case PROJECTILE_PORTO_BLUE:
-                               self.colormod = '1 1 2';
-                               self.alphamod = 0.5;
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
+                               this.colormod = '1 1 2';
+                               this.alphamod = 0.5;
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
                                break;
                        case PROJECTILE_HAGAR_BOUNCING:
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
                                break;
                        case PROJECTILE_CRYLINK_BOUNCING:
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
                                break;
                        case PROJECTILE_FIREBALL:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
-                               self.mins = '-16 -16 -16';
-                               self.maxs = '16 16 16';
+                               loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
+                               this.mins = '-16 -16 -16';
+                               this.maxs = '16 16 16';
                                break;
                        case PROJECTILE_FIREMINE:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY), VOL_BASE, ATTEN_NORM);
-                               self.move_movetype = MOVETYPE_BOUNCE;
-                               self.move_touch = func_null;
-                               self.mins = '-4 -4 -4';
-                               self.maxs = '4 4 4';
+                               loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY), VOL_BASE, ATTEN_NORM);
+                               this.move_movetype = MOVETYPE_BOUNCE;
+                               this.move_touch = func_null;
+                               this.mins = '-4 -4 -4';
+                               this.maxs = '4 4 4';
                                break;
                        case PROJECTILE_TAG:
-                               self.mins = '-2 -2 -2';
-                               self.maxs = '2 2 2';
+                               this.mins = '-2 -2 -2';
+                               this.maxs = '2 2 2';
                                break;
                        case PROJECTILE_FLAC:
-                               self.mins = '-2 -2 -2';
-                               self.maxs = '2 2 2';
+                               this.mins = '-2 -2 -2';
+                               this.maxs = '2 2 2';
                                break;
                        case PROJECTILE_SEEKER:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
-                               self.mins = '-4 -4 -4';
-                               self.maxs = '4 4 4';
+                               loopsound(this, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
+                               this.mins = '-4 -4 -4';
+                               this.maxs = '4 4 4';
                                break;
                        case PROJECTILE_RAPTORBOMB:
-                               self.mins = '-3 -3 -3';
-                               self.maxs = '3 3 3';
+                               this.mins = '-3 -3 -3';
+                               this.maxs = '3 3 3';
                                break;
                        case PROJECTILE_RAPTORBOMBLET:
                                break;
                        case PROJECTILE_RAPTORCANNON:
                                break;
                        case PROJECTILE_SPIDERROCKET:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
+                               loopsound(this, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                break;
                        case PROJECTILE_WAKIROCKET:
-                               loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
+                               loopsound(this, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                break;
                        /*
                        case PROJECTILE_WAKICANNON:
                            break;
                        case PROJECTILE_BUMBLE_GUN:
                            // only new engines support sound moving with object
-                           loopsound(self, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
-                           self.mins = '0 0 -4';
-                           self.maxs = '0 0 -4';
-                           self.move_movetype = MOVETYPE_BOUNCE;
-                           self.move_touch = func_null;
-                           self.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
-                           self.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
+                           loopsound(this, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
+                           this.mins = '0 0 -4';
+                           this.maxs = '0 0 -4';
+                           this.move_movetype = MOVETYPE_BOUNCE;
+                           this.move_touch = func_null;
+                           this.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
+                           this.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
                            break;
                        */
                        default:
                                break;
                }
 
-               MUTATOR_CALLHOOK(EditProjectile, self);
+               MUTATOR_CALLHOOK(EditProjectile, this);
 
-               setsize(self, self.mins, self.maxs);
+               setsize(this, this.mins, this.maxs);
        }
 
        return = true;
 
-       if (self.gravity)
+       if (this.gravity)
        {
-               if (self.move_movetype == MOVETYPE_FLY)
-                       self.move_movetype = MOVETYPE_TOSS;
-               if (self.move_movetype == MOVETYPE_BOUNCEMISSILE)
-                       self.move_movetype = MOVETYPE_BOUNCE;
+               if (this.move_movetype == MOVETYPE_FLY)
+                       this.move_movetype = MOVETYPE_TOSS;
+               if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
+                       this.move_movetype = MOVETYPE_BOUNCE;
        }
        else
        {
-               if (self.move_movetype == MOVETYPE_TOSS)
-                       self.move_movetype = MOVETYPE_FLY;
-               if (self.move_movetype == MOVETYPE_BOUNCE)
-                       self.move_movetype = MOVETYPE_BOUNCEMISSILE;
+               if (this.move_movetype == MOVETYPE_TOSS)
+                       this.move_movetype = MOVETYPE_FLY;
+               if (this.move_movetype == MOVETYPE_BOUNCE)
+                       this.move_movetype = MOVETYPE_BOUNCEMISSILE;
        }
 
-       if (!(self.count & 0x80))
+       if (!(this.count & 0x80))
                InterpolateOrigin_Note(this);
 
-       self.classname = "csqcprojectile";
-       self.draw = Projectile_Draw;
-       self.entremove = Ent_RemoveProjectile;
+       this.classname = "csqcprojectile";
+       this.draw = Projectile_Draw;
+       this.entremove = Ent_RemoveProjectile;
 }
 
 PRECACHE(Projectiles)
index a925f34..1b0d313 100644 (file)
@@ -17,7 +17,7 @@ class(Projectile).float gravity;
 class(Projectile).int snd_looping;
 class(Projectile).bool silent;
 
-void SUB_Stop();
+void SUB_Stop(entity this);
 
 void Projectile_ResetTrail(entity this, vector to);
 
@@ -27,7 +27,7 @@ void Projectile_Draw(entity this);
 
 void loopsound(entity e, int ch, string samp, float vol, float attn);
 
-void Ent_RemoveProjectile();
+void Ent_RemoveProjectile(entity this);
 
 const int FL_PROJECTILE = BIT(15);
 
index f8561b5..c4b428e 100644 (file)
@@ -7,49 +7,45 @@
     #include "../server/defs.qh"
 #endif
 
-bool monsters_animoverride(entity e)
+bool monsters_animoverride(entity this)
 {
        Monster monster_id = NULL;
-       for(int i = MON_FIRST; i <= MON_LAST; ++i)
-       {
-               entity mon = get_monsterinfo(i);
-
-               //if(substring(e.model, 0, strlen(mon.model) - 4) == substring(mon.model, 0, strlen(mon.model) - 4))
-               if(e.model == mon.model)
+       FOREACH(Monsters, it != WEP_Null, LAMBDA(
+               if(it.model == this.model)
                {
-                       monster_id = mon;
+                       monster_id = it;
                        break;
                }
-       }
+       ));
 
        if(!monster_id) { return false; }
 
-       monster_id.mr_anim(monster_id);
+       monster_id.mr_anim(monster_id, this);
 
        vector none = '0 0 0';
-       e.anim_duckwalk = e.anim_walk;
-       e.anim_duckjump = animfixfps(e, '5 1 10', none);
-       e.anim_duckidle = e.anim_idle;
-       e.anim_jump = animfixfps(e, '8 1 10', none);
-       e.anim_taunt = animfixfps(e, '12 1 0.33', none);
-       e.anim_runbackwards = e.anim_run;
-       e.anim_strafeleft = e.anim_run;
-       e.anim_straferight = e.anim_run;
-       e.anim_forwardright = e.anim_run;
-       e.anim_forwardleft = e.anim_run;
-       e.anim_backright = e.anim_run;
-       e.anim_backleft  = e.anim_run;
-       e.anim_duckwalkbackwards = e.anim_walk;
-       e.anim_duckwalkstrafeleft = e.anim_walk;
-       e.anim_duckwalkstraferight = e.anim_walk;
-       e.anim_duckwalkforwardright = e.anim_walk;
-       e.anim_duckwalkforwardleft = e.anim_walk;
-       e.anim_duckwalkbackright = e.anim_walk;
-       e.anim_duckwalkbackleft  = e.anim_walk;
+       this.anim_duckwalk = this.anim_walk;
+       this.anim_duckjump = animfixfps(this, '5 1 10', none);
+       this.anim_duckidle = this.anim_idle;
+       this.anim_jump = animfixfps(this, '8 1 10', none);
+       this.anim_taunt = animfixfps(this, '12 1 0.33', none);
+       this.anim_runbackwards = this.anim_run;
+       this.anim_strafeleft = this.anim_run;
+       this.anim_straferight = this.anim_run;
+       this.anim_forwardright = this.anim_run;
+       this.anim_forwardleft = this.anim_run;
+       this.anim_backright = this.anim_run;
+       this.anim_backleft  = this.anim_run;
+       this.anim_duckwalkbackwards = this.anim_walk;
+       this.anim_duckwalkstrafeleft = this.anim_walk;
+       this.anim_duckwalkstraferight = this.anim_walk;
+       this.anim_duckwalkforwardright = this.anim_walk;
+       this.anim_duckwalkforwardleft = this.anim_walk;
+       this.anim_duckwalkbackright = this.anim_walk;
+       this.anim_duckwalkbackleft  = this.anim_walk;
 
        // these anims ought to stay until stopped explicitly by weaponsystem
-       e.anim_shoot_z = 0.001;
-       e.anim_melee_z = 0.001;
+       this.anim_shoot_z = 0.001;
+       this.anim_melee_z = 0.001;
 
        return true;
 }
index 378d8c8..5b53592 100644 (file)
@@ -495,7 +495,7 @@ void GenericCommand_runtest(float request, float argc)
                                        TEST_Run(argv(i));
                        }
                        else
-                               TEST_RunAll();
+                               RUN_ALL_TESTS();
                        return;
                }
 
index 4bffd04..b2302f6 100644 (file)
@@ -223,6 +223,8 @@ const int WATERLEVEL_NONE = 0;
 const int WATERLEVEL_WETFEET = 1;
 const int WATERLEVEL_SWIMMING = 2;
 const int WATERLEVEL_SUBMERGED = 3;
+
+// server flags
 const int SERVERFLAG_ALLOW_FULLBRIGHT = 1;
 const int SERVERFLAG_TEAMPLAY = 2;
 const int SERVERFLAG_PLAYERSTATS = 4;
index c4b88cc..916fd88 100644 (file)
 
 // add hook function calls here
 #define CSQCMODEL_HOOK_PREUPDATE \
-       CSQCModel_Hook_PreUpdate(isnew, isplayer, islocalplayer);
+       CSQCModel_Hook_PreUpdate(this, isnew, isplayer, islocalplayer);
 #define CSQCMODEL_HOOK_POSTUPDATE \
-       CSQCModel_Hook_PostUpdate(isnew, isplayer, islocalplayer);
+       CSQCModel_Hook_PostUpdate(this, isnew, isplayer, islocalplayer);
 #define CSQCMODEL_HOOK_PREDRAW \
-       CSQCModel_Hook_PreDraw(isplayer);
+       CSQCModel_Hook_PreDraw(this, isplayer);
 #define CSQCPLAYER_HOOK_POSTCAMERASETUP() \
        CSQCPlayer_SetViewLocation()
 
index f68bf38..6763519 100644 (file)
@@ -38,31 +38,31 @@ class(Casing) .bool silent;
 class(Casing) .int state;
 class(Casing) .float cnt;
 
-void Casing_Delete()
-{SELFPARAM();
-    remove(self);
+void Casing_Delete(entity this)
+{
+    remove(this);
 }
 
 void Casing_Draw(entity this)
 {
-    if (self.move_flags & FL_ONGROUND)
+    if (this.move_flags & FL_ONGROUND)
     {
-        self.move_angles_x = 0;
-        self.move_angles_z = 0;
-        UNSET_ONGROUND(self);
+        this.move_angles_x = 0;
+        this.move_angles_z = 0;
+        UNSET_ONGROUND(this);
     }
 
-    Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
-    if (wasfreed(self))
+    Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+    if (wasfreed(this))
         return; // deleted by touch function
 
-    self.renderflags = 0;
-    self.alpha = bound(0, self.cnt - time, 1);
+    this.renderflags = 0;
+    this.alpha = bound(0, this.cnt - time, 1);
 
-    if (self.alpha < ALPHA_MIN_VISIBLE)
+    if (this.alpha < ALPHA_MIN_VISIBLE)
     {
-        Casing_Delete();
-        self.drawmask = 0;
+        Casing_Delete(this);
+        this.drawmask = 0;
     }
 }
 
@@ -83,7 +83,7 @@ void Casing_Touch()
 {SELFPARAM();
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
     {
-        Casing_Delete();
+        Casing_Delete(self);
         return;
     }
 
@@ -113,12 +113,12 @@ void Casing_Touch()
     self.nextthink = time + 0.2;
 }
 
-void Casing_Damage(float thisdmg, int hittype, vector org, vector thisforce)
-{SELFPARAM();
+void Casing_Damage(entity this, float thisdmg, int hittype, vector org, vector thisforce)
+{
     if (thisforce.z < 0)
         thisforce.z = 0;
-    self.move_velocity = self.move_velocity + thisforce + '0 0 100';
-    self.move_flags &= ~FL_ONGROUND;
+    this.move_velocity = this.move_velocity + thisforce + '0 0 100';
+    this.move_flags &= ~FL_ONGROUND;
 }
 
 NET_HANDLE(casings, bool isNew)
index 45b532b..4d85ab9 100644 (file)
@@ -271,7 +271,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
                        self.silent = 1;
 
                if(self.event_damage)
-                       self.event_damage(thisdmg, w_deathtype, w_org, thisforce);
+                       self.event_damage(self, thisdmg, w_deathtype, w_org, thisforce);
 
                DamageEffect(w_org, thisdmg, w_deathtype, species);
 
index 09be41c..3d0da1b 100644 (file)
@@ -20,7 +20,7 @@ bool Violence_GibSplash_SendEntity(entity this, entity to, int sf)
 }
 
 void Violence_GibSplash_At(vector org, vector dir, float type, float amount, entity gibowner, entity attacker)
-{SELFPARAM();
+{
        if(g_cts) // no gibs in CTS
                return;
 
@@ -29,14 +29,14 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
        e.state = type; // should stay smaller than 15
        if(!sound_allowed(MSG_BROADCAST, gibowner) || !sound_allowed(MSG_BROADCAST, attacker))
                e.state |= 0x40; // "silence" bit
-       e.state |= 8 * self.species; // gib type, ranges from 0 to 15
+       e.state |= 8 * gibowner.species; // gib type, ranges from 0 to 15
 
        // if this is a copied dead body, send the num of its player instead
        // TODO: remove this field, read from model txt files
-       if(self.classname == "body")
-               e.team = etof(self.enemy);
+       if(gibowner.classname == "body")
+               e.team = etof(gibowner.enemy);
        else
-               e.team = etof(self);
+               e.team = etof(gibowner);
 
        setorigin(e, org);
        e.velocity = dir;
@@ -66,9 +66,9 @@ void Violence_GibSplash(entity source, float type, float amount, entity attacker
 .float cnt;
 .float gravity;
 
-void Gib_Delete()
-{SELFPARAM();
-       remove(self);
+void Gib_Delete(entity this)
+{
+       remove(this);
 }
 
 string species_prefix(int specnum);
@@ -112,7 +112,7 @@ void new_te_bloodshower (int ef, vector org, float explosionspeed, int howmany)
 void SUB_RemoveOnNoImpact()
 {
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
-               Gib_Delete();
+               Gib_Delete(self);
 }
 
 void Gib_Touch()
@@ -121,7 +121,7 @@ void Gib_Touch()
 
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
        {
-               Gib_Delete();
+               Gib_Delete(self);
                return;
        }
 
@@ -129,36 +129,36 @@ void Gib_Touch()
                sound(self, CH_PAIN, SND_GIB_SPLAT_RANDOM(), VOL_BASE, ATTEN_NORM);
        __pointparticles(_particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
 
-       Gib_Delete();
+       Gib_Delete(self);
 }
 
 void Gib_Draw(entity this)
 {
        vector oldorg;
-       oldorg = self.origin;
+       oldorg = this.origin;
 
-       Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
-       if(wasfreed(self))
+       Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+       if(wasfreed(this))
                return;
 
-       if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
-               // TODO somehow make it spray in a direction dependent on self.angles
-               __trailparticles(self, _particleeffectnum(strcat(species_prefix(self.cnt), EFFECT_TR_SLIGHTBLOOD.eent_eff_name)), oldorg, self.origin);
+       if(this.touch == Gib_Touch) // don't do this for the "chunk" thingie...
+               // TODO somehow make it spray in a direction dependent on this.angles
+               __trailparticles(this, _particleeffectnum(strcat(species_prefix(this.cnt), EFFECT_TR_SLIGHTBLOOD.eent_eff_name)), oldorg, this.origin);
        else
-               __trailparticles(self, _particleeffectnum(strcat(species_prefix(self.cnt), EFFECT_TR_BLOOD.eent_eff_name)), oldorg, self.origin);
+               __trailparticles(this, _particleeffectnum(strcat(species_prefix(this.cnt), EFFECT_TR_BLOOD.eent_eff_name)), oldorg, this.origin);
 
-       self.renderflags = 0;
+       this.renderflags = 0;
 
        // make gibs die faster at low view quality
        // if view_quality is 0.5, we want to have them die twice as fast
-       self.nextthink -= frametime * (1 / bound(0.01, view_quality, 1.00) - 1);
+       this.nextthink -= frametime * (1 / bound(0.01, view_quality, 1.00) - 1);
 
-       self.alpha = bound(0, self.nextthink - time, 1);
+       this.alpha = bound(0, this.nextthink - time, 1);
 
-       if(self.alpha < ALPHA_MIN_VISIBLE)
+       if(this.alpha < ALPHA_MIN_VISIBLE)
        {
-               self.drawmask = 0;
-               Gib_Delete();
+               this.drawmask = 0;
+               Gib_Delete(this);
        }
 }
 
index 41c5ba0..d7e437e 100644 (file)
@@ -95,19 +95,19 @@ class(ModelEffect) .float scale1, scale2;
 
 void ModelEffect_Draw(entity this)
 {
-       self.angles = self.angles + frametime * self.avelocity;
-       setorigin(self, self.origin + frametime * self.velocity);
-       self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
-       self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
-       if(self.alpha < ALPHA_MIN_VISIBLE)
+       this.angles = this.angles + frametime * this.avelocity;
+       setorigin(this, this.origin + frametime * this.velocity);
+       this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
+       this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
+       if(this.alpha < ALPHA_MIN_VISIBLE)
        {
-               remove(self);
+               remove(this);
                return;
        }
-       self.drawmask = MASK_NORMAL;
-       if(self.scale <= 0)
+       this.drawmask = MASK_NORMAL;
+       if(this.scale <= 0)
        {
-               self.drawmask = 0;
+               this.drawmask = 0;
                return;
        }
 }
index 1a7cad8..73744e6 100644 (file)
@@ -6,7 +6,7 @@
 entityclass(Rubble);
 class(Rubble).float creationtime;
 
-void RubbleLimit(string cname, float limit, void() deleteproc)
+void RubbleLimit(string cname, float limit, void(entity) deleteproc)
 {
        SELFPARAM();
        entity e;
@@ -42,7 +42,7 @@ void RubbleLimit(string cname, float limit, void() deleteproc)
                if (c <= limit) break;
 
                // delete this oldest one and search again
-               WITH(entity, self, oldest, deleteproc());
+               deleteproc(oldest);
        }
 }
 
index 6367f40..ff67a72 100644 (file)
 
 #ifdef CSQC
 
-       void Ent_RemoveEntCS()
+       void Ent_RemoveEntCS(entity this)
        {
-               SELFPARAM();
                int n = this.sv_entnum;
                entity e = entcs_receiver(n);
                entcs_receiver(n, NULL);
index f5b6111..6ded489 100644 (file)
@@ -44,75 +44,75 @@ void ons_generator_ray_spawn(vector org)
 
 void generator_draw(entity this)
 {
-       if(time < self.move_time)
+       if(time < this.move_time)
                return;
 
-       if(self.health > 0)
+       if(this.health > 0)
        {
                // damaged fx (less probable the more damaged is the generator)
-               if(random() < 0.9 - self.health / self.max_health)
+               if(random() < 0.9 - this.health / this.max_health)
                if(random() < 0.01)
                {
-                       pointparticles(EFFECT_ELECTRO_BALLEXPLODE, self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
-                       sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
+                       pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
+                       sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
                }
                else
-                       pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
+                       pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
 
-               self.move_time = time + 0.1;
+               this.move_time = time + 0.1;
 
                return;
        }
 
-       if(self.count <= 0)
+       if(this.count <= 0)
                return;
 
        vector org;
        int i;
 
        // White shockwave
-       if(self.count==40||self.count==20)
+       if(this.count==40||this.count==20)
        {
-               sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
-               pointparticles(EFFECT_ELECTRO_COMBO, self.origin, '0 0 0', 6);
+               sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
+               pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
        }
 
        // rays
        if(random() > 0.25)
        {
-               ons_generator_ray_spawn(self.origin);
+               ons_generator_ray_spawn(this.origin);
        }
 
        // Spawn fire balls
        for(i=0;i < 10;++i)
        {
-               org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
+               org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
                pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
        }
 
        // Short explosion sound + small explosion
        if(random() < 0.25)
        {
-               te_explosion(self.origin);
-               sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+               te_explosion(this.origin);
+               sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
        // Particles
-       org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
+       org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
        pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
 
        // Final explosion
-       if(self.count==1)
+       if(this.count==1)
        {
-               org = self.origin;
+               org = this.origin;
                te_explosion(org);
                pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
-               sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+               sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
-       self.move_time = time + 0.05;
+       this.move_time = time + 0.05;
 
-       self.count -= 1;
+       this.count -= 1;
 }
 
 void generator_damage(float hp)
index 7cdefd9..b4d7672 100644 (file)
@@ -487,18 +487,18 @@ int ons_ControlPoint_Attackable(entity cp, int teamnumber)
        return 0;
 }
 
-void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
        if(damage <= 0) { return; }
 
-       if (self.owner.isshielded)
+       if (this.owner.isshielded)
        {
                // this is protected by a shield, so ignore the damage
-               if (time > self.pain_finished)
+               if (time > this.pain_finished)
                        if (IS_PLAYER(attacker))
                        {
                                play2(attacker, SND(ONS_DAMAGEBLOCKEDBYSHIELD));
-                               self.pain_finished = time + 1;
+                               this.pain_finished = time + 1;
                                attacker.typehitsound += 1; // play both sounds (shield is way too quiet)
                        }
 
@@ -506,60 +506,60 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
        }
 
        if(IS_PLAYER(attacker))
-       if(time - ons_notification_time[self.team] > 10)
+       if(time - ons_notification_time[this.team] > 10)
        {
-               play2team(self.team, SND(ONS_CONTROLPOINT_UNDERATTACK));
-               ons_notification_time[self.team] = time;
+               play2team(this.team, SND(ONS_CONTROLPOINT_UNDERATTACK));
+               ons_notification_time[this.team] = time;
        }
 
-       self.health = self.health - damage;
-       if(self.owner.iscaptured)
-               WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+       this.health = this.health - damage;
+       if(this.owner.iscaptured)
+               WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
        else
-               WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / ONS_CP_THINKRATE));
-       self.pain_finished = time + 1;
+               WaypointSprite_UpdateBuildFinished(this.owner.sprite, time + (this.max_health - this.health) / (this.count / ONS_CP_THINKRATE));
+       this.pain_finished = time + 1;
        // particles on every hit
        pointparticles(EFFECT_SPARKS, hitloc, force*-1, 1);
        //sound on every hit
        if (random() < 0.5)
-               sound(self, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE+0.3, ATTEN_NORM);
+               sound(this, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE+0.3, ATTEN_NORM);
        else
-               sound(self, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE+0.3, ATTEN_NORM);
+               sound(this, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE+0.3, ATTEN_NORM);
 
-       if (self.health < 0)
+       if (this.health < 0)
        {
-               sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
-               pointparticles(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_CPDESTROYED_), self.owner.message, attacker.netname);
+               sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+               pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_CPDESTROYED_), this.owner.message, attacker.netname);
 
                PlayerScore_Add(attacker, SP_ONS_TAKES, 1);
                PlayerScore_Add(attacker, SP_SCORE, 10);
 
-               self.owner.goalentity = world;
-               self.owner.islinked = false;
-               self.owner.iscaptured = false;
-               self.owner.team = 0;
-               self.owner.colormap = 1024;
+               this.owner.goalentity = world;
+               this.owner.islinked = false;
+               this.owner.iscaptured = false;
+               this.owner.team = 0;
+               this.owner.colormap = 1024;
 
-               WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
+               WaypointSprite_UpdateMaxHealth(this.owner.sprite, 0);
 
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               setself(self.owner);
-               activator = self;
-               SUB_UseTargets ();
+               setself(this.owner);
+               activator = this;
+               WITH(entity, self, this, SUB_UseTargets());
                setself(this);
 
-               self.owner.waslinked = self.owner.islinked;
-               if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
-                       setmodel_fixsize(self.owner, MDL_ONS_CP_PAD1);
-               //setsize(self, '-32 -32 0', '32 32 8');
+               this.owner.waslinked = this.owner.islinked;
+               if(this.owner.model != "models/onslaught/controlpoint_pad.md3")
+                       setmodel_fixsize(this.owner, MDL_ONS_CP_PAD1);
+               //setsize(this, '-32 -32 0', '32 32 8');
 
-               remove(self);
+               remove(this);
        }
 
-       self.SendFlags |= CPSF_STATUS;
+       this.SendFlags |= CPSF_STATUS;
 }
 
 void ons_ControlPoint_Icon_Think()
@@ -570,11 +570,9 @@ void ons_ControlPoint_Icon_Think()
        {
                int _enemy_count = 0;
                int _friendly_count = 0;
-               float _dist;
 
                FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
-                       _dist = vlen(it.origin - self.origin);
-                       if(_dist < autocvar_g_onslaught_cp_proxydecap_distance)
+                       if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
                        {
                                if(SAME_TEAM(it, self))
                                        ++_friendly_count;
@@ -590,7 +588,7 @@ void ons_ControlPoint_Icon_Think()
                self.SendFlags |= CPSF_STATUS;
                if(self.health <= 0)
                {
-                       ons_ControlPoint_Icon_Damage(self, self, 1, 0, self.origin, '0 0 0');
+                       ons_ControlPoint_Icon_Damage(self, self, self, 1, 0, self.origin, '0 0 0');
                        return;
                }
        }
@@ -955,64 +953,64 @@ void ons_Generator_UpdateSprite(entity e)
        }
 }
 
-void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
        if(damage <= 0) { return; }
        if(warmup_stage || gameover) { return; }
        if(!round_handler_IsRoundStarted()) { return; }
 
-       if (attacker != self)
+       if (attacker != this)
        {
-               if (self.isshielded)
+               if (this.isshielded)
                {
                        // this is protected by a shield, so ignore the damage
-                       if (time > self.pain_finished)
+                       if (time > this.pain_finished)
                                if (IS_PLAYER(attacker))
                                {
                                        play2(attacker, SND(ONS_DAMAGEBLOCKEDBYSHIELD));
                                        attacker.typehitsound += 1;
-                                       self.pain_finished = time + 1;
+                                       this.pain_finished = time + 1;
                                }
                        return;
                }
-               if (time > self.pain_finished)
+               if (time > this.pain_finished)
                {
-                       self.pain_finished = time + 10;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, self), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK)));
-                       play2team(self.team, SND(ONS_GENERATOR_UNDERATTACK));
+                       this.pain_finished = time + 10;
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && SAME_TEAM(it, this), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK)));
+                       play2team(this.team, SND(ONS_GENERATOR_UNDERATTACK));
                }
        }
-       self.health = self.health - damage;
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       this.health = this.health - damage;
+       WaypointSprite_UpdateHealth(this.sprite, this.health);
        // choose an animation frame based on health
-       self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
+       this.frame = 10 * bound(0, (1 - this.health / this.max_health), 1);
        // see if the generator is still functional, or dying
-       if (self.health > 0)
+       if (this.health > 0)
        {
-               self.lasthealth = self.health;
+               this.lasthealth = this.health;
        }
        else
        {
-               if (attacker == self)
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_));
+               if (attacker == this)
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_));
                else
                {
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_));
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(this.team, INFO_ONSLAUGHT_GENDESTROYED_));
                        PlayerScore_Add(attacker, SP_SCORE, 100);
                }
-               self.iscaptured = false;
-               self.islinked = false;
-               self.isshielded = false;
-               self.takedamage = DAMAGE_NO; // can't be hurt anymore
-               self.event_damage = func_null; // won't do anything if hurt
-               self.count = 0; // reset counter
-               self.think = func_null;
-               self.nextthink = 0;
-               //self.think(); // do the first explosion now
-
-               WaypointSprite_UpdateMaxHealth(self.sprite, 0);
-               WaypointSprite_Ping(self.sprite);
-               //WaypointSprite_Kill(self.sprite); // can't do this yet, code too poor
+               this.iscaptured = false;
+               this.islinked = false;
+               this.isshielded = false;
+               this.takedamage = DAMAGE_NO; // can't be hurt anymore
+               this.event_damage = func_null; // won't do anything if hurt
+               this.count = 0; // reset counter
+               this.think = func_null;
+               this.nextthink = 0;
+               //this.think(); // do the first explosion now
+
+               WaypointSprite_UpdateMaxHealth(this.sprite, 0);
+               WaypointSprite_Ping(this.sprite);
+               //WaypointSprite_Kill(this.sprite); // can't do this yet, code too poor
 
                onslaught_updatelinks();
        }
@@ -1020,7 +1018,7 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
        // Throw some flaming gibs on damage, more damage = more chance for gib
        if(random() < damage/220)
        {
-               sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+               sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        }
        else
        {
@@ -1029,12 +1027,12 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
 
                //sound on every hit
                if (random() < 0.5)
-                       sound(self, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE, ATTEN_NORM);
                else
-                       sound(self, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM);
        }
 
-       self.SendFlags |= GSF_STATUS;
+       this.SendFlags |= GSF_STATUS;
 }
 
 void ons_GeneratorThink()
@@ -1622,8 +1620,8 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
        {
                if(SAME_TEAM(tmp_entity, self))
                if(tmp_entity.iscaptured)
-               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) <= max_dist)
-               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+               if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <=, max_dist))
+               if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
                        closest_target = tmp_entity;
                tmp_entity = tmp_entity.chain;
        }
@@ -1631,8 +1629,8 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
        while(tmp_entity)
        {
                if(SAME_TEAM(tmp_entity, self))
-               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) < max_dist)
-               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+               if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <, max_dist))
+               if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
                        closest_target = tmp_entity;
                tmp_entity = tmp_entity.chain;
        }
index 7a12b30..0db0d0b 100644 (file)
@@ -50,11 +50,11 @@ CLASS(GameItem, Object)
     ATTRIB(GameItem, m_color, vector, '1 1 1')
     ATTRIB(GameItem, m_waypoint, string, string_null)
     ATTRIB(GameItem, m_waypointblink, int, 1)
-    METHOD(GameItem, display, void(entity this, void(string name, string icon) returns)) {
+    METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns)) {
         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
-    METHOD(GameItem, show, void(entity this)) { LOG_INFO("A game item\n"); }
-    void ITEM_HANDLE(Show, entity this) { this.show(this); }
+    METHOD(GameItem, show, void(GameItem this)) { LOG_INFO("A game item\n"); }
+    void ITEM_HANDLE(Show, GameItem this) { this.show(this); }
 ENDCLASS(GameItem)
 
 #endif
index 1996327..dbc74a0 100644 (file)
@@ -8,8 +8,7 @@ CLASS(Pickup, GameItem)
     ATTRIB(Pickup, m_sound, Sound, SND_ITEMPICKUP)
 #endif
     ATTRIB(Pickup, m_name, string, string_null)
-    METHOD(Pickup, show, void(entity this));
-    void Pickup_show(entity this) { LOG_INFOF("%s: %s\n", etos(this), this.m_name); }
+    METHOD(Pickup, show, void(Pickup this)) { LOG_INFOF("%s: %s\n", etos(this), this.m_name); }
 #ifdef SVQC
     ATTRIB(Pickup, m_mins, vector, '-16 -16 0')
     ATTRIB(Pickup, m_maxs, vector, '16 16 32')
@@ -21,7 +20,7 @@ CLASS(Pickup, GameItem)
     ATTRIB(Pickup, m_respawntime, float(), func_null)
     ATTRIB(Pickup, m_respawntimejitter, float(), func_null)
     float Item_GiveTo(entity item, entity player);
-    METHOD(Pickup, giveTo, bool(entity this, entity item, entity player))
+    METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player))
     {
         bool b = Item_GiveTo(item, player);
         if (b) {
@@ -31,7 +30,7 @@ CLASS(Pickup, GameItem)
         }
         return b;
     }
-    bool ITEM_HANDLE(Pickup, entity this, entity item, entity player);
+    bool ITEM_HANDLE(Pickup, Pickup this, entity item, entity player);
 #endif
 ENDCLASS(Pickup)
 
index 93147d4..6f7e7c3 100644 (file)
@@ -54,7 +54,7 @@ string minigame_texture(string name)
        return path;
 }
 
-#define FIELD(Flags, Type, Name) MSLE_CLEAN_##Type(self.Name)
+#define FIELD(Flags, Type, Name) MSLE_CLEAN_##Type(this.Name)
 #define MSLE_CLEAN_String(x) strunzone(x);
 #define MSLE_CLEAN_Byte(x)
 #define MSLE_CLEAN_Char(x)
@@ -67,7 +67,7 @@ string minigame_texture(string name)
 #define MSLE_CLEAN_Vector2D(x)
 
 #define MSLE(Name,Fields) \
-       void msle_entremove_##Name() { SELFPARAM(); strunzone(self.netname); Fields }
+       void msle_entremove_##Name(entity this) { strunzone(this.netname); Fields }
 MINIGAME_SIMPLELINKED_ENTITIES
 #undef MSLE
 #undef FIELD
@@ -105,9 +105,9 @@ void deactivate_minigame()
                HUD_MinigameMenu_CurrentButton();
 }
 
-void minigame_entremove()
-{SELFPARAM();
-       if ( self == active_minigame )
+void minigame_entremove(entity this)
+{
+       if ( this == active_minigame )
                deactivate_minigame();
 }
 
@@ -147,9 +147,9 @@ void activate_minigame(entity minigame)
        }
 }
 
-void minigame_player_entremove()
-{SELFPARAM();
-       if ( self.owner == active_minigame && self.minigame_playerslot == player_localentnum )
+void minigame_player_entremove(entity this)
+{
+       if ( this.owner == active_minigame && this.minigame_playerslot == player_localentnum )
                deactivate_minigame();
 }
 
index 359003f..87c75f4 100644 (file)
@@ -124,7 +124,7 @@ bool pong_paddle_hit(entity ball, int pteam)
                return false;
        vector near_point = box_nearest(paddle.mins+paddle.origin,
                                                                        paddle.maxs+paddle.origin, ball.origin);
-       return vlen(near_point-ball.origin) <= ball.pong_length ;
+       return vdist(near_point - ball.origin, <=, ball.pong_length);
 }
 
 // Checks for a goal, when that happes adds scores and resets the ball
index 476dcfb..22e2072 100644 (file)
@@ -25,7 +25,7 @@ const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes
 const int MONSTER_SIZE_QUAKE = 8192;
 
 // entity properties of monsterinfo:
-.bool(int, entity targ) monster_attackfunc;
+.bool(int, entity actor, entity targ) monster_attackfunc;
 
 // animations
 .vector anim_blockend;
@@ -56,17 +56,17 @@ CLASS(Monster, Object)
     ATTRIB(Monster, maxs, vector, '0 0 0')
 
     /** (SERVER) setup monster data */
-    METHOD(Monster, mr_setup, bool(Monster this)) { return false; }
+    METHOD(Monster, mr_setup, bool(Monster this, entity actor)) { return false; }
     /** (SERVER) logic to run every frame */
-    METHOD(Monster, mr_think, bool(Monster this)) { return false; }
+    METHOD(Monster, mr_think, bool(Monster this, entity actor)) { return false; }
     /** (SERVER) called when monster dies */
-    METHOD(Monster, mr_death, bool(Monster this)) { return false; }
+    METHOD(Monster, mr_death, bool(Monster this, entity actor)) { return false; }
     /** (BOTH) precaches models/sounds used by this monster */
     METHOD(Monster, mr_precache, bool(Monster this)) { return false; }
     /** (SERVER) called when monster is damaged */
-    METHOD(Monster, mr_pain, bool(Monster this)) { return false; }
+    METHOD(Monster, mr_pain, bool(Monster this, entity actor)) { return false; }
     /** (BOTH?) sets animations for monster */
-    METHOD(Monster, mr_anim, bool(Monster this)) { return false; }
+    METHOD(Monster, mr_anim, bool(Monster this, entity actor)) { return false; }
 
 ENDCLASS(Monster)
 
index 2541de0..37c6301 100644 (file)
@@ -40,8 +40,8 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike));
 #ifdef SVQC
 
 SOUND(MageSpike_FIRE, W_Sound("electro_fire"));
-void M_Mage_Attack_Spike(vector dir);
-void M_Mage_Attack_Push();
+void M_Mage_Attack_Spike(entity this, vector dir);
+void M_Mage_Attack_Push(entity this);
 METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) {
     if (fire & 1)
     if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) {
@@ -49,24 +49,24 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weapon
         actor.enemy = Monster_FindTarget(actor);
         W_SetupShot_Dir(actor, v_forward, false, 0, SND(MageSpike_FIRE), CH_WEAPON_B, 0);
        if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
-        M_Mage_Attack_Spike(w_shotdir);
+        M_Mage_Attack_Spike(actor, w_shotdir);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
     if (fire & 2)
     if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) {
-        M_Mage_Attack_Push();
+        M_Mage_Attack_Push(actor);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
-void M_Mage_Attack_Teleport();
+void M_Mage_Attack_Teleport(entity this, entity targ);
 
 CLASS(OffhandMageTeleport, OffhandWeapon)
     .bool OffhandMageTeleport_key_pressed;
     METHOD(OffhandMageTeleport, offhand_think, void(OffhandMageTeleport this, entity player, bool key_pressed))
     {
         if (key_pressed && !player.OffhandMageTeleport_key_pressed)
-            WITH(entity, self, player, M_Mage_Attack_Teleport());
+               M_Mage_Attack_Teleport(player, player.enemy);
         player.OffhandMageTeleport_key_pressed = key_pressed;
     }
 ENDCLASS(OffhandMageTeleport)
@@ -110,58 +110,58 @@ const float mage_anim_death               = 4;
 const float mage_anim_run              = 5;
 */
 
-void() M_Mage_Defend_Heal;
-void() M_Mage_Defend_Shield;
+void M_Mage_Defend_Heal(entity this);
+void M_Mage_Defend_Shield(entity this);
 
 .entity mage_spike;
 .float mage_shield_delay;
 .float mage_shield_time;
 
-float M_Mage_Defend_Heal_Check(entity e)
-{SELFPARAM();
-       if(e == world)
+bool M_Mage_Defend_Heal_Check(entity this, entity targ)
+{
+       if(targ == world)
                return false;
-       if(e.health <= 0)
+       if(targ.health <= 0)
                return false;
-       if(DIFF_TEAM(e, self) && e != self.monster_follow)
+       if(DIFF_TEAM(targ, this) && targ != this.monster_follow)
                return false;
-       if(STAT(FROZEN, e))
+       if(STAT(FROZEN, targ))
                return false;
-       if(!IS_PLAYER(e))
-               return (IS_MONSTER(e) && e.health < e.max_health);
-       if(e.items & ITEM_Shield.m_itemid)
+       if(!IS_PLAYER(targ))
+               return (IS_MONSTER(targ) && targ.health < targ.max_health);
+       if(targ.items & ITEM_Shield.m_itemid)
                return false;
 
-       switch(self.skin)
+       switch(this.skin)
        {
-               case 0: return (e.health < autocvar_g_balance_health_regenstable);
-               case 1: return ((e.ammo_cells && e.ammo_cells < g_pickup_cells_max) || (e.ammo_plasma && e.ammo_plasma < g_pickup_plasma_max) || (e.ammo_rockets && e.ammo_rockets < g_pickup_rockets_max) || (e.ammo_nails && e.ammo_nails < g_pickup_nails_max) || (e.ammo_shells && e.ammo_shells < g_pickup_shells_max));
-               case 2: return (e.armorvalue < autocvar_g_balance_armor_regenstable);
-               case 3: return (e.health > 0);
+               case 0: return (targ.health < autocvar_g_balance_health_regenstable);
+               case 1: return ((targ.ammo_cells && targ.ammo_cells < g_pickup_cells_max) || (targ.ammo_plasma && targ.ammo_plasma < g_pickup_plasma_max) || (targ.ammo_rockets && targ.ammo_rockets < g_pickup_rockets_max) || (targ.ammo_nails && targ.ammo_nails < g_pickup_nails_max) || (targ.ammo_shells && targ.ammo_shells < g_pickup_shells_max));
+               case 2: return (targ.armorvalue < autocvar_g_balance_armor_regenstable);
+               case 3: return (targ.health > 0);
        }
 
        return false;
 }
 
-void M_Mage_Attack_Spike_Explode()
-{SELFPARAM();
-       self.event_damage = func_null;
+void M_Mage_Attack_Spike_Explode(entity this)
+{
+       this.event_damage = func_null;
 
-       sound(self, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
 
-       self.realowner.mage_spike = world;
+       this.realowner.mage_spike = world;
 
-       Send_Effect(EFFECT_EXPLOSION_SMALL, self.origin, '0 0 0', 1);
-       RadiusDamage (self, self.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), world, world, 0, DEATH_MONSTER_MAGE.m_id, other);
+       Send_Effect(EFFECT_EXPLOSION_SMALL, this.origin, '0 0 0', 1);
+       RadiusDamage (this, this.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), world, world, 0, DEATH_MONSTER_MAGE.m_id, other);
 
-       remove (self);
+       remove (this);
 }
 
 void M_Mage_Attack_Spike_Touch()
 {
        PROJECTILE_TOUCH;
 
-       M_Mage_Attack_Spike_Explode();
+       M_Mage_Attack_Spike_Explode(self);
 }
 
 .float wait;
@@ -171,7 +171,7 @@ void M_Mage_Attack_Spike_Think()
 {SELFPARAM();
        if (time > self.ltime || (self.enemy && self.enemy.health <= 0) || self.owner.health <= 0) {
                self.projectiledeathtype |= HITTYPE_SPLASH;
-               M_Mage_Attack_Spike_Explode();
+               M_Mage_Attack_Spike_Explode(self);
        }
 
        float spd = vlen(self.velocity);
@@ -192,13 +192,12 @@ void M_Mage_Attack_Spike_Think()
                float turnrate = (autocvar_g_monster_mage_attack_spike_turnrate); // how fast to turn
                vector desireddir = normalize(eorg - self.origin);
                vector olddir = normalize(self.velocity); // get my current direction
-               float dist = vlen(eorg - self.origin);
 
                // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
-               if ((autocvar_g_monster_mage_attack_spike_smart) && (dist > (autocvar_g_monster_mage_attack_spike_smart_mindist)))
+               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - self.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
                {
                        // Is it a better idea (shorter distance) to trace to the target itself?
-                       if ( vlen(self.origin + olddir * self.wait) < dist)
+                       if ( vlen2(self.origin + olddir * self.wait) < vlen2(eorg - self.origin))
                                traceline(self.origin, self.origin + olddir * self.wait, false, self);
                        else
                                traceline(self.origin, eorg, false, self);
@@ -221,43 +220,42 @@ void M_Mage_Attack_Spike_Think()
        UpdateCSQCProjectile(self);
 }
 
-void M_Mage_Attack_Spike(vector dir)
+void M_Mage_Attack_Spike(entity this, vector dir)
 {
-       SELFPARAM();
-       makevectors(self.angles);
+       makevectors(this.angles);
 
        entity missile = spawn();
-       missile.owner = missile.realowner = self;
+       missile.owner = missile.realowner = this;
        missile.think = M_Mage_Attack_Spike_Think;
        missile.ltime = time + 7;
        missile.nextthink = time;
        missile.solid = SOLID_BBOX;
        missile.movetype = MOVETYPE_FLYMISSILE;
        missile.flags = FL_PROJECTILE;
-       setorigin(missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14);
+       setorigin(missile, this.origin + v_forward * 14 + '0 0 30' + v_right * -14);
        setsize(missile, '0 0 0', '0 0 0');
        missile.velocity = dir * 400;
        missile.avelocity = '300 300 300';
-       missile.enemy = self.enemy;
+       missile.enemy = this.enemy;
        missile.touch = M_Mage_Attack_Spike_Touch;
 
-       self.mage_spike = missile;
+       this.mage_spike = missile;
 
        CSQCProjectile(missile, true, PROJECTILE_MAGE_SPIKE, true);
 }
 
-void M_Mage_Defend_Heal()
-{SELFPARAM();
+void M_Mage_Defend_Heal(entity this)
+{
        entity head;
        float washealed = false;
 
-       for(head = findradius(self.origin, (autocvar_g_monster_mage_heal_range)); head; head = head.chain) if(M_Mage_Defend_Heal_Check(head))
+       for(head = findradius(this.origin, (autocvar_g_monster_mage_heal_range)); head; head = head.chain) if(M_Mage_Defend_Heal_Check(this, head))
        {
                washealed = true;
                string fx = "";
                if(IS_PLAYER(head))
                {
-                       switch(self.skin)
+                       switch(this.skin)
                        {
                                case 0:
                                        if(head.health < autocvar_g_balance_health_regenstable) head.health = bound(0, head.health + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_health_regenstable);
@@ -279,7 +277,7 @@ void M_Mage_Defend_Heal()
                                        }
                                        break;
                                case 3:
-                                       head.health = bound(0, head.health - ((head == self)  ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable);
+                                       head.health = bound(0, head.health - ((head == this)  ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable);
                                        fx = EFFECT_RAGE.eent_eff_name;
                                        break;
                        }
@@ -297,66 +295,69 @@ void M_Mage_Defend_Heal()
 
        if(washealed)
        {
-               setanim(self, self.anim_shoot, true, true, true);
-               self.attack_finished_single[0] = time + (autocvar_g_monster_mage_heal_delay);
-               self.anim_finished = time + 1.5;
+               setanim(this, this.anim_shoot, true, true, true);
+               this.attack_finished_single[0] = time + (autocvar_g_monster_mage_heal_delay);
+               this.anim_finished = time + 1.5;
        }
 }
 
-void M_Mage_Attack_Push()
-{SELFPARAM();
-       sound(self, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
-       RadiusDamage (self, self, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, self.enemy);
-       Send_Effect(EFFECT_TE_EXPLOSION, self.origin, '0 0 0', 1);
+void M_Mage_Attack_Push(entity this)
+{
+       sound(this, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
+       RadiusDamage (this, this, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, this.enemy);
+       Send_Effect(EFFECT_TE_EXPLOSION, this.origin, '0 0 0', 1);
 
-       setanim(self, self.anim_shoot, true, true, true);
-       self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_push_delay);
+       setanim(this, this.anim_shoot, true, true, true);
+       this.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_push_delay);
 }
 
-void M_Mage_Attack_Teleport()
-{SELFPARAM();
-       entity targ = self.enemy;
-       if (!targ) return;
-       if (vlen(targ.origin - self.origin) > 1500) return;
+void M_Mage_Attack_Teleport(entity this, entity targ)
+{
+       if(!targ) return;
+       if(vdist(targ.origin - this.origin, >, 1500)) return;
 
        makevectors(targ.angles);
-       tracebox(targ.origin + ((v_forward * -1) * 200), self.mins, self.maxs, self.origin, MOVE_NOMONSTERS, self);
+       tracebox(targ.origin + ((v_forward * -1) * 200), this.mins, this.maxs, this.origin, MOVE_NOMONSTERS, this);
 
        if(trace_fraction < 1)
                return;
 
-       Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1);
-       setorigin(self, targ.origin + ((v_forward * -1) * 200));
+       vector newpos = targ.origin + ((v_forward * -1) * 200);
+
+       Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_SPAWN_NEUTRAL, newpos, '0 0 0', 1);
+       
+       setorigin(this, newpos);
 
-       vector a = vectoangles(targ.origin - self.origin);
+       vector a = vectoangles(targ.origin - this.origin);
        a.x = -a.x;
-       self.angles_x = a.x;
-       self.angles_y = a.y;
-       self.fixangle = true;
-       self.velocity *= 0.5;
+       this.angles_x = a.x;
+       this.angles_y = a.y;
+       this.fixangle = true;
+       this.velocity *= 0.5;
 
-       self.attack_finished_single[0] = time + 0.2;
+       this.attack_finished_single[0] = time + 0.2;
 }
 
-void M_Mage_Defend_Shield_Remove()
-{SELFPARAM();
-       self.effects &= ~(EF_ADDITIVE | EF_BLUE);
-       self.armorvalue = autocvar_g_monsters_armor_blockpercent;
+void M_Mage_Defend_Shield_Remove(entity this)
+{
+       this.effects &= ~(EF_ADDITIVE | EF_BLUE);
+       this.armorvalue = autocvar_g_monsters_armor_blockpercent;
 }
 
-void M_Mage_Defend_Shield()
-{SELFPARAM();
-       self.effects |= (EF_ADDITIVE | EF_BLUE);
-       self.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay);
-       self.armorvalue = (autocvar_g_monster_mage_shield_blockpercent);
-       self.mage_shield_time = time + (autocvar_g_monster_mage_shield_time);
-       setanim(self, self.anim_shoot, true, true, true);
-       self.attack_finished_single[0] = time + 1;
-       self.anim_finished = time + 1;
+void M_Mage_Defend_Shield(entity this)
+{
+       this.effects |= (EF_ADDITIVE | EF_BLUE);
+       this.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay);
+       this.armorvalue = (autocvar_g_monster_mage_shield_blockpercent);
+       this.mage_shield_time = time + (autocvar_g_monster_mage_shield_time);
+       setanim(this, this.anim_shoot, true, true, true);
+       this.attack_finished_single[0] = time + 1;
+       this.anim_finished = time + 1;
 }
 
-float M_Mage_Attack(float attack_type, entity targ)
-{SELFPARAM();
+bool M_Mage_Attack(int attack_type, entity actor, entity targ)
+{
     .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
@@ -366,7 +367,7 @@ float M_Mage_Attack(float attack_type, entity targ)
                        {
                                Weapon wep = WEP_MAGE_SPIKE;
 
-                               wep.wr_think(wep, self, weaponentity, 2);
+                               wep.wr_think(wep, actor, weaponentity, 2);
                                return true;
                        }
 
@@ -374,26 +375,26 @@ float M_Mage_Attack(float attack_type, entity targ)
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       if(!self.mage_spike)
+                       if(!actor.mage_spike)
                        {
                                if(random() <= 0.4)
                                {
                                        OffhandWeapon off = OFFHAND_MAGE_TELEPORT;
-                                       off.offhand_think(off, self, true);
+                                       off.offhand_think(off, actor, true);
                                        return true;
                                }
                                else
                                {
-                                       setanim(self, self.anim_shoot, true, true, true);
-                                       self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay);
-                                       self.anim_finished = time + 1;
+                                       setanim(actor, actor.anim_shoot, true, true, true);
+                                       actor.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay);
+                                       actor.anim_finished = time + 1;
                                        Weapon wep = WEP_MAGE_SPIKE;
-                                       wep.wr_think(wep, self, weaponentity, 1);
+                                       wep.wr_think(wep, actor, weaponentity, 1);
                                        return true;
                                }
                        }
 
-                       if(self.mage_spike)
+                       if(actor.mage_spike)
                                return true;
                        else
                                return false;
@@ -403,86 +404,82 @@ float M_Mage_Attack(float attack_type, entity targ)
        return false;
 }
 
-spawnfunc(monster_mage) { Monster_Spawn(MON_MAGE.monsterid); }
+spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); }
 
 #endif // SVQC
 
                #ifdef SVQC
-               METHOD(Mage, mr_think, bool(Monster thismon))
+               METHOD(Mage, mr_think, bool(Mage thismon, entity actor))
                {
-                       SELFPARAM();
-                       entity head;
                        bool need_help = false;
 
-                       for(head = world; (head = findfloat(head, iscreature, true)); )
-                       if(head != self)
-                       if(vlen(head.origin - self.origin) <= (autocvar_g_monster_mage_heal_range))
-                       if(M_Mage_Defend_Heal_Check(head))
+                       FOREACH_ENTITY_FLOAT(iscreature, true,
                        {
-                               need_help = true;
-                               break;
-                       }
+                               if(it != actor)
+                               if(vdist(it.origin - actor.origin, <=, autocvar_g_monster_mage_heal_range))
+                               if(M_Mage_Defend_Heal_Check(actor, it))
+                               {
+                                       need_help = true;
+                                       break;
+                               }
+                       });
 
-                       if(self.health < (autocvar_g_monster_mage_heal_minhealth) || need_help)
-                       if(time >= self.attack_finished_single[0])
+                       if(actor.health < (autocvar_g_monster_mage_heal_minhealth) || need_help)
+                       if(time >= actor.attack_finished_single[0])
                        if(random() < 0.5)
-                               M_Mage_Defend_Heal();
+                               M_Mage_Defend_Heal(actor);
 
-                       if(time >= self.mage_shield_time && self.armorvalue)
-                               M_Mage_Defend_Shield_Remove();
+                       if(time >= actor.mage_shield_time && actor.armorvalue)
+                               M_Mage_Defend_Shield_Remove(actor);
 
-                       if(self.enemy)
-                       if(self.health < self.max_health)
-                       if(time >= self.mage_shield_delay)
+                       if(actor.enemy)
+                       if(actor.health < actor.max_health)
+                       if(time >= actor.mage_shield_delay)
                        if(random() < 0.5)
-                               M_Mage_Defend_Shield();
+                               M_Mage_Defend_Shield(actor);
 
                        return true;
                }
-               METHOD(Mage, mr_pain, bool(Monster thismon))
+               METHOD(Mage, mr_pain, bool(Mage thismon, entity actor))
                {
                        return true;
                }
-               METHOD(Mage, mr_death, bool(Monster thismon))
+               METHOD(Mage, mr_death, bool(Mage thismon, entity actor))
                {
-                       SELFPARAM();
-                       setanim(self, self.anim_die1, false, true, true);
+                       setanim(actor, actor.anim_die1, false, true, true);
                        return true;
                }
                #endif
                #ifndef MENUQC
-               METHOD(Mage, mr_anim, bool(Monster thismon))
+               METHOD(Mage, mr_anim, bool(Mage thismon, entity actor))
                {
-                       SELFPARAM();
                        vector none = '0 0 0';
-                       self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds
-                       self.anim_walk = animfixfps(self, '1 1 1', none);
-                       self.anim_idle = animfixfps(self, '0 1 1', none);
-                       self.anim_pain1 = animfixfps(self, '3 1 2', none); // 0.5 seconds
-                       self.anim_shoot = animfixfps(self, '2 1 5', none); // analyze models and set framerate
-                       self.anim_run = animfixfps(self, '5 1 1', none);
-
+                       actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
+                       actor.anim_walk = animfixfps(actor, '1 1 1', none);
+                       actor.anim_idle = animfixfps(actor, '0 1 1', none);
+                       actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
+                       actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
+                       actor.anim_run = animfixfps(actor, '5 1 1', none);
                        return true;
                }
                #endif
                #ifdef SVQC
                .float speed;
                spawnfunc(item_health_large);
-               METHOD(Mage, mr_setup, bool(Monster thismon))
+               METHOD(Mage, mr_setup, bool(Mage thismon, entity actor))
                {
-                       SELFPARAM();
-                       if(!self.health) self.health = (autocvar_g_monster_mage_health);
-                       if(!self.speed) { self.speed = (autocvar_g_monster_mage_speed_walk); }
-                       if(!self.speed2) { self.speed2 = (autocvar_g_monster_mage_speed_run); }
-                       if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_mage_speed_stop); }
-                       if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_mage_damageforcescale); }
+                       if(!actor.health) actor.health = (autocvar_g_monster_mage_health);
+                       if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); }
+                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); }
+                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_mage_speed_stop); }
+                       if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_mage_damageforcescale); }
 
-                       self.monster_loot = spawnfunc_item_health_large;
-                       self.monster_attackfunc = M_Mage_Attack;
+                       actor.monster_loot = spawnfunc_item_health_large;
+                       actor.monster_attackfunc = M_Mage_Attack;
 
                        return true;
                }
-               METHOD(Mage, mr_precache, bool(Monster thismon))
+               METHOD(Mage, mr_precache, bool(Mage thismon))
                {
                        return true;
                }
index c642cb5..0ffa60f 100644 (file)
@@ -57,29 +57,23 @@ const float shambler_anim_death             = 8;
 
 .float shambler_lastattack; // delay attacks separately
 
-void M_Shambler_Attack_Smash()
-{SELFPARAM();
-       makevectors(self.angles);
-       Send_Effect(EFFECT_EXPLOSION_MEDIUM, (self.origin + (v_forward * 150)) - ('0 0 1' * self.maxs.z), '0 0 0', 1);
-       sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+void M_Shambler_Attack_Smash(entity this)
+{
+       makevectors(this.angles);
+       Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1);
+       sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
        // RadiusDamage does NOT support custom starting location, which means we must use this hack...
 
-       tracebox(self.origin + v_forward * 50, self.mins * 0.5, self.maxs * 0.5, self.origin + v_forward * autocvar_g_monster_shambler_attack_smash_range, MOVE_NORMAL, self);
+       tracebox(this.origin + v_forward * 50, this.mins * 0.5, this.maxs * 0.5, this.origin + v_forward * autocvar_g_monster_shambler_attack_smash_range, MOVE_NORMAL, this);
 
        if(trace_ent.takedamage)
-               Damage(trace_ent, self, self, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_SHAMBLER_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - self.origin));
+               Damage(trace_ent, this, this, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - this.origin));
 }
 
-void M_Shambler_Attack_Swing()
-{SELFPARAM();
-       float r = (random() < 0.5);
-       if(r && Monster_Attack_Melee(self.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((r) ? self.anim_melee2 : self.anim_melee3), self.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW.m_id, true))
-       {
-               Monster_Delay(1, 0, 0.5, M_Shambler_Attack_Swing);
-               self.attack_finished_single[0] += 0.5;
-               self.anim_finished = self.attack_finished_single[0];
-       }
+void M_Shambler_Attack_Swing(entity this)
+{
+       Monster_Attack_Melee(this, this.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((random() >= 0.5) ? this.anim_melee2 : this.anim_melee3), this.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW.m_id, true);
 }
 
 #include <common/effects/qc/all.qh>
@@ -89,7 +83,7 @@ void M_Shambler_Attack_Lightning_Explode()
        entity head;
 
        sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
-       Send_Effect(EFFECT_ELECTRO_IMPACT, '0 0 0', '0 0 0', 1);
+       Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
 
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
@@ -111,18 +105,18 @@ void M_Shambler_Attack_Lightning_Explode()
        self.nextthink = time + 0.2;
 }
 
-void M_Shambler_Attack_Lightning_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
-       if (self.health <= 0)
+void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+       if (this.health <= 0)
                return;
 
-       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
+       if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
                return; // g_projectiles_damage says to halt
 
-       self.health = self.health - damage;
+       this.health = this.health - damage;
 
-       if (self.health <= 0)
-               W_PrepareExplosionByDamage(attacker, self.use);
+       if (this.health <= 0)
+               WITH(entity, self, this, W_PrepareExplosionByDamage(attacker, this.use));
 }
 
 void M_Shambler_Attack_Lightning_Touch()
@@ -143,20 +137,20 @@ void M_Shambler_Attack_Lightning_Think()
        }
 }
 
-void M_Shambler_Attack_Lightning()
-{SELFPARAM();
+void M_Shambler_Attack_Lightning(entity this)
+{
        entity gren;
 
-       monster_makevectors(self.enemy);
+       monster_makevectors(this, this.enemy);
 
        gren = new(grenade);
-       gren.owner = gren.realowner = self;
+       gren.owner = gren.realowner = this;
        gren.bot_dodge = true;
        gren.bot_dodgerating = (autocvar_g_monster_shambler_attack_lightning_damage);
        gren.movetype = MOVETYPE_BOUNCE;
        PROJECTILE_MAKETRIGGER(gren);
        gren.projectiledeathtype = DEATH_MONSTER_SHAMBLER_ZAP.m_id;
-       setorigin(gren, CENTER_OR_VIEWOFS(self));
+       setorigin(gren, CENTER_OR_VIEWOFS(this));
        setsize(gren, '-8 -8 -8', '8 8 8');
        gren.scale = 2.5;
 
@@ -182,39 +176,41 @@ void M_Shambler_Attack_Lightning()
 
 .int state;
 
-float M_Shambler_Attack(float attack_type, entity targ)
-{SELFPARAM();
+bool M_Shambler_Attack(int attack_type, entity actor, entity targ)
+{
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
                {
-                       M_Shambler_Attack_Swing();
+                       int swing_cnt = bound(1, floor(random() * 4), 3);
+                       Monster_Delay(actor, swing_cnt, 0.5, M_Shambler_Attack_Swing);
+                       actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
                        return true;
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       float randomness = random(), enemy_len = vlen(self.enemy.origin - self.origin);
+                       float randomness = random();
 
-                       if(time >= self.shambler_lastattack) // shambler doesn't attack much
-                       if(IS_ONGROUND(self))
-                       if(randomness <= 0.5 && enemy_len <= autocvar_g_monster_shambler_attack_smash_range)
+                       if(time >= actor.shambler_lastattack) // shambler doesn't attack much
+                       if(IS_ONGROUND(actor))
+                       if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_shambler_attack_smash_range))
                        {
-                               setanim(self, self.anim_melee2, true, true, false);
-                               Monster_Delay(1, 0, 0.7, M_Shambler_Attack_Smash);
-                               self.attack_finished_single[0] = time + 1.1;
-                               self.anim_finished = time + 1.1;
-                               self.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
-                               self.shambler_lastattack = time + 3 + random() * 1.5;
+                               setanim(actor, actor.anim_melee2, true, true, false);
+                               Monster_Delay(actor, 1, 0.7, M_Shambler_Attack_Smash);
+                               actor.attack_finished_single[0] = time + 1.1;
+                               actor.anim_finished = time + 1.1;
+                               actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
+                               actor.shambler_lastattack = time + 3 + random() * 1.5;
                                return true;
                        }
-                       else if(randomness <= 0.1 && enemy_len >= autocvar_g_monster_shambler_attack_smash_range * 1.5) // small chance, don't want this spammed
+                       else if(randomness <= 0.1 && vdist(actor.enemy.origin - actor.origin, >=, autocvar_g_monster_shambler_attack_smash_range * 1.5)) // small chance, don't want this spammed
                        {
-                               setanim(self, self.anim_shoot, true, true, false);
-                               self.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
-                               self.attack_finished_single[0] = time + 1.1;
-                               self.anim_finished = 1.1;
-                               self.shambler_lastattack = time + 3 + random() * 1.5;
-                               Monster_Delay(1, 0, 0.6, M_Shambler_Attack_Lightning);
+                               setanim(actor, actor.anim_shoot, true, true, false);
+                               actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
+                               actor.attack_finished_single[0] = time + 1.1;
+                               actor.anim_finished = 1.1;
+                               actor.shambler_lastattack = time + 3 + random() * 1.5;
+                               Monster_Delay(actor, 1, 0.6, M_Shambler_Attack_Lightning);
                                return true;
                        }
 
@@ -225,66 +221,61 @@ float M_Shambler_Attack(float attack_type, entity targ)
        return false;
 }
 
-spawnfunc(monster_shambler) { Monster_Spawn(MON_SHAMBLER.monsterid); }
+spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); }
 #endif // SVQC
 
                #ifdef SVQC
-               METHOD(Shambler, mr_think, bool(Shambler thismon))
+               METHOD(Shambler, mr_think, bool(Shambler thismon, entity actor))
                {
                        return true;
                }
-               METHOD(Shambler, mr_pain, bool(Shambler thismon))
+               METHOD(Shambler, mr_pain, bool(Shambler thismon, entity actor))
                {
-                       SELFPARAM();
-                       self.pain_finished = time + 0.5;
-                       setanim(self, self.anim_pain1, true, true, false);
+                       actor.pain_finished = time + 0.5;
+                       setanim(actor, actor.anim_pain1, true, true, false);
                        return true;
                }
-               METHOD(Shambler, mr_death, bool(Shambler thismon))
+               METHOD(Shambler, mr_death, bool(Shambler thismon, entity actor))
                {
-                       SELFPARAM();
-                       setanim(self, self.anim_die1, false, true, true);
+                       setanim(actor, actor.anim_die1, false, true, true);
                        return true;
                }
                #endif
                #ifndef MENUQC
-               METHOD(Shambler, mr_anim, bool(Shambler thismon))
+               METHOD(Shambler, mr_anim, bool(Shambler thismon, entity actor))
                {
-                       SELFPARAM();
                        vector none = '0 0 0';
-                       self.anim_die1 = animfixfps(self, '8 1 0.5', none); // 2 seconds
-                       self.anim_walk = animfixfps(self, '1 1 1', none);
-                       self.anim_idle = animfixfps(self, '0 1 1', none);
-                       self.anim_pain1 = animfixfps(self, '7 1 2', none); // 0.5 seconds
-                       self.anim_melee1 = animfixfps(self, '3 1 5', none); // analyze models and set framerate
-                       self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
-                       self.anim_melee3 = animfixfps(self, '5 1 5', none); // analyze models and set framerate
-                       self.anim_shoot = animfixfps(self, '6 1 5', none); // analyze models and set framerate
-                       self.anim_run = animfixfps(self, '2 1 1', none);
-
+                       actor.anim_die1 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
+                       actor.anim_walk = animfixfps(actor, '1 1 1', none);
+                       actor.anim_idle = animfixfps(actor, '0 1 1', none);
+                       actor.anim_pain1 = animfixfps(actor, '7 1 2', none); // 0.5 seconds
+                       actor.anim_melee1 = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
+                       actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
+                       actor.anim_melee3 = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
+                       actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
+                       actor.anim_run = animfixfps(actor, '2 1 1', none);
                        return true;
                }
                #endif
                #ifdef SVQC
                spawnfunc(item_health_mega);
                .float animstate_endtime;
-               METHOD(Shambler, mr_setup, bool(Shambler thismon))
+               METHOD(Shambler, mr_setup, bool(Shambler thismon, entity actor))
                {
-                       SELFPARAM();
-                       if(!self.health) self.health = (autocvar_g_monster_shambler_health);
-                       if(!self.attack_range) self.attack_range = 150;
-                       if(!self.speed) { self.speed = (autocvar_g_monster_shambler_speed_walk); }
-                       if(!self.speed2) { self.speed2 = (autocvar_g_monster_shambler_speed_run); }
-                       if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_shambler_speed_stop); }
-                       if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); }
-
-                       self.monster_loot = spawnfunc_item_health_mega;
-                       self.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
-
-                       setanim(self, self.anim_shoot, false, true, true);
-                       self.spawn_time = self.animstate_endtime;
-                       self.spawnshieldtime = self.spawn_time;
-                       self.monster_attackfunc = M_Shambler_Attack;
+                       if(!actor.health) actor.health = (autocvar_g_monster_shambler_health);
+                       if(!actor.attack_range) actor.attack_range = 150;
+                       if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); }
+                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_shambler_speed_run); }
+                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_shambler_speed_stop); }
+                       if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); }
+
+                       actor.monster_loot = spawnfunc_item_health_mega;
+                       actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX
+
+                       setanim(actor, actor.anim_shoot, false, true, true);
+                       actor.spawn_time = actor.animstate_endtime;
+                       actor.spawnshieldtime = actor.spawn_time;
+                       actor.monster_attackfunc = M_Shambler_Attack;
 
                        return true;
                }
index 0ec5f78..8923994 100644 (file)
@@ -50,7 +50,7 @@ float autocvar_g_monster_spider_attack_web_delay;
 float autocvar_g_monster_spider_attack_bite_damage;
 float autocvar_g_monster_spider_attack_bite_delay;
 
-void M_Spider_Attack_Web();
+void M_Spider_Attack_Web(entity this);
 
 REGISTER_MUTATOR(spiderweb, true);
 
@@ -101,7 +101,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity
         if (isPlayer) actor.enemy = Monster_FindTarget(actor);
         W_SetupShot_Dir(actor, v_forward, false, 0, SND(SpiderAttack_FIRE), CH_WEAPON_B, 0);
        if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
-               M_Spider_Attack_Web();
+               M_Spider_Attack_Web(actor);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         return;
     }
@@ -111,7 +111,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity
                actor.enemy = Monster_FindTarget(actor);
                actor.attack_range = 60;
        }
-       Monster_Attack_Melee(actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true);
+       Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true);
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
@@ -153,14 +153,14 @@ void M_Spider_Attack_Web_Touch()
 
 void adaptor_think2use_hittype_splash();
 
-void M_Spider_Attack_Web()
-{SELFPARAM();
-       monster_makevectors(self.enemy);
+void M_Spider_Attack_Web(entity this)
+{
+       monster_makevectors(this, this.enemy);
 
-       sound(self, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
 
        entity proj = new(plasma);
-       proj.owner = proj.realowner = self;
+       proj.owner = proj.realowner = this;
        proj.use = M_Spider_Attack_Web_Explode;
        proj.think = adaptor_think2use_hittype_splash;
        proj.bot_dodge = true;
@@ -168,7 +168,7 @@ void M_Spider_Attack_Web()
        proj.nextthink = time + 5;
        PROJECTILE_MAKETRIGGER(proj);
        proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id;
-       setorigin(proj, CENTER_OR_VIEWOFS(self));
+       setorigin(proj, CENTER_OR_VIEWOFS(this));
 
        //proj.glow_size = 50;
        //proj.glow_color = 45;
@@ -190,20 +190,20 @@ void M_Spider_Attack_Web()
        CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true);
 }
 
-bool M_Spider_Attack(int attack_type, entity targ)
-{SELFPARAM();
+bool M_Spider_Attack(int attack_type, entity actor, entity targ)
+{
     .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
                Weapon wep = WEP_SPIDER_ATTACK;
                case MONSTER_ATTACK_MELEE:
                {
-                       wep.wr_think(wep, self, weaponentity, 2);
+                       wep.wr_think(wep, actor, weaponentity, 2);
                        return true;
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       wep.wr_think(wep, self, weaponentity, 1);
+                       wep.wr_think(wep, actor, weaponentity, 1);
                        return true;
                }
        }
@@ -211,53 +211,49 @@ bool M_Spider_Attack(int attack_type, entity targ)
        return false;
 }
 
-spawnfunc(monster_spider) { Monster_Spawn(MON_SPIDER.monsterid); }
+spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); }
 #endif // SVQC
 
                #ifdef SVQC
-               METHOD(Spider, mr_think, bool(Spider thismon))
+               METHOD(Spider, mr_think, bool(Spider thismon, entity actor))
                {
                        return true;
                }
-               METHOD(Spider, mr_pain, bool(Spider thismon))
+               METHOD(Spider, mr_pain, bool(Spider thismon, entity actor))
                {
                        return true;
                }
-               METHOD(Spider, mr_death, bool(Spider thismon))
+               METHOD(Spider, mr_death, bool(Spider thismon, entity actor))
                {
-                       SELFPARAM();
-                       setanim(self, self.anim_melee, false, true, true);
-                       self.angles_x = 180;
+                       setanim(actor, actor.anim_melee, false, true, true);
+                       actor.angles_x = 180;
                        return true;
                }
                #endif
                #ifndef MENUQC
-               METHOD(Spider, mr_anim, bool(Spider thismon))
+               METHOD(Spider, mr_anim, bool(Spider thismon, entity actor))
                {
-                       SELFPARAM();
                        vector none = '0 0 0';
-                       self.anim_walk = animfixfps(self, '1 1 1', none);
-                       self.anim_idle = animfixfps(self, '0 1 1', none);
-                       self.anim_melee = animfixfps(self, '2 1 5', none); // analyze models and set framerate
-                       self.anim_shoot = animfixfps(self, '3 1 5', none); // analyze models and set framerate
-                       self.anim_run = animfixfps(self, '1 1 1', none);
-
+                       actor.anim_walk = animfixfps(actor, '1 1 1', none);
+                       actor.anim_idle = animfixfps(actor, '0 1 1', none);
+                       actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
+                       actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate
+                       actor.anim_run = animfixfps(actor, '1 1 1', none);
                        return true;
                }
                #endif
                #ifdef SVQC
                spawnfunc(item_health_medium);
-               METHOD(Spider, mr_setup, bool(Spider thismon))
+               METHOD(Spider, mr_setup, bool(Spider thismon, entity actor))
                {
-                       SELFPARAM();
-                       if(!self.health) self.health = (autocvar_g_monster_spider_health);
-                       if(!self.speed) { self.speed = (autocvar_g_monster_spider_speed_walk); }
-                       if(!self.speed2) { self.speed2 = (autocvar_g_monster_spider_speed_run); }
-                       if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_spider_speed_stop); }
-                       if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
-
-                       self.monster_loot = spawnfunc_item_health_medium;
-                       self.monster_attackfunc = M_Spider_Attack;
+                       if(!actor.health) actor.health = (autocvar_g_monster_spider_health);
+                       if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); }
+                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); }
+                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); }
+                       if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); }
+
+                       actor.monster_loot = spawnfunc_item_health_medium;
+                       actor.monster_attackfunc = M_Spider_Attack;
 
                        return true;
                }
index 4fde531..b7d398d 100644 (file)
@@ -56,7 +56,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity
                if (IS_MONSTER(actor)) {
                        actor.attack_finished_single[0] = time + 1.2;
                        actor.anim_finished = time + 1.2;
-                       monster_makevectors(actor.enemy);
+                       monster_makevectors(actor, actor.enemy);
                }
 
                entity missile = spawn();
@@ -101,13 +101,15 @@ void M_Wyvern_Attack_Fireball_Explode()
        SELFPARAM();
        Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
 
-       entity owner = self.realowner;
+       entity own = self.realowner;
 
-       RadiusDamage(self, owner, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
+       RadiusDamage(self, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
 
-       for (entity e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); )
-       if (vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
-               Fire_AddDamage(e, owner, 5 * MONSTER_SKILLMOD(owner), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
+       FOREACH_ENTITY_FLOAT(takedamage, DAMAGE_AIM,
+       {
+               if(vdist(it.origin - self.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
+                       Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, self.projectiledeathtype);
+       });
 
        remove(self);
 }
@@ -119,18 +121,17 @@ void M_Wyvern_Attack_Fireball_Touch()
        M_Wyvern_Attack_Fireball_Explode();
 }
 
-float M_Wyvern_Attack(float attack_type, entity targ)
+bool M_Wyvern_Attack(int attack_type, entity actor, entity targ)
 {
-       SELFPARAM();
        .entity weaponentity = weaponentities[0];
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
                case MONSTER_ATTACK_RANGED:
                {
-                       w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin);
+                       w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
                        Weapon wep = WEP_WYVERN_ATTACK;
-                       wep.wr_think(wep, self, weaponentity, 1);
+                       wep.wr_think(wep, actor, weaponentity, 1);
                        return true;
                }
        }
@@ -138,59 +139,54 @@ float M_Wyvern_Attack(float attack_type, entity targ)
        return false;
 }
 
-spawnfunc(monster_wyvern) { Monster_Spawn(MON_WYVERN.monsterid); }
+spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); }
 #endif // SVQC
 
                #ifdef SVQC
-               METHOD(Wyvern, mr_think, bool(Wyvern thismon))
+               METHOD(Wyvern, mr_think, bool(Wyvern thismon, entity actor))
                {
                        return true;
                }
-               METHOD(Wyvern, mr_pain, bool(Wyvern thismon))
+               METHOD(Wyvern, mr_pain, bool(Wyvern thismon, entity actor))
                {
-                       SELFPARAM();
-                       self.pain_finished = time + 0.5;
-                       setanim(self, self.anim_pain1, true, true, false);
+                       actor.pain_finished = time + 0.5;
+                       setanim(actor, actor.anim_pain1, true, true, false);
                        return true;
                }
-               METHOD(Wyvern, mr_death, bool(Wyvern thismon))
+               METHOD(Wyvern, mr_death, bool(Wyvern thismon, entity actor))
                {
-                       SELFPARAM();
-                       setanim(self, self.anim_die1, false, true, true);
-                       self.velocity_x = -200 + 400 * random();
-                       self.velocity_y = -200 + 400 * random();
-                       self.velocity_z = 100 + 100 * random();
+                       setanim(actor, actor.anim_die1, false, true, true);
+                       actor.velocity_x = -200 + 400 * random();
+                       actor.velocity_y = -200 + 400 * random();
+                       actor.velocity_z = 100 + 100 * random();
                        return true;
                }
                #endif
                #ifndef MENUQC
-               METHOD(Wyvern, mr_anim, bool(Wyvern thismon))
+               METHOD(Wyvern, mr_anim, bool(Wyvern thismon, entity actor))
                {
-                       SELFPARAM();
                        vector none = '0 0 0';
-                       self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds
-                       self.anim_walk = animfixfps(self, '1 1 1', none);
-                       self.anim_idle = animfixfps(self, '0 1 1', none);
-                       self.anim_pain1 = animfixfps(self, '3 1 2', none); // 0.5 seconds
-                       self.anim_shoot = animfixfps(self, '2 1 5', none); // analyze models and set framerate
-                       self.anim_run = animfixfps(self, '1 1 1', none);
-
+                       actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
+                       actor.anim_walk = animfixfps(actor, '1 1 1', none);
+                       actor.anim_idle = animfixfps(actor, '0 1 1', none);
+                       actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
+                       actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
+                       actor.anim_run = animfixfps(actor, '1 1 1', none);
                        return true;
                }
                #endif
                #ifdef SVQC
                spawnfunc(item_cells);
-               METHOD(Wyvern, mr_setup, bool(Wyvern thismon))
+               METHOD(Wyvern, mr_setup, bool(Wyvern thismon, entity actor))
                {
-                       SELFPARAM();
-                       if(!self.health) self.health = (autocvar_g_monster_wyvern_health);
-                       if(!self.speed) { self.speed = (autocvar_g_monster_wyvern_speed_walk); }
-                       if(!self.speed2) { self.speed2 = (autocvar_g_monster_wyvern_speed_run); }
-                       if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
-                       if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
-
-                       self.monster_loot = spawnfunc_item_cells;
-                       self.monster_attackfunc = M_Wyvern_Attack;
+                       if(!actor.health) actor.health = (autocvar_g_monster_wyvern_health);
+                       if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
+                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
+                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
+                       if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
+
+                       actor.monster_loot = spawnfunc_item_cells;
+                       actor.monster_attackfunc = M_Wyvern_Attack;
 
                        return true;
                }
index d63188b..b522a96 100644 (file)
@@ -98,130 +98,125 @@ void M_Zombie_Attack_Leap_Touch()
        }
 }
 
-void M_Zombie_Defend_Block_End()
-{SELFPARAM();
-       if(self.health <= 0)
+void M_Zombie_Defend_Block_End(entity this)
+{
+       if(this.health <= 0)
                return;
 
-       setanim(self, self.anim_blockend, false, true, true);
-       self.armorvalue = autocvar_g_monsters_armor_blockpercent;
+       setanim(this, this.anim_blockend, false, true, true);
+       this.armorvalue = autocvar_g_monsters_armor_blockpercent;
 }
 
-float M_Zombie_Defend_Block()
-{SELFPARAM();
-       self.armorvalue = 0.9;
-       self.state = MONSTER_ATTACK_MELEE; // freeze monster
-       self.attack_finished_single[0] = time + 2.1;
-       self.anim_finished = self.attack_finished_single[0];
-       setanim(self, self.anim_blockstart, false, true, true);
+bool M_Zombie_Defend_Block(entity this)
+{
+       this.armorvalue = 0.9;
+       this.state = MONSTER_ATTACK_MELEE; // freeze monster
+       this.attack_finished_single[0] = time + 2.1;
+       this.anim_finished = this.attack_finished_single[0];
+       setanim(this, this.anim_blockstart, false, true, true);
 
-       Monster_Delay(1, 0, 2, M_Zombie_Defend_Block_End);
+       Monster_Delay(this, 1, 2, M_Zombie_Defend_Block_End);
 
        return true;
 }
 
-float M_Zombie_Attack(float attack_type, entity targ)
-{SELFPARAM();
+bool M_Zombie_Attack(int attack_type, entity actor, entity targ)
+{
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
                {
-                       if(random() < 0.3 && self.health < 75 && self.enemy.health > 10)
-                               return M_Zombie_Defend_Block();
+                       if(random() < 0.3 && actor.health < 75 && actor.enemy.health > 10)
+                               return M_Zombie_Defend_Block(actor);
 
-                       float rand = random();
+                       float anim_chance = random();
                        vector chosen_anim;
 
-                       if(rand < 0.33)
-                               chosen_anim = self.anim_melee1;
-                       else if(rand < 0.66)
-                               chosen_anim = self.anim_melee2;
+                       if(anim_chance < 0.33)
+                               chosen_anim = actor.anim_melee1;
+                       else if(anim_chance < 0.66)
+                               chosen_anim = actor.anim_melee2;
                        else
-                               chosen_anim = self.anim_melee3;
+                               chosen_anim = actor.anim_melee3;
 
-                       return Monster_Attack_Melee(self.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, self.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE.m_id, true);
+                       return Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, actor.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE.m_id, true);
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       makevectors(self.angles);
-                       return Monster_Attack_Leap(self.anim_shoot, M_Zombie_Attack_Leap_Touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay));
+                       makevectors(actor.angles);
+                       return Monster_Attack_Leap(actor, actor.anim_shoot, M_Zombie_Attack_Leap_Touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay));
                }
        }
 
        return false;
 }
 
-spawnfunc(monster_zombie) { Monster_Spawn(MON_ZOMBIE.monsterid); }
+spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); }
 #endif // SVQC
 
                #ifdef SVQC
-               METHOD(Zombie, mr_think, bool(Zombie thismon))
+               METHOD(Zombie, mr_think, bool(Zombie thismon, entity actor))
                {
-                       SELFPARAM();
-                       if(time >= self.spawn_time)
-                               self.damageforcescale = autocvar_g_monster_zombie_damageforcescale;
+                       if(time >= actor.spawn_time)
+                               actor.damageforcescale = autocvar_g_monster_zombie_damageforcescale;
                        return true;
                }
-               METHOD(Zombie, mr_pain, bool(Zombie thismon))
+               METHOD(Zombie, mr_pain, bool(Zombie thismon, entity actor))
                {
-                       SELFPARAM();
-                       self.pain_finished = time + 0.34;
-                       setanim(self, ((random() > 0.5) ? self.anim_pain1 : self.anim_pain2), true, true, false);
+                       actor.pain_finished = time + 0.34;
+                       setanim(actor, ((random() > 0.5) ? actor.anim_pain1 : actor.anim_pain2), true, true, false);
                        return true;
                }
-               METHOD(Zombie, mr_death, bool(Zombie thismon))
+               METHOD(Zombie, mr_death, bool(Zombie thismon, entity actor))
                {
-                       SELFPARAM();
-                       self.armorvalue = autocvar_g_monsters_armor_blockpercent;
+                       actor.armorvalue = autocvar_g_monsters_armor_blockpercent;
 
-                       setanim(self, ((random() > 0.5) ? self.anim_die1 : self.anim_die2), false, true, true);
+                       setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true);
                        return true;
                }
                #endif
                #ifndef MENUQC
-               METHOD(Zombie, mr_anim, bool(Zombie thismon))
+               METHOD(Zombie, mr_anim, bool(Zombie thismon, entity actor))
                {
-                       SELFPARAM();
                        vector none = '0 0 0';
-                       self.anim_die1 = animfixfps(self, '9 1 0.5', none); // 2 seconds
-                       self.anim_die2 = animfixfps(self, '12 1 0.5', none); // 2 seconds
-                       self.anim_spawn = animfixfps(self, '30 1 3', none);
-                       self.anim_walk = animfixfps(self, '27 1 1', none);
-                       self.anim_idle = animfixfps(self, '19 1 1', none);
-                       self.anim_pain1 = animfixfps(self, '20 1 2', none); // 0.5 seconds
-                       self.anim_pain2 = animfixfps(self, '22 1 2', none); // 0.5 seconds
-                       self.anim_melee1 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
-                       self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
-                       self.anim_melee3 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
-                       self.anim_shoot = animfixfps(self, '0 1 5', none); // analyze models and set framerate
-                       self.anim_run = animfixfps(self, '27 1 1', none);
-                       self.anim_blockstart = animfixfps(self, '8 1 1', none);
-                       self.anim_blockend = animfixfps(self, '7 1 1', none);
-
+                       actor.anim_die1 = animfixfps(actor, '9 1 0.5', none); // 2 seconds
+                       actor.anim_die2 = animfixfps(actor, '12 1 0.5', none); // 2 seconds
+                       actor.anim_spawn = animfixfps(actor, '30 1 3', none);
+                       actor.anim_walk = animfixfps(actor, '27 1 1', none);
+                       actor.anim_idle = animfixfps(actor, '19 1 1', none);
+                       actor.anim_pain1 = animfixfps(actor, '20 1 2', none); // 0.5 seconds
+                       actor.anim_pain2 = animfixfps(actor, '22 1 2', none); // 0.5 seconds
+                       actor.anim_melee1 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
+                       actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
+                       actor.anim_melee3 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate
+                       actor.anim_shoot = animfixfps(actor, '0 1 5', none); // analyze models and set framerate
+                       actor.anim_run = animfixfps(actor, '27 1 1', none);
+                       actor.anim_blockstart = animfixfps(actor, '8 1 1', none);
+                       actor.anim_blockend = animfixfps(actor, '7 1 1', none);
                        return true;
                }
                #endif
                #ifdef SVQC
-               METHOD(Zombie, mr_setup, bool(Zombie thismon))
+               METHOD(Zombie, mr_setup, bool(Zombie thismon, entity actor))
                {
-                       if(!self.health) self.health = (autocvar_g_monster_zombie_health);
-                       if(!self.speed) { self.speed = (autocvar_g_monster_zombie_speed_walk); }
-                       if(!self.speed2) { self.speed2 = (autocvar_g_monster_zombie_speed_run); }
-                       if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_zombie_speed_stop); }
+                       if(!actor.health) actor.health = (autocvar_g_monster_zombie_health);
+                       if(!actor.speed) { actor.speed = (autocvar_g_monster_zombie_speed_walk); }
+                       if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_zombie_speed_run); }
+                       if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_zombie_speed_stop); }
 
-                       if(self.spawnflags & MONSTERFLAG_NORESPAWN)
-                               self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
+                       if(actor.spawnflags & MONSTERFLAG_NORESPAWN)
+                               actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
 
-                       self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
+                       actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
 
-                       self.monster_loot = spawnfunc_item_health_medium;
-                       self.monster_attackfunc = M_Zombie_Attack;
-                       self.spawnshieldtime = self.spawn_time;
-                       self.respawntime = 0.2;
-                       self.damageforcescale = 0.0001; // no push while spawning
+                       actor.monster_loot = spawnfunc_item_health_medium;
+                       actor.monster_attackfunc = M_Zombie_Attack;
+                       actor.spawnshieldtime = actor.spawn_time;
+                       actor.respawntime = 0.2;
+                       actor.damageforcescale = 0.0001; // no push while spawning
 
-                       setanim(self, self.anim_spawn, false, true, true);
-                       self.spawn_time = self.animstate_endtime;
+                       setanim(actor, actor.anim_spawn, false, true, true);
+                       actor.spawn_time = actor.animstate_endtime;
 
                        return true;
                }
index e2e573d..7045926 100644 (file)
@@ -63,7 +63,7 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity
        }
 
        // Monster_Spawn checks if monster is valid
-       WITH(entity, self, e, Monster_Spawn(monster_id));
+       Monster_Spawn(e, monster_id);
 
        return e;
 }
index 967757e..ccc3b83 100644 (file)
     #include <server/round_handler.qh>
 #endif
 
-void monsters_setstatus()
-{SELFPARAM();
-       self.stat_monsters_total = monsters_total;
-       self.stat_monsters_killed = monsters_killed;
+void monsters_setstatus(entity this)
+{
+       this.stat_monsters_total = monsters_total;
+       this.stat_monsters_killed = monsters_killed;
 }
 
-void monster_dropitem()
-{SELFPARAM();
-       if(!self.candrop || !self.monster_loot)
+void monster_dropitem(entity this)
+{
+       if(!this.candrop || !this.monster_loot)
                return;
 
-       vector org = self.origin + ((self.mins + self.maxs) * 0.5);
+       vector org = this.origin + ((this.mins + this.maxs) * 0.5);
        entity e = new(droppedweapon); // use weapon handling to remove it on touch
        e.spawnfunc_checked = true;
 
-       e.monster_loot = self.monster_loot;
+       e.monster_loot = this.monster_loot;
 
        MUTATOR_CALLHOOK(MonsterDropItem, e);
        e = other;
 
        if(e && e.monster_loot)
        {
-               setself(e);
                e.noalign = true;
-               e.monster_loot(e);
+               WITH(entity, self, e, e.monster_loot(e));
                e.gravity = 1;
                e.movetype = MOVETYPE_TOSS;
                e.reset = SUB_Remove;
@@ -57,65 +56,62 @@ void monster_dropitem()
                e.velocity = randomvec() * 175 + '0 0 325';
                e.item_spawnshieldtime = time + 0.7;
                SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1);
-               setself(this);
        }
 }
 
-void monster_makevectors(entity e)
-{SELFPARAM();
-       if(IS_MONSTER(self))
+void monster_makevectors(entity this, entity targ)
+{
+       if(IS_MONSTER(this))
        {
-               vector v;
-
-               v = e.origin + (e.mins + e.maxs) * 0.5;
-               self.v_angle = vectoangles(v - (self.origin + self.view_ofs));
-               self.v_angle_x = -self.v_angle_x;
+               vector v = targ.origin + (targ.mins + targ.maxs) * 0.5;
+               this.v_angle = vectoangles(v - (this.origin + this.view_ofs));
+               this.v_angle_x = -this.v_angle_x;
        }
 
-       makevectors(self.v_angle);
+       makevectors(this.v_angle);
 }
 
 // ===============
 // Target handling
 // ===============
 
-bool Monster_ValidTarget(entity mon, entity player)
-{SELFPARAM();
+bool Monster_ValidTarget(entity this, entity targ)
+{
        // ensure we're not checking nonexistent monster/target
-       if(!mon || !player) { return false; }
+       if(!this || !targ) { return false; }
 
-       if((player == mon)
-       || (autocvar_g_monsters_lineofsight && !checkpvs(mon.origin + mon.view_ofs, player)) // enemy cannot be seen
-       || (IS_VEHICLE(player) && !((get_monsterinfo(mon.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
+       if((targ == this)
+       || (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen
+       || (IS_VEHICLE(targ) && !((get_monsterinfo(this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
        || (time < game_starttime) // monsters do nothing before match has started
-       || (player.takedamage == DAMAGE_NO)
-       || (player.items & IT_INVISIBILITY)
-       || (IS_SPEC(player) || IS_OBSERVER(player)) // don't attack spectators
-       || (!IS_VEHICLE(player) && (IS_DEAD(player) || IS_DEAD(mon) || player.health <= 0 || mon.health <= 0))
-       || (mon.monster_follow == player || player.monster_follow == mon)
-       || (!IS_VEHICLE(player) && (player.flags & FL_NOTARGET))
-       || (!autocvar_g_monsters_typefrag && player.BUTTON_CHAT)
-       || (SAME_TEAM(player, mon))
-       || (STAT(FROZEN, player))
-       || (player.alpha != 0 && player.alpha < 0.5)
+       || (targ.takedamage == DAMAGE_NO)
+       || (targ.items & IT_INVISIBILITY)
+       || (IS_SPEC(targ) || IS_OBSERVER(targ)) // don't attack spectators
+       || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || targ.health <= 0 || this.health <= 0))
+       || (this.monster_follow == targ || targ.monster_follow == this)
+       || (!IS_VEHICLE(targ) && (targ.flags & FL_NOTARGET))
+       || (!autocvar_g_monsters_typefrag && targ.BUTTON_CHAT)
+       || (SAME_TEAM(targ, this))
+       || (STAT(FROZEN, targ))
+       || (targ.alpha != 0 && targ.alpha < 0.5)
        )
        {
                // if any of the above checks fail, target is not valid
                return false;
        }
 
-       traceline(mon.origin + self.view_ofs, player.origin, 0, mon);
+       traceline(this.origin + this.view_ofs, targ.origin, 0, this);
 
-       if((trace_fraction < 1) && (trace_ent != player))
+       if((trace_fraction < 1) && (trace_ent != targ))
                return false;
 
-       if(autocvar_g_monsters_target_infront || (mon.spawnflags & MONSTERFLAG_INFRONT))
-       if(mon.enemy != player)
+       if(autocvar_g_monsters_target_infront || (this.spawnflags & MONSTERFLAG_INFRONT))
+       if(this.enemy != targ)
        {
                float dot;
 
-               makevectors (mon.angles);
-               dot = normalize (player.origin - mon.origin) * v_forward;
+               makevectors (this.angles);
+               dot = normalize (targ.origin - this.origin) * v_forward;
 
                if(dot <= autocvar_g_monsters_target_infront_range) { return false; }
        }
@@ -142,7 +138,7 @@ entity Monster_FindTarget(entity mon)
                        if(closest_target)
                        {