]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/hud_smooth_weapon_switch' into 'master'
authorMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:46:33 +0000 (08:46 +0000)
committerMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:46:33 +0000 (08:46 +0000)
Smooth selection change in the weapons panel, optionally with a nice lens effect

See merge request !321

256 files changed:
qcsrc/client/announcer.qc
qcsrc/client/autocvars.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/shownames.qc
qcsrc/client/view.qc
qcsrc/client/weapons/projectile.qc
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/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_controlpoint.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_generator.qc
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/snake.qc
qcsrc/common/minigames/sv_minigames.qc
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/sv_monsters.qc
qcsrc/common/monsters/sv_monsters.qh
qcsrc/common/mutators/mutator/buffs/all.qh
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/instagib/instagib.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nix/nix.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/overkill/overkill.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/mutators/mutator/physical_items/physical_items.qc
qcsrc/common/mutators/mutator/pinata/pinata.qc
qcsrc/common/mutators/mutator/sandbox/sandbox.qc
qcsrc/common/mutators/mutator/superspec/superspec.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
qcsrc/common/notifications/all.qc
qcsrc/common/physics/movelib.qc
qcsrc/common/physics/movelib.qh
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/movetypes.qh
qcsrc/common/physics/movetypes/push.qc
qcsrc/common/physics/player.qc
qcsrc/common/sounds/sound.qh
qcsrc/common/state.qc
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/common/triggers/func/bobbing.qc
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/conveyor.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door_rotating.qc
qcsrc/common/triggers/func/door_secret.qc
qcsrc/common/triggers/func/fourier.qc
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/func/pendulum.qc
qcsrc/common/triggers/func/plat.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/common/triggers/func/rainsnow.qc
qcsrc/common/triggers/func/rotating.qc
qcsrc/common/triggers/func/stardust.qc
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/func/vectormamamam.qc
qcsrc/common/triggers/misc/corner.qc
qcsrc/common/triggers/misc/follow.qc
qcsrc/common/triggers/misc/laser.qc
qcsrc/common/triggers/misc/teleport_dest.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/platforms.qh
qcsrc/common/triggers/subs.qc
qcsrc/common/triggers/subs.qh
qcsrc/common/triggers/target/location.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/triggers/target/music.qh
qcsrc/common/triggers/target/spawn.qc
qcsrc/common/triggers/target/speaker.qc
qcsrc/common/triggers/target/voicescript.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/teleporters.qh
qcsrc/common/triggers/trigger/counter.qc
qcsrc/common/triggers/trigger/delay.qc
qcsrc/common/triggers/trigger/gamestart.qc
qcsrc/common/triggers/trigger/gravity.qc
qcsrc/common/triggers/trigger/heal.qc
qcsrc/common/triggers/trigger/hurt.qc
qcsrc/common/triggers/trigger/impulse.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/jumppads.qh
qcsrc/common/triggers/trigger/keylock.qc
qcsrc/common/triggers/trigger/magicear.qc
qcsrc/common/triggers/trigger/monoflop.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/trigger/multi.qh
qcsrc/common/triggers/trigger/multivibrator.qc
qcsrc/common/triggers/trigger/secret.qc
qcsrc/common/triggers/trigger/swamp.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/triggers/trigger/viewloc.qc
qcsrc/common/triggers/triggers.qc
qcsrc/common/triggers/triggers.qh
qcsrc/common/turrets/checkpoint.qc
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/turrets/targettrigger.qc
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/flac.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/machinegun.qc
qcsrc/common/turrets/turret/machinegun_weapon.qc
qcsrc/common/turrets/turret/mlrs.qc
qcsrc/common/turrets/turret/phaser.qc
qcsrc/common/turrets/turret/phaser_weapon.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/turrets/util.qc
qcsrc/common/turrets/util.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
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/weapons/all.qh
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/crylink.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/hlac.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/common/weapons/weapon/vortex.qc
qcsrc/dpdefs/csprogsdefs.qh
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/lib/csqcmodel/sv_model.qc
qcsrc/lib/defer.qh
qcsrc/lib/net.qh
qcsrc/lib/self.qh
qcsrc/lib/warpzone/client.qc
qcsrc/lib/warpzone/common.qc
qcsrc/lib/warpzone/common.qh
qcsrc/lib/warpzone/server.qc
qcsrc/lib/warpzone/server.qh
qcsrc/lib/warpzone/util_server.qc
qcsrc/lib/warpzone/util_server.qh
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/havocbot.qh
qcsrc/server/bot/waypoints.qc
qcsrc/server/bot/waypoints.qh
qcsrc/server/cheats.qc
qcsrc/server/cheats.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_impulse.qc
qcsrc/server/cl_player.qc
qcsrc/server/cl_player.qh
qcsrc/server/command/cmd.qc
qcsrc/server/command/common.qc
qcsrc/server/command/common.qh
qcsrc/server/command/radarmap.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/vote.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_damage.qh
qcsrc/server/g_hook.qc
qcsrc/server/g_lights.qc
qcsrc/server/g_models.qc
qcsrc/server/g_subs.qc
qcsrc/server/g_subs.qh
qcsrc/server/g_world.qc
qcsrc/server/ipban.qc
qcsrc/server/item_key.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qh
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/mutators/mutator/gamemode_race.qc
qcsrc/server/mutators/mutator/gamemode_tdm.qc
qcsrc/server/pathlib/debug.qc
qcsrc/server/pathlib/expandnode.qc
qcsrc/server/pathlib/main.qc
qcsrc/server/pathlib/movenode.qc
qcsrc/server/pathlib/path_waypoint.qc
qcsrc/server/pathlib/pathlib.qh
qcsrc/server/pathlib/utility.qc
qcsrc/server/pathlib/utility.qh
qcsrc/server/playerdemo.qc
qcsrc/server/playerdemo.qh
qcsrc/server/portals.qc
qcsrc/server/race.qc
qcsrc/server/race.qh
qcsrc/server/round_handler.qc
qcsrc/server/scores.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/spawnpoints.qh
qcsrc/server/steerlib.qc
qcsrc/server/steerlib.qh
qcsrc/server/sv_main.qc
qcsrc/server/t_quake.qc
qcsrc/server/t_quake3.qc
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/common.qh
qcsrc/server/weapons/csqcprojectile.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/throwing.qh
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/tracing.qh
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh

index a7b0e47499595474c6c8e90aae4c40eb3a85887b..e5fd7d575f643a7e9c7f940c62f8eec94c2b82a5 100644 (file)
@@ -17,9 +17,8 @@ string AnnouncerOption()
 
 entity announcer_countdown;
 
-void Announcer_Countdown()
+void Announcer_Countdown(entity this)
 {
-       SELFPARAM();
        float starttime = STAT(GAMESTARTTIME);
        float roundstarttime = STAT(ROUNDSTARTTIME);
        if(roundstarttime == -1)
@@ -102,7 +101,7 @@ void Announcer_Gamestart()
                        if (!announcer_countdown)
                        {
                                announcer_countdown = new(announcer_countdown);
-                               announcer_countdown.think = Announcer_Countdown;
+                               setthink(announcer_countdown, Announcer_Countdown);
                        }
 
                        if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
index 26834613cf1d7cc123d507c63f3eee3d77c72737..086dec33e0cf1eb3c51da170be52c366d736f6df 100644 (file)
@@ -414,7 +414,6 @@ float autocvar_cl_hitsound_max_pitch = 1.5;
 float autocvar_cl_hitsound_nom_damage = 25;
 float autocvar_cl_hitsound_antispam_time;
 int autocvar_cl_eventchase_death = 1;
-int autocvar_cl_eventchase_nexball = 1;
 vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
 float autocvar_cl_eventchase_generator_distance = 400;
 float autocvar_cl_eventchase_distance = 140;
index 7cbe6e125f14c5c7642bf8b3c039f4df2dc7ac70..39c30f7d528aefe7cfef76adf106a5dc8fb8990c 100644 (file)
@@ -290,9 +290,8 @@ float SetTeam(entity o, int Team)
        return false;
 }
 
-void Playerchecker_Think()
+void Playerchecker_Think(entity this)
 {
-       SELFPARAM();
     int i;
        entity e;
        for(i = 0; i < maxclients; ++i)
@@ -337,7 +336,7 @@ void TrueAim_Init();
 void PostInit()
 {
        entity playerchecker = new_pure(playerchecker);
-       playerchecker.think = Playerchecker_Think;
+       setthink(playerchecker, Playerchecker_Think);
        playerchecker.nextthink = time + 0.2;
 
        TrueAim_Init();
@@ -379,19 +378,6 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
 // --------------------------------------------------------------------------
 // BEGIN OPTIONAL CSQC FUNCTIONS
 
-.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)
@@ -1201,16 +1187,21 @@ string getcommandkey(string text, string command)
        keys = db_get(binddb, command);
        if (keys == "")
        {
+               bool joy_detected = cvar("joy_detected");
                n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
                for(j = 0; j < n; ++j)
                {
                        k = stof(argv(j));
                        if(k != -1)
                        {
-                               if ("" == keys)
-                                       keys = keynumtostring(k);
+                               string key = keynumtostring(k);
+                               if(!joy_detected && substring(key, 0, 3) == "JOY")
+                                       continue;
+
+                               if (keys == "")
+                                       keys = key;
                                else
-                                       keys = strcat(keys, ", ", keynumtostring(k));
+                                       keys = strcat(keys, ", ", key);
 
                                ++l;
                                if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
index 9d7c4068900967da4202dc23029f773d98566334..8601d26b589338b2dc8b18a342e0a68abc230396 100644 (file)
@@ -6,8 +6,6 @@
 // --------------------------------------------------------------------------
 // MENU Functionality
 
-void setpredraw(entity this, void(entity) pdfunc);
-
 // --------------------------------------------------------------------------
 // Onslaught
 
index 5368cb6429177ef4130a10e45610596485cab269..e9db990c82d474a07e06ee358dd9f0a99313ece1 100644 (file)
@@ -167,7 +167,6 @@ void Draw_ShowNames(entity this)
 
 void Draw_ShowNames_All()
 {
-    SELFPARAM();
        if (!autocvar_hud_shownames) return;
        LL_EACH(shownames_ent, true, {
                entity entcs = entcs_receiver(i);
@@ -177,8 +176,8 @@ void Draw_ShowNames_All()
                        continue;
                }
                make_impure(it);
-               assert(entcs.think, eprint(entcs));
-               WITHSELF(entcs, entcs.think());
+               assert(getthink(entcs), eprint(entcs));
+               WITHSELF(entcs, getthink(entcs)(entcs));
                if (!entcs.has_origin) continue;
                if (entcs.m_entcs_private)
                {
index 4696b5ef520f979a310d6c890724f2307ba52552..ae705793450651075782c73e01b308dba010d898 100644 (file)
@@ -741,8 +741,6 @@ bool WantEventchase(entity this)
                        return true;
                if(MUTATOR_CALLHOOK(WantEventchase, this))
                        return true;
-               if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
-                       return true;
                if(autocvar_cl_eventchase_death && (STAT(HEALTH) <= 0))
                {
                        if(autocvar_cl_eventchase_death == 2)
@@ -922,9 +920,8 @@ LABEL(normalcolor)
        return wcross_color;
 }
 
-void HUD_Crosshair()
-{SELFPARAM();
-       entity e = this;
+void HUD_Crosshair(entity this)
+{
        float f, i, j;
        vector v;
        if(!scoreboard_active && !camera_active && intermission != 2 &&
@@ -981,6 +978,7 @@ void HUD_Crosshair()
                string wcross_name = "";
                float wcross_scale, wcross_blur;
 
+        entity e = this; // wtf?
                if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
                {
                        e = switchingweapon;
@@ -1307,7 +1305,7 @@ void HUD_Crosshair()
        }
 }
 
-void HUD_Draw()
+void HUD_Draw(entity this)
 {
        if(!intermission)
        if (MUTATOR_CALLHOOK(HUD_Draw_overlay))
@@ -1342,7 +1340,7 @@ void HUD_Draw()
 
        // crosshair goes VERY LAST
        UpdateDamage();
-       HUD_Crosshair();
+       HUD_Crosshair(this);
        HitSound();
 }
 
@@ -1360,7 +1358,8 @@ int lasthud;
 float vh_notice_time;
 void WaypointSprite_Load();
 void CSQC_UpdateView(float w, float h)
-{SELFPARAM();
+{
+    SELFPARAM();
     TC(int, w); TC(int, h);
        entity e;
        float fov;
@@ -2171,7 +2170,7 @@ void CSQC_UpdateView(float w, float h)
 
        scoreboard_active = HUD_WouldDrawScoreboard();
 
-       HUD_Draw();
+       HUD_Draw(this);
 
        if(NextFrameCommand)
        {
index ea2f5f3d6dc87be3ac19515754715556755dd638..6261fa842f987773298274395246d7a32f782739 100644 (file)
@@ -22,12 +22,6 @@ void SUB_Stop(entity this)
        this.move_movetype = MOVETYPE_NONE;
 }
 
-void SUB_Stop_self()
-{
-       SELFPARAM();
-       SUB_Stop(this);
-}
-
 void Projectile_ResetTrail(entity this, vector to)
 {
        this.trail_oldorigin = to;
@@ -337,7 +331,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                this.mins = '0 0 0';
                this.maxs = '0 0 0';
                this.colormod = '0 0 0';
-               this.move_touch = SUB_Stop_self;
+               settouch(this, SUB_Stop);
                this.move_movetype = MOVETYPE_TOSS;
                this.alphamod = 1;
 
@@ -349,7 +343,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                                this.mins = '0 0 -4';
                                this.maxs = '0 0 -4';
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                this.move_bounce_factor = WEP_CVAR_SEC(electro, bouncefactor);
                                this.move_bounce_stopspeed = WEP_CVAR_SEC(electro, bouncestop);
                                break;
@@ -367,7 +361,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                                this.mins = '-3 -3 -3';
                                this.maxs = '3 3 3';
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                this.move_bounce_factor = WEP_CVAR(mortar, bouncefactor);
                                this.move_bounce_stopspeed = WEP_CVAR(mortar, bouncestop);
                                break;
@@ -385,21 +379,21 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                                this.colormod = '2 1 1';
                                this.alphamod = 0.5;
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                break;
                        case PROJECTILE_PORTO_BLUE:
                                this.colormod = '1 1 2';
                                this.alphamod = 0.5;
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                break;
                        case PROJECTILE_HAGAR_BOUNCING:
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                break;
                        case PROJECTILE_CRYLINK_BOUNCING:
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                break;
                        case PROJECTILE_FIREBALL:
                                loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
@@ -409,7 +403,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                        case PROJECTILE_FIREMINE:
                                loopsound(this, CH_SHOTS_SINGLE, SND(FIREBALL_FLY), VOL_BASE, ATTEN_NORM);
                                this.move_movetype = MOVETYPE_BOUNCE;
-                               this.move_touch = func_null;
+                               settouch(this, func_null);
                                this.mins = '-4 -4 -4';
                                this.maxs = '4 4 4';
                                break;
index ab217110b08a96352ea01185e63be7e38ff08134..8cb4a2aa18ff6dcfff9065b62ad01c2b656919af 100644 (file)
@@ -15,10 +15,10 @@ REGISTER_NET_TEMP(casings)
 
 #ifdef SVQC
 void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
-{SELFPARAM();
+{
     .entity weaponentity = weaponentities[0]; // TODO: parameter
-    entity wep = self.(weaponentity);
-    vector org = self.origin + self.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
+    entity wep = casingowner.(weaponentity);
+    vector org = casingowner.origin + casingowner.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
 
     if (!sound_allowed(MSG_BROADCAST, casingowner))
         casingtype |= 0x80;
@@ -83,8 +83,8 @@ Sound SND_CASINGS_RANDOM() {
     return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
 }
 
-void Casing_Touch()
-{SELFPARAM();
+void Casing_Touch(entity this)
+{
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
     {
         Casing_Delete(self);
@@ -156,7 +156,7 @@ NET_HANDLE(casings, bool isNew)
     casing.move_angles = casing.angles;
     casing.move_avelocity = '0 250 0' + 100 * prandomvec();
     casing.move_movetype = MOVETYPE_BOUNCE;
-    casing.move_touch = Casing_Touch;
+    settouch(casing, Casing_Touch);
     casing.move_time = time;
     casing.event_damage = Casing_Damage;
     casing.solid = SOLID_TRIGGER;
index c894ea15414f294ba8d5b6b1d62192b3558056c1..30a0a0c9e589e5eeec56602a722e1bbbea8f71a1 100644 (file)
@@ -20,15 +20,15 @@ REGISTER_NET_LINKED(ENT_CLIENT_DAMAGEINFO)
 bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
-       WriteShort(MSG_ENTITY, self.projectiledeathtype);
-       WriteCoord(MSG_ENTITY, floor(self.origin.x));
-       WriteCoord(MSG_ENTITY, floor(self.origin.y));
-       WriteCoord(MSG_ENTITY, floor(self.origin.z));
-       WriteByte(MSG_ENTITY, bound(1, self.dmg, 255));
-       WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255));
-       WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255));
-       WriteShort(MSG_ENTITY, self.oldorigin.x);
-       WriteByte(MSG_ENTITY, self.species);
+       WriteShort(MSG_ENTITY, this.projectiledeathtype);
+       WriteCoord(MSG_ENTITY, floor(this.origin.x));
+       WriteCoord(MSG_ENTITY, floor(this.origin.y));
+       WriteCoord(MSG_ENTITY, floor(this.origin.z));
+       WriteByte(MSG_ENTITY, bound(1, this.dmg, 255));
+       WriteByte(MSG_ENTITY, bound(0, this.dmg_radius, 255));
+       WriteByte(MSG_ENTITY, bound(1, this.dmg_edge, 255));
+       WriteShort(MSG_ENTITY, this.oldorigin.x);
+       WriteByte(MSG_ENTITY, this.species);
        return true;
 }
 
@@ -69,8 +69,8 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad
 .int state;
 .bool isplayermodel;
 
-void DamageEffect_Think()
-{SELFPARAM();
+void DamageEffect_Think(entity this)
+{
        // if particle distribution is enabled, slow ticrate by total number of damages
        if(autocvar_cl_damageeffect_distribute)
                this.nextthink = time + autocvar_cl_damageeffect_ticrate * this.owner.total_damages;
@@ -183,7 +183,7 @@ void DamageEffect(entity this, vector hitorg, float thedamage, int type, int spe
        e.owner = this;
        e.cnt = time + life;
        e.team = _particleeffectnum(effectname);
-       e.think = DamageEffect_Think;
+       setthink(e, DamageEffect_Think);
        e.nextthink = time;
        this.total_damages += 1;
 }
@@ -418,7 +418,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
                if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
                {
                        if(!MUTATOR_CALLHOOK(Weapon_ImpactEffect, hitwep))
-                               hitwep.wr_impacteffect(hitwep);
+                               hitwep.wr_impacteffect(hitwep, this);
                }
        }
 }
index bbe3ad934836e41c2ec671dedd2dee05e64335e7..20b050c3a4a633ea225e8e7a2e0f523ce17991f1 100644 (file)
@@ -111,15 +111,14 @@ void new_te_bloodshower (int ef, vector org, float explosionspeed, int howmany)
                __pointparticles(ef, org, randomvec() * explosionspeed, howmany / 50);
 }
 
-void SUB_RemoveOnNoImpact()
+void SUB_RemoveOnNoImpact(entity this)
 {
-    SELFPARAM();
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
                Gib_Delete(self);
 }
 
-void Gib_Touch()
-{SELFPARAM();
+void Gib_Touch(entity this)
+{
        // TODO maybe bounce of walls, make more gibs, etc.
 
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
@@ -144,7 +143,7 @@ void Gib_Draw(entity this)
        if(wasfreed(this))
                return;
 
-       if(this.touch == Gib_Touch) // don't do this for the "chunk" thingie...
+       if(gettouch(this) == 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
@@ -182,9 +181,9 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
 
        gib.draw = Gib_Draw;
        if(destroyontouch)
-               gib.move_touch = Gib_Touch;
+               settouch(gib, Gib_Touch);
        else
-               gib.move_touch = SUB_RemoveOnNoImpact;
+               settouch(gib, SUB_RemoveOnNoImpact);
 
        // don't spawn gibs inside solid - just don't
        if(org != safeorg)
index 84b083b952f272a3c3894fb2e6bc81d5218bafd2..f577762906b6737427a9f0edd2289123f78729ac 100644 (file)
@@ -14,43 +14,43 @@ bool modeleffect_SendEntity(entity this, entity to, int sf)
        WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
 
        f = 0;
-       if(self.velocity != '0 0 0')
+       if(this.velocity != '0 0 0')
                f |= 1;
-       if(self.angles != '0 0 0')
+       if(this.angles != '0 0 0')
                f |= 2;
-       if(self.avelocity != '0 0 0')
+       if(this.avelocity != '0 0 0')
                f |= 4;
 
        WriteByte(MSG_ENTITY, f);
-       WriteShort(MSG_ENTITY, self.modelindex);
-       WriteByte(MSG_ENTITY, self.skin);
-       WriteByte(MSG_ENTITY, self.frame);
-       WriteCoord(MSG_ENTITY, self.origin.x);
-       WriteCoord(MSG_ENTITY, self.origin.y);
-       WriteCoord(MSG_ENTITY, self.origin.z);
+       WriteShort(MSG_ENTITY, this.modelindex);
+       WriteByte(MSG_ENTITY, this.skin);
+       WriteByte(MSG_ENTITY, this.frame);
+       WriteCoord(MSG_ENTITY, this.origin.x);
+       WriteCoord(MSG_ENTITY, this.origin.y);
+       WriteCoord(MSG_ENTITY, this.origin.z);
        if(f & 1)
        {
-               WriteCoord(MSG_ENTITY, self.velocity.x);
-               WriteCoord(MSG_ENTITY, self.velocity.y);
-               WriteCoord(MSG_ENTITY, self.velocity.z);
+               WriteCoord(MSG_ENTITY, this.velocity.x);
+               WriteCoord(MSG_ENTITY, this.velocity.y);
+               WriteCoord(MSG_ENTITY, this.velocity.z);
        }
        if(f & 2)
        {
-               WriteCoord(MSG_ENTITY, self.angles.x);
-               WriteCoord(MSG_ENTITY, self.angles.y);
-               WriteCoord(MSG_ENTITY, self.angles.z);
+               WriteCoord(MSG_ENTITY, this.angles.x);
+               WriteCoord(MSG_ENTITY, this.angles.y);
+               WriteCoord(MSG_ENTITY, this.angles.z);
        }
        if(f & 4)
        {
-               WriteCoord(MSG_ENTITY, self.avelocity.x);
-               WriteCoord(MSG_ENTITY, self.avelocity.y);
-               WriteCoord(MSG_ENTITY, self.avelocity.z);
+               WriteCoord(MSG_ENTITY, this.avelocity.x);
+               WriteCoord(MSG_ENTITY, this.avelocity.y);
+               WriteCoord(MSG_ENTITY, this.avelocity.z);
        }
-       WriteShort(MSG_ENTITY, self.scale * 256.0);
-       WriteShort(MSG_ENTITY, self.scale2 * 256.0);
-       WriteByte(MSG_ENTITY, self.teleport_time * 100.0);
-       WriteByte(MSG_ENTITY, self.fade_time * 100.0);
-       WriteByte(MSG_ENTITY, self.alpha * 255.0);
+       WriteShort(MSG_ENTITY, this.scale * 256.0);
+       WriteShort(MSG_ENTITY, this.scale2 * 256.0);
+       WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
+       WriteByte(MSG_ENTITY, this.fade_time * 100.0);
+       WriteByte(MSG_ENTITY, this.alpha * 255.0);
 
        return true;
 }
index 1310ff0343b8d98e0b82c1246d493fb4985162eb..75deb92eaf8a5c448a69c7754ade78af4b82cfd7 100644 (file)
@@ -83,9 +83,8 @@
                return _entcs_send(this, to, sf, MSG_ENTITY);
        }
 
-       void entcs_think()
+       void entcs_think(entity this)
        {
-               SELFPARAM();
                this.nextthink = time + 0.033333333333;  // TODO: increase this to like 0.15 once the client can do smoothing
                entity o = this.owner;
                int i = 1;
        {
                entity e = player.entcs = new(entcs_sender);
                e.owner = player;
-               e.think = entcs_think;
+               setthink(e, entcs_think);
                e.nextthink = time;
                Net_LinkEntity(e, false, 0, entcs_send);
                if (!IS_REAL_CLIENT(player)) return;
                if (e != this) remove(e);
        }
 
-       void entcs_think()
+       void entcs_think(entity this)
        {
-               SELFPARAM();
                entity e = CSQCModel_server2csqc(this.sv_entnum);
                if (e == NULL)
                {
                                make_pure(e);
                        }
                        e.sv_entnum = n;
-                       e.think = entcs_think;
+                       setthink(e, entcs_think);
                        entcs_receiver(n, e);
                }
                else if (this && e != this)
        #undef X
                this.iflags |= IFLAG_ORIGIN;
                InterpolateOrigin_Note(this);
-               WITHSELF(this, this.think());
+               WITHSELF(this, getthink(this)(this));
                return true;
        }
 
index 0d02e4b538e3f789981118358500052609b3399e..1c72b351f7ff7e4e65b48fd9e5bf599f86c11a40 100644 (file)
@@ -26,7 +26,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
 
        bool entcs_send(entity this, entity to, int sf);
 
-       void entcs_think();
+       void entcs_think(entity this);
 
        void entcs_attach(entity e);
 
index d95df1f5eb4941922cb36f8a9316a28142c41e98..426cab70e151aea46122fac85d0896113cf1319e 100644 (file)
@@ -1,6 +1,18 @@
 #include "nexball.qh"
 
 #ifdef IMPLEMENTATION
+#ifdef CSQC
+int autocvar_cl_eventchase_nexball = 1;
+
+REGISTER_MUTATOR(cl_nb, true);
+
+MUTATOR_HOOKFUNCTION(cl_nb, WantEventchase)
+{
+       if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
+               return true;
+       return false;
+}
+#endif
 #ifdef SVQC
 .float metertime = _STAT(NB_METERSTART);
 
@@ -40,9 +52,9 @@ float autocvar_g_balance_nexball_secondary_lifetime;
 float autocvar_g_balance_nexball_secondary_refire;
 float autocvar_g_balance_nexball_secondary_speed;
 
-void basketball_touch();
-void football_touch();
-void ResetBall();
+void basketball_touch(entity this);
+void football_touch(entity this);
+void ResetBall(entity this);
 const int NBM_NONE = 0;
 const int NBM_FOOTBALL = 2;
 const int NBM_BASKETBALL = 4;
@@ -84,56 +96,55 @@ void ball_restart(entity this)
 {
        if(this.owner)
                DropBall(this, this.owner.origin, '0 0 0');
-       ResetBall();
+       ResetBall(this);
 }
 
-void nexball_setstatus()
-{SELFPARAM();
-       self.items &= ~IT_KEY1;
-       if(self.ballcarried)
+void nexball_setstatus(entity this)
+{
+       this.items &= ~IT_KEY1;
+       if(this.ballcarried)
        {
-               if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
+               if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
                {
-                       bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
-                       setself(self.ballcarried);
-                       DropBall(self, self.owner.origin, '0 0 0');
-                       ResetBall();
-                       setself(this);
+                       bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
+                       DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
+                       entity e = this.ballcarried;
+                       WITHSELF(e, ResetBall(e));
                }
                else
-                       self.items |= IT_KEY1;
+                       this.items |= IT_KEY1;
        }
 }
 
-void relocate_nexball()
-{SELFPARAM();
-       tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
+void relocate_nexball(entity this)
+{
+       tracebox(this.origin, BALL_MINS, BALL_MAXS, this.origin, true, this);
        if(trace_startsolid)
        {
                vector o;
-               o = self.origin;
-               if(!move_out_of_solid(self))
+               o = this.origin;
+               if(!move_out_of_solid(this))
                        objerror("could not get out of solid at all!");
-               LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
-               LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
-               LOG_INFO(" ", ftos(self.origin.y - o.y));
-               LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
-               self.origin = o;
+               LOG_INFO("^1NOTE: this map needs FIXING. ", this.classname, " at ", vtos(o - '0 0 1'));
+               LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+               LOG_INFO(" ", ftos(this.origin.y - o.y));
+               LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
+               this.origin = o;
        }
 }
 
-void DropOwner()
-{SELFPARAM();
+void DropOwner(entity this)
+{
        entity ownr;
-       ownr = self.owner;
-       DropBall(self, ownr.origin, ownr.velocity);
+       ownr = this.owner;
+       DropBall(this, ownr.origin, ownr.velocity);
        makevectors(ownr.v_angle.y * '0 1 0');
        ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
        UNSET_ONGROUND(ownr);
 }
 
 void GiveBall(entity plyr, entity ball)
-{SELFPARAM();
+{
        .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
        entity ownr = ball.owner;
        if(ownr)
@@ -168,7 +179,7 @@ void GiveBall(entity plyr, entity ball)
 
        ball.velocity = '0 0 0';
        ball.movetype = MOVETYPE_NONE;
-       ball.touch = func_null;
+       settouch(ball, func_null);
        ball.effects |= EF_NOSHADOW;
        ball.scale = 1; // scale down.
 
@@ -177,19 +188,17 @@ void GiveBall(entity plyr, entity ball)
 
        if(autocvar_g_nexball_basketball_delay_hold)
        {
-               ball.think = DropOwner;
+               setthink(ball, DropOwner);
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
        plyr.(weaponentity).weapons = plyr.weapons;
        plyr.(weaponentity).m_switchweapon = PS(plyr).m_weapon;
        plyr.weapons = WEPSET(NEXBALL);
-       setself(plyr);
        Weapon w = WEP_NEXBALL;
-       w.wr_resetplayer(w);
+       WITHSELF(plyr, w.wr_resetplayer(w, plyr));
        PS(plyr).m_switchweapon = WEP_NEXBALL;
-       W_SwitchWeapon(WEP_NEXBALL);
-       setself(this);
+       WITHSELF(plyr, W_SwitchWeapon(plyr, WEP_NEXBALL));
 }
 
 void DropBall(entity ball, vector org, vector vel)
@@ -205,8 +214,8 @@ void DropBall(entity ball, vector org, vector vel)
        ball.scale = ball_scale;
        ball.velocity = vel;
        ball.nb_droptime = time;
-       ball.touch = basketball_touch;
-       ball.think = ResetBall;
+       settouch(ball, basketball_touch);
+       setthink(ball, ResetBall);
        ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
 
        if(ball.owner.metertime)
@@ -224,64 +233,64 @@ void DropBall(entity ball, vector org, vector vel)
        ball.owner = world;
 }
 
-void InitBall()
-{SELFPARAM();
+void InitBall(entity this)
+{
        if(gameover) return;
-       UNSET_ONGROUND(self);
-       self.movetype = MOVETYPE_BOUNCE;
-       if(self.classname == "nexball_basketball")
-               self.touch = basketball_touch;
-       else if(self.classname == "nexball_football")
-               self.touch = football_touch;
-       self.cnt = 0;
-       self.think = ResetBall;
-       self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
-       self.teamtime = 0;
-       self.pusher = world;
-       self.team = false;
-       _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
-       WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
+       UNSET_ONGROUND(this);
+       this.movetype = MOVETYPE_BOUNCE;
+       if(this.classname == "nexball_basketball")
+               settouch(this, basketball_touch);
+       else if(this.classname == "nexball_football")
+               settouch(this, football_touch);
+       this.cnt = 0;
+       setthink(this, ResetBall);
+       this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
+       this.teamtime = 0;
+       this.pusher = world;
+       this.team = false;
+       _sound(this, CH_TRIGGER, this.noise1, VOL_BASE, ATTEN_NORM);
+       WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
        LogNB("init", world);
 }
 
-void ResetBall()
-{SELFPARAM();
-       if(self.cnt < 2)        // step 1
+void ResetBall(entity this)
+{
+       if(this.cnt < 2)        // step 1
        {
-               if(time == self.teamtime)
-                       bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
+               if(time == this.teamtime)
+                       bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
 
-               self.touch = func_null;
-               self.movetype = MOVETYPE_NOCLIP;
-               self.velocity = '0 0 0'; // just in case?
-               if(!self.cnt)
+               settouch(this, func_null);
+               this.movetype = MOVETYPE_NOCLIP;
+               this.velocity = '0 0 0'; // just in case?
+               if(!this.cnt)
                        LogNB("resetidle", world);
-               self.cnt = 2;
-               self.nextthink = time;
+               this.cnt = 2;
+               this.nextthink = time;
        }
-       else if(self.cnt < 4)     // step 2 and 3
+       else if(this.cnt < 4)     // step 2 and 3
        {
-//             dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n");
-               self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement
-               self.nextthink = time + 0.5;
-               self.cnt += 1;
+//             dprint("Step ", ftos(this.cnt), ": Calculated velocity: ", vtos(this.spawnorigin - this.origin), ", time: ", ftos(time), "\n");
+               this.velocity = (this.spawnorigin - this.origin) * (this.cnt - 1); // 1 or 0.5 second movement
+               this.nextthink = time + 0.5;
+               this.cnt += 1;
        }
        else     // step 4
        {
 //             dprint("Step 4: time: ", ftos(time), "\n");
-               if(vlen(self.origin - self.spawnorigin) > 10)  // should not happen anymore
+               if(vlen(this.origin - this.spawnorigin) > 10)  // should not happen anymore
                        LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
-                                  vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
-               self.velocity = '0 0 0';
-               setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
-               self.movetype = MOVETYPE_NONE;
-               self.think = InitBall;
-               self.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
+                                  vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n");
+               this.velocity = '0 0 0';
+               setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway
+               this.movetype = MOVETYPE_NONE;
+               setthink(this, InitBall);
+               this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start;
        }
 }
 
-void football_touch()
-{SELFPARAM();
+void football_touch(entity this)
+{
        if(other.solid == SOLID_BSP)
        {
                if(time > self.lastground + 0.1)
@@ -326,11 +335,11 @@ void football_touch()
        self.avelocity = -250 * v_forward;  // maybe there is a way to make it look better?
 }
 
-void basketball_touch()
-{SELFPARAM();
+void basketball_touch(entity this)
+{
        if(other.ballcarried)
        {
-               football_touch();
+               football_touch(this);
                return;
        }
        if(!self.cnt && IS_PLAYER(other) && !STAT(FROZEN, other) && !IS_DEAD(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
@@ -348,8 +357,8 @@ void basketball_touch()
        }
 }
 
-void GoalTouch()
-{SELFPARAM();
+void GoalTouch(entity this)
+{
        entity ball;
        float isclient, pscore, otherteam;
        string pname;
@@ -431,9 +440,9 @@ void GoalTouch()
        WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
 
        ball.cnt = 1;
-       ball.think = ResetBall;
+       setthink(ball, ResetBall);
        if(ball.classname == "nexball_basketball")
-               ball.touch = football_touch; // better than func_null: football control until the ball gets reset
+               settouch(ball, football_touch); // better than func_null: football control until the ball gets reset
        ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT);
 }
 
@@ -444,10 +453,10 @@ spawnfunc(nexball_team)
 {
        if(!g_nexball)
        {
-               remove(self);
+               remove(this);
                return;
        }
-       self.team = self.cnt + 1;
+       this.team = this.cnt + 1;
 }
 
 void nb_spawnteam(string teamname, float teamcolor)
@@ -512,62 +521,62 @@ void nb_delayedinit(entity this)
 //       spawnfuncs       //
 //=======================//
 
-void SpawnBall()
-{SELFPARAM();
-       if(!g_nexball) { remove(self); return; }
+void SpawnBall(entity this)
+{
+       if(!g_nexball) { remove(this); return; }
 
 //     balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
 
-       if(self.model == "")
+       if(this.model == "")
        {
-               self.model = "models/nexball/ball.md3";
-               self.scale = 1.3;
+               this.model = "models/nexball/ball.md3";
+               this.scale = 1.3;
        }
 
-       precache_model(self.model);
-       _setmodel(self, self.model);
-       setsize(self, BALL_MINS, BALL_MAXS);
-       ball_scale = self.scale;
+       precache_model(this.model);
+       _setmodel(this, this.model);
+       setsize(this, BALL_MINS, BALL_MAXS);
+       ball_scale = this.scale;
 
-       relocate_nexball();
-       self.spawnorigin = self.origin;
+       relocate_nexball(this);
+       this.spawnorigin = this.origin;
 
-       self.effects = self.effects | EF_LOWPRECISION;
+       this.effects = this.effects | EF_LOWPRECISION;
 
-       if(cvar(strcat("g_", self.classname, "_trail")))  //nexball_basketball :p
+       if(cvar(strcat("g_", this.classname, "_trail")))  //nexball_basketball :p
        {
-               self.glow_color = autocvar_g_nexball_trail_color;
-               self.glow_trail = true;
+               this.glow_color = autocvar_g_nexball_trail_color;
+               this.glow_trail = true;
        }
 
-       self.movetype = MOVETYPE_FLY;
+       this.movetype = MOVETYPE_FLY;
 
        if(!autocvar_g_nexball_sound_bounce)
-               self.noise = "";
-       else if(self.noise == "")
-               self.noise = strzone(SND(NB_BOUNCE));
+               this.noise = "";
+       else if(this.noise == "")
+               this.noise = strzone(SND(NB_BOUNCE));
        //bounce sound placeholder (FIXME)
-       if(self.noise1 == "")
-               self.noise1 = strzone(SND(NB_DROP));
+       if(this.noise1 == "")
+               this.noise1 = strzone(SND(NB_DROP));
        //ball drop sound placeholder (FIXME)
-       if(self.noise2 == "")
-               self.noise2 = strzone(SND(NB_STEAL));
+       if(this.noise2 == "")
+               this.noise2 = strzone(SND(NB_STEAL));
        //stealing sound placeholder (FIXME)
-       if(self.noise) precache_sound(self.noise);
-       precache_sound(self.noise1);
-       precache_sound(self.noise2);
+       if(this.noise) precache_sound(this.noise);
+       precache_sound(this.noise1);
+       precache_sound(this.noise2);
 
-       WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
+       WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
 
-       self.reset = ball_restart;
-       self.think = InitBall;
-       self.nextthink = game_starttime + autocvar_g_nexball_delay_start;
+       this.reset = ball_restart;
+       setthink(this, InitBall);
+       this.nextthink = game_starttime + autocvar_g_nexball_delay_start;
 }
 
 spawnfunc(nexball_basketball)
 {
        nexball_mode |= NBM_BASKETBALL;
-       self.classname = "nexball_basketball";
+       this.classname = "nexball_basketball";
        if (!(balls & BALL_BASKET))
        {
                /*
@@ -578,26 +587,26 @@ spawnfunc(nexball_basketball)
                */
                autocvar_g_nexball_basketball_effects_default = autocvar_g_nexball_basketball_effects_default & BALL_EFFECTMASK;
        }
-       if(!self.effects)
-               self.effects = autocvar_g_nexball_basketball_effects_default;
-       self.solid = SOLID_TRIGGER;
-       self.pushable = autocvar_g_nexball_basketball_jumppad;
+       if(!this.effects)
+               this.effects = autocvar_g_nexball_basketball_effects_default;
+       this.solid = SOLID_TRIGGER;
+       this.pushable = autocvar_g_nexball_basketball_jumppad;
        balls |= BALL_BASKET;
-       self.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
-       self.bouncestop = autocvar_g_nexball_basketball_bouncestop;
-       SpawnBall();
+       this.bouncefactor = autocvar_g_nexball_basketball_bouncefactor;
+       this.bouncestop = autocvar_g_nexball_basketball_bouncestop;
+       SpawnBall(this);
 }
 
 spawnfunc(nexball_football)
 {
        nexball_mode |= NBM_FOOTBALL;
-       self.classname = "nexball_football";
-       self.solid = SOLID_TRIGGER;
+       this.classname = "nexball_football";
+       this.solid = SOLID_TRIGGER;
        balls |= BALL_FOOT;
-       self.pushable = autocvar_g_nexball_football_jumppad;
-       self.bouncefactor = autocvar_g_nexball_football_bouncefactor;
-       self.bouncestop = autocvar_g_nexball_football_bouncestop;
-       SpawnBall();
+       this.pushable = autocvar_g_nexball_football_jumppad;
+       this.bouncefactor = autocvar_g_nexball_football_bouncefactor;
+       this.bouncestop = autocvar_g_nexball_football_bouncestop;
+       SpawnBall(this);
 }
 
 float nb_Goal_Customize()
@@ -610,61 +619,61 @@ float nb_Goal_Customize()
        return true;
 }
 
-void SpawnGoal()
-{SELFPARAM();
-       if(!g_nexball) { remove(self); return; }
+void SpawnGoal(entity this)
+{
+       if(!g_nexball) { remove(this); return; }
 
        EXACTTRIGGER_INIT;
 
-       if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
+       if(this.team != GOAL_OUT && Team_TeamToNumber(this.team) != -1)
        {
-               entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
-               wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
-               self.sprite.customizeentityforclient = nb_Goal_Customize;
+               entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE);
+               wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0');
+               this.sprite.customizeentityforclient = nb_Goal_Customize;
        }
 
-       self.classname = "nexball_goal";
-       if(self.noise == "")
-               self.noise = "ctf/respawn.wav";
-       precache_sound(self.noise);
-       self.touch = GoalTouch;
+       this.classname = "nexball_goal";
+       if(this.noise == "")
+               this.noise = "ctf/respawn.wav";
+       precache_sound(this.noise);
+       settouch(this, GoalTouch);
 }
 
 spawnfunc(nexball_redgoal)
 {
-       self.team = NUM_TEAM_1;
-       SpawnGoal();
+       this.team = NUM_TEAM_1;
+       SpawnGoal(this);
 }
 spawnfunc(nexball_bluegoal)
 {
-       self.team = NUM_TEAM_2;
-       SpawnGoal();
+       this.team = NUM_TEAM_2;
+       SpawnGoal(this);
 }
 spawnfunc(nexball_yellowgoal)
 {
-       self.team = NUM_TEAM_3;
-       SpawnGoal();
+       this.team = NUM_TEAM_3;
+       SpawnGoal(this);
 }
 spawnfunc(nexball_pinkgoal)
 {
-       self.team = NUM_TEAM_4;
-       SpawnGoal();
+       this.team = NUM_TEAM_4;
+       SpawnGoal(this);
 }
 
 spawnfunc(nexball_fault)
 {
-       self.team = GOAL_FAULT;
-       if(self.noise == "")
-               self.noise = strzone(SND(TYPEHIT));
-       SpawnGoal();
+       this.team = GOAL_FAULT;
+       if(this.noise == "")
+               this.noise = strzone(SND(TYPEHIT));
+       SpawnGoal(this);
 }
 
 spawnfunc(nexball_out)
 {
-       self.team = GOAL_OUT;
-       if(self.noise == "")
-               self.noise = strzone(SND(TYPEHIT));
-       SpawnGoal();
+       this.team = GOAL_OUT;
+       if(this.noise == "")
+               this.noise = strzone(SND(TYPEHIT));
+       SpawnGoal(this);
 }
 
 //
@@ -706,33 +715,33 @@ spawnfunc(ball_bound)
 //=======================//
 
 
-void W_Nexball_Think()
-{SELFPARAM();
+void W_Nexball_Think(entity this)
+{
        //dprint("W_Nexball_Think\n");
-       //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
-       vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
-       vector old_dir = normalize(self.velocity);
-       float _speed = vlen(self.velocity);
+       //vector new_dir = steerlib_arrive(this.enemy.origin, 2500);
+       vector new_dir = normalize(this.enemy.origin + '0 0 50' - this.origin);
+       vector old_dir = normalize(this.velocity);
+       float _speed = vlen(this.velocity);
        vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed;
        //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate
 
-       self.velocity = new_vel;
+       this.velocity = new_vel;
 
-       self.nextthink = time;
+       this.nextthink = time;
 }
 
-void W_Nexball_Touch()
-{SELFPARAM();
+void W_Nexball_Touch(entity this)
+{
        entity ball, attacker;
-       attacker = self.owner;
-       //self.think = func_null;
-       //self.enemy = world;
+       attacker = this.owner;
+       //this.think = func_null;
+       //this.enemy = world;
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
        if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
                if((ball = other.ballcarried) && !STAT(FROZEN, other) && !IS_DEAD(other) && (IS_PLAYER(attacker)))
                {
-                       other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
+                       other.velocity = other.velocity + normalize(this.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
                        UNSET_ONGROUND(other);
                        if(!attacker.ballcarried)
                        {
@@ -749,22 +758,22 @@ void W_Nexball_Touch()
                                GiveBall(attacker, other.ballcarried);
                        }
                }
-       remove(self);
+       remove(this);
 }
 
-void W_Nexball_Attack(float t)
-{SELFPARAM();
+void W_Nexball_Attack(entity actor, float t)
+{
        entity ball;
        float mul, mi, ma;
-       if(!(ball = self.ballcarried))
+       if(!(ball = actor.ballcarried))
                return;
 
-       W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+       W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
        tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
        if(trace_startsolid)
        {
-               if(self.metertime)
-                       self.metertime = 0; // Shot failed, hide the power meter
+               if(actor.metertime)
+                       actor.metertime = 0; // Shot failed, hide the power meter
                return;
        }
 
@@ -782,7 +791,7 @@ void W_Nexball_Attack(float t)
                mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
        }
 
-       DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
+       DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(actor.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
 
 
        //TODO: use the speed_up cvar too ??
@@ -790,14 +799,14 @@ void W_Nexball_Attack(float t)
 
 vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
 
-void W_Nexball_Attack2()
-{SELFPARAM();
-       if(self.ballcarried.enemy)
+void W_Nexball_Attack2(entity actor)
+{
+       if(actor.ballcarried.enemy)
        {
-               entity _ball = self.ballcarried;
-               W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+               entity _ball = actor.ballcarried;
+               W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
                DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
-               _ball.think = W_Nexball_Think;
+               setthink(_ball, W_Nexball_Think);
                _ball.nextthink = time;
                return;
        }
@@ -805,10 +814,10 @@ void W_Nexball_Attack2()
        if(!autocvar_g_nexball_tackling)
                return;
 
-       W_SetupShot(self, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
+       W_SetupShot(actor, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
        entity missile = new(ballstealer);
 
-       missile.owner = self;
+       missile.owner = actor;
 
        missile.movetype = MOVETYPE_FLY;
        PROJECTILE_MAKETRIGGER(missile);
@@ -819,8 +828,8 @@ void W_Nexball_Attack2()
 
        W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
        missile.angles = vectoangles(missile.velocity);
-       missile.touch = W_Nexball_Touch;
-       missile.think = SUB_Remove_self;
+       settouch(missile, W_Nexball_Touch);
+       setthink(missile, SUB_Remove);
        missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
 
        missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
@@ -858,50 +867,49 @@ float ball_customize()
 
 METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire))
 {
-    SELFPARAM();
     TC(BallStealer, thiswep);
     if(fire & 1)
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire))
             if(autocvar_g_nexball_basketball_meter)
             {
-                if(self.ballcarried && !self.metertime)
-                    self.metertime = time;
+                if(actor.ballcarried && !actor.metertime)
+                    actor.metertime = time;
                 else
                     weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
             }
             else
             {
-                W_Nexball_Attack(-1);
+                W_Nexball_Attack(actor, -1);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
             }
     if(fire & 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
         {
-            W_Nexball_Attack2();
+            W_Nexball_Attack2(actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
         }
 
-    if(!(fire & 1) && self.metertime && self.ballcarried)
+    if(!(fire & 1) && actor.metertime && actor.ballcarried)
     {
-        W_Nexball_Attack(time - self.metertime);
+        W_Nexball_Attack(actor, time - actor.metertime);
         // DropBall or stealing will set metertime back to 0
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
     }
 }
 
-METHOD(BallStealer, wr_setup, void(BallStealer this))
+METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
 {
     TC(BallStealer, this);
     //weapon_setup(WEP_PORTO.m_id);
 }
 
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
 {
     TC(BallStealer, this);
     return true;
 }
 
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
 {
     TC(BallStealer, this);
     return true;
@@ -983,9 +991,9 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                        {
                                self.weapons = self.(weaponentity).weapons;
                                Weapon w = WEP_NEXBALL;
-                               w.wr_resetplayer(w);
+                               w.wr_resetplayer(w, self);
                                PS(self).m_switchweapon = self.(weaponentity).m_switchweapon;
-                               W_SwitchWeapon(PS(self).m_switchweapon);
+                               W_SwitchWeapon(self, PS(self).m_switchweapon);
 
                                self.(weaponentity).weapons = '0 0 0';
                        }
@@ -993,7 +1001,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
 
        }
 
-       nexball_setstatus();
+       nexball_setstatus(self);
 
        return false;
 }
index bb302998f2e9c6c8daeb19e08562987126a11153..0870ed6bfa323b0811b504b9d7db39330c9fd19a 100644 (file)
@@ -172,8 +172,8 @@ bool ons_CaptureShield_Customize()
        return true;
 }
 
-void ons_CaptureShield_Touch()
-{SELFPARAM();
+void ons_CaptureShield_Touch(entity this)
+{
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
        if(!IS_PLAYER(other)) { return; }
        if(SAME_TEAM(other, self)) { return; }
@@ -208,7 +208,7 @@ void ons_CaptureShield_Spawn(entity generator, bool is_generator)
        shield.team = generator.team;
        shield.colormap = generator.colormap;
        shield.reset = ons_CaptureShield_Reset;
-       shield.touch = ons_CaptureShield_Touch;
+       settouch(shield, ons_CaptureShield_Touch);
        shield.customizeentityforclient = ons_CaptureShield_Customize;
        shield.effects = EF_ADDITIVE;
        shield.movetype = MOVETYPE_NOCLIP;
@@ -395,36 +395,36 @@ bool ons_Link_Send(entity this, entity to, int sendflags)
        return true;
 }
 
-void ons_Link_CheckUpdate()
-{SELFPARAM();
+void ons_Link_CheckUpdate(entity this)
+{
        // TODO check if the two sides have moved (currently they won't move anyway)
        float cc = 0, cc1 = 0, cc2 = 0;
 
-       if(self.goalentity.islinked || self.goalentity.iscaptured) { cc1 = (self.goalentity.team - 1) * 0x01; }
-       if(self.enemy.islinked || self.enemy.iscaptured) { cc2 = (self.enemy.team - 1) * 0x10; }
+       if(this.goalentity.islinked || this.goalentity.iscaptured) { cc1 = (this.goalentity.team - 1) * 0x01; }
+       if(this.enemy.islinked || this.enemy.iscaptured) { cc2 = (this.enemy.team - 1) * 0x10; }
 
        cc = cc1 + cc2;
 
-       if(cc != self.clientcolors)
+       if(cc != this.clientcolors)
        {
-               self.clientcolors = cc;
-               self.SendFlags |= 4;
+               this.clientcolors = cc;
+               this.SendFlags |= 4;
        }
 
-       self.nextthink = time;
+       this.nextthink = time;
 }
 
 void ons_DelayedLinkSetup(entity this)
 {
-       self.goalentity = find(world, targetname, self.target);
-       self.enemy = find(world, targetname, self.target2);
-       if(!self.goalentity) { objerror("can not find target\n"); }
-       if(!self.enemy) { objerror("can not find target2\n"); }
+       this.goalentity = find(world, targetname, this.target);
+       this.enemy = find(world, targetname, this.target2);
+       if(!this.goalentity) { objerror("can not find target\n"); }
+       if(!this.enemy) { objerror("can not find target2\n"); }
 
-       LOG_DEBUG(strcat(etos(self.goalentity), " linked with ", etos(self.enemy), "\n"));
-       self.SendFlags |= 3;
-       self.think = ons_Link_CheckUpdate;
-       self.nextthink = time;
+       LOG_DEBUG(strcat(etos(this.goalentity), " linked with ", etos(this.enemy), "\n"));
+       this.SendFlags |= 3;
+       setthink(this, ons_Link_CheckUpdate);
+       this.nextthink = time;
 }
 
 
@@ -559,9 +559,9 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker
        this.SendFlags |= CPSF_STATUS;
 }
 
-void ons_ControlPoint_Icon_Think()
-{SELFPARAM();
-       self.nextthink = time + ONS_CP_THINKRATE;
+void ons_ControlPoint_Icon_Think(entity this)
+{
+       this.nextthink = time + ONS_CP_THINKRATE;
 
        if(autocvar_g_onslaught_cp_proxydecap)
        {
@@ -569,9 +569,9 @@ void ons_ControlPoint_Icon_Think()
                int _friendly_count = 0;
 
                FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
-                       if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
+                       if(vdist(it.origin - this.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
                        {
-                               if(SAME_TEAM(it, self))
+                               if(SAME_TEAM(it, this))
                                        ++_friendly_count;
                                else
                                        ++_enemy_count;
@@ -581,107 +581,107 @@ void ons_ControlPoint_Icon_Think()
                _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
                _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
 
-               self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
-               self.SendFlags |= CPSF_STATUS;
-               if(self.health <= 0)
+               this.health = bound(0, this.health + (_friendly_count - _enemy_count), this.max_health);
+               this.SendFlags |= CPSF_STATUS;
+               if(this.health <= 0)
                {
-                       ons_ControlPoint_Icon_Damage(self, self, self, 1, 0, self.origin, '0 0 0');
+                       ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, this.origin, '0 0 0');
                        return;
                }
        }
 
-       if (time > self.pain_finished + 5)
+       if (time > this.pain_finished + 5)
        {
-               if(self.health < self.max_health)
+               if(this.health < this.max_health)
                {
-                       self.health = self.health + self.count;
-                       if (self.health >= self.max_health)
-                               self.health = self.max_health;
-                       WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+                       this.health = this.health + this.count;
+                       if (this.health >= this.max_health)
+                               this.health = this.max_health;
+                       WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
                }
        }
 
-       if(self.owner.islinked != self.owner.waslinked)
+       if(this.owner.islinked != this.owner.waslinked)
        {
                // unteam the spawnpoint if needed
-               int t = self.owner.team;
-               if(!self.owner.islinked)
-                       self.owner.team = 0;
+               int t = this.owner.team;
+               if(!this.owner.islinked)
+                       this.owner.team = 0;
 
-               SUB_UseTargets(self.owner, self, NULL);
+               SUB_UseTargets(this.owner, this, NULL);
 
-               self.owner.team = t;
+               this.owner.team = t;
 
-               self.owner.waslinked = self.owner.islinked;
+               this.owner.waslinked = this.owner.islinked;
        }
 
        // damaged fx
-       if(random() < 0.6 - self.health / self.max_health)
+       if(random() < 0.6 - this.health / this.max_health)
        {
-               Send_Effect(EFFECT_ELECTRIC_SPARKS, self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
+               Send_Effect(EFFECT_ELECTRIC_SPARKS, this.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
 
                if(random() > 0.8)
-                       sound(self, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
                else if (random() > 0.5)
-                       sound(self, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
        }
 }
 
-void ons_ControlPoint_Icon_BuildThink()
-{SELFPARAM();
+void ons_ControlPoint_Icon_BuildThink(entity this)
+{
        int a;
 
-       self.nextthink = time + ONS_CP_THINKRATE;
+       this.nextthink = time + ONS_CP_THINKRATE;
 
        // only do this if there is power
-       a = ons_ControlPoint_CanBeLinked(self.owner, self.owner.team);
+       a = ons_ControlPoint_CanBeLinked(this.owner, this.owner.team);
        if(!a)
                return;
 
-       self.health = self.health + self.count;
+       this.health = this.health + this.count;
 
-       self.SendFlags |= CPSF_STATUS;
+       this.SendFlags |= CPSF_STATUS;
 
-       if (self.health >= self.max_health)
+       if (this.health >= this.max_health)
        {
-               self.health = self.max_health;
-               self.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
-               self.think = ons_ControlPoint_Icon_Think;
-               sound(self, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
-               self.owner.iscaptured = true;
-               self.solid = SOLID_BBOX;
+               this.health = this.max_health;
+               this.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
+               setthink(this, ons_ControlPoint_Icon_Think);
+               sound(this, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
+               this.owner.iscaptured = true;
+               this.solid = SOLID_BBOX;
 
-               Send_Effect(EFFECT_CAP(self.owner.team), self.owner.origin, '0 0 0', 1);
+               Send_Effect(EFFECT_CAP(this.owner.team), this.owner.origin, '0 0 0', 1);
 
-               WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
-               WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+               WaypointSprite_UpdateMaxHealth(this.owner.sprite, this.max_health);
+               WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
 
-               if(IS_PLAYER(self.owner.ons_toucher))
+               if(IS_PLAYER(this.owner.ons_toucher))
                {
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message);
-                       Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(self.owner.ons_toucher.team, CENTER_ONS_CAPTURE), self.owner.message);
-                       Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message);
-                       PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1);
-                       PlayerTeamScore_AddScore(self.owner.ons_toucher, 10);
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
+                       Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
+                       Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
+                       PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
+                       PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
                }
 
-               self.owner.ons_toucher = world;
+               this.owner.ons_toucher = world;
 
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               SUB_UseTargets(self.owner, self, NULL);
+               SUB_UseTargets(this.owner, this, NULL);
 
-               self.SendFlags |= CPSF_SETUP;
+               this.SendFlags |= CPSF_SETUP;
        }
-       if(self.owner.model != MDL_ONS_CP_PAD2.model_str())
-               setmodel_fixsize(self.owner, MDL_ONS_CP_PAD2);
+       if(this.owner.model != MDL_ONS_CP_PAD2.model_str())
+               setmodel_fixsize(this.owner, MDL_ONS_CP_PAD2);
 
-       if(random() < 0.9 - self.health / self.max_health)
-               Send_Effect(EFFECT_RAGE, self.origin + 10 * randomvec(), '0 0 -1', 1);
+       if(random() < 0.9 - this.health / this.max_health)
+               Send_Effect(EFFECT_RAGE, this.origin + 10 * randomvec(), '0 0 -1', 1);
 }
 
-void onslaught_controlpoint_icon_link(entity e, void() spawnproc);
+void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc);
 
 void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
 {
@@ -776,8 +776,8 @@ void ons_ControlPoint_UpdateSprite(entity e)
        }
 }
 
-void ons_ControlPoint_Touch()
-{SELFPARAM();
+void ons_ControlPoint_Touch(entity this)
+{
        entity toucher = other;
        int attackable;
 
@@ -813,8 +813,8 @@ void ons_ControlPoint_Touch()
        onslaught_updatelinks();
 }
 
-void ons_ControlPoint_Think()
-{SELFPARAM();
+void ons_ControlPoint_Think(entity this)
+{
        self.nextthink = time + ONS_CP_THINKRATE;
        CSQCMODEL_AUTOUPDATE(self);
 }
@@ -830,7 +830,7 @@ void ons_ControlPoint_Reset(entity this)
        this.iscaptured = false;
        this.islinked = false;
        this.isshielded = true;
-       this.think = ons_ControlPoint_Think;
+       setthink(this, ons_ControlPoint_Think);
        this.ons_toucher = world;
        this.nextthink = time + ONS_CP_THINKRATE;
        setmodel_fixsize(this, MDL_ONS_CP_PAD1);
@@ -850,16 +850,13 @@ void ons_DelayedControlPoint_Setup(entity this)
        onslaught_updatelinks();
 
        // captureshield setup
-       ons_CaptureShield_Spawn(self, false);
+       ons_CaptureShield_Spawn(this, false);
 
-       CSQCMODEL_AUTOINIT(self);
+       CSQCMODEL_AUTOINIT(this);
 }
 
 void ons_ControlPoint_Setup(entity cp)
-{SELFPARAM();
-       // declarations
-       setself(cp); // for later usage with droptofloor()
-
+{
        // main setup
        cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
        ons_worldcplist = cp;
@@ -868,8 +865,8 @@ void ons_ControlPoint_Setup(entity cp)
        cp.team = 0;
        cp.solid = SOLID_BBOX;
        cp.movetype = MOVETYPE_NONE;
-       cp.touch = ons_ControlPoint_Touch;
-       cp.think = ons_ControlPoint_Think;
+       settouch(cp, ons_ControlPoint_Touch);
+       setthink(cp, ons_ControlPoint_Think);
        cp.nextthink = time + ONS_CP_THINKRATE;
        cp.reset = ons_ControlPoint_Reset;
        cp.colormap = 1024;
@@ -892,14 +889,13 @@ void ons_ControlPoint_Setup(entity cp)
        {
                setorigin(cp, cp.origin + '0 0 20');
                cp.noalign = false;
-               setself(cp);
-               droptofloor();
+               WITHSELF(cp, droptofloor());
                cp.movetype = MOVETYPE_TOSS;
        }
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_SpawnFixed(WP_Null, cp.origin + CPGEN_WAYPOINT_OFFSET, cp, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(cp.sprite, cp.team, SPRITERULE_TEAMPLAY);
 
        InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
 }
@@ -994,7 +990,7 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d
                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;
+               setthink(this, func_null);
                this.nextthink = 0;
                //this.think(); // do the first explosion now
 
@@ -1025,22 +1021,22 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d
        this.SendFlags |= GSF_STATUS;
 }
 
-void ons_GeneratorThink()
-{SELFPARAM();
-       self.nextthink = time + GEN_THINKRATE;
+void ons_GeneratorThink(entity this)
+{
+       this.nextthink = time + GEN_THINKRATE;
        if (!gameover)
        {
-               if(!self.isshielded && self.wait < time)
+               if(!this.isshielded && this.wait < time)
                {
-                       self.wait = time + 5;
+                       this.wait = time + 5;
                        FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
-                               if(SAME_TEAM(it, self))
+                               if(SAME_TEAM(it, this))
                                {
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
                                        soundto(MSG_ONE, it, CHAN_AUTO, SND(KH_ALARM), VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
                                }
                                else
-                                       Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED));
+                                       Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(this.team, CENTER_ONS_NOTSHIELDED));
                        });
                }
        }
@@ -1056,7 +1052,7 @@ void ons_GeneratorReset(entity this)
        this.islinked = true;
        this.isshielded = true;
        this.event_damage = ons_GeneratorDamage;
-       this.think = ons_GeneratorThink;
+       setthink(this, ons_GeneratorThink);
        this.nextthink = time + GEN_THINKRATE;
 
        Net_LinkEntity(this, false, 0, generator_send);
@@ -1087,8 +1083,8 @@ void ons_DelayedGeneratorSetup(entity this)
 }
 
 
-void onslaught_generator_touch()
-{SELFPARAM();
+void onslaught_generator_touch(entity this)
+{
        if ( IS_PLAYER(other) )
        if ( SAME_TEAM(self,other) )
        if ( self.iscaptured )
@@ -1098,10 +1094,9 @@ void onslaught_generator_touch()
 }
 
 void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
-{SELFPARAM();
+{
        // declarations
        int teamnumber = gen.team;
-       setself(gen); // for later usage with droptofloor()
 
        // main setup
        gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
@@ -1117,12 +1112,12 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.bot_attack = true;
        gen.event_damage = ons_GeneratorDamage;
        gen.reset = ons_GeneratorReset;
-       gen.think = ons_GeneratorThink;
+       setthink(gen, ons_GeneratorThink);
        gen.nextthink = time + GEN_THINKRATE;
        gen.iscaptured = true;
        gen.islinked = true;
        gen.isshielded = true;
-       gen.touch = onslaught_generator_touch;
+       settouch(gen, onslaught_generator_touch);
 
        // appearence
        // model handled by CSQC
@@ -1131,14 +1126,13 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.colormap = 1024 + (teamnumber - 1) * 17;
 
        // generator placement
-       setself(gen);
-       droptofloor();
+       WITHSELF(gen, droptofloor());
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
-       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(gen.sprite, gen.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_UpdateMaxHealth(gen.sprite, gen.max_health);
+       WaypointSprite_UpdateHealth(gen.sprite, gen.health);
 
        InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
 }
@@ -1761,7 +1755,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
 // ==============
 
 MUTATOR_HOOKFUNCTION(ons, reset_map_global)
-{SELFPARAM();
+{
        FOREACH_CLIENT(IS_PLAYER(it), {
                it.ons_roundlost = false;
                it.ons_deathloc = '0 0 0';
@@ -2162,7 +2156,7 @@ MUTATOR_HOOKFUNCTION(ons, TurretThink)
        }
 
        if(self.team != self.tur_head.team)
-               turret_respawn();
+               turret_respawn(self);
 
        return false;
 }
@@ -2183,16 +2177,16 @@ keys:
  */
 spawnfunc(onslaught_link)
 {
-       if(!g_onslaught) { remove(self); return; }
+       if(!g_onslaught) { remove(this); return; }
 
-       if (self.target == "" || self.target2 == "")
+       if (this.target == "" || this.target2 == "")
                objerror("target and target2 must be set\n");
 
-       self.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
-       ons_worldlinklist = self;
+       this.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
+       ons_worldlinklist = this;
 
-       InitializeEntity(self, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
-       Net_LinkEntity(self, false, 0, ons_Link_Send);
+       InitializeEntity(this, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
+       Net_LinkEntity(this, false, 0, ons_Link_Send);
 }
 
 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
@@ -2208,9 +2202,9 @@ keys:
 
 spawnfunc(onslaught_controlpoint)
 {
-       if(!g_onslaught) { remove(self); return; }
+       if(!g_onslaught) { remove(this); return; }
 
-       ons_ControlPoint_Setup(self);
+       ons_ControlPoint_Setup(this);
 }
 
 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
@@ -2224,10 +2218,10 @@ keys:
  */
 spawnfunc(onslaught_generator)
 {
-       if(!g_onslaught) { remove(self); return; }
-       if(!self.team) { objerror("team must be set"); }
+       if(!g_onslaught) { remove(this); return; }
+       if(!this.team) { objerror("team must be set"); }
 
-       ons_GeneratorSetup(self);
+       ons_GeneratorSetup(this);
 }
 
 // scoreboard setup
index 4924287189f1809001f2d445f9c30acaab5505da..aceb3e64eacf9f504a2002d1b47dbde0dbb147cc 100644 (file)
@@ -32,9 +32,9 @@ bool cpicon_send(entity this, entity to, int sf)
        return true;
 }
 
-void onslaught_controlpoint_icon_link(entity e, void() spawnproc)
+void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc)
 {
        Net_LinkEntity(e, true, 0, cpicon_send);
-       e.think         = spawnproc;
+       setthink(e, spawnproc);
        e.nextthink     = time * sys_frametime;
 }
index cf8d234a3a295c4c2dfb0ec4e91eccdfc6a21f23..aeac4e1626d88fa2af7b87cc3bc8611fb59f21cd 100644 (file)
@@ -29,9 +29,9 @@ bool generator_send(entity this, entity to, int sf)
        return true;
 }
 
-void generator_link(void() spawnproc)
+void generator_link(void(entity this) spawnproc)
 {SELFPARAM();
        Net_LinkEntity(self, true, 0, generator_send);
-       self.think              = spawnproc;
+       setthink(self, spawnproc);
        self.nextthink  = time;
 }
index f080e90d068cd666bc9d471c8041061ec0084d9c..4e3bfc25d3609ca7e36c321b90a70011a1dead3b 100644 (file)
@@ -156,24 +156,24 @@ void minigame_player_entremove(entity this)
 string() ReadString_Raw = #366;
 string ReadString_Zoned() { return strzone(ReadString_Raw()); }
 #define ReadString ReadString_Zoned
-#define FIELD(Flags, Type,Name) if ( sf & (Flags) ) self.Name = Read##Type();
+#define FIELD(Flags, Type,Name) if ( sf & (Flags) ) this.Name = Read##Type();
 #define MSLE(Name,Fields) \
-       else if ( self.classname == #Name ) { \
+       else if ( this.classname == #Name ) { \
                if ( sf & MINIG_SF_CREATE ) { \
                        minigame_read_owner(); \
-                       self.entremove = msle_entremove_##Name; \
+                       this.entremove = msle_entremove_##Name; \
                } \
-               minigame_ent = self.owner; \
+               minigame_ent = this.owner; \
                Fields \
        }
 void minigame_read_owner()
 {SELFPARAM();
        string owner_name = ReadString_Raw();
-       self.owner = world;
+       this.owner = world;
        do
-               self.owner = find(self.owner,netname,owner_name);
-       while ( self.owner && self.owner.classname != "minigame" );
-       if ( !self.owner )
+               this.owner = find(this.owner,netname,owner_name);
+       while ( this.owner && this.owner.classname != "minigame" );
+       if ( !this.owner )
                LOG_TRACE("Got a minigame entity without a minigame!\n");
 }
 NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
@@ -181,63 +181,63 @@ NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
        float sf = ReadByte();
        if ( sf & MINIG_SF_CREATE )
        {
-               self.classname = msle_classname(ReadShort());
-               self.netname = ReadString_Zoned();
+               this.classname = msle_classname(ReadShort());
+               this.netname = ReadString_Zoned();
        }
 
        entity minigame_ent = world;
 
-       if ( self.classname == "minigame" )
+       if ( this.classname == "minigame" )
        {
-               minigame_ent = self;
+               minigame_ent = this;
 
                if ( sf & MINIG_SF_CREATE )
                {
-                       self.entremove = minigame_entremove;
-                       self.descriptor = minigame_get_descriptor(ReadString_Raw());
-                       if ( !self.descriptor )
+                       this.entremove = minigame_entremove;
+                       this.descriptor = minigame_get_descriptor(ReadString_Raw());
+                       if ( !this.descriptor )
                                LOG_TRACE("Got a minigame without a client-side descriptor!\n");
                        else
-                               self.minigame_event = self.descriptor.minigame_event;
+                               this.minigame_event = this.descriptor.minigame_event;
                }
                if ( sf & MINIG_SF_UPDATE )
-                       self.minigame_flags = ReadLong();
+                       this.minigame_flags = ReadLong();
        }
-       else if ( self.classname == "minigame_player" )
+       else if ( this.classname == "minigame_player" )
        {
                float activate = 0;
                if ( sf & MINIG_SF_CREATE )
                {
-                       self.entremove = minigame_player_entremove;
+                       this.entremove = minigame_player_entremove;
                        minigame_read_owner();
                        float ent = ReadLong();
-                       self.minigame_playerslot = ent;
+                       this.minigame_playerslot = ent;
                        LOG_DEBUG("Player: ",entcs_GetName(ent-1),"\n");
 
-                       activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
+                       activate = (ent == player_localnum+1 && this.owner && this.owner != active_minigame);
 
                }
-               minigame_ent = self.owner;
+               minigame_ent = this.owner;
 
                if ( sf & MINIG_SF_UPDATE )
-                       self.team = ReadByte();
+                       this.team = ReadByte();
 
                if ( activate )
                {
-                       minigame_self = self;
-                       activate_minigame(self.owner);
+                       minigame_self = this;
+                       activate_minigame(this.owner);
                }
        }
        MINIGAME_SIMPLELINKED_ENTITIES
 
        if ( minigame_ent )
-               minigame_ent.minigame_event(minigame_ent,"network_receive",self,sf);
+               minigame_ent.minigame_event(minigame_ent,"network_receive",this,sf);
 
        if ( sf & MINIG_SF_CREATE )
        {
-               LOG_DEBUG("CL Reading entity: ",ftos(etof(self)),
-                       " classname:",self.classname," enttype:",ftos(self.enttype) );
-               LOG_DEBUG(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
+               LOG_DEBUG("CL Reading entity: ",ftos(etof(this)),
+                       " classname:",this.classname," enttype:",ftos(this.enttype) );
+               LOG_DEBUG(" sf:",ftos(sf)," netname:",this.netname,"\n\n");
        }
        return true;
 }
index 87c75f48c59ab05ac3b9ce01d4c628ccb66a3580..4bcb8c51446ee77020731131ee95bc2e9bc7ef9e 100644 (file)
@@ -36,7 +36,7 @@ float autocvar_sv_minigames_pong_ball_number;
 float autocvar_sv_minigames_pong_ai_thinkspeed;
 float autocvar_sv_minigames_pong_ai_tolerance;
 
-void pong_ball_think();
+void pong_ball_think(entity this);
 
 // Throws a ball in a random direction and sets the think function
 void pong_ball_throw(entity ball)
@@ -47,15 +47,15 @@ void pong_ball_throw(entity ball)
        while ( fabs(sin(angle)) < 0.17 || fabs(cos(angle)) < 0.17 );
        ball.velocity_x = cos(angle)*autocvar_sv_minigames_pong_ball_speed;
        ball.velocity_y = sin(angle)*autocvar_sv_minigames_pong_ball_speed;
-       ball.think = pong_ball_think;
+       setthink(ball, pong_ball_think);
        ball.nextthink = time;
        ball.team = 0;
        ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
 }
 
 // Think equivalent of pong_ball_throw, used to delay throws
-void pong_ball_throwthink()
-{SELFPARAM();
+void pong_ball_throwthink(entity this)
+{
        pong_ball_throw(self);
 }
 
@@ -64,10 +64,10 @@ void pong_ball_reset(entity ball)
 {
        ball.velocity = '0 0 0';
        ball.origin = '0.5 0.5 0';
-       ball.think = SUB_NullThink;
+       setthink(ball, SUB_NullThink);
        ball.team = 0;
        ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
-       ball.think = pong_ball_throwthink;
+       setthink(ball, pong_ball_throwthink);
        ball.nextthink = time + autocvar_sv_minigames_pong_ball_wait;
 }
 
@@ -145,77 +145,77 @@ bool pong_goal(entity ball, int pteam)
 }
 
 // Moves the ball around
-void pong_ball_think()
-{SELFPARAM();
+void pong_ball_think(entity this)
+{
        float think_speed = autocvar_sys_ticrate;
-       self.nextthink = time + think_speed;
+       this.nextthink = time + think_speed;
 
-       self.origin_x += self.velocity_x * think_speed;
-       self.origin_y += self.velocity_y * think_speed;
-       self.SendFlags |= MINIG_SF_UPDATE;
+       this.origin_x += this.velocity_x * think_speed;
+       this.origin_y += this.velocity_y * think_speed;
+       this.SendFlags |= MINIG_SF_UPDATE;
 
        int i;
        for ( i = 1; i <= PONG_MAX_PLAYERS; i++ )
-               if ( pong_paddle_hit(self, i) )
+               if ( pong_paddle_hit(this, i) )
                {
-                       pong_paddle_bounce(self,i);
-                       self.team = i;
-                       self.SendFlags |= PONG_SF_BALLTEAM;
+                       pong_paddle_bounce(this,i);
+                       this.team = i;
+                       this.SendFlags |= PONG_SF_BALLTEAM;
                        return;
                }
 
-       if ( self.origin_y <= self.pong_length )
+       if ( this.origin_y <= this.pong_length )
        {
-               if ( !pong_goal(self,3) )
+               if ( !pong_goal(this,3) )
                {
-                       self.origin_y = self.pong_length;
-                       self.velocity_y *= -1;
+                       this.origin_y = this.pong_length;
+                       this.velocity_y *= -1;
                }
        }
-       else if ( self.origin_y >= 1-self.pong_length )
+       else if ( this.origin_y >= 1-this.pong_length )
        {
-               if ( !pong_goal(self,4) )
+               if ( !pong_goal(this,4) )
                {
-                       self.origin_y = 1-self.pong_length;
-                       self.velocity_y *= -1;
+                       this.origin_y = 1-this.pong_length;
+                       this.velocity_y *= -1;
                }
        }
 
-       if ( self.origin_x <= self.pong_length )
+       if ( this.origin_x <= this.pong_length )
        {
-               if ( !pong_goal(self,2) )
+               if ( !pong_goal(this,2) )
                {
-                        self.origin_x = self.pong_length;
-                        self.velocity_x *= -1;
+                        this.origin_x = this.pong_length;
+                        this.velocity_x *= -1;
                }
        }
-       else if ( self.origin_x >= 1-self.pong_length )
+       else if ( this.origin_x >= 1-this.pong_length )
        {
-               if ( !pong_goal(self,1) )
+               if ( !pong_goal(this,1) )
                {
-                        self.origin_x = 1-self.pong_length;
-                        self.velocity_x *= -1;
+                        this.origin_x = 1-this.pong_length;
+                        this.velocity_x *= -1;
                }
        }
 
 }
 
 // AI action
-void pong_ai_think()
-{SELFPARAM();
+void pong_ai_think(entity this)
+{
        float think_speed = autocvar_sv_minigames_pong_ai_thinkspeed;
-       self.nextthink = time + think_speed;
+       this.nextthink = time + think_speed;
 
        float distance;
        float next_distance;
        float min_distance = 1;
        entity ball = world;
        entity mayball = world;
-       while ( ( mayball = findentity(mayball,owner,self.owner) ) )
+       while ( ( mayball = findentity(mayball,owner,this.owner) ) )
                if ( mayball.classname == "pong_ball" )
                {
-                       distance = vlen(mayball.origin-self.pong_ai_paddle.origin);
-                       next_distance = vlen(mayball.origin+mayball.velocity-self.pong_ai_paddle.origin);
+                       distance = vlen(mayball.origin-this.pong_ai_paddle.origin);
+                       next_distance = vlen(mayball.origin+mayball.velocity-this.pong_ai_paddle.origin);
                        if (  distance < min_distance && ( distance < 0.5 || next_distance < distance ) )
                        {
                                min_distance = distance;
@@ -224,31 +224,31 @@ void pong_ai_think()
                }
 
        float target = 0.5;
-       float self_pos;
+       float my_pos;
 
 
-       if ( self.team <= 2 )
+       if ( this.team <= 2 )
        {
                if ( ball )
                        target = ball.origin_y + ball.velocity_y*think_speed;
-               self_pos = self.pong_ai_paddle.origin_y;
+               my_pos = this.pong_ai_paddle.origin_y;
        }
        else
        {
                if ( ball )
                        target = ball.origin_x + ball.velocity_x*think_speed;
-               self_pos = self.pong_ai_paddle.origin_x;
+               my_pos = this.pong_ai_paddle.origin_x;
        }
 
-       distance = self.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
+       distance = this.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
                + autocvar_sv_minigames_pong_paddle_speed * think_speed;
 
-       if (target < self_pos - distance)
-               self.pong_keys = PONG_KEY_DECREASE;
-       else if (target > self_pos + distance)
-               self.pong_keys = PONG_KEY_INCREASE;
+       if (target < my_pos - distance)
+               this.pong_keys = PONG_KEY_DECREASE;
+       else if (target > my_pos + distance)
+               this.pong_keys = PONG_KEY_INCREASE;
        else
-               self.pong_keys = 0;
+               this.pong_keys = 0;
 }
 
 entity pong_ai_spawn(entity paddle)
@@ -256,7 +256,7 @@ entity pong_ai_spawn(entity paddle)
        entity ai = msle_spawn(paddle.owner,"pong_ai");
        ai.minigame_players = ai;
        ai.team = paddle.team;
-       ai.think = pong_ai_think;
+       setthink(ai, pong_ai_think);
        ai.nextthink = time;
        ai.pong_ai_paddle = paddle;
 
@@ -266,26 +266,26 @@ entity pong_ai_spawn(entity paddle)
 }
 
 // Moves the paddle
-void pong_paddle_think()
-{SELFPARAM();
+void pong_paddle_think(entity this)
+{
        float think_speed = autocvar_sys_ticrate;
-       self.nextthink = time + think_speed;
+       this.nextthink = time + think_speed;
 
-       if ( self.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
-                self.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
+       if ( this.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
+                this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
        {
                float movement = autocvar_sv_minigames_pong_paddle_speed * think_speed;
-               float halflen = self.pong_length/2;
+               float halflen = this.pong_length/2;
 
-               if ( self.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
+               if ( this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
                        movement *= -1;
 
-               if ( self.team > 2 )
-                       self.origin_x = bound(halflen, self.origin_x+movement, 1-halflen);
+               if ( this.team > 2 )
+                       this.origin_x = bound(halflen, this.origin_x+movement, 1-halflen);
                else
-                       self.origin_y = bound(halflen, self.origin_y+movement, 1-halflen);
+                       this.origin_y = bound(halflen, this.origin_y+movement, 1-halflen);
 
-               self.SendFlags |= MINIG_SF_UPDATE;
+               this.SendFlags |= MINIG_SF_UPDATE;
        }
 }
 
@@ -315,7 +315,7 @@ entity pong_paddle_spawn(entity minigame, int pl_team, entity real_player)
        entity paddle = msle_spawn(minigame,"pong_paddle");
        paddle.pong_length = autocvar_sv_minigames_pong_paddle_size;
        paddle.origin = pong_team_to_paddlepos(pl_team);
-       paddle.think = pong_paddle_think;
+       setthink(paddle, pong_paddle_think);
        paddle.nextthink = time;
        paddle.team = pl_team;
        paddle.mins = pong_team_to_box_halfsize(pl_team,-paddle.pong_length,-1/16);
index d367472d8214f1a4296e4bbf3dcce47802c06e00..98729092ccd2894c10a172c687439fc69c521457 100644 (file)
@@ -153,17 +153,16 @@ void snake_check_winner(entity minigame)
 }
 
 void snake_move_head(entity minigame, entity head);
-void snake_head_think()
+void snake_head_think(entity this)
 {
-    SELFPARAM();
-       entity minigame = self.owner;
+       entity minigame = this.owner;
 
        if(minigame.minigame_flags & SNAKE_TURN_MOVE)
-               snake_move_head(minigame, self);
+               snake_move_head(minigame, this);
 
        snake_check_winner(minigame);
 
-       self.nextthink = time + self.snake_delay;
+       this.nextthink = time + this.snake_delay;
 }
 
 void minigame_setup_snake(entity minigame, int pteam)
@@ -185,7 +184,7 @@ void minigame_setup_snake(entity minigame, int pteam)
        piece.snake_next = world;
        piece.snake_prev = world;
        piece.snake_last = piece;
-       piece.think = snake_head_think;
+       setthink(piece, snake_head_think);
        piece.snake_delay = autocvar_sv_minigames_snake_delay_initial;
        piece.nextthink = time + 0.1;
        minigame_server_sendflags(piece,MINIG_SF_ALL);
index 991544189291e227cf6e6876d6cb7c15bfb9fff3..18e1d3216ee38e14ae103df2720b96a9773dc405 100644 (file)
@@ -65,35 +65,35 @@ bool minigame_SendEntity(entity this, entity to, int sf)
 
        if ( sf & MINIG_SF_CREATE )
        {
-               WriteShort(MSG_ENTITY,msle_id(self.classname));
-               WriteString(MSG_ENTITY,self.netname);
+               WriteShort(MSG_ENTITY,msle_id(this.classname));
+               WriteString(MSG_ENTITY,this.netname);
        }
 
-       entity minigame_ent = self.owner;
+       entity minigame_ent = this.owner;
 
-       if ( self.classname == "minigame" )
+       if ( this.classname == "minigame" )
        {
-               minigame_ent = self;
+               minigame_ent = this;
 
                if ( sf & MINIG_SF_CREATE )
-                       WriteString(MSG_ENTITY,self.descriptor.netname);
+                       WriteString(MSG_ENTITY,this.descriptor.netname);
 
                if ( sf & MINIG_SF_UPDATE )
-                       WriteLong(MSG_ENTITY,self.minigame_flags);
+                       WriteLong(MSG_ENTITY,this.minigame_flags);
        }
-       else if ( self.classname == "minigame_player" )
+       else if ( this.classname == "minigame_player" )
        {
                if ( sf & MINIG_SF_CREATE )
                {
-                       WriteString(MSG_ENTITY,self.owner.netname);
-                       WriteLong(MSG_ENTITY,etof(self.minigame_players));
+                       WriteString(MSG_ENTITY,this.owner.netname);
+                       WriteLong(MSG_ENTITY,etof(this.minigame_players));
                }
                if ( sf & MINIG_SF_UPDATE )
-                       WriteByte(MSG_ENTITY,self.team);
+                       WriteByte(MSG_ENTITY,this.team);
        }
        MINIGAME_SIMPLELINKED_ENTITIES
 
-       minigame_ent.minigame_event(minigame_ent,"network_send",self,sf);
+       minigame_ent.minigame_event(minigame_ent,"network_send",this,sf);
 
        return true;
 
@@ -122,7 +122,7 @@ bool minigame_CheckSend()
 }
 
 int minigame_addplayer(entity minigame_session, entity player)
-{SELFPARAM();
+{
        if ( player.active_minigame )
        {
                if ( player.active_minigame == minigame_session )
index 66ea47f251abd8681c3bbe716cfd77a207a49e98..5b7bf3a56a512101e07ca5fafcfeb97fc6d633b9 100644 (file)
@@ -160,10 +160,9 @@ void M_Mage_Attack_Spike_Explode(entity this)
        remove (this);
 }
 
-void M_Mage_Attack_Spike_Touch()
+void M_Mage_Attack_Spike_Touch(entity this)
 {
-    SELFPARAM();
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        M_Mage_Attack_Spike_Explode(self);
 }
@@ -171,57 +170,57 @@ void M_Mage_Attack_Spike_Touch()
 .float wait;
 
 // copied from W_Seeker_Think
-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(self);
+void M_Mage_Attack_Spike_Think(entity this)
+{
+       if (time > this.ltime || (this.enemy && this.enemy.health <= 0) || this.owner.health <= 0) {
+               this.projectiledeathtype |= HITTYPE_SPLASH;
+               M_Mage_Attack_Spike_Explode(this);
        }
 
-       float spd = vlen(self.velocity);
+       float spd = vlen(this.velocity);
        spd = bound(
                spd - (autocvar_g_monster_mage_attack_spike_decel) * frametime,
                (autocvar_g_monster_mage_attack_spike_speed_max),
                spd + (autocvar_g_monster_mage_attack_spike_accel) * frametime
        );
 
-       if (self.enemy != world)
-               if (self.enemy.takedamage != DAMAGE_AIM || IS_DEAD(self.enemy))
-                       self.enemy = world;
+       if (this.enemy != world)
+               if (this.enemy.takedamage != DAMAGE_AIM || IS_DEAD(this.enemy))
+                       this.enemy = world;
 
-       if (self.enemy != world)
+       if (this.enemy != world)
        {
-               entity e = self.enemy;
+               entity e = this.enemy;
                vector eorg = 0.5 * (e.absmin + e.absmax);
                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
+               vector desireddir = normalize(eorg - this.origin);
+               vector olddir = normalize(this.velocity); // get my current direction
 
                // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
-               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - self.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
+               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - this.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
                {
-                       // Is it a better idea (shorter distance) to trace to the target itself?
-                       if ( vlen2(self.origin + olddir * self.wait) < vlen2(eorg - self.origin))
-                               traceline(self.origin, self.origin + olddir * self.wait, false, self);
+                       // Is it a better idea (shorter distance) to trace to the target itthis?
+                       if ( vlen2(this.origin + olddir * this.wait) < vlen2(eorg - this.origin))
+                               traceline(this.origin, this.origin + olddir * this.wait, false, this);
                        else
-                               traceline(self.origin, eorg, false, self);
+                               traceline(this.origin, eorg, false, this);
 
                        // Setup adaptive tracelength
-                       self.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(self.origin - trace_endpos), self.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
+                       this.wait = bound((autocvar_g_monster_mage_attack_spike_smart_trace_min), vlen(this.origin - trace_endpos), this.wait = (autocvar_g_monster_mage_attack_spike_smart_trace_max));
 
                        // Calc how important it is that we turn and add this to the desierd (enemy) dir.
                        desireddir = normalize(((trace_plane_normal * (1 - trace_fraction)) + (desireddir * trace_fraction)) * 0.5);
                }
 
                vector newdir = normalize(olddir + desireddir * turnrate); // take the average of the 2 directions; not the best method but simple & easy
-               self.velocity = newdir * spd; // make me fly in the new direction at my flight speed
+               this.velocity = newdir * spd; // make me fly in the new direction at my flight speed
        }
 
        ///////////////
 
-       //self.angles = vectoangles(self.velocity);                     // turn model in the new flight direction
-       self.nextthink = time;// + 0.05; // csqc projectiles
-       UpdateCSQCProjectile(self);
+       //this.angles = vectoangles(this.velocity);                     // turn model in the new flight direction
+       this.nextthink = time;// + 0.05; // csqc projectiles
+       UpdateCSQCProjectile(this);
 }
 
 void M_Mage_Attack_Spike(entity this, vector dir)
@@ -230,7 +229,7 @@ void M_Mage_Attack_Spike(entity this, vector dir)
 
        entity missile = spawn();
        missile.owner = missile.realowner = this;
-       missile.think = M_Mage_Attack_Spike_Think;
+       setthink(missile, M_Mage_Attack_Spike_Think);
        missile.ltime = time + 7;
        missile.nextthink = time;
        missile.solid = SOLID_BBOX;
@@ -241,7 +240,7 @@ void M_Mage_Attack_Spike(entity this, vector dir)
        missile.velocity = dir * 400;
        missile.avelocity = '300 300 300';
        missile.enemy = this.enemy;
-       missile.touch = M_Mage_Attack_Spike_Touch;
+       settouch(missile, M_Mage_Attack_Spike_Touch);
 
        this.mage_spike = missile;
 
index 139967a2ccb5fcc5826265b9a488c32ea2bedc38..2e9384dc2adb0c37a78319c1ba6411e53328760f 100644 (file)
@@ -78,36 +78,36 @@ void M_Shambler_Attack_Swing(entity this)
 
 #include <common/effects/qc/all.qh>
 
-void M_Shambler_Attack_Lightning_Explode()
-{SELFPARAM();
+void M_Shambler_Attack_Lightning_Explode(entity this)
+{
        entity head;
 
-       sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
-       Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
+       sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
+       Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
 
-       self.event_damage = func_null;
-       self.takedamage = DAMAGE_NO;
-       self.movetype = MOVETYPE_NONE;
-       self.velocity = '0 0 0';
+       this.event_damage = func_null;
+       this.takedamage = DAMAGE_NO;
+       this.movetype = MOVETYPE_NONE;
+       this.velocity = '0 0 0';
 
-       if(self.movetype == MOVETYPE_NONE)
-               self.velocity = self.oldvelocity;
+       if(this.movetype == MOVETYPE_NONE)
+               this.velocity = this.oldvelocity;
 
-       RadiusDamage (self, self.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), world, world, (autocvar_g_monster_shambler_attack_lightning_force), self.projectiledeathtype, other);
+       RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), world, world, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, other);
 
-       for(head = findradius(self.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != self.realowner) if(head.takedamage)
+       for(head = findradius(this.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != this.realowner) if(head.takedamage)
        {
-               te_csqc_lightningarc(self.origin, head.origin);
-               Damage(head, self, self.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(self), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
+               te_csqc_lightningarc(this.origin, head.origin);
+               Damage(head, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
        }
 
-       self.think = SUB_Remove_self;
-       self.nextthink = time + 0.2;
+       setthink(this, SUB_Remove);
+       this.nextthink = time + 0.2;
 }
 
 void M_Shambler_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, M_Shambler_Attack_Lightning_Explode());
+       M_Shambler_Attack_Lightning_Explode(this);
 }
 
 void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -124,20 +124,20 @@ void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity at
                W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
 }
 
-void M_Shambler_Attack_Lightning_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void M_Shambler_Attack_Lightning_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
 
        self.use(this, NULL, NULL);
 }
 
-void M_Shambler_Attack_Lightning_Think()
-{SELFPARAM();
-       self.nextthink = time;
-       if (time > self.cnt)
+void M_Shambler_Attack_Lightning_Think(entity this)
+{
+       this.nextthink = time;
+       if (time > this.cnt)
        {
                other = world;
-               M_Shambler_Attack_Lightning_Explode();
+               M_Shambler_Attack_Lightning_Explode(this);
                return;
        }
 }
@@ -161,9 +161,9 @@ void M_Shambler_Attack_Lightning(entity this)
 
        gren.cnt = time + 5;
        gren.nextthink = time;
-       gren.think = M_Shambler_Attack_Lightning_Think;
+       setthink(gren, M_Shambler_Attack_Lightning_Think);
        gren.use = M_Shambler_Attack_Lightning_Explode_use;
-       gren.touch = M_Shambler_Attack_Lightning_Touch;
+       settouch(gren, M_Shambler_Attack_Lightning_Touch);
 
        gren.takedamage = DAMAGE_YES;
        gren.health = 50;
index 0b2e3650b4c3cdf23d86008393709646af99614d..b9f9bfc21c2992807c513abaf5cd0c7649720138 100644 (file)
@@ -156,14 +156,14 @@ void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger)
        WITHSELF(this, M_Spider_Attack_Web_Explode());
 }
 
-void M_Spider_Attack_Web_Touch()
+void M_Spider_Attack_Web_Touch(entity this)
 {
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        M_Spider_Attack_Web_Explode();
 }
 
-void adaptor_think2use_hittype_splash();
+void adaptor_think2use_hittype_splash(entity this);
 
 void M_Spider_Attack_Web(entity this)
 {
@@ -174,7 +174,7 @@ void M_Spider_Attack_Web(entity this)
        entity proj = new(plasma);
        proj.owner = proj.realowner = this;
        proj.use = M_Spider_Attack_Web_Explode_use;
-       proj.think = adaptor_think2use_hittype_splash;
+       setthink(proj, adaptor_think2use_hittype_splash);
        proj.bot_dodge = true;
        proj.bot_dodgerating = 0;
        proj.nextthink = time + 5;
@@ -186,7 +186,7 @@ void M_Spider_Attack_Web(entity this)
        //proj.glow_color = 45;
        proj.movetype = MOVETYPE_BOUNCE;
        W_SetupProjVelocity_Explicit(proj, v_forward, v_up, (autocvar_g_monster_spider_attack_web_speed), (autocvar_g_monster_spider_attack_web_speed_up), 0, 0, false);
-       proj.touch = M_Spider_Attack_Web_Touch;
+       settouch(proj, M_Spider_Attack_Web_Touch);
        setsize(proj, '-4 -4 -4', '4 4 4');
        proj.takedamage = DAMAGE_NO;
        proj.damageforcescale = 0;
index 1adf8f84c85af71053b4d98cbf2e39ceaf7170c1..ae8e8751de182271788f96ed8396065ad85a677c 100644 (file)
@@ -45,8 +45,8 @@ float autocvar_g_monster_wyvern_attack_fireball_force;
 float autocvar_g_monster_wyvern_attack_fireball_radius;
 float autocvar_g_monster_wyvern_attack_fireball_speed;
 
-void M_Wyvern_Attack_Fireball_Explode();
-void M_Wyvern_Attack_Fireball_Touch();
+void M_Wyvern_Attack_Fireball_Explode(entity this);
+void M_Wyvern_Attack_Fireball_Touch(entity this);
 
 SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
@@ -72,15 +72,15 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity
                missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
                missile.avelocity = '300 300 300';
                missile.nextthink = time + 5;
-               missile.think = M_Wyvern_Attack_Fireball_Explode;
-               missile.touch = M_Wyvern_Attack_Fireball_Touch;
+               setthink(missile, M_Wyvern_Attack_Fireball_Explode);
+               settouch(missile, M_Wyvern_Attack_Fireball_Touch);
                CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
 
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
 }
 
-METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this)) {
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
     TC(WyvernAttack, this);
        return true;
 }
@@ -99,29 +99,28 @@ const float wyvern_anim_pain        = 3;
 const float wyvern_anim_death  = 4;
 */
 
-void M_Wyvern_Attack_Fireball_Explode()
+void M_Wyvern_Attack_Fireball_Explode(entity this)
 {
-       SELFPARAM();
-       Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
 
-       entity own = self.realowner;
+       entity own = this.realowner;
 
-       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);
+       RadiusDamage(this, 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, this.projectiledeathtype, world);
 
        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);
+               if(vdist(it.origin - this.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
+                       Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, this.projectiledeathtype);
        });
 
-       remove(self);
+       remove(this);
 }
 
-void M_Wyvern_Attack_Fireball_Touch()
+void M_Wyvern_Attack_Fireball_Touch(entity this)
 {
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
-       M_Wyvern_Attack_Fireball_Explode();
+       M_Wyvern_Attack_Fireball_Explode(this);
 }
 
 bool M_Wyvern_Attack(int attack_type, entity actor, entity targ)
index b28bb8d84eaefa6fbb194bd293b35e48cc992702..ec84bb948f21e8503bf1ea321cbbc03699479d9b 100644 (file)
@@ -75,8 +75,8 @@ const float zombie_anim_spawn                         = 30;
 
 .vector moveto;
 
-void M_Zombie_Attack_Leap_Touch()
-{SELFPARAM();
+void M_Zombie_Attack_Leap_Touch(entity this)
+{
        if (self.health <= 0)
                return;
 
@@ -87,14 +87,14 @@ void M_Zombie_Attack_Leap_Touch()
                angles_face = vectoangles(self.moveto - self.origin);
                angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force);
                Damage(other, self, self, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_ZOMBIE_JUMP.m_id, other.origin, angles_face);
-               self.touch = Monster_Touch; // instantly turn it off to stop damage spam
+               settouch(self, Monster_Touch); // instantly turn it off to stop damage spam
                self.state = 0;
        }
 
        if (trace_dphitcontents)
        {
                self.state = 0;
-               self.touch = Monster_Touch;
+               settouch(self, Monster_Touch);
        }
 }
 
index def29e969df9a8b373d50121deb37f77065877dc..2e7281bc2c2d1f9b08bdccb6005da9c9b228a923 100644 (file)
@@ -191,7 +191,6 @@ void monster_changeteam(entity ent, float newteam)
 }
 
 .void(entity) monster_delayedfunc;
-void Monster_Delay_Action_self();
 void Monster_Delay_Action(entity this)
 {
        if(Monster_ValidTarget(this.owner, this.owner.enemy)) { this.monster_delayedfunc(this.owner); }
@@ -199,28 +198,22 @@ void Monster_Delay_Action(entity this)
        if(this.cnt > 1)
        {
                this.cnt -= 1;
-               this.think = Monster_Delay_Action_self;
+               setthink(this, Monster_Delay_Action);
                this.nextthink = time + this.count;
        }
        else
        {
-               this.think = SUB_Remove_self;
+               setthink(this, SUB_Remove);
                this.nextthink = time;
        }
 }
 
-void Monster_Delay_Action_self()
-{
-    SELFPARAM();
-       Monster_Delay_Action(self);
-}
-
 void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
 {
        // deferred attacking, checks if monster is still alive and target is still valid before attacking
        entity e = spawn();
 
-       e.think = Monster_Delay_Action_self;
+       setthink(e, Monster_Delay_Action);
        e.nextthink = time + defer_amnt;
        e.count = defer_amnt;
        e.owner = this;
@@ -401,7 +394,7 @@ bool Monster_Attack_Leap_Check(entity this, vector vel)
        return true;
 }
 
-bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime)
+bool Monster_Attack_Leap(entity this, vector anm, void(entity this) touchfunc, vector vel, float animtime)
 {
        if(!Monster_Attack_Leap_Check(this, vel))
                return false;
@@ -415,7 +408,7 @@ bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel,
 
        if(this.flags & FL_MONSTER)
                this.state = MONSTER_ATTACK_RANGED;
-       this.touch = touchfunc;
+       settouch(this, touchfunc);
        this.origin_z += 1;
        this.velocity = vel;
        UNSET_ONGROUND(this);
@@ -473,8 +466,8 @@ void Monster_UpdateModel(entity this)
        mon.mr_anim(mon, this);
 }
 
-void Monster_Touch()
-{SELFPARAM();
+void Monster_Touch(entity this)
+{
        if(other == world) { return; }
 
        if(other.monster_attack)
@@ -516,14 +509,14 @@ bool Monster_Respawn_Check(entity this)
        return true;
 }
 
-void Monster_Respawn() { SELFPARAM(); Monster_Spawn(this, this.monsterid); }
+void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); }
 
 void Monster_Dead_Fade(entity this)
 {
        if(Monster_Respawn_Check(this))
        {
                this.spawnflags |= MONSTERFLAG_RESPAWNED;
-               this.think = Monster_Respawn;
+               setthink(this, Monster_Respawn);
                this.nextthink = time + this.respawntime;
                this.monster_lifetime = 0;
                this.deadflag = DEAD_RESPAWNING;
@@ -835,7 +828,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
        if(this.state == MONSTER_ATTACK_RANGED && IS_ONGROUND(this))
        {
                this.state = 0;
-               this.touch = Monster_Touch;
+               settouch(this, Monster_Touch);
        }
 
        if(this.state && time >= this.attack_finished_single[0])
@@ -919,8 +912,8 @@ void Monster_Remove(entity this)
        remove(this);
 }
 
-void Monster_Dead_Think()
-{SELFPARAM();
+void Monster_Dead_Think(entity this)
+{
        this.nextthink = time + this.ticrate;
 
        if(this.monster_lifetime != 0)
@@ -943,7 +936,7 @@ bool Monster_Appear_Check(entity this, int monster_id)
        if(!(this.spawnflags & MONSTERFLAG_APPEAR))
                return false;
 
-       this.think = func_null;
+       setthink(this, func_null);
        this.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used)
        this.nextthink = 0;
        this.use = Monster_Appear;
@@ -980,7 +973,7 @@ void Monster_Dead_Damage(entity this, entity inflictor, entity attacker, float d
                // number of monsters spawned with mobspawn command
                totalspawned -= 1;
 
-               this.think = SUB_Remove_self;
+               setthink(this, SUB_Remove);
                this.nextthink = time + 0.1;
                this.event_damage = func_null;
        }
@@ -988,7 +981,7 @@ void Monster_Dead_Damage(entity this, entity inflictor, entity attacker, float d
 
 void Monster_Dead(entity this, entity attacker, float gibbed)
 {
-       this.think = Monster_Dead_Think;
+       setthink(this, Monster_Dead_Think);
        this.nextthink = time;
        this.monster_lifetime = time + 5;
 
@@ -1022,7 +1015,7 @@ void Monster_Dead(entity this, entity attacker, float gibbed)
        this.enemy                      = world;
        this.movetype           = MOVETYPE_TOSS;
        this.moveto                     = this.origin;
-       this.touch                      = Monster_Touch; // reset incase monster was pouncing
+       settouch(this, Monster_Touch); // reset incase monster was pouncing
        this.reset                      = func_null;
        this.state                      = 0;
        this.attack_finished_single[0] = 0;
@@ -1115,7 +1108,7 @@ void Monster_Damage(entity this, entity inflictor, entity attacker, float damage
                {
                        Violence_GibSplash(this, 1, 0.5, attacker);
 
-                       this.think = SUB_Remove_self;
+                       setthink(this, SUB_Remove);
                        this.nextthink = time + 0.1;
                }
        }
@@ -1214,9 +1207,9 @@ void Monster_Anim(entity this)
        */
 }
 
-void Monster_Think()
-{SELFPARAM();
-       this.think = Monster_Think;
+void Monster_Think(entity this)
+{
+       setthink(this, Monster_Think);
        this.nextthink = this.ticrate;
 
        if(this.monster_lifetime)
@@ -1287,7 +1280,7 @@ bool Monster_Spawn_Setup(entity this)
                }
        }
 
-       this.think = Monster_Think;
+       setthink(this, Monster_Think);
        this.nextthink = time + this.ticrate;
 
        if(MUTATOR_CALLHOOK(MonsterSpawn, this))
@@ -1331,7 +1324,7 @@ bool Monster_Spawn(entity this, int mon_id)
        this.damagedbycontents  = true;
        this.monsterid                  = mon_id;
        this.event_damage               = Monster_Damage;
-       this.touch                              = Monster_Touch;
+       settouch(this, Monster_Touch);
        this.use                                = Monster_Use;
        this.solid                              = SOLID_BBOX;
        this.movetype                   = MOVETYPE_WALK;
index 59d8cbd973f9b144d63f527881651499542d9581..f8501fc758e1b8184f67e9ff222beab022d647ac 100644 (file)
@@ -77,7 +77,7 @@ bool Monster_Spawn(entity this, int mon_id);
 
 void monster_setupcolors(entity this);
 
-void Monster_Touch();
+void Monster_Touch(entity this);
 
 void Monster_Move_2D(entity this, float mspeed, float allow_jumpoff);
 
@@ -85,7 +85,7 @@ void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity)
 
 float Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop);
 
-bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime);
+bool Monster_Attack_Leap(entity this, vector anm, void(entity this) touchfunc, vector vel, float animtime);
 
 entity Monster_FindTarget(entity this);
 
index 8e1319b39bdcfeb16e6b7f164735b773f7a71fde..66f83d1c517c03705af2508787f4f0eeef4f46f9 100644 (file)
@@ -46,9 +46,9 @@ STATIC_INIT(REGISTER_BUFFS) {
        void buff_Init(entity ent);
        void buff_Init_Compat(entity ent, entity replacement);
        #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
-               self.buffs = b.m_itemid; \
-               self.team = t; \
-               buff_Init(self); \
+               this.buffs = b.m_itemid; \
+               this.team = t; \
+               buff_Init(this); \
        }
        #define BUFF_SPAWNFUNCS(e, b)                       \
                        BUFF_SPAWNFUNC(e,           b,  0)          \
@@ -56,7 +56,7 @@ STATIC_INIT(REGISTER_BUFFS) {
                        BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
                        BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
                        BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
-       #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
+       #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(this, r); }
 #else
        #define BUFF_SPAWNFUNC(e, b, t)
        #define BUFF_SPAWNFUNCS(e, b)
index 15b725ee4b18d2bcd934728a6e0b2c2c8b233496..c450dc5703d8ba2520a64518701b442c9737bb6a 100644 (file)
@@ -153,17 +153,17 @@ void buff_Effect(entity player, string eff)
 }
 
 // buff item
-float buff_Waypoint_visible_for_player(entity plr)
-{SELFPARAM();
-       if(!self.owner.buff_active && !self.owner.buff_activetime)
+bool buff_Waypoint_visible_for_player(entity this, entity player, entity view)
+{
+       if(!this.owner.buff_active && !this.owner.buff_activetime)
                return false;
 
-       if (plr.buffs)
+       if (view.buffs)
        {
-               return plr.cvar_cl_buffs_autoreplace == false || plr.buffs != self.owner.buffs;
+               return view.cvar_cl_buffs_autoreplace == false || view.buffs != this.owner.buffs;
        }
 
-       return WaypointSprite_visible_for_player(plr);
+       return WaypointSprite_visible_for_player(this, player, view);
 }
 
 void buff_Waypoint_Spawn(entity e)
@@ -175,16 +175,16 @@ void buff_Waypoint_Spawn(entity e)
        e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
 }
 
-void buff_SetCooldown(float cd)
-{SELFPARAM();
+void buff_SetCooldown(entity this, float cd)
+{
        cd = max(0, cd);
 
-       if(!self.buff_waypoint)
-               buff_Waypoint_Spawn(self);
+       if(!this.buff_waypoint)
+               buff_Waypoint_Spawn(this);
 
-       WaypointSprite_UpdateBuildFinished(self.buff_waypoint, time + cd);
-       self.buff_activetime = cd;
-       self.buff_active = !cd;
+       WaypointSprite_UpdateBuildFinished(this.buff_waypoint, time + cd);
+       this.buff_activetime = cd;
+       this.buff_active = !cd;
 }
 
 void buff_Respawn(entity this)
@@ -197,7 +197,7 @@ void buff_Respawn(entity this)
        if(!MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY,
                ((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256))
        {
-               entity spot = SelectSpawnPoint(true);
+               entity spot = SelectSpawnPoint(this, true);
                setorigin(this, spot.origin);
                this.velocity = ((randomvec() * 100) + '0 0 200');
                this.angles = spot.angles;
@@ -222,8 +222,8 @@ void buff_Respawn(entity this)
        sound(this, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
 }
 
-void buff_Touch()
-{SELFPARAM();
+void buff_Touch(entity this)
+{
        if(gameover) { return; }
 
        if(ITEM_TOUCH_NEEDKILL())
@@ -298,82 +298,82 @@ void buff_NewType(entity ent, float cb)
        ent.buffs = RandomSelection_chosen_float;
 }
 
-void buff_Think()
-{SELFPARAM();
-       if(self.buffs != self.oldbuffs)
+void buff_Think(entity this)
+{
+       if(this.buffs != this.oldbuffs)
        {
-               entity buff = buff_FirstFromFlags(self.buffs);
-               self.color = buff.m_color;
-               self.glowmod = buff_GlowColor(buff);
-               self.skin = buff.m_skin;
+               entity buff = buff_FirstFromFlags(this.buffs);
+               this.color = buff.m_color;
+               this.glowmod = buff_GlowColor(buff);
+               this.skin = buff.m_skin;
 
-               setmodel(self, MDL_BUFF);
+               setmodel(this, MDL_BUFF);
 
-               if(self.buff_waypoint)
+               if(this.buff_waypoint)
                {
-                       //WaypointSprite_Disown(self.buff_waypoint, 1);
-                       WaypointSprite_Kill(self.buff_waypoint);
-                       buff_Waypoint_Spawn(self);
-                       if(self.buff_activetime)
-                               WaypointSprite_UpdateBuildFinished(self.buff_waypoint, time + self.buff_activetime - frametime);
+                       //WaypointSprite_Disown(this.buff_waypoint, 1);
+                       WaypointSprite_Kill(this.buff_waypoint);
+                       buff_Waypoint_Spawn(this);
+                       if(this.buff_activetime)
+                               WaypointSprite_UpdateBuildFinished(this.buff_waypoint, time + this.buff_activetime - frametime);
                }
 
-               self.oldbuffs = self.buffs;
+               this.oldbuffs = this.buffs;
        }
 
        if(!gameover)
        if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
-       if(!self.buff_activetime_updated)
+       if(!this.buff_activetime_updated)
        {
-               buff_SetCooldown(self.buff_activetime);
-               self.buff_activetime_updated = true;
+               buff_SetCooldown(this, this.buff_activetime);
+               this.buff_activetime_updated = true;
        }
 
-       if(!self.buff_active && !self.buff_activetime)
-       if(!self.owner || STAT(FROZEN, self.owner) || IS_DEAD(self.owner) || !self.owner.iscreature || !(self.owner.buffs & self.buffs))
+       if(!this.buff_active && !this.buff_activetime)
+       if(!this.owner || STAT(FROZEN, this.owner) || IS_DEAD(this.owner) || !this.owner.iscreature || !(this.owner.buffs & this.buffs))
        {
-               buff_SetCooldown(autocvar_g_buffs_cooldown_respawn + frametime);
-               self.owner = world;
+               buff_SetCooldown(this, autocvar_g_buffs_cooldown_respawn + frametime);
+               this.owner = world;
                if(autocvar_g_buffs_randomize)
-                       buff_NewType(self, self.buffs);
+                       buff_NewType(this, this.buffs);
 
-               if(autocvar_g_buffs_random_location || (self.spawnflags & 64))
-                       buff_Respawn(self);
+               if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
+                       buff_Respawn(this);
        }
 
-       if(self.buff_activetime)
+       if(this.buff_activetime)
        if(!gameover)
        if((round_handler_IsActive() && !round_handler_IsRoundStarted()) || time >= game_starttime)
        {
-               self.buff_activetime = max(0, self.buff_activetime - frametime);
+               this.buff_activetime = max(0, this.buff_activetime - frametime);
 
-               if(!self.buff_activetime)
+               if(!this.buff_activetime)
                {
-                       self.buff_active = true;
-                       sound(self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTN_NORM);
-                       Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
+                       this.buff_active = true;
+                       sound(this, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTN_NORM);
+                       Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
                }
        }
 
-       if(self.buff_active)
+       if(this.buff_active)
        {
-               if(self.team && !self.buff_waypoint)
-                       buff_Waypoint_Spawn(self);
+               if(this.team && !this.buff_waypoint)
+                       buff_Waypoint_Spawn(this);
 
-               if(self.lifetime)
-               if(time >= self.lifetime)
-                       buff_Respawn(self);
+               if(this.lifetime)
+               if(time >= this.lifetime)
+                       buff_Respawn(this);
        }
 
-       self.nextthink = time;
-       //self.angles_y = time * 110.1;
+       this.nextthink = time;
+       //this.angles_y = time * 110.1;
 }
 
-void buff_Waypoint_Reset()
-{SELFPARAM();
-       WaypointSprite_Kill(self.buff_waypoint);
+void buff_Waypoint_Reset(entity this)
+{
+       WaypointSprite_Kill(this.buff_waypoint);
 
-       if(self.buff_activetime) { buff_Waypoint_Spawn(self); }
+       if(this.buff_activetime) { buff_Waypoint_Spawn(this); }
 }
 
 void buff_Reset(entity this)
@@ -381,8 +381,8 @@ void buff_Reset(entity this)
        if(autocvar_g_buffs_randomize)
                buff_NewType(this, this.buffs);
        this.owner = world;
-       buff_SetCooldown(autocvar_g_buffs_cooldown_activate);
-       buff_Waypoint_Reset();
+       buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate);
+       buff_Waypoint_Reset(this);
        this.buff_activetime_updated = false;
 
        if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
@@ -392,68 +392,65 @@ void buff_Reset(entity this)
 float buff_Customize()
 {SELFPARAM();
        entity player = WaypointSprite_getviewentity(other);
-       if(!self.buff_active || (self.team && DIFF_TEAM(player, self)))
+       if(!this.buff_active || (this.team && DIFF_TEAM(player, this)))
        {
-               self.alpha = 0.3;
-               if(self.effects & EF_FULLBRIGHT) { self.effects &= ~(EF_FULLBRIGHT); }
-               self.pflags = 0;
+               this.alpha = 0.3;
+               if(this.effects & EF_FULLBRIGHT) { this.effects &= ~(EF_FULLBRIGHT); }
+               this.pflags = 0;
        }
        else
        {
-               self.alpha = 1;
-               if(!(self.effects & EF_FULLBRIGHT)) { self.effects |= EF_FULLBRIGHT; }
-               self.light_lev = 220 + 36 * sin(time);
-               self.pflags = PFLAGS_FULLDYNAMIC;
+               this.alpha = 1;
+               if(!(this.effects & EF_FULLBRIGHT)) { this.effects |= EF_FULLBRIGHT; }
+               this.light_lev = 220 + 36 * sin(time);
+               this.pflags = PFLAGS_FULLDYNAMIC;
        }
        return true;
 }
 
-void buff_Init(entity ent)
-{SELFPARAM();
-       if(!cvar("g_buffs")) { remove(ent); return; }
-
-       if(!teamplay && ent.team) { ent.team = 0; }
-
-       entity buff = buff_FirstFromFlags(self.buffs);
-
-       setself(ent);
-       if(!self.buffs || buff_Available(buff))
-               buff_NewType(self, 0);
-
-       self.classname = "item_buff";
-       self.solid = SOLID_TRIGGER;
-       self.flags = FL_ITEM;
-       self.think = buff_Think;
-       self.touch = buff_Touch;
-       self.reset = buff_Reset;
-       self.nextthink = time + 0.1;
-       self.gravity = 1;
-       self.movetype = MOVETYPE_TOSS;
-       self.scale = 1;
-       self.skin = buff.m_skin;
-       self.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW;
-       self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
-       self.customizeentityforclient = buff_Customize;
-       //self.gravity = 100;
-       self.color = buff.m_color;
-       self.glowmod = buff_GlowColor(self);
-       buff_SetCooldown(autocvar_g_buffs_cooldown_activate + game_starttime);
-       self.buff_active = !self.buff_activetime;
-       self.pflags = PFLAGS_FULLDYNAMIC;
-
-       if(self.spawnflags & 1)
-               self.noalign = true;
-
-       if(self.noalign)
-               self.movetype = MOVETYPE_NONE; // reset by random location
-
-       setmodel(self, MDL_BUFF);
-       setsize(self, BUFF_MIN, BUFF_MAX);
-
-       if(cvar("g_buffs_random_location") || (self.spawnflags & 64))
-               buff_Respawn(self);
+void buff_Init(entity this)
+{
+       if(!cvar("g_buffs")) { remove(this); return; }
+
+       if(!teamplay && this.team) { this.team = 0; }
+
+       entity buff = buff_FirstFromFlags(this.buffs);
 
-       setself(this);
+       if(!this.buffs || buff_Available(buff))
+               buff_NewType(this, 0);
+
+       this.classname = "item_buff";
+       this.solid = SOLID_TRIGGER;
+       this.flags = FL_ITEM;
+       setthink(this, buff_Think);
+       settouch(this, buff_Touch);
+       this.reset = buff_Reset;
+       this.nextthink = time + 0.1;
+       this.gravity = 1;
+       this.movetype = MOVETYPE_TOSS;
+       this.scale = 1;
+       this.skin = buff.m_skin;
+       this.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW;
+       this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+       this.customizeentityforclient = buff_Customize;
+       //this.gravity = 100;
+       this.color = buff.m_color;
+       this.glowmod = buff_GlowColor(this);
+       buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate + game_starttime);
+       this.buff_active = !this.buff_activetime;
+       this.pflags = PFLAGS_FULLDYNAMIC;
+
+       if(this.spawnflags & 1)
+               this.noalign = true;
+
+       if(this.noalign)
+               this.movetype = MOVETYPE_NONE; // reset by random location
+
+       setmodel(this, MDL_BUFF);
+       setsize(this, BUFF_MIN, BUFF_MAX);
+
+       if(cvar("g_buffs_random_location") || (this.spawnflags & 64))
+               buff_Respawn(this);
 }
 
 void buff_Init_Compat(entity ent, entity replacement)
@@ -477,12 +474,12 @@ void buff_SpawnReplacement(entity ent, entity old)
        buff_Init(ent);
 }
 
-void buff_Vengeance_DelayedDamage()
-{SELFPARAM();
-       if(self.enemy)
-               Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF.m_id, self.enemy.origin, '0 0 0');
+void buff_Vengeance_DelayedDamage(entity this)
+{
+       if(this.enemy)
+               Damage(this.enemy, this.owner, this.owner, this.dmg, DEATH_BUFF.m_id, this.enemy.origin, '0 0 0');
 
-       remove(self);
+       remove(this);
        return;
 }
 
@@ -549,7 +546,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate)
                dmgent.dmg = frag_damage * autocvar_g_buffs_vengeance_damage_multiplier;
                dmgent.enemy = frag_attacker;
                dmgent.owner = frag_target;
-               dmgent.think = buff_Vengeance_DelayedDamage;
+               setthink(dmgent, buff_Vengeance_DelayedDamage);
                dmgent.nextthink = time + 0.1;
        }
 
@@ -888,12 +885,11 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                        if(boxesoverlap(self.absmin - pickup_size, self.absmax + pickup_size, it.absmin, it.absmax))
                        {
-                               if(it.touch)
+                               if(gettouch(it))
                                {
                                        entity oldother = other;
                                        other = self;
-                                       WITHSELF(it, it.touch());
-
+                                       WITHSELF(it, gettouch(it)(it));
                                        other = oldother;
                                }
                        }
index ec11970fed3519536b2076f8d9cee51e3a286df7..fe33046678fa9fc1d46c47a3bd24132753b64a5a 100644 (file)
@@ -24,25 +24,25 @@ REGISTER_MUTATOR(mutator_instagib, cvar("g_instagib") && !g_nexball);
 
 spawnfunc(item_minst_cells)
 {
-       if (!g_instagib) { remove(self); return; }
-       if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
+       if (!g_instagib) { remove(this); return; }
+       if (!this.ammo_cells) this.ammo_cells = autocvar_g_instagib_ammo_drop;
        StartItem(this, ITEM_VaporizerCells);
 }
 
-void instagib_invisibility()
-{SELFPARAM();
-       self.strength_finished = autocvar_g_balance_powerup_strength_time;
+void instagib_invisibility(entity this)
+{
+       this.strength_finished = autocvar_g_balance_powerup_strength_time;
        StartItem(this, ITEM_Invisibility);
 }
 
-void instagib_extralife()
-{SELFPARAM();
+void instagib_extralife(entity this)
+{
        StartItem(this, ITEM_ExtraLife);
 }
 
-void instagib_speed()
-{SELFPARAM();
-       self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
+void instagib_speed(entity this)
+{
+       this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
        StartItem(this, ITEM_Speed);
 }
 
@@ -55,86 +55,86 @@ void instagib_stop_countdown(entity e)
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_INSTAGIB_FINDAMMO);
        e.instagib_needammo = false;
 }
-void instagib_ammocheck()
-{SELFPARAM();
-       if(time < self.instagib_nextthink)
+void instagib_ammocheck(entity this)
+{
+       if(time < this.instagib_nextthink)
                return;
-       if(!IS_PLAYER(self))
+       if(!IS_PLAYER(this))
                return; // not a player
 
-       if(IS_DEAD(self) || gameover)
-               instagib_stop_countdown(self);
-       else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
-               instagib_stop_countdown(self);
+       if(IS_DEAD(this) || gameover)
+               instagib_stop_countdown(this);
+       else if (this.ammo_cells > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+               instagib_stop_countdown(this);
        else if(autocvar_g_rm && autocvar_g_rm_laser)
        {
-               if(!self.instagib_needammo)
+               if(!this.instagib_needammo)
                {
-                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
-                       self.instagib_needammo = true;
+                       Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
+                       this.instagib_needammo = true;
                }
        }
        else
        {
-               self.instagib_needammo = true;
-               if (self.health <= 5)
+               this.instagib_needammo = true;
+               if (this.health <= 5)
                {
-                       Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
+                       Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
                }
-               else if (self.health <= 10)
+               else if (this.health <= 10)
                {
-                       Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
+                       Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_1);
                }
-               else if (self.health <= 20)
+               else if (this.health <= 20)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_2);
                }
-               else if (self.health <= 30)
+               else if (this.health <= 30)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_3);
                }
-               else if (self.health <= 40)
+               else if (this.health <= 40)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_4);
                }
-               else if (self.health <= 50)
+               else if (this.health <= 50)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_5);
                }
-               else if (self.health <= 60)
+               else if (this.health <= 60)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_6);
                }
-               else if (self.health <= 70)
+               else if (this.health <= 70)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_7);
                }
-               else if (self.health <= 80)
+               else if (this.health <= 80)
                {
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_8);
                }
-               else if (self.health <= 90)
+               else if (this.health <= 90)
                {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
-                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_9);
                }
                else
                {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
-                       Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
+                       Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
                }
        }
-       self.instagib_nextthink = time + 1;
+       this.instagib_nextthink = time + 1;
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
@@ -180,8 +180,8 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPreThink)
-{
-       instagib_ammocheck();
+{SELFPARAM();
+       instagib_ammocheck(self);
        return false;
 }
 
@@ -457,11 +457,11 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, OnEntityPreSpawn)
 
        float r = random();
        if (r < 0.3)
-               e.think = instagib_invisibility;
+               setthink(e, instagib_invisibility);
        else if (r < 0.6)
-               e.think = instagib_extralife;
+               setthink(e, instagib_extralife);
        else
-               e.think = instagib_speed;
+               setthink(e, instagib_speed);
 
        e.nextthink = time + 0.1;
        e.spawnflags = self.spawnflags;
index cabfd31b816ec03e53e3eae5c8f94e0bf840aa2f..4e339cea0ed3397acbe476a9f55742a84a0313f0 100644 (file)
@@ -84,7 +84,7 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
        }
        self.colormod = nade_type.m_color;
        self.move_movetype = MOVETYPE_BOUNCE;
-       self.move_touch = func_null;
+       settouch(self, func_null);
        self.scale = 1.5;
        self.avelocity = randomvec() * 720;
 
@@ -147,12 +147,12 @@ REGISTER_MUTATOR(nades, cvar("g_nades"));
 
 .entity nade_spawnloc;
 
-void nade_timer_think()
-{SELFPARAM();
-       self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
-       self.nextthink = time;
-       if(!self.owner || wasfreed(self.owner))
-               remove(self);
+void nade_timer_think(entity this)
+{
+       this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
+       this.nextthink = time;
+       if(!this.owner || wasfreed(this.owner))
+               remove(this);
 }
 
 void nade_burn_spawn(entity _nade)
@@ -167,7 +167,7 @@ void nade_spawn(entity _nade)
        setattachment(timer, _nade, "");
        timer.colormap = _nade.colormap;
        timer.glowmod = _nade.glowmod;
-       timer.think = nade_timer_think;
+       setthink(timer, nade_timer_think);
        timer.nextthink = time;
        timer.wait = _nade.wait;
        timer.owner = _nade;
@@ -178,8 +178,8 @@ void nade_spawn(entity _nade)
        CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
 }
 
-void napalm_damage(float dist, float damage, float edgedamage, float burntime)
-{SELFPARAM();
+void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
+{
        entity e;
        float d;
        vector p;
@@ -188,17 +188,17 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime)
                return;
 
        RandomSelection_Init();
-       for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
+       for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
                if(e.takedamage == DAMAGE_AIM)
-               if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
-               if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
+               if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
+               if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
                if(!STAT(FROZEN, e))
                {
                        p = e.origin;
                        p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
                        p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
                        p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
-                       d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
+                       d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
                        if(d < dist)
                        {
                                e.fireball_impactvec = p;
@@ -207,59 +207,59 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime)
                }
        if(RandomSelection_chosen_ent)
        {
-               d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
+               d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
                d = damage + (edgedamage - damage) * (d / dist);
-               Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
-               //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
-               Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
+               Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
+               //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
+               Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
        }
 }
 
 
-void napalm_ball_think()
-{SELFPARAM();
+void napalm_ball_think(entity this)
+{
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       if(time > self.pushltime)
+       if(time > this.pushltime)
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       vector midpoint = ((self.absmin + self.absmax) * 0.5);
+       vector midpoint = ((this.absmin + this.absmax) * 0.5);
        if(pointcontents(midpoint) == CONTENT_WATER)
        {
-               self.velocity = self.velocity * 0.5;
+               this.velocity = this.velocity * 0.5;
 
                if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
-                       { self.velocity_z = 200; }
+                       { this.velocity_z = 200; }
        }
 
-       self.angles = vectoangles(self.velocity);
+       this.angles = vectoangles(this.velocity);
 
-       napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
+       napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
                                  autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
 
-       self.nextthink = time + 0.1;
+       this.nextthink = time + 0.1;
 }
 
 
-void nade_napalm_ball()
-{SELFPARAM();
+void nade_napalm_ball(entity this)
+{
        entity proj;
        vector kick;
 
-       spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
+       spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
 
        proj = new(grenade);
-       proj.owner = self.owner;
-       proj.realowner = self.realowner;
-       proj.team = self.owner.team;
+       proj.owner = this.owner;
+       proj.realowner = this.realowner;
+       proj.team = this.owner.team;
        proj.bot_dodge = true;
        proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
        proj.movetype = MOVETYPE_BOUNCE;
@@ -268,8 +268,8 @@ void nade_napalm_ball()
        setmodel(proj, MDL_Null);
        proj.scale = 1;//0.5;
        setsize(proj, '-4 -4 -4', '4 4 4');
-       setorigin(proj, self.origin);
-       proj.think = napalm_ball_think;
+       setorigin(proj, this.origin);
+       setthink(proj, napalm_ball_think);
        proj.nextthink = time;
        proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
        proj.effects = EF_LOWPRECISION | EF_FLAME;
@@ -289,50 +289,50 @@ void nade_napalm_ball()
 }
 
 
-void napalm_fountain_think()
-{SELFPARAM();
+void napalm_fountain_think(entity this)
+{
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       if(time >= self.ltime)
+       if(time >= this.ltime)
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       vector midpoint = ((self.absmin + self.absmax) * 0.5);
+       vector midpoint = ((this.absmin + this.absmax) * 0.5);
        if(pointcontents(midpoint) == CONTENT_WATER)
        {
-               self.velocity = self.velocity * 0.5;
+               this.velocity = this.velocity * 0.5;
 
                if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
-                       { self.velocity_z = 200; }
+                       { this.velocity_z = 200; }
 
-               UpdateCSQCProjectile(self);
+               UpdateCSQCProjectile(this);
        }
 
-       napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
+       napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
                autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
 
-       self.nextthink = time + 0.1;
-       if(time >= self.nade_special_time)
+       this.nextthink = time + 0.1;
+       if(time >= this.nade_special_time)
        {
-               self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
-               nade_napalm_ball();
+               this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
+               nade_napalm_ball(this);
        }
 }
 
-void nade_napalm_boom()
-{SELFPARAM();
+void nade_napalm_boom(entity this)
+{
        entity fountain;
        int c;
        for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
-               nade_napalm_ball();
+               nade_napalm_ball(this);
 
 
        fountain = spawn();
@@ -340,7 +340,7 @@ void nade_napalm_boom()
        fountain.realowner = self.realowner;
        fountain.origin = self.origin;
        setorigin(fountain, fountain.origin);
-       fountain.think = napalm_fountain_think;
+       setthink(fountain, napalm_fountain_think);
        fountain.nextthink = time;
        fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
        fountain.pushltime = fountain.ltime;
@@ -363,8 +363,8 @@ void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
        Drop_Special_Items(frost_target);
 }
 
-void nade_ice_think()
-{SELFPARAM();
+void nade_ice_think(entity this)
+{
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
@@ -428,25 +428,25 @@ void nade_ice_think()
                nade_ice_freeze(self, e, current_freeze_time);
 }
 
-void nade_ice_boom()
-{SELFPARAM();
+void nade_ice_boom(entity this)
+{
        entity fountain;
        fountain = spawn();
-       fountain.owner = self.owner;
-       fountain.realowner = self.realowner;
-       fountain.origin = self.origin;
+       fountain.owner = this.owner;
+       fountain.realowner = this.realowner;
+       fountain.origin = this.origin;
        setorigin(fountain, fountain.origin);
-       fountain.think = nade_ice_think;
+       setthink(fountain, nade_ice_think);
        fountain.nextthink = time;
        fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
        fountain.pushltime = fountain.wait = fountain.ltime;
-       fountain.team = self.team;
+       fountain.team = this.team;
        fountain.movetype = MOVETYPE_TOSS;
        fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
        fountain.bot_dodge = false;
        setsize(fountain, '-16 -16 -16', '16 16 16');
        fountain.nade_special_time = time+0.3;
-       fountain.angles = self.angles;
+       fountain.angles = this.angles;
 
        if ( autocvar_g_nades_ice_explode )
        {
@@ -454,9 +454,9 @@ void nade_ice_boom()
                entity timer = new(nade_timer);
                setmodel(timer, MDL_NADE_TIMER);
                setattachment(timer, fountain, "");
-               timer.colormap = self.colormap;
-               timer.glowmod = self.glowmod;
-               timer.think = nade_timer_think;
+               timer.colormap = this.colormap;
+               timer.glowmod = this.glowmod;
+               setthink(timer, nade_timer_think);
                timer.nextthink = time;
                timer.wait = fountain.ltime;
                timer.owner = fountain;
@@ -466,44 +466,44 @@ void nade_ice_boom()
                setmodel(fountain, MDL_Null);
 }
 
-void nade_translocate_boom()
-{SELFPARAM();
-       if(self.realowner.vehicle)
+void nade_translocate_boom(entity this)
+{
+       if(this.realowner.vehicle)
                return;
 
-       vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
-       tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
+       vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
+       tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
        locout = trace_endpos;
 
-       makevectors(self.realowner.angles);
+       makevectors(this.realowner.angles);
 
-       MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
+       MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
 
-       TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+       TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
 }
 
-void nade_spawn_boom()
-{SELFPARAM();
+void nade_spawn_boom(entity this)
+{
        entity spawnloc = spawn();
-       setorigin(spawnloc, self.origin);
-       setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
+       setorigin(spawnloc, this.origin);
+       setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
        spawnloc.movetype = MOVETYPE_NONE;
        spawnloc.solid = SOLID_NOT;
-       spawnloc.drawonlytoclient = self.realowner;
+       spawnloc.drawonlytoclient = this.realowner;
        spawnloc.effects = EF_STARDUST;
        spawnloc.cnt = autocvar_g_nades_spawn_count;
 
-       if(self.realowner.nade_spawnloc)
+       if(this.realowner.nade_spawnloc)
        {
-               remove(self.realowner.nade_spawnloc);
-               self.realowner.nade_spawnloc = world;
+               remove(this.realowner.nade_spawnloc);
+               this.realowner.nade_spawnloc = world;
        }
 
-       self.realowner.nade_spawnloc = spawnloc;
+       this.realowner.nade_spawnloc = spawnloc;
 }
 
-void nade_heal_think()
-{SELFPARAM();
+void nade_heal_think(entity this)
+{
        if(time >= self.ltime)
        {
                remove(self);
@@ -521,8 +521,8 @@ void nade_heal_think()
                self.nade_show_particles = 0;
 }
 
-void nade_heal_touch()
-{SELFPARAM();
+void nade_heal_touch(entity this)
+{
        float maxhealth;
        float health_factor;
        if(IS_PLAYER(other) || IS_MONSTER(other))
@@ -563,19 +563,19 @@ void nade_heal_touch()
        }
 }
 
-void nade_heal_boom()
-{SELFPARAM();
+void nade_heal_boom(entity this)
+{
        entity healer;
        healer = spawn();
-       healer.owner = self.owner;
-       healer.realowner = self.realowner;
-       setorigin(healer, self.origin);
+       healer.owner = this.owner;
+       healer.realowner = this.realowner;
+       setorigin(healer, this.origin);
        healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
        healer.ltime = time + healer.healer_lifetime;
-       healer.team = self.realowner.team;
+       healer.team = this.realowner.team;
        healer.bot_dodge = false;
        healer.solid = SOLID_TRIGGER;
-       healer.touch = nade_heal_touch;
+       settouch(healer, nade_heal_touch);
 
        setmodel(healer, MDL_NADE_HEAL);
        healer.healer_radius = autocvar_g_nades_nade_radius;
@@ -584,26 +584,26 @@ void nade_heal_boom()
 
        Net_LinkEntity(healer, true, 0, healer_send);
 
-       healer.think = nade_heal_think;
+       setthink(healer, nade_heal_think);
        healer.nextthink = time;
        healer.SendFlags |= 1;
 }
 
-void nade_monster_boom()
-{SELFPARAM();
-       entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
+void nade_monster_boom(entity this)
+{
+       entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
 
        if(autocvar_g_nades_pokenade_monster_lifetime > 0)
                e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
        e.monster_skill = MONSTER_SKILL_INSANE;
 }
 
-void nade_boom()
-{SELFPARAM();
+void nade_boom(entity this)
+{
        entity expef = NULL;
        bool nade_blast = true;
 
-       switch ( Nades_from(self.nade_type) )
+       switch ( Nades_from(this.nade_type) )
        {
                case NADE_TYPE_NAPALM:
                        nade_blast = autocvar_g_nades_napalm_blast;
@@ -619,7 +619,7 @@ void nade_boom()
                case NADE_TYPE_MONSTER:
                case NADE_TYPE_SPAWN:
                        nade_blast = false;
-                       switch(self.realowner.team)
+                       switch(this.realowner.team)
                        {
                                case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
                                case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
@@ -635,43 +635,43 @@ void nade_boom()
 
                default:
                case NADE_TYPE_NORMAL:
-                       expef = EFFECT_NADE_EXPLODE(self.realowner.team);
+                       expef = EFFECT_NADE_EXPLODE(this.realowner.team);
                        break;
        }
 
        if(expef)
-               Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1);
+               Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
 
-       sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
-       sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
-       self.event_damage = func_null; // prevent somehow calling damage in the next call
+       this.event_damage = func_null; // prevent somehow calling damage in the next call
 
        if(nade_blast)
        {
-               RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
-                                autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
-               Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
+               RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
+                                autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
+               Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
        }
 
-       if(self.takedamage)
-       switch ( Nades_from(self.nade_type) )
+       if(this.takedamage)
+       switch ( Nades_from(this.nade_type) )
        {
-               case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
-               case NADE_TYPE_ICE: nade_ice_boom(); break;
-               case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
-               case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
-               case NADE_TYPE_HEAL: nade_heal_boom(); break;
-               case NADE_TYPE_MONSTER: nade_monster_boom(); break;
+               case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
+               case NADE_TYPE_ICE: nade_ice_boom(this); break;
+               case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
+               case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
+               case NADE_TYPE_HEAL: nade_heal_boom(this); break;
+               case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
        }
 
-       FOREACH_ENTITY_ENT(aiment, self,
+       FOREACH_ENTITY_ENT(aiment, this,
        {
                if(it.classname == "grapplinghook")
                        RemoveGrapplingHook(it.realowner);
        });
 
-       remove(self);
+       remove(this);
 }
 
 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
@@ -688,8 +688,8 @@ void nade_pickup(entity this, entity thenade)
 }
 
 bool CanThrowNade(entity this);
-void nade_touch()
-{SELFPARAM();
+void nade_touch(entity this)
+{
        if(other)
                UpdateCSQCProjectile(self);
 
@@ -724,7 +724,7 @@ void nade_touch()
                return;
        }
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        //setsize(self, '-2 -2 -2', '2 2 2');
        //UpdateCSQCProjectile(self);
@@ -735,14 +735,14 @@ void nade_touch()
        }
 
        self.enemy = other;
-       nade_boom();
+       nade_boom(self);
 }
 
-void nade_beep()
-{SELFPARAM();
-       sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
-       self.think = nade_boom;
-       self.nextthink = max(self.wait, time);
+void nade_beep(entity this)
+{
+       sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+       setthink(this, nade_boom);
+       this.nextthink = max(this.wait, time);
 }
 
 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -750,7 +750,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
                this.takedamage = DAMAGE_NO;
-               WITHSELF(this, nade_boom());
+               WITHSELF(this, nade_boom(this));
                return;
        }
 
@@ -796,7 +796,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i
        {
                sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
                this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
-               this.think = nade_beep;
+               setthink(this, nade_beep);
        }
 
        this.health -= damage;
@@ -859,7 +859,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
        if(set_owner)
                _nade.realowner = e;
 
-       _nade.touch = nade_touch;
+       settouch(_nade, nade_touch);
        _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
        _nade.health = autocvar_g_nades_nade_health;
        _nade.max_health = _nade.health;
@@ -888,7 +888,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
 
        if(_time)
        {
-               _nade.think = nade_boom;
+               setthink(_nade, nade_boom);
                _nade.nextthink = _time;
        }
 
@@ -970,7 +970,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        n.glowmod = player.glowmod;
        n.wait = time + max(0, ntime);
        n.nade_time_primed = time;
-       n.think = nade_beep;
+       setthink(n, nade_beep);
        n.nextthink = max(n.wait - 3, time);
        n.projectiledeathtype = DEATH_NADE.m_id;
 
@@ -981,7 +981,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        fn.colormod = Nades_from(n.nade_type).m_color;
        fn.colormap = player.colormap;
        fn.glowmod = player.glowmod;
-       fn.think = SUB_Remove_self;
+       setthink(fn, SUB_Remove);
        fn.nextthink = n.wait;
 
        player.nade = n;
index 0b6908a8b31ed512f35330ea13c85110cf712b0b..e51003204c54e0a949dfde20d580fa1fcadf1845 100644 (file)
@@ -160,7 +160,7 @@ void NIX_GiveCurrentWeapon()
                else
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
 
-               e.wr_resetplayer(e);
+               e.wr_resetplayer(e, self);
 
                // all weapons must be fully loaded when we spawn
                if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
@@ -209,7 +209,7 @@ void NIX_GiveCurrentWeapon()
                if(!client_hasweapon(self, PS(self).m_switchweapon, true, false))
                {
                        if(client_hasweapon(self, w, true, false))
-                               W_SwitchWeapon(w);
+                               W_SwitchWeapon(self, w);
                }
 }
 
index ec8061c3d2f764a5ff2bf0b6c7a3ea90e7ea7193..419123e10477d5e8983402f2e2a8f73dbe4499af 100644 (file)
@@ -64,7 +64,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
                return;
        }
 
-       if(!thiswep.wr_checkammo1(thiswep))
+       if(!thiswep.wr_checkammo1(thiswep, actor))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -89,7 +89,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
 
        Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       W_MachineGun_MuzzleFlash();
+       W_MachineGun_MuzzleFlash(actor);
        W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
 
        if (autocvar_g_casings >= 2) // casing code
@@ -100,9 +100,9 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto);
 }
 
-METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
+METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(vdist(self.origin - self.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 0.001, false);
     else
@@ -124,24 +124,22 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea
     }
 }
 
-METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+    float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
 
     if(autocvar_g_balance_hmg_reload_ammo)
-        ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+        ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
 
     return ammo_amount;
 }
 
-METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+    float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
 
     if(autocvar_g_balance_hmg_reload_ammo)
-        ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+        ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
 
     return ammo_amount;
 }
@@ -168,9 +166,9 @@ METHOD(HeavyMachineGun, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep))
+METHOD(HeavyMachineGun, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 2;
     pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
index 45a7e77f3d21a002470f2c2bb84721f4ecb8eec1..c670879e3788e9c8cceff9e3bff4a49614f15b4c 100644 (file)
@@ -267,8 +267,8 @@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
        return false;
 }
 
-void self_spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
-void self_spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
+void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
+void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
 
 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
 {SELFPARAM();
@@ -287,7 +287,7 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
                        wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
                        wep.pickup_anyway = true;
                        wep.spawnfunc_checked = true;
-                       wep.think = self_spawnfunc_weapon_hmg;
+                       setthink(wep, self_spawnfunc_weapon_hmg);
                        wep.nextthink = time + 0.1;
                        return true;
                }
@@ -304,7 +304,7 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
                        wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
                        wep.pickup_anyway = true;
                        wep.spawnfunc_checked = true;
-                       wep.think = self_spawnfunc_weapon_rpc;
+                       setthink(wep, self_spawnfunc_weapon_rpc);
                        wep.nextthink = time + 0.1;
                        return true;
                }
index 2d9d423cf5502bc1ff66a3ba5d7e7af7defd688e..b3b8f4248aef2f13070132af15e90dc39327e353 100644 (file)
@@ -50,8 +50,8 @@ REGISTER_WEAPON(RPC, rpc, NEW(RocketPropelledChainsaw));
 #ifdef SVQC
 spawnfunc(weapon_rpc) { weapon_defaultspawnfunc(this, WEP_RPC); }
 
-void W_RocketPropelledChainsaw_Explode()
-{SELFPARAM();
+void W_RocketPropelledChainsaw_Explode(entity this)
+{
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
 
@@ -60,13 +60,13 @@ void W_RocketPropelledChainsaw_Explode()
        remove (self);
 }
 
-void W_RocketPropelledChainsaw_Touch ()
-{SELFPARAM();
-       if(WarpZone_Projectile_Touch())
-               if(wasfreed(self))
+void W_RocketPropelledChainsaw_Touch (entity this)
+{
+       if(WarpZone_Projectile_Touch(this))
+               if(wasfreed(this))
                        return;
 
-       W_RocketPropelledChainsaw_Explode();
+       W_RocketPropelledChainsaw_Explode(this);
 }
 
 void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -83,8 +83,8 @@ void W_RocketPropelledChainsaw_Damage(entity this, entity inflictor, entity atta
                W_PrepareExplosionByDamage(this, attacker, W_RocketPropelledChainsaw_Explode);
 }
 
-void W_RocketPropelledChainsaw_Think()
-{SELFPARAM();
+void W_RocketPropelledChainsaw_Think(entity this)
+{
        if(self.cnt <= time)
        {
                remove(self);
@@ -132,9 +132,9 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
        setorigin (missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
        W_SetupProjVelocity_Basic(missile, WEP_CVAR(rpc, speed), 0);
 
-       missile.touch = W_RocketPropelledChainsaw_Touch;
+       settouch(missile, W_RocketPropelledChainsaw_Touch);
 
-       missile.think = W_RocketPropelledChainsaw_Think;
+       setthink(missile, W_RocketPropelledChainsaw_Think);
        missile.cnt = time + WEP_CVAR(rpc, lifetime);
        missile.nextthink = time;
        missile.flags = FL_PROJECTILE;
@@ -150,9 +150,9 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
-METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
 }
 
@@ -178,15 +178,14 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en
     }
 }
 
-METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
-    ammo_amount += self.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
+    ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
     return ammo_amount;
 }
 
-METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
 {
     return false;
 }
@@ -219,9 +218,9 @@ METHOD(RocketPropelledChainsaw, wr_killmessage, Notification(entity thiswep))
 
 #ifdef CSQC
 
-METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 12;
     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
index aaad9d47be599b59c91a7c879014d0deb8dc6535..3ef52fec5abe6647a32806ba5844a71d43825c3e 100644 (file)
@@ -31,8 +31,8 @@ REGISTER_MUTATOR(physical_items, cvar("g_physical_items"))
 
 .vector spawn_origin, spawn_angles;
 
-void physical_item_think()
-{SELFPARAM();
+void physical_item_think(entity this)
+{
        self.nextthink = time;
 
        self.alpha = self.owner.alpha; // apply fading and ghosting
@@ -68,8 +68,8 @@ void physical_item_think()
                remove(self); // the real item is gone, remove this
 }
 
-void physical_item_touch()
-{SELFPARAM();
+void physical_item_touch(entity this)
+{
        if(!self.cnt) // not for dropped items
        if (ITEM_TOUCH_NEEDKILL())
        {
@@ -116,9 +116,9 @@ MUTATOR_HOOKFUNCTION(physical_items, Item_Spawn)
        wep.dphitcontentsmask = self.dphitcontentsmask;
        wep.cnt = (self.owner != world);
 
-       wep.think = physical_item_think;
+       setthink(wep, physical_item_think);
        wep.nextthink = time;
-       wep.touch = physical_item_touch;
+       settouch(wep, physical_item_touch);
        wep.event_damage = physical_item_damage;
 
        if(!wep.cnt)
index 22ab9acae3d2193382a240a10c69556ae6d17d36..62dd19e4f07c09650591e074099f7efe815c1b26 100644 (file)
@@ -6,7 +6,7 @@ MUTATOR_HOOKFUNCTION(pinata, PlayerDies)
        FOREACH(Weapons, it != WEP_Null, LAMBDA(
                if(frag_target.weapons & WepSet_FromWeapon(it))
                if(PS(frag_target).m_switchweapon != it)
-               if(W_IsWeaponThrowable(it.m_id))
+               if(W_IsWeaponThrowable(frag_target, it.m_id))
                        W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325');
        ));
 
index 6391e1f8726b4f7ad17cf5d89d7007a65e0950da..b3e9ea15a94c1bd9bf3f39b2473694d577c42006 100644 (file)
@@ -46,8 +46,8 @@ float object_count;
 .string material;
 
 .float touch_timer;
-void sandbox_ObjectFunction_Touch()
-{SELFPARAM();
+void sandbox_ObjectFunction_Touch(entity this)
+{
        // apply material impact effects
 
        if(!self.material)
@@ -71,8 +71,8 @@ void sandbox_ObjectFunction_Touch()
        Send_Effect_(strcat("impact_", self.material), self.origin, '0 0 0', ceil(intensity * 10)); // allow a count from 1 to 10
 }
 
-void sandbox_ObjectFunction_Think()
-{SELFPARAM();
+void sandbox_ObjectFunction_Think(entity this)
+{
        // decide if and how this object can be grabbed
        if(autocvar_g_sandbox_readonly)
                self.grab = 0; // no grabbing
@@ -187,8 +187,8 @@ entity sandbox_ObjectSpawn(float database)
        e.frame = 0;
        e.skin = 0;
        e.material = string_null;
-       e.touch = sandbox_ObjectFunction_Touch;
-       e.think = sandbox_ObjectFunction_Think;
+       settouch(e, sandbox_ObjectFunction_Touch);
+       setthink(e, sandbox_ObjectFunction_Think);
        e.nextthink = time;
        //e.effects |= EF_SELECTABLE; // don't do this all the time, maybe just when editing objects?
 
index 5471bcbae06fac3e3e8422442d61f98136ffa908..142f9d9ba54dce3d379993b0cbfc794336435896 100644 (file)
@@ -104,50 +104,45 @@ MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
        FOREACH_CLIENT(true, LAMBDA(
                if(!IS_SPEC(it) && !IS_OBSERVER(it))
                        continue;
-               setself(it);
-               if(self.superspec_flags & SSF_ITEMMSG)
-                       if(superspec_filteritem(self, _item))
+               if(it.superspec_flags & SSF_ITEMMSG)
+                       if(superspec_filteritem(it, _item))
                        {
-                               if(self.superspec_flags & SSF_VERBOSE)
-                                       superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
+                               if(it.superspec_flags & SSF_VERBOSE)
+                                       superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
                                else
-                                       superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
-                               if((self.autospec_flags & ASF_SSIM) && self.enemy != other)
+                                       superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
+                               if((it.autospec_flags & ASF_SSIM) && it.enemy != other)
                                {
-                                       superspec_Spectate(other);
-
-                                       setself(this);
+                                       WITHSELF(it, superspec_Spectate(other));
                                        return MUT_ITEMTOUCH_CONTINUE;
                                }
                        }
 
-               if((self.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
-                       (self.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
-                       (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
-                       (self.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
-                       (self.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
+               if((it.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
+                       (it.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
+                       (it.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
+                       (it.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
+                       (it.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
                {
 
-                       if((self.enemy != other) || IS_OBSERVER(self))
+                       if((it.enemy != other) || IS_OBSERVER(it))
                        {
-                               if(self.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(self))
+                               if(it.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(it))
                                {
-                                       if(self.superspec_flags & SSF_VERBOSE)
-                                               superspec_msg("", "", self, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
+                                       if(it.superspec_flags & SSF_VERBOSE)
+                                               superspec_msg("", "", it, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
                                }
                                else
                                {
-                                       if(self.autospec_flags & ASF_SHOWWHAT)
-                                               superspec_msg("", "", self, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
+                                       if(it.autospec_flags & ASF_SHOWWHAT)
+                                               superspec_msg("", "", it, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
 
-                                       superspec_Spectate(other);
+                                       WITHSELF(it, superspec_Spectate(other));
                                }
                        }
                }
        ));
 
-       setself(this);
-
        return MUT_ITEMTOUCH_CONTINUE;
 }
 
@@ -382,8 +377,8 @@ MUTATOR_HOOKFUNCTION(superspec, BuildMutatorsPrettyString)
        return 0;
 }
 
-void superspec_hello()
-{SELFPARAM();
+void superspec_hello(entity this)
+{
        if(self.enemy.crypto_idfp == "")
                Send_Notification(NOTIF_ONE_ONLY, self.enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
 
@@ -403,7 +398,7 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
 
        entity _hello = spawn();
        _hello.enemy = self;
-       _hello.think = superspec_hello;
+       setthink(_hello, superspec_hello);
        _hello.nextthink = time + 5;
 
        if (!_ISLOCAL)
@@ -440,19 +435,16 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
 
 MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 {
-    SELFPARAM();
        FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
-               setself(it);
-               if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == frag_target)
+               if(it.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && it.enemy == frag_target)
                {
-                       if(self.autospec_flags & ASF_SHOWWHAT)
-                               superspec_msg("", "", self, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
+                       if(it.autospec_flags & ASF_SHOWWHAT)
+                               superspec_msg("", "", it, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
 
-                       superspec_Spectate(frag_attacker);
+                       WITHSELF(it, superspec_Spectate(frag_attacker));
                }
        ));
 
-       setself(frag_target);
        return false;
 }
 
index d391c73fb18c7aa86b44603d77c3ad1e89d05d17..3e82db0b5070220b590070aaf8b8ea823333e5b4 100644 (file)
@@ -14,29 +14,29 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 
     sendflags = sendflags & 0x7F;
 
-    if (self.max_health || (self.pain_finished && (time < self.pain_finished + 0.25)))
+    if (this.max_health || (this.pain_finished && (time < this.pain_finished + 0.25)))
         sendflags |= 0x80;
 
     int f = 0;
-    if(self.currentammo)
+    if(this.currentammo)
         f |= 1; // hideable
-    if(self.exteriormodeltoclient == to)
+    if(this.exteriormodeltoclient == to)
         f |= 2; // my own
 
     MUTATOR_CALLHOOK(SendWaypoint, this, to, sendflags, f);
 
     WriteByte(MSG_ENTITY, sendflags);
-    WriteByte(MSG_ENTITY, self.wp_extra);
+    WriteByte(MSG_ENTITY, this.wp_extra);
 
     if (sendflags & 0x80)
     {
-        if (self.max_health)
+        if (this.max_health)
         {
-            WriteByte(MSG_ENTITY, (self.health / self.max_health) * 191.0);
+            WriteByte(MSG_ENTITY, (this.health / this.max_health) * 191.0);
         }
         else
         {
-            float dt = self.pain_finished - time;
+            float dt = this.pain_finished - time;
             dt = bound(0, dt * 32, 16383);
             WriteByte(MSG_ENTITY, (dt & 0xFF00) / 256 + 192);
             WriteByte(MSG_ENTITY, (dt & 0x00FF));
@@ -45,44 +45,44 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 
     if (sendflags & 64)
     {
-        WriteCoord(MSG_ENTITY, self.origin.x);
-        WriteCoord(MSG_ENTITY, self.origin.y);
-        WriteCoord(MSG_ENTITY, self.origin.z);
+        WriteCoord(MSG_ENTITY, this.origin.x);
+        WriteCoord(MSG_ENTITY, this.origin.y);
+        WriteCoord(MSG_ENTITY, this.origin.z);
     }
 
     if (sendflags & 1)
     {
-        WriteByte(MSG_ENTITY, self.team);
-        WriteByte(MSG_ENTITY, self.rule);
+        WriteByte(MSG_ENTITY, this.team);
+        WriteByte(MSG_ENTITY, this.rule);
     }
 
     if (sendflags & 2)
-        WriteString(MSG_ENTITY, self.model1);
+        WriteString(MSG_ENTITY, this.model1);
 
     if (sendflags & 4)
-        WriteString(MSG_ENTITY, self.model2);
+        WriteString(MSG_ENTITY, this.model2);
 
     if (sendflags & 8)
-        WriteString(MSG_ENTITY, self.model3);
+        WriteString(MSG_ENTITY, this.model3);
 
     if (sendflags & 16)
     {
-        WriteCoord(MSG_ENTITY, self.fade_time);
-        WriteCoord(MSG_ENTITY, self.teleport_time);
-        WriteShort(MSG_ENTITY, self.fade_rate); // maxdist
+        WriteCoord(MSG_ENTITY, this.fade_time);
+        WriteCoord(MSG_ENTITY, this.teleport_time);
+        WriteShort(MSG_ENTITY, this.fade_rate); // maxdist
         WriteByte(MSG_ENTITY, f);
     }
 
     if (sendflags & 32)
     {
-        WriteByte(MSG_ENTITY, self.cnt); // icon on radar
-        WriteByte(MSG_ENTITY, self.colormod.x * 255.0);
-        WriteByte(MSG_ENTITY, self.colormod.y * 255.0);
-        WriteByte(MSG_ENTITY, self.colormod.z * 255.0);
+        WriteByte(MSG_ENTITY, this.cnt); // icon on radar
+        WriteByte(MSG_ENTITY, this.colormod.x * 255.0);
+        WriteByte(MSG_ENTITY, this.colormod.y * 255.0);
+        WriteByte(MSG_ENTITY, this.colormod.z * 255.0);
 
-        if (WaypointSprite_isteammate(self.owner, WaypointSprite_getviewentity(to)))
+        if (WaypointSprite_isteammate(this.owner, WaypointSprite_getviewentity(to)))
         {
-            float dt = (self.waypointsprite_helpmetime - time) / 0.1;
+            float dt = (this.waypointsprite_helpmetime - time) / 0.1;
             if (dt < 0)
                 dt = 0;
             if (dt > 255)
@@ -903,8 +903,8 @@ void WaypointSprite_Disown(entity wp, float fadetime)
     }
 }
 
-void WaypointSprite_Think()
-{SELFPARAM();
+void WaypointSprite_Think(entity this)
+{
     bool doremove = false;
 
     if (self.fade_time && time >= self.teleport_time)
@@ -921,25 +921,25 @@ void WaypointSprite_Think()
         self.nextthink = time; // WHY?!?
 }
 
-float WaypointSprite_visible_for_player(entity e)
-{SELFPARAM();
+bool WaypointSprite_visible_for_player(entity this, entity player, entity view)
+{
     // personal waypoints
-    if (self.enemy && self.enemy != e)
+    if (this.enemy && this.enemy != view)
         return false;
 
     // team waypoints
-    if (self.rule == SPRITERULE_SPECTATOR)
+    if (this.rule == SPRITERULE_SPECTATOR)
     {
         if (!autocvar_sv_itemstime)
             return false;
-        if (!warmup_stage && IS_PLAYER(e))
+        if (!warmup_stage && IS_PLAYER(view))
             return false;
     }
-    else if (self.team && self.rule == SPRITERULE_DEFAULT)
+    else if (this.team && this.rule == SPRITERULE_DEFAULT)
     {
-        if (self.team != e.team)
+        if (this.team != view.team)
             return false;
-        if (!IS_PLAYER(e))
+        if (!IS_PLAYER(view))
             return false;
     }
 
@@ -973,7 +973,7 @@ float WaypointSprite_Customize()
     if (MUTATOR_CALLHOOK(CustomizeWaypoint, self, other))
         return false;
 
-    return self.waypointsprite_visible_for_player(e);
+    return self.waypointsprite_visible_for_player(self, other, e);
 }
 
 bool WaypointSprite_SendEntity(entity this, entity to, float sendflags);
@@ -1019,7 +1019,7 @@ entity WaypointSprite_Spawn(
         wp.owned_by_field = ownfield;
     }
     wp.fade_rate = maxdistance;
-    wp.think = WaypointSprite_Think;
+    setthink(wp, WaypointSprite_Think);
     wp.nextthink = time;
     wp.model1 = spr.netname;
     wp.customizeentityforclient = WaypointSprite_Customize;
index 843a88d4502430dac3e536e9d5ee4b2839ea4b39..385d9fa749653c59048c3dcf7c2f78991a8a5de6 100644 (file)
@@ -128,7 +128,7 @@ float autocvar_sv_waypointsprite_limitedrange;
 .string model2;
 .string model3;
 
-.float(entity) waypointsprite_visible_for_player;
+.bool(entity, entity, entity) waypointsprite_visible_for_player;
 
 void WaypointSprite_UpdateSprites(entity e, entity m1, entity m2, entity m3);
 
@@ -160,9 +160,9 @@ void WaypointSprite_Kill(entity wp);
 
 void WaypointSprite_Disown(entity wp, float fadetime);
 
-void WaypointSprite_Think();
+void WaypointSprite_Think(entity this);
 
-float WaypointSprite_visible_for_player(entity e);
+bool WaypointSprite_visible_for_player(entity this, entity player, entity view);
 
 entity WaypointSprite_getviewentity(entity e);
 
index 267bd9e66d966b0ae5b586b00d6ab815c8d8c262..3d3c786297c43cb283cd39f43449b4611c98de7b 100644 (file)
@@ -1478,9 +1478,8 @@ NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new)
 #endif
 
 #ifdef SVQC
-void Net_Notification_Remove()
+void Net_Notification_Remove(entity this)
 {
-       SELFPARAM();
        #ifdef NOTIFICATIONS_DEBUG
        Debug_Notification(sprintf(
                "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
@@ -1697,7 +1696,7 @@ void Send_Notification(
                        net_notif.nent_floats[i] = ...((net_notif.nent_stringcount + i), float);
                }
 
-               net_notif.think = Net_Notification_Remove;
+               setthink(net_notif, Net_Notification_Remove);
                net_notif.nextthink = (time > autocvar_notification_lifetime_mapload)
                        ? (time + autocvar_notification_lifetime_runtime)
                        : autocvar_notification_lifetime_mapload;
index a27b8666eedf0a716c4f5743dd844bdfd2593c76..cfdcbfd14700262db5e3911b95c83107e4427c45 100644 (file)
@@ -5,23 +5,23 @@
 
 /**
     Simulate drag
-    self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
+    this.velocity = movelib_dragvec(this.velocity,0.02,0.5);
 **/
-vector movelib_dragvec(float drag, float exp_)
-{SELFPARAM();
+vector movelib_dragvec(entity this, float drag, float exp_)
+{
     float lspeed,ldrag;
 
-    lspeed = vlen(self.velocity);
+    lspeed = vlen(this.velocity);
     ldrag = lspeed * drag;
     ldrag = ldrag * (drag * exp_);
     ldrag = 1 - (ldrag / lspeed);
 
-    return self.velocity * ldrag;
+    return this.velocity * ldrag;
 }
 
 /**
     Simulate drag
-    self.velocity *= movelib_dragflt(somespeed,0.01,0.7);
+    this.velocity *= movelib_dragflt(somespeed,0.01,0.7);
 **/
 float movelib_dragflt(float fspeed,float drag,float exp_)
 {
@@ -37,70 +37,70 @@ float movelib_dragflt(float fspeed,float drag,float exp_)
 /**
     Do a inertia simulation based on velocity.
     Basicaly, this allows you to simulate loss of steering with higher speed.
-    self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
+    this.velocity = movelib_inertmove_byspeed(this.velocity,newvel,1000,0.1,0.9);
 **/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)
-{SELFPARAM();
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max,float newmin,float oldmax)
+{
     float influense;
 
-    influense = vlen(self.velocity) * (1 / vel_max);
+    influense = vlen(this.velocity) * (1 / vel_max);
 
     influense = bound(newmin,influense,oldmax);
 
-    return (vel_new * (1 - influense)) + (self.velocity * influense);
+    return (vel_new * (1 - influense)) + (this.velocity * influense);
 }
 
-vector movelib_inertmove(vector new_vel,float new_bias)
-{SELFPARAM();
-    return new_vel * new_bias + self.velocity * (1-new_bias);
+vector movelib_inertmove(entity this, vector new_vel,float new_bias)
+{
+    return new_vel * new_bias + this.velocity * (1-new_bias);
 }
 
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce)
-{SELFPARAM();
+void movelib_move(entity this, vector force,float max_velocity,float drag,float theMass,float breakforce)
+{
     float deltatime;
     float acceleration;
     float mspeed;
     vector breakvec;
 
-    deltatime = time - self.movelib_lastupdate;
+    deltatime = time - this.movelib_lastupdate;
     if (deltatime > 0.15) deltatime = 0;
-    self.movelib_lastupdate = time;
+    this.movelib_lastupdate = time;
     if (!deltatime) return;
 
-    mspeed = vlen(self.velocity);
+    mspeed = vlen(this.velocity);
 
     if (theMass)
         acceleration = vlen(force) / theMass;
     else
         acceleration = vlen(force);
 
-    if (IS_ONGROUND(self))
+    if (IS_ONGROUND(this))
     {
         if (breakforce)
         {
-            breakvec = (normalize(self.velocity) * (breakforce / theMass) * deltatime);
-            self.velocity = self.velocity - breakvec;
+            breakvec = (normalize(this.velocity) * (breakforce / theMass) * deltatime);
+            this.velocity = this.velocity - breakvec;
         }
 
-        self.velocity = self.velocity + force * (acceleration * deltatime);
+        this.velocity = this.velocity + force * (acceleration * deltatime);
     }
 
     if (drag)
-        self.velocity = movelib_dragvec(drag, 1);
+        this.velocity = movelib_dragvec(this, drag, 1);
 
-    if (self.waterlevel > 1)
+    if (this.waterlevel > 1)
     {
-        self.velocity = self.velocity + force * (acceleration * deltatime);
-        self.velocity = self.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
+        this.velocity = this.velocity + force * (acceleration * deltatime);
+        this.velocity = this.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
     }
     else
-        self.velocity = self.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
+        this.velocity = this.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
 
-    mspeed = vlen(self.velocity);
+    mspeed = vlen(this.velocity);
 
     if (max_velocity)
         if (mspeed > max_velocity)
-            self.velocity = normalize(self.velocity) * (mspeed - 50);//* max_velocity;
+            this.velocity = normalize(this.velocity) * (mspeed - 50);//* max_velocity;
 }
 
 /*
@@ -112,17 +112,17 @@ void movelib_move(vector force,float max_velocity,float drag,float theMass,float
 .float buoyancy;
 float movelib_deltatime;
 
-void movelib_startupdate()
+void movelib_startupdate(entity this)
 {
-    movelib_deltatime = time - self.movelib_lastupdate;
+    movelib_deltatime = time - this.movelib_lastupdate;
 
     if (movelib_deltatime > 0.5)
         movelib_deltatime = 0;
 
-    self.movelib_lastupdate = time;
+    this.movelib_lastupdate = time;
 }
 
-void movelib_update(vector dir,float force)
+void movelib_update(entity this, vector dir,float force)
 {
     vector acceleration;
     float old_speed;
@@ -135,30 +135,30 @@ void movelib_update(vector dir,float force)
 
     if(!movelib_deltatime)
         return;
-    v_z = self.velocity_z;
-    old_speed    = vlen(self.velocity);
-    old_dir      = normalize(self.velocity);
+    v_z = this.velocity_z;
+    old_speed    = vlen(this.velocity);
+    old_dir      = normalize(this.velocity);
 
-    //ggravity      =  (autocvar_sv_gravity / self.mass) * '0 0 100';
-    acceleration =  (force / self.mass) * dir;
-    //acceleration -= old_dir * (old_speed / self.mass);
+    //ggravity      =  (autocvar_sv_gravity / this.mass) * '0 0 100';
+    acceleration =  (force / this.mass) * dir;
+    //acceleration -= old_dir * (old_speed / this.mass);
     acceleration -= ggravity;
 
-    if(self.waterlevel > 1)
+    if(this.waterlevel > 1)
     {
-        ffriction = self.water_friction;
-        acceleration += self.buoyancy * '0 0 1';
+        ffriction = this.water_friction;
+        acceleration += this.buoyancy * '0 0 1';
     }
     else
-        if(IS_ONGROUND(self))
-            ffriction = self.ground_friction;
+        if(IS_ONGROUND(this))
+            ffriction = this.ground_friction;
         else
-            ffriction = self.air_friction;
+            ffriction = this.air_friction;
 
     acceleration *= ffriction;
-    //self.velocity = self.velocity * (ffriction * movelib_deltatime);
-    self.velocity += acceleration * movelib_deltatime;
-    self.velocity_z = v_z;
+    //this.velocity = this.velocity * (ffriction * movelib_deltatime);
+    this.velocity += acceleration * movelib_deltatime;
+    this.velocity_z = v_z;
 
 }
 */
index 90ea4b4160e12d79ce24e4b00e60fc9582c424f0..a64651b30e092dd2939cb513bcab941744d0ba35 100644 (file)
@@ -8,7 +8,7 @@
     Simulate drag
     self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
 **/
-vector movelib_dragvec(float drag, float exp_);
+vector movelib_dragvec(entity this, float drag, float exp_);
 
 /**
     Simulate drag
@@ -21,12 +21,12 @@ float movelib_dragflt(float fspeed,float drag,float exp_);
     Basicaly, this allows you to simulate loss of steering with higher speed.
     self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
 **/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax);
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max, float newmin, float oldmax);
 
-vector movelib_inertmove(vector new_vel,float new_bias);
+vector movelib_inertmove(entity this, vector new_vel, float new_bias);
 
 .float  movelib_lastupdate;
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce);
+void movelib_move(entity this, vector force, float max_velocity, float drag, float theMass, float breakforce);
 
 /*
 void movelib_move_simple(vector newdir,float velo,float blendrate)
index 33c56216a5d71b8ad053f9c3a05236af65ae5509..ce7d04d1da29975b09c1c7db9cd9c8a92e746163 100644 (file)
@@ -317,20 +317,20 @@ void _Movetype_Impact(entity this, entity oth)  // SV_Impact
 {
        entity oldother = other;
 
-       if(this.move_touch)
+       if(gettouch(this))
        {
                other = oth;
 
-               WITHSELF(this, this.move_touch());
+               WITHSELF(this, gettouch(this)(this));
 
                other = oldother;
        }
 
-       if(oth.move_touch)
+       if(gettouch(oth))
        {
                other = this;
 
-               WITHSELF(oth, oth.move_touch());
+               WITHSELF(oth, gettouch(oth)(oth));
 
                other = oldother;
        }
@@ -346,7 +346,7 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
     FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
                if (it.solid == SOLID_TRIGGER && it != this)
                if (it.move_nomonsters != MOVE_NOMONSTERS && it.move_nomonsters != MOVE_WORLDONLY)
-               if (it.move_touch && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
+               if (gettouch(it) && boxesoverlap(it.absmin, it.absmax, this.absmin, this.absmax))
                {
                        other = this;
 
@@ -360,7 +360,7 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
                        trace_plane_dist = 0;
                        trace_ent = this;
 
-                       WITHSELF(it, it.move_touch());
+                       WITHSELF(it, gettouch(it)(it));
                }
     });
 
index ada026df9f93cdc5dc6f3613cb311c455031e97d..931a0630dbac126485cff3c1372c3fa8959aeb1a 100644 (file)
@@ -6,7 +6,7 @@
 #define UNSET_ONGROUND(s)                   ((s).flags &= ~FL_ONGROUND)
 
 .float move_ltime;
-.void()move_think;
+.void(entity this) move_think;
 .float move_nextthink;
 .void()move_blocked;
 
@@ -19,7 +19,6 @@
 .int move_flags;
 .int move_watertype;
 .int move_waterlevel;
-.void()move_touch;
 .void(float, float)contentstransition;
 .float move_bounce_factor;
 .float move_bounce_stopspeed;
index b3cfb875da28a318c6585bd1a91df2f8e1ff64ef..276b10476fff83e05b75b625ed4f0d73a46f6117 100644 (file)
@@ -149,6 +149,6 @@ void _Movetype_Physics_Pusher(entity this, float dt)  // SV_Physics_Pusher
                this.move_nextthink = 0;
                this.move_time = time;
                other = world;
-               WITHSELF(this, this.move_think());
+               WITHSELF(this, this.move_think(this));
        }
 }
index 41ada953d59a9a137a5a2144b3e53a68faee020d..e59dc306e3b37a4a96e23dc644e89348288994c2 100644 (file)
@@ -646,15 +646,15 @@ float racecar_angle(float forward, float down)
 
 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
 .float specialcommand_pos;
-void SpecialCommand()
+void SpecialCommand(entity this)
 {
 #ifdef SVQC
-       if (!CheatImpulse(CHIMPULSE_GIVE_ALL.impulse))
+       if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
                LOG_INFO("A hollow voice says \"Plugh\".\n");
 #endif
 }
 
-float PM_check_specialcommand(entity this, float buttons)
+bool PM_check_specialcommand(entity this, int buttons)
 {
 #ifdef SVQC
        string c;
@@ -681,7 +681,7 @@ float PM_check_specialcommand(entity this, float buttons)
                if (this.specialcommand_pos >= strlen(specialcommand))
                {
                        this.specialcommand_pos = 0;
-                       SpecialCommand();
+                       SpecialCommand(this);
                        return true;
                }
        }
index a462861f29b8401452b3c1d75becd2a4de24e555..90b2758aca3569e841d6cfa185ca2a556847bd2d 100644 (file)
@@ -76,7 +76,7 @@ const float VOL_BASEVOICE = 1.0;
                        auto = true; \
                        __chan = fabs(__chan); \
                        entity tmp = __e = new(csqc_autochannel); \
-                       tmp.think = SUB_Remove_self; \
+                       setthink(tmp, SUB_Remove); \
                        tmp.nextthink = time + soundlength(__samp); \
                } \
                vector old_origin = __e.origin; \
index 1d96923ed0fe314b643e8dd510421c5615b34476..0ffe55eb4fa50ba77a3c0c22ddb5c2b4defa2812 100644 (file)
@@ -59,7 +59,7 @@ void ClientState_attach(entity this)
 void bot_clientdisconnect(entity this);
 void W_HitPlotClose(entity this);
 void anticheat_report(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
 void entcs_detach(entity this);
 void accuracy_free(entity this);
 void ClientData_Detach(entity this);
@@ -76,9 +76,9 @@ void ClientState_detach(entity this)
 
     W_HitPlotClose(this);
     anticheat_report(this);
-    playerdemo_shutdown();
+    playerdemo_shutdown(this);
     entcs_detach(this);
-    accuracy_free(self);
+    accuracy_free(this);
     ClientData_Detach(this);
-    PlayerScore_Detach(self);
+    PlayerScore_Detach(this);
 }
index a3ac40b670010a39cfff08aea30f1c7c826b4037..656d829a93ee26b86bc1acb345db9257bee196a3 100644 (file)
@@ -152,134 +152,134 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
 
     if(sf & ISF_LOCATION)
     {
-        self.origin_x = ReadCoord();
-        self.origin_y = ReadCoord();
-        self.origin_z = ReadCoord();
-        setorigin(self, self.origin);
-        self.oldorigin = self.origin;
+        this.origin_x = ReadCoord();
+        this.origin_y = ReadCoord();
+        this.origin_z = ReadCoord();
+        setorigin(this, this.origin);
+        this.oldorigin = this.origin;
     }
 
     if(sf & ISF_ANGLES)
     {
-        self.angles_x = ReadAngle();
-        self.angles_y = ReadAngle();
-        self.angles_z = ReadAngle();
-        self.move_angles = self.angles;
+        this.angles_x = ReadAngle();
+        this.angles_y = ReadAngle();
+        this.angles_z = ReadAngle();
+        this.move_angles = this.angles;
     }
 
     if(sf & ISF_SIZE)
     {
         float use_bigsize = ReadByte();
-        setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
+        setsize(this, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
     }
 
     if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
     {
-        self.ItemStatus = ReadByte();
+        this.ItemStatus = ReadByte();
 
-        Item_SetAlpha(self);
+        Item_SetAlpha(this);
 
         if(autocvar_cl_fullbright_items)
-            if(self.ItemStatus & ITS_ALLOWFB)
-                self.effects |= EF_FULLBRIGHT;
+            if(this.ItemStatus & ITS_ALLOWFB)
+                this.effects |= EF_FULLBRIGHT;
 
-        if(self.ItemStatus & ITS_POWERUP)
+        if(this.ItemStatus & ITS_POWERUP)
         {
-            if(self.ItemStatus & ITS_AVAILABLE)
-                self.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
+            if(this.ItemStatus & ITS_AVAILABLE)
+                this.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
             else
-                 self.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
+                 this.effects &= ~(EF_ADDITIVE | EF_FULLBRIGHT);
         }
     }
 
     if(sf & ISF_MODEL)
     {
-        self.drawmask  = MASK_NORMAL;
-               self.move_movetype = MOVETYPE_TOSS;
-        self.draw       = ItemDraw;
-        self.solid = SOLID_TRIGGER;
-        //self.move_flags |= FL_ITEM;
+        this.drawmask  = MASK_NORMAL;
+               this.move_movetype = MOVETYPE_TOSS;
+        this.draw       = ItemDraw;
+        this.solid = SOLID_TRIGGER;
+        //this.move_flags |= FL_ITEM;
 
         bool use_bigsize = ReadByte();
 
-        self.fade_end = ReadShort();
-        self.fade_start = ReadShort();
-        if(self.fade_start && !autocvar_cl_items_nofade)
-               setpredraw(self, Item_PreDraw);
+        this.fade_end = ReadShort();
+        this.fade_start = ReadShort();
+        if(this.fade_start && !autocvar_cl_items_nofade)
+               setpredraw(this, Item_PreDraw);
 
-        if(self.mdl)
-            strunzone(self.mdl);
+        if(this.mdl)
+            strunzone(this.mdl);
 
-        self.mdl = "";
+        this.mdl = "";
         string _fn = ReadString();
 
-        if(autocvar_cl_simple_items && (self.ItemStatus & ITS_ALLOWSI))
+        if(autocvar_cl_simple_items && (this.ItemStatus & ITS_ALLOWSI))
         {
             string _fn2 = substring(_fn, 0 , strlen(_fn) -4);
-            self.draw = ItemDrawSimple;
+            this.draw = ItemDrawSimple;
 
             if(fexists(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
+                this.mdl = strzone(sprintf("%s%s.md3", _fn2, autocvar_cl_simpleitems_postfix));
             else if(fexists(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
+                this.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
             else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
+                this.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
             else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
+                this.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
             else
             {
-                self.draw = ItemDraw;
+                this.draw = ItemDraw;
                 LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
             }
         }
 
-        if(self.draw != ItemDrawSimple)
-            self.mdl = strzone(_fn);
+        if(this.draw != ItemDrawSimple)
+            this.mdl = strzone(_fn);
 
 
-        if(self.mdl == "")
-            LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, ", tell tZork about this!\n");
+        if(this.mdl == "")
+            LOG_TRACE("^1WARNING!^7 this.mdl is unset for item ", this.classname, ", tell tZork about this!\n");
 
-        precache_model(self.mdl);
-        _setmodel(self, self.mdl);
+        precache_model(this.mdl);
+        _setmodel(this, this.mdl);
 
-        setsize(self, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
+        setsize(this, '-16 -16 0', (use_bigsize) ? '16 16 48' : '16 16 32');
     }
 
     if(sf & ISF_COLORMAP)
-        self.colormap = ReadShort();
+        this.colormap = ReadShort();
 
     if(sf & ISF_DROP)
     {
-        self.gravity = 1;
-        self.pushable = true;
-        //self.move_angles = '0 0 0';
-        self.move_movetype = MOVETYPE_TOSS;
-        self.move_velocity_x = ReadCoord();
-        self.move_velocity_y = ReadCoord();
-        self.move_velocity_z = ReadCoord();
-        self.velocity = self.move_velocity;
-        self.move_origin = self.oldorigin;
-
-        if(!self.move_time)
+        this.gravity = 1;
+        this.pushable = true;
+        //this.move_angles = '0 0 0';
+        this.move_movetype = MOVETYPE_TOSS;
+        this.move_velocity_x = ReadCoord();
+        this.move_velocity_y = ReadCoord();
+        this.move_velocity_z = ReadCoord();
+        this.velocity = this.move_velocity;
+        this.move_origin = this.oldorigin;
+
+        if(!this.move_time)
         {
-            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(autocvar_cl_animate_items)
     {
-        if(self.ItemStatus & ITS_ANIMATE1)
-            self.move_avelocity = '0 180 0';
+        if(this.ItemStatus & ITS_ANIMATE1)
+            this.move_avelocity = '0 180 0';
 
-        if(self.ItemStatus & ITS_ANIMATE2)
-            self.move_avelocity = '0 -90 0';
+        if(this.ItemStatus & ITS_ANIMATE2)
+            this.move_avelocity = '0 -90 0';
     }
 
-    self.entremove = ItemRemove;
+    this.entremove = ItemRemove;
 
     return true;
 }
@@ -471,8 +471,8 @@ void Item_Show (entity e, float mode)
        e.SendFlags |= ISF_STATUS;
 }
 
-void Item_Think()
-{SELFPARAM();
+void Item_Think(entity this)
+{
        self.nextthink = time;
        if(self.origin != self.oldorigin)
                ItemUpdate(self);
@@ -484,8 +484,8 @@ float Item_ItemsTime_UpdateTime(entity e, float t);
 void Item_ItemsTime_SetTime(entity e, float t);
 void Item_ItemsTime_SetTimesForAllPlayers();
 
-void Item_Respawn ()
-{SELFPARAM();
+void Item_Respawn (entity this)
+{
        Item_Show(self, 1);
        // this is ugly...
        if(self.items == ITEM_Strength.m_itemid)
@@ -503,20 +503,20 @@ void Item_Respawn ()
                Item_ItemsTime_SetTimesForAllPlayers();
        }
 
-       self.think = Item_Think;
+       setthink(self, Item_Think);
        self.nextthink = time;
 
        //Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
        Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
 }
 
-void Item_RespawnCountdown ()
-{SELFPARAM();
+void Item_RespawnCountdown (entity this)
+{
        if(self.count >= ITEM_RESPAWN_TICKS)
        {
                if(self.waypointsprite_attached)
                        WaypointSprite_Kill(self.waypointsprite_attached);
-               Item_Respawn();
+               Item_Respawn(self);
        }
        else
        {
@@ -554,15 +554,13 @@ void Item_RespawnCountdown ()
 
                if(self.waypointsprite_attached)
                {
-                       setself(self.waypointsprite_attached);
                        FOREACH_CLIENT(IS_REAL_CLIENT(it), {
-                               if(self.waypointsprite_visible_for_player(it))
+                               if(self.waypointsprite_attached.waypointsprite_visible_for_player(self.waypointsprite_attached, it, it))
                                {
                                        msg_entity = it;
                                        soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM);    // play respawn sound
                                }
                        });
-                       setself(this);
 
                        WaypointSprite_Ping(self.waypointsprite_attached);
                        //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
@@ -570,14 +568,14 @@ void Item_RespawnCountdown ()
        }
 }
 
-void Item_RespawnThink()
-{SELFPARAM();
+void Item_RespawnThink(entity this)
+{
        self.nextthink = time;
        if(self.origin != self.oldorigin)
                ItemUpdate(self);
 
        if(time >= self.wait)
-               Item_Respawn();
+               Item_Respawn(self);
 }
 
 void Item_ScheduleRespawnIn(entity e, float t)
@@ -585,7 +583,7 @@ void Item_ScheduleRespawnIn(entity e, float t)
        // if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally
        if ((Item_ItemsTime_Allow(e.itemdef) || e.weapons & WEPSET_SUPERWEAPONS) && (t - ITEM_RESPAWN_TICKS) > 0)
        {
-               e.think = Item_RespawnCountdown;
+               setthink(e, Item_RespawnCountdown);
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
                e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
                e.count = 0;
@@ -595,7 +593,7 @@ void Item_ScheduleRespawnIn(entity e, float t)
        }
        else
        {
-               e.think = Item_RespawnThink;
+               setthink(e, Item_RespawnThink);
                e.nextthink = time;
                e.scheduledrespawntime = time + t;
                e.wait = time + t;
@@ -763,9 +761,8 @@ LABEL(skip)
        return 1;
 }
 
-void Item_Touch()
+void Item_Touch(entity this)
 {
-       SELFPARAM();
 
        // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
        if (this.classname == "droppedweapon")
@@ -851,7 +848,7 @@ void Item_Reset(entity this)
 
        if (this.classname != "droppedweapon")
        {
-               this.think = Item_Think;
+               setthink(this, Item_Think);
                this.nextthink = time;
 
                if (this.waypointsprite_attached)
@@ -861,7 +858,6 @@ void Item_Reset(entity this)
                        Item_ScheduleInitialRespawn(this);
        }
 }
-void Item_Reset_self() { SELFPARAM(); Item_Reset(this); }
 
 void Item_FindTeam(entity this)
 {
@@ -903,8 +899,8 @@ void Item_FindTeam(entity this)
 }
 
 // Savage: used for item garbage-collection
-void RemoveItem()
-{SELFPARAM();
+void RemoveItem(entity this)
+{
        if(wasfreed(self) || !self) { return; }
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
        remove(self);
@@ -1030,7 +1026,7 @@ float commodity_pickupevalfunc(entity player, entity item)
 void Item_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
-               WITHSELF(this, RemoveItem());
+               WITHSELF(this, RemoveItem(this));
 }
 
 void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter)
@@ -1084,7 +1080,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                this.movetype = MOVETYPE_TOSS;
 
                // Savage: remove thrown items after a certain period of time ("garbage collection")
-               this.think = RemoveItem;
+               setthink(this, RemoveItem);
                this.nextthink = time + 20;
 
                this.takedamage = DAMAGE_YES;
@@ -1184,7 +1180,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        this.bot_pickupbasevalue = pickupbasevalue;
        this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
        this.netname = itemname;
-       this.touch = Item_Touch;
+       settouch(this, Item_Touch);
        setmodel(this, MDL_Null); // precision set below
        //this.effects |= EF_LOWPRECISION;
 
@@ -1637,7 +1633,7 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
                e.(regenfield) = max(e.(regenfield), time + regentime);
 }
 float GiveItems(entity e, float beginarg, float endarg)
-{SELFPARAM();
+{
        float got, i, val, op;
        float _switchweapon;
        string cmd;
@@ -1799,7 +1795,7 @@ float GiveItems(entity e, float beginarg, float endarg)
        POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null);
 
        if(e.superweapons_finished <= 0)
-               if(self.weapons & WEPSET_SUPERWEAPONS)
+               if(e.weapons & WEPSET_SUPERWEAPONS)
                        e.superweapons_finished = autocvar_g_balance_superweapons_time;
 
        if(e.strength_finished <= 0)
index ce8307821ca11b0faea0811529e153eb2614661c..5ebc9d7e6234f4e8bd06d1233f0584a91946a254 100644 (file)
@@ -72,9 +72,9 @@ const float ITEM_RESPAWN_TICKS = 10;
 
 void Item_Show (entity e, float mode);
 
-void Item_Respawn ();
+void Item_Respawn (entity this);
 
-void Item_RespawnCountdown ();
+void Item_RespawnCountdown(entity this);
 void Item_ScheduleRespawnIn(entity e, float t);
 
 void Item_ScheduleRespawn(entity e);
@@ -88,7 +88,7 @@ float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax
 
 float Item_GiveTo(entity item, entity player);
 
-void Item_Touch();
+void Item_Touch(entity this);
 
 void Item_Reset(entity this);
 
index 909f5cd975c59381fc5ded443c4ae578466f35f4..e030632498d2c3f0cfb488135edd51245dedc642 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float height;
-void func_bobbing_controller_think()
-{SELFPARAM();
+void func_bobbing_controller_think(entity this)
+{
        vector v;
        self.nextthink = time + 0.1;
 
@@ -31,53 +31,53 @@ dmgtime : See above.
 spawnfunc(func_bobbing)
 {
        entity controller;
-       if (self.noise != "")
+       if (this.noise != "")
        {
-               precache_sound(self.noise);
-               soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+               precache_sound(this.noise);
+               soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
        }
-       if (!self.speed)
-               self.speed = 4;
-       if (!self.height)
-               self.height = 32;
+       if (!this.speed)
+               this.speed = 4;
+       if (!this.height)
+               this.height = 32;
        // center of bobbing motion
-       self.destvec = self.origin;
+       this.destvec = this.origin;
        // time scale to get degrees
-       self.cnt = 360 / self.speed;
+       this.cnt = 360 / this.speed;
 
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
        // damage when blocked
-       self.blocked = generic_plat_blocked;
-       if(self.dmg && (self.message == ""))
-               self.message = " was squished";
-    if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
-       if(self.dmg && (!self.dmgtime))
-               self.dmgtime = 0.25;
-       self.dmgtime2 = time;
+       this.blocked = generic_plat_blocked;
+       if(this.dmg && (this.message == ""))
+               this.message = " was squished";
+    if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
+       if(this.dmg && (!this.dmgtime))
+               this.dmgtime = 0.25;
+       this.dmgtime2 = time;
 
        // how far to bob
-       if (self.spawnflags & 1) // X
-               self.movedir = '1 0 0' * self.height;
-       else if (self.spawnflags & 2) // Y
-               self.movedir = '0 1 0' * self.height;
+       if (this.spawnflags & 1) // X
+               this.movedir = '1 0 0' * this.height;
+       else if (this.spawnflags & 2) // Y
+               this.movedir = '0 1 0' * this.height;
        else // Z
-               self.movedir = '0 0 1' * self.height;
+               this.movedir = '0 0 1' * this.height;
 
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
 
        // wait for targets to spawn
        controller = new(func_bobbing_controller);
-       controller.owner = self;
+       controller.owner = this;
        controller.nextthink = time + 1;
-       controller.think = func_bobbing_controller_think;
-       self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
-       self.SUB_THINK = SUB_NullThink;
+       setthink(controller, func_bobbing_controller_think);
+       this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+       SUB_THINK(this, SUB_NullThink);
 
        // Savage: Reduce bandwith, critical on e.g. nexdm02
-       self.effects |= EF_LOWPRECISION;
+       this.effects |= EF_LOWPRECISION;
 
        // TODO make a reset function for this one
 }
index 25857be3a1f48d659bc35a0f1a1c2a6467a845bc..246762659aafbfcc7a9b3e1e23614432344af4da 100644 (file)
@@ -189,8 +189,8 @@ void func_breakable_restore(entity this, entity actor, entity trigger)
        CSQCMODEL_AUTOUPDATE(this);
 }
 
-void func_breakable_restore_self()
-{SELFPARAM();
+void func_breakable_restore_self(entity this)
+{
        func_breakable_restore(this, NULL, NULL);
 }
 
@@ -221,7 +221,7 @@ void func_breakable_destroy(entity this, entity actor, entity trigger)
 
        if(this.respawntime)
        {
-               this.think = func_breakable_restore_self;
+               setthink(this, func_breakable_restore_self);
                this.nextthink = time + this.respawntime + crandom() * this.respawntimejitter;
        }
 
@@ -231,8 +231,8 @@ void func_breakable_destroy(entity this, entity actor, entity trigger)
        this.message = oldmsg;
 }
 
-void func_breakable_destroy_self()
-{SELFPARAM();
+void func_breakable_destroy_self(entity this)
+{
        func_breakable_destroy(this, NULL, NULL);
 }
 
@@ -271,7 +271,7 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float
                // do not explode NOW but in the NEXT FRAME!
                // because recursive calls to RadiusDamage are not allowed
                this.nextthink = time;
-               this.think = func_breakable_destroy_self;
+               setthink(this, func_breakable_destroy_self);
        }
 }
 
@@ -319,7 +319,7 @@ spawnfunc(func_breakable)
                this.dmg_force = 200;
 
        this.mdl = this.model;
-       SetBrushEntityModel();
+       WITHSELF(this, SetBrushEntityModel());
 
        if(this.spawnflags & 4)
                this.use = func_breakable_destroy;
index a1cabdc6c0326d2fa82bb766bfc1f5cd8c87abef..5584f9ffa167bbb476fbd16ce6804e08ba3c836f 100644 (file)
@@ -1,25 +1,25 @@
 #ifdef SVQC
 // button and multiple button
 
-void() button_wait;
-void() button_return;
+void button_wait(entity this);
+void button_return(entity this);
 
-void button_wait()
-{SELFPARAM();
+void button_wait(entity this)
+{
        self.state = STATE_TOP;
        self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
-       self.SUB_THINK = button_return;
+       SUB_THINK(self, button_return);
        SUB_UseTargets(self, self.enemy, NULL);
        self.frame = 1;                 // use alternate textures
 }
 
-void button_done()
-{SELFPARAM();
+void button_done(entity this)
+{
        self.state = STATE_BOTTOM;
 }
 
-void button_return()
-{SELFPARAM();
+void button_return(entity this)
+{
        self.state = STATE_DOWN;
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done);
        self.frame = 0;                 // use normal textures
@@ -49,14 +49,14 @@ void button_fire()
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait);
 }
 
-void button_reset()
-{SELFPARAM();
-       self.health = self.max_health;
-       setorigin(self, self.pos1);
-       self.frame = 0;                 // use normal textures
-       self.state = STATE_BOTTOM;
-       if (self.health)
-               self.takedamage = DAMAGE_YES;   // can be shot again
+void button_reset(entity this)
+{
+       this.health = this.max_health;
+       setorigin(this, this.pos1);
+       this.frame = 0;                 // use normal textures
+       this.state = STATE_BOTTOM;
+       if (this.health)
+               this.takedamage = DAMAGE_YES;   // can be shot again
 }
 
 void button_use(entity this, entity actor, entity trigger)
@@ -68,8 +68,8 @@ void button_use(entity this, entity actor, entity trigger)
        WITHSELF(this, button_fire());
 }
 
-void button_touch()
-{SELFPARAM();
+void button_touch(entity this)
+{
        if (!other)
                return;
        if (!other.iscreature)
@@ -113,42 +113,42 @@ When a button is touched, it moves some distance in the direction of it's angle,
 */
 spawnfunc(func_button)
 {
-       SetMovedir(self);
+       SetMovedir(this);
 
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
-       self.effects |= EF_LOWPRECISION;
+       this.effects |= EF_LOWPRECISION;
 
-       self.blocked = button_blocked;
-       self.use = button_use;
+       this.blocked = button_blocked;
+       this.use = button_use;
 
-//     if (self.health == 0) // all buttons are now shootable
-//             self.health = 10;
-       if (self.health)
+//     if (this.health == 0) // all buttons are now shootable
+//             this.health = 10;
+       if (this.health)
        {
-               self.max_health = self.health;
-               self.event_damage = button_damage;
-               self.takedamage = DAMAGE_YES;
+               this.max_health = this.health;
+               this.event_damage = button_damage;
+               this.takedamage = DAMAGE_YES;
        }
        else
-               self.touch = button_touch;
+               settouch(this, button_touch);
 
-       if (!self.speed)
-               self.speed = 40;
-       if (!self.wait)
-               self.wait = 1;
-       if (!self.lip)
-               self.lip = 4;
+       if (!this.speed)
+               this.speed = 40;
+       if (!this.wait)
+               this.wait = 1;
+       if (!this.lip)
+               this.lip = 4;
 
-    if(self.noise != "")
-        precache_sound(self.noise);
+    if(this.noise != "")
+        precache_sound(this.noise);
 
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
-       self.pos1 = self.origin;
-       self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
-    self.flags |= FL_NOTARGET;
+       this.pos1 = this.origin;
+       this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
+    this.flags |= FL_NOTARGET;
 
-       button_reset();
+       button_reset(this);
 }
 #endif
index 5cd17e7bfc3e1544cdeca427a884d09b5b542828..a4be9fe0538dd1ffad145f2beba54765025de6af 100644 (file)
@@ -1,7 +1,7 @@
 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
 
-void conveyor_think()
-{SELFPARAM();
+void conveyor_think(entity this)
+{
 #ifdef CSQC
        // TODO: check if this is what is causing the glitchiness when switching between them
        float dt = time - self.move_time;
@@ -108,11 +108,11 @@ bool conveyor_send(entity this, entity to, int sf)
        return true;
 }
 
-void conveyor_init()
-{SELFPARAM();
+void conveyor_init(entity this)
+{
        if (!this.speed) this.speed = 200;
        this.movedir *= this.speed;
-       this.think = conveyor_think;
+       setthink(this, conveyor_think);
        this.nextthink = time;
        IFTARGETED
        {
@@ -132,70 +132,70 @@ void conveyor_init()
 
 spawnfunc(trigger_conveyor)
 {
-       SetMovedir(self);
+       SetMovedir(this);
        EXACTTRIGGER_INIT;
-       conveyor_init();
+       conveyor_init(this);
 }
 
 spawnfunc(func_conveyor)
 {
-       SetMovedir(self);
-       InitMovingBrushTrigger();
-       self.movetype = MOVETYPE_NONE;
-       conveyor_init();
+       SetMovedir(this);
+       InitMovingBrushTrigger(this);
+       this.movetype = MOVETYPE_NONE;
+       conveyor_init(this);
 }
 
 #elif defined(CSQC)
 
-void conveyor_draw(entity this) { WITHSELF(this, conveyor_think()); }
-
-void conveyor_init()
-{SELFPARAM();
-       self.draw = conveyor_draw;
-       self.drawmask = MASK_NORMAL;
+void conveyor_draw(entity this) { WITHSELF(this, conveyor_think(this)); }
 
-       self.movetype = MOVETYPE_NONE;
-       self.model = "";
-       self.solid = SOLID_TRIGGER;
-       self.move_origin = self.origin;
-       self.move_time = time;
+void conveyor_init(entity this)
+{
+       this.draw = conveyor_draw;
+       this.drawmask = MASK_NORMAL;
+
+       this.movetype = MOVETYPE_NONE;
+       this.model = "";
+       this.solid = SOLID_TRIGGER;
+       this.move_origin = this.origin;
+       this.move_time = time;
 }
 
 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
 {
-       float sf = ReadByte();
+       int sf = ReadByte();
 
        if(sf & 1)
        {
-               self.warpzone_isboxy = ReadByte();
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
-
-               self.mins_x = ReadCoord();
-               self.mins_y = ReadCoord();
-               self.mins_z = ReadCoord();
-               self.maxs_x = ReadCoord();
-               self.maxs_y = ReadCoord();
-               self.maxs_z = ReadCoord();
-               setsize(self, self.mins, self.maxs);
-
-               self.movedir_x = ReadCoord();
-               self.movedir_y = ReadCoord();
-               self.movedir_z = ReadCoord();
-
-               self.speed = ReadByte();
-               self.state = ReadByte();
-
-               self.targetname = strzone(ReadString());
-               self.target = strzone(ReadString());
-
-               conveyor_init();
+               this.warpzone_isboxy = ReadByte();
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+               setorigin(this, this.origin);
+
+               this.mins_x = ReadCoord();
+               this.mins_y = ReadCoord();
+               this.mins_z = ReadCoord();
+               this.maxs_x = ReadCoord();
+               this.maxs_y = ReadCoord();
+               this.maxs_z = ReadCoord();
+               setsize(this, this.mins, this.maxs);
+
+               this.movedir_x = ReadCoord();
+               this.movedir_y = ReadCoord();
+               this.movedir_z = ReadCoord();
+
+               this.speed = ReadByte();
+               this.state = ReadByte();
+
+               this.targetname = strzone(ReadString());
+               this.target = strzone(ReadString());
+
+               conveyor_init(this);
        }
 
        if(sf & 2)
-               self.state = ReadByte();
+               this.state = ReadByte();
 
        return true;
 }
index 30de40fa9c51874e28ef6f4b2290b9b6b146c1b8..92afdebecaf4c7c2749149b7704bd1bd88002c2f 100644 (file)
@@ -20,9 +20,9 @@ THINK FUNCTIONS
 =============================================================================
 */
 
-void() door_go_down;
+void door_go_down(entity this);
 void() door_go_up;
-void() door_rotating_go_down;
+void door_rotating_go_down(entity this);
 void() door_rotating_go_up;
 
 void door_blocked()
@@ -66,10 +66,10 @@ void door_blocked()
                                else
                        if (self.classname == "door")
                        {
-                               door_go_down ();
+                               door_go_down (self);
                        } else
                        {
-                               door_rotating_go_down ();
+                               door_rotating_go_down (self);
                        }
                        }
                }
@@ -84,8 +84,8 @@ void door_blocked()
        }
 }
 
-void door_hit_top()
-{SELFPARAM();
+void door_hit_top(entity this)
+{
        if (self.noise1 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
@@ -93,23 +93,23 @@ void door_hit_top()
                return;         // don't come down automatically
        if (self.classname == "door")
        {
-               self.SUB_THINK = door_go_down;
+               SUB_THINK(self, door_go_down);
        } else
        {
-               self.SUB_THINK = door_rotating_go_down;
+               SUB_THINK(self, door_rotating_go_down);
        }
        self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
 }
 
-void door_hit_bottom()
-{SELFPARAM();
+void door_hit_bottom(entity this)
+{
        if (self.noise1 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_BOTTOM;
 }
 
-void door_go_down()
-{SELFPARAM();
+void door_go_down(entity this)
+{
        if (self.noise2 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
@@ -208,7 +208,6 @@ bool door_check_keys(entity door, entity player)
 
 void door_fire(entity this, entity actor, entity trigger)
 {
-       entity starte;
        if (this.owner != this)
                objerror ("door_fire: this.owner != this");
 
@@ -216,49 +215,39 @@ void door_fire(entity this, entity actor, entity trigger)
        {
                if (this.state == STATE_UP || this.state == STATE_TOP)
                {
-                       starte = self;
-                       do
-                       {
-                               if (self.classname == "door")
-                               {
-                                       door_go_down ();
-                               }
-                               else
-                               {
-                                       door_rotating_go_down ();
+                       entity e = this;
+                       do {
+                               if (e.classname == "door") {
+                                       WITHSELF(e, door_go_down(e));
+                               } else {
+                                       WITHSELF(e, door_rotating_go_down(e));
                                }
-                               setself(self.enemy);
-                       } while ( (self != starte) && (self != world) );
-                       setself(this);
+                               e = e.enemy;
+                       } while ((e != this) && (e != NULL));
                        return;
                }
        }
 
 // trigger all paired doors
-       starte = self;
-       do
-       {
-               if (self.classname == "door")
-               {
-                       door_go_up ();
-               } else
-               {
+       entity e = this;
+       do {
+               if (e.classname == "door") {
+                       WITHSELF(e, door_go_up());
+               } else {
                        // if the BIDIR spawnflag (==2) is set and the trigger has set trigger_reverse, reverse the opening direction
-                       if ((self.spawnflags & 2) && other.trigger_reverse!=0 && self.lip!=666 && self.state == STATE_BOTTOM)
-                       {
-                               self.lip = 666; // self.lip is used to remember reverse opening direction for door_rotating
-                               self.pos2 = '0 0 0' - self.pos2;
+                       if ((e.spawnflags & 2) && other.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) {
+                               e.lip = 666; // e.lip is used to remember reverse opening direction for door_rotating
+                               e.pos2 = '0 0 0' - e.pos2;
                        }
                        // if BIDIR_IN_DOWN (==8) is set, prevent the door from reoping during closing if it is triggered from the wrong side
-                       if (!((self.spawnflags & 2) &&  (self.spawnflags & 8) && self.state == STATE_DOWN
-                               && (((self.lip==666) && (other.trigger_reverse==0)) || ((self.lip!=666) && (other.trigger_reverse!=0)))))
+                       if (!((e.spawnflags & 2) &&  (e.spawnflags & 8) && e.state == STATE_DOWN
+                               && (((e.lip == 666) && (other.trigger_reverse == 0)) || ((e.lip != 666) && (other.trigger_reverse != 0)))))
                        {
-                               door_rotating_go_up ();
+                               WITHSELF(e, door_rotating_go_up());
                        }
                }
-               setself(self.enemy);
-       } while ( (self != starte) && (self != world) );
-       setself(this);
+               e = e.enemy;
+       } while ((e != this) && (e != NULL));
 }
 
 void door_use(entity this, entity actor, entity trigger)
@@ -300,8 +289,8 @@ Prints messages
 ================
 */
 
-void door_touch()
-{SELFPARAM();
+void door_touch(entity this)
+{
        if (!IS_PLAYER(other))
                return;
        if (self.owner.door_finished > time)
@@ -343,7 +332,7 @@ void door_generic_plat_blocked()
                                if (self.state == STATE_DOWN)
                                        door_rotating_go_up ();
                                else
-                                       door_rotating_go_down ();
+                                       door_rotating_go_down (self);
                        }
                }
 #ifdef SVQC
@@ -357,19 +346,19 @@ void door_generic_plat_blocked()
        }
 }
 
-void door_rotating_hit_top()
-{SELFPARAM();
+void door_rotating_hit_top(entity this)
+{
        if (self.noise1 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
        if (self.spawnflags & DOOR_TOGGLE)
                return;         // don't come down automatically
-       self.SUB_THINK = door_rotating_go_down;
+       SUB_THINK(self, door_rotating_go_down);
        self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
 }
 
-void door_rotating_hit_bottom()
-{SELFPARAM();
+void door_rotating_hit_bottom(entity this)
+{
        if (self.noise1 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        if (self.lip==666) // self.lip is used to remember reverse opening direction for door_rotating
@@ -380,8 +369,8 @@ void door_rotating_hit_bottom()
        self.state = STATE_BOTTOM;
 }
 
-void door_rotating_go_down()
-{SELFPARAM();
+void door_rotating_go_down(entity this)
+{
        if (self.noise2 != "")
                _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
@@ -425,8 +414,8 @@ Spawned if a door lacks a real activator
 =========================================
 */
 
-void door_trigger_touch()
-{SELFPARAM();
+void door_trigger_touch(entity this)
+{
        if (other.health < 1)
 #ifdef SVQC
                if (!((other.iscreature || (other.flags & FL_PROJECTILE)) && !IS_DEAD(other)))
@@ -457,11 +446,7 @@ void door_spawnfield(vector fmins, vector fmaxs)
        trigger.solid = SOLID_TRIGGER;
        trigger.owner = self;
 #ifdef SVQC
-       trigger.touch = door_trigger_touch;
-#elif defined(CSQC)
-       trigger.trigger_touch = door_trigger_touch;
-       trigger.draw = trigger_draw_generic;
-       trigger.drawmask = MASK_NORMAL;
+       settouch(trigger, door_trigger_touch);
 #endif
 
        setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
@@ -703,7 +688,7 @@ void door_reset(entity this)
        SUB_SETORIGIN(this, this.pos1);
        this.SUB_VELOCITY = '0 0 0';
        this.state = STATE_BOTTOM;
-       this.SUB_THINK = func_null;
+       SUB_THINK(this, func_null);
        this.SUB_NEXTTHINK = 0;
 
 #ifdef SVQC
@@ -717,92 +702,85 @@ void door_reset(entity this)
 spawnfunc(func_door)
 {
        // Quake 1 keys compatibility
-       if (self.spawnflags & SPAWNFLAGS_GOLD_KEY)
-               self.itemkeys |= ITEM_KEY_BIT(0);
-       if (self.spawnflags & SPAWNFLAGS_SILVER_KEY)
-               self.itemkeys |= ITEM_KEY_BIT(1);
+       if (this.spawnflags & SPAWNFLAGS_GOLD_KEY)
+               this.itemkeys |= ITEM_KEY_BIT(0);
+       if (this.spawnflags & SPAWNFLAGS_SILVER_KEY)
+               this.itemkeys |= ITEM_KEY_BIT(1);
 
-       SetMovedir(self);
+       SetMovedir(this);
 
-       self.max_health = self.health;
-       if (!InitMovingBrushTrigger())
+       this.max_health = this.health;
+       if (!InitMovingBrushTrigger(this))
                return;
-       self.effects |= EF_LOWPRECISION;
-       self.classname = "door";
+       this.effects |= EF_LOWPRECISION;
+       this.classname = "door";
 
-       if(self.noise == "")
-               self.noise = "misc/talk.wav";
-       if(self.noise3 == "")
-               self.noise3 = "misc/talk.wav";
-       precache_sound(self.noise);
-       precache_sound(self.noise3);
+       if(this.noise == "")
+               this.noise = "misc/talk.wav";
+       if(this.noise3 == "")
+               this.noise3 = "misc/talk.wav";
+       precache_sound(this.noise);
+       precache_sound(this.noise3);
 
-       self.blocked = door_blocked;
-       self.use = door_use;
+       this.blocked = door_blocked;
+       this.use = door_use;
 
-       if(self.dmg && (self.message == ""))
-               self.message = "was squished";
-       if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
+       if(this.dmg && (this.message == ""))
+               this.message = "was squished";
+       if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
 
-       if (self.sounds > 0)
+       if (this.sounds > 0)
        {
                precache_sound ("plats/medplat1.wav");
                precache_sound ("plats/medplat2.wav");
-               self.noise2 = "plats/medplat1.wav";
-               self.noise1 = "plats/medplat2.wav";
+               this.noise2 = "plats/medplat1.wav";
+               this.noise1 = "plats/medplat2.wav";
        }
 
-       if (!self.speed)
-               self.speed = 100;
-       if (!self.wait)
-               self.wait = 3;
-       if (!self.lip)
-               self.lip = 8;
+       if (!this.speed)
+               this.speed = 100;
+       if (!this.wait)
+               this.wait = 3;
+       if (!this.lip)
+               this.lip = 8;
 
-       self.pos1 = self.SUB_ORIGIN;
-       self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
+       this.pos1 = this.SUB_ORIGIN;
+       this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
 
-       if(self.spawnflags & DOOR_NONSOLID)
-               self.solid = SOLID_NOT;
+       if(this.spawnflags & DOOR_NONSOLID)
+               this.solid = SOLID_NOT;
 
 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
 // but spawn in the open position
-       if (self.spawnflags & DOOR_START_OPEN)
-               InitializeEntity(self, door_init_startopen, INITPRIO_SETLOCATION);
+       if (this.spawnflags & DOOR_START_OPEN)
+               InitializeEntity(this, door_init_startopen, INITPRIO_SETLOCATION);
 
-       self.state = STATE_BOTTOM;
+       this.state = STATE_BOTTOM;
 
-       if (self.health)
+       if (this.health)
        {
-               self.takedamage = DAMAGE_YES;
-               self.event_damage = door_damage;
+               this.takedamage = DAMAGE_YES;
+               this.event_damage = door_damage;
        }
 
-       if (self.items)
-               self.wait = -1;
+       if (this.items)
+               this.wait = -1;
 
-       self.touch = door_touch;
+       settouch(this, door_touch);
 
 // LinkDoors can't be done until all of the doors have been spawned, so
 // the sizes can be detected properly.
-       InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
+       InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
 
-       self.reset = door_reset;
+       this.reset = door_reset;
 }
 
 #elif defined(CSQC)
 
-void door_draw(entity this)
-{
-       Movetype_Physics_NoMatchServer(this);
-
-       trigger_draw_generic(this);
-}
-
 NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
 {
-       float sf = ReadByte();
+       int sf = ReadByte();
 
        if(sf & SF_TRIGGER_INIT)
        {
@@ -812,7 +790,7 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
                this.mdl = strzone(ReadString());
                _setmodel(this, this.mdl);
 
-               trigger_common_read(true);
+               trigger_common_read(this, true);
 
                vector v;
 
@@ -839,9 +817,6 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
 
                this.solid = SOLID_BSP;
                this.movetype = MOVETYPE_PUSH;
-               this.trigger_touch = door_touch;
-               this.draw = door_draw;
-               this.drawmask = MASK_NORMAL;
                this.use = door_use;
 
                LinkDoors(this);
index 4c97fe6a8aa7c1d7584c4fb63d7c024a247c968e..504005e362733e18de841000c848af1ef7b76c4d 100644 (file)
@@ -32,7 +32,7 @@ void door_rotating_reset(entity this)
        this.angles = this.pos1;
        this.avelocity = '0 0 0';
        this.state = STATE_BOTTOM;
-       this.think = func_null;
+       setthink(this, func_null);
        this.nextthink = 0;
 }
 
@@ -47,80 +47,80 @@ void door_rotating_init_startopen(entity this)
 spawnfunc(func_door_rotating)
 {
 
-       //if (!self.deathtype) // map makers can override this
-       //      self.deathtype = " got in the way";
+       //if (!this.deathtype) // map makers can override this
+       //      this.deathtype = " got in the way";
 
        // I abuse "movedir" for denoting the axis for now
-       if (self.spawnflags & 64) // X (untested)
-               self.movedir = '0 0 1';
-       else if (self.spawnflags & 128) // Y (untested)
-               self.movedir = '1 0 0';
+       if (this.spawnflags & 64) // X (untested)
+               this.movedir = '0 0 1';
+       else if (this.spawnflags & 128) // Y (untested)
+               this.movedir = '1 0 0';
        else // Z
-               self.movedir = '0 1 0';
+               this.movedir = '0 1 0';
 
-       if (self.angles_y==0) self.angles_y = 90;
+       if (this.angles_y==0) this.angles_y = 90;
 
-       self.movedir = self.movedir * self.angles_y;
-       self.angles = '0 0 0';
+       this.movedir = this.movedir * this.angles_y;
+       this.angles = '0 0 0';
 
-       self.max_health = self.health;
-       self.avelocity = self.movedir;
-       if (!InitMovingBrushTrigger())
+       this.max_health = this.health;
+       this.avelocity = this.movedir;
+       if (!InitMovingBrushTrigger(this))
                return;
-       self.velocity = '0 0 0';
-       //self.effects |= EF_LOWPRECISION;
-       self.classname = "door_rotating";
+       this.velocity = '0 0 0';
+       //this.effects |= EF_LOWPRECISION;
+       this.classname = "door_rotating";
 
-       self.blocked = door_blocked;
-       self.use = door_use;
+       this.blocked = door_blocked;
+       this.use = door_use;
 
-    if(self.spawnflags & 8)
-        self.dmg = 10000;
+    if(this.spawnflags & 8)
+        this.dmg = 10000;
 
-    if(self.dmg && (self.message == ""))
-               self.message = "was squished";
-    if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
+    if(this.dmg && (this.message == ""))
+               this.message = "was squished";
+    if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
 
-    if (self.sounds > 0)
+    if (this.sounds > 0)
        {
                precache_sound ("plats/medplat1.wav");
                precache_sound ("plats/medplat2.wav");
-               self.noise2 = "plats/medplat1.wav";
-               self.noise1 = "plats/medplat2.wav";
+               this.noise2 = "plats/medplat1.wav";
+               this.noise1 = "plats/medplat2.wav";
        }
 
-       if (!self.speed)
-               self.speed = 50;
-       if (!self.wait)
-               self.wait = 1;
-       self.lip = 0; // self.lip is used to remember reverse opening direction for door_rotating
+       if (!this.speed)
+               this.speed = 50;
+       if (!this.wait)
+               this.wait = 1;
+       this.lip = 0; // this.lip is used to remember reverse opening direction for door_rotating
 
-       self.pos1 = '0 0 0';
-       self.pos2 = self.movedir;
+       this.pos1 = '0 0 0';
+       this.pos2 = this.movedir;
 
 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
 // but spawn in the open position
-       if (self.spawnflags & DOOR_START_OPEN)
-               InitializeEntity(self, door_rotating_init_startopen, INITPRIO_SETLOCATION);
+       if (this.spawnflags & DOOR_START_OPEN)
+               InitializeEntity(this, door_rotating_init_startopen, INITPRIO_SETLOCATION);
 
-       self.state = STATE_BOTTOM;
+       this.state = STATE_BOTTOM;
 
-       if (self.health)
+       if (this.health)
        {
-               self.takedamage = DAMAGE_YES;
-               self.event_damage = door_damage;
+               this.takedamage = DAMAGE_YES;
+               this.event_damage = door_damage;
        }
 
-       if (self.items)
-               self.wait = -1;
+       if (this.items)
+               this.wait = -1;
 
-       self.touch = door_touch;
+       settouch(this, door_touch);
 
 // LinkDoors can't be done until all of the doors have been spawned, so
 // the sizes can be detected properly.
-       InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
+       InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS);
 
-       self.reset = door_rotating_reset;
+       this.reset = door_rotating_reset;
 }
 #endif
index 3e45302040ca1f805e0e4681f1ae2fc3b4b580fa..12008e492d443896506773352d798e0ddbdf569c 100644 (file)
@@ -1,11 +1,11 @@
 #ifdef SVQC
-void() fd_secret_move1;
-void() fd_secret_move2;
-void() fd_secret_move3;
-void() fd_secret_move4;
-void() fd_secret_move5;
-void() fd_secret_move6;
-void() fd_secret_done;
+void fd_secret_move1(entity this);
+void fd_secret_move2(entity this);
+void fd_secret_move3(entity this);
+void fd_secret_move4(entity this);
+void fd_secret_move5(entity this);
+void fd_secret_move6(entity this);
+void fd_secret_done(entity this);
 
 const float SECRET_OPEN_ONCE = 1;              // stays open
 const float SECRET_1ST_LEFT = 2;               // 1st move is left of arrow
@@ -69,60 +69,60 @@ void fd_secret_damage(entity this, entity inflictor, entity attacker, float dama
 }
 
 // Wait after first movement...
-void fd_secret_move1()
-{SELFPARAM();
+void fd_secret_move1(entity this)
+{
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
-       self.think = fd_secret_move2;
+       setthink(self, fd_secret_move2);
        if (self.noise3 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
 }
 
 // Start moving sideways w/sound...
-void fd_secret_move2()
-{SELFPARAM();
+void fd_secret_move2(entity this)
+{
        if (self.noise2 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3);
 }
 
 // Wait here until time to go back...
-void fd_secret_move3()
-{SELFPARAM();
+void fd_secret_move3(entity this)
+{
        if (self.noise3 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
        if (!(self.spawnflags & SECRET_OPEN_ONCE))
        {
                self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
-               self.think = fd_secret_move4;
+               setthink(self, fd_secret_move4);
        }
 }
 
 // Move backward...
-void fd_secret_move4()
-{SELFPARAM();
+void fd_secret_move4(entity this)
+{
        if (self.noise2 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5);
 }
 
 // Wait 1 second...
-void fd_secret_move5()
-{SELFPARAM();
+void fd_secret_move5(entity this)
+{
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
-       self.think = fd_secret_move6;
+       setthink(self, fd_secret_move6);
        if (self.noise3 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
 }
 
-void fd_secret_move6()
-{SELFPARAM();
+void fd_secret_move6(entity this)
+{
        if (self.noise2 != "")
                _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done);
 }
 
-void fd_secret_done()
-{SELFPARAM();
+void fd_secret_done(entity this)
+{
        if (self.spawnflags&SECRET_YES_SHOOT)
        {
                self.health = 10000;
@@ -150,8 +150,8 @@ secret_touch
 Prints messages
 ================
 */
-void secret_touch()
-{SELFPARAM();
+void secret_touch(entity this)
+{
        if (!other.iscreature)
                return;
        if (self.door_finished > time)
@@ -175,7 +175,7 @@ void secret_reset(entity this)
                this.takedamage = DAMAGE_YES;
        }
        setorigin(this, this.oldorigin);
-       this.think = func_null;
+       setthink(this, func_null);
        this.SUB_NEXTTHINK = 0;
 }
 
@@ -207,13 +207,13 @@ spawnfunc(func_door_secret)
        this.mangle = this.angles;
        this.angles = '0 0 0';
        this.classname = "door";
-       if (!InitMovingBrushTrigger()) return;
+       if (!InitMovingBrushTrigger(this)) return;
        this.effects |= EF_LOWPRECISION;
 
        if (this.noise == "") this.noise = "misc/talk.wav";
        precache_sound(this.noise);
 
-       this.touch = secret_touch;
+       settouch(this, secret_touch);
        this.blocked = secret_blocked;
        this.speed = 50;
        this.use = fd_secret_use;
index 31e3835914ecb59d5722942ed35f1b824dbf83aa..53366aa1054dcde093ec130031ee5a579ce86c60 100644 (file)
@@ -10,8 +10,8 @@ dmg: Do this mutch dmg every .dmgtime intervall when blocked
 dmgtime: See above.
 */
 
-void func_fourier_controller_think()
-{SELFPARAM();
+void func_fourier_controller_think(entity this)
+{
        vector v;
        float n, i, t;
 
@@ -42,46 +42,46 @@ void func_fourier_controller_think()
 spawnfunc(func_fourier)
 {
        entity controller;
-       if (self.noise != "")
+       if (this.noise != "")
        {
-               precache_sound(self.noise);
-               soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+               precache_sound(this.noise);
+               soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
        }
 
-       if (!self.speed)
-               self.speed = 4;
-       if (!self.height)
-               self.height = 32;
-       self.destvec = self.origin;
-       self.cnt = 360 / self.speed;
-
-       self.blocked = generic_plat_blocked;
-       if(self.dmg && (self.message == ""))
-               self.message = " was squished";
-    if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
-       if(self.dmg && (!self.dmgtime))
-               self.dmgtime = 0.25;
-       self.dmgtime2 = time;
-
-       if(self.netname == "")
-               self.netname = "1 0 0 0 1";
-
-       if (!InitMovingBrushTrigger())
+       if (!this.speed)
+               this.speed = 4;
+       if (!this.height)
+               this.height = 32;
+       this.destvec = this.origin;
+       this.cnt = 360 / this.speed;
+
+       this.blocked = generic_plat_blocked;
+       if(this.dmg && (this.message == ""))
+               this.message = " was squished";
+    if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
+       if(this.dmg && (!this.dmgtime))
+               this.dmgtime = 0.25;
+       this.dmgtime2 = time;
+
+       if(this.netname == "")
+               this.netname = "1 0 0 0 1";
+
+       if (!InitMovingBrushTrigger(this))
                return;
 
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
        // wait for targets to spawn
        controller = new(func_fourier_controller);
-       controller.owner = self;
+       controller.owner = this;
        controller.nextthink = time + 1;
-       controller.think = func_fourier_controller_think;
-       self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
-       self.SUB_THINK = SUB_NullThink; // for PushMove
+       setthink(controller, func_fourier_controller_think);
+       this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+       SUB_THINK(this, SUB_NullThink); // for PushMove
 
        // Savage: Reduce bandwith, critical on e.g. nexdm02
-       self.effects |= EF_LOWPRECISION;
+       this.effects |= EF_LOWPRECISION;
 
        // TODO make a reset function for this one
 }
index 04c5c2563d785a665685bd9d8888393f9a2ad9cb..e0108cd8f0f030e0eaaa6124c20f373fa15a349f 100644 (file)
@@ -1,7 +1,7 @@
 REGISTER_NET_LINKED(ENT_CLIENT_LADDER)
 
-void func_ladder_touch()
-{SELFPARAM();
+void func_ladder_touch(entity this)
+{
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -32,31 +32,29 @@ bool func_ladder_send(entity to, int sf)
        return true;
 }
 
-void func_ladder_link()
+void func_ladder_link(entity this)
 {
-    SELFPARAM();
-       self.SendEntity = func_ladder_send;
-       self.SendFlags = 0xFFFFFF;
-       //self.model = "null";
+       this.SendEntity = func_ladder_send;
+       this.SendFlags = 0xFFFFFF;
+       //this.model = "null";
 }
 
-void func_ladder_init()
+void func_ladder_init(entity this)
 {
-    SELFPARAM();
-       self.touch = func_ladder_touch;
+       settouch(this, func_ladder_touch);
 
-       trigger_init(self);
-       func_ladder_link();
+       trigger_init(this);
+       func_ladder_link(this);
 }
 
 spawnfunc(func_ladder)
 {
-       func_ladder_init();
+       func_ladder_init(this);
 }
 
 spawnfunc(func_water)
 {
-       func_ladder_init();
+       func_ladder_init(this);
 }
 
 #elif defined(CSQC)
@@ -70,17 +68,17 @@ void func_ladder_remove(entity this)
 
 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
 {
-       self.classname = strzone(ReadString());
-       self.skin = ReadByte();
-       self.speed = ReadCoord();
+       this.classname = strzone(ReadString());
+       this.skin = ReadByte();
+       this.speed = ReadCoord();
 
-       trigger_common_read(false);
+       trigger_common_read(this, false);
 
-       self.solid = SOLID_TRIGGER;
-       self.move_touch = func_ladder_touch;
-       self.drawmask = MASK_NORMAL;
-       self.move_time = time;
-       self.entremove = func_ladder_remove;
+       this.solid = SOLID_TRIGGER;
+       settouch(this, func_ladder_touch);
+       this.drawmask = MASK_NORMAL;
+       this.move_time = time;
+       this.entremove = func_ladder_remove;
 
        return true;
 }
index 2d8aea35cfa1a756c3f7981984f772dc9b87e16e..e05b2a6fca08927c0e081f9e1e230a70ad1a0c45 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float freq;
-void func_pendulum_controller_think()
-{SELFPARAM();
+void func_pendulum_controller_think(entity this)
+{
        float v;
        self.nextthink = time + 0.1;
 
@@ -24,52 +24,52 @@ void func_pendulum_controller_think()
 spawnfunc(func_pendulum)
 {
        entity controller;
-       if (self.noise != "")
+       if (this.noise != "")
        {
-               precache_sound(self.noise);
-               soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+               precache_sound(this.noise);
+               soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
        }
 
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
        // keys: angle, speed, phase, noise, freq
 
-       if(!self.speed)
-               self.speed = 30;
-       // not initializing self.dmg to 2, to allow damageless pendulum
+       if(!this.speed)
+               this.speed = 30;
+       // not initializing this.dmg to 2, to allow damageless pendulum
 
-       if(self.dmg && (self.message == ""))
-               self.message = " was squished";
-       if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
-       if(self.dmg && (!self.dmgtime))
-               self.dmgtime = 0.25;
-       self.dmgtime2 = time;
+       if(this.dmg && (this.message == ""))
+               this.message = " was squished";
+       if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
+       if(this.dmg && (!this.dmgtime))
+               this.dmgtime = 0.25;
+       this.dmgtime2 = time;
 
-       self.blocked = generic_plat_blocked;
+       this.blocked = generic_plat_blocked;
 
-       self.avelocity_z = 0.0000001;
-       if (!InitMovingBrushTrigger())
+       this.avelocity_z = 0.0000001;
+       if (!InitMovingBrushTrigger(this))
                return;
 
-       if(!self.freq)
+       if(!this.freq)
        {
                // find pendulum length (same formula as Q3A)
-               self.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(self.mins_z))));
+               this.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(this.mins_z))));
        }
 
        // copy initial angle
-       self.cnt = self.angles_z;
+       this.cnt = this.angles_z;
 
        // wait for targets to spawn
        controller = new(func_pendulum_controller);
-       controller.owner = self;
+       controller.owner = this;
        controller.nextthink = time + 1;
-       controller.think = func_pendulum_controller_think;
-       self.nextthink = self.SUB_LTIME + 999999999;
-       self.SUB_THINK = SUB_NullThink; // for PushMove
+       setthink(controller, func_pendulum_controller_think);
+       this.nextthink = this.SUB_LTIME + 999999999;
+       SUB_THINK(this, SUB_NullThink); // for PushMove
 
-       //self.effects |= EF_LOWPRECISION;
+       //this.effects |= EF_LOWPRECISION;
 
        // TODO make a reset function for this one
 }
index 14cfa564134b74e0c6633ac53d5862a05c4db6d7..7e2ae74aabfd5080e936a2f20fc615c8989d624d 100644 (file)
@@ -101,7 +101,7 @@ spawnfunc(func_plat)
        this.angles = '0 0 0';
 
        this.classname = "plat";
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
        this.effects |= EF_LOWPRECISION;
        setsize (this, this.mins , this.maxs);
@@ -142,7 +142,7 @@ NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
                this.model = strzone(ReadString());
                _setmodel(this, this.model);
 
-               trigger_common_read(true);
+               trigger_common_read(this, true);
 
                this.pos1_x = ReadCoord();
                this.pos1_y = ReadCoord();
index 9cec88f99463f0563bce49a05d76457b77d06946..9cfc01acbf20f6c85488ff24453ac3d7af711f60 100644 (file)
@@ -93,8 +93,8 @@ void pointparticles_use(entity this, entity actor, entity trigger)
        this.SendFlags |= 2;
 }
 
-void pointparticles_think()
-{SELFPARAM();
+void pointparticles_think(entity this)
+{
        if(self.origin != self.oldorigin)
        {
                self.SendFlags |= 4;
@@ -143,7 +143,7 @@ spawnfunc(func_pointparticles)
        }
        else
                this.state = 1;
-       this.think = pointparticles_think;
+       setthink(this, pointparticles_think);
        this.nextthink = time;
 }
 
@@ -194,20 +194,20 @@ void Draw_PointParticles(entity this)
        vector p;
        vector sz;
        vector o;
-       o = self.origin;
-       sz = self.maxs - self.mins;
-       n = doBGMScript(self);
-       if(self.absolute == 2)
+       o = this.origin;
+       sz = this.maxs - this.mins;
+       n = doBGMScript(this);
+       if(this.absolute == 2)
        {
                if(n >= 0)
-                       n = self.just_toggled ? self.impulse : 0;
+                       n = this.just_toggled ? this.impulse : 0;
                else
-                       n = self.impulse * drawframetime;
+                       n = this.impulse * drawframetime;
        }
        else
        {
-               n *= self.impulse * drawframetime;
-               if(self.just_toggled)
+               n *= this.impulse * drawframetime;
+               if(this.just_toggled)
                        if(n < 1)
                                n = 1;
        }
@@ -216,46 +216,46 @@ void Draw_PointParticles(entity this)
        fail = 0;
        for(i = random(); i <= n && fail <= 64*n; ++i)
        {
-               p = o + self.mins;
+               p = o + this.mins;
                p.x += random() * sz.x;
                p.y += random() * sz.y;
                p.z += random() * sz.z;
-               if(WarpZoneLib_BoxTouchesBrush(p, p, self, world))
+               if(WarpZoneLib_BoxTouchesBrush(p, p, this, world))
                {
-                       if(self.movedir != '0 0 0')
+                       if(this.movedir != '0 0 0')
                        {
-                               traceline(p, p + normalize(self.movedir) * 4096, 0, world);
+                               traceline(p, p + normalize(this.movedir) * 4096, 0, world);
                                p = trace_endpos;
                                int eff_num;
-                               if(self.cnt)
-                                       eff_num = self.cnt;
+                               if(this.cnt)
+                                       eff_num = this.cnt;
                                else
-                                       eff_num = _particleeffectnum(self.mdl);
-                               __pointparticles(eff_num, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
+                                       eff_num = _particleeffectnum(this.mdl);
+                               __pointparticles(eff_num, p, trace_plane_normal * vlen(this.movedir) + this.velocity + randomvec() * this.waterlevel, this.count);
                        }
                        else
                        {
                                int eff_num;
-                               if(self.cnt)
-                                       eff_num = self.cnt;
+                               if(this.cnt)
+                                       eff_num = this.cnt;
                                else
-                                       eff_num = _particleeffectnum(self.mdl);
-                               __pointparticles(eff_num, p, self.velocity + randomvec() * self.waterlevel, self.count);
+                                       eff_num = _particleeffectnum(this.mdl);
+                               __pointparticles(eff_num, p, this.velocity + randomvec() * this.waterlevel, this.count);
                        }
-                       if(self.noise != "")
+                       if(this.noise != "")
                        {
-                               setorigin(self, p);
-                               _sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
+                               setorigin(this, p);
+                               _sound(this, CH_AMBIENT, this.noise, VOL_BASE * this.volume, this.atten);
                        }
-                       self.just_toggled = 0;
+                       this.just_toggled = 0;
                }
-               else if(self.absolute)
+               else if(this.absolute)
                {
                        ++fail;
                        --i;
                }
        }
-       setorigin(self, o);
+       setorigin(this, o);
 }
 
 void Ent_PointParticles_Remove(entity this)
@@ -279,105 +279,105 @@ NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew)
        if(f & 2)
        {
                i = ReadCoord(); // density (<0: point, >0: volume)
-               if(i && !self.impulse && (self.cnt || self.mdl)) // self.cnt check is so it only happens if the ent already existed
-                       self.just_toggled = 1;
-               self.impulse = i;
+               if(i && !this.impulse && (this.cnt || this.mdl)) // this.cnt check is so it only happens if the ent already existed
+                       this.just_toggled = 1;
+               this.impulse = i;
        }
        if(f & 4)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
        }
        if(f & 1)
        {
-               self.modelindex = ReadShort();
+               this.modelindex = ReadShort();
                if(f & 0x80)
                {
-                       if(self.modelindex)
+                       if(this.modelindex)
                        {
-                               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    = '0 0 0';
-                               self.maxs_x = ReadCoord();
-                               self.maxs_y = ReadCoord();
-                               self.maxs_z = ReadCoord();
+                               this.mins    = '0 0 0';
+                               this.maxs_x = ReadCoord();
+                               this.maxs_y = ReadCoord();
+                               this.maxs_z = ReadCoord();
                        }
                }
                else
                {
-                       self.mins = self.maxs = '0 0 0';
+                       this.mins = this.maxs = '0 0 0';
                }
 
-               self.cnt = ReadShort(); // effect number
-               self.mdl = strzone(ReadString()); // effect string
+               this.cnt = ReadShort(); // effect number
+               this.mdl = strzone(ReadString()); // effect string
 
                if(f & 0x20)
                {
-                       self.velocity = decompressShortVector(ReadShort());
-                       self.movedir = decompressShortVector(ReadShort());
+                       this.velocity = decompressShortVector(ReadShort());
+                       this.movedir = decompressShortVector(ReadShort());
                }
                else
                {
-                       self.velocity = self.movedir = '0 0 0';
+                       this.velocity = this.movedir = '0 0 0';
                }
                if(f & 0x40)
                {
-                       self.waterlevel = ReadShort() / 16.0;
-                       self.count = ReadByte() / 16.0;
+                       this.waterlevel = ReadShort() / 16.0;
+                       this.count = ReadByte() / 16.0;
                }
                else
                {
-                       self.waterlevel = 0;
-                       self.count = 1;
+                       this.waterlevel = 0;
+                       this.count = 1;
                }
-               if(self.noise)
-                       strunzone(self.noise);
-               if(self.bgmscript)
-                       strunzone(self.bgmscript);
-               self.noise = strzone(ReadString());
-               if(self.noise != "")
+               if(this.noise)
+                       strunzone(this.noise);
+               if(this.bgmscript)
+                       strunzone(this.bgmscript);
+               this.noise = strzone(ReadString());
+               if(this.noise != "")
                {
-                       self.atten = ReadByte() / 64.0;
-                       self.volume = ReadByte() / 255.0;
+                       this.atten = ReadByte() / 64.0;
+                       this.volume = ReadByte() / 255.0;
                }
-               self.bgmscript = strzone(ReadString());
-               if(self.bgmscript != "")
+               this.bgmscript = strzone(ReadString());
+               if(this.bgmscript != "")
                {
-                       self.bgmscriptattack = ReadByte() / 64.0;
-                       self.bgmscriptdecay = ReadByte() / 64.0;
-                       self.bgmscriptsustain = ReadByte() / 255.0;
-                       self.bgmscriptrelease = ReadByte() / 64.0;
+                       this.bgmscriptattack = ReadByte() / 64.0;
+                       this.bgmscriptdecay = ReadByte() / 64.0;
+                       this.bgmscriptsustain = ReadByte() / 255.0;
+                       this.bgmscriptrelease = ReadByte() / 64.0;
                }
-               BGMScript_InitEntity(self);
+               BGMScript_InitEntity(this);
        }
 
        return = true;
 
        if(f & 2)
        {
-               self.absolute = (self.impulse >= 0);
-               if(!self.absolute)
+               this.absolute = (this.impulse >= 0);
+               if(!this.absolute)
                {
-                       v = self.maxs - self.mins;
-                       self.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
+                       v = this.maxs - this.mins;
+                       this.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
                }
        }
 
        if(f & 0x10)
-               self.absolute = 2;
+               this.absolute = 2;
 
-       setorigin(self, self.origin);
-       setsize(self, self.mins, self.maxs);
-       self.solid = SOLID_NOT;
-       self.draw = Draw_PointParticles;
-       self.entremove = Ent_PointParticles_Remove;
+       setorigin(this, this.origin);
+       setsize(this, this.mins, this.maxs);
+       this.solid = SOLID_NOT;
+       this.draw = Draw_PointParticles;
+       this.entremove = Ent_PointParticles_Remove;
 }
 #endif
index fc4630318270dfdd44721dd009ccb7184e1a9e6e..1bb1bd47b416fb978f3b8af75ced491357b2ee56 100644 (file)
@@ -4,16 +4,16 @@ REGISTER_NET_LINKED(ENT_CLIENT_RAINSNOW)
 bool rainsnow_SendEntity(entity this, entity to, float sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_RAINSNOW);
-       WriteByte(MSG_ENTITY, self.state);
-       WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
-       WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
-       WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
-       WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
-       WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
-       WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
-       WriteShort(MSG_ENTITY, compressShortVector(self.dest));
-       WriteShort(MSG_ENTITY, self.count);
-       WriteByte(MSG_ENTITY, self.cnt);
+       WriteByte(MSG_ENTITY, this.state);
+       WriteCoord(MSG_ENTITY, this.origin_x + this.mins_x);
+       WriteCoord(MSG_ENTITY, this.origin_y + this.mins_y);
+       WriteCoord(MSG_ENTITY, this.origin_z + this.mins_z);
+       WriteCoord(MSG_ENTITY, this.maxs_x - this.mins_x);
+       WriteCoord(MSG_ENTITY, this.maxs_y - this.mins_y);
+       WriteCoord(MSG_ENTITY, this.maxs_z - this.mins_z);
+       WriteShort(MSG_ENTITY, compressShortVector(this.dest));
+       WriteShort(MSG_ENTITY, this.count);
+       WriteByte(MSG_ENTITY, this.cnt);
        return true;
 }
 
@@ -30,28 +30,28 @@ Keys:
 */
 spawnfunc(func_rain)
 {
-       self.dest = self.velocity;
-       self.velocity = '0 0 0';
-       if (!self.dest)
-               self.dest = '0 0 -700';
-       self.angles = '0 0 0';
-       self.movetype = MOVETYPE_NONE;
-       self.solid = SOLID_NOT;
+       this.dest = this.velocity;
+       this.velocity = '0 0 0';
+       if (!this.dest)
+               this.dest = '0 0 -700';
+       this.angles = '0 0 0';
+       this.movetype = MOVETYPE_NONE;
+       this.solid = SOLID_NOT;
        SetBrushEntityModel();
-       if (!self.cnt)
-               self.cnt = 12;
-       if (!self.count)
-               self.count = 2000;
-       self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
-       if (self.count < 1)
-               self.count = 1;
-       if(self.count > 65535)
-               self.count = 65535;
+       if (!this.cnt)
+               this.cnt = 12;
+       if (!this.count)
+               this.count = 2000;
+       this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
+       if (this.count < 1)
+               this.count = 1;
+       if(this.count > 65535)
+               this.count = 65535;
 
-       self.state = 1; // 1 is rain, 0 is snow
-       self.Version = 1;
+       this.state = 1; // 1 is rain, 0 is snow
+       this.Version = 1;
 
-       Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
+       Net_LinkEntity(this, false, 0, rainsnow_SendEntity);
 }
 
 
@@ -68,28 +68,28 @@ Keys:
 */
 spawnfunc(func_snow)
 {
-       self.dest = self.velocity;
-       self.velocity = '0 0 0';
-       if (!self.dest)
-               self.dest = '0 0 -300';
-       self.angles = '0 0 0';
-       self.movetype = MOVETYPE_NONE;
-       self.solid = SOLID_NOT;
+       this.dest = this.velocity;
+       this.velocity = '0 0 0';
+       if (!this.dest)
+               this.dest = '0 0 -300';
+       this.angles = '0 0 0';
+       this.movetype = MOVETYPE_NONE;
+       this.solid = SOLID_NOT;
        SetBrushEntityModel();
-       if (!self.cnt)
-               self.cnt = 12;
-       if (!self.count)
-               self.count = 2000;
-       self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
-       if (self.count < 1)
-               self.count = 1;
-       if(self.count > 65535)
-               self.count = 65535;
+       if (!this.cnt)
+               this.cnt = 12;
+       if (!this.count)
+               this.count = 2000;
+       this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
+       if (this.count < 1)
+               this.count = 1;
+       if(this.count > 65535)
+               this.count = 65535;
 
-       self.state = 0; // 1 is rain, 0 is snow
-       self.Version = 1;
+       this.state = 0; // 1 is rain, 0 is snow
+       this.Version = 1;
 
-       Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
+       Net_LinkEntity(this, false, 0, rainsnow_SendEntity);
 }
 #elif defined(CSQC)
 void Draw_Rain(entity this)
@@ -104,29 +104,29 @@ void Draw_Snow(entity this)
 
 NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
 {
-       self.impulse = ReadByte(); // Rain, Snow, or Whatever
-       self.origin_x = ReadCoord();
-       self.origin_y = ReadCoord();
-       self.origin_z = ReadCoord();
-       self.maxs_x = ReadCoord();
-       self.maxs_y = ReadCoord();
-       self.maxs_z = ReadCoord();
-       self.velocity = decompressShortVector(ReadShort());
-       self.count = ReadShort() * 10;
-       self.glow_color = ReadByte(); // color
+       this.impulse = ReadByte(); // Rain, Snow, or Whatever
+       this.origin_x = ReadCoord();
+       this.origin_y = ReadCoord();
+       this.origin_z = ReadCoord();
+       this.maxs_x = ReadCoord();
+       this.maxs_y = ReadCoord();
+       this.maxs_z = ReadCoord();
+       this.velocity = decompressShortVector(ReadShort());
+       this.count = ReadShort() * 10;
+       this.glow_color = ReadByte(); // color
 
        return = true;
 
-       self.mins    = -0.5 * self.maxs;
-       self.maxs    =  0.5 * self.maxs;
-       self.origin  = self.origin - self.mins;
+       this.mins    = -0.5 * this.maxs;
+       this.maxs    =  0.5 * this.maxs;
+       this.origin  = this.origin - this.mins;
 
-       setorigin(self, self.origin);
-       setsize(self, self.mins, self.maxs);
-       self.solid = SOLID_NOT;
-       if(self.impulse)
-               self.draw = Draw_Rain;
+       setorigin(this, this.origin);
+       setsize(this, this.mins, this.maxs);
+       this.solid = SOLID_NOT;
+       if(this.impulse)
+               this.draw = Draw_Rain;
        else
-               self.draw = Draw_Snow;
+               this.draw = Draw_Snow;
 }
 #endif
index 3f481ae78f4d30ec5dff0c2394efca09bf8717c1..f34d41e2b02af8737d31d8c7e701de75dbe047e6 100644 (file)
@@ -27,49 +27,49 @@ dmgtime : See above.
 
 spawnfunc(func_rotating)
 {
-       if (self.noise != "")
+       if (this.noise != "")
        {
-               precache_sound(self.noise);
-               ambientsound(self.origin, self.noise, VOL_BASE, ATTEN_IDLE);
+               precache_sound(this.noise);
+               ambientsound(this.origin, this.noise, VOL_BASE, ATTEN_IDLE);
        }
 
-       self.active = ACTIVE_ACTIVE;
-       self.setactive = func_rotating_setactive;
+       this.active = ACTIVE_ACTIVE;
+       this.setactive = func_rotating_setactive;
 
-       if (!self.speed)
-               self.speed = 100;
+       if (!this.speed)
+               this.speed = 100;
        // FIXME: test if this turns the right way, then remove this comment (negate as needed)
-       if (self.spawnflags & 4) // X (untested)
-               self.avelocity = '0 0 1' * self.speed;
+       if (this.spawnflags & 4) // X (untested)
+               this.avelocity = '0 0 1' * this.speed;
        // FIXME: test if this turns the right way, then remove this comment (negate as needed)
-       else if (self.spawnflags & 8) // Y (untested)
-               self.avelocity = '1 0 0' * self.speed;
+       else if (this.spawnflags & 8) // Y (untested)
+               this.avelocity = '1 0 0' * this.speed;
        // FIXME: test if this turns the right way, then remove this comment (negate as needed)
        else // Z
-               self.avelocity = '0 1 0' * self.speed;
+               this.avelocity = '0 1 0' * this.speed;
 
-       self.pos1 = self.avelocity;
+       this.pos1 = this.avelocity;
 
-    if(self.dmg && (self.message == ""))
-        self.message = " was squished";
-    if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
+    if(this.dmg && (this.message == ""))
+        this.message = " was squished";
+    if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
 
 
-    if(self.dmg && (!self.dmgtime))
-        self.dmgtime = 0.25;
+    if(this.dmg && (!this.dmgtime))
+        this.dmgtime = 0.25;
 
-    self.dmgtime2 = time;
+    this.dmgtime2 = time;
 
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
        // no EF_LOWPRECISION here, as rounding angles is bad
 
-    self.blocked = generic_plat_blocked;
+    this.blocked = generic_plat_blocked;
 
        // wait for targets to spawn
-       self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
-       self.SUB_THINK = SUB_NullThink; // for PushMove
+       this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+       SUB_THINK(this, SUB_NullThink); // for PushMove
 
        // TODO make a reset function for this one
 }
index 859cdf53df00517d0f9c45cd56d5d6464dacc5d4..db5081b61b474659b09a7f98f0cd58742d98f86f 100644 (file)
@@ -1,8 +1,8 @@
 #ifdef SVQC
 spawnfunc(func_stardust)
 {
-       self.effects = EF_STARDUST;
+       this.effects = EF_STARDUST;
 
-       CSQCMODEL_AUTOINIT(self);
+       CSQCMODEL_AUTOINIT(this);
 }
 #endif
index 013d4597fb8bf73d36773c00494a1887f41b7b61..9c73e2b80b561d77235a122c6bd52dd8cdcd9752 100644 (file)
@@ -1,10 +1,10 @@
 .float train_wait_turning;
-void() train_next;
+void train_next(entity this);
 #ifdef SVQC
 void train_use(entity this, entity actor, entity trigger);
 #endif
-void train_wait()
-{SELFPARAM();
+void train_wait(entity this)
+{
        SUB_UseTargets(this.enemy, NULL, NULL);
        self.enemy = world;
 
@@ -44,7 +44,7 @@ void train_wait()
        if(tg.spawnflags & 4)
        {
                self.use = train_use;
-               self.SUB_THINK = func_null;
+               SUB_THINK(self, func_null);
                self.SUB_NEXTTHINK = 0;
        }
        else
@@ -52,17 +52,17 @@ void train_wait()
             if(self.wait < 0 || self.train_wait_turning) // no waiting or we already waited while turning
        {
                self.train_wait_turning = false;
-               train_next();
+               train_next(self);
        }
        else
        {
-               self.SUB_THINK = train_next;
+               SUB_THINK(self, train_next);
                self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
        }
 }
 
-void train_next()
-{SELFPARAM();
+void train_next(entity this)
+{
        entity targ, cp = world;
        vector cp_org = '0 0 0';
 
@@ -179,7 +179,7 @@ void train_link()
 void train_use(entity this, entity actor, entity trigger)
 {
        this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
-       this.SUB_THINK = train_next;
+       SUB_THINK(this, train_next);
        this.use = func_null; // not again
 }
 
@@ -195,7 +195,7 @@ void func_train_find(entity this)
        if(!(self.spawnflags & 4))
        {
                self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
-               self.SUB_THINK = train_next;
+               SUB_THINK(self, train_next);
        }
 
        train_link();
@@ -211,45 +211,45 @@ target : targetname of first spawnfunc_path_corner (starts here)
 #ifdef SVQC
 spawnfunc(func_train)
 {
-       if (self.noise != "")
-               precache_sound(self.noise);
+       if (this.noise != "")
+               precache_sound(this.noise);
 
-       if (self.target == "")
+       if (this.target == "")
                objerror("func_train without a target");
-       if (!self.speed)
-               self.speed = 100;
+       if (!this.speed)
+               this.speed = 100;
 
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
-       self.effects |= EF_LOWPRECISION;
+       this.effects |= EF_LOWPRECISION;
 
-       if(self.spawnflags & 4)
-               self.use = train_use;
+       if(this.spawnflags & 4)
+               this.use = train_use;
 
-       if (self.spawnflags & 2)
+       if (this.spawnflags & 2)
        {
-               self.platmovetype_turn = true;
-               self.view_ofs = '0 0 0'; // don't offset a rotating train, origin works differently now
+               this.platmovetype_turn = true;
+               this.view_ofs = '0 0 0'; // don't offset a rotating train, origin works differently now
        }
        else
-               self.view_ofs = self.mins;
+               this.view_ofs = this.mins;
 
        // wait for targets to spawn
-       InitializeEntity(self, func_train_find, INITPRIO_FINDTARGET);
-
-       self.blocked = generic_plat_blocked;
-       if(self.dmg && (self.message == ""))
-               self.message = " was squished";
-    if(self.dmg && (self.message2 == ""))
-               self.message2 = "was squished by";
-       if(self.dmg && (!self.dmgtime))
-               self.dmgtime = 0.25;
-       self.dmgtime2 = time;
-
-       if(!set_platmovetype(self, self.platmovetype))
+       InitializeEntity(this, func_train_find, INITPRIO_FINDTARGET);
+
+       this.blocked = generic_plat_blocked;
+       if(this.dmg && (this.message == ""))
+               this.message = " was squished";
+    if(this.dmg && (this.message2 == ""))
+               this.message2 = "was squished by";
+       if(this.dmg && (!this.dmgtime))
+               this.dmgtime = 0.25;
+       this.dmgtime2 = time;
+
+       if(!set_platmovetype(this, this.platmovetype))
                return;
-       self.platmovetype_start_default = self.platmovetype_start;
-       self.platmovetype_end_default = self.platmovetype_end;
+       this.platmovetype_start_default = this.platmovetype_start;
+       this.platmovetype_end_default = this.platmovetype_end;
 
        // TODO make a reset function for this one
 }
@@ -266,70 +266,70 @@ NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew)
 
        if(sf & SF_TRIGGER_INIT)
        {
-               self.platmovetype = strzone(ReadString());
-               self.platmovetype_turn = ReadByte();
-               self.spawnflags = ReadByte();
+               this.platmovetype = strzone(ReadString());
+               this.platmovetype_turn = ReadByte();
+               this.spawnflags = ReadByte();
 
-               self.model = strzone(ReadString());
-               _setmodel(self, self.model);
+               this.model = strzone(ReadString());
+               _setmodel(this, this.model);
 
-               trigger_common_read(true);
+               trigger_common_read(this, true);
 
-               self.curvetarget = strzone(ReadString());
+               this.curvetarget = strzone(ReadString());
 
-               self.pos1_x = ReadCoord();
-               self.pos1_y = ReadCoord();
-               self.pos1_z = ReadCoord();
-               self.pos2_x = ReadCoord();
-               self.pos2_y = ReadCoord();
-               self.pos2_z = ReadCoord();
+               this.pos1_x = ReadCoord();
+               this.pos1_y = ReadCoord();
+               this.pos1_z = ReadCoord();
+               this.pos2_x = ReadCoord();
+               this.pos2_y = ReadCoord();
+               this.pos2_z = ReadCoord();
 
-               self.size_x = ReadCoord();
-               self.size_y = ReadCoord();
-               self.size_z = ReadCoord();
+               this.size_x = ReadCoord();
+               this.size_y = ReadCoord();
+               this.size_z = ReadCoord();
 
-               self.view_ofs_x = ReadCoord();
-               self.view_ofs_y = ReadCoord();
-               self.view_ofs_z = ReadCoord();
+               this.view_ofs_x = ReadCoord();
+               this.view_ofs_y = ReadCoord();
+               this.view_ofs_z = ReadCoord();
 
-               self.mangle_x = ReadAngle();
-               self.mangle_y = ReadAngle();
-               self.mangle_z = ReadAngle();
+               this.mangle_x = ReadAngle();
+               this.mangle_y = ReadAngle();
+               this.mangle_z = ReadAngle();
 
-               self.speed = ReadShort();
-               self.height = ReadShort();
-               self.lip = ReadByte();
-               self.state = ReadByte();
-               self.wait = ReadByte();
+               this.speed = ReadShort();
+               this.height = ReadShort();
+               this.lip = ReadByte();
+               this.state = ReadByte();
+               this.wait = ReadByte();
 
-               self.dmg = ReadShort();
-               self.dmgtime = ReadByte();
+               this.dmg = ReadShort();
+               this.dmgtime = ReadByte();
 
-               self.classname = "func_train";
-               self.solid = SOLID_BSP;
-               self.movetype = MOVETYPE_PUSH;
-               self.drawmask = MASK_NORMAL;
-               self.draw = train_draw;
-               self.entremove = trigger_remove_generic;
+               this.classname = "func_train";
+               this.solid = SOLID_BSP;
+               this.movetype = MOVETYPE_PUSH;
+               this.drawmask = MASK_NORMAL;
+               this.draw = train_draw;
+               this.entremove = trigger_remove_generic;
 
-               if(set_platmovetype(self, self.platmovetype))
+               if(set_platmovetype(this, this.platmovetype))
                {
-                       self.platmovetype_start_default = self.platmovetype_start;
-                       self.platmovetype_end_default = self.platmovetype_end;
+                       this.platmovetype_start_default = this.platmovetype_start;
+                       this.platmovetype_end_default = this.platmovetype_end;
                }
 
                // everything is set up by the time the train is linked, we shouldn't need this
                //func_train_find();
 
                // but we will need these
-               //self.move_nextthink = self.move_ltime + 0.1;
-               //self.move_think = train_next;
-               train_next();
-
-               self.move_movetype = MOVETYPE_PUSH;
-               self.move_origin = self.origin;
-               self.move_angles = self.angles;
-               self.move_time = time;
+               //this.move_nextthink = this.move_ltime + 0.1;
+               //this.move_think = train_next;
+               WITHSELF(this, train_next(this));
+
+               this.move_movetype = MOVETYPE_PUSH;
+               this.move_origin = this.origin;
+               this.move_angles = this.angles;
+               this.move_time = time;
        }
 
        if(sf & SF_TRIGGER_RESET)
index 2dfa1ac98f9817d4b4cc07b1d245416db3ca00ee..b3e931b3a364f66f7e5389a396dc9fdde2aa3111 100644 (file)
@@ -57,8 +57,8 @@ vector func_vectormamamam_origin(entity o, float t)
        return v;
 }
 
-void func_vectormamamam_controller_think()
-{SELFPARAM();
+void func_vectormamamam_controller_think(entity this)
+{
        self.nextthink = time + 0.1;
 
        if(self.owner.active != ACTIVE_ACTIVE)
@@ -73,86 +73,86 @@ void func_vectormamamam_controller_think()
 
 void func_vectormamamam_findtarget(entity this)
 {
-       if(self.target != "")
-               self.wp00 = find(world, targetname, self.target);
+       if(this.target != "")
+               this.wp00 = find(world, targetname, this.target);
 
-       if(self.target2 != "")
-               self.wp01 = find(world, targetname, self.target2);
+       if(this.target2 != "")
+               this.wp01 = find(world, targetname, this.target2);
 
-       if(self.target3 != "")
-               self.wp02 = find(world, targetname, self.target3);
+       if(this.target3 != "")
+               this.wp02 = find(world, targetname, this.target3);
 
-       if(self.target4 != "")
-               self.wp03 = find(world, targetname, self.target4);
+       if(this.target4 != "")
+               this.wp03 = find(world, targetname, this.target4);
 
-       if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03)
+       if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
                objerror("No reference entity found, so there is nothing to move. Aborting.");
 
-       self.destvec = self.origin - func_vectormamamam_origin(self, 0);
+       this.destvec = this.origin - func_vectormamamam_origin(this, 0);
 
        entity controller;
        controller = new(func_vectormamamam_controller);
-       controller.owner = self;
+       controller.owner = this;
        controller.nextthink = time + 1;
-       controller.think = func_vectormamamam_controller_think;
+       setthink(controller, func_vectormamamam_controller_think);
 }
 
 spawnfunc(func_vectormamamam)
 {
-       if (self.noise != "")
+       if (this.noise != "")
        {
-               precache_sound(self.noise);
-               soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+               precache_sound(this.noise);
+               soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
        }
 
-       if(!self.targetfactor)
-               self.targetfactor = 1;
+       if(!this.targetfactor)
+               this.targetfactor = 1;
 
-       if(!self.target2factor)
-               self.target2factor = 1;
+       if(!this.target2factor)
+               this.target2factor = 1;
 
-       if(!self.target3factor)
-               self.target3factor = 1;
+       if(!this.target3factor)
+               this.target3factor = 1;
 
-       if(!self.target4factor)
-               self.target4factor = 1;
+       if(!this.target4factor)
+               this.target4factor = 1;
 
-       if(vlen(self.targetnormal))
-               self.targetnormal = normalize(self.targetnormal);
+       if(vlen(this.targetnormal))
+               this.targetnormal = normalize(this.targetnormal);
 
-       if(vlen(self.target2normal))
-               self.target2normal = normalize(self.target2normal);
+       if(vlen(this.target2normal))
+               this.target2normal = normalize(this.target2normal);
 
-       if(vlen(self.target3normal))
-               self.target3normal = normalize(self.target3normal);
+       if(vlen(this.target3normal))
+               this.target3normal = normalize(this.target3normal);
 
-       if(vlen(self.target4normal))
-               self.target4normal = normalize(self.target4normal);
+       if(vlen(this.target4normal))
+               this.target4normal = normalize(this.target4normal);
 
-       self.blocked = generic_plat_blocked;
-       if(self.dmg && (self.message == ""))
-               self.message = " was squished";
-    if(self.dmg && (self.message == ""))
-               self.message2 = "was squished by";
-       if(self.dmg && (!self.dmgtime))
-               self.dmgtime = 0.25;
-       self.dmgtime2 = time;
+       this.blocked = generic_plat_blocked;
+       if(this.dmg && (this.message == ""))
+               this.message = " was squished";
+    if(this.dmg && (this.message == ""))
+               this.message2 = "was squished by";
+       if(this.dmg && (!this.dmgtime))
+               this.dmgtime = 0.25;
+       this.dmgtime2 = time;
 
-       if(self.netname == "")
-               self.netname = "1 0 0 0 1";
+       if(this.netname == "")
+               this.netname = "1 0 0 0 1";
 
-       if (!InitMovingBrushTrigger())
+       if (!InitMovingBrushTrigger(this))
                return;
 
        // wait for targets to spawn
-       self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
-       self.SUB_THINK = SUB_NullThink; // for PushMove
+       this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
+       SUB_THINK(this, SUB_NullThink); // for PushMove
 
        // Savage: Reduce bandwith, critical on e.g. nexdm02
-       self.effects |= EF_LOWPRECISION;
+       this.effects |= EF_LOWPRECISION;
 
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
-       InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
+       InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
 }
 #endif
index d081807bccb3072bcf466c74efb003d8f7346e45..38772a295562e09ec2138f05f7e54dec1a445e79 100644 (file)
@@ -1,40 +1,40 @@
 REGISTER_NET_LINKED(ENT_CLIENT_CORNER)
 
 #ifdef SVQC
-bool corner_send(entity to, int sf)
-{SELFPARAM();
+bool corner_send(entity this, entity to, int sf)
+{
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CORNER);
 
-       WriteString(MSG_ENTITY, self.platmovetype);
+       WriteString(MSG_ENTITY, this.platmovetype);
 
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       WriteCoord(MSG_ENTITY, this.origin_x);
+       WriteCoord(MSG_ENTITY, this.origin_y);
+       WriteCoord(MSG_ENTITY, this.origin_z);
 
-       WriteString(MSG_ENTITY, self.target);
-       WriteString(MSG_ENTITY, self.target2);
-       WriteString(MSG_ENTITY, self.target3);
-       WriteString(MSG_ENTITY, self.target4);
-       WriteString(MSG_ENTITY, self.targetname);
-       WriteByte(MSG_ENTITY, self.target_random);
+       WriteString(MSG_ENTITY, this.target);
+       WriteString(MSG_ENTITY, this.target2);
+       WriteString(MSG_ENTITY, this.target3);
+       WriteString(MSG_ENTITY, this.target4);
+       WriteString(MSG_ENTITY, this.targetname);
+       WriteByte(MSG_ENTITY, this.target_random);
 
-       WriteByte(MSG_ENTITY, self.wait);
+       WriteByte(MSG_ENTITY, this.wait);
 
        return true;
 }
 
-void corner_link()
+void corner_link(entity this)
 {
-       //Net_LinkEntity(self, false, 0, corner_send);
+       //Net_LinkEntity(this, false, 0, corner_send);
 }
 
 spawnfunc(path_corner)
 {
        // setup values for overriding train movement
        // if a second value does not exist, both start and end speeds are the single value specified
-       set_platmovetype(self, self.platmovetype);
+       set_platmovetype(this, this.platmovetype);
 
-       corner_link();
+       corner_link(this);
 }
 #elif defined(CSQC)
 
@@ -61,29 +61,29 @@ void corner_remove(entity this)
 
 NET_HANDLE(ENT_CLIENT_CORNER, bool isnew)
 {
-       self.platmovetype = strzone(ReadString());
+       this.platmovetype = strzone(ReadString());
 
-       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);
 
-       self.target = strzone(ReadString());
-       self.target2 = strzone(ReadString());
-       self.target3 = strzone(ReadString());
-       self.target4 = strzone(ReadString());
-       self.targetname = strzone(ReadString());
-       self.target_random = ReadByte();
+       this.target = strzone(ReadString());
+       this.target2 = strzone(ReadString());
+       this.target3 = strzone(ReadString());
+       this.target4 = strzone(ReadString());
+       this.targetname = strzone(ReadString());
+       this.target_random = ReadByte();
 
-       self.wait = ReadByte();
+       this.wait = ReadByte();
 
        return = true;
 
-       self.classname = "path_corner";
-       self.drawmask = MASK_NORMAL;
-       self.entremove = corner_remove;
+       this.classname = "path_corner";
+       this.drawmask = MASK_NORMAL;
+       this.entremove = corner_remove;
 
-       set_platmovetype(self, self.platmovetype);
+       set_platmovetype(this, this.platmovetype);
 }
 
 #endif
index 2ac304a212d08fbfaa28183353538040cee7716f..dbe1cb7d8c0013aee51a65788547def7624610b3 100644 (file)
@@ -6,10 +6,10 @@ void follow_init(entity this)
        entity src, dst;
        src = world;
        dst = world;
-       if(self.killtarget != "")
-               src = find(world, targetname, self.killtarget);
-       if(self.target != "")
-               dst = find(world, targetname, self.target);
+       if(this.killtarget != "")
+               src = find(world, targetname, this.killtarget);
+       if(this.target != "")
+               dst = find(world, targetname, this.target);
 
        if(!src && !dst)
        {
@@ -17,35 +17,35 @@ void follow_init(entity this)
                return;
        }
 
-       if(self.jointtype)
+       if(this.jointtype)
        {
                // already done :P entity must stay
-               self.aiment = src;
-               self.enemy = dst;
+               this.aiment = src;
+               this.enemy = dst;
        }
        else if(!src || !dst)
        {
                objerror("follow: could not find target/killtarget");
                return;
        }
-       else if(self.spawnflags & 1)
+       else if(this.spawnflags & 1)
        {
                // attach
-               if(self.spawnflags & 2)
+               if(this.spawnflags & 2)
                {
-                       setattachment(dst, src, self.message);
+                       setattachment(dst, src, this.message);
                }
                else
                {
-                       attach_sameorigin(dst, src, self.message);
+                       attach_sameorigin(dst, src, this.message);
                }
 
                dst.solid = SOLID_NOT; // solid doesn't work with attachment
-               remove(self);
+               remove(this);
        }
        else
        {
-               if(self.spawnflags & 2)
+               if(this.spawnflags & 2)
                {
                        dst.movetype = MOVETYPE_FOLLOW;
                        dst.aiment = src;
@@ -58,12 +58,12 @@ void follow_init(entity this)
                        follow_sameorigin(dst, src);
                }
 
-               remove(self);
+               remove(this);
        }
 }
 
 spawnfunc(misc_follow)
 {
-       InitializeEntity(self, follow_init, INITPRIO_FINDTARGET);
+       InitializeEntity(this, follow_init, INITPRIO_FINDTARGET);
 }
 #endif
index 6e589eddf04bf4da822ce56e56699b7d3d79ed89..f0aafc7c40e5d06238324f87b0eb6d14dec518bb 100644 (file)
@@ -56,8 +56,8 @@ void misc_laser_init(entity this)
 }
 
 .entity pusher;
-void misc_laser_think()
-{SELFPARAM();
+void misc_laser_think(entity this)
+{
        vector o;
        entity hitent;
        vector hitloc;
@@ -232,7 +232,7 @@ spawnfunc(misc_laser)
        if(!this.scale) this.scale = 1;
        if(!this.modelscale) this.modelscale = 1;
        else if(this.modelscale < 0) this.modelscale = 0;
-       this.think = misc_laser_think;
+       setthink(this, misc_laser_think);
        this.nextthink = time;
        InitializeEntity(this, misc_laser_init, INITPRIO_FINDTARGET);
 
@@ -317,65 +317,65 @@ void Draw_Laser(entity this)
 
 NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
 {
-       InterpolateOrigin_Undo(self);
+       InterpolateOrigin_Undo(this);
 
        // 30 bytes, or 13 bytes for just moving
        int f = ReadByte();
-       self.count = (f & 0xF0);
+       this.count = (f & 0xF0);
 
-       if(self.count & 0x80)
-               self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+       if(this.count & 0x80)
+               this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
        else
-               self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
+               this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
 
        if(f & 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(f & 8)
        {
-               self.colormod_x = ReadByte() / 255.0;
-               self.colormod_y = ReadByte() / 255.0;
-               self.colormod_z = ReadByte() / 255.0;
+               this.colormod_x = ReadByte() / 255.0;
+               this.colormod_y = ReadByte() / 255.0;
+               this.colormod_z = ReadByte() / 255.0;
                if(f & 0x40)
-                       self.alpha = ReadByte() / 255.0;
+                       this.alpha = ReadByte() / 255.0;
                else
-                       self.alpha = 0;
-               self.scale = 2;
-               self.modelscale = 50;
+                       this.alpha = 0;
+               this.scale = 2;
+               this.modelscale = 50;
                if(f & 0x20)
                {
-                       self.scale *= ReadByte() / 16.0; // beam radius
-                       self.modelscale *= ReadByte() / 16.0; // dlight radius
+                       this.scale *= ReadByte() / 16.0; // beam radius
+                       this.modelscale *= ReadByte() / 16.0; // dlight radius
                }
                if((f & 0x80) || !(f & 0x10))
-                       self.cnt = ReadShort() - 1; // effect number
+                       this.cnt = ReadShort() - 1; // effect number
                else
-                       self.cnt = 0;
+                       this.cnt = 0;
        }
        if(f & 2)
        {
                if(f & 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();
                }
                else
                {
-                       self.angles_x = ReadAngle();
-                       self.angles_y = ReadAngle();
+                       this.angles_x = ReadAngle();
+                       this.angles_y = ReadAngle();
                }
        }
        if(f & 4)
-               self.state = ReadByte();
+               this.state = ReadByte();
 
        return = true;
 
        InterpolateOrigin_Note(this);
-       self.draw = Draw_Laser;
+       this.draw = Draw_Laser;
 }
 #endif
index 33401930d8d929c836ee4f16273ae5aa6d90d669..b3a242076a28b49e6406237ef33ad911adce0563 100644 (file)
@@ -24,21 +24,21 @@ bool teleport_dest_send(entity this, entity to, int sf)
        return true;
 }
 
-void teleport_dest_link()
-{SELFPARAM();
-       Net_LinkEntity(self, false, 0, teleport_dest_send);
-       self.SendFlags |= 1; // update
+void teleport_dest_link(entity this)
+{
+       Net_LinkEntity(this, false, 0, teleport_dest_send);
+       this.SendFlags |= 1; // update
 }
 
 spawnfunc(info_teleport_destination)
 {
-       self.classname = "info_teleport_destination";
+       this.classname = "info_teleport_destination";
 
-       self.mangle = self.angles;
-       self.angles = '0 0 0';
+       this.mangle = this.angles;
+       this.angles = '0 0 0';
 
-       //setorigin (self, self.origin + '0 0 27');     // To fix a mappers' habit as old as Quake
-       setorigin (self, self.origin);
+       //setorigin (this, this.origin + '0 0 27');     // To fix a mappers' habit as old as Quake
+       setorigin (this, this.origin);
 
        IFTARGETED
        {
@@ -46,7 +46,7 @@ spawnfunc(info_teleport_destination)
        else
                objerror ("^3Teleport destination without a targetname");
 
-       teleport_dest_link();
+       teleport_dest_link(this);
 }
 
 spawnfunc(misc_teleporter_dest)
@@ -63,9 +63,9 @@ spawnfunc(target_teleporter)
 
 void teleport_dest_remove(entity this)
 {
-       //if(self.classname)
-               //strunzone(self.classname);
-       //self.classname = string_null;
+       //if(this.classname)
+               //strunzone(this.classname);
+       //this.classname = string_null;
 
        if(this.targetname)
                strunzone(this.targetname);
@@ -78,22 +78,22 @@ NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
 
        if(sf & 1)
        {
-               self.classname = "info_teleport_destination";
-               self.cnt = ReadByte();
-               self.speed = ReadCoord();
-               self.targetname = strzone(ReadString());
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-
-               self.mangle_x = ReadAngle();
-               self.mangle_y = ReadAngle();
-               self.mangle_z = ReadAngle();
-
-               setorigin(self, self.origin);
-
-               self.drawmask = MASK_NORMAL;
-               self.entremove = teleport_dest_remove;
+               this.classname = "info_teleport_destination";
+               this.cnt = ReadByte();
+               this.speed = ReadCoord();
+               this.targetname = strzone(ReadString());
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+
+               this.mangle_x = ReadAngle();
+               this.mangle_y = ReadAngle();
+               this.mangle_z = ReadAngle();
+
+               setorigin(this, this.origin);
+
+               this.drawmask = MASK_NORMAL;
+               this.entremove = teleport_dest_remove;
        }
 
        return = true;
index 7429f2b3550bfbf95db857da277f7b9f45d8d5fc..7b583f1d3d370545b900505b40167cadb966c2e3 100644 (file)
@@ -23,17 +23,11 @@ void plat_spawn_inside_trigger()
        vector tmin, tmax;
 
        trigger = spawn();
-       trigger.touch = plat_center_touch;
+       settouch(trigger, plat_center_touch);
        trigger.movetype = MOVETYPE_NONE;
        trigger.solid = SOLID_TRIGGER;
        trigger.enemy = self;
 
-#ifdef CSQC
-       trigger.drawmask = MASK_NORMAL;
-       trigger.trigger_touch = plat_center_touch;
-       trigger.draw = trigger_draw_generic;
-#endif
-
        tmin = self.absmin + '25 25 0';
        tmax = self.absmax - '25 25 -8';
        tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
@@ -64,23 +58,23 @@ void plat_spawn_inside_trigger()
        objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
 }
 
-void plat_hit_top()
-{SELFPARAM();
+void plat_hit_top(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 1;
 
-       self.SUB_THINK = plat_go_down;
+       SUB_THINK(self, plat_go_down);
        self.SUB_NEXTTHINK = self.SUB_LTIME + 3;
 }
 
-void plat_hit_bottom()
-{SELFPARAM();
+void plat_hit_bottom(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 2;
 }
 
-void plat_go_down()
-{SELFPARAM();
+void plat_go_down(entity this)
+{
        _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 3;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
@@ -93,8 +87,8 @@ void plat_go_up()
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
 }
 
-void plat_center_touch()
-{SELFPARAM();
+void plat_center_touch(entity this)
+{
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -108,15 +102,14 @@ void plat_center_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 2)
-               plat_go_up ();
-       else if (self.state == 1)
-               self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
+       if (self.enemy.state == 2)
+               WITHSELF(self.enemy, plat_go_up());
+       else if (self.enemy.state == 1)
+               self.enemy.SUB_NEXTTHINK = self.enemy.SUB_LTIME + 1;
 }
 
-void plat_outside_touch()
-{SELFPARAM();
+void plat_outside_touch(entity this)
+{
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -128,21 +121,22 @@ void plat_outside_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 1)
-               plat_go_down ();
+       if (self.enemy.state == 1) {
+           entity e = self.enemy;
+               WITHSELF(e, plat_go_down(e));
+    }
 }
 
 void plat_trigger_use(entity this, entity actor, entity trigger)
 {
 #ifdef SVQC
-       if (this.think)
+       if (getthink(this))
                return;         // already activated
 #elif defined(CSQC)
        if(this.move_think)
                return;
 #endif
-       WITHSELF(this, plat_go_down());
+       WITHSELF(this, plat_go_down(this));
 }
 
 
@@ -167,7 +161,7 @@ void plat_crush()
 #endif
 
                if (self.state == 4)
-                       plat_go_down ();
+                       plat_go_down (self);
                else if (self.state == 3)
                        plat_go_up ();
        // when in other states, then the plat_crush event came delayed after
@@ -181,7 +175,7 @@ void plat_use(entity this, entity actor, entity trigger)
        this.use = func_null;
        if (this.state != 4)
                objerror ("plat_use: not in up state");
-       WITHSELF(this, plat_go_down());
+       WITHSELF(this, plat_go_down(this));
 }
 
 .string sound1, sound2;
index 9a32e327a23fd324d2a21c34bf0a136c38f65dba..f73da630fd0cd174ec27c04b2a7825931ff76e1d 100644 (file)
@@ -3,11 +3,11 @@
 
 .float dmgtime2;
 
-void() plat_center_touch;
-void() plat_outside_touch;
+void plat_center_touch(entity this);
+void plat_outside_touch(entity this);
 void plat_trigger_use(entity this, entity actor, entity trigger);
 void() plat_go_up;
-void() plat_go_down;
+void plat_go_down(entity this);
 void() plat_crush;
 const float PLAT_LOW_TRIGGER = 1;
 
index 7d6ea9de981ce038ea9d9603e6cd1258e00946f1..c2be7c72d925ecd12176b44d56ab3423354ae5c2 100644 (file)
@@ -1,7 +1,7 @@
-void SUB_NullThink() { }
+void SUB_NullThink(entity this) { }
 
-void()  SUB_CalcMoveDone;
-void() SUB_CalcAngleMoveDone;
+void SUB_CalcMoveDone(entity this);
+void SUB_CalcAngleMoveDone(entity this);
 
 /*
 ==================
@@ -44,11 +44,11 @@ void SUB_VanishOrRemove (entity ent)
        }
 }
 
-void SUB_SetFade_Think ()
-{SELFPARAM();
+void SUB_SetFade_Think (entity this)
+{
        if(this.alpha == 0)
                this.alpha = 1;
-       this.SUB_THINK = SUB_SetFade_Think;
+       SUB_THINK(this, SUB_SetFade_Think);
        this.SUB_NEXTTHINK = time;
        this.alpha -= frametime * this.fade_rate;
        if (this.alpha < 0.01)
@@ -67,7 +67,7 @@ Fade 'ent' out when time >= 'when'
 void SUB_SetFade (entity ent, float when, float fading_time)
 {
        ent.fade_rate = 1/fading_time;
-       ent.SUB_THINK = SUB_SetFade_Think;
+       SUB_THINK(ent, SUB_SetFade_Think);
        ent.SUB_NEXTTHINK = when;
 }
 
@@ -79,21 +79,20 @@ calculate self.SUB_VELOCITY and self.SUB_NEXTTHINK to reach dest from
 self.SUB_ORIGIN traveling at speed
 ===============
 */
-void SUB_CalcMoveDone ()
-{SELFPARAM();
+void SUB_CalcMoveDone(entity this)
+{
        // After moving, set origin to exact final destination
 
        SUB_SETORIGIN (self, self.finaldest);
        self.SUB_VELOCITY = '0 0 0';
        self.SUB_NEXTTHINK = -1;
        if (self.think1)
-               self.think1 ();
+               self.think1 (self);
 }
 
 .float platmovetype_turn;
-void SUB_CalcMove_controller_think ()
-{SELFPARAM();
-       entity oldself;
+void SUB_CalcMove_controller_think (entity this)
+{
        float traveltime;
        float phasepos;
        float nexttick;
@@ -143,11 +142,10 @@ void SUB_CalcMove_controller_think ()
        else
        {
                // derivative: delta + 2 * delta2 (e.g. for angle positioning)
-               oldself = self;
-               self.owner.SUB_THINK = self.think1;
-               setself(self.owner);
-               remove(oldself);
-               self.SUB_THINK();
+               entity own = self.owner;
+               SUB_THINK(own, self.think1);
+               remove(self);
+               WITHSELF(own, SUB_THUNK(own)(own));
        }
 }
 
@@ -185,7 +183,7 @@ float TSPEED_START = 1;
 float TSPEED_END = 2;
 // TODO average too?
 
-void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func)
+void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
 {SELFPARAM();
        float   traveltime;
        entity controller;
@@ -195,7 +193,7 @@ void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float
 
        self.think1 = func;
        self.finaldest = tdest;
-       self.SUB_THINK = SUB_CalcMoveDone;
+       SUB_THINK(self, SUB_CalcMoveDone);
 
        switch(tspeedtype)
        {
@@ -230,20 +228,18 @@ void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float
        controller.finaldest = (tdest + '0 0 0.125'); // where do we want to end? Offset to overshoot a bit.
        controller.animstate_starttime = time;
        controller.animstate_endtime = time + traveltime;
-       controller.think = SUB_CalcMove_controller_think;
-       controller.think1 = self.SUB_THINK;
+       setthink(controller, SUB_CalcMove_controller_think);
+       controller.think1 = SUB_THUNK(self);
 
        // the thinking is now done by the controller
-       self.SUB_THINK = SUB_NullThink; // for PushMove
+       SUB_THINK(self, SUB_NullThink); // for PushMove
        self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
 
        // invoke controller
-       setself(controller);
-       self.think();
-       setself(self.owner);
+       WITHSELF(controller, getthink(controller)(controller));
 }
 
-void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
+void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void(entity this) func)
 {SELFPARAM();
        vector  delta;
        float   traveltime;
@@ -253,7 +249,7 @@ void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
 
        self.think1 = func;
        self.finaldest = tdest;
-       self.SUB_THINK = SUB_CalcMoveDone;
+       SUB_THINK(self, SUB_CalcMoveDone);
 
        if (tdest == self.SUB_ORIGIN)
        {
@@ -292,8 +288,8 @@ void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
        SUB_CalcMove_Bezier((self.SUB_ORIGIN + tdest) * 0.5, tdest, tspeedtype, tspeed, func);
 }
 
-void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
-{SELFPARAM();
+void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
+{
        WITHSELF(ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
 }
 
@@ -307,18 +303,18 @@ self.angles rotating
 The calling function should make sure self.SUB_THINK is valid
 ===============
 */
-void SUB_CalcAngleMoveDone ()
-{SELFPARAM();
+void SUB_CalcAngleMoveDone(entity this)
+{
        // After rotating, set angle to exact final angle
        self.angles = self.finalangle;
        self.SUB_AVELOCITY = '0 0 0';
        self.SUB_NEXTTHINK = -1;
        if (self.think1)
-               self.think1 ();
+               self.think1 (self);
 }
 
 // FIXME: I fixed this function only for rotation around the main axes
-void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func)
+void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void(entity this) func)
 {SELFPARAM();
        vector  delta;
        float   traveltime;
@@ -347,7 +343,7 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void()
 
        self.think1 = func;
        self.finalangle = destangle;
-       self.SUB_THINK = SUB_CalcAngleMoveDone;
+       SUB_THINK(self, SUB_CalcAngleMoveDone);
 
        if (traveltime < 0.1)
        {
@@ -360,7 +356,7 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void()
        self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
 }
 
-void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
-{SELFPARAM();
+void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
+{
        WITHSELF(ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
 }
index 6a844261379a971e3d76da1a371008aac2c3f63a..1ce3ea2e9e842864e7315270fab82622a784af81 100644 (file)
@@ -9,7 +9,8 @@
        #define SUB_ORIGIN                      origin
        #define SUB_SETORIGIN(s,v)      setorigin((s), (v))
        #define SUB_NEXTTHINK           nextthink
-       #define SUB_THINK                       think
+       #define SUB_THINK(e, f)     setthink(e, f)
+       #define SUB_THUNK(e)        getthink(e)
        #define SUB_LTIME                       ltime
        #define SUB_FLAGS                       flags
 
@@ -22,7 +23,8 @@
        #define SUB_AVELOCITY   move_avelocity
        #define SUB_ORIGIN              move_origin
        #define SUB_NEXTTHINK   move_nextthink
-       #define SUB_THINK               move_think
+       #define SUB_THINK(e, f) ((e).move_think = (f))
+       #define SUB_THUNK(e)    ((e).move_think)
        #define SUB_LTIME               move_ltime
        #define SUB_FLAGS               move_flags
 
@@ -41,7 +43,7 @@ void SUB_SetFade (entity ent, float when, float fading_time);
 void SUB_VanishOrRemove (entity ent);
 
 .vector                finaldest, finalangle;          //plat.qc stuff
-.void()                think1;
+.void(entity this) think1;
 .float state;
 .float         t_length, t_width;
 
index 642c72cdbb13645fddb3da24e05e6aeffb47a139..5a24d2c5ed6e4e709ba4d2b5d445b1905e59ab23 100644 (file)
@@ -3,7 +3,7 @@ void target_push_init(entity this);
 
 spawnfunc(target_location)
 {
-    self.classname = "target_location";
+    this.classname = "target_location";
     // location name in netname
     // eventually support: count, teamgame selectors, line of sight?
 
index c48a0ba26b351270856be3c499e156fbdbd8c2dc..32237200ee9bd93abda850564cb8bf9054800535 100644 (file)
@@ -20,28 +20,28 @@ REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_MUSIC)
 //   fade_rate
 // when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
 // when targetname is not set, THIS ONE is default
-void target_music_sendto(float to, float is)
-{SELFPARAM();
+void target_music_sendto(entity this, int to, bool is)
+{
        WriteHeader(to, TE_CSQC_TARGET_MUSIC);
-       WriteShort(to, etof(self));
-       WriteByte(to, self.volume * 255.0 * is);
-       WriteByte(to, self.fade_time * 16.0);
-       WriteByte(to, self.fade_rate * 16.0);
-       WriteByte(to, self.lifetime);
-       WriteString(to, self.noise);
+       WriteShort(to, etof(this));
+       WriteByte(to, this.volume * 255.0 * is);
+       WriteByte(to, this.fade_time * 16.0);
+       WriteByte(to, this.fade_rate * 16.0);
+       WriteByte(to, this.lifetime);
+       WriteString(to, this.noise);
 }
 void target_music_reset(entity this)
 {
-       if (this.targetname == "") target_music_sendto(MSG_ALL, 1);
+       if (this.targetname == "") target_music_sendto(this, MSG_ALL, 1);
 }
 void target_music_kill()
 {
        FOREACH_ENTITY_CLASS("target_music", true, {
                it.volume = 0;
         if (it.targetname == "")
-            WITHSELF(it, target_music_sendto(MSG_ALL, 1));
+            WITHSELF(it, target_music_sendto(it, MSG_ALL, 1));
         else
-            WITHSELF(it, target_music_sendto(MSG_ALL, 0));
+            WITHSELF(it, target_music_sendto(it, MSG_ALL, 0));
        });
 }
 void target_music_use(entity this, entity actor, entity trigger)
@@ -51,33 +51,32 @@ void target_music_use(entity this, entity actor, entity trigger)
        if(IS_REAL_CLIENT(actor))
        {
                msg_entity = actor;
-               target_music_sendto(MSG_ONE, 1);
+               target_music_sendto(this, MSG_ONE, 1);
        }
        FOREACH_CLIENT(IS_SPEC(it) && it.enemy == actor, {
                msg_entity = it;
-               target_music_sendto(MSG_ONE, 1);
+               target_music_sendto(this, MSG_ONE, 1);
        });
 }
 spawnfunc(target_music)
 {
-       self.use = target_music_use;
-       self.reset = target_music_reset;
-       if(!self.volume)
-               self.volume = 1;
-       if(self.targetname == "")
-               target_music_sendto(MSG_INIT, 1);
+       this.use = target_music_use;
+       this.reset = target_music_reset;
+       if(!this.volume)
+               this.volume = 1;
+       if(this.targetname == "")
+               target_music_sendto(this, MSG_INIT, 1);
        else
-               target_music_sendto(MSG_INIT, 0);
+               target_music_sendto(this, MSG_INIT, 0);
 }
 void TargetMusic_RestoreGame()
-{SELFPARAM();
+{
        for(entity e = world; (e = find(e, classname, "target_music")); )
        {
-               setself(e);
-               if(self.targetname == "")
-                       target_music_sendto(MSG_INIT, 1);
+               if(e.targetname == "")
+                       target_music_sendto(e, MSG_INIT, 1);
                else
-                       target_music_sendto(MSG_INIT, 0);
+                       target_music_sendto(e, MSG_INIT, 0);
        }
 }
 // values:
@@ -92,38 +91,38 @@ bool trigger_music_SendEntity(entity this, entity to, float sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
        sf &= ~0x80;
-       if(self.cnt)
+       if(this.cnt)
                sf |= 0x80;
        WriteByte(MSG_ENTITY, sf);
        if(sf & 4)
        {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
+               WriteCoord(MSG_ENTITY, this.origin.x);
+               WriteCoord(MSG_ENTITY, this.origin.y);
+               WriteCoord(MSG_ENTITY, this.origin.z);
        }
        if(sf & 1)
        {
-               if(self.model != "null")
+               if(this.model != "null")
                {
-                       WriteShort(MSG_ENTITY, self.modelindex);
-                       WriteCoord(MSG_ENTITY, self.mins.x);
-                       WriteCoord(MSG_ENTITY, self.mins.y);
-                       WriteCoord(MSG_ENTITY, self.mins.z);
-                       WriteCoord(MSG_ENTITY, self.maxs.x);
-                       WriteCoord(MSG_ENTITY, self.maxs.y);
-                       WriteCoord(MSG_ENTITY, self.maxs.z);
+                       WriteShort(MSG_ENTITY, this.modelindex);
+                       WriteCoord(MSG_ENTITY, this.mins.x);
+                       WriteCoord(MSG_ENTITY, this.mins.y);
+                       WriteCoord(MSG_ENTITY, this.mins.z);
+                       WriteCoord(MSG_ENTITY, this.maxs.x);
+                       WriteCoord(MSG_ENTITY, this.maxs.y);
+                       WriteCoord(MSG_ENTITY, this.maxs.z);
                }
                else
                {
                        WriteShort(MSG_ENTITY, 0);
-                       WriteCoord(MSG_ENTITY, self.maxs.x);
-                       WriteCoord(MSG_ENTITY, self.maxs.y);
-                       WriteCoord(MSG_ENTITY, self.maxs.z);
+                       WriteCoord(MSG_ENTITY, this.maxs.x);
+                       WriteCoord(MSG_ENTITY, this.maxs.y);
+                       WriteCoord(MSG_ENTITY, this.maxs.z);
                }
-               WriteByte(MSG_ENTITY, self.volume * 255.0);
-               WriteByte(MSG_ENTITY, self.fade_time * 16.0);
-               WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
-               WriteString(MSG_ENTITY, self.noise);
+               WriteByte(MSG_ENTITY, this.volume * 255.0);
+               WriteByte(MSG_ENTITY, this.fade_time * 16.0);
+               WriteByte(MSG_ENTITY, this.fade_rate * 16.0);
+               WriteString(MSG_ENTITY, this.noise);
        }
        return 1;
 }
@@ -253,8 +252,8 @@ void Net_TargetMusic()
        }
 }
 
-void Ent_TriggerMusic_Think()
-{SELFPARAM();
+void Ent_TriggerMusic_Think(entity this)
+{
        if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
        {
                music_trigger = self;
@@ -274,55 +273,55 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew)
        int f = ReadByte();
        if(f & 4)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
        }
        if(f & 1)
        {
-               self.modelindex = ReadShort();
-               if(self.modelindex)
+               this.modelindex = ReadShort();
+               if(this.modelindex)
                {
-                       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    = '0 0 0';
-                       self.maxs_x = ReadCoord();
-                       self.maxs_y = ReadCoord();
-                       self.maxs_z = ReadCoord();
+                       this.mins    = '0 0 0';
+                       this.maxs_x = ReadCoord();
+                       this.maxs_y = ReadCoord();
+                       this.maxs_z = ReadCoord();
                }
 
-               self.volume = ReadByte() / 255.0;
-               self.fade_time = ReadByte() / 16.0;
-               self.fade_rate = ReadByte() / 16.0;
-               string s = self.noise;
-               if(self.noise)
-                       strunzone(self.noise);
-               self.noise = strzone(ReadString());
-               if(self.noise != s)
+               this.volume = ReadByte() / 255.0;
+               this.fade_time = ReadByte() / 16.0;
+               this.fade_rate = ReadByte() / 16.0;
+               string s = this.noise;
+               if(this.noise)
+                       strunzone(this.noise);
+               this.noise = strzone(ReadString());
+               if(this.noise != s)
                {
-                       precache_sound(self.noise);
-                       _sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
-                       if(getsoundtime(self, CH_BGM_SINGLE) < 0)
+                       precache_sound(this.noise);
+                       _sound(this, CH_BGM_SINGLE, this.noise, 0, ATTEN_NONE);
+                       if(getsoundtime(this, CH_BGM_SINGLE) < 0)
                        {
-                               LOG_TRACEF("Cannot initialize sound %s\n", self.noise);
-                               strunzone(self.noise);
-                               self.noise = string_null;
+                               LOG_TRACEF("Cannot initialize sound %s\n", this.noise);
+                               strunzone(this.noise);
+                               this.noise = string_null;
                        }
                }
        }
 
-       setorigin(self, self.origin);
-       setsize(self, self.mins, self.maxs);
-       self.cnt = 1;
-       self.think = Ent_TriggerMusic_Think;
-       self.nextthink = time;
+       setorigin(this, this.origin);
+       setsize(this, this.mins, this.maxs);
+       this.cnt = 1;
+       setthink(this, Ent_TriggerMusic_Think);
+       this.nextthink = time;
        return true;
 }
 
index 1884879764f20d0e21f3f75f83cb56a8d5f5a093..ff8b12fda49aa744a7b649e61360b0faf8ac3a04 100644 (file)
@@ -18,7 +18,7 @@ void TargetMusic_Advance();
 
 void Net_TargetMusic();
 
-void Ent_TriggerMusic_Think();
+void Ent_TriggerMusic_Think(entity this);
 
 void Ent_TriggerMusic_Remove();
 
index 74ac8fd99ad8899e6d556cbf9837929f0e2b2664..5b6824283cf4a1b28f6fd0ee43e68bf03a86c451 100644 (file)
@@ -330,9 +330,9 @@ void initialize_field_db()
 spawnfunc(target_spawn)
 {
        initialize_field_db();
-       self.use = target_spawn_use;
-       self.message = strzone(strreplace("'", "\"", self.message));
-       self.target_spawn_id = ++target_spawn_count;
-       InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
+       this.use = target_spawn_use;
+       this.message = strzone(strreplace("'", "\"", this.message));
+       this.target_spawn_id = ++target_spawn_count;
+       InitializeEntity(this, target_spawn_spawnfirst, INITPRIO_LAST);
 }
 #endif
index 046128f796d2cef4d353942496d952cb8d8c11c5..dc9b34b4a95796fc575d4785c8cdaf4e68a83999 100644 (file)
@@ -79,53 +79,53 @@ spawnfunc(target_speaker)
 {
        // TODO: "*" prefix to sound file name
        // TODO: wait and random (just, HOW? random is not a field)
-       if(self.noise)
-               precache_sound (self.noise);
+       if(this.noise)
+               precache_sound (this.noise);
 
-       if(!self.atten && !(self.spawnflags & 4))
+       if(!this.atten && !(this.spawnflags & 4))
        {
                IFTARGETED
-                       self.atten = ATTEN_NORM;
+                       this.atten = ATTEN_NORM;
                else
-                       self.atten = ATTEN_STATIC;
+                       this.atten = ATTEN_STATIC;
        }
-       else if(self.atten < 0)
-               self.atten = 0;
+       else if(this.atten < 0)
+               this.atten = 0;
 
-       if(!self.volume)
-               self.volume = 1;
+       if(!this.volume)
+               this.volume = 1;
 
        IFTARGETED
        {
-               if(self.spawnflags & 8) // ACTIVATOR
-                       self.use = target_speaker_use_activator;
-               else if(self.spawnflags & 1) // LOOPED_ON
+               if(this.spawnflags & 8) // ACTIVATOR
+                       this.use = target_speaker_use_activator;
+               else if(this.spawnflags & 1) // LOOPED_ON
                {
-                       target_speaker_use_on(self, NULL, NULL);
-                       self.reset = target_speaker_reset;
+                       target_speaker_use_on(this, NULL, NULL);
+                       this.reset = target_speaker_reset;
                }
-               else if(self.spawnflags & 2) // LOOPED_OFF
+               else if(this.spawnflags & 2) // LOOPED_OFF
                {
-                       self.use = target_speaker_use_on;
-                       self.reset = target_speaker_reset;
+                       this.use = target_speaker_use_on;
+                       this.reset = target_speaker_reset;
                }
                else
-                       self.use = target_speaker_use_on;
+                       this.use = target_speaker_use_on;
        }
-       else if(self.spawnflags & 1) // LOOPED_ON
+       else if(this.spawnflags & 1) // LOOPED_ON
        {
-               ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
-               remove(self);
+               ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+               remove(this);
        }
-       else if(self.spawnflags & 2) // LOOPED_OFF
+       else if(this.spawnflags & 2) // LOOPED_OFF
        {
                objerror("This sound entity can never be activated");
        }
        else
        {
                // Quake/Nexuiz fallback
-               ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
-               remove(self);
+               ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+               remove(this);
        }
 }
 #endif
index e8433177094dfec0337a9e101f878bface1873c4..bfce684c4a461bfabb1361f418c9bb35487d763c 100644 (file)
@@ -84,18 +84,18 @@ spawnfunc(target_voicescript)
        // delay: initial delay before the first message
 
        float i, n;
-       self.use = target_voicescript_use;
+       this.use = target_voicescript_use;
 
-       n = tokenize_console(self.message);
-       self.cnt = n / 2;
+       n = tokenize_console(this.message);
+       this.cnt = n / 2;
        for(i = 0; i+1 < n; i += 2)
        {
                if(argv(i) == "*")
                {
-                       self.cnt = i / 2;
+                       this.cnt = i / 2;
                        ++i;
                }
-               precache_sound(strcat(self.netname, "/", argv(i), ".wav"));
+               precache_sound(strcat(this.netname, "/", argv(i), ".wav"));
        }
 }
 #endif
index 04667f4cc228391eefab47954ab56695e99d3f10..c4322e94382ed8de8b2cf20418c0935efac2e612 100644 (file)
@@ -251,12 +251,12 @@ void teleport_findtarget(entity this)
 {
        int n = 0;
        entity e;
-       for(e = world; (e = find(e, targetname, self.target)); )
+       for(e = world; (e = find(e, targetname, this.target)); )
        {
                ++n;
 #ifdef SVQC
                if(e.movetype == MOVETYPE_NONE)
-                       waypoint_spawnforteleporter(self, e.origin, 0);
+                       waypoint_spawnforteleporter(this, e.origin, 0);
                if(e.classname != "info_teleport_destination")
                        LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n");
 #endif
@@ -271,21 +271,18 @@ void teleport_findtarget(entity this)
        else if(n == 1)
        {
                // exactly one dest - bots love that
-               self.enemy = find(e, targetname, self.target);
+               this.enemy = find(e, targetname, this.target);
        }
        else
        {
                // have to use random selection every single time
-               self.enemy = world;
+               this.enemy = world;
        }
 
        // now enable touch
+       settouch(this, Teleport_Touch);
 #ifdef SVQC
-       self.touch = Teleport_Touch;
-
-       trigger_teleport_link(self);
-#elif defined(CSQC)
-       self.move_touch = Teleport_Touch;
+       trigger_teleport_link(this);
 #endif
 }
 
index 9366678b15c50dd79db5f194dcc3aadfec7d6a57..ef47b0c6c8d00f180394f9f882d6bac61950d80d 100644 (file)
@@ -17,7 +17,7 @@ const float TELEPORT_SIMPLE = 2; // only do teleport, nothing special
 
 entity Simple_TeleportPlayer(entity teleporter, entity player);
 
-void Teleport_Touch ();
+void Teleport_Touch (entity this);
 
 void teleport_findtarget(entity this);
 
index 5ada6805fc067ae7d4410ca29a5fb39f4ec8fd57..a4f850ba9ad548d9b76e14f67f64fd6f4851054a 100644 (file)
@@ -11,7 +11,7 @@ void counter_use(entity this, entity actor, entity trigger)
                        Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
 
                this.enemy = actor;
-               WITHSELF(this, multi_trigger ());
+               multi_trigger(this);
        }
        else
        {
@@ -38,12 +38,12 @@ After the counter has been triggered "count" times (default 2), it will fire all
 */
 spawnfunc(trigger_counter)
 {
-       self.wait = -1;
-       if (!self.count)
-               self.count = 2;
-       self.cnt = self.count;
+       this.wait = -1;
+       if (!this.count)
+               this.count = 2;
+       this.cnt = this.count;
 
-       self.use = counter_use;
-       self.reset = counter_reset;
+       this.use = counter_use;
+       this.reset = counter_reset;
 }
 #endif
index 02c1aa968b7e14d302072f7d665e369fafcd9da3..d6742fed3298c03f70882ee07871ed566a54beb5 100644 (file)
@@ -1,22 +1,22 @@
 #ifdef SVQC
 void delay_use(entity this, entity actor, entity trigger)
 {
-   this.think = SUB_UseTargets_self;
+   setthink(this, SUB_UseTargets_self);
    this.nextthink = this.wait;
 }
 
 void delay_reset(entity this)
 {
-       this.think = func_null;
+       setthink(this, func_null);
        this.nextthink = 0;
 }
 
 spawnfunc(trigger_delay)
 {
-    if(!self.wait)
-        self.wait = 1;
+    if(!this.wait)
+        this.wait = 1;
 
-    self.use = delay_use;
-    self.reset = delay_reset;
+    this.use = delay_use;
+    this.reset = delay_reset;
 }
 #endif
index 5f3206a2af5bb470b16c388e306381e0b8aa8aae..b042d01e06ba04d81089e980686c88171fa377be 100644 (file)
@@ -18,7 +18,7 @@ spawnfunc(trigger_gamestart)
 
        if(this.wait)
        {
-               this.think = adaptor_think2use;
+               setthink(this, adaptor_think2use);
                this.nextthink = game_starttime + this.wait;
        }
        else
index c7dd586cb3b3f266435bed42dd0a458be6511d7e..197ea9271be5cb4bb5140f4e1d460635e2117899 100644 (file)
@@ -12,8 +12,8 @@ void trigger_gravity_remove(entity own)
                backtrace("Removing a trigger_gravity_check with no valid owner");
        own.trigger_gravity_check = world;
 }
-void trigger_gravity_check_think()
-{SELFPARAM();
+void trigger_gravity_check_think(entity this)
+{
        // This spawns when a player enters the gravity zone and checks if he left.
        // Each frame, self.count is set to 2 by trigger_gravity_touch() and decreased by 1 here.
        // It the player has left the gravity trigger, this will be allowed to reach 0 and indicate that.
@@ -37,8 +37,8 @@ void trigger_gravity_use(entity this, entity actor, entity trigger)
        this.state = !this.state;
 }
 
-void trigger_gravity_touch()
-{SELFPARAM();
+void trigger_gravity_touch(entity this)
+{
        float g;
 
        if(self.state != true)
@@ -69,7 +69,7 @@ void trigger_gravity_touch()
                other.trigger_gravity_check.enemy = self;
                other.trigger_gravity_check.owner = other;
                other.trigger_gravity_check.gravity = other.gravity;
-               other.trigger_gravity_check.think = trigger_gravity_check_think;
+               setthink(other.trigger_gravity_check, trigger_gravity_check_think);
                other.trigger_gravity_check.nextthink = time;
                other.trigger_gravity_check.count = 2;
                if(other.gravity)
@@ -87,20 +87,20 @@ void trigger_gravity_touch()
 
 spawnfunc(trigger_gravity)
 {
-       if(self.gravity == 1)
+       if(this.gravity == 1)
                return;
 
        EXACTTRIGGER_INIT;
-       self.touch = trigger_gravity_touch;
-       if(self.noise != "")
-               precache_sound(self.noise);
+       settouch(this, trigger_gravity_touch);
+       if(this.noise != "")
+               precache_sound(this.noise);
 
-       self.state = true;
+       this.state = true;
        IFTARGETED
        {
-               self.use = trigger_gravity_use;
-               if(self.spawnflags & 2)
-                       self.state = false;
+               this.use = trigger_gravity_use;
+               if(this.spawnflags & 2)
+                       this.state = false;
        }
 }
 #endif
index cbabe8dfd609096cea7a6bb7d6f79227c1cb112e..25d824d7a62f0953dd6f5538a4bd1771cf565fb4 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float triggerhealtime;
-void trigger_heal_touch()
-{SELFPARAM();
+void trigger_heal_touch(entity this)
+{
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -27,16 +27,16 @@ void trigger_heal_touch()
 
 spawnfunc(trigger_heal)
 {
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
        EXACTTRIGGER_INIT;
-       self.touch = trigger_heal_touch;
-       if (!self.health)
-               self.health = 10;
-       if (!self.max_health)
-               self.max_health = 200; //Max health topoff for field
-       if(self.noise == "")
-               self.noise = "misc/mediumhealth.wav";
-       precache_sound(self.noise);
+       settouch(this, trigger_heal_touch);
+       if (!this.health)
+               this.health = 10;
+       if (!this.max_health)
+               this.max_health = 200; //Max health topoff for field
+       if(this.noise == "")
+               this.noise = "misc/mediumhealth.wav";
+       precache_sound(this.noise);
 }
 #endif
index a7ee567ebc08ec3c8a0615720e4cbe1fd35af98f..82199a39311ec56ee18d3acdb2e718818afdb0ed 100644 (file)
@@ -8,8 +8,8 @@ void trigger_hurt_use(entity this, entity actor, entity trigger)
 }
 
 .float triggerhurttime;
-void trigger_hurt_touch()
-{SELFPARAM();
+void trigger_hurt_touch(entity this)
+{
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -60,23 +60,23 @@ entity trigger_hurt_first;
 spawnfunc(trigger_hurt)
 {
        EXACTTRIGGER_INIT;
-       self.active = ACTIVE_ACTIVE;
-       self.touch = trigger_hurt_touch;
-       self.use = trigger_hurt_use;
-       self.enemy = world; // I hate you all
-       if (!self.dmg)
-               self.dmg = 1000;
-       if (self.message == "")
-               self.message = "was in the wrong place";
-       if (self.message2 == "")
-               self.message2 = "was thrown into a world of hurt by";
-       // self.message = "someone like %s always gets wrongplaced";
+       this.active = ACTIVE_ACTIVE;
+       settouch(this, trigger_hurt_touch);
+       this.use = trigger_hurt_use;
+       this.enemy = world; // I hate you all
+       if (!this.dmg)
+               this.dmg = 1000;
+       if (this.message == "")
+               this.message = "was in the wrong place";
+       if (this.message2 == "")
+               this.message2 = "was thrown into a world of hurt by";
+       // this.message = "someone like %s always gets wrongplaced";
 
        if(!trigger_hurt_first)
-               trigger_hurt_first = self;
+               trigger_hurt_first = this;
        if(trigger_hurt_last)
-               trigger_hurt_last.trigger_hurt_next = self;
-       trigger_hurt_last = self;
+               trigger_hurt_last.trigger_hurt_next = this;
+       trigger_hurt_last = this;
 }
 
 float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
index b7cd57272dce363c57e103f755e6a126c165019a..d45a82b53c41dc2450710f8bc2d3397ea4fbaadd 100644 (file)
@@ -1,6 +1,6 @@
 // targeted (directional) mode
-void trigger_impulse_touch1()
-{SELFPARAM();
+void trigger_impulse_touch1(entity this)
+{
        entity targ;
        float pushdeltatime;
        float str;
@@ -74,8 +74,8 @@ void trigger_impulse_touch1()
 }
 
 // Directionless (accelerator/decelerator) mode
-void trigger_impulse_touch2()
-{SELFPARAM();
+void trigger_impulse_touch2(entity this)
+{
        float pushdeltatime;
 
        if (self.active != ACTIVE_ACTIVE)
@@ -102,8 +102,8 @@ void trigger_impulse_touch2()
 }
 
 // Spherical (gravity/repulsor) mode
-void trigger_impulse_touch3()
-{SELFPARAM();
+void trigger_impulse_touch3(entity this)
+{
        float pushdeltatime;
        float str;
 
@@ -179,41 +179,40 @@ bool trigger_impulse_send(entity this, entity to, int sf)
        return true;
 }
 
-void trigger_impulse_link()
+void trigger_impulse_link(entity this)
 {
-    SELFPARAM();
-       trigger_link(self, trigger_impulse_send);
+       trigger_link(this, trigger_impulse_send);
 }
 
 spawnfunc(trigger_impulse)
 {
-       self.active = ACTIVE_ACTIVE;
+       this.active = ACTIVE_ACTIVE;
 
-       trigger_init(self);
+       trigger_init(this);
 
-       if(self.radius)
+       if(this.radius)
        {
-               if(!self.strength) self.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
-               setorigin(self, self.origin);
-               setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius);
-               self.touch = trigger_impulse_touch3;
+               if(!this.strength) this.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
+               setorigin(this, this.origin);
+               setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
+               settouch(this, trigger_impulse_touch3);
        }
        else
        {
-               if(self.target)
+               if(this.target)
                {
-                       if(!self.strength) self.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
-                       self.touch = trigger_impulse_touch1;
+                       if(!this.strength) this.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
+                       settouch(this, trigger_impulse_touch1);
                }
                else
                {
-                       if(!self.strength) self.strength = 0.9;
-                       self.strength = pow(self.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
-                       self.touch = trigger_impulse_touch2;
+                       if(!this.strength) this.strength = 0.9;
+                       this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
+                       settouch(this, trigger_impulse_touch2);
                }
        }
 
-       trigger_impulse_link();
+       trigger_impulse_link(this);
 }
 #elif defined(CSQC)
 NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
@@ -224,18 +223,16 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
        this.falloff = ReadByte();
        this.active = ReadByte();
 
-       trigger_common_read(true);
+       trigger_common_read(this, true);
        return = true;
 
        this.classname = "trigger_impulse";
        this.solid = SOLID_TRIGGER;
        this.entremove = trigger_remove_generic;
-       //this.draw = trigger_draw_generic;
-       this.drawmask = MASK_NORMAL;
        this.move_time = time;
 
-       if(this.radius) { this.move_touch = trigger_impulse_touch3; }
-       else if(this.target) { this.move_touch = trigger_impulse_touch1; }
-       else { this.move_touch = trigger_impulse_touch2; }
+       if (this.radius) { settouch(this, trigger_impulse_touch3); }
+       else if (this.target) { settouch(this, trigger_impulse_touch1); }
+       else { settouch(this, trigger_impulse_touch2); }
 }
 #endif
index 44413a9c4b9171f8182c0cf8a04f9de0b08e8e24..cbb2f03279d859bb79b84efd52803ebd771412f3 100644 (file)
@@ -129,8 +129,8 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht)
        return sdir * vs + '0 0 1' * vz;
 }
 
-void trigger_push_touch()
-{SELFPARAM();
+void trigger_push_touch(entity this)
+{
        if (this.active == ACTIVE_NOT)
                return;
 
@@ -262,8 +262,8 @@ void trigger_push_touch()
 
        if (this.spawnflags & PUSH_ONCE)
        {
-               this.touch = func_null;
-               this.think = SUB_Remove_self;
+               settouch(this, func_null);
+               setthink(this, SUB_Remove);
                this.nextthink = time;
        }
 #endif
@@ -382,7 +382,7 @@ spawnfunc(trigger_push)
 
        this.active = ACTIVE_ACTIVE;
        this.use = trigger_push_use;
-       this.touch = trigger_push_touch;
+       settouch(this, trigger_push_touch);
 
        // normal push setup
        if (!this.speed)
@@ -443,13 +443,11 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
        this.active = ReadByte();
        this.height = ReadCoord();
 
-       trigger_common_read(true);
+       trigger_common_read(this, true);
 
        this.entremove = trigger_remove_generic;
        this.solid = SOLID_TRIGGER;
-       //this.draw = trigger_draw_generic;
-       this.move_touch = trigger_push_touch;
-       this.drawmask = MASK_NORMAL;
+       settouch(this, trigger_push_touch);
        this.move_time = time;
        defer(this, 0.25, trigger_push_findtarget);
 
index 6fd61dc9da7561fb0bd684d30e50f95113267917..4e8bf1809fd24840637abeb5a3aa27e31109bd41 100644 (file)
@@ -35,7 +35,7 @@ void trigger_push_use(entity this, entity actor, entity trigger);
 
 vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
 
-void trigger_push_touch();
+void trigger_push_touch(entity this);
 
 .vector dest;
 void trigger_push_findtarget(entity this);
index 311075aa0a0a0ed5c23cedc57d7194c4b6a0d937..e90eb1853affc2dc4e51097b1889980af8f07853 100644 (file)
@@ -18,8 +18,8 @@ void trigger_keylock_kill(string s)
                remove(t);
 }
 
-void trigger_keylock_touch()
-{SELFPARAM();
+void trigger_keylock_touch(entity this)
+{
        bool key_used = false;
        bool started_delay = false;
 
@@ -82,22 +82,22 @@ void trigger_keylock_touch()
 REGISTER_NET_LINKED(ENT_CLIENT_KEYLOCK)
 
 #ifdef SVQC
-bool trigger_keylock_send(entity to, int sf)
-{SELFPARAM();
+bool trigger_keylock_send(entity this, entity to, int sf)
+{
        WriteHeader(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
 
-       WriteInt24_t(MSG_ENTITY, self.itemkeys);
-       WriteByte(MSG_ENTITY, self.height);
+       WriteInt24_t(MSG_ENTITY, this.itemkeys);
+       WriteByte(MSG_ENTITY, this.height);
 
-       trigger_common_write(self, true);
+       trigger_common_write(this, true);
 
        return true;
 }
 
-void trigger_keylock_link()
+void trigger_keylock_link(entity this)
 {
        // uncomment to network keylocks
-       //Net_LinkEntity(self, false, 0, trigger_keylock_send);
+       //Net_LinkEntity(this, false, 0, trigger_keylock_send);
 }
 
 /*QUAKED trigger_keylock (.0 .5 .8) ?
@@ -121,44 +121,44 @@ message2 and noise2 will be resent to the player every 2 seconds while he is in
 */
 spawnfunc(trigger_keylock)
 {
-       if(!self.itemkeys) { remove(self); return; }
+       if(!this.itemkeys) { remove(this); return; }
 
        // set unlocked message
-       if(self.message == "")
-               self.message = "Unlocked!";
+       if(this.message == "")
+               this.message = "Unlocked!";
 
        // set default unlock noise
-       if(self.noise == "")
+       if(this.noise == "")
        {
-               if(self.sounds == 1)
-                       self.noise = "misc/secret.wav";
-               else if(self.sounds == 2)
-                       self.noise = strzone(SND(TALK));
-               else //if (self.sounds == 3) {
-                       self.noise = "misc/trigger1.wav";
+               if(this.sounds == 1)
+                       this.noise = "misc/secret.wav";
+               else if(this.sounds == 2)
+                       this.noise = strzone(SND(TALK));
+               else //if (this.sounds == 3) {
+                       this.noise = "misc/trigger1.wav";
        }
 
        // set default use key sound
-       if(self.noise1 == "")
-               self.noise1 = "misc/decreasevalue.wav";
+       if(this.noise1 == "")
+               this.noise1 = "misc/decreasevalue.wav";
 
        // set closed sourd
-       if(self.noise2 == "")
-               self.noise2 = SND(TALK);
+       if(this.noise2 == "")
+               this.noise2 = SND(TALK);
 
        // delay between triggering message2 and trigger2
-       if(!self.wait) { self.wait = 5; }
+       if(!this.wait) { this.wait = 5; }
 
        // precache sounds
-       precache_sound(self.noise);
-       precache_sound(self.noise1);
-       precache_sound(self.noise2);
+       precache_sound(this.noise);
+       precache_sound(this.noise1);
+       precache_sound(this.noise2);
 
        EXACTTRIGGER_INIT;
 
-       self.touch = trigger_keylock_touch;
+       settouch(this, trigger_keylock_touch);
 
-       trigger_keylock_link();
+       trigger_keylock_link(this);
 }
 #elif defined(CSQC)
 void keylock_remove(entity this)
@@ -184,17 +184,14 @@ void keylock_remove(entity this)
 
 NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew)
 {
-       self.itemkeys = ReadInt24_t();
-       self.height = ReadByte();
+       this.itemkeys = ReadInt24_t();
+       this.height = ReadByte();
 
-       trigger_common_read(true);
+       trigger_common_read(this, true);
 
        return = true;
 
-       self.classname = "trigger_keylock";
-       self.drawmask = MASK_NORMAL;
-       self.draw = trigger_draw_generic;
-       self.trigger_touch = trigger_keylock_touch;
-       self.entremove = keylock_remove;
+       this.classname = "trigger_keylock";
+       this.entremove = keylock_remove;
 }
 #endif
index 2c94fa395db722bd944e73047d1ee259788587ae..3287210409c8cd65b73cbd378e02920f5c7a70e4 100644 (file)
@@ -158,8 +158,8 @@ string trigger_magicear_processmessage_forallears(entity source, float teamsay,
 
 spawnfunc(trigger_magicear)
 {
-       self.enemy = magicears;
-       magicears = self;
+       this.enemy = magicears;
+       magicears = this;
 
        // actually handled in "say" processing
        // spawnflags:
@@ -190,6 +190,6 @@ spawnfunc(trigger_magicear)
        // movedir:
        //   for spawnflags 256, defines 'instrument+1 mintempo maxtempo' (zero component doesn't matter)
 
-       self.movedir_x -= 1; // map to tuba instrument numbers
+       this.movedir_x -= 1; // map to tuba instrument numbers
 }
 #endif
index 994d498c11e8b0a43056979fccd29ee5430542e7..018e20884b25938e7d17fba6fc0764948c2aad1d 100644 (file)
@@ -21,8 +21,8 @@ void monoflop_fixed_use(entity this, entity actor, entity trigger)
        SUB_UseTargets(this, actor, trigger);
 }
 
-void monoflop_think()
-{SELFPARAM();
+void monoflop_think(entity this)
+{
        this.state = 0;
        SUB_UseTargets(this, this.enemy, NULL);
 }
@@ -41,7 +41,7 @@ spawnfunc(trigger_monoflop)
                this.use = monoflop_fixed_use;
        else
                this.use = monoflop_use;
-       this.think = monoflop_think;
+       setthink(this, monoflop_think);
        this.state = 0;
        this.reset = monoflop_reset;
 }
index ce7bba67321ce482a15c9f28bf414742029d9f49..435255727e7f4139e83baebe29266bdf8291f827 100644 (file)
@@ -2,60 +2,60 @@
 
 #ifdef SVQC
 // the wait time has passed, so set back up for another activation
-void multi_wait()
-{SELFPARAM();
-       if (self.max_health)
+void multi_wait(entity this)
+{
+       if (this.max_health)
        {
-               self.health = self.max_health;
-               self.takedamage = DAMAGE_YES;
-               self.solid = SOLID_BBOX;
+               this.health = this.max_health;
+               this.takedamage = DAMAGE_YES;
+               this.solid = SOLID_BBOX;
        }
 }
 
 
 // the trigger was just touched/killed/used
-// self.enemy should be set to the activator so it can be held through a delay
+// this.enemy should be set to the activator so it can be held through a delay
 // so wait for the delay time before firing
-void multi_trigger()
-{SELFPARAM();
-       if (self.nextthink > time)
+void multi_trigger(entity this)
+{
+       if (this.nextthink > time)
        {
                return;         // allready been triggered
        }
 
-       if(self.spawnflags & 16384)
-       if(!IS_PLAYER(self.enemy))
+       if(this.spawnflags & 16384)
+       if(!IS_PLAYER(this.enemy))
                return; // only players
 
-       if (self.classname == "trigger_secret")
+       if (this.classname == "trigger_secret")
        {
-               if (!IS_PLAYER(self.enemy))
+               if (!IS_PLAYER(this.enemy))
                        return;
                found_secrets = found_secrets + 1;
                WriteByte (MSG_ALL, SVC_FOUNDSECRET);
        }
 
-       if (self.noise)
-               _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+       if (this.noise)
+               _sound (this.enemy, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
 
 // don't trigger again until reset
-       self.takedamage = DAMAGE_NO;
+       this.takedamage = DAMAGE_NO;
 
-       SUB_UseTargets(self, self.enemy, self.goalentity);
+       SUB_UseTargets(this, this.enemy, this.goalentity);
 
-       if (self.wait > 0)
+       if (this.wait > 0)
        {
-               self.think = multi_wait;
-               self.nextthink = time + self.wait;
+               setthink(this, multi_wait);
+               this.nextthink = time + this.wait;
        }
-       else if (self.wait == 0)
+       else if (this.wait == 0)
        {
-               multi_wait(); // waiting finished
+               WITHSELF(this, multi_wait(this)); // waiting finished
        }
        else
-       {       // we can't just remove (self) here, because this is a touch function
+       {       // we can't just remove (this) here, because this is a touch function
                // called wheil C code is looping through area links...
-               self.touch = func_null;
+               settouch(this, func_null);
        }
 }
 
@@ -63,11 +63,11 @@ void multi_use(entity this, entity actor, entity trigger)
 {
        this.goalentity = trigger;
        this.enemy = actor;
-       WITHSELF(this, multi_trigger());
+       multi_trigger(this);
 }
 
-void multi_touch()
-{SELFPARAM();
+void multi_touch(entity this)
+{
        if(!(self.spawnflags & 2))
        if(!other.iscreature)
                        return;
@@ -94,7 +94,7 @@ void multi_touch()
 
        self.enemy = other;
        self.goalentity = other;
-       multi_trigger ();
+       multi_trigger(self);
 }
 
 void multi_eventdamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -109,21 +109,21 @@ void multi_eventdamage(entity this, entity inflictor, entity attacker, float dam
        {
                this.enemy = attacker;
                this.goalentity = inflictor;
-               WITHSELF(this, multi_trigger());
+               multi_trigger(this);
        }
 }
 
 void multi_reset(entity this)
 {
        if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
-               this.touch = multi_touch;
+               settouch(this, multi_touch);
        if (this.max_health)
        {
                this.health = this.max_health;
                this.takedamage = DAMAGE_YES;
                this.solid = SOLID_BBOX;
        }
-       this.think = func_null;
+       setthink(this, func_null);
        this.nextthink = 0;
        this.team = this.team_saved;
 }
@@ -143,43 +143,43 @@ set "message" to text string
 */
 spawnfunc(trigger_multiple)
 {
-       self.reset = multi_reset;
-       if (self.sounds == 1)
-               self.noise = "misc/secret.wav";
-       else if (self.sounds == 2)
-               self.noise = strzone(SND(TALK));
-       else if (self.sounds == 3)
-               self.noise = "misc/trigger1.wav";
-
-       if(self.noise)
-               precache_sound(self.noise);
-
-       if (!self.wait)
-               self.wait = 0.2;
-       else if(self.wait < -1)
-               self.wait = 0;
-       self.use = multi_use;
+       this.reset = multi_reset;
+       if (this.sounds == 1)
+               this.noise = "misc/secret.wav";
+       else if (this.sounds == 2)
+               this.noise = strzone(SND(TALK));
+       else if (this.sounds == 3)
+               this.noise = "misc/trigger1.wav";
+
+       if(this.noise)
+               precache_sound(this.noise);
+
+       if (!this.wait)
+               this.wait = 0.2;
+       else if(this.wait < -1)
+               this.wait = 0;
+       this.use = multi_use;
 
        EXACTTRIGGER_INIT;
 
-       self.team_saved = self.team;
+       this.team_saved = this.team;
 
-       if (self.health)
+       if (this.health)
        {
-               if (self.spawnflags & SPAWNFLAG_NOTOUCH)
+               if (this.spawnflags & SPAWNFLAG_NOTOUCH)
                        objerror ("health and notouch don't make sense\n");
-               self.max_health = self.health;
-               self.event_damage = multi_eventdamage;
-               self.takedamage = DAMAGE_YES;
-               self.solid = SOLID_BBOX;
-               setorigin (self, self.origin);  // make sure it links into the world
+               this.max_health = this.health;
+               this.event_damage = multi_eventdamage;
+               this.takedamage = DAMAGE_YES;
+               this.solid = SOLID_BBOX;
+               setorigin (this, this.origin);  // make sure it links into the world
        }
        else
        {
-               if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
+               if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
                {
-                       self.touch = multi_touch;
-                       setorigin (self, self.origin);  // make sure it links into the world
+                       settouch(this, multi_touch);
+                       setorigin (this, this.origin);  // make sure it links into the world
                }
        }
 }
index 1a67dfd3580342a017192ebc6af9cf213703ad9e..43358c2744606b8e04247255ea48f4245693e31d 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 
 #ifdef SVQC
-void multi_trigger();
+void multi_trigger(entity this);
 void multi_reset(entity this);
 
 spawnfunc(trigger_once);
index a50f62b7abd699f207746792a1693f7a07dd9c26..1a1850537d4f29cd7bdde118395ea007e1d1716d 100644 (file)
@@ -1,28 +1,33 @@
 #ifdef SVQC
-void multivibrator_send()
-{SELFPARAM();
+void multivibrator_send(entity this)
+{
        float newstate;
        float cyclestart;
 
-       cyclestart = floor((time + self.phase) / (self.wait + self.respawntime)) * (self.wait + self.respawntime) - self.phase;
+       cyclestart = floor((time + this.phase) / (this.wait + this.respawntime)) * (this.wait + this.respawntime) - this.phase;
 
-       newstate = (time < cyclestart + self.wait);
+       newstate = (time < cyclestart + this.wait);
 
-       if(self.state != newstate)
-               SUB_UseTargets(self, self, NULL);
-       self.state = newstate;
+       if(this.state != newstate)
+               SUB_UseTargets(this, this, NULL);
+       this.state = newstate;
 
-       if(self.state)
-               self.nextthink = cyclestart + self.wait + 0.01;
+       if(this.state)
+               this.nextthink = cyclestart + this.wait + 0.01;
        else
-               self.nextthink = cyclestart + self.wait + self.respawntime + 0.01;
+               this.nextthink = cyclestart + this.wait + this.respawntime + 0.01;
+}
+
+void multivibrator_send_think(entity this)
+{
+       multivibrator_send(this);
 }
 
 void multivibrator_toggle(entity this, entity actor, entity trigger)
 {
        if(this.nextthink == 0)
        {
-               WITHSELF(this, multivibrator_send());
+               multivibrator_send(this);
        }
        else
        {
@@ -35,12 +40,12 @@ void multivibrator_toggle(entity this, entity actor, entity trigger)
        }
 }
 
-void multivibrator_reset()
-{SELFPARAM();
-       if(!(self.spawnflags & 1))
-               self.nextthink = 0; // wait for a trigger event
+void multivibrator_reset(entity this)
+{
+       if(!(this.spawnflags & 1))
+               this.nextthink = 0; // wait for a trigger event
        else
-               self.nextthink = max(1, time);
+               this.nextthink = max(1, time);
 }
 
 /*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ON
@@ -56,17 +61,17 @@ START_ON: assume it is already turned on (when targeted)
 */
 spawnfunc(trigger_multivibrator)
 {
-       if(!self.wait)
-               self.wait = 1;
-       if(!self.respawntime)
-               self.respawntime = self.wait;
+       if(!this.wait)
+               this.wait = 1;
+       if(!this.respawntime)
+               this.respawntime = this.wait;
 
-       self.state = 0;
-       self.use = multivibrator_toggle;
-       self.think = multivibrator_send;
-       self.nextthink = max(1, time);
+       this.state = 0;
+       this.use = multivibrator_toggle;
+       setthink(this, multivibrator_send_think);
+       this.nextthink = max(1, time);
 
        IFTARGETED
-               multivibrator_reset();
+               multivibrator_reset(this);
 }
 #endif
index f94cd00ad9680e5b61b203c2c2b4e9eeaa10c3eb..a6f40be3ea5521a909f7d0df6c649e995e0da39c 100644 (file)
@@ -17,8 +17,8 @@ void secrets_setstatus()
 /**
  * A secret has been found (maybe :P)
  */
-void trigger_secret_touch()
-{SELFPARAM();
+void trigger_secret_touch(entity this)
+{
        // only a player can trigger this
        if (!IS_PLAYER(other))
                return;
@@ -33,7 +33,7 @@ void trigger_secret_touch()
        self.message = "";
 
        // handle normal trigger features
-       multi_touch();
+       multi_touch(self);
        remove(self);
 }
 
@@ -58,30 +58,30 @@ spawnfunc(trigger_secret)
        secrets_total += 1;
 
        // add default message
-       if (self.message == "")
-               self.message = "You found a secret!";
+       if (this.message == "")
+               this.message = "You found a secret!";
 
        // set default sound
-       if (self.noise == "")
-       if (!self.sounds)
-               self.sounds = 1; // misc/secret.wav
+       if (this.noise == "")
+       if (!this.sounds)
+               this.sounds = 1; // misc/secret.wav
 
        // this entity can't be a target itself!!!!
-       self.targetname = "";
+       this.targetname = "";
 
        // you can't just shoot a room to find it, can you?
-       self.health = 0;
+       this.health = 0;
 
        // a secret can not be delayed
-       self.delay = 0;
+       this.delay = 0;
 
        // convert this trigger to trigger_once
-       self.classname = "trigger_once";
+       this.classname = "trigger_once";
        spawnfunc_trigger_once(this);
 
        // take over the touch() function, so we can mark secret as found
-       self.touch = trigger_secret_touch;
+       settouch(this, trigger_secret_touch);
        // ignore triggering;
-       self.use = func_null;
+       this.use = func_null;
 }
 #endif
index ad9c872dae6a4e17f3d233390186045539d16850..3a1cf9530b0c44ceed0c5b797f27ae4e38b5ea62 100644 (file)
@@ -22,8 +22,8 @@
 #ifdef SVQC
 spawnfunc(trigger_swamp);
 #endif
-void swamp_touch();
-void swampslug_think();
+void swamp_touch(entity this);
+void swampslug_think(entity this);
 
 
 /*
@@ -36,8 +36,8 @@ void swampslug_think();
 *
 * I do it this way becuz there is no "untouch" event.
 */
-void swampslug_think()
-{SELFPARAM();
+void swampslug_think(entity this)
+{
        //Slowly kill the slug
        self.health = self.health - 1;
 
@@ -60,8 +60,8 @@ void swampslug_think()
        self.nextthink = time + self.swamp_interval;
 }
 
-void swamp_touch()
-{SELFPARAM();
+void swamp_touch(entity this)
+{
        // If whatever thats touching the swamp is not a player
        // or if its a dead player, just dont care abt it.
        if(!IS_PLAYER(other) || IS_DEAD(other))
@@ -76,7 +76,7 @@ void swamp_touch()
                //centerprint(other,"Entering swamp!\n");
                other.swampslug = spawn();
                other.swampslug.health = 2;
-               other.swampslug.think = swampslug_think;
+               setthink(other.swampslug, swampslug_think);
                other.swampslug.nextthink = time;
                other.swampslug.owner = other;
                other.swampslug.dmg = self.dmg;
@@ -108,9 +108,9 @@ float swamp_send(entity this, entity to, float sf)
        return true;
 }
 
-void swamp_link()
-{SELFPARAM();
-       trigger_link(self, swamp_send);
+void swamp_link(entity this)
+{
+       trigger_link(this, swamp_send);
 }
 
 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
@@ -120,37 +120,37 @@ get slowd down and damaged
 spawnfunc(trigger_swamp)
 {
        // Init stuff
-       trigger_init(self);
-       self.touch = swamp_touch;
+       trigger_init(this);
+       settouch(this, swamp_touch);
 
        // Setup default keys, if missing
-       if(self.dmg <= 0)
-               self.dmg = 5;
-       if(self.swamp_interval <= 0)
-               self.swamp_interval = 1;
-       if(self.swamp_slowdown <= 0)
-               self.swamp_slowdown = 0.5;
-
-       swamp_link();
+       if(this.dmg <= 0)
+               this.dmg = 5;
+       if(this.swamp_interval <= 0)
+               this.swamp_interval = 1;
+       if(this.swamp_slowdown <= 0)
+               this.swamp_slowdown = 0.5;
+
+       swamp_link(this);
 }
 
 #elif defined(CSQC)
 
 NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew)
 {
-       self.dmg = ReadByte();
-       self.swamp_slowdown = ReadByte();
-       self.swamp_interval = ReadByte();
+       this.dmg = ReadByte();
+       this.swamp_slowdown = ReadByte();
+       this.swamp_interval = ReadByte();
 
-       trigger_common_read(false);
+       trigger_common_read(this, false);
 
        return = true;
 
-       self.classname = "trigger_swamp";
-       self.solid = SOLID_TRIGGER;
-       self.move_touch = swamp_touch;
-       self.drawmask = MASK_NORMAL;
-       self.move_time = time;
-       self.entremove = trigger_remove_generic;
+       this.classname = "trigger_swamp";
+       this.solid = SOLID_TRIGGER;
+       settouch(this, swamp_touch);
+       this.drawmask = MASK_NORMAL;
+       this.move_time = time;
+       this.entremove = trigger_remove_generic;
 }
 #endif
index c9b8147139aa8eb27b99a5b28694a41092e046ac..54777b75cb1aa57723aa5d0c4d90c6556bdcaeb7 100644 (file)
@@ -11,8 +11,8 @@ void trigger_teleport_use(entity this, entity actor, entity trigger)
 }
 #endif
 
-void Teleport_Touch ()
-{SELFPARAM();
+void Teleport_Touch (entity this)
+{
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -79,49 +79,47 @@ void trigger_teleport_link(entity this)
 
 spawnfunc(trigger_teleport)
 {
-       self.angles = '0 0 0';
+       this.angles = '0 0 0';
 
-       self.active = ACTIVE_ACTIVE;
-       //trigger_init(self); // only for predicted triggers?
+       this.active = ACTIVE_ACTIVE;
+       //trigger_init(this); // only for predicted triggers?
        EXACTTRIGGER_INIT;
-       self.use = trigger_teleport_use;
+       this.use = trigger_teleport_use;
 
-       if(self.noise != "")
-               FOREACH_WORD(self.noise, true, precache_sound(it));
+       if(this.noise != "")
+               FOREACH_WORD(this.noise, true, precache_sound(it));
 
        // this must be called to spawn the teleport waypoints for bots
-       InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
+       InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
 
-       if (self.target == "")
+       if (this.target == "")
        {
                objerror ("Teleporter with no target");
                return;
        }
 
-       self.teleport_next = teleport_first;
-       teleport_first = self;
+       this.teleport_next = teleport_first;
+       teleport_first = this;
 }
 #elif defined(CSQC)
 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
 {
-       self.classname = "trigger_teleport";
-       int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
-       self.spawnflags = ReadInt24_t();
-       self.active = ReadByte();
-       self.speed = ReadCoord();
-
-       trigger_common_read(true);
-
-       self.entremove = trigger_remove_generic;
-       self.solid = SOLID_TRIGGER;
-       //self.draw = trigger_draw_generic;
-       //self.move_touch = trigger_push_touch;
-       self.drawmask = MASK_NORMAL;
-       self.move_time = time;
-       defer(self, 0.25, teleport_findtarget);
-
-       self.teleport_next = teleport_first;
-       teleport_first = self;
+       this.classname = "trigger_teleport";
+       int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; }
+       this.spawnflags = ReadInt24_t();
+       this.active = ReadByte();
+       this.speed = ReadCoord();
+
+       trigger_common_read(this, true);
+
+       this.entremove = trigger_remove_generic;
+       this.solid = SOLID_TRIGGER;
+       //this.move_touch = trigger_push_touch;
+       this.move_time = time;
+       defer(this, 0.25, teleport_findtarget);
+
+       this.teleport_next = teleport_first;
+       teleport_first = this;
 
        return true;
 }
index db75434bfb6f98bd226f81bc72c07bbec718683b..d65fe953f39d2de0bd015d6ed74f747e53f5591c 100644 (file)
@@ -10,8 +10,8 @@ REGISTER_NET_LINKED(ENT_CLIENT_VIEWLOC_TRIGGER)
 
 #ifdef SVQC
 
-void viewloc_think()
-{SELFPARAM();
+void viewloc_think(entity this)
+{
        entity e;
 
        // we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities
@@ -45,12 +45,12 @@ bool trigger_viewloc_send(entity this, entity to, int sf)
        // CSQC doesn't need to know our origin (yet), as we're only available for referencing
        WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
 
-       WriteEntity(MSG_ENTITY, self.enemy);
-       WriteEntity(MSG_ENTITY, self.goalentity);
+       WriteEntity(MSG_ENTITY, this.enemy);
+       WriteEntity(MSG_ENTITY, this.goalentity);
 
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       WriteCoord(MSG_ENTITY, this.origin_x);
+       WriteCoord(MSG_ENTITY, this.origin_y);
+       WriteCoord(MSG_ENTITY, this.origin_z);
 
        return true;
 }
@@ -58,75 +58,75 @@ bool trigger_viewloc_send(entity this, entity to, int sf)
 void viewloc_init(entity this)
 {
        entity e;
-       for(e = world; (e = find(e, targetname, self.target)); )
+       for(e = world; (e = find(e, targetname, this.target)); )
                if(e.classname == "target_viewlocation_start")
                {
-                       self.enemy = e;
+                       this.enemy = e;
                        break;
                }
-       for(e = world; (e = find(e, targetname, self.target2)); )
+       for(e = world; (e = find(e, targetname, this.target2)); )
                if(e.classname == "target_viewlocation_end")
                {
-                       self.goalentity = e;
+                       this.goalentity = e;
                        break;
                }
 
-       if(!self.enemy) { LOG_INFO("^1FAIL!\n"); remove(self); return; }
+       if(!this.enemy) { LOG_INFO("^1FAIL!\n"); remove(this); return; }
 
-       if(!self.goalentity)
-               self.goalentity = self.enemy; // make them match so CSQC knows what to do
+       if(!this.goalentity)
+               this.goalentity = this.enemy; // make them match so CSQC knows what to do
 
-       Net_LinkEntity(self, false, 0, trigger_viewloc_send);
+       Net_LinkEntity(this, false, 0, trigger_viewloc_send);
 
-       self.think = viewloc_think;
-       self.nextthink = time;
+       setthink(this, viewloc_think);
+       this.nextthink = time;
 }
 
 spawnfunc(trigger_viewlocation)
 {
        // we won't check target2 here yet, as it may not even need to exist
-       if(self.target == "") { LOG_INFO("^1FAIL!\n"); remove(self); return; }
+       if(this.target == "") { LOG_INFO("^1FAIL!\n"); remove(this); return; }
 
        EXACTTRIGGER_INIT;
-       InitializeEntity(self, viewloc_init, INITPRIO_FINDTARGET);
+       InitializeEntity(this, viewloc_init, INITPRIO_FINDTARGET);
 }
 
 bool viewloc_send(entity this, entity to, int sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
 
-       WriteByte(MSG_ENTITY, self.cnt);
+       WriteByte(MSG_ENTITY, this.cnt);
 
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       WriteCoord(MSG_ENTITY, this.origin_x);
+       WriteCoord(MSG_ENTITY, this.origin_y);
+       WriteCoord(MSG_ENTITY, this.origin_z);
 
-       WriteCoord(MSG_ENTITY, self.angles_x);
-       WriteCoord(MSG_ENTITY, self.angles_y);
-       WriteCoord(MSG_ENTITY, self.angles_z);
+       WriteCoord(MSG_ENTITY, this.angles_x);
+       WriteCoord(MSG_ENTITY, this.angles_y);
+       WriteCoord(MSG_ENTITY, this.angles_z);
 
        return true;
 }
 
 .float angle;
-void viewloc_link()
-{SELFPARAM();
-       if(self.angle)
-               self.angles_y = self.angle;
-       Net_LinkEntity(self, false, 0, viewloc_send);
+void viewloc_link(entity this)
+{
+       if(this.angle)
+               this.angles_y = this.angle;
+       Net_LinkEntity(this, false, 0, viewloc_send);
 }
 
 spawnfunc(target_viewlocation_start)
 {
-       self.classname = "target_viewlocation_start";
-       self.cnt = 1;
-       viewloc_link();
+       this.classname = "target_viewlocation_start";
+       this.cnt = 1;
+       viewloc_link(this);
 }
 spawnfunc(target_viewlocation_end)
 {
-       self.classname = "target_viewlocation_end";
-       self.cnt = 2;
-       viewloc_link();
+       this.classname = "target_viewlocation_end";
+       this.cnt = 2;
+       viewloc_link(this);
 }
 
 // compatibility
@@ -134,8 +134,8 @@ spawnfunc(target_viewlocation) { spawnfunc_target_viewlocation_start(this); }
 
 #elif defined(CSQC)
 
-void trigger_viewloc_updatelink()
-{SELFPARAM();
+void trigger_viewloc_updatelink(entity this)
+{
        self.enemy = findfloat(world, entnum, self.cnt);
        self.goalentity = findfloat(world, entnum, self.count);
 }
@@ -145,44 +145,44 @@ NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
        float point1 = ReadShort();
        float point2 = ReadShort();
 
-       self.enemy = findfloat(world, entnum, point1);
-       self.goalentity = findfloat(world, entnum, point2);
+       this.enemy = findfloat(world, entnum, point1);
+       this.goalentity = findfloat(world, entnum, point2);
 
-       self.origin_x = ReadCoord();
-       self.origin_y = ReadCoord();
-       self.origin_z = ReadCoord();
+       this.origin_x = ReadCoord();
+       this.origin_y = ReadCoord();
+       this.origin_z = ReadCoord();
 
        return = true;
 
-       setorigin(self, self.origin);
+       setorigin(this, this.origin);
 
-       self.cnt = point1;
-       self.count = point2;
+       this.cnt = point1;
+       this.count = point2;
 
-       self.think = trigger_viewloc_updatelink;
-       self.nextthink = time + 1; // we need to delay this or else
+       setthink(this, trigger_viewloc_updatelink);
+       this.nextthink = time + 1; // we need to delay this or else
 
-       self.classname = "trigger_viewlocation";
-       self.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive
+       this.classname = "trigger_viewlocation";
+       this.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive
 }
 
 NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew)
 {
-       self.cnt = ReadByte();
+       this.cnt = ReadByte();
 
-       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);
 
-       self.movedir_x = ReadCoord();
-       self.movedir_y = ReadCoord();
-       self.movedir_z = ReadCoord();
+       this.movedir_x = ReadCoord();
+       this.movedir_y = ReadCoord();
+       this.movedir_z = ReadCoord();
 
        return = true;
 
-       self.classname = ((self.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start");
-       self.drawmask = MASK_NORMAL; // don't cull it
+       this.classname = ((this.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start");
+       this.drawmask = MASK_NORMAL; // don't cull it
 }
 
 #endif
index 4493138d08dca032f149aaba09a4f8e5f2817f53..d9c6a08126a90672e85be1966b31144faeba8ef2 100644 (file)
@@ -2,8 +2,8 @@ void SUB_DontUseTargets(entity this, entity actor, entity trigger) { }
 
 void SUB_UseTargets(entity this, entity actor, entity trigger);
 
-void DelayThink()
-{SELFPARAM();
+void DelayThink(entity this)
+{
        SUB_UseTargets (this, this.enemy, NULL);
        remove(this);
 }
@@ -24,7 +24,7 @@ void FixSize(entity e)
 void trigger_init(entity this)
 {
        string m = this.model;
-       WITHSELF(this, WarpZoneLib_ExactTrigger_Init());
+       EXACTTRIGGER_INIT;
        if(m != "")
        {
                precache_model(m);
@@ -92,8 +92,8 @@ void trigger_common_write(entity this, bool withtarget)
 
 #elif defined(CSQC)
 
-void trigger_common_read(bool withtarget)
-{SELFPARAM();
+void trigger_common_read(entity this, bool withtarget)
+{
        int f = ReadByte();
        this.warpzone_isboxy = (f & 1);
 
@@ -193,7 +193,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
        // create a temp object to fire at a later time
                entity t = new(DelayedUse);
                t.nextthink = time + this.delay;
-               t.think = DelayThink;
+               setthink(t, DelayThink);
                t.enemy = actor;
                t.message = this.message;
                t.killtarget = this.killtarget;
@@ -276,38 +276,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
                RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this);
 }
 
-void SUB_UseTargets_self()
-{SELFPARAM();
-       SUB_UseTargets(this, NULL, NULL);
-}
-
-#ifdef CSQC
-void trigger_touch_generic(entity this, void() touchfunc)
-{
-       entity e;
-       for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
-       if(e.classname == "csqcprojectile")
-       {
-               vector emin = e.absmin, emax = e.absmax;
-               if(this.solid == SOLID_BSP)
-               {
-                       emin -= '1 1 1';
-                       emax += '1 1 1';
-               }
-               if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
-               if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
-               {
-                       other = e;
-                       WITHSELF(this, touchfunc());
-               }
-       }
-}
-void trigger_draw_generic(entity this)
+void SUB_UseTargets_self(entity this)
 {
-       float dt = time - this.move_time;
-       this.move_time = time;
-       if(dt <= 0) { return; }
-
-       if(this.trigger_touch) { trigger_touch_generic(this, this.trigger_touch); }
+       SUB_UseTargets(this, NULL, NULL);
 }
-#endif
index 69d53fba41d9d6707a91d9aba7b1801bdca1c5c2..5e24781e696faa23ef56148cd848e746d0f341f5 100644 (file)
@@ -8,8 +8,6 @@ const float SF_TRIGGER_RESET = 4;
 const float    SPAWNFLAG_NOMESSAGE = 1;
 const float    SPAWNFLAG_NOTOUCH = 1;
 
-.void() trigger_touch;
-
 .bool pushable;
 
 .float antiwall_flag; // Variable to define what to do with func_clientwall
@@ -39,7 +37,7 @@ void target_voicescript_clear(entity pl);
 void FixSize(entity e);
 
 #ifdef CSQC
-void trigger_common_read(bool withtarget);
+void trigger_common_read(entity this, bool withtarget);
 void trigger_remove_generic(entity this);
 
 .float active;
index bb2bff22c8bf3179befb6610f7240773693126fe..2f3b11a7d9f76716d86f2facf36570ca4ae807f5 100644 (file)
@@ -51,8 +51,8 @@ If a loop is of targets are formed, any unit entering this loop will patrol it i
 If the checkpoint chain in not looped, the unit will go "Roaming" when the last point is reached.
 */
 //float tc_acum;
-void turret_checkpoint_init()
-{SELFPARAM();
+void turret_checkpoint_init(entity this)
+{
     traceline(self.origin + '0 0 16', self.origin - '0 0 1024', MOVE_WORLDONLY, self);
     setorigin(self, trace_endpos + '0 0 32');
 
@@ -69,14 +69,14 @@ void turret_checkpoint_init()
 
 spawnfunc(turret_checkpoint)
 {
-    setorigin(self,self.origin);
-    self.think = turret_checkpoint_init;
-    self.nextthink = time + 0.2;
+    setorigin(this,this.origin);
+    setthink(this, turret_checkpoint_init);
+    this.nextthink = time + 0.2;
 }
 
 // Compat.
 spawnfunc(walker_checkpoint)
 {
-    self.classname = "turret_checkpoint";
+    this.classname = "turret_checkpoint";
     spawnfunc_turret_checkpoint(this);
 }
index 079d6b3f0dbc445577c8b95b1834f81d0e0d353e..0fc168c2cac60c85a1d2035aa89d1ac132085b40 100644 (file)
@@ -6,16 +6,16 @@ void turret_remove(entity this)
 }
 
 .vector glowmod;
-void turret_changeteam()
-{SELFPARAM();
-       self.glowmod = Team_ColorRGB(self.team - 1) * 2;
-       self.teamradar_color = Team_ColorRGB(self.team - 1);
+void turret_changeteam(entity this)
+{
+       this.glowmod = Team_ColorRGB(this.team - 1) * 2;
+       this.teamradar_color = Team_ColorRGB(this.team - 1);
 
-       if(self.team)
-               self.colormap = 1024 + (self.team - 1) * 17;
+       if(this.team)
+               this.colormap = 1024 + (this.team - 1) * 17;
 
-       self.tur_head.colormap = self.colormap;
-       self.tur_head.glowmod = self.glowmod;
+       this.tur_head.colormap = this.colormap;
+       this.tur_head.glowmod = this.glowmod;
 
 }
 
@@ -313,8 +313,8 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
        return gib;
 }
 
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
        sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        pointparticles(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
        if (!autocvar_cl_nogibs)
@@ -359,85 +359,85 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
 
        if(sf & TNSF_SETUP)
        {
-               self.m_id = ReadByte();
+               this.m_id = ReadByte();
 
-               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);
 
-               self.angles_x = ReadAngle();
-               self.angles_y = ReadAngle();
+               this.angles_x = ReadAngle();
+               this.angles_y = ReadAngle();
 
                turret_construct();
-               self.colormap = 1024;
-               self.glowmod = '0 1 1';
-               self.tur_head.colormap = self.colormap;
-               self.tur_head.glowmod = self.glowmod;
+               this.colormap = 1024;
+               this.glowmod = '0 1 1';
+               this.tur_head.colormap = this.colormap;
+               this.tur_head.glowmod = this.glowmod;
        }
 
        if(sf & TNSF_ANG)
        {
-               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-                       self.tur_head = spawn();
+               if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       this.tur_head = spawn();
 
-               self.tur_head.move_angles_x = ReadShort();
-               self.tur_head.move_angles_y = ReadShort();
-               //self.tur_head.angles = self.angles + self.tur_head.move_angles;
-               self.tur_head.angles = self.tur_head.move_angles;
+               this.tur_head.move_angles_x = ReadShort();
+               this.tur_head.move_angles_y = ReadShort();
+               //this.tur_head.angles = this.angles + this.tur_head.move_angles;
+               this.tur_head.angles = this.tur_head.move_angles;
        }
 
        if(sf & TNSF_AVEL)
        {
-               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-                       self.tur_head = spawn();
+               if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       this.tur_head = spawn();
 
-               self.tur_head.move_avelocity_x = ReadShort();
-               self.tur_head.move_avelocity_y = ReadShort();
+               this.tur_head.move_avelocity_x = ReadShort();
+               this.tur_head.move_avelocity_y = ReadShort();
        }
 
        if(sf & TNSF_MOVE)
        {
-               self.origin_x = ReadShort();
-               self.origin_y = ReadShort();
-               self.origin_z = ReadShort();
-               setorigin(self, self.origin);
+               this.origin_x = ReadShort();
+               this.origin_y = ReadShort();
+               this.origin_z = ReadShort();
+               setorigin(this, this.origin);
 
-               self.velocity_x = ReadShort();
-               self.velocity_y = ReadShort();
-               self.velocity_z = ReadShort();
+               this.velocity_x = ReadShort();
+               this.velocity_y = ReadShort();
+               this.velocity_z = ReadShort();
 
-               self.move_angles_y = ReadShort();
+               this.move_angles_y = ReadShort();
 
-               self.move_time   = time;
-               self.move_velocity = self.velocity;
-               self.move_origin   = self.origin;
+               this.move_time   = time;
+               this.move_velocity = this.velocity;
+               this.move_origin   = this.origin;
        }
 
        if(sf & TNSF_ANIM)
        {
-               self.frame1time = ReadCoord();
-               self.frame        = ReadByte();
+               this.frame1time = ReadCoord();
+               this.frame        = ReadByte();
        }
 
        if(sf & TNSF_STATUS)
        {
                float _tmp;
                _tmp = ReadByte();
-               if(_tmp != self.team)
+               if(_tmp != this.team)
                {
-                       self.team = _tmp;
-                       turret_changeteam();
+                       this.team = _tmp;
+                       turret_changeteam(this);
                }
 
                _tmp = ReadByte();
-               if(_tmp == 0 && self.health != 0)
-                       turret_die();
-               else if(self.health && self.health != _tmp)
-                       self.helpme = servertime + 10;
+               if(_tmp == 0 && this.health != 0)
+                       turret_die(this);
+               else if(this.health && this.health != _tmp)
+                       this.helpme = servertime + 10;
 
-               self.health = _tmp;
+               this.health = _tmp;
        }
-       //self.enemy.health = self.health / 255;
+       //this.enemy.health = this.health / 255;
        return true;
 }
index 2578c1e6dba117bc781648eb08e6bfa94f5aeccc..769c0edf720bfc241d81a5b817f131bbebf6f7a9 100644 (file)
@@ -164,15 +164,15 @@ float turret_targetscore_generic(entity _turret, entity _target)
 }
 
 // Generic damage handling
-void turret_hide()
-{SELFPARAM();
+void turret_hide(entity this)
+{
        self.effects   |= EF_NODRAW;
        self.nextthink = time + self.respawntime - 0.2;
-       self.think       = turret_respawn;
+       setthink(self, turret_respawn);
 }
 
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
        self.deadflag             = DEAD_DEAD;
        self.tur_head.deadflag = self.deadflag;
 
@@ -201,7 +201,7 @@ void turret_die()
                // Setup respawn
                self.SendFlags    |= TNSF_STATUS;
                self.nextthink   = time + 0.2;
-               self.think               = turret_hide;
+               setthink(self, turret_hide);
 
                tur.tr_death(tur, self);
        }
@@ -245,15 +245,15 @@ void turret_damage(entity this, entity inflictor, entity attacker, float damage,
                this.tur_head.event_damage = func_null;
                this.takedamage                  = DAMAGE_NO;
                this.nextthink = time;
-               this.think = turret_die;
+               setthink(this, turret_die);
        }
 
        this.SendFlags  |= TNSF_STATUS;
 }
 
-void() turret_think;
-void turret_respawn()
-{SELFPARAM();
+void turret_think(entity this);
+void turret_respawn(entity this)
+{
        // Make sure all parts belong to the same team since
        // this function doubles as "teamchange" function.
        self.tur_head.team      = self.team;
@@ -272,7 +272,7 @@ void turret_respawn()
        self.ammo                                       = self.ammo_max;
 
        self.nextthink = time + self.ticrate;
-       self.think       = turret_think;
+       setthink(self, turret_think);
 
        self.SendFlags = TNSF_FULL_UPDATE;
 
@@ -427,8 +427,8 @@ void load_unit_settings(entity ent, bool is_reload)
        }
 }
 
-void turret_projectile_explode()
-{SELFPARAM();
+void turret_projectile_explode(entity this)
+{
 
        self.takedamage = DAMAGE_NO;
        self.event_damage = func_null;
@@ -443,10 +443,10 @@ void turret_projectile_explode()
        remove(self);
 }
 
-void turret_projectile_touch()
+void turret_projectile_touch(entity this)
 {
-       PROJECTILE_TOUCH;
-       turret_projectile_explode();
+       PROJECTILE_TOUCH(this);
+       turret_projectile_explode(this);
 }
 
 void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
@@ -471,8 +471,8 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
        proj.realowner    = self;
        proj.bot_dodge    = true;
        proj.bot_dodgerating = self.shot_dmg;
-       proj.think                = turret_projectile_explode;
-       proj.touch                = turret_projectile_touch;
+       setthink(proj, turret_projectile_explode);
+       settouch(proj, turret_projectile_touch);
        proj.nextthink    = time + 9;
        proj.movetype           = MOVETYPE_FLYMISSILE;
        proj.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
@@ -499,39 +499,33 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
 ** and updated aim<->predict impact distance.
 **/
 void turret_do_updates(entity t_turret)
-{SELFPARAM();
-       vector enemy_pos;
-
-       setself(t_turret);
-
-       enemy_pos = real_origin(self.enemy);
+{
+       vector enemy_pos = real_origin(t_turret.enemy);
 
-       turret_tag_fire_update();
+       WITHSELF(t_turret, turret_tag_fire_update());
 
-       self.tur_shotdir_updated = v_forward;
-       self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos);
-       self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos);
+       t_turret.tur_shotdir_updated = v_forward;
+       t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos);
+       t_turret.tur_dist_aimpos = vlen(t_turret.tur_shotorg - t_turret.tur_aimpos);
 
-       /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy))
+       /*if((t_turret.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (t_turret.enemy))
        {
-               oldpos = self.enemy.origin;
-               setorigin(self.enemy, self.tur_aimpos);
-               tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-               setorigin(self.enemy, oldpos);
+               oldpos = t_turret.enemy.origin;
+               setorigin(t_turret.enemy, t_turret.tur_aimpos);
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1', '1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
+               setorigin(t_turret.enemy, oldpos);
 
-               if(trace_ent == self.enemy)
-                       self.tur_dist_impact_to_aimpos = 0;
+               if(trace_ent == t_turret.enemy)
+                       t_turret.tur_dist_impact_to_aimpos = 0;
                else
-                       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos);
+                       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos);
        }
        else*/
-               tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-
-       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
-       self.tur_impactent                       = trace_ent;
-       self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1','1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
 
-       setself(this);
+       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos) - (vlen(t_turret.enemy.maxs - t_turret.enemy.mins) * 0.5);
+       t_turret.tur_impactent                   = trace_ent;
+       t_turret.tur_impacttime                 = vlen(t_turret.tur_shotorg - trace_endpos) / t_turret.shot_speed;
 }
 
 /**
@@ -1017,8 +1011,8 @@ void turret_fire()
 #endif
 }
 
-void turret_think()
-{SELFPARAM();
+void turret_think(entity this)
+{
        self.nextthink = time + self.ticrate;
 
        MUTATOR_CALLHOOK(TurretThink, self);
@@ -1195,14 +1189,13 @@ void turret_use(entity this, entity actor, entity trigger)
 void turret_link()
 {SELFPARAM();
        Net_LinkEntity(self, true, 0, turret_send);
-       self.think       = turret_think;
+       setthink(self, turret_think);
        self.nextthink = time;
        self.tur_head.effects = EF_NODRAW;
 }
 
-void turrets_manager_think()
+void turrets_manager_think(entity this)
 {
-       SELFPARAM();
        this.nextthink = time + 1;
 
        if (autocvar_g_turrets_reloadcvars == 1)
@@ -1262,7 +1255,7 @@ float turret_initialize(Turret tur)
        if(!e)
        {
                e = new(turret_manager);
-               e.think = turrets_manager_think;
+               setthink(e, turrets_manager_think);
                e.nextthink = time + 2;
        }
 
@@ -1386,7 +1379,7 @@ float turret_initialize(Turret tur)
 #endif
 
        turret_link();
-       turret_respawn();
+       turret_respawn(self);
        turret_tag_fire_update();
 
        tur.tr_setup(tur, self);
index 622f2360f7d0aec8fd6ad109129a04e98972ffa8..1d492e8164a057cf17f799ef58a773f532461803 100644 (file)
@@ -2,7 +2,7 @@
 #define SV_TURRETS_H
 
 entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
-void turret_projectile_explode();
+void turret_projectile_explode(entity this);
 float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
 float turret_firecheck();
 entity turret_select_target();
@@ -77,7 +77,7 @@ const float TFL_TRACKTYPE_FLUIDINERTIA = 3; // simulated inertia ("wobbly" mode)
 .float track_accel_rotate;
 .float track_blendrate;
 
-void() turret_respawn;
+void turret_respawn(entity this);
 
 /// updates aim org, shot org, shot dir and enemy org for selected turret
 void turret_do_updates(entity e_turret);
index 625746341750754f0f6336550a1eff867aaf1430..4828bf0b34c17b078126affea19477e9d7929014 100644 (file)
@@ -1,37 +1,24 @@
 spawnfunc(turret_targettrigger);
-void turret_targettrigger_touch();
+void turret_targettrigger_touch(entity this);
 
-void turret_targettrigger_touch()
-{SELFPARAM();
-    entity e;
-    if (self.cnt > time) return;
-    entity oldself = this;
-
-    e = find(world, targetname, self.target);
-    while (e)
-    {
-        if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
-        {
-            setself(e);
-            if(e.turret_addtarget)
-                e.turret_addtarget(other,oldself);
-        }
-
-        e = find(e, targetname, oldself.target);
-    }
-
-    oldself.cnt = time + 0.5;
-
-    setself(this);
+void turret_targettrigger_touch(entity this)
+{
+    if (this.cnt > time) return;
+    FOREACH_ENTITY_STRING_ORDERED(targetname, this.target, {
+        if (!(it.turret_flags & TUR_FLAG_RECIEVETARGETS)) continue;
+        if (!it.turret_addtarget) continue;
+        WITHSELF(it, it.turret_addtarget(other, this));
+    });
+    this.cnt = time + 0.5;
 }
 
 /*QUAKED turret_targettrigger (.5 .5 .5) ?
 */
 spawnfunc(turret_targettrigger)
 {
-    if(!autocvar_g_turrets) { remove(self); return; }
+    if(!autocvar_g_turrets) { remove(this); return; }
 
-    InitTrigger ();
+    WITHSELF(this, InitTrigger());
 
-    self.touch = turret_targettrigger_touch;
+    settouch(this, turret_targettrigger_touch);
 }
index 0bdfca46ed2cec92acc84a9f96d81f34114e4385..113431003c93053903b04ae4768616314e6c6ff6 100644 (file)
@@ -54,7 +54,7 @@ void ewheel_move_path()
 
                 if (self.pathgoal.enemy)
                 {
-                    self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
+                    self.pathcurrent = pathlib_astar(self, self.pathgoal.origin,self.pathgoal.enemy.origin);
                     self.pathgoal = self.pathgoal.enemy;
                 }
             }
@@ -83,7 +83,7 @@ void ewheel_move_enemy()
 {SELFPARAM();
     float newframe;
 
-    self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
+    self.steerto = steerlib_arrive(self, self.enemy.origin,self.target_range_optimal);
 
     self.moveto  = self.origin + self.steerto * 128;
 
@@ -133,7 +133,7 @@ void ewheel_move_idle()
         movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop));
 }
 
-spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(this); }
 
 METHOD(EWheel, tr_think, void(EWheel thistur, entity it))
 {
@@ -207,7 +207,7 @@ METHOD(EWheel, tr_setup, void(EWheel this, entity it))
             {
 
 #ifdef EWHEEL_FANCYPATH
-                it.pathcurrent = WALKER_PATH(it.origin,e.origin);
+                it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
                 it.pathgoal = e;
 #else
                 it.pathcurrent  = e;
index 6bd6a3ff1462389ec9eb65649826614722e7470a..0969018d629b19d85a927217d43e0c12886a36bc 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(FLAC, NEW(Flac));
 
 #ifdef SVQC
 
-spawnfunc(turret_flac) { if (!turret_initialize(TUR_FLAC)) remove(self); }
+spawnfunc(turret_flac) { if (!turret_initialize(TUR_FLAC)) remove(this); }
 
 METHOD(Flac, tr_setup, void(Flac this, entity it))
 {
index 175fa7617ffdc24812da3130256d2fc7561dadfe..eb8db7358f5820807035b1f445266ba45716d726 100644 (file)
@@ -4,7 +4,7 @@
 
 #ifdef SVQC
 
-void turret_flac_projectile_think_explode();
+void turret_flac_projectile_think_explode(entity this);
 SOUND(FlacAttack_FIRE, W_Sound("electro_fire"));
 METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
@@ -24,7 +24,7 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen
 
         entity proj = turret_projectile(SND_HAGAR_FIRE, 5, 0, DEATH_TURRET_FLAC.m_id, PROJECTILE_HAGAR, true, true);
         proj.missile_flags = MIF_SPLASH | MIF_PROXY;
-        proj.think       = turret_flac_projectile_think_explode;
+        setthink(proj, turret_flac_projectile_think_explode);
         proj.nextthink  = time + actor.tur_impacttime + (random() * 0.01 - random() * 0.01);
         Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1);
 
@@ -36,9 +36,8 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen
     }
 }
 
-void turret_flac_projectile_think_explode()
+void turret_flac_projectile_think_explode(entity this)
 {
-    SELFPARAM();
     if(self.enemy != world)
     if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 3))
         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
index 5c253d4c571ab9df1a7025f3f1b5a4136fd9618a..9b67e1db2fd714cbd0b4e972ce2380bd921d37c6 100644 (file)
@@ -46,7 +46,7 @@ bool turret_fusionreactor_firecheck()
     return true;
 }
 
-spawnfunc(turret_fusionreactor) { if (!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
+spawnfunc(turret_fusionreactor) { if (!turret_initialize(TUR_FUSIONREACTOR)) remove(this); }
 
 METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
 {
index ef279f7611fd767cbdcc2e289489b91edf68579b..b3100bcb5e8aeb7e1a474b87ca2bf38b16644ee5 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(HELLION, NEW(Hellion));
 
 #ifdef SVQC
 
-spawnfunc(turret_hellion) { if (!turret_initialize(TUR_HELLION)) remove(self); }
+spawnfunc(turret_hellion) { if (!turret_initialize(TUR_HELLION)) remove(this); }
 
 METHOD(Hellion, tr_think, void(Hellion thistur, entity it))
 {
index 7df79c8c7e03d41f1c1fc214047b51b8abac9674..2b80607ce7e1b66ee4fe29b985723de419c415d7 100644 (file)
@@ -7,7 +7,7 @@
 float autocvar_g_turrets_unit_hellion_shot_speed_gain;
 float autocvar_g_turrets_unit_hellion_shot_speed_max;
 
-void turret_hellion_missile_think();
+void turret_hellion_missile_think(entity this);
 SOUND(HellionAttack_FIRE, W_Sound("electro_fire"));
 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
@@ -31,7 +31,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo
 
         entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false);
         te_explosion (missile.origin);
-        missile.think          = turret_hellion_missile_think;
+        setthink(missile, turret_hellion_missile_think);
         missile.nextthink      = time;
         missile.flags          = FL_PROJECTILE;
         missile.max_health   = time + 9;
@@ -41,8 +41,8 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo
     }
 }
 
-void turret_hellion_missile_think()
-{SELFPARAM();
+void turret_hellion_missile_think(entity this)
+{
     vector olddir,newdir;
     vector pre_pos;
     float itime;
@@ -52,7 +52,7 @@ void turret_hellion_missile_think()
     olddir = normalize(self.velocity);
 
     if(self.max_health < time)
-        turret_projectile_explode();
+        turret_projectile_explode(self);
 
     // Enemy dead? just keep on the current heading then.
     if ((self.enemy == world) || (IS_DEAD(self.enemy)))
@@ -65,7 +65,7 @@ void turret_hellion_missile_think()
         self.angles = vectoangles(self.velocity);
 
         if(vdist(self.origin - self.owner.origin, >, (self.owner.shot_radius * 5)))
-            turret_projectile_explode();
+            turret_projectile_explode(self);
 
         // Accelerate
         self.velocity = olddir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
@@ -77,7 +77,7 @@ void turret_hellion_missile_think()
 
     // Enemy in range?
     if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 0.2))
-        turret_projectile_explode();
+        turret_projectile_explode(self);
 
     // Predict enemy position
     itime = vlen(self.enemy.origin - self.origin) / vlen(self.velocity);
@@ -98,7 +98,7 @@ void turret_hellion_missile_think()
     self.velocity = newdir * min(vlen(self.velocity) * (autocvar_g_turrets_unit_hellion_shot_speed_gain), (autocvar_g_turrets_unit_hellion_shot_speed_max));
 
     if (itime < 0.05)
-        self.think = turret_projectile_explode;
+        setthink(self, turret_projectile_explode);
 
     UpdateCSQCProjectile(self);
 }
index 4e7b4513818e1b0e264e080fdf23a44361541bf6..2c9f68cf7cd526bc23f2b2d8d77413dd62b0c923 100644 (file)
@@ -28,7 +28,7 @@ REGISTER_TURRET(HK, NEW(HunterKiller));
 .float atime;
 #endif
 
-spawnfunc(turret_hk) { if(!turret_initialize(TUR_HK)) remove(self); }
+spawnfunc(turret_hk) { if(!turret_initialize(TUR_HK)) remove(this); }
 
 METHOD(HunterKiller, tr_think, void(HunterKiller thistur, entity it))
 {
index 319a579cf2bac4d537e4d2c497f329f75bd2d409..dffe83c8283d135b220e0cd4509269de57be9458 100644 (file)
@@ -11,7 +11,7 @@ float autocvar_g_turrets_unit_hk_shot_speed_decel;
 float autocvar_g_turrets_unit_hk_shot_speed_max;
 float autocvar_g_turrets_unit_hk_shot_speed_turnrate;
 
-void turret_hk_missile_think();
+void turret_hk_missile_think(entity this);
 SOUND(HunterKillerAttack_FIRE, W_Sound("electro_fire"));
 METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
@@ -29,7 +29,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity
         entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false);
         te_explosion (missile.origin);
 
-        missile.think = turret_hk_missile_think;
+        setthink(missile, turret_hk_missile_think);
         missile.nextthink = time + 0.25;
         missile.movetype = MOVETYPE_BOUNCEMISSILE;
         missile.velocity = actor.tur_shotdir_updated * (actor.shot_speed * 0.75);
@@ -45,8 +45,8 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity
 }
 
 bool hk_is_valid_target(entity e_target);
-void turret_hk_missile_think()
-{SELFPARAM();
+void turret_hk_missile_think(entity this)
+{
     vector vu, vd, vf, vl, vr, ve;  // Vector (direction)
     float  fu, fd, ff, fl, fr, fe;  // Fraction to solid
     vector olddir,wishdir,newdir;   // Final direction
@@ -95,7 +95,7 @@ void turret_hk_missile_think()
         // Close enougth to do decent damage?
         if ( edist <= (self.owner.shot_radius * 0.25) )
         {
-            turret_projectile_explode();
+            turret_projectile_explode(self);
             return;
         }
 
index e919026570af16da0598a4dbb9dbaff79b2473ac..5202ea371e6ccc4503000993944ca72e4165d023 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(MACHINEGUN, NEW(MachineGunTurret));
 
 #ifdef SVQC
 
-spawnfunc(turret_machinegun) { if (!turret_initialize(TUR_MACHINEGUN)) remove(self); }
+spawnfunc(turret_machinegun) { if (!turret_initialize(TUR_MACHINEGUN)) remove(this); }
 
 METHOD(MachineGunTurret, tr_setup, void(MachineGunTurret this, entity it))
 {
index 853750f6caf7fd839b3a7d4e50d4d38ec0b23440..34cd32d74279c07a8ebda0744d5cab5e422a1810 100644 (file)
@@ -4,7 +4,7 @@
 
 #ifdef SVQC
 
-void W_MachineGun_MuzzleFlash();
+void W_MachineGun_MuzzleFlash(entity actor);
 SOUND(MachineGunTurretAttack_FIRE, W_Sound("electro_fire"));
 METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
@@ -20,7 +20,7 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .ent
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         }
         fireBullet (actor, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, 0);
-        W_MachineGun_MuzzleFlash();
+        W_MachineGun_MuzzleFlash(actor);
         setattachment(actor.muzzle_flash, actor.tur_head, "tag_fire");
     }
 }
index 43710b6c02f91e6b82ee5eb220b8a41874484d6a..bff2586053edc8e9513c13d124029ee7c6af180f 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(MLRS, NEW(MLRSTurret));
 
 #ifdef SVQC
 
-spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(self); }
+spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(this); }
 
 METHOD(MLRSTurret, tr_think, void(MLRSTurret thistur, entity it))
 {
index e4c0c119a434af41591fd94a3527a06a35af226a..7675bc41e9adc6c33954ec0d178a0880728788f1 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(PHASER, NEW(PhaserTurret));
 
 #ifdef SVQC
 
-spawnfunc(turret_phaser) { if (!turret_initialize(TUR_PHASER)) remove(self); }
+spawnfunc(turret_phaser) { if (!turret_initialize(TUR_PHASER)) remove(this); }
 
 .int fireflag;
 
index 440bdf6a7299a6271363f3968b03a55d258d0db5..1f6d62c95b78bb7fa13a81b8955b00ef4f6b2a05 100644 (file)
@@ -3,7 +3,7 @@
 #ifdef IMPLEMENTATION
 
 #ifdef SVQC
-void beam_think();
+void beam_think(entity this);
 
 .int fireflag;
 SOUND(PhaserTurretAttack_FIRE, W_Sound("electro_fire"));
@@ -26,7 +26,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
         setmodel(beam, MDL_TUR_PHASER_BEAM);
         beam.effects = EF_LOWPRECISION;
         beam.solid = SOLID_NOT;
-        beam.think = beam_think;
+        setthink(beam, beam_think);
         beam.cnt = time + actor.shot_speed;
         beam.shot_spread = time + 2;
         beam.nextthink = time;
@@ -52,8 +52,8 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
     }
 }
 
-void beam_think()
-{SELFPARAM();
+void beam_think(entity this)
+{
     if ((time > self.cnt) || (IS_DEAD(self.owner)))
     {
         self.owner.attack_finished_single[0] = time + self.owner.shot_refire;
@@ -76,8 +76,7 @@ void beam_think()
     self.nextthink = time + self.ticrate;
 
     self.owner.attack_finished_single[0] = time + frametime;
-    setself(self.owner);
-    FireImoBeam (   self.tur_shotorg,
+    FireImoBeam (   self.owner, self.tur_shotorg,
                     self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
                     '-1 -1 -1' * self.shot_radius,
                     '1 1 1' * self.shot_radius,
@@ -85,7 +84,6 @@ void beam_think()
                     this.shot_dmg,
                     0.75,
                     DEATH_TURRET_PHASER.m_id);
-    setself(this);
     self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
 
 }
index 5b2fd0f35fc363602e0abb9d20e2437385b94401..97f5c5659721767a2c08a9e54d2ef5eade95949a 100644 (file)
@@ -22,13 +22,13 @@ REGISTER_TURRET(PLASMA, NEW(PlasmaTurret));
 
 #ifdef SVQC
 
-spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(self); }
+spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(this); }
 
 METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
 {
     if(g_instagib)
     {
-        FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (self, self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
         Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
index 55226bd864d47f87d92c9caa3fa819bb6b5a7cc9..9874fb3cbd26bc1273a74efaead905e08300a72c 100644 (file)
@@ -28,13 +28,13 @@ REGISTER_TURRET(PLASMA_DUAL, NEW(DualPlasmaTurret));
 
 #ifdef SVQC
 
-spawnfunc(turret_plasma_dual) { if (!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
+spawnfunc(turret_plasma_dual) { if (!turret_initialize(TUR_PLASMA_DUAL)) remove(this); }
 
 METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it))
 {
     SELFPARAM();
     if (g_instagib) {
-        FireRailgunBullet (self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (self, self.tur_shotorg, self.tur_shotorg + self.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
 
index 510331c637400fe19586cee4767fff7cffaabd81..35929ccc5dde1f680da289744a3671c996bc33d6 100644 (file)
@@ -22,7 +22,7 @@ REGISTER_TURRET(TESLA, NEW(TeslaCoil));
 
 #ifdef SVQC
 
-spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(self); }
+spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(this); }
 
 METHOD(TeslaCoil, tr_think, void(TeslaCoil thistur, entity it))
 {
index 51ace9a7d0ddab65889b3c062d587743cdc022e1..fec4060d44f30841b7fe32ca5b6403efce804600 100644 (file)
@@ -63,7 +63,7 @@ const int ANIM_ROAM       = 11;
 .float animflag;
 .float idletime;
 
-#define WALKER_PATH(s,e) pathlib_astar(s,e)
+#define WALKER_PATH(this, s, e) pathlib_astar(this, s, e)
 
 float walker_firecheck()
 {SELFPARAM();
@@ -97,8 +97,8 @@ void walker_setnoanim(entity this)
     turrets_setframe(ANIM_NO, false);
     self.animflag = self.frame;
 }
-void walker_rocket_explode()
-{SELFPARAM();
+void walker_rocket_explode(entity this)
+{
     RadiusDamage (self, self.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), self, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, world);
     remove (self);
 }
@@ -113,9 +113,9 @@ void walker_rocket_damage(entity this, entity inflictor, entity attacker, float
 }
 
 #define WALKER_ROCKET_MOVE movelib_move_simple(self, newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self)
-void walker_rocket_loop();
-void walker_rocket_think()
-{SELFPARAM();
+void walker_rocket_loop(entity this);
+void walker_rocket_think(entity this)
+{
     vector newdir;
     float edist;
     float itime;
@@ -141,14 +141,14 @@ void walker_rocket_think()
 
     if (self.max_health < time)
     {
-        self.think       = walker_rocket_explode;
+        setthink(self, walker_rocket_explode);
         self.nextthink  = time;
         return;
     }
 
     if (self.shot_dmg != 1337 && random() < 0.01)
     {
-        walker_rocket_loop();
+        walker_rocket_loop(self);
         return;
     }
 
@@ -161,7 +161,7 @@ void walker_rocket_think()
     if (self.enemy)
     {
         itime = max(edist / m_speed, 1);
-        newdir = steerlib_pull(self.enemy.origin + self.tur_shotorg);
+        newdir = steerlib_pull(self, self.enemy.origin + self.tur_shotorg);
     }
     else
         newdir  = normalize(self.velocity);
@@ -169,57 +169,57 @@ void walker_rocket_think()
     WALKER_ROCKET_MOVE;
 }
 
-void walker_rocket_loop3()
-{SELFPARAM();
+void walker_rocket_loop3(entity this)
+{
     vector newdir;
     self.nextthink = time;
 
     if (self.max_health < time)
     {
-        self.think = walker_rocket_explode;
+        setthink(self, walker_rocket_explode);
         return;
     }
 
     if(vdist(self.origin - self.tur_shotorg, <, 100))
     {
-        self.think = walker_rocket_think;
+        setthink(self, walker_rocket_think);
         return;
     }
 
-    newdir = steerlib_pull(self.tur_shotorg);
+    newdir = steerlib_pull(self, self.tur_shotorg);
     WALKER_ROCKET_MOVE;
 
     self.angles = vectoangles(self.velocity);
 }
 
-void walker_rocket_loop2()
-{SELFPARAM();
+void walker_rocket_loop2(entity this)
+{
     vector newdir;
 
     self.nextthink = time;
 
     if (self.max_health < time)
     {
-        self.think = walker_rocket_explode;
+        setthink(self, walker_rocket_explode);
         return;
     }
 
     if(vdist(self.origin - self.tur_shotorg, <, 100))
     {
         self.tur_shotorg = self.origin - '0 0 200';
-        self.think = walker_rocket_loop3;
+        setthink(self, walker_rocket_loop3);
         return;
     }
 
-    newdir = steerlib_pull(self.tur_shotorg);
+    newdir = steerlib_pull(self, self.tur_shotorg);
     WALKER_ROCKET_MOVE;
 }
 
-void walker_rocket_loop()
-{SELFPARAM();
+void walker_rocket_loop(entity this)
+{
     self.nextthink = time;
     self.tur_shotorg = self.origin + '0 0 300';
-    self.think = walker_rocket_loop2;
+    setthink(self, walker_rocket_loop2);
     self.shot_dmg = 1337;
 }
 
@@ -248,9 +248,9 @@ void walker_fire_rocket(vector org)
     rocket.enemy                         = self.enemy;
 
     if (random() < 0.01)
-        rocket.think             = walker_rocket_loop;
+        setthink(rocket, walker_rocket_loop);
     else
-        rocket.think             = walker_rocket_think;
+        setthink(rocket, walker_rocket_think);
 
     rocket.event_damage           = walker_rocket_damage;
 
@@ -258,7 +258,7 @@ void walker_fire_rocket(vector org)
     rocket.movetype               = MOVETYPE_FLY;
     rocket.velocity               = normalize((v_forward + v_up * 0.5) + (randomvec() * 0.2)) * (autocvar_g_turrets_unit_walker_rocket_speed);
     rocket.angles                       = vectoangles(rocket.velocity);
-    rocket.touch                         = walker_rocket_explode;
+    settouch(rocket, walker_rocket_explode);
     rocket.flags                         = FL_PROJECTILE;
     rocket.solid                         = SOLID_BBOX;
     rocket.max_health           = time + 9;
@@ -317,7 +317,7 @@ void walker_move_path()
 
                 if (self.pathgoal.enemy)
                 {
-                    self.pathcurrent = WALKER_PATH(self.pathgoal.origin,self.pathgoal.enemy.origin);
+                    self.pathcurrent = WALKER_PATH(self, self.pathgoal.origin, self.pathgoal.enemy.origin);
                     self.pathgoal = self.pathgoal.enemy;
                 }
             }
@@ -344,7 +344,7 @@ void walker_move_path()
 #endif
 }
 
-spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); }
+spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(this); }
 
 METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it))
 {
@@ -617,7 +617,7 @@ METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
         else
         {
 #ifdef WALKER_FANCYPATHING
-            it.pathcurrent = WALKER_PATH(it.origin, e.origin);
+            it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
             it.pathgoal = e;
 #else
             it.pathcurrent = e;
index 17f42c8115edacd9b24b028c9a1a07ee578bb440..0344d149230461e0ca97b3db210de93bf7441e3a 100644 (file)
@@ -20,10 +20,10 @@ float turret_tag_fire_update()
 /*
 * Railgun-like beam, but has thickness and suppots slowing of target
 */
-void FireImoBeam (vector start, vector end, vector smin, vector smax,
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax,
                                  float bforce, float f_dmg, float f_velfactor, int deathtype)
 
-{SELFPARAM();
+{
        vector hitloc, force, endpoint, dir;
        entity ent;
 
@@ -37,7 +37,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
        // note down which entities were hit so we can damage them later
        while (1)
        {
-               tracebox(start, smin, smax, end, false, self);
+               tracebox(start, smin, smax, end, false, this);
 
                // if it is world we can't hurt it so stop now
                if (trace_ent == world || trace_fraction == 1)
@@ -81,7 +81,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
                // apply the damage
                if (ent.takedamage)
                {
-                       Damage (ent, self, self, f_dmg, deathtype, hitloc, force);
+                       Damage (ent, this, this, f_dmg, deathtype, hitloc, force);
                        ent.velocity = ent.velocity * f_velfactor;
                        //ent.alpha = 0.25 + random() * 0.75;
                }
@@ -98,7 +98,7 @@ void marker_think()
        if(self.cnt)
        if(self.cnt < time)
        {
-               self.think = SUB_Remove;
+               setthink(self, SUB_Remove);
                self.nextthink = time;
                return;
        }
@@ -116,7 +116,7 @@ void mark_error(vector where,float lifetime)
        setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
-       err.think = marker_think;
+       setthink(err, marker_think);
        err.nextthink = time;
        err.skin = 0;
        if(lifetime)
@@ -129,7 +129,7 @@ void mark_info(vector where,float lifetime)
        setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
-       err.think = marker_think;
+       setthink(err, marker_think);
        err.nextthink = time;
        err.skin = 1;
        if(lifetime)
@@ -142,7 +142,7 @@ entity mark_misc(vector where,float lifetime)
        setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
-       err.think = marker_think;
+       setthink(err, marker_think);
        err.nextthink = time;
        err.skin = 3;
        if(lifetime)
index dd9efec6b2b9f3b668c6cdf18de3f6598bb3509c..536af8703b9a7321eff1f0c410684865e8e06189 100644 (file)
@@ -7,6 +7,6 @@ float turret_tag_fire_update();
 vector shortangle_vxy(vector ang1, vector ang2);
 vector angleofs(entity from, entity to);
 vector angleofs3(vector from, vector from_a, entity to);
-void FireImoBeam (vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
 
 #endif
index ec643fcb5885cac7d20ccd0cfe0cf16b93b6ea80..52110137253b224511204353637be62d99d7d36c 100644 (file)
@@ -57,22 +57,25 @@ string wordwrap(string s, float l)
 
 #ifndef MENUQC
 #ifndef CSQC
+entity _wordwrap_buffer_sprint_ent;
 void wordwrap_buffer_sprint(string s)
-{SELFPARAM();
+{
        wordwrap_buffer = strcat(wordwrap_buffer, s);
        if(s == "\n")
        {
-               sprint(self, wordwrap_buffer);
+               sprint(_wordwrap_buffer_sprint_ent, wordwrap_buffer);
                wordwrap_buffer = "";
        }
 }
 
-void wordwrap_sprint(string s, float l)
-{SELFPARAM();
+void wordwrap_sprint(entity to, string s, float l)
+{
        wordwrap_buffer = "";
+       _wordwrap_buffer_sprint_ent = to;
        wordwrap_cb(s, l, wordwrap_buffer_sprint);
+       _wordwrap_buffer_sprint_ent = NULL;
        if(wordwrap_buffer != "")
-               sprint(self, strcat(wordwrap_buffer, "\n"));
+               sprint(to, strcat(wordwrap_buffer, "\n"));
        wordwrap_buffer = "";
        return;
 }
index 066033a175a1791a2ce05326b223de57db40d4ae..fa17a06a328af4414350a1a9a29632f5114cd34b 100644 (file)
@@ -11,7 +11,7 @@ vector real_origin(entity ent);
 string wordwrap(string s, float l);
 #ifndef MENUQC
 #ifndef CSQC
-void wordwrap_sprint(string s, float l);
+void wordwrap_sprint(entity to, string s, float l);
 #endif
 #endif
 void wordwrap_cb(string s, float l, void(string) callback);
index e2187290d97910574b1b51a2537e2eefd42538ac..9659ea5f828f860af5fcf37d34a34399873ec425 100644 (file)
@@ -82,8 +82,8 @@ NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew)
        // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
        if(hud_id == 0)
        {
-               sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
-               sound(self, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+               sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+               sound(this, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
                return;
        }
 
index fc44613e5d111cbafd02f69700f9552b09fb7678..6f1d2d91842857a3ff07a26ca8a212a16a154d68 100644 (file)
@@ -208,13 +208,13 @@ void vehicles_projectile_damage(entity this, entity inflictor, entity attacker,
        {
                this.takedamage = DAMAGE_NO;
                this.event_damage = func_null;
-               this.think = adaptor_think2use;
+               setthink(this, adaptor_think2use);
                this.nextthink = time;
        }
 }
 
-void vehicles_projectile_explode()
-{SELFPARAM();
+void vehicles_projectile_explode(entity this)
+{
        if(self.owner && other != world)
        {
                if(other == self.owner.vehicle)
@@ -224,7 +224,7 @@ void vehicles_projectile_explode()
                        return;
        }
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        self.event_damage = func_null;
        RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, world, self.shot_force, self.totalfrags, other);
@@ -234,7 +234,7 @@ void vehicles_projectile_explode()
 
 void vehicles_projectile_explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, vehicles_projectile_explode());
+       WITHSELF(this, vehicles_projectile_explode(this));
 }
 
 entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
@@ -261,11 +261,11 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
        proj.bot_dodge          = true;
        proj.bot_dodgerating  = _dmg;
        proj.velocity            = _vel;
-       proj.touch                      = vehicles_projectile_explode;
+       settouch(proj, vehicles_projectile_explode);
        proj.use                          = vehicles_projectile_explode_use;
        proj.owner                      = this;
        proj.realowner          = _owner;
-       proj.think                      = SUB_Remove_self;
+       setthink(proj, SUB_Remove);
        proj.nextthink          = time + 30;
 
        if(_health)
@@ -290,16 +290,16 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
        return proj;
 }
 
-void vehicles_gib_explode()
-{SELFPARAM();
+void vehicles_gib_explode(entity this)
+{
        sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
        remove(self);
 }
 
-void vehicles_gib_think()
-{SELFPARAM();
+void vehicles_gib_think(entity this)
+{
        self.alpha -= 0.1;
        if(self.cnt >= time)
                remove(self);
@@ -325,14 +325,14 @@ entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag,
 
        if(_explode)
        {
-               _gib.think = vehicles_gib_explode;
+               setthink(_gib, vehicles_gib_explode);
                _gib.nextthink = time + random() * _explode;
-               _gib.touch = vehicles_gib_explode;
+               settouch(_gib, vehicles_gib_explode);
        }
        else
        {
                _gib.cnt = time + _maxtime;
-               _gib.think = vehicles_gib_think;
+               setthink(_gib, vehicles_gib_think);
                _gib.nextthink = time + _maxtime - 1;
                _gib.alpha = 1;
        }
@@ -442,7 +442,7 @@ void vehicles_clearreturn(entity veh)
                if(ret.wp00 == veh)
                {
                        ret.classname   = "";
-                       ret.think          = SUB_Remove_self;
+                       setthink(ret, SUB_Remove);
                        ret.nextthink   = time + 0.1;
 
                        if(ret.waypointsprite_attached)
@@ -453,12 +453,12 @@ void vehicles_clearreturn(entity veh)
        }
 }
 
-void vehicles_spawn();
-void vehicles_return()
-{SELFPARAM();
+void vehicles_spawn(entity this);
+void vehicles_return(entity this)
+{
        Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1);
 
-       self.wp00.think  = vehicles_spawn;
+       setthink(self.wp00, vehicles_spawn);
        self.wp00.nextthink = time;
 
        if(self.waypointsprite_attached)
@@ -467,8 +467,8 @@ void vehicles_return()
        remove(self);
 }
 
-void vehicles_showwp_goaway()
-{SELFPARAM();
+void vehicles_showwp_goaway(entity this)
+{
        if(self.waypointsprite_attached)
                WaypointSprite_Kill(self.waypointsprite_attached);
 
@@ -476,48 +476,45 @@ void vehicles_showwp_goaway()
 
 }
 
-void vehicles_showwp()
-{SELFPARAM();
-       entity oldself = world;
+void vehicles_showwp(entity this)
+{
        vector rgb;
 
-       if(self.cnt)
+       entity ent = this;
+
+       if(ent.cnt)
        {
-               self.think        = vehicles_return;
-               self.nextthink  = self.cnt;
+               setthink(ent, vehicles_return);
+               ent.nextthink = ent.cnt;
        }
        else
        {
-               self.think        = vehicles_return;
-               self.nextthink  = time +1;
-
-               oldself = self;
-               setself(spawn());
-               setmodel(self, MDL_Null);
-               self.team = oldself.wp00.team;
-               self.wp00 = oldself.wp00;
-               setorigin(self, oldself.wp00.pos1);
-
-               self.nextthink = time + 5;
-               self.think = vehicles_showwp_goaway;
+               setthink(ent, vehicles_return);
+               ent.nextthink  = time + 1;
+
+               ent = spawn();
+               setmodel(ent, MDL_Null);
+               ent.team = this.wp00.team;
+               ent.wp00 = this.wp00;
+               setorigin(ent, this.wp00.pos1);
+
+               ent.nextthink = time + 5;
+               setthink(ent, vehicles_showwp_goaway);
        }
 
-       if(teamplay && self.team)
-               rgb = Team_ColorRGB(self.team);
+       if(teamplay && ent.team)
+               rgb = Team_ColorRGB(ent.team);
        else
                rgb = '1 1 1';
-       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
+       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', world, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle);
        wp.colormod = rgb;
-       if(self.waypointsprite_attached)
+       if(ent.waypointsprite_attached)
        {
-               WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
+               WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT);
                if(this == NULL)
-                       WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
-               WaypointSprite_Ping(self.waypointsprite_attached);
+                       WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink);
+               WaypointSprite_Ping(ent.waypointsprite_attached);
        }
-
-       if(this)
-               setself(this);
 }
 
 void vehicles_setreturn(entity veh)
@@ -529,7 +526,7 @@ void vehicles_setreturn(entity veh)
        ret = new(vehicle_return);
        ret.wp00           = veh;
        ret.team                = veh.team;
-       ret.think          = vehicles_showwp;
+       setthink(ret, vehicles_showwp);
 
        if(IS_DEAD(veh))
        {
@@ -562,7 +559,7 @@ void vehicle_use(entity this, entity actor, entity trigger)
                LOG_TRACE("Respawning vehicle: ", this.netname, "\n");
                if(this.effects & EF_NODRAW)
                {
-                       this.think = vehicles_spawn;
+                       setthink(this, vehicles_spawn);
                        this.nextthink = time + 3;
                }
                else
@@ -588,8 +585,8 @@ void vehicles_regen(entity this, float timer, .float regen_field, float field_ma
        }
 }
 
-void shieldhit_think()
-{SELFPARAM();
+void shieldhit_think(entity this)
+{
        self.alpha -= 0.1;
        if (self.alpha <= 0)
        {
@@ -668,7 +665,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag
                        setattachment(this.vehicle_shieldent, this, "");
                        setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
                        this.vehicle_shieldent.scale       = 256 / vlen(this.maxs - this.mins);
-                       this.vehicle_shieldent.think       = shieldhit_think;
+                       setthink(this.vehicle_shieldent, shieldhit_think);
                }
 
                this.vehicle_shieldent.colormod = '1 1 1';
@@ -825,7 +822,6 @@ void vehicles_exit(bool eject)
                if (_vehicle.vehicle_flags & VHF_PLAYERSLOT)
                {
                        _vehicle.vehicle_exit(eject);
-                       setself(this);
                        vehicles_exit_running = false;
                        return;
                }
@@ -905,8 +901,8 @@ void vehicles_exit(bool eject)
        vehicles_exit_running = false;
 }
 
-void vehicles_touch()
-{SELFPARAM();
+void vehicles_touch(entity this)
+{
        if(MUTATOR_CALLHOOK(VehicleTouch, self, other))
                return;
 
@@ -958,9 +954,6 @@ bool vehicle_impulse(entity this, int imp)
 
 void vehicles_enter(entity pl, entity veh)
 {
-    SELFPARAM();
-       entity oldself = self;
-
    // Remove this when bots know how to use vehicles
        if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
                return;
@@ -1089,17 +1082,15 @@ void vehicles_enter(entity pl, entity veh)
 
        MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
 
-       setself(veh);
        CSQCModel_UnlinkEntity(veh);
        Vehicle info = Vehicles_from(veh.vehicleid);
-       info.vr_enter(info, veh);
-       setself(oldself);
+       WITHSELF(veh, info.vr_enter(info, veh));
 
        antilag_clear(pl, CS(pl));
 }
 
-void vehicles_think()
-{SELFPARAM();
+void vehicles_think(entity this)
+{
        self.nextthink = time;
 
        if(self.owner)
@@ -1114,15 +1105,15 @@ void vehicles_think()
 }
 
 // initialization
-void vehicles_spawn()
-{SELFPARAM();
+void vehicles_spawn(entity this)
+{
        LOG_TRACE("Spawning vehicle: ", self.classname, "\n");
 
        // disown & reset
        self.vehicle_hudmodel.viewmodelforclient = self;
 
        self.owner                              = world;
-       self.touch                              = vehicles_touch;
+       settouch(self, vehicles_touch);
        self.event_damage               = vehicles_damage;
        self.iscreature                 = true;
        self.teleportable               = false; // no teleporting for vehicles, too buggy
@@ -1135,7 +1126,7 @@ void vehicles_spawn()
        self.flags                              = FL_NOTARGET;
        self.avelocity                  = '0 0 0';
        self.velocity                   = '0 0 0';
-       self.think                              = vehicles_think;
+       setthink(self, vehicles_think);
        self.nextthink                  = time;
 
        // Reset locking
@@ -1219,8 +1210,8 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
        this.vehicleid                          = info.vehicleid;
        this.PlayerPhysplug                     = info.PlayerPhysplug;
        this.event_damage                       = func_null;
-       this.touch                                      = vehicles_touch;
-       this.think                                      = vehicles_spawn;
+       settouch(this, vehicles_touch);
+       setthink(this, vehicles_spawn);
        this.nextthink                          = time;
        this.effects                            = EF_NODRAW;
        this.dphitcontentsmask          = DPCONTENTS_BODY | DPCONTENTS_SOLID;
index c3c0861e95ef257187904119fc0a3938a0e604ac..945c0964f4f5c8ab54a0f871d0ec3058b63a4002 100644 (file)
@@ -369,13 +369,13 @@ bool vehicles_valid_pilot()
        return true;
 }
 
-void bumblebee_touch()
-{SELFPARAM();
+void bumblebee_touch(entity this)
+{
        if(autocvar_g_vehicles_enter) { return; }
 
        if(self.gunner1 != world && self.gunner2 != world)
        {
-               vehicles_touch();
+               vehicles_touch(self);
                return;
        }
 
@@ -388,7 +388,7 @@ void bumblebee_touch()
                        return;
        }
 
-       vehicles_touch();
+       vehicles_touch(self);
 }
 
 void bumblebee_regen(entity this)
@@ -625,8 +625,8 @@ bool bumblebee_pilot_frame(entity this)
        PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
-void bumblebee_land()
-{SELFPARAM();
+void bumblebee_land(entity this)
+{
        float hgt;
 
        hgt = raptor_altitude(512);
@@ -635,7 +635,7 @@ void bumblebee_land()
        self.angles_z *= 0.95;
 
        if(hgt < 16)
-               self.think      = vehicles_think;
+               setthink(self, vehicles_think);
 
        self.nextthink = time;
 
@@ -650,11 +650,11 @@ void bumblebee_exit(float eject)
                return;
        }
 
-       self.touch = vehicles_touch;
+       settouch(self, vehicles_touch);
 
        if(!IS_DEAD(self))
        {
-               self.think = bumblebee_land;
+               setthink(self, bumblebee_land);
                self.nextthink  = time;
        }
 
@@ -685,8 +685,8 @@ void bumblebee_exit(float eject)
        self.owner = world;
 }
 
-void bumblebee_blowup()
-{SELFPARAM();
+void bumblebee_blowup(entity this)
+{
        RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
                                 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
                                 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
@@ -702,10 +702,10 @@ void bumblebee_blowup()
        remove(self);
 }
 
-void bumblebee_diethink()
-{SELFPARAM();
+void bumblebee_diethink(entity this)
+{
        if(time >= self.wait)
-               self.think = bumblebee_blowup;
+               setthink(self, bumblebee_blowup);
 
        if(random() < 0.1)
        {
@@ -730,7 +730,7 @@ METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh, entity instance))
 METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh, entity instance))
 {
     SELFPARAM();
-    self.touch = bumblebee_touch;
+    settouch(self, bumblebee_touch);
     self.nextthink = 0;
     self.movetype = MOVETYPE_BOUNCEMISSILE;
 }
@@ -744,100 +744,83 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
 
     if(!self.owner)
     {
-        entity oldself = self;
         if(self.gunner1)
         {
-            setself(self.gunner1);
-            oldself.gun1.vehicle_exit(VHEF_EJECT);
-            entity oldother = other;
-            other = self;
-            setself(oldself);
-            self.phase = 0;
-            self.touch();
-            other = oldother;
-            return;
+               entity e = self.gunner1;
+               WITHSELF(e, self.gun1.vehicle_exit(VHEF_EJECT));
+               entity oldother = other;
+               other = e;
+               self.phase = 0;
+               gettouch(self)(self);
+               other = oldother;
+               return;
         }
 
         if(self.gunner2)
         {
-            setself(self.gunner2);
-            oldself.gun2.vehicle_exit(VHEF_EJECT);
-            entity oldother = other;
-            other = self;
-            setself(oldself);
-            self.phase = 0;
-            self.touch();
-            other = oldother;
+               entity e = self.gunner2;
+               WITHSELF(e, self.gun2.vehicle_exit(VHEF_EJECT));
+               entity oldother = other;
+               other = e;
+               self.phase = 0;
+               gettouch(self)(self);
+               other = oldother;
             return;
         }
     }
 }
 METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
 {
-    SELFPARAM();
-    entity oldself = self;
-    setself(instance);
+       CSQCModel_UnlinkEntity(instance);
 
-    CSQCModel_UnlinkEntity(self);
+       // hide beam
+       if(instance.gun3.enemy || !wasfreed(instance.gun3.enemy))
+               instance.gun3.enemy.effects |= EF_NODRAW;
 
-    // Hide beam
-    if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
-        self.gun3.enemy.effects |= EF_NODRAW;
+       if(instance.gunner1)
+               WITHSELF(instance.gunner1, instance.gun1.vehicle_exit(VHEF_EJECT));
 
-    if(self.gunner1)
-    {
-        setself(self.gunner1);
-        oldself.gun1.vehicle_exit(VHEF_EJECT);
-        setself(oldself);
-    }
-
-    if(self.gunner2)
-    {
-        setself(self.gunner2);
-        oldself.gun2.vehicle_exit(VHEF_EJECT);
-        setself(oldself);
-    }
+       if(instance.gunner2)
+               WITHSELF(instance.gunner2, instance.gun2.vehicle_exit(VHEF_EJECT));
 
-    self.vehicle_exit(VHEF_EJECT);
+       WITHSELF(instance, instance.vehicle_exit(VHEF_EJECT));
 
-    fixedmakevectors(self.angles);
-    vehicle_tossgib(instance, self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
-    vehicle_tossgib(instance, self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
-    vehicle_tossgib(instance, self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
+    fixedmakevectors(instance.angles);
+    vehicle_tossgib(instance, instance.gun1, instance.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
+    vehicle_tossgib(instance, instance.gun2, instance.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
+    vehicle_tossgib(instance, instance.gun3, instance.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
 
-    entity _body = vehicle_tossgib(instance, self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
+    entity _body = vehicle_tossgib(instance, instance, instance.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
 
     if(random() > 0.5)
-        _body.touch = bumblebee_blowup;
+        settouch(_body, bumblebee_blowup);
     else
-        _body.touch = func_null;
+        settouch(_body, func_null);
 
-    _body.think = bumblebee_diethink;
+    setthink(_body, bumblebee_diethink);
     _body.nextthink = time;
     _body.wait = time + 2 + (random() * 8);
-    _body.owner = self;
-    _body.enemy = self.enemy;
+    _body.owner = instance;
+    _body.enemy = instance.enemy;
     _body.scale = 1.5;
-    _body.angles = self.angles;
-
-    Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
-
-    self.health                        = 0;
-    self.event_damage  = func_null;
-    self.solid                 = SOLID_NOT;
-    self.takedamage            = DAMAGE_NO;
-    self.deadflag              = DEAD_DYING;
-    self.movetype              = MOVETYPE_NONE;
-    self.effects               = EF_NODRAW;
-    self.colormod              = '0 0 0';
-    self.avelocity             = '0 0 0';
-    self.velocity              = '0 0 0';
-    self.touch                         = func_null;
-    self.nextthink             = 0;
-
-    setorigin(self, self.pos1);
-
-    setself(oldself);
+    _body.angles = instance.angles;
+
+    Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(instance.origin, 16), '0 0 0', 1);
+
+    instance.health                    = 0;
+    instance.event_damage      = func_null;
+    instance.solid                     = SOLID_NOT;
+    instance.takedamage                = DAMAGE_NO;
+    instance.deadflag          = DEAD_DYING;
+    instance.movetype          = MOVETYPE_NONE;
+    instance.effects           = EF_NODRAW;
+    instance.colormod          = '0 0 0';
+    instance.avelocity         = '0 0 0';
+    instance.velocity          = '0 0 0';
+    settouch(instance, func_null);
+    instance.nextthink                 = 0;
+
+    setorigin(instance, instance.pos1);
 }
 METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance))
 {
@@ -851,7 +834,7 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance))
         setattachment(self.vehicle_shieldent, self, "");
         setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
         self.vehicle_shieldent.scale       = 512 / vlen(self.maxs - self.mins);
-        self.vehicle_shieldent.think       = shieldhit_think;
+        setthink(self.vehicle_shieldent, shieldhit_think);
         self.vehicle_shieldent.alpha = -1;
         self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
 
index 00b796dda059a9bd7905b88c5f39d364de8ac2c8..26a6ddd13c9eb8a7f429dd95be989c1bde461796 100644 (file)
@@ -56,35 +56,35 @@ NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew)
 
     if(sf & BRG_SETUP)
     {
-        self.cnt  = ReadByte();
-        self.team = ReadByte();
-        self.cnt  = ReadByte();
+        this.cnt  = ReadByte();
+        this.team = ReadByte();
+        this.cnt  = ReadByte();
 
-        if(self.cnt)
-            self.colormod = '1 0 0';
+        if(this.cnt)
+            this.colormod = '1 0 0';
         else
-            self.colormod = '0 1 0';
+            this.colormod = '0 1 0';
 
-        self.traileffect = EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH.m_id;
-        self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
+        this.traileffect = EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH.m_id;
+        this.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
 
-        self.draw = bumble_raygun_draw;
+        this.draw = bumble_raygun_draw;
     }
 
 
     if(sf & BRG_START)
     {
-        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(sf & BRG_END)
     {
-        self.move_origin_x = ReadCoord();
-        self.move_origin_y = ReadCoord();
-        self.move_origin_z = ReadCoord();
+        this.move_origin_x = ReadCoord();
+        this.move_origin_y = ReadCoord();
+        this.move_origin_z = ReadCoord();
     }
     return true;
 }
index ded599b7d2a77cc5b481f65a36dd8ef858f646f3..bcbe5be702cc799a2437dc6def3a8826fb446e4e 100644 (file)
@@ -316,12 +316,11 @@ bool racer_frame(entity this)
        this.movement = vehic.velocity += df * PHYS_INPUT_TIMELENGTH;
 
 #ifdef SVQC
-       setself(vehic);
 
        Weapon wep1 = WEP_RACER;
        if (!forbidWeaponUse(this))
        if (PHYS_INPUT_BUTTON_ATCK(this))
-       if (wep1.wr_checkammo1(wep1))
+       if (wep1.wr_checkammo1(wep1, vehic))
        {
                string tagname = (vehic.cnt)
                    ? (vehic.cnt = 0, "tag_fire1")
@@ -333,11 +332,9 @@ bool racer_frame(entity this)
                crosshair_trace(this);
                w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
                .entity weaponentity = weaponentities[0];
-               wep1.wr_think(wep1, vehic, weaponentity, 1);
+               WITHSELF(vehic, wep1.wr_think(wep1, vehic, weaponentity, 1));
        }
 
-       setself(this);
-
        if(autocvar_g_vehicle_racer_rocket_locktarget)
        {
                if(vehic.vehicle_last_trace == time + autocvar_g_vehicle_racer_thinkrate)
@@ -406,8 +403,8 @@ bool racer_frame(entity this)
        this.velocity = vehic.velocity;
 }
 
-void racer_think()
-{SELFPARAM();
+void racer_think(entity this)
+{
        this.nextthink = time + autocvar_g_vehicle_racer_thinkrate;
 
        tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, this);
@@ -440,7 +437,7 @@ void racer_exit(float eject)
 {SELFPARAM();
        vector spot;
 
-       self.think        = racer_think;
+       setthink(self, racer_think);
        self.nextthink  = time;
        self.movetype   = MOVETYPE_BOUNCE;
        sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
@@ -492,7 +489,7 @@ void racer_blowup()
                                        DEATH_VH_WAKI_DEATH.m_id, world);
 
        self.nextthink  = time + autocvar_g_vehicle_racer_respawntime;
-       self.think        = vehicles_spawn;
+       setthink(self, vehicles_spawn);
        self.movetype   = MOVETYPE_NONE;
        self.effects    = EF_NODRAW;
        self.solid = SOLID_NOT;
@@ -504,8 +501,8 @@ void racer_blowup()
        setorigin(self, self.pos1);
 }
 
-void racer_blowup_think()
-{SELFPARAM();
+void racer_blowup_think(entity this)
+{
        self.nextthink = time;
 
        if(time >= self.delay)
@@ -514,8 +511,8 @@ void racer_blowup_think()
        CSQCMODEL_AUTOUPDATE(self);
 }
 
-void racer_deadtouch()
-{SELFPARAM();
+void racer_deadtouch(entity this)
+{
        self.avelocity_x *= 0.7;
        self.cnt -= 1;
        if(self.cnt <= 0)
@@ -608,7 +605,7 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance))
         self.mass                         = 900;
     }
 
-    self.think           = racer_think;
+    setthink(self, racer_think);
     self.nextthink       = time;
     self.vehicle_health = autocvar_g_vehicle_racer_health;
     self.vehicle_shield = autocvar_g_vehicle_racer_shield;
@@ -641,7 +638,7 @@ METHOD(Racer, vr_death, void(Racer thisveh, entity instance))
     instance.wait                      = time;
     instance.delay                     = 2 + time + random() * 3;
     instance.cnt                       = 1 + random() * 2;
-    instance.touch                     = racer_deadtouch;
+    settouch(instance, racer_deadtouch);
 
     Send_Effect(EFFECT_EXPLOSION_MEDIUM, instance.origin, '0 0 0', 1);
 
@@ -654,7 +651,7 @@ METHOD(Racer, vr_death, void(Racer thisveh, entity instance))
     instance.velocity += '0 0 700';
     instance.colormod = '-0.5 -0.5 -0.5';
 
-    instance.think = racer_blowup_think;
+    setthink(instance, racer_blowup_think);
     instance.nextthink = time;
 #endif
 }
index 36655fd1de8a9bf56683ad17fb9df789ab42440a..f15b8cfb8a74ddfe092069e651355dbd0bc5dc27 100644 (file)
@@ -34,17 +34,16 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone
     }
 }
 
-METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep))
+METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor))
 {
-    SELFPARAM();
-    bool isPlayer = IS_PLAYER(self);
-    entity player = isPlayer ? self : self.owner;
+    bool isPlayer = IS_PLAYER(actor);
+    entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_racer_cannon_cost;
 }
 
-void racer_rocket_tracker();
-void racer_rocket_groundhugger();
+void racer_rocket_tracker(entity this);
+void racer_rocket_groundhugger(entity this);
 
 void racer_fire_rocket(entity player, vector org, vector dir, entity trg)
 {
@@ -60,13 +59,13 @@ void racer_fire_rocket(entity player, vector org, vector dir, entity trg)
     rocket.cnt                   = time + 15;
 
     if(trg)
-        rocket.think                   = racer_rocket_tracker;
+        setthink(rocket, racer_rocket_tracker);
     else
-        rocket.think                   = racer_rocket_groundhugger;
+        setthink(rocket, racer_rocket_groundhugger);
 }
 
-void racer_rocket_tracker()
-{SELFPARAM();
+void racer_rocket_tracker(entity this)
+{
     vector olddir, newdir;
     float oldvel, newvel;
 
@@ -102,7 +101,7 @@ void racer_rocket_tracker()
     {
         //bprint("Target lost!\n");
         //dprint("OF:", ftos(vlen(newdir - v_forward)), "\n");
-        self.think = racer_rocket_groundhugger;
+        setthink(self, racer_rocket_groundhugger);
         return;
     }
 
@@ -117,8 +116,8 @@ void racer_rocket_tracker()
     return;
 }
 
-void racer_rocket_groundhugger()
-{SELFPARAM();
+void racer_rocket_groundhugger(entity this)
+{
     vector olddir, newdir;
     float oldvel, newvel;
 
index 8b2f9e01b89a7160ade80bf7d2a90f5ac992d5c4..3a2401989fb381b3d9b089d3824b030c9cc74678 100644 (file)
@@ -83,8 +83,8 @@ float raptor_altitude(float amax)
        return vlen(self.origin - trace_endpos);
 }
 
-void raptor_land()
-{SELFPARAM();
+void raptor_land(entity this)
+{
        float hgt;
 
        hgt = raptor_altitude(512);
@@ -102,7 +102,7 @@ void raptor_land()
        if(hgt < 16)
        {
                self.movetype = MOVETYPE_TOSS;
-               self.think      = vehicles_think;
+               setthink(self, vehicles_think);
                self.frame      = 0;
        }
 
@@ -118,7 +118,7 @@ void raptor_exit(float eject)
 
        if(!IS_DEAD(self))
        {
-               self.think        = raptor_land;
+               setthink(self, raptor_land);
                self.nextthink  = time;
        }
 
@@ -385,13 +385,12 @@ bool raptor_frame(entity this)
        UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
        */
 
-       // TODO: fix wr_checkammo and its use of self!
        setself(vehic);
 
        Weapon wep1 = WEP_RAPTOR;
        if(!forbidWeaponUse(this))
        if(PHYS_INPUT_BUTTON_ATCK(this))
-       if (wep1.wr_checkammo1(wep1))
+       if (wep1.wr_checkammo1(wep1, vehic))
        {
            .entity weaponentity = weaponentities[0];
                wep1.wr_think(wep1, vehic, weaponentity, 1);
@@ -521,8 +520,8 @@ bool raptor_takeoff(entity this)
        PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
-void raptor_blowup()
-{SELFPARAM();
+void raptor_blowup(entity this)
+{
        self.deadflag   = DEAD_DEAD;
        self.vehicle_exit(VHEF_NORMAL);
        RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH.m_id, world);
@@ -535,14 +534,14 @@ void raptor_blowup()
        self.velocity      = '0 0 0';
 
        setorigin(self, self.pos1);
-       self.touch = func_null;
+       settouch(self, func_null);
        self.nextthink = 0;
 }
 
-void raptor_diethink()
-{SELFPARAM();
+void raptor_diethink(entity this)
+{
        if(time >= self.wait)
-               self.think = raptor_blowup;
+               setthink(self, raptor_blowup);
 
        if(random() < 0.05)
        {
@@ -556,8 +555,8 @@ void raptor_diethink()
 
 // If we dont do this ever now and then, the raptors rotors
 // stop working, presumably due to angle overflow. cute.
-void raptor_rotor_anglefix()
-{SELFPARAM();
+void raptor_rotor_anglefix(entity this)
+{
        self.gun1.angles_y = anglemods(self.gun1.angles_y);
        self.gun2.angles_y = anglemods(self.gun2.angles_y);
        self.nextthink = time + 15;
@@ -645,7 +644,7 @@ METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
     instance.takedamage                        = DAMAGE_NO;
     instance.deadflag                  = DEAD_DYING;
     instance.movetype                  = MOVETYPE_BOUNCE;
-    instance.think                             = raptor_diethink;
+    setthink(instance, raptor_diethink);
     instance.nextthink                 = time;
     instance.wait                              = time + 5 + (random() * 5);
 
@@ -657,7 +656,7 @@ METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
     instance.avelocity -= '0 0.5 1' * (random() * 400);
 
     instance.colormod = '-0.5 -0.5 -0.5';
-    instance.touch = raptor_blowup;
+    settouch(instance, raptor_blowup);
 }
 METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
 {
@@ -725,7 +724,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
         self.bomb1.gun2 = spinner;
 
         // Sigh.
-        self.bomb1.think = raptor_rotor_anglefix;
+        setthink(self.bomb1, raptor_rotor_anglefix);
         self.bomb1.nextthink = time;
 
         self.mass                         = 1 ;
index c51fa154f7925155680db346c788409e6e02c9b0..fc439734c0f78fbf71db2805d6f0ced5227f318d 100644 (file)
@@ -30,10 +30,9 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon
         weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
     }
 }
-METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) {
-    SELFPARAM();
-    bool isPlayer = IS_PLAYER(self);
-    entity player = isPlayer ? self : self.owner;
+METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) {
+    bool isPlayer = IS_PLAYER(actor);
+    entity player = isPlayer ? actor : actor.owner;
     entity veh = player.vehicle;
     return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_raptor_cannon_cost;
 }
@@ -46,15 +45,15 @@ METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, .entity weaponen
     entity veh = player.vehicle;
     if (fire & 2)
     if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_bombs_refire)) {
-        if (veh) setself(veh);
-        raptor_bombdrop();
+        entity e = (veh) ? veh : player;
+        WITHSELF(e, raptor_bombdrop());
         weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
-void raptor_flare_think();
+void raptor_flare_think(entity this);
 void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force);
-void raptor_flare_touch();
+void raptor_flare_touch(entity this);
 
 METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
@@ -71,7 +70,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weapone
             _flare.movetype = MOVETYPE_TOSS;
             _flare.gravity = 0.15;
             _flare.velocity = 0.25 * actor.velocity + (v_forward + randomvec() * 0.25)* -500;
-            _flare.think = raptor_flare_think;
+            setthink(_flare, raptor_flare_think);
             _flare.nextthink = time;
             _flare.owner = veh ? veh : player;
             _flare.solid = SOLID_CORPSE;
@@ -79,15 +78,15 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weapone
             _flare.event_damage = raptor_flare_damage;
             _flare.health = 20;
             _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
-            _flare.touch = raptor_flare_touch;
+            settouch(_flare, raptor_flare_touch);
         }
         weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
 
-void raptor_bomblet_boom()
-{SELFPARAM();
+void raptor_bomblet_boom(entity this)
+{
     RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
                                     autocvar_g_vehicle_raptor_bomblet_edgedamage,
                                     autocvar_g_vehicle_raptor_bomblet_radius, world, world,
@@ -95,18 +94,18 @@ void raptor_bomblet_boom()
     remove(self);
 }
 
-void raptor_bomblet_touch()
-{SELFPARAM();
+void raptor_bomblet_touch(entity this)
+{
     if(other == self.owner)
         return;
 
-    PROJECTILE_TOUCH;
-    self.think = raptor_bomblet_boom;
+    PROJECTILE_TOUCH(this);
+    setthink(self, raptor_bomblet_boom);
     self.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay;
 }
 
-void raptor_bomb_burst()
-{SELFPARAM();
+void raptor_bomb_burst(entity this)
+{
     if(self.cnt > time)
     if(autocvar_g_vehicle_raptor_bomblet_alt)
     {
@@ -130,8 +129,8 @@ void raptor_bomb_burst()
         setorigin(bomblet, self.origin);
 
         bomblet.movetype       = MOVETYPE_TOSS;
-        bomblet.touch     = raptor_bomblet_touch;
-        bomblet.think     = raptor_bomblet_boom;
+        settouch(bomblet, raptor_bomblet_touch);
+        setthink(bomblet, raptor_bomblet_boom);
         bomblet.nextthink   = time + 5;
         bomblet.owner     = self.owner;
         bomblet.realowner   = self.realowner;
@@ -158,8 +157,10 @@ void raptor_bombdrop()
 
     bomb_1.movetype     = bomb_2.movetype   = MOVETYPE_BOUNCE;
     bomb_1.velocity     = bomb_2.velocity   = self.velocity;
-    bomb_1.touch               = bomb_2.touch    = raptor_bomb_burst;
-    bomb_1.think               = bomb_2.think    = raptor_bomb_burst;
+    settouch(bomb_1, raptor_bomb_burst);
+    settouch(bomb_2, raptor_bomb_burst);
+    setthink(bomb_1, raptor_bomb_burst);
+    setthink(bomb_2, raptor_bomb_burst);
     bomb_1.cnt           = bomb_2.cnt          = time + 10;
 
     if(autocvar_g_vehicle_raptor_bomblet_alt)
@@ -179,8 +180,8 @@ void raptor_bombdrop()
     CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true);
 }
 
-void raptor_flare_touch()
-{SELFPARAM();
+void raptor_flare_touch(entity this)
+{
     remove(self);
 }
 
@@ -191,8 +192,8 @@ void raptor_flare_damage(entity this, entity inflictor, entity attacker, float d
         remove(this);
 }
 
-void raptor_flare_think()
-{SELFPARAM();
+void raptor_flare_think(entity this)
+{
     self.nextthink = time + 0.1;
     entity _missile = findchainentity(enemy, self.owner);
     while(_missile)
index 57f1310c4b8cf618f21b8f12b2f2ba39aa13e7a4..1b27587398d00c89507efd6e67cec59ebd32e3a3 100644 (file)
@@ -351,7 +351,7 @@ void spiderbot_exit(float eject)
                e = e.chain;
        }
 
-       self.think = vehicles_think;
+       setthink(self, vehicles_think);
        self.nextthink = time;
        self.frame = 5;
        self.movetype = MOVETYPE_WALK;
@@ -392,9 +392,9 @@ void spiderbot_exit(float eject)
        self.owner = world;
 }
 
-void spiderbot_headfade()
-{SELFPARAM();
-       self.think = spiderbot_headfade;
+void spiderbot_headfade(entity this)
+{
+       setthink(self, spiderbot_headfade);
        self.nextthink = self.fade_time;
        self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
 
@@ -409,8 +409,8 @@ void spiderbot_headfade()
        }
 }
 
-void spiderbot_blowup()
-{SELFPARAM();
+void spiderbot_blowup(entity this)
+{
        if(self.cnt > time)
        {
                if(random() < 0.1)
@@ -451,7 +451,7 @@ void spiderbot_blowup()
        h.cnt = time + (3.5 * random());
        h.fade_rate = 1 / min(self.respawntime, 10);
        h.fade_time = time;
-       h.think = spiderbot_headfade;
+       setthink(h, spiderbot_headfade);
        h.nextthink = time;
 
        org = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01"));
@@ -571,9 +571,9 @@ METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
     instance.health                            = 0;
     instance.event_damage              = func_null;
     instance.takedamage                        = DAMAGE_NO;
-    instance.touch                             = func_null;
+    settouch(instance, func_null);
     instance.cnt                               = 3.4 + time + random() * 2;
-    instance.think                             = spiderbot_blowup;
+    setthink(instance, spiderbot_blowup);
     instance.nextthink                 = time;
     instance.deadflag                  = DEAD_DYING;
     instance.frame                             = 5;
index dd209676d49dce7f7206b02c9c286ddc145dc139..ae8c6c6f982ed156f10d2234773080eedb824d22 100644 (file)
@@ -10,8 +10,8 @@ void spiderbot_rocket_artillery()
     UpdateCSQCProjectile(self);
 }
 
-void spiderbot_rocket_unguided()
-{SELFPARAM();
+void spiderbot_rocket_unguided(entity this)
+{
     vector newdir, olddir;
 
     self.nextthink  = time;
@@ -26,14 +26,14 @@ void spiderbot_rocket_unguided()
         self.use(self, NULL, NULL);
 }
 
-void spiderbot_rocket_guided()
-{SELFPARAM();
+void spiderbot_rocket_guided(entity this)
+{
     vector newdir, olddir;
 
     self.nextthink  = time;
 
     if(!self.realowner.vehicle)
-        self.think = spiderbot_rocket_unguided;
+        setthink(self, spiderbot_rocket_unguided);
 
     crosshair_trace(self.realowner);
     olddir = normalize(self.velocity);
@@ -56,10 +56,10 @@ void spiderbot_guide_release(entity this)
     crosshair_trace(this.owner);
     while(rkt)
     {
-        if(rkt.think == spiderbot_rocket_guided)
+        if(getthink(rkt) == spiderbot_rocket_guided)
         {
             rkt.pos1 = trace_endpos;
-            rkt.think = spiderbot_rocket_unguided;
+            setthink(rkt, spiderbot_rocket_unguided);
         }
         rkt = rkt.chain;
     }
@@ -196,7 +196,7 @@ void spiderbot_rocket_do(entity this)
             float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
             _dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
             rocket.nextthink  = time + (_dist / autocvar_g_vehicle_spiderbot_rocket_speed);
-            rocket.think        = vehicles_projectile_explode;
+            setthink(rocket, vehicles_projectile_explode);
 
             if(PHYS_INPUT_BUTTON_ATCK2(this.owner) && this.tur_head.frame == 1)
                 this.wait = -10;
@@ -209,7 +209,7 @@ void spiderbot_rocket_do(entity this)
             crosshair_trace(this.owner);
             rocket.pos1           = trace_endpos;
             rocket.nextthink  = time;
-            rocket.think         = spiderbot_rocket_guided;
+            setthink(rocket, spiderbot_rocket_guided);
 
 
         break;
index 9b9046aa4c668b126bb023f9ff157517f5b3d3c3..b86b77fadf4ffc0cb14de612227121f3433c2635 100644 (file)
@@ -107,15 +107,14 @@ void W_PROP_reload(int chan, entity to)
         if (f) f(it, chan);
     });
 }
-void W_PROP_think()
+void W_PROP_think(entity this)
 {
     W_PROP_reload(MSG_ALL, NULL);
 }
 STATIC_INIT_LATE(W_PROP_reloader)
 {
-    SELFPARAM();
     entity e = W_PROP_reloader = new_pure(W_PROP_reloader);
-    WITHSELF(e, (e.think = W_PROP_think)());
+    WITHSELF(e, (setthink(e, W_PROP_think))(e));
 }
 #endif
 
index ef115b220d5e699df07c440c59bb2fc528fc8587..99ff42367fe14bbb38e330f2143425e055ea9676 100644 (file)
@@ -85,15 +85,15 @@ CLASS(Weapon, Object)
     ATTRIB(Weapon, m_pickup, entity, NULL);
 
     /** (SERVER) setup weapon data */
-    METHOD(Weapon, wr_setup, void(Weapon this)) {}
+    METHOD(Weapon, wr_setup, void(Weapon this, entity actor)) {}
     /** (SERVER) logic to run every frame */
     METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
     /** (SERVER) checks ammo for weapon primary */
-    METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
+    METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor)) {return false;}
     /** (SERVER) checks ammo for weapon second */
-    METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
+    METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor)) {return false;}
     /** (SERVER) runs bot aiming code for this weapon */
-    METHOD(Weapon, wr_aim, void(Weapon this)) {}
+    METHOD(Weapon, wr_aim, void(Weapon this, entity actor)) {}
     /** (BOTH)   precaches models/sounds used by this weapon, also sets up weapon properties */
     METHOD(Weapon, wr_init, void(Weapon this)) {}
     /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
@@ -103,13 +103,13 @@ CLASS(Weapon, Object)
     /** (SERVER) handles reloading for weapon */
     METHOD(Weapon, wr_reload, void(Weapon this, entity actor, .entity weaponentity)) {}
     /** (SERVER) clears fields that the weapon may use */
-    METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
+    METHOD(Weapon, wr_resetplayer, void(Weapon this, entity actor)) {}
     /** (CLIENT) impact effect for weapon explosion */
-    METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
+    METHOD(Weapon, wr_impacteffect, void(Weapon this, entity actor)) {}
     /** (SERVER) called whenever a player dies */
-    METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
+    METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor)) {}
     /** (SERVER) logic to run when weapon is lost */
-    METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
+    METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor)) {}
     /** (ALL)    dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
     METHOD(Weapon, wr_config, void(Weapon this)) {}
     /** (CLIENT) weapon specific zoom reticle */
@@ -120,9 +120,9 @@ CLASS(Weapon, Object)
     /** (CLIENT) weapon specific glow */
     METHOD(Weapon, wr_glow, vector(Weapon this)) { return '0 0 0'; }
     /** (SERVER) the weapon is dropped */
-    METHOD(Weapon, wr_drop, void(Weapon this)) {}
+    METHOD(Weapon, wr_drop, void(Weapon this, entity actor)) {}
     /** (SERVER) a weapon is picked up */
-    METHOD(Weapon, wr_pickup, void(Weapon this)) {}
+    METHOD(Weapon, wr_pickup, void(Weapon this, entity actor)) {}
     /** (SERVER) update cvar based properties */
     METHOD(Weapon, wr_update, void(Weapon this)) {}
        METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
index cf391b034a3e76807eab3187e41cb287e33f257b..5df635f77d997af1a6a866fb2e2d929dc3cdc12c 100644 (file)
@@ -231,8 +231,8 @@ void Arc_Player_SetHeat(entity player)
        //dprint("Heat: ",ftos(player.arc_heat_percent*100),"%\n");
 }
 
-void W_Arc_Bolt_Explode()
-{SELFPARAM();
+void W_Arc_Bolt_Explode(entity this)
+{
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR(arc, bolt_damage), WEP_CVAR(arc, bolt_edgedamage), WEP_CVAR(arc, bolt_radius), world, world, WEP_CVAR(arc, bolt_force), self.projectiledeathtype, other);
 
@@ -241,7 +241,7 @@ void W_Arc_Bolt_Explode()
 
 void W_Arc_Bolt_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Arc_Bolt_Explode());
+       WITHSELF(this, W_Arc_Bolt_Explode(this));
 }
 
 void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -256,17 +256,18 @@ void W_Arc_Bolt_Damage(entity this, entity inflictor, entity attacker, float dam
        this.angles = vectoangles(this.velocity);
 
        if(this.health <= 0)
-               W_PrepareExplosionByDamage(this, attacker, this.think);
+               W_PrepareExplosionByDamage(this, attacker, getthink(this));
 }
 
-void W_Arc_Bolt_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Arc_Bolt_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
        self.use(this, NULL, NULL);
 }
 
-void W_Arc_Attack_Bolt(Weapon thiswep)
-{SELFPARAM();
+void W_Arc_Attack_Bolt(Weapon thiswep, entity actor)
+{
+    entity this = actor;
        entity missile;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR(arc, bolt_ammo));
@@ -286,9 +287,9 @@ void W_Arc_Attack_Bolt(Weapon thiswep)
        missile.event_damage = W_Arc_Bolt_Damage;
        missile.damagedbycontents = true;
 
-       missile.touch = W_Arc_Bolt_Touch;
+       settouch(missile, W_Arc_Bolt_Touch);
        missile.use = W_Arc_Bolt_Explode_use;
-       missile.think = adaptor_think2use_hittype_splash;
+       setthink(missile, adaptor_think2use_hittype_splash);
        missile.nextthink = time + WEP_CVAR(arc, bolt_lifetime);
        PROJECTILE_MAKETRIGGER(missile);
        missile.projectiledeathtype = WEP_ARC.m_id | HITTYPE_SECONDARY;
@@ -307,8 +308,8 @@ void W_Arc_Attack_Bolt(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
-void W_Arc_Beam_Think()
-{SELFPARAM();
+void W_Arc_Beam_Think(entity this)
+{
        if(self != self.owner.arc_beam)
        {
                remove(self);
@@ -372,15 +373,14 @@ void W_Arc_Beam_Think()
                }
 
                if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
-               setself(self.owner);
+               entity own = self.owner;
                Weapon w = WEP_ARC;
-               if(!w.wr_checkammo1(w) && !w.wr_checkammo2(w))
-               if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
+               if(!w.wr_checkammo1(w, own) && !w.wr_checkammo2(w, own))
+               if(!(own.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
-                       W_SwitchToOtherWeapon(self);
+                       W_SwitchToOtherWeapon(own);
                }
-               setself(this);
                remove(self);
                return;
        }
@@ -675,8 +675,8 @@ void W_Arc_Beam_Think()
        self.nextthink = time;
 }
 
-void W_Arc_Beam(float burst)
-{SELFPARAM();
+void W_Arc_Beam(float burst, entity actor)
+{entity this = actor;
 
        // only play fire sound if 1 sec has passed since player let go the fire button
        if(time - self.beam_prev > 1)
@@ -684,7 +684,7 @@ void W_Arc_Beam(float burst)
 
        entity beam = self.arc_beam = new(W_Arc_Beam);
        beam.solid = SOLID_NOT;
-       beam.think = W_Arc_Beam_Think;
+       setthink(beam, W_Arc_Beam_Think);
        beam.owner = self;
        beam.movetype = MOVETYPE_NONE;
        beam.bot_dodge = true;
@@ -692,11 +692,10 @@ void W_Arc_Beam(float burst)
        beam.beam_bursting = burst;
        Net_LinkEntity(beam, false, 0, W_Arc_Beam_Send);
 
-       WITHSELF(beam, beam.think());
+       WITHSELF(beam, getthink(beam)(beam));
 }
-
-void Arc_Smoke()
-{SELFPARAM();
+void Arc_Smoke(entity actor)
+{entity this = actor;
        makevectors(self.v_angle);
        W_SetupShot_Range(self,true,0,SND_Null,0,0,0);
 
@@ -731,9 +730,9 @@ void Arc_Smoke()
        }
 }
 
-METHOD(Arc, wr_aim, void(entity thiswep))
+METHOD(Arc, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(WEP_CVAR(arc, beam_botaimspeed))
     {
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(
@@ -758,7 +757,7 @@ METHOD(Arc, wr_aim, void(entity thiswep))
 METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
     Arc_Player_SetHeat(actor);
-    Arc_Smoke();
+    Arc_Smoke(actor);
 
     bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt));
 
@@ -780,7 +779,7 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(beam_fire2), 0))
             {
-                W_Arc_Beam(boolean(beam_fire2));
+                W_Arc_Beam(boolean(beam_fire2), actor);
 
                 if(!actor.arc_BUTTON_ATCK_prev)
                 {
@@ -796,7 +795,7 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(arc, bolt_refire)))
         {
-            W_Arc_Attack_Bolt(thiswep);
+            W_Arc_Attack_Bolt(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, bolt_refire), w_ready);
         }
     }
@@ -831,23 +830,21 @@ METHOD(Arc, wr_init, void(entity thiswep))
         arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
     }
 }
-METHOD(Arc, wr_checkammo1, bool(entity thiswep))
+METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    return ((!WEP_CVAR(arc, beam_ammo)) || (self.(thiswep.ammo_field) > 0));
+    return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0));
 }
-METHOD(Arc, wr_checkammo2, bool(entity thiswep))
+METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     if(WEP_CVAR(arc, bolt))
     {
-        float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
-        ammo_amount += self.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
+        float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
+        ammo_amount += actor.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
         return ammo_amount;
     }
     else
         return WEP_CVAR(arc, overheat_max) > 0 &&
-            ((!WEP_CVAR(arc, burst_ammo)) || (self.(thiswep.ammo_field) > 0));
+            ((!WEP_CVAR(arc, burst_ammo)) || (actor.(thiswep.ammo_field) > 0));
 }
 METHOD(Arc, wr_killmessage, Notification(entity thiswep))
 {
@@ -856,17 +853,17 @@ METHOD(Arc, wr_killmessage, Notification(entity thiswep))
     else
         return WEAPON_ARC_MURDER;
 }
-METHOD(Arc, wr_drop, void(entity thiswep))
+METHOD(Arc, wr_drop, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     weapon_dropevent_item.arc_overheat = self.arc_overheat;
     weapon_dropevent_item.arc_cooldown = self.arc_cooldown;
     self.arc_overheat = 0;
     self.arc_cooldown = 0;
 }
-METHOD(Arc, wr_pickup, void(entity thiswep))
+METHOD(Arc, wr_pickup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if ( !client_hasweapon(self, thiswep, false, false) &&
         weapon_dropevent_item.arc_overheat > time )
     {
@@ -878,9 +875,9 @@ METHOD(Arc, wr_pickup, void(entity thiswep))
 #ifdef CSQC
 bool autocvar_cl_arcbeam_teamcolor = true;
 
-METHOD(Arc, wr_impacteffect, void(entity thiswep))
+METHOD(Arc, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(w_deathtype & HITTYPE_SECONDARY)
     {
         vector org2;
@@ -1289,308 +1286,308 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
        {
                int gunalign = W_GetGunAlignment(world);
 
-               self.beam_shotorigin = arc_shotorigin[gunalign];
+               this.beam_shotorigin = arc_shotorigin[gunalign];
 
                // set other main attributes of the beam
-               self.draw = Draw_ArcBeam;
-               self.entremove = Remove_ArcBeam;
-               self.move_time = time;
-               loopsound(self, CH_SHOTS_SINGLE, SND(ARC_LOOP), VOL_BASE, ATTEN_NORM);
+               this.draw = Draw_ArcBeam;
+               this.entremove = Remove_ArcBeam;
+               this.move_time = time;
+               loopsound(this, CH_SHOTS_SINGLE, SND(ARC_LOOP), VOL_BASE, ATTEN_NORM);
 
                flash = spawn();
-               flash.owner = self;
+               flash.owner = this;
                flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
                flash.drawmask = MASK_NORMAL;
                flash.solid = SOLID_NOT;
                flash.avelocity_z = 5000;
-               setattachment(flash, self, "");
+               setattachment(flash, this, "");
                setorigin(flash, '0 0 0');
 
-               self.beam_muzzleentity = flash;
+               this.beam_muzzleentity = flash;
        }
        else
        {
-               flash = self.beam_muzzleentity;
+               flash = this.beam_muzzleentity;
        }
 
        if(sf & ARC_SF_SETTINGS) // settings information
        {
-               self.beam_degreespersegment = ReadShort();
-               self.beam_distancepersegment = ReadShort();
-               self.beam_maxangle = ReadShort();
-               self.beam_range = ReadCoord();
-               self.beam_returnspeed = ReadShort();
-               self.beam_tightness = (ReadByte() / 10);
+               this.beam_degreespersegment = ReadShort();
+               this.beam_distancepersegment = ReadShort();
+               this.beam_maxangle = ReadShort();
+               this.beam_range = ReadCoord();
+               this.beam_returnspeed = ReadShort();
+               this.beam_tightness = (ReadByte() / 10);
 
                if(ReadByte())
                {
                        if(autocvar_chase_active)
-                               { self.beam_usevieworigin = 1; }
+                               { this.beam_usevieworigin = 1; }
                        else // use view origin
-                               { self.beam_usevieworigin = 2; }
+                               { this.beam_usevieworigin = 2; }
                }
                else
                {
-                       self.beam_usevieworigin = 0;
+                       this.beam_usevieworigin = 0;
                }
 
-               self.sv_entnum = ReadByte();
+               this.sv_entnum = ReadByte();
        }
 
-       if(!self.beam_usevieworigin)
+       if(!this.beam_usevieworigin)
        {
-               // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
-               self.iflags = IFLAG_ORIGIN;
+               // this.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
+               this.iflags = IFLAG_ORIGIN;
 
-               InterpolateOrigin_Undo(self);
+               InterpolateOrigin_Undo(this);
        }
 
        if(sf & ARC_SF_START) // starting location
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
        }
-       else if(self.beam_usevieworigin) // infer the location from player location
+       else if(this.beam_usevieworigin) // infer the location from player location
        {
-               if(self.beam_usevieworigin == 2)
+               if(this.beam_usevieworigin == 2)
                {
                        // use view origin
-                       self.origin = view_origin;
+                       this.origin = view_origin;
                }
                else
                {
                        // use player origin so that third person display still works
-                       self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT));
+                       this.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT));
                }
        }
 
-       setorigin(self, self.origin);
+       setorigin(this, this.origin);
 
        if(sf & ARC_SF_WANTDIR) // want/aim direction
        {
-               self.v_angle_x = ReadCoord();
-               self.v_angle_y = ReadCoord();
-               self.v_angle_z = ReadCoord();
+               this.v_angle_x = ReadCoord();
+               this.v_angle_y = ReadCoord();
+               this.v_angle_z = ReadCoord();
        }
 
        if(sf & ARC_SF_BEAMDIR) // beam direction
        {
-               self.angles_x = ReadCoord();
-               self.angles_y = ReadCoord();
-               self.angles_z = ReadCoord();
+               this.angles_x = ReadCoord();
+               this.angles_y = ReadCoord();
+               this.angles_z = ReadCoord();
        }
 
        if(sf & ARC_SF_BEAMTYPE) // beam type
        {
-               self.beam_type = ReadByte();
+               this.beam_type = ReadByte();
 
-               vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(stof(getplayerkeyvalue(self.sv_entnum - 1, "colors")) & 0x0F, true) : '1 1 1');
-               switch(self.beam_type)
+               vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true) : '1 1 1');
+               switch(this.beam_type)
                {
                        case ARC_BT_MISS:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 8;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 8;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_WALL: // grenadelauncher_muzzleflash healray_muzzleflash
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 8;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; // (EFFECT_GRENADE_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 8;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; // (EFFECT_GRENADE_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_HEAL:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 8;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
-                               self.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 8;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
+                               this.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_HIT:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 8;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 20;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 0;
-                               self.beam_hitlight[3] = 0;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 50;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 0;
-                               self.beam_muzzlelight[3] = 0;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 8;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 20;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 0;
+                               this.beam_hitlight[3] = 0;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 50;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 0;
+                               this.beam_muzzlelight[3] = 0;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_BURST_MISS:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 14;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 14;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_BURST_WALL:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 14;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 14;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_BURST_HEAL:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 14;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
-                               self.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT2);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 14;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM_HEAL);
+                               this.beam_hiteffect = (EFFECT_ARC_BEAM_HEAL_IMPACT2);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
                        }
                        case ARC_BT_BURST_HIT:
                        {
-                               self.beam_color = beamcolor;
-                               self.beam_alpha = 0.5;
-                               self.beam_thickness = 14;
-                               self.beam_traileffect = (EFFECT_ARC_BEAM);
-                               self.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = beamcolor;
+                               this.beam_alpha = 0.5;
+                               this.beam_thickness = 14;
+                               this.beam_traileffect = (EFFECT_ARC_BEAM);
+                               this.beam_hiteffect = (EFFECT_ARC_LIGHTNING);
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
@@ -1599,26 +1596,26 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
                        // shouldn't be possible, but lets make it colorful if it does :D
                        default:
                        {
-                               self.beam_color = randomvec();
-                               self.beam_alpha = 1;
-                               self.beam_thickness = 8;
-                               self.beam_traileffect = NULL;
-                               self.beam_hiteffect = NULL;
-                               self.beam_hitlight[0] = 0;
-                               self.beam_hitlight[1] = 1;
-                               self.beam_hitlight[2] = 1;
-                               self.beam_hitlight[3] = 1;
-                               self.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
-                               self.beam_muzzlelight[0] = 0;
-                               self.beam_muzzlelight[1] = 1;
-                               self.beam_muzzlelight[2] = 1;
-                               self.beam_muzzlelight[3] = 1;
-                               self.beam_image = "particles/lgbeam";
-                               if(self.beam_muzzleeffect)
+                               this.beam_color = randomvec();
+                               this.beam_alpha = 1;
+                               this.beam_thickness = 8;
+                               this.beam_traileffect = NULL;
+                               this.beam_hiteffect = NULL;
+                               this.beam_hitlight[0] = 0;
+                               this.beam_hitlight[1] = 1;
+                               this.beam_hitlight[2] = 1;
+                               this.beam_hitlight[3] = 1;
+                               this.beam_muzzleeffect = NULL; //(EFFECT_VORTEX_MUZZLEFLASH);
+                               this.beam_muzzlelight[0] = 0;
+                               this.beam_muzzlelight[1] = 1;
+                               this.beam_muzzlelight[2] = 1;
+                               this.beam_muzzlelight[3] = 1;
+                               this.beam_image = "particles/lgbeam";
+                               if(this.beam_muzzleeffect)
                                {
                                        setmodel(flash, MDL_ARC_MUZZLEFLASH);
-                                       flash.alpha = self.beam_alpha;
-                                       flash.colormod = self.beam_color;
+                                       flash.alpha = this.beam_alpha;
+                                       flash.colormod = this.beam_color;
                                        flash.scale = 0.5;
                                }
                                break;
@@ -1626,7 +1623,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
                }
        }
 
-       if(!self.beam_usevieworigin)
+       if(!this.beam_usevieworigin)
        {
                InterpolateOrigin_Note(this);
        }
index f9f3008ff834c80ab1cdec6758d5e1f93178c395..394d50c6946c76007c9f70fff3d60da78c1b94ba 100644 (file)
@@ -56,9 +56,9 @@ REGISTER_WEAPON(BLASTER, blaster, NEW(Blaster));
 spawnfunc(weapon_blaster) { weapon_defaultspawnfunc(this, WEP_BLASTER); }
 spawnfunc(weapon_laser) { spawnfunc_weapon_blaster(this); }
 
-void W_Blaster_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Blaster_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
 
        self.event_damage = func_null;
 
@@ -78,10 +78,10 @@ void W_Blaster_Touch()
        remove(self);
 }
 
-void W_Blaster_Think()
-{SELFPARAM();
+void W_Blaster_Think(entity this)
+{
        this.movetype = MOVETYPE_FLY;
-       this.think = SUB_Remove_self;
+       setthink(this, SUB_Remove);
        this.nextthink = time + this.blaster_lifetime;
        CSQCProjectile(this, true, PROJECTILE_BLASTER, true);
 }
@@ -98,7 +98,7 @@ void W_Blaster_Attack(
        float atk_spread,
        float atk_delay,
        float atk_lifetime)
-{SELFPARAM();
+{
        vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
 
        W_SetupShot_Dir(actor, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage);
@@ -135,24 +135,24 @@ void W_Blaster_Attack(
        //missile.glow_color = 250; // 244, 250
        //missile.glow_size = 120;
 
-       missile.touch = W_Blaster_Touch;
+       settouch(missile, W_Blaster_Touch);
        missile.flags = FL_PROJECTILE;
        missile.missile_flags = MIF_SPLASH;
        missile.projectiledeathtype = atk_deathtype;
-       missile.think = W_Blaster_Think;
+       setthink(missile, W_Blaster_Think);
        missile.nextthink = time + atk_delay;
 
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
 
        if (time >= missile.nextthink)
        {
-               WITHSELF(missile, missile.think());
+               WITHSELF(missile, getthink(missile)(missile));
        }
 }
 
-METHOD(Blaster, wr_aim, void(entity thiswep))
+METHOD(Blaster, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(WEP_CVAR(blaster, secondary))
     {
         if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
@@ -223,18 +223,18 @@ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponenti
     }
 }
 
-METHOD(Blaster, wr_setup, void(entity thiswep))
+METHOD(Blaster, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.ammo_field = ammo_none;
 }
 
-METHOD(Blaster, wr_checkammo1, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor))
 {
     return true; // infinite ammo
 }
 
-METHOD(Blaster, wr_checkammo2, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor))
 {
     return true; // blaster has infinite ammo
 }
@@ -252,9 +252,9 @@ METHOD(Blaster, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Blaster, wr_impacteffect, void(entity thiswep))
+METHOD(Blaster, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 6;
     pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
index 9e2bb47416b890eded0d598ae31b485202557ef7..a582f9843bf7047d884aa77fa9bbd6f773c99616 100644 (file)
@@ -228,8 +228,8 @@ vector W_Crylink_LinkJoin(entity e, float jspeed)
        return targ_origin;
 }
 
-void W_Crylink_LinkJoinEffect_Think()
-{SELFPARAM();
+void W_Crylink_LinkJoinEffect_Think(entity this)
+{
        // is there at least 2 projectiles very close?
        entity e, p;
        float n;
@@ -293,12 +293,12 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad)
 }
 
 // NO bounce protection, as bounces are limited!
-void W_Crylink_Touch()
-{SELFPARAM();
+void W_Crylink_Touch(entity this)
+{
        float finalhit;
        float f;
        float isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        float a;
        a = bound(0, 1 - (time - self.fade_time) * self.fade_rate, 1);
@@ -338,14 +338,14 @@ void W_Crylink_Touch()
        //      CSQCProjectile(proj, true, PROJECTILE_CRYLINK, true);
 }
 
-void W_Crylink_Fadethink()
-{SELFPARAM();
+void W_Crylink_Fadethink(entity this)
+{
        W_Crylink_Dequeue(self);
        remove(self);
 }
 
-void W_Crylink_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Crylink_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        float counter, shots;
        entity proj, prevproj, firstproj;
        vector s;
@@ -414,9 +414,9 @@ void W_Crylink_Attack(Weapon thiswep)
                }
                s = s * WEP_CVAR_PRI(crylink, spread) * g_weaponspreadfactor;
                W_SetupProjVelocity_Explicit(proj, w_shotdir + right * s.y + up * s.z, v_up, WEP_CVAR_PRI(crylink, speed), 0, 0, 0, false);
-               proj.touch = W_Crylink_Touch;
+               settouch(proj, W_Crylink_Touch);
 
-               proj.think = W_Crylink_Fadethink;
+               setthink(proj, W_Crylink_Fadethink);
                if(counter == 0)
                {
                        proj.fade_time = time + WEP_CVAR_PRI(crylink, middle_lifetime);
@@ -452,8 +452,8 @@ void W_Crylink_Attack(Weapon thiswep)
        }
 }
 
-void W_Crylink_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Crylink_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
        float counter, shots;
        entity proj, prevproj, firstproj;
        vector s;
@@ -530,8 +530,8 @@ void W_Crylink_Attack2(Weapon thiswep)
                }
 
                W_SetupProjVelocity_Explicit(proj, s, v_up, WEP_CVAR_SEC(crylink, speed), 0, 0, 0, false);
-               proj.touch = W_Crylink_Touch;
-               proj.think = W_Crylink_Fadethink;
+               settouch(proj, W_Crylink_Touch);
+               setthink(proj, W_Crylink_Fadethink);
                if(counter == (shots - 1) / 2)
                {
                        proj.fade_time = time + WEP_CVAR_SEC(crylink, middle_lifetime);
@@ -567,9 +567,9 @@ void W_Crylink_Attack2(Weapon thiswep)
        }
 }
 
-METHOD(Crylink, wr_aim, void(entity thiswep))
+METHOD(Crylink, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(random() < 0.10)
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false);
     else
@@ -586,7 +586,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         if(actor.crylink_waitrelease != 1)
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(crylink, refire)))
         {
-            W_Crylink_Attack(thiswep);
+            W_Crylink_Attack(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
         }
     }
@@ -596,7 +596,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         if(actor.crylink_waitrelease != 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(crylink, refire)))
         {
-            W_Crylink_Attack2(thiswep);
+            W_Crylink_Attack2(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
         }
     }
@@ -615,13 +615,13 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
                 pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed));
 
                 linkjoineffect = new(linkjoineffect);
-                linkjoineffect.think = W_Crylink_LinkJoinEffect_Think;
+                setthink(linkjoineffect, W_Crylink_LinkJoinEffect_Think);
                 linkjoineffect.nextthink = time + w_crylink_linkjoin_time;
                 linkjoineffect.owner = actor;
                 setorigin(linkjoineffect, pos);
             }
             actor.crylink_waitrelease = 0;
-            if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep))
+            if(!thiswep.wr_checkammo1(thiswep, actor) && !thiswep.wr_checkammo2(thiswep, actor))
             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
             {
                 // ran out of ammo!
@@ -631,32 +631,29 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         }
     }
 }
-METHOD(Crylink, wr_checkammo1, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     // don't "run out of ammo" and switch weapons while waiting for release
-    if(self.crylink_lastgroup && self.crylink_waitrelease)
+    if(actor.crylink_lastgroup && actor.crylink_waitrelease)
         return true;
 
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
-    ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
+    ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
     return ammo_amount;
 }
-METHOD(Crylink, wr_checkammo2, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     // don't "run out of ammo" and switch weapons while waiting for release
-    if(self.crylink_lastgroup && self.crylink_waitrelease)
+    if(actor.crylink_lastgroup && actor.crylink_waitrelease)
         return true;
 
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
-    ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
+    ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
     return ammo_amount;
 }
 METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND_RELOAD);
 }
 METHOD(Crylink, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -668,9 +665,9 @@ METHOD(Crylink, wr_killmessage, Notification(entity thiswep))
 }
 #endif
 #ifdef CSQC
-METHOD(Crylink, wr_impacteffect, void(entity thiswep))
+METHOD(Crylink, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 2;
     if(w_deathtype & HITTYPE_SECONDARY)
index 1cde73d4466bcb887976050518c74820d63c3a8e..772b9ea6294c616d38aed6aa346de49ee4440e74 100644 (file)
@@ -72,8 +72,8 @@ spawnfunc(weapon_rocketlauncher) { spawnfunc_weapon_devastator(this); }
 
 .entity lastrocket;
 
-void W_Devastator_Unregister()
-{SELFPARAM();
+void W_Devastator_Unregister(entity this)
+{
        if(self.realowner && self.realowner.lastrocket == self)
        {
                self.realowner.lastrocket = world;
@@ -81,9 +81,9 @@ void W_Devastator_Unregister()
        }
 }
 
-void W_Devastator_Explode()
-{SELFPARAM();
-       W_Devastator_Unregister();
+void W_Devastator_Explode(entity this)
+{
+       W_Devastator_Unregister(self);
 
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
@@ -123,9 +123,9 @@ void W_Devastator_Explode()
        remove(self);
 }
 
-void W_Devastator_DoRemoteExplode(.entity weaponentity)
-{SELFPARAM();
-       W_Devastator_Unregister();
+void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
+{
+       W_Devastator_Unregister(self);
 
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
@@ -204,8 +204,8 @@ void W_Devastator_DoRemoteExplode(.entity weaponentity)
        remove(self);
 }
 
-void W_Devastator_RemoteExplode(.entity weaponentity)
-{SELFPARAM();
+void W_Devastator_RemoteExplode(entity this, .entity weaponentity)
+{
        if(!IS_DEAD(self.realowner))
        if(self.realowner.lastrocket)
        {
@@ -214,7 +214,7 @@ void W_Devastator_RemoteExplode(.entity weaponentity)
                        : (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(devastator, remote_radius))) // safety device
                )
                {
-                       W_Devastator_DoRemoteExplode(weaponentity);
+                       W_Devastator_DoRemoteExplode(self, weaponentity);
                }
        }
 }
@@ -252,8 +252,8 @@ vector W_Devastator_SteerTo(vector thisdir, vector goaldir, float maxturn_cos)
 //   normalize(thisdir + goaldir)
 //   normalize(0)
 
-void W_Devastator_Think()
-{SELFPARAM();
+void W_Devastator_Think(entity this)
+{
        vector desireddir, olddir, newdir, desiredorigin, goal;
        float velspeed, f;
        self.nextthink = time;
@@ -261,7 +261,7 @@ void W_Devastator_Think()
        {
                other = world;
                self.projectiledeathtype |= HITTYPE_BOUNCE;
-               W_Devastator_Explode();
+               W_Devastator_Explode(self);
                return;
        }
 
@@ -313,23 +313,23 @@ void W_Devastator_Think()
 
                .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                if(self.rl_detonate_later)
-                       W_Devastator_RemoteExplode(weaponentity);
+                       W_Devastator_RemoteExplode(self, weaponentity);
        }
 
        if(self.csqcprojectile_clientanimate == 0)
                UpdateCSQCProjectile(self);
 }
 
-void W_Devastator_Touch()
-{SELFPARAM();
-       if(WarpZone_Projectile_Touch())
+void W_Devastator_Touch(entity this)
+{
+       if(WarpZone_Projectile_Touch(this))
        {
-               if(wasfreed(self))
-                       W_Devastator_Unregister();
+               if(wasfreed(this))
+                       W_Devastator_Unregister(this);
                return;
        }
-       W_Devastator_Unregister();
-       W_Devastator_Explode();
+       W_Devastator_Unregister(this);
+       W_Devastator_Explode(this);
 }
 
 void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -347,8 +347,8 @@ void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float d
                W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode);
 }
 
-void W_Devastator_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Devastator_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
        entity flash;
 
@@ -384,8 +384,8 @@ void W_Devastator_Attack(Weapon thiswep)
        W_SetupProjVelocity_Basic(missile, WEP_CVAR(devastator, speedstart), 0);
        missile.angles = vectoangles(missile.velocity);
 
-       missile.touch = W_Devastator_Touch;
-       missile.think = W_Devastator_Think;
+       settouch(missile, W_Devastator_Touch);
+       setthink(missile, W_Devastator_Think);
        missile.nextthink = time;
        missile.cnt = time + WEP_CVAR(devastator, lifetime);
        missile.flags = FL_PROJECTILE;
@@ -405,8 +405,9 @@ void W_Devastator_Attack(Weapon thiswep)
 }
 
 #if 0
-METHOD(Devastator, wr_aim, void(entity thiswep))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
 {
+    entity this = actor;
     // aim and decide to fire if appropriate
     PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
@@ -432,9 +433,9 @@ METHOD(Devastator, wr_aim, void(entity thiswep))
     }
 }
 #else
-METHOD(Devastator, wr_aim, void(entity thiswep))
+METHOD(Devastator, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     // aim and decide to fire if appropriate
     PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
@@ -530,7 +531,7 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
             if(actor.rl_release || WEP_CVAR(devastator, guidestop))
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
             {
-                W_Devastator_Attack(thiswep);
+                W_Devastator_Attack(thiswep, actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
                 actor.rl_release = 0;
             }
@@ -556,62 +557,60 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen
         }
     }
 }
-METHOD(Devastator, wr_setup, void(entity thiswep))
+METHOD(Devastator, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.rl_release = 1;
 }
-METHOD(Devastator, wr_checkammo1, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     #if 0
     // don't switch while guiding a missile
-    if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_DEVASTATOR)
+    if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
     {
         ammo_amount = false;
         if(WEP_CVAR(devastator, reload_ammo))
         {
-            if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && self.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
+            if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
                 ammo_amount = true;
         }
-        else if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
+        else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
             ammo_amount = true;
         return !ammo_amount;
     }
     #endif
     #if 0
-    if(self.rl_release == 0)
+    if(actor.rl_release == 0)
     {
-        LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
+        LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
         return true;
     }
     else
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
-        ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
-        LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+        ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+        LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
         return ammo_amount;
     }
     #else
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
-    ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+    ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
     return ammo_amount;
     #endif
 }
-METHOD(Devastator, wr_checkammo2, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor))
 {
     return false;
 }
-METHOD(Devastator, wr_resetplayer, void(entity thiswep))
+METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
     self.rl_release = 0;
 }
 METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, WEP_CVAR(devastator, ammo), SND_RELOAD);
+    W_Reload(actor, WEP_CVAR(devastator, ammo), SND_RELOAD);
 }
 METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -628,9 +627,9 @@ METHOD(Devastator, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Devastator, wr_impacteffect, void(entity thiswep))
+METHOD(Devastator, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 12;
     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
index 315ea5a5a470731d5f699df18ae81c1e1e4eeea0..64a5e06aa0621f0dd826f943cd0eec7018bfa217 100644 (file)
@@ -68,7 +68,7 @@ REGISTER_WEAPON(ELECTRO, electro, NEW(Electro));
 #ifdef SVQC
 .float electro_count;
 .float electro_secondarytime;
-void W_Electro_ExplodeCombo();
+void W_Electro_ExplodeCombo(entity this);
 #endif
 #endif
 #ifdef IMPLEMENTATION
@@ -104,7 +104,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
                        e.classname = "electro_orb_chain";
 
                        // now set the next one to trigger as well
-                       e.think = W_Electro_ExplodeCombo;
+                       setthink(e, W_Electro_ExplodeCombo);
 
                        // delay combo chains, looks cooler
                        e.nextthink =
@@ -122,8 +122,8 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
        }
 }
 
-void W_Electro_ExplodeCombo()
-{SELFPARAM();
+void W_Electro_ExplodeCombo(entity this)
+{
        W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
 
        self.event_damage = func_null;
@@ -144,8 +144,8 @@ void W_Electro_ExplodeCombo()
        remove(self);
 }
 
-void W_Electro_Explode()
-{SELFPARAM();
+void W_Electro_Explode(entity this)
+{
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -193,17 +193,17 @@ void W_Electro_Explode()
 
 void W_Electro_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Electro_Explode());
+       WITHSELF(this, W_Electro_Explode(this));
 }
 
-void W_Electro_TouchExplode()
+void W_Electro_TouchExplode(entity this)
 {
-       PROJECTILE_TOUCH;
-       W_Electro_Explode();
+       PROJECTILE_TOUCH(this);
+       W_Electro_Explode(this);
 }
 
-void W_Electro_Bolt_Think()
-{SELFPARAM();
+void W_Electro_Bolt_Think(entity this)
+{
        if(time >= self.ltime)
        {
                this.use(this, NULL, NULL);
@@ -226,7 +226,7 @@ void W_Electro_Bolt_Think()
                                e.classname = "electro_orb_chain";
 
                                // now set the next one to trigger as well
-                               e.think = W_Electro_ExplodeCombo;
+                               setthink(e, W_Electro_ExplodeCombo);
 
                                // delay combo chains, looks cooler
                                e.nextthink =
@@ -254,8 +254,8 @@ void W_Electro_Bolt_Think()
        else { self.nextthink = self.ltime; }
 }
 
-void W_Electro_Attack_Bolt(Weapon thiswep)
-{SELFPARAM();
+void W_Electro_Attack_Bolt(Weapon thiswep, entity actor)
+{entity this = actor;
        entity proj;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo));
@@ -278,7 +278,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep)
        proj.bot_dodge = true;
        proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
        proj.use = W_Electro_Explode_use;
-       proj.think = W_Electro_Bolt_Think;
+       setthink(proj, W_Electro_Bolt_Think);
        proj.nextthink = time;
        proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
        PROJECTILE_MAKETRIGGER(proj);
@@ -288,7 +288,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep)
        proj.movetype = MOVETYPE_FLY;
        W_SetupProjVelocity_PRI(proj, electro);
        proj.angles = vectoangles(proj.velocity);
-       proj.touch = W_Electro_TouchExplode;
+       settouch(proj, W_Electro_TouchExplode);
        setsize(proj, '0 0 -3', '0 0 -3');
        proj.flags = FL_PROJECTILE;
        proj.missile_flags = MIF_SPLASH;
@@ -298,11 +298,11 @@ void W_Electro_Attack_Bolt(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Electro_Orb_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Electro_Orb_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
        if(other.takedamage == DAMAGE_AIM)
-               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
+               { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(self); } }
        else
        {
                //UpdateCSQCProjectile(self);
@@ -332,7 +332,7 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float
                        // change owner to whoever caused the combo explosion
                        this.realowner = inflictor.realowner;
                        this.classname = "electro_orb_chain";
-                       this.think = W_Electro_ExplodeCombo;
+                       setthink(this, W_Electro_ExplodeCombo);
                        this.nextthink = time +
                                (
                                        // bound the length, inflictor may be in a galaxy far far away (warpzones)
@@ -348,13 +348,13 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float
                else
                {
                        this.use = W_Electro_Explode_use;
-                       this.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
+                       setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
                }
        }
 }
 
-void W_Electro_Attack_Orb(Weapon thiswep)
-{SELFPARAM();
+void W_Electro_Attack_Orb(Weapon thiswep, entity actor)
+{entity this = actor;
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo));
 
        W_SetupShot_ProjectileSize(
@@ -375,7 +375,7 @@ void W_Electro_Attack_Orb(Weapon thiswep)
        entity proj = new(electro_orb);
        proj.owner = proj.realowner = self;
        proj.use = W_Electro_Explode_use;
-       proj.think = adaptor_think2use_hittype_splash;
+       setthink(proj, adaptor_think2use_hittype_splash);
        proj.bot_dodge = true;
        proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
        proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
@@ -387,7 +387,7 @@ void W_Electro_Attack_Orb(Weapon thiswep)
        //proj.glow_color = 45;
        proj.movetype = MOVETYPE_BOUNCE;
        W_SetupProjVelocity_UP_SEC(proj, electro);
-       proj.touch = W_Electro_Orb_Touch;
+       settouch(proj, W_Electro_Orb_Touch);
        setsize(proj, '0 0 -4', '0 0 -4');
        proj.takedamage = DAMAGE_YES;
        proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
@@ -414,12 +414,12 @@ void W_Electro_Attack_Orb(Weapon thiswep)
 }
 
 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
-{SELFPARAM();
+{entity this = actor;
        if(self.electro_count > 1)
        if(PHYS_INPUT_BUTTON_ATCK2(self))
        if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
        {
-               W_Electro_Attack_Orb(WEP_ELECTRO);
+               W_Electro_Attack_Orb(WEP_ELECTRO, actor);
                self.electro_count -= 1;
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
                return;
@@ -430,9 +430,9 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
 
 .float bot_secondary_electromooth;
 
-METHOD(Electro, wr_aim, void(entity thiswep))
+METHOD(Electro, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = PHYS_INPUT_BUTTON_ATCK2(self) = false;
     if(vdist(self.origin - self.enemy.origin, >, 1000)) { self.bot_secondary_electromooth = 0; }
     if(self.bot_secondary_electromooth == 0)
@@ -480,7 +480,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
         {
-                W_Electro_Attack_Bolt(thiswep);
+                W_Electro_Attack_Bolt(thiswep, actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
     }
@@ -489,45 +489,42 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         if(time >= actor.electro_secondarytime)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
         {
-            W_Electro_Attack_Orb(thiswep);
+            W_Electro_Attack_Orb(thiswep, actor);
             actor.electro_count = WEP_CVAR_SEC(electro, count);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
             actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
         }
     }
 }
-METHOD(Electro, wr_checkammo1, bool(entity thiswep))
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
-    ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
+    ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
     return ammo_amount;
 }
-METHOD(Electro, wr_checkammo2, bool(entity thiswep))
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float ammo_amount;
     if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
-        ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+        ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
     }
     else
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
-        ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
+        ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
     }
     return ammo_amount;
 }
-METHOD(Electro, wr_resetplayer, void(entity thiswep))
+METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.electro_secondarytime = time;
 }
 METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
 }
 METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -554,9 +551,9 @@ METHOD(Electro, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Electro, wr_impacteffect, void(entity thiswep))
+METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 6;
     if(w_deathtype & HITTYPE_SECONDARY)
index 4bbcdb68e50498af226bafb5a21f8bead1f2bf8b..3ee23e8f5f7a66f16682c004056b88e3a03635f3 100644 (file)
@@ -62,8 +62,8 @@ REGISTER_WEAPON(FIREBALL, fireball, NEW(Fireball));
 #ifdef SVQC
 spawnfunc(weapon_fireball) { weapon_defaultspawnfunc(this, WEP_FIREBALL); }
 
-void W_Fireball_Explode()
-{SELFPARAM();
+void W_Fireball_Explode(entity this)
+{
        entity e;
        float dist;
        float points;
@@ -114,17 +114,17 @@ void W_Fireball_Explode()
 
 void W_Fireball_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Fireball_Explode());
+       WITHSELF(this, W_Fireball_Explode(this));
 }
 
-void W_Fireball_TouchExplode()
+void W_Fireball_TouchExplode(entity this)
 {
-       PROJECTILE_TOUCH;
-       W_Fireball_Explode();
+       PROJECTILE_TOUCH(this);
+       W_Fireball_Explode(this);
 }
 
-void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
-{SELFPARAM();
+void W_Fireball_LaserPlay(entity this, float dt, float dist, float damage, float edgedamage, float burntime)
+{
        entity e;
        float d;
        vector p;
@@ -157,17 +157,17 @@ void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage,
        }
 }
 
-void W_Fireball_Think()
-{SELFPARAM();
+void W_Fireball_Think(entity this)
+{
        if(time > self.pushltime)
        {
                self.cnt = 1;
                self.projectiledeathtype |= HITTYPE_SPLASH;
-               W_Fireball_Explode();
+               W_Fireball_Explode(this);
                return;
        }
 
-       W_Fireball_LaserPlay(0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
+       W_Fireball_LaserPlay(self, 0.1, WEP_CVAR_PRI(fireball, laserradius), WEP_CVAR_PRI(fireball, laserdamage), WEP_CVAR_PRI(fireball, laseredgedamage), WEP_CVAR_PRI(fireball, laserburntime));
 
        self.nextthink = time + 0.1;
 }
@@ -188,8 +188,8 @@ void W_Fireball_Damage(entity this, entity inflictor, entity attacker, float dam
        }
 }
 
-void W_Fireball_Attack1()
-{SELFPARAM();
+void W_Fireball_Attack1(entity actor)
+{entity this = actor;
        entity proj;
 
        W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 2, SND_FIREBALL_FIRE2, CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
@@ -202,7 +202,7 @@ void W_Fireball_Attack1()
        proj.bot_dodgerating = WEP_CVAR_PRI(fireball, damage);
        proj.pushltime = time + WEP_CVAR_PRI(fireball, lifetime);
        proj.use = W_Fireball_Explode_use;
-       proj.think = W_Fireball_Think;
+       setthink(proj, W_Fireball_Think);
        proj.nextthink = time;
        proj.health = WEP_CVAR_PRI(fireball, health);
        proj.team = self.team;
@@ -216,7 +216,7 @@ void W_Fireball_Attack1()
        proj.movetype = MOVETYPE_FLY;
        W_SetupProjVelocity_PRI(proj, fireball);
        proj.angles = vectoangles(proj.velocity);
-       proj.touch = W_Fireball_TouchExplode;
+       settouch(proj, W_Fireball_TouchExplode);
        setsize(proj, '-16 -16 -16', '16 16 16');
        proj.flags = FL_PROJECTILE;
     proj.missile_flags = MIF_SPLASH | MIF_PROXY;
@@ -226,46 +226,46 @@ void W_Fireball_Attack1()
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Fireball_AttackEffect(float i, vector f_diff)
-{SELFPARAM();
-       W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0);
+void W_Fireball_AttackEffect(entity actor, float i, vector f_diff)
+{
+       W_SetupShot_ProjectileSize(actor, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0);
        w_shotorg += f_diff.x * v_up + f_diff.y * v_right;
        Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 }
 
 void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       W_Fireball_Attack1();
+       W_Fireball_Attack1(actor);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
 }
 
 void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
+       W_Fireball_AttackEffect(actor, 0, '+1.25 +3.75 0');
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
 }
 
 void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
+       W_Fireball_AttackEffect(actor, 0, '-1.25 +3.75 0');
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
 }
 
 void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
+       W_Fireball_AttackEffect(actor, 1, '+1.25 -3.75 0');
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
 }
 
 void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, .entity weaponentity, int fire)
-{SELFPARAM();
-       W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
-       sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
+{
+       W_Fireball_AttackEffect(actor, 0, '-1.25 -3.75 0');
+       sound(actor, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
 }
 
-void W_Fireball_Firemine_Think()
-{SELFPARAM();
+void W_Fireball_Firemine_Think(entity this)
+{
        if(time > self.pushltime)
        {
                remove(self);
@@ -285,14 +285,14 @@ void W_Fireball_Firemine_Think()
                        self.cnt = 0;
        }
 
-       W_Fireball_LaserPlay(0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
+       W_Fireball_LaserPlay(self, 0.1, WEP_CVAR_SEC(fireball, laserradius), WEP_CVAR_SEC(fireball, laserdamage), WEP_CVAR_SEC(fireball, laseredgedamage), WEP_CVAR_SEC(fireball, laserburntime));
 
        self.nextthink = time + 0.1;
 }
 
-void W_Fireball_Firemine_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Fireball_Firemine_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
        if(other.takedamage == DAMAGE_AIM)
        if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
        {
@@ -302,8 +302,8 @@ void W_Fireball_Firemine_Touch()
        self.projectiledeathtype |= HITTYPE_BOUNCE;
 }
 
-void W_Fireball_Attack2()
-{SELFPARAM();
+void W_Fireball_Attack2(entity actor)
+{entity this = actor;
        entity proj;
        vector f_diff;
        float c;
@@ -337,11 +337,11 @@ void W_Fireball_Attack2()
        proj.bot_dodgerating = WEP_CVAR_SEC(fireball, damage);
        proj.movetype = MOVETYPE_BOUNCE;
        proj.projectiledeathtype = WEP_FIREBALL.m_id | HITTYPE_SECONDARY;
-       proj.touch = W_Fireball_Firemine_Touch;
+       settouch(proj, W_Fireball_Firemine_Touch);
        PROJECTILE_MAKETRIGGER(proj);
        setsize(proj, '-4 -4 -4', '4 4 4');
        setorigin(proj, w_shotorg);
-       proj.think = W_Fireball_Firemine_Think;
+       setthink(proj, W_Fireball_Firemine_Think);
        proj.nextthink = time;
        proj.damageforcescale = WEP_CVAR_SEC(fireball, damageforcescale);
        proj.pushltime = time + WEP_CVAR_SEC(fireball, lifetime);
@@ -356,9 +356,9 @@ void W_Fireball_Attack2()
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-METHOD(Fireball, wr_aim, void(entity thiswep))
+METHOD(Fireball, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = false;
     PHYS_INPUT_BUTTON_ATCK2(self) = false;
     if(self.bot_primary_fireballmooth == 0)
@@ -393,27 +393,27 @@ METHOD(Fireball, wr_think, void(entity thiswep, entity actor, .entity weaponenti
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(fireball, refire)))
         {
-            W_Fireball_Attack2();
+            W_Fireball_Attack2(actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
         }
     }
 }
-METHOD(Fireball, wr_setup, void(entity thiswep))
+METHOD(Fireball, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.ammo_field = ammo_none;
 }
-METHOD(Fireball, wr_checkammo1, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor))
 {
     return true; // infinite ammo
 }
-METHOD(Fireball, wr_checkammo2, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor))
 {
     return true; // fireball has infinite ammo
 }
-METHOD(Fireball, wr_resetplayer, void(entity thiswep))
+METHOD(Fireball, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.fireball_primarytime = time;
 }
 METHOD(Fireball, wr_suicidemessage, Notification(entity thiswep))
@@ -434,9 +434,9 @@ METHOD(Fireball, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Fireball, wr_impacteffect, void(entity thiswep))
+METHOD(Fireball, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     if(w_deathtype & HITTYPE_SECONDARY)
     {
index 4b0367fb5e6478079b1fc6ddc91c9f5467821105..577d4cf4e2671b562e8843601ce55a620e793609 100644 (file)
@@ -63,8 +63,8 @@ spawnfunc(weapon_hagar) { weapon_defaultspawnfunc(this, WEP_HAGAR); }
 
 // NO bounce protection, as bounces are limited!
 
-void W_Hagar_Explode()
-{SELFPARAM();
+void W_Hagar_Explode(entity this)
+{
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), world, world, WEP_CVAR_PRI(hagar, force), self.projectiledeathtype, other);
 
@@ -73,11 +73,11 @@ void W_Hagar_Explode()
 
 void W_Hagar_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Hagar_Explode());
+       WITHSELF(this, W_Hagar_Explode(this));
 }
 
-void W_Hagar_Explode2()
-{SELFPARAM();
+void W_Hagar_Explode2(entity this)
+{
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), world, world, WEP_CVAR_SEC(hagar, force), self.projectiledeathtype, other);
 
@@ -86,7 +86,7 @@ void W_Hagar_Explode2()
 
 void W_Hagar_Explode2_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Hagar_Explode2());
+       WITHSELF(this, W_Hagar_Explode2(this));
 }
 
 void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -110,18 +110,18 @@ void W_Hagar_Damage(entity this, entity inflictor, entity attacker, float damage
        this.angles = vectoangles(this.velocity);
 
        if(this.health <= 0)
-               W_PrepareExplosionByDamage(this, attacker, this.think);
+               W_PrepareExplosionByDamage(this, attacker, getthink(this));
 }
 
-void W_Hagar_Touch()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Hagar_Touch(entity this)
+{
+       PROJECTILE_TOUCH(this);
        this.use(this, NULL, NULL);
 }
 
-void W_Hagar_Touch2()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Hagar_Touch2(entity this)
+{
+       PROJECTILE_TOUCH(this);
 
        if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
                this.use(this, NULL, NULL);
@@ -134,8 +134,8 @@ void W_Hagar_Touch2()
        }
 }
 
-void W_Hagar_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Hagar_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(hagar, ammo));
@@ -155,9 +155,9 @@ void W_Hagar_Attack(Weapon thiswep)
        missile.event_damage = W_Hagar_Damage;
        missile.damagedbycontents = true;
 
-       missile.touch = W_Hagar_Touch;
+       settouch(missile, W_Hagar_Touch);
        missile.use = W_Hagar_Explode_use;
-       missile.think = adaptor_think2use_hittype_splash;
+       setthink(missile, adaptor_think2use_hittype_splash);
        missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
        PROJECTILE_MAKETRIGGER(missile);
        missile.projectiledeathtype = WEP_HAGAR.m_id;
@@ -176,8 +176,8 @@ void W_Hagar_Attack(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
-void W_Hagar_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Hagar_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo));
@@ -197,10 +197,10 @@ void W_Hagar_Attack2(Weapon thiswep)
        missile.event_damage = W_Hagar_Damage;
        missile.damagedbycontents = true;
 
-       missile.touch = W_Hagar_Touch2;
+       settouch(missile, W_Hagar_Touch2);
        missile.cnt = 0;
        missile.use = W_Hagar_Explode2_use;
-       missile.think = adaptor_think2use_hittype_splash;
+       setthink(missile, adaptor_think2use_hittype_splash);
        missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
        PROJECTILE_MAKETRIGGER(missile);
        missile.projectiledeathtype = WEP_HAGAR.m_id | HITTYPE_SECONDARY;
@@ -220,8 +220,8 @@ void W_Hagar_Attack2(Weapon thiswep)
 }
 
 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
-void W_Hagar_Attack2_Load_Release(.entity weaponentity)
-{SELFPARAM();
+void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity)
+{entity this = actor;
        // time to release the rockets we've loaded
 
        entity missile;
@@ -256,9 +256,9 @@ void W_Hagar_Attack2_Load_Release(.entity weaponentity)
                missile.event_damage = W_Hagar_Damage;
                missile.damagedbycontents = true;
 
-               missile.touch = W_Hagar_Touch; // not bouncy
+               settouch(missile, W_Hagar_Touch); // not bouncy
                missile.use = W_Hagar_Explode2_use;
-               missile.think = adaptor_think2use_hittype_splash;
+               setthink(missile, adaptor_think2use_hittype_splash);
                missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
                PROJECTILE_MAKETRIGGER(missile);
                missile.projectiledeathtype = WEP_HAGAR.m_id | HITTYPE_SECONDARY;
@@ -299,8 +299,8 @@ void W_Hagar_Attack2_Load_Release(.entity weaponentity)
        self.hagar_load = 0;
 }
 
-void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
-{SELFPARAM();
+void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity)
+{entity this = actor;
        // loadable hagar secondary attack, must always run each frame
 
        if(time < game_starttime)
@@ -388,7 +388,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
                if(!PHYS_INPUT_BUTTON_ATCK2(self) || (stopped && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
                {
                        self.(weaponentity).state = WS_READY;
-                       W_Hagar_Attack2_Load_Release(weaponentity);
+                       W_Hagar_Attack2_Load_Release(self, weaponentity);
                }
        }
        else
@@ -397,7 +397,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
                self.hagar_warning = false;
 
                // we aren't checking ammo during an attack, so we must do it here
-               if(!(thiswep.wr_checkammo1(thiswep) + thiswep.wr_checkammo2(thiswep)))
+               if(!(thiswep.wr_checkammo1(thiswep, self) + thiswep.wr_checkammo2(thiswep, self)))
                if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
@@ -415,7 +415,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
                return;
        }
 
-       if(!thiswep.wr_checkammo1(thiswep))
+       if(!thiswep.wr_checkammo1(thiswep, actor))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -423,7 +423,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
                return;
        }
 
-       W_Hagar_Attack(thiswep);
+       W_Hagar_Attack(thiswep, actor);
 
        int slot = weaponslot(weaponentity);
        ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor();
@@ -437,9 +437,9 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
        weapon_thinkf(actor, weaponentity, theframe, WEP_CVAR_PRI(hagar, refire), W_Hagar_Attack_Auto);
 }
 
-METHOD(Hagar, wr_aim, void(entity thiswep))
+METHOD(Hagar, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(random()>0.15)
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
     else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
@@ -451,7 +451,7 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
     loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
 
     if(loadable_secondary)
-        W_Hagar_Attack2_Load(thiswep, weaponentity); // must always run each frame
+        W_Hagar_Attack2_Load(thiswep, actor, weaponentity); // must always run each frame
     if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
         thiswep.wr_reload(thiswep, actor, weaponentity);
     }
@@ -464,25 +464,24 @@ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire)))
         {
-            W_Hagar_Attack2(thiswep);
+            W_Hagar_Attack2(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
         }
     }
 }
-METHOD(Hagar, wr_gonethink, void(entity thiswep))
+METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
     // we lost the weapon and want to prepare switching away
-    if(self.hagar_load)
+    if(actor.hagar_load)
     {
         .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-        self.(weaponentity).state = WS_READY;
-        W_Hagar_Attack2_Load_Release(weaponentity);
+        actor.(weaponentity).state = WS_READY;
+        W_Hagar_Attack2_Load_Release(actor, weaponentity);
     }
 }
-METHOD(Hagar, wr_setup, void(entity thiswep))
+METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.hagar_loadblock = false;
 
     if(self.hagar_load)
@@ -491,36 +490,33 @@ METHOD(Hagar, wr_setup, void(entity thiswep))
         self.hagar_load = 0;
     }
 }
-METHOD(Hagar, wr_checkammo1, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
-    ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
+    ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
     return ammo_amount;
 }
-METHOD(Hagar, wr_checkammo2, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
-    ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
+    ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
     return ammo_amount;
 }
-METHOD(Hagar, wr_resetplayer, void(entity thiswep))
+METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.hagar_load = 0;
 }
-METHOD(Hagar, wr_playerdeath, void(entity thiswep))
+METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
     .entity weaponentity = weaponentities[0]; // TODO: unhardcode
     // if we have any rockets loaded when we die, release them
-    if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
-        W_Hagar_Attack2_Load_Release(weaponentity);
+    if(actor.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
+        W_Hagar_Attack2_Load_Release(actor, weaponentity);
 }
 METHOD(Hagar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
+    entity this = actor;
     if(!self.hagar_load) // require releasing loaded rockets first
         W_Reload(self, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD);
 }
@@ -539,9 +535,9 @@ METHOD(Hagar, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Hagar, wr_impacteffect, void(entity thiswep))
+METHOD(Hagar, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 6;
     pointparticles(EFFECT_HAGAR_EXPLODE, org2, '0 0 0', 1);
index 4be78821cde2ff5dcd0e3a8e4fffa1b655ab8cd7..3fa50ff0445565e0543a1dee20225326ecba2a7c 100644 (file)
@@ -54,11 +54,11 @@ REGISTER_WEAPON(HLAC, hlac, NEW(HLAC));
 #ifdef SVQC
 spawnfunc(weapon_hlac) { weapon_defaultspawnfunc(this, WEP_HLAC); }
 
-void W_HLAC_Touch()
-{SELFPARAM();
+void W_HLAC_Touch(entity this)
+{
        float isprimary;
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        self.event_damage = func_null;
 
@@ -69,8 +69,8 @@ void W_HLAC_Touch()
        remove(self);
 }
 
-void W_HLAC_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_HLAC_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
     float spread;
 
@@ -104,8 +104,8 @@ void W_HLAC_Attack(Weapon thiswep)
        W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
        //missile.angles = vectoangles(missile.velocity); // csqc
 
-       missile.touch = W_HLAC_Touch;
-       missile.think = SUB_Remove_self;
+       settouch(missile, W_HLAC_Touch);
+       setthink(missile, SUB_Remove);
 
     missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
 
@@ -117,8 +117,8 @@ void W_HLAC_Attack(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
-void W_HLAC_Attack2()
-{SELFPARAM();
+void W_HLAC_Attack2(entity actor)
+{entity this = actor;
        entity missile;
     float spread;
 
@@ -146,8 +146,8 @@ void W_HLAC_Attack2()
        W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
        //missile.angles = vectoangles(missile.velocity); // csqc
 
-       missile.touch = W_HLAC_Touch;
-       missile.think = SUB_Remove_self;
+       settouch(missile, W_HLAC_Touch);
+       setthink(missile, SUB_Remove);
 
     missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
 
@@ -171,7 +171,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
 
        if(PHYS_INPUT_BUTTON_ATCK(actor))
        {
-               if(!thiswep.wr_checkammo1(thiswep))
+               if(!thiswep.wr_checkammo1(thiswep, actor))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -181,7 +181,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
 
                int slot = weaponslot(weaponentity);
                ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
-               W_HLAC_Attack(WEP_HLAC);
+               W_HLAC_Attack(WEP_HLAC, actor);
                actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
        }
@@ -191,14 +191,14 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
        }
 }
 
-void W_HLAC_Attack2_Frame(Weapon thiswep)
-{SELFPARAM();
+void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor)
+{entity this = actor;
     float i;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hlac, ammo));
 
     for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
-        W_HLAC_Attack2();
+        W_HLAC_Attack2(actor);
 
        if(!autocvar_g_norecoil)
        {
@@ -207,9 +207,9 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
        }
 }
 
-METHOD(HLAC, wr_aim, void(entity thiswep))
+METHOD(HLAC, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
 }
 METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
@@ -221,7 +221,7 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
         {
             actor.misc_bulletcounter = 0;
-            W_HLAC_Attack(thiswep);
+            W_HLAC_Attack(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
         }
     }
@@ -230,29 +230,26 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hlac, refire)))
         {
-            W_HLAC_Attack2_Frame(thiswep);
+            W_HLAC_Attack2_Frame(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
         }
     }
 }
-METHOD(HLAC, wr_checkammo1, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
-    ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
+    ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
     return ammo_amount;
 }
-METHOD(HLAC, wr_checkammo2, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
-    ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
+    ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
     return ammo_amount;
 }
 METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND_RELOAD);
 }
 METHOD(HLAC, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -266,9 +263,9 @@ METHOD(HLAC, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(HLAC, wr_impacteffect, void(entity thiswep))
+METHOD(HLAC, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 6;
     pointparticles(EFFECT_BLASTER_IMPACT, org2, w_backoff * 1000, 1);
index fac16c48716422cdc800cb1e62cd3c999947ce13..7c4aabfe71e2b280e106bb4759cd893b81bf270d 100644 (file)
@@ -79,8 +79,8 @@ OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(Offhand
 
 spawnfunc(weapon_hook) { weapon_defaultspawnfunc(this, WEP_HOOK); }
 
-void W_Hook_ExplodeThink()
-{SELFPARAM();
+void W_Hook_ExplodeThink(entity this)
+{
        float dt, dmg_remaining_next, f;
 
        dt = time - self.teleport_time;
@@ -99,13 +99,13 @@ void W_Hook_ExplodeThink()
                remove(self);
 }
 
-void W_Hook_Explode2()
-{SELFPARAM();
+void W_Hook_Explode2(entity this)
+{
        self.event_damage = func_null;
-       self.touch = func_null;
+       settouch(self, func_null);
        self.effects |= EF_NODRAW;
 
-       self.think = W_Hook_ExplodeThink;
+       setthink(self, W_Hook_ExplodeThink);
        self.nextthink = time;
        self.dmg = WEP_CVAR_SEC(hook, damage);
        self.dmg_edge = WEP_CVAR_SEC(hook, edgedamage);
@@ -120,7 +120,7 @@ void W_Hook_Explode2()
 
 void W_Hook_Explode2_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Hook_Explode2());
+       WITHSELF(this, W_Hook_Explode2(this));
 }
 
 void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -137,9 +137,9 @@ void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage,
                W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2);
 }
 
-void W_Hook_Touch2()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Hook_Touch2(entity this)
+{
+       PROJECTILE_TOUCH(this);
        this.use(this, NULL, NULL);
 }
 
@@ -159,9 +159,9 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
        setsize(gren, '0 0 0', '0 0 0');
 
        gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime);
-       gren.think = adaptor_think2use_hittype_splash;
+       setthink(gren, adaptor_think2use_hittype_splash);
        gren.use = W_Hook_Explode2_use;
-       gren.touch = W_Hook_Touch2;
+       settouch(gren, W_Hook_Touch2);
 
        gren.takedamage = DAMAGE_YES;
        gren.health = WEP_CVAR_SEC(hook, health);
@@ -187,7 +187,6 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
 
 METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    SELFPARAM();
     if (fire & 1) {
         if(!actor.hook)
         if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
@@ -278,28 +277,27 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         actor.hook_state &= ~HOOK_REMOVING;
     }
 }
-METHOD(Hook, wr_setup, void(entity thiswep))
+METHOD(Hook, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
 }
-METHOD(Hook, wr_checkammo1, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor))
 {
-    SELFPARAM();
     if (!thiswep.ammo_factor) return true;
-    if(self.hook)
-        return self.ammo_fuel > 0;
+    if(actor.hook)
+        return actor.ammo_fuel > 0;
     else
-        return self.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
+        return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
 }
-METHOD(Hook, wr_checkammo2, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor))
 {
     // infinite ammo for now
-    return true; // self.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
+    return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
 }
-METHOD(Hook, wr_resetplayer, void(entity thiswep))
+METHOD(Hook, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     RemoveGrapplingHook(self);
     self.hook_time = 0;
     self.hook_refire = time;
@@ -312,9 +310,9 @@ METHOD(Hook, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Hook, wr_impacteffect, void(entity thiswep))
+METHOD(Hook, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 2;
     pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1);
@@ -496,73 +494,73 @@ void Remove_GrapplingHook(entity this)
 
 NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)
 {
-       self.HookType = NET_ENT_CLIENT_HOOK;
+       this.HookType = NET_ENT_CLIENT_HOOK;
 
        int sf = ReadByte();
 
-       self.HookSilent = (sf & 0x80);
-       self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
+       this.HookSilent = (sf & 0x80);
+       this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
 
-       InterpolateOrigin_Undo(self);
+       InterpolateOrigin_Undo(this);
 
        if(sf & 1)
        {
                int myowner = ReadByte();
-               self.owner = playerslots[myowner - 1];
-               self.sv_entnum = myowner;
+               this.owner = playerslots[myowner - 1];
+               this.sv_entnum = myowner;
                if(csqcplayer && myowner == player_localentnum)
-                       csqcplayer.hook = self;
-               switch(self.HookType)
+                       csqcplayer.hook = this;
+               switch(this.HookType)
                {
                        default:
                        case NET_ENT_CLIENT_HOOK:
-                               self.HookRange = 0;
+                               this.HookRange = 0;
                                break;
                        case NET_ENT_CLIENT_ARC_BEAM:
-                               self.HookRange = ReadCoord();
+                               this.HookRange = ReadCoord();
                                break;
                }
        }
        if(sf & 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(sf & 4)
        {
-               self.velocity_x = ReadCoord();
-               self.velocity_y = ReadCoord();
-               self.velocity_z = ReadCoord();
+               this.velocity_x = ReadCoord();
+               this.velocity_y = ReadCoord();
+               this.velocity_z = ReadCoord();
        }
 
        InterpolateOrigin_Note(this);
 
-       if(bIsNew || !self.teleport_time)
+       if(bIsNew || !this.teleport_time)
        {
-               self.draw = Draw_GrapplingHook;
-               self.entremove = Remove_GrapplingHook;
+               this.draw = Draw_GrapplingHook;
+               this.entremove = Remove_GrapplingHook;
 
-               switch(self.HookType)
+               switch(this.HookType)
                {
                        default:
                        case NET_ENT_CLIENT_HOOK:
                                // for the model
-                               setmodel(self, MDL_HOOK);
-                               self.drawmask = MASK_NORMAL;
+                               setmodel(this, MDL_HOOK);
+                               this.drawmask = MASK_NORMAL;
                                break;
                        case NET_ENT_CLIENT_ARC_BEAM:
-                               sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
+                               sound (this, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
                                break;
                }
        }
 
-       self.teleport_time = time + 10;
+       this.teleport_time = time + 10;
        return true;
 }
 
-// TODO: hook: temporarily transform self.origin for drawing the model along warpzones!
+// TODO: hook: temporarily transform this.origin for drawing the model along warpzones!
 #endif
 
 #endif
index 355eada3c7b9f6c31cddd8675dc745b9c4d669a6..10a8c40a181dbcaa5bdb95723e9efc56a778b2f6 100644 (file)
@@ -62,7 +62,7 @@ REGISTER_WEAPON(MACHINEGUN, machinegun, NEW(MachineGun));
 spawnfunc(weapon_machinegun)
 {
        if(autocvar_sv_q3acompat_machineshotgunswap)
-       if(self.classname != "droppedweapon")
+       if(this.classname != "droppedweapon")
        {
                weapon_defaultspawnfunc(this, WEP_SHOCKWAVE);
                return;
@@ -71,8 +71,8 @@ spawnfunc(weapon_machinegun)
 }
 spawnfunc(weapon_uzi) { spawnfunc_weapon_machinegun(this); }
 
-void W_MachineGun_MuzzleFlash_Think()
-{SELFPARAM();
+void W_MachineGun_MuzzleFlash_Think(entity this)
+{
        this.frame += 2;
        this.scale *= 0.5;
        this.alpha -= 0.25;
@@ -80,7 +80,7 @@ void W_MachineGun_MuzzleFlash_Think()
 
        if(this.alpha <= 0)
        {
-               this.think = SUB_Remove_self;
+               setthink(this, SUB_Remove);
                this.nextthink = time;
                this.realowner.muzzle_flash = world;
                return;
@@ -88,8 +88,8 @@ void W_MachineGun_MuzzleFlash_Think()
 
 }
 
-void W_MachineGun_MuzzleFlash()
-{SELFPARAM();
+void W_MachineGun_MuzzleFlash(entity actor)
+{entity this = actor;
        if(self.muzzle_flash == world)
                self.muzzle_flash = spawn();
 
@@ -97,7 +97,7 @@ void W_MachineGun_MuzzleFlash()
        setmodel(self.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below
 
        self.muzzle_flash.scale = 0.75;
-       self.muzzle_flash.think = W_MachineGun_MuzzleFlash_Think;
+       setthink(self.muzzle_flash, W_MachineGun_MuzzleFlash_Think);
        self.muzzle_flash.nextthink = time + 0.02;
        self.muzzle_flash.frame = 2;
        self.muzzle_flash.alpha = 0.75;
@@ -106,8 +106,8 @@ void W_MachineGun_MuzzleFlash()
        self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
 }
 
-void W_MachineGun_Attack(Weapon thiswep, int deathtype, .entity weaponentity)
-{SELFPARAM();
+void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity)
+{entity this = actor;
        W_SetupShot(self, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
        if(!autocvar_g_norecoil)
        {
@@ -125,7 +125,7 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, .entity weaponentity)
 
        Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       W_MachineGun_MuzzleFlash();
+       W_MachineGun_MuzzleFlash(self);
        W_AttachToShotorg(self, self.muzzle_flash, '5 0 0');
 
        // casing code
@@ -148,7 +148,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit
        }
        if(PHYS_INPUT_BUTTON_ATCK(actor))
        {
-               if(!thiswep.wr_checkammo2(thiswep))
+               if(!thiswep.wr_checkammo2(thiswep, actor))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -156,7 +156,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit
                        return;
                }
                actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
-               W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity);
+               W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity);
                weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
        }
        else
@@ -174,7 +174,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
                return;
        }
 
-       if(!thiswep.wr_checkammo1(thiswep))
+       if(!thiswep.wr_checkammo1(thiswep, actor))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -198,7 +198,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
 
        Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       W_MachineGun_MuzzleFlash();
+       W_MachineGun_MuzzleFlash(actor);
        W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
 
        if(autocvar_g_casings >= 2) // casing code
@@ -222,7 +222,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
        Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
-       W_MachineGun_MuzzleFlash();
+       W_MachineGun_MuzzleFlash(actor);
        W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0');
 
        if(autocvar_g_casings >= 2) // casing code
@@ -242,9 +242,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
 }
 
-METHOD(MachineGun, wr_aim, void(entity thiswep))
+METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(vdist(self.origin - self.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 0.001, false);
     else
@@ -267,7 +267,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
         if(fire & 2)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
         {
-            if(!thiswep.wr_checkammo2(thiswep))
+            if(!thiswep.wr_checkammo2(thiswep, actor))
             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
             {
                 W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -288,7 +288,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
         {
             actor.misc_bulletcounter = 1;
-            W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, weaponentity); // sets attack_finished
+            W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity); // sets attack_finished
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
         }
 
@@ -296,51 +296,48 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
         {
             actor.misc_bulletcounter = 1;
-            W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, weaponentity); // sets attack_finished
+            W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
         }
     }
 }
-METHOD(MachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float ammo_amount;
     if(WEP_CVAR(machinegun, mode) == 1)
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
     else
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
 
     if(WEP_CVAR(machinegun, reload_ammo))
     {
         if(WEP_CVAR(machinegun, mode) == 1)
-            ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
+            ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
         else
-            ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+            ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
     }
     return ammo_amount;
 }
-METHOD(MachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float ammo_amount;
     if(WEP_CVAR(machinegun, mode) == 1)
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
     else
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
 
     if(WEP_CVAR(machinegun, reload_ammo))
     {
         if(WEP_CVAR(machinegun, mode) == 1)
-            ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
+            ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
         else
-            ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+            ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
     }
     return ammo_amount;
 }
 METHOD(MachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD);
+    W_Reload(actor, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND_RELOAD);
 }
 METHOD(MachineGun, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -357,9 +354,9 @@ METHOD(MachineGun, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(MachineGun, wr_impacteffect, void(entity thiswep))
+METHOD(MachineGun, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 2;
     pointparticles(EFFECT_MACHINEGUN_IMPACT, org2, w_backoff * 1000, 1);
index 96d7555cda63b4cbf4f4ea540ca6504c4f6a5db6..bc7f8eb39efbe6be32be3d9cb757bf355af3c402 100644 (file)
@@ -53,7 +53,7 @@ ENDCLASS(MineLayer)
 REGISTER_WEAPON(MINE_LAYER, minelayer, NEW(MineLayer));
 
 #ifdef SVQC
-void W_MineLayer_Think();
+void W_MineLayer_Think(entity this);
 .float minelayer_detonate, mine_explodeanyway;
 .float mine_time;
 .vector mine_orientation;
@@ -63,8 +63,8 @@ void W_MineLayer_Think();
 #ifdef SVQC
 spawnfunc(weapon_minelayer) { weapon_defaultspawnfunc(this, WEP_MINE_LAYER); }
 
-void W_MineLayer_Stick(entity to)
-{SELFPARAM();
+void W_MineLayer_Stick(entity this, entity to)
+{
        spamsound(self, CH_SHOTS, SND(MINE_STICK), VOL_BASE, ATTN_NORM);
 
        // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
@@ -96,21 +96,20 @@ void W_MineLayer_Stick(entity to)
 
        newmine.mine_time = self.mine_time;
 
-       newmine.touch = func_null;
-       newmine.think = W_MineLayer_Think;
+       settouch(newmine, func_null);
+       setthink(newmine, W_MineLayer_Think);
        newmine.nextthink = time;
        newmine.cnt = self.cnt;
        newmine.flags = self.flags;
 
        remove(self);
-       setself(newmine);
 
        if(to)
-               SetMovetypeFollow(self, to);
+               SetMovetypeFollow(newmine, to);
 }
 
-void W_MineLayer_Explode()
-{SELFPARAM();
+void W_MineLayer_Explode(entity this)
+{
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -125,23 +124,22 @@ void W_MineLayer_Explode()
 
        if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
        {
-               setself(self.realowner);
+               entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w))
+               if(!w.wr_checkammo1(w, own))
                {
-                       self.cnt = WEP_MINE_LAYER.m_id;
+                       own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = 0; // TODO: unhardcode
-                       ATTACK_FINISHED(self, slot) = time;
-                       PS(self).m_switchweapon = w_getbestweapon(self);
+                       ATTACK_FINISHED(own, slot) = time;
+                       PS(own).m_switchweapon = w_getbestweapon(own);
                }
-               setself(this);
        }
        self.realowner.minelayer_mines -= 1;
        remove(self);
 }
 
-void W_MineLayer_DoRemoteExplode()
-{SELFPARAM();
+void W_MineLayer_DoRemoteExplode(entity this)
+{
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
 
@@ -152,35 +150,34 @@ void W_MineLayer_DoRemoteExplode()
 
        if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
        {
-               setself(self.realowner);
+               entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w))
+               if(!w.wr_checkammo1(w, own))
                {
-                       self.cnt = WEP_MINE_LAYER.m_id;
+                       own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = 0; // TODO: unhardcode
-                       ATTACK_FINISHED(self, slot) = time;
-                       PS(self).m_switchweapon = w_getbestweapon(self);
+                       ATTACK_FINISHED(own, slot) = time;
+                       PS(own).m_switchweapon = w_getbestweapon(own);
                }
-               setself(this);
        }
-       self.realowner.minelayer_mines -= 1;
+       this.realowner.minelayer_mines -= 1;
        remove(self);
 }
 
-void W_MineLayer_RemoteExplode()
-{SELFPARAM();
+void W_MineLayer_RemoteExplode(entity this)
+{
        if(!IS_DEAD(self.realowner))
                if((self.spawnshieldtime >= 0)
                        ? (time >= self.spawnshieldtime) // timer
                        : (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(minelayer, remote_radius))) // safety device
                )
                {
-                       W_MineLayer_DoRemoteExplode();
+                       W_MineLayer_DoRemoteExplode(self);
                }
 }
 
-void W_MineLayer_ProximityExplode()
-{SELFPARAM();
+void W_MineLayer_ProximityExplode(entity this)
+{
        // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
        if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
        {
@@ -195,7 +192,7 @@ void W_MineLayer_ProximityExplode()
        }
 
        self.mine_time = 0;
-       W_MineLayer_Explode();
+       W_MineLayer_Explode(self);
 }
 
 int W_MineLayer_Count(entity e)
@@ -208,8 +205,8 @@ int W_MineLayer_Count(entity e)
        return minecount;
 }
 
-void W_MineLayer_Think()
-{SELFPARAM();
+void W_MineLayer_Think(entity this)
+{
        entity head;
 
        self.nextthink = time;
@@ -239,7 +236,7 @@ void W_MineLayer_Think()
        {
                other = world;
                self.projectiledeathtype |= HITTYPE_BOUNCE;
-               W_MineLayer_Explode();
+               W_MineLayer_Explode(self);
                return;
        }
 
@@ -260,7 +257,7 @@ void W_MineLayer_Think()
        // explode if it's time to
        if(self.mine_time && time >= self.mine_time)
        {
-               W_MineLayer_ProximityExplode();
+               W_MineLayer_ProximityExplode(self);
                return;
        }
 
@@ -268,15 +265,15 @@ void W_MineLayer_Think()
        if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
        if(!IS_DEAD(self.realowner))
        if(self.minelayer_detonate)
-               W_MineLayer_RemoteExplode();
+               W_MineLayer_RemoteExplode(self);
 }
 
-void W_MineLayer_Touch()
-{SELFPARAM();
+void W_MineLayer_Touch(entity this)
+{
        if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
                return; // we're already a stuck mine, why do we get called? TODO does this even happen?
 
-       if(WarpZone_Projectile_Touch())
+       if(WarpZone_Projectile_Touch(self))
        {
                if(wasfreed(self))
                        self.realowner.minelayer_mines -= 1;
@@ -290,7 +287,7 @@ void W_MineLayer_Touch()
        }
        else
        {
-               W_MineLayer_Stick(other);
+               W_MineLayer_Stick(self, other);
        }
 }
 
@@ -311,8 +308,8 @@ void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float da
                W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode);
 }
 
-void W_MineLayer_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_MineLayer_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        entity mine;
        entity flash;
 
@@ -358,8 +355,8 @@ void W_MineLayer_Attack(Weapon thiswep)
        W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0);
        mine.angles = vectoangles(mine.velocity);
 
-       mine.touch = W_MineLayer_Touch;
-       mine.think = W_MineLayer_Think;
+       settouch(mine, W_MineLayer_Touch);
+       setthink(mine, W_MineLayer_Think);
        mine.nextthink = time;
        mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
        mine.flags = FL_PROJECTILE;
@@ -383,12 +380,12 @@ void W_MineLayer_Attack(Weapon thiswep)
        self.minelayer_mines = W_MineLayer_Count(self);
 }
 
-float W_MineLayer_PlacedMines(float detonate)
-{SELFPARAM();
+float W_MineLayer_PlacedMines(entity this, float detonate)
+{
        entity mine;
        float minfound = 0;
 
-       for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self)
+       for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == this)
        {
                if(detonate)
                {
@@ -404,9 +401,9 @@ float W_MineLayer_PlacedMines(float detonate)
        return minfound;
 }
 
-METHOD(MineLayer, wr_aim, void(entity thiswep))
+METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     // aim and decide to fire if appropriate
     if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
         PHYS_INPUT_BUTTON_ATCK(self) = false;
@@ -508,7 +505,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
     {
         // not if we're holding the minelayer without enough ammo, but can detonate existing mines
-        if(!(W_MineLayer_PlacedMines(false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
+        if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
             thiswep.wr_reload(thiswep, actor, weaponentity);
         }
     }
@@ -516,46 +513,43 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire)))
         {
-            W_MineLayer_Attack(thiswep);
+            W_MineLayer_Attack(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
         }
     }
 
     if(fire & 2)
     {
-        if(W_MineLayer_PlacedMines(true))
+        if(W_MineLayer_PlacedMines(actor, true))
             sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
     }
 }
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     //int slot = 0; // TODO: unhardcode
     // actually do // don't switch while placing a mine
-    //if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_MINE_LAYER)
+    //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
     //{
-        float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
-        ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
+        float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
+        ammo_amount += actor.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
         return ammo_amount;
     //}
     //return true;
 }
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    if(W_MineLayer_PlacedMines(false))
+    if(W_MineLayer_PlacedMines(actor, false))
         return true;
     else
         return false;
 }
-METHOD(MineLayer, wr_resetplayers, void(entity thiswep))
+METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    self.minelayer_mines = 0;
+    actor.minelayer_mines = 0;
 }
 METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, WEP_CVAR(minelayer, ammo), SND_RELOAD);
+    W_Reload(actor, WEP_CVAR(minelayer, ammo), SND_RELOAD);
 }
 METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -569,9 +563,9 @@ METHOD(MineLayer, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(MineLayer, wr_impacteffect, void(entity thiswep))
+METHOD(MineLayer, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 12;
     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
index 5fbacc7ba4b958cffef6f406d7b1ce53d76853d9..843eaa86bca170f6a9de49ba011c52cc05b792f4 100644 (file)
@@ -64,8 +64,8 @@ REGISTER_WEAPON(MORTAR, mortar, NEW(Mortar));
 spawnfunc(weapon_mortar) { weapon_defaultspawnfunc(this, WEP_MORTAR); }
 spawnfunc(weapon_grenadelauncher) { spawnfunc_weapon_mortar(this); }
 
-void W_Mortar_Grenade_Explode()
-{SELFPARAM();
+void W_Mortar_Grenade_Explode(entity this)
+{
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -86,11 +86,11 @@ void W_Mortar_Grenade_Explode()
 
 void W_Mortar_Grenade_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Mortar_Grenade_Explode());
+       WITHSELF(this, W_Mortar_Grenade_Explode(this));
 }
 
-void W_Mortar_Grenade_Explode2()
-{SELFPARAM();
+void W_Mortar_Grenade_Explode2(entity this)
+{
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -111,7 +111,7 @@ void W_Mortar_Grenade_Explode2()
 
 void W_Mortar_Grenade_Explode2_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Mortar_Grenade_Explode2());
+       WITHSELF(this, W_Mortar_Grenade_Explode2(this));
 }
 
 void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -128,23 +128,23 @@ void W_Mortar_Grenade_Damage(entity this, entity inflictor, entity attacker, flo
                W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
 }
 
-void W_Mortar_Grenade_Think1()
-{SELFPARAM();
+void W_Mortar_Grenade_Think1(entity this)
+{
        self.nextthink = time;
        if(time > self.cnt)
        {
                other = world;
                self.projectiledeathtype |= HITTYPE_BOUNCE;
-               W_Mortar_Grenade_Explode();
+               W_Mortar_Grenade_Explode(self);
                return;
        }
        if(self.gl_detonate_later && self.gl_bouncecnt >= WEP_CVAR_PRI(mortar, remote_minbouncecnt))
-               W_Mortar_Grenade_Explode();
+               W_Mortar_Grenade_Explode(self);
 }
 
-void W_Mortar_Grenade_Touch1()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Mortar_Grenade_Touch1(entity this)
+{
+       PROJECTILE_TOUCH(this);
        if(other.takedamage == DAMAGE_AIM || WEP_CVAR_PRI(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
        {
                this.use(this, NULL, NULL);
@@ -174,9 +174,9 @@ void W_Mortar_Grenade_Touch1()
        }
 }
 
-void W_Mortar_Grenade_Touch2()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_Mortar_Grenade_Touch2(entity this)
+{
+       PROJECTILE_TOUCH(this);
        if(other.takedamage == DAMAGE_AIM || WEP_CVAR_SEC(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
        {
                this.use(this, NULL, NULL);
@@ -210,8 +210,8 @@ void W_Mortar_Grenade_Touch2()
        }
 }
 
-void W_Mortar_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Mortar_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        entity gren;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(mortar, ammo));
@@ -235,9 +235,9 @@ void W_Mortar_Attack(Weapon thiswep)
 
        gren.cnt = time + WEP_CVAR_PRI(mortar, lifetime);
        gren.nextthink = time;
-       gren.think = W_Mortar_Grenade_Think1;
+       setthink(gren, W_Mortar_Grenade_Think1);
        gren.use = W_Mortar_Grenade_Explode_use;
-       gren.touch = W_Mortar_Grenade_Touch1;
+       settouch(gren, W_Mortar_Grenade_Touch1);
 
        gren.takedamage = DAMAGE_YES;
        gren.health = WEP_CVAR_PRI(mortar, health);
@@ -258,8 +258,8 @@ void W_Mortar_Attack(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, gren);
 }
 
-void W_Mortar_Attack2(Weapon thiswep)
-{SELFPARAM();
+void W_Mortar_Attack2(Weapon thiswep, entity actor)
+{entity this = actor;
        entity gren;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(mortar, ammo));
@@ -282,9 +282,9 @@ void W_Mortar_Attack2(Weapon thiswep)
        setsize(gren, '-3 -3 -3', '3 3 3');
 
        gren.nextthink = time + WEP_CVAR_SEC(mortar, lifetime);
-       gren.think = adaptor_think2use_hittype_splash;
+       setthink(gren, adaptor_think2use_hittype_splash);
        gren.use = W_Mortar_Grenade_Explode2_use;
-       gren.touch = W_Mortar_Grenade_Touch2;
+       settouch(gren, W_Mortar_Grenade_Touch2);
 
        gren.takedamage = DAMAGE_YES;
        gren.health = WEP_CVAR_SEC(mortar, health);
@@ -307,9 +307,9 @@ void W_Mortar_Attack2(Weapon thiswep)
 
 .float bot_secondary_grenademooth;
 
-METHOD(Mortar, wr_aim, void(entity thiswep))
+METHOD(Mortar, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = false;
     PHYS_INPUT_BUTTON_ATCK2(self) = false;
     if(self.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH
@@ -353,7 +353,7 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(mortar, refire)))
         {
-            W_Mortar_Attack(thiswep);
+            W_Mortar_Attack(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
         }
     }
@@ -376,29 +376,26 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         }
         else if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(mortar, refire)))
         {
-            W_Mortar_Attack2(thiswep);
+            W_Mortar_Attack2(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
         }
     }
 }
-METHOD(Mortar, wr_checkammo1, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
-    ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
+    ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
     return ammo_amount;
 }
-METHOD(Mortar, wr_checkammo2, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
-    ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
+    ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
     return ammo_amount;
 }
 METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO
+    W_Reload(actor, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND_RELOAD); // WEAPONTODO
 }
 METHOD(Mortar, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -418,9 +415,9 @@ METHOD(Mortar, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Mortar, wr_impacteffect, void(entity thiswep))
+METHOD(Mortar, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 12;
     pointparticles(EFFECT_GRENADE_EXPLODE, org2, '0 0 0', 1);
index b9488889ddf69c81d639e522905c6906d8685c3f..ac9f759fc75954fd3988ae334ffeafcb03775f2c 100644 (file)
@@ -53,8 +53,8 @@ MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) {
        FOREACH_CLIENT(IS_PLAYER(it), it.porto_forbidden = max(0, it.porto_forbidden - 1));
 }
 
-void W_Porto_Success()
-{SELFPARAM();
+void W_Porto_Success(entity this)
+{
        if(self.realowner == world)
        {
                objerror("Cannot succeed successfully: no owner\n");
@@ -66,60 +66,60 @@ void W_Porto_Success()
 }
 
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
-void W_Porto_Fail(float failhard)
-{SELFPARAM();
-       if(self.realowner == world)
+void W_Porto_Fail(entity this, float failhard)
+{
+       if(this.realowner == world)
        {
                objerror("Cannot fail successfully: no owner\n");
                return;
        }
 
        // no portals here!
-       if(self.cnt < 0)
+       if(this.cnt < 0)
        {
-               Portal_ClearWithID(self.realowner, self.portal_id);
+               Portal_ClearWithID(this.realowner, this.portal_id);
        }
 
-       self.realowner.porto_current = world;
+       this.realowner.porto_current = world;
 
-       if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && !IS_DEAD(self.realowner) && !(self.realowner.weapons & WEPSET(PORTO)))
+       if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(this.realowner.weapons & WEPSET(PORTO)))
        {
-               setsize(self, '-16 -16 0', '16 16 32');
-               setorigin(self, self.origin + trace_plane_normal);
-               if(move_out_of_solid(self))
+               setsize(this, '-16 -16 0', '16 16 32');
+               setorigin(this, this.origin + trace_plane_normal);
+               if(move_out_of_solid(this))
                {
-                       self.flags = FL_ITEM;
-                       self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128);
-                       tracetoss(self, self);
-                       if(vdist(trace_endpos - self.realowner.origin, <, 128))
+                       this.flags = FL_ITEM;
+                       this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128);
+                       tracetoss(this, this);
+                       if(vdist(trace_endpos - this.realowner.origin, <, 128))
                        {
-                               W_ThrowNewWeapon(self.realowner, WEP_PORTO.m_id, 0, self.origin, self.velocity);
-                               Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
+                               W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity);
+                               Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
                        }
                }
        }
-       remove(self);
+       remove(this);
 }
 
 void W_Porto_Remove(entity p)
-{SELFPARAM();
+{
        if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
        {
-               WITHSELF(p.porto_current, W_Porto_Fail(1));
+               WITHSELF(p.porto_current, W_Porto_Fail(p.porto_current, 1));
        }
 }
 
-void W_Porto_Think()
-{SELFPARAM();
+void W_Porto_Think(entity this)
+{
        trace_plane_normal = '0 0 0';
        if(self.realowner.playerid != self.playerid)
                remove(self);
        else
-               W_Porto_Fail(0);
+               W_Porto_Fail(self, 0);
 }
 
-void W_Porto_Touch()
-{SELFPARAM();
+void W_Porto_Touch(entity this)
+{
        vector norm;
 
        // do not use PROJECTILE_TOUCH here
@@ -155,7 +155,7 @@ void W_Porto_Touch()
        else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
        {
                sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
-               W_Porto_Fail(0);
+               W_Porto_Fail(self, 0);
                if(self.cnt < 0)
                        Portal_ClearAll_PortalsOnly(self.realowner);
        }
@@ -167,13 +167,13 @@ void W_Porto_Touch()
                        sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
                        trace_plane_normal = norm;
                        Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN);
-                       W_Porto_Success();
+                       W_Porto_Success(self);
                }
                else
                {
                        sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
                        trace_plane_normal = norm;
-                       W_Porto_Fail(0);
+                       W_Porto_Fail(self, 0);
                }
        }
        else if(self.cnt == 1)
@@ -184,13 +184,13 @@ void W_Porto_Touch()
                        sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
                        trace_plane_normal = norm;
                        Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
-                       W_Porto_Success();
+                       W_Porto_Success(self);
                }
                else
                {
                        sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
                        trace_plane_normal = norm;
-                       W_Porto_Fail(0);
+                       W_Porto_Fail(self, 0);
                }
        }
        else if(self.effects & EF_RED)
@@ -210,7 +210,7 @@ void W_Porto_Touch()
                        sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
                        trace_plane_normal = norm;
                        Portal_ClearAll_PortalsOnly(self.realowner);
-                       W_Porto_Fail(0);
+                       W_Porto_Fail(self, 0);
                }
        }
        else
@@ -222,26 +222,26 @@ void W_Porto_Touch()
                                sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM);
                                trace_plane_normal = norm;
                                Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT);
-                               W_Porto_Success();
+                               W_Porto_Success(self);
                        }
                        else
                        {
                                sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
                                Portal_ClearAll_PortalsOnly(self.realowner);
-                               W_Porto_Fail(0);
+                               W_Porto_Fail(self, 0);
                        }
                }
                else
                {
                        sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM);
                        Portal_ClearAll_PortalsOnly(self.realowner);
-                       W_Porto_Fail(0);
+                       W_Porto_Fail(self, 0);
                }
        }
 }
 
-void W_Porto_Attack(float type)
-{SELFPARAM();
+void W_Porto_Attack(entity actor, float type)
+{entity this = actor;
        entity gren;
 
        W_SetupShot(self, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0);
@@ -265,8 +265,8 @@ void W_Porto_Attack(float type)
        setsize(gren, '0 0 0', '0 0 0');
 
        gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime);
-       gren.think = W_Porto_Think;
-       gren.touch = W_Porto_Touch;
+       setthink(gren, W_Porto_Think);
+       settouch(gren, W_Porto_Touch);
 
        if(self.items & ITEM_Strength.m_itemid)
                W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed) * autocvar_g_balance_powerup_strength_force, 0);
@@ -292,9 +292,9 @@ void W_Porto_Attack(float type)
        MUTATOR_CALLHOOK(EditProjectile, self, gren);
 }
 
-METHOD(PortoLaunch, wr_aim, void(entity thiswep))
+METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = false;
     PHYS_INPUT_BUTTON_ATCK2(self) = false;
     if(!WEP_CVAR(porto, secondary))
@@ -310,7 +310,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone
         if(!actor.porto_forbidden)
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
         {
-            W_Porto_Attack(0);
+            W_Porto_Attack(actor, 0);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
         }
 
@@ -319,7 +319,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone
         if(!actor.porto_forbidden)
         if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire)))
         {
-            W_Porto_Attack(1);
+            W_Porto_Attack(actor, 1);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
         }
     }
@@ -352,34 +352,34 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone
         if(!actor.porto_forbidden)
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
         {
-            W_Porto_Attack(-1);
+            W_Porto_Attack(actor, -1);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
         }
     }
 }
-METHOD(PortoLaunch, wr_checkammo1, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this))
 {
     // always allow infinite ammo
     return true;
 }
-METHOD(PortoLaunch, wr_checkammo2, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this))
 {
     // always allow infinite ammo
     return true;
 }
-METHOD(PortoLaunch, wr_setup, void(entity thiswep))
+METHOD(PortoLaunch, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.ammo_field = ammo_none;
 }
-METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep))
+METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.porto_current = world;
 }
 #endif
 #ifdef CSQC
-METHOD(PortoLaunch, wr_impacteffect, void(entity this)) {
+METHOD(PortoLaunch, wr_impacteffect, void(entity this, entity actor)) {
     LOG_WARNING("Since when does Porto send DamageInfo?\n");
 }
 #endif
index 606770579880aa4f177ec878bc8c30ace0eb53c7..7381172aacf48bdfd0bf19e95638bf08280ab0ac 100644 (file)
@@ -56,8 +56,8 @@ spawnfunc(weapon_rifle) { weapon_defaultspawnfunc(this, WEP_RIFLE); }
 spawnfunc(weapon_campingrifle) { spawnfunc_weapon_rifle(this); }
 spawnfunc(weapon_sniperrifle) { spawnfunc_weapon_rifle(this); }
 
-void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound)
-{SELFPARAM();
+void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor)
+{entity this = actor;
        float i;
 
        W_DecreaseAmmo(thiswep, self, pAmmo);
@@ -79,17 +79,17 @@ void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pFor
                SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
 }
 
-void W_Rifle_Attack()
+void W_Rifle_Attack(entity actor)
 {
-       W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE);
+       W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor);
 }
 
-void W_Rifle_Attack2()
+void W_Rifle_Attack2(entity actor)
 {
-       W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2);
+       W_Rifle_FireBullet(WEP_RIFLE, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor);
 }
 
-.void() rifle_bullethail_attackfunc;
+.void(entity actor) rifle_bullethail_attackfunc;
 .WFRAME rifle_bullethail_frame;
 .float rifle_bullethail_animtime;
 .float rifle_bullethail_refire;
@@ -107,7 +107,7 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent
                PS(actor).m_switchweapon = sw;
        if(r)
        {
-               actor.rifle_bullethail_attackfunc();
+               actor.rifle_bullethail_attackfunc(actor);
                weapon_thinkf(actor, weaponentity, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue);
        }
        else
@@ -116,10 +116,10 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, .entity weaponent
        }
 }
 
-void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFRAME fr, float animtime, float refire)
-{SELFPARAM();
+void W_Rifle_BulletHail(entity actor, .entity weaponentity, float mode, void(entity actor) AttackFunc, WFRAME fr, float animtime, float refire)
+{entity this = actor;
        // if we get here, we have at least one bullet to fire
-       AttackFunc();
+       AttackFunc(actor);
        if(mode)
        {
                // continue hail
@@ -138,9 +138,9 @@ void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFR
 
 .float bot_secondary_riflemooth;
 
-METHOD(Rifle, wr_aim, void(entity thiswep))
+METHOD(Rifle, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     PHYS_INPUT_BUTTON_ATCK(self) = false;
     PHYS_INPUT_BUTTON_ATCK2(self) = false;
     if(vdist(self.origin - self.enemy.origin, >, 1000))
@@ -174,7 +174,7 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
         {
             weapon_prepareattack_do(actor, weaponentity, false, WEP_CVAR_PRI(rifle, refire));
-            W_Rifle_BulletHail(weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+            W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
             actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
         }
         if(fire & 2)
@@ -189,7 +189,7 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
                     if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
                     {
                         weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(rifle, refire));
-                        W_Rifle_BulletHail(weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+                        W_Rifle_BulletHail(actor, weaponentity, WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
                         actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
                     }
                 }
@@ -197,29 +197,26 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         }
     }
 }
-METHOD(Rifle, wr_checkammo1, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
-    ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
+    ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
     return ammo_amount;
 }
-METHOD(Rifle, wr_checkammo2, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
-    ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
+    ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
     return ammo_amount;
 }
-METHOD(Rifle, wr_resetplayer, void(entity thiswep))
+METHOD(Rifle, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.rifle_accumulator = time - WEP_CVAR(rifle, bursttime);
 }
 METHOD(Rifle, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND_RELOAD);
 }
 METHOD(Rifle, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -246,9 +243,9 @@ METHOD(Rifle, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Rifle, wr_impacteffect, void(entity thiswep))
+METHOD(Rifle, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 2;
     pointparticles(EFFECT_RIFLE_IMPACT, org2, w_backoff * 1000, 1);
index 6dffec39d3378eddba5453c46bc45e171cc4bb50..0852555510eba9eef9b71b98dd546fffad1314cd 100644 (file)
@@ -94,23 +94,23 @@ spawnfunc(weapon_seeker) { weapon_defaultspawnfunc(this, WEP_SEEKER); }
 // ============================
 // Begin: Missile functions, these are general functions to be manipulated by other code
 // ============================
-void W_Seeker_Missile_Explode()
-{SELFPARAM();
+void W_Seeker_Missile_Explode(entity this)
+{
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), world, world, WEP_CVAR(seeker, missile_force), self.projectiledeathtype, other);
 
        remove(self);
 }
 
-void W_Seeker_Missile_Touch()
+void W_Seeker_Missile_Touch(entity this)
 {
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
-       W_Seeker_Missile_Explode();
+       W_Seeker_Missile_Explode(this);
 }
 
-void W_Seeker_Missile_Think()
-{SELFPARAM();
+void W_Seeker_Missile_Think(entity this)
+{
        entity e;
        vector desireddir, olddir, newdir, eorg;
        float turnrate;
@@ -120,7 +120,7 @@ void W_Seeker_Missile_Think()
        if(time > self.cnt)
        {
                self.projectiledeathtype |= HITTYPE_SPLASH;
-               W_Seeker_Missile_Explode();
+               W_Seeker_Missile_Explode(self);
        }
 
        spd = vlen(self.velocity);
@@ -178,7 +178,7 @@ void W_Seeker_Missile_Think()
                        {
                                if(self.autoswitch <= time)
                                {
-                                       W_Seeker_Missile_Explode();
+                                       W_Seeker_Missile_Explode(self);
                                        self.autoswitch = 0;
                                }
                        }
@@ -248,8 +248,8 @@ void W_Seeker_Missile_Animate()
 }
 */
 
-void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target)
-{SELFPARAM();
+void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, vector f_diff, entity m_target)
+{entity this = actor;
        entity missile;
 
        W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, missile_ammo));
@@ -266,8 +266,8 @@ void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target)
        missile.bot_dodge       = true;
        missile.bot_dodgerating = WEP_CVAR(seeker, missile_damage);
 
-       missile.think           = W_Seeker_Missile_Think;
-       missile.touch           = W_Seeker_Missile_Touch;
+       setthink(missile, W_Seeker_Missile_Think);
+       settouch(missile, W_Seeker_Missile_Touch);
        missile.event_damage    = W_Seeker_Missile_Damage;
        missile.nextthink       = time;// + 0.2;// + cvar("g_balance_seeker_missile_activate_delay");
        missile.cnt             = time + WEP_CVAR(seeker, missile_lifetime);
@@ -304,8 +304,8 @@ void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target)
 // ============================
 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
 // ============================
-void W_Seeker_Flac_Explode()
-{SELFPARAM();
+void W_Seeker_Flac_Explode(entity this)
+{
        self.event_damage = func_null;
 
        RadiusDamage(self, self.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), world, world, WEP_CVAR(seeker, flac_force), self.projectiledeathtype, other);
@@ -315,18 +315,11 @@ void W_Seeker_Flac_Explode()
 
 void W_Seeker_Flac_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_Seeker_Flac_Explode());
-}
-
-void W_Seeker_Flac_Touch()
-{
-       PROJECTILE_TOUCH;
-
-       W_Seeker_Flac_Explode();
+       WITHSELF(this, W_Seeker_Flac_Explode(this));
 }
 
-void W_Seeker_Fire_Flac(Weapon thiswep)
-{SELFPARAM();
+void W_Seeker_Fire_Flac(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
        vector f_diff;
        float c;
@@ -359,9 +352,9 @@ void W_Seeker_Fire_Flac(Weapon thiswep)
        missile.owner                   = missile.realowner = self;
        missile.bot_dodge               = true;
        missile.bot_dodgerating = WEP_CVAR(seeker, flac_damage);
-       missile.touch                   = W_Seeker_Flac_Explode;
+       settouch(missile, W_Seeker_Flac_Explode);
        missile.use                     = W_Seeker_Flac_Explode_use;
-       missile.think                   = adaptor_think2use_hittype_splash;
+       setthink(missile, adaptor_think2use_hittype_splash);
        missile.nextthink               = time + WEP_CVAR(seeker, flac_lifetime) + WEP_CVAR(seeker, flac_lifetime_rand);
        missile.solid                   = SOLID_BBOX;
        missile.movetype                = MOVETYPE_FLY;
@@ -396,8 +389,8 @@ entity W_Seeker_Tagged_Info(entity isowner, entity istarget)
        return world;
 }
 
-void W_Seeker_Attack()
-{SELFPARAM();
+void W_Seeker_Attack(entity actor)
+{entity this = actor;
        entity tracker, closest_target;
 
        closest_target = world;
@@ -416,53 +409,52 @@ void W_Seeker_Attack()
        if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
                closest_target = world;
 
-       W_Seeker_Fire_Missile(WEP_SEEKER, '0 0 0', closest_target);
+       W_Seeker_Fire_Missile(WEP_SEEKER, actor, '0 0 0', closest_target);
 }
 
-void W_Seeker_Vollycontroller_Think() // TODO: Merge this with W_Seeker_Attack
-{SELFPARAM();
+void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seeker_Attack
+{
        float c;
        entity oldenemy;
-       self.cnt = self.cnt - 1;
+       this.cnt = this.cnt - 1;
 
        Weapon thiswep = WEP_SEEKER;
-       if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (IS_DEAD(self.realowner)) || (PS(self.realowner).m_switchweapon != WEP_SEEKER))
+       if((!(this.realowner.items & IT_UNLIMITED_AMMO) && this.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (PS(this.realowner).m_switchweapon != WEP_SEEKER))
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       self.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
+       this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
 
-       setself(self.realowner);
+       entity own = this.realowner;
 
-       oldenemy = self.enemy;
-       self.enemy = this.enemy;
+       oldenemy = own.enemy;
+       own.enemy = this.enemy;
 
-       c = self.cnt % 4;
+       c = own.cnt % 4;
        switch(c)
        {
                case 0:
-                       W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 -3.75 0', self.enemy);
+                       WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 -3.75 0', own.enemy));
                        break;
                case 1:
-                       W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 -3.75 0', self.enemy);
+                       WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 -3.75 0', own.enemy));
                        break;
                case 2:
-                       W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 +3.75 0', self.enemy);
+                       WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '-1.25 +3.75 0', own.enemy));
                        break;
                case 3:
                default:
-                       W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 +3.75 0', self.enemy);
+                       WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, own, '+1.25 +3.75 0', own.enemy));
                        break;
        }
 
-       self.enemy = oldenemy;
-       setself(this);
+       own.enemy = oldenemy;
 }
 
-void W_Seeker_Tracker_Think()
-{SELFPARAM();
+void W_Seeker_Tracker_Think(entity this)
+{
        // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
        if((IS_DEAD(self.realowner)) || (IS_DEAD(self.tag_target)) || (PS(self.realowner).m_switchweapon != WEP_SEEKER)
        || (time > self.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime)))
@@ -500,13 +492,13 @@ void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float d
                W_Seeker_Tag_Explode(this);
 }
 
-void W_Seeker_Tag_Touch()
-{SELFPARAM();
+void W_Seeker_Tag_Touch(entity this)
+{
        vector dir;
        vector org2;
        entity e;
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        dir     = normalize(self.realowner.origin - self.origin);
        org2    = findbetterlocation(self.origin, 8);
@@ -540,12 +532,12 @@ void W_Seeker_Tag_Touch()
                        {
                                e.tag_target  = other;
                                e.tag_time    = time;
-                               e.think       = W_Seeker_Tracker_Think;
+                               setthink(e, W_Seeker_Tracker_Think);
                        }
                        else
                        {
                                e.enemy     = other;
-                               e.think     = W_Seeker_Vollycontroller_Think;
+                               setthink(e, W_Seeker_Vollycontroller_Think);
                        }
 
                        e.nextthink   = time;
@@ -562,8 +554,8 @@ void W_Seeker_Tag_Touch()
        return;
 }
 
-void W_Seeker_Fire_Tag(Weapon thiswep)
-{SELFPARAM();
+void W_Seeker_Fire_Tag(Weapon thiswep, entity actor)
+{entity this = actor;
        entity missile;
        W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, tag_ammo));
 
@@ -573,8 +565,8 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
        missile.owner           = missile.realowner = self;
        missile.bot_dodge       = true;
        missile.bot_dodgerating = 50;
-       missile.touch           = W_Seeker_Tag_Touch;
-       missile.think           = SUB_Remove_self;
+       settouch(missile, W_Seeker_Tag_Touch);
+       setthink(missile, SUB_Remove);
        missile.nextthink       = time + WEP_CVAR(seeker, tag_lifetime);
        missile.movetype        = MOVETYPE_FLY;
        missile.solid           = SOLID_BBOX;
@@ -603,9 +595,9 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
 // Begin: Genereal weapon functions
 // ============================
 
-METHOD(Seeker, wr_aim, void(entity thiswep))
+METHOD(Seeker, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(WEP_CVAR(seeker, type) == 1)
         if(W_Seeker_Tagged_Info(self, self.enemy) != world)
             PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false);
@@ -624,7 +616,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, missile_refire)))
             {
-                W_Seeker_Attack();
+                W_Seeker_Attack(actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
             }
         }
@@ -632,7 +624,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
             {
-                W_Seeker_Fire_Tag(thiswep);
+                W_Seeker_Fire_Tag(thiswep, actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
             }
         }
@@ -644,7 +636,7 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, tag_refire)))
             {
-                W_Seeker_Fire_Tag(thiswep);
+                W_Seeker_Fire_Tag(thiswep, actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
             }
         }
@@ -652,48 +644,45 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(seeker, flac_refire)))
             {
-                W_Seeker_Fire_Flac(thiswep);
+                W_Seeker_Fire_Flac(thiswep, actor);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
             }
         }
     }
 }
-METHOD(Seeker, wr_checkammo1, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float ammo_amount;
     if(WEP_CVAR(seeker, type) == 1)
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
-        ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
+        ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
     }
     else
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
-        ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+        ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
     }
     return ammo_amount;
 }
-METHOD(Seeker, wr_checkammo2, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float ammo_amount;
     if(WEP_CVAR(seeker, type) == 1)
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
-        ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+        ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
     }
     else
     {
-        ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
-        ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
+        ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
+        ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
     }
     return ammo_amount;
 }
 METHOD(Seeker, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND_RELOAD);
 }
 METHOD(Seeker, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -710,9 +699,9 @@ METHOD(Seeker, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Seeker, wr_impacteffect, void(entity thiswep))
+METHOD(Seeker, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2;
     org2 = w_org + w_backoff * 6;
     if(w_deathtype & HITTYPE_BOUNCE)
index 444f96894fa1f44e1e3c3e939c4de8005b249382..a39e7697b96dcb07c6127f3d86d9cd665bee4636 100644 (file)
@@ -112,8 +112,8 @@ float shockwave_hit_damage[MAX_SHOCKWAVE_HITS];
 vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
 
 // MELEE ATTACK MODE
-void W_Shockwave_Melee_Think()
-{SELFPARAM();
+void W_Shockwave_Melee_Think(entity this)
+{
        // declarations
        float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
        entity target_victim;
@@ -241,7 +241,7 @@ void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int f
 
        entity meleetemp = new_pure(meleetemp);
        meleetemp.owner = meleetemp.realowner = actor;
-       meleetemp.think = W_Shockwave_Melee_Think;
+       setthink(meleetemp, W_Shockwave_Melee_Think);
        meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor();
        W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
 }
@@ -276,11 +276,12 @@ float W_Shockwave_Attack_CheckSpread(
 }
 
 float W_Shockwave_Attack_IsVisible(
+       entity actor,
        entity head,
        vector nearest_on_line,
        vector sw_shotorg,
        vector attack_endpos)
-{SELFPARAM();
+{entity this = actor;
        vector nearest_to_attacker = head.WarpZone_findradius_nearest;
        vector center = (head.origin + (head.mins + head.maxs) * 0.5);
        vector corner;
@@ -339,8 +340,8 @@ float W_Shockwave_Attack_CheckHit(
        return true;
 }
 
-void W_Shockwave_Send()
-{SELFPARAM();
+void W_Shockwave_Send(entity actor)
+{
        WriteHeader(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
        WriteCoord(MSG_BROADCAST, w_shotorg.x);
        WriteCoord(MSG_BROADCAST, w_shotorg.y);
@@ -351,11 +352,11 @@ void W_Shockwave_Send()
        WriteShort(MSG_BROADCAST, WEP_CVAR(shockwave, blast_distance));
        WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_max), 255));
        WriteByte(MSG_BROADCAST, bound(0, WEP_CVAR(shockwave, blast_spread_min), 255));
-       WriteByte(MSG_BROADCAST, etof(self));
+       WriteByte(MSG_BROADCAST, etof(actor));
 }
 
-void W_Shockwave_Attack()
-{SELFPARAM();
+void W_Shockwave_Attack(entity actor)
+{entity this = actor;
        // declarations
        float multiplier, multiplier_from_accuracy, multiplier_from_distance;
        float final_damage;
@@ -374,7 +375,7 @@ void W_Shockwave_Attack()
        //entity transform = WarpZone_trace_transform;
 
        // do the firing effect now
-       W_Shockwave_Send();
+       W_Shockwave_Send(self);
        Damage_DamageInfo(
                attack_hitpos,
                WEP_CVAR(shockwave, blast_splash_damage),
@@ -570,7 +571,7 @@ void W_Shockwave_Attack()
                        vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line);
 
                        if((vlen(head.WarpZone_findradius_dist) <= WEP_CVAR(shockwave, blast_distance))
-                               && (W_Shockwave_Attack_IsVisible(head, nearest_on_line, w_shotorg, attack_endpos)))
+                               && (W_Shockwave_Attack_IsVisible(self, head, nearest_on_line, w_shotorg, attack_endpos)))
                        {
                                // calculate importance of distance and accuracy for this attack
                                multiplier_from_accuracy = (1 -
@@ -671,9 +672,9 @@ void W_Shockwave_Attack()
        }
 }
 
-METHOD(Shockwave, wr_aim, void(entity thiswep))
+METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(vlen(self.origin - self.enemy.origin) <= WEP_CVAR(shockwave, melee_range))
         { PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false); }
     else
@@ -687,7 +688,7 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime)))
             {
-                W_Shockwave_Attack();
+                W_Shockwave_Attack(actor);
                 actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready);
             }
@@ -704,11 +705,11 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent
         }
     }
 }
-METHOD(Shockwave, wr_checkammo1, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
 {
     return true; // infinite ammo
 }
-METHOD(Shockwave, wr_checkammo2, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
 {
     // shockwave has infinite ammo
     return true;
@@ -853,7 +854,7 @@ void Net_ReadShockwaveParticle()
        shockwave.sw_time = time;
 }
 
-METHOD(Shockwave, wr_impacteffect, void(entity thiswep))
+METHOD(Shockwave, wr_impacteffect, void(entity thiswep, entity actor))
 {
     // handled by Net_ReadShockwaveParticle
     //vector org2;
index 1a23189402d8c28f6d52e62b54d39d94b83ec378..2440ea42ede70009ce04de04918cf0f539a50ce3 100644 (file)
@@ -58,8 +58,8 @@ REGISTER_WEAPON(SHOTGUN, shotgun, NEW(Shotgun));
 #ifdef SVQC
 spawnfunc(weapon_shotgun) { weapon_defaultspawnfunc(this, WEP_SHOTGUN); }
 
-void W_Shotgun_Attack(Weapon thiswep, float isprimary)
-{SELFPARAM();
+void W_Shotgun_Attack(Weapon thiswep, entity actor, float isprimary)
+{entity this = actor;
        float   sc;
        entity flash;
 
@@ -79,7 +79,7 @@ void W_Shotgun_Attack(Weapon thiswep, float isprimary)
        // muzzle flash for 1st person view
        flash = spawn();
        setmodel(flash, MDL_SHOTGUN_MUZZLEFLASH); // precision set below
-       flash.think = SUB_Remove_self;
+       setthink(flash, SUB_Remove);
        flash.nextthink = time + 0.06;
        flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
        W_AttachToShotorg(self, flash, '5 0 0');
@@ -87,8 +87,8 @@ void W_Shotgun_Attack(Weapon thiswep, float isprimary)
 
 .float swing_prev;
 .entity swing_alreadyhit;
-void W_Shotgun_Melee_Think()
-{SELFPARAM();
+void W_Shotgun_Melee_Think(entity this)
+{
        // declarations
        float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
        entity target_victim;
@@ -190,7 +190,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f
 
        entity meleetemp = new_pure(meleetemp);
        meleetemp.realowner = actor;
-       meleetemp.think = W_Shotgun_Melee_Think;
+       setthink(meleetemp, W_Shotgun_Melee_Think);
        meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor();
        W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range));
 }
@@ -198,7 +198,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f
 // alternate secondary weapon frames
 void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       if (!thiswep.wr_checkammo2(thiswep))
+       if (!thiswep.wr_checkammo2(thiswep, actor))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -207,12 +207,12 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity
        }
 
        sound(actor, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound
-       W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
+       W_Shotgun_Attack(WEP_SHOTGUN, actor, true); // actually is secondary, but we trick the last shot into playing full reload sound
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
 }
 void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 {
-       if (!thiswep.wr_checkammo2(thiswep))
+       if (!thiswep.wr_checkammo2(thiswep, actor))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
@@ -220,15 +220,15 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                return;
        }
 
-       W_Shotgun_Attack(WEP_SHOTGUN, false);
+       W_Shotgun_Attack(WEP_SHOTGUN, actor, false);
        weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2);
 }
 
 .float shotgun_primarytime;
 
-METHOD(Shotgun, wr_aim, void(entity thiswep))
+METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(vdist(self.origin - self.enemy.origin, <=, WEP_CVAR_SEC(shotgun, melee_range)))
         PHYS_INPUT_BUTTON_ATCK2(self) = bot_aim(self, 1000000, 0, 0.001, false);
     else
@@ -251,7 +251,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
             {
                 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime)))
                 {
-                    W_Shotgun_Attack(thiswep, true);
+                    W_Shotgun_Attack(thiswep, actor, true);
                     actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor();
                     weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready);
                 }
@@ -263,7 +263,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
             {
                 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
                 {
-                    W_Shotgun_Attack(thiswep, false);
+                    W_Shotgun_Attack(thiswep, actor, false);
                     actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor();
                     weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1);
                 }
@@ -280,31 +280,29 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
     }
 }
-METHOD(Shotgun, wr_setup, void(entity thiswep))
+METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.ammo_field = ammo_none;
 }
-METHOD(Shotgun, wr_checkammo1, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
-    ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+    ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
     return ammo_amount;
 }
-METHOD(Shotgun, wr_checkammo2, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    if(IS_BOT_CLIENT(self))
-    if(vdist(self.origin - self.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
+    if(IS_BOT_CLIENT(actor))
+    if(vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
         return false; // bots cannot use secondary out of range (fixes constant melee when out of ammo)
     switch(WEP_CVAR(shotgun, secondary))
     {
         case 1: return true; // melee does not use ammo
         case 2: // secondary triple shot
         {
-            float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
-            ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+            float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+            ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
             return ammo_amount;
         }
         default: return false; // secondary unavailable
@@ -312,8 +310,7 @@ METHOD(Shotgun, wr_checkammo2, bool(entity thiswep))
 }
 METHOD(Shotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO
+    W_Reload(actor, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO
 }
 METHOD(Shotgun, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -331,9 +328,9 @@ METHOD(Shotgun, wr_killmessage, Notification(entity thiswep))
 #ifdef CSQC
 .float prevric;
 
-METHOD(Shotgun, wr_impacteffect, void(entity thiswep))
+METHOD(Shotgun, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2 = w_org + w_backoff * 2;
     pointparticles(EFFECT_SHOTGUN_IMPACT, org2, w_backoff * 1000, 1);
     if(!w_issilent && time - self.prevric > 0.25)
index 4cb5ded982424f0973129251320b10f840258ccf..3dd1c26289f3a74e6c5c5190a04c051c06306a97 100644 (file)
@@ -274,8 +274,8 @@ bool W_Tuba_NoteSendEntity(entity this, entity to, int sf)
        return true;
 }
 
-void W_Tuba_NoteThink()
-{SELFPARAM();
+void W_Tuba_NoteThink(entity this)
+{
        float dist_mult;
        float vol0, vol1;
        vector dir0, dir1;
@@ -309,8 +309,8 @@ void W_Tuba_NoteThink()
        });
 }
 
-void W_Tuba_NoteOn(float hittype)
-{SELFPARAM();
+void W_Tuba_NoteOn(entity actor, float hittype)
+{entity this = actor;
        vector o;
        float n;
 
@@ -338,7 +338,7 @@ void W_Tuba_NoteOn(float hittype)
                self.tuba_note.owner = self.tuba_note.realowner = self;
                self.tuba_note.cnt = n;
                self.tuba_note.tuba_instrument = self.tuba_instrument;
-               self.tuba_note.think = W_Tuba_NoteThink;
+               setthink(self.tuba_note, W_Tuba_NoteThink);
                self.tuba_note.nextthink = time;
                self.tuba_note.spawnshieldtime = time;
                Net_LinkEntity(self.tuba_note, false, 0, W_Tuba_NoteSendEntity);
@@ -359,9 +359,8 @@ void W_Tuba_NoteOn(float hittype)
 #endif
 
 #ifdef SVQC
-METHOD(Tuba, wr_aim, void(Tuba this))
+METHOD(Tuba, wr_aim, void(Tuba this, entity actor))
 {
-       entity actor = self;
        // bots cannot play the Tuba well yet
        // I think they should start with the recorder first
        if (vdist((actor.origin - actor.enemy.origin), <, WEP_CVAR(tuba, radius)))
@@ -378,13 +377,13 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f
        if (fire & 1)
        if (weapon_prepareattack(this, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
        {
-               W_Tuba_NoteOn(0);
+               W_Tuba_NoteOn(actor, 0);
                weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
        }
        if (fire & 2)
        if (weapon_prepareattack(this, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
        {
-               W_Tuba_NoteOn(HITTYPE_SECONDARY);
+               W_Tuba_NoteOn(actor, HITTYPE_SECONDARY);
                weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
        }
        if (actor.tuba_note)
@@ -396,9 +395,8 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f
        }
 }
 
-METHOD(Tuba, wr_setup, void(Tuba this))
+METHOD(Tuba, wr_setup, void(Tuba this, entity actor))
 {
-       entity actor = self;
        actor.ammo_field = ammo_none;
        actor.tuba_instrument = 0;
 }
@@ -461,8 +459,8 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
 #ifdef SVQC
 
 // infinite ammo
-METHOD(Tuba, wr_checkammo1, bool(Tuba this)) { return true; }
-METHOD(Tuba, wr_checkammo2, bool(Tuba this)) { return true; }
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor)) { return true; }
 
 METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
 {
@@ -552,8 +550,8 @@ void tubasound(entity e, bool restart)
        }
 }
 
-void Ent_TubaNote_Think()
-{SELFPARAM();
+void Ent_TubaNote_Think(entity this)
+{
        float f = autocvar_g_balance_tuba_fadetime;
        if (f > 0) {
                this.tuba_volume -= frametime * this.tuba_volume_initial / f;
@@ -588,8 +586,6 @@ void Ent_TubaNote_StopSound(entity this)
        this.enemy = NULL;
 }
 
-void Ent_TubaNote_StopSound_self() { SELFPARAM(); Ent_TubaNote_StopSound(self); }
-
 NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isNew)
 {
        bool upd = false;
@@ -631,9 +627,9 @@ NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isNew)
                }
        }
 
-       this.think = Ent_TubaNote_StopSound_self;
+       setthink(this, Ent_TubaNote_StopSound);
        this.entremove = Ent_TubaNote_StopSound;
-       this.enemy.think = Ent_TubaNote_Think;
+       setthink(this.enemy, Ent_TubaNote_Think);
        this.enemy.nextthink = time + 10;
 
        if (upd) {
index 8ce6caadd546b337e0ccd88c3ade4cfcf5400b6d..c4672e727c53a05a19c945308291801aecb8518f 100644 (file)
@@ -137,7 +137,7 @@ void VaporizerBeam_Draw(entity this)
 NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
 {
        Net_Accept(vortex_beam);
-       this.think = SUB_Remove_self;
+       setthink(this, SUB_Remove);
        this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
        this.draw = VaporizerBeam_Draw;
        this.drawmask = MASK_NORMAL;
@@ -167,8 +167,8 @@ NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
 spawnfunc(weapon_vaporizer) { weapon_defaultspawnfunc(this, WEP_VAPORIZER); }
 spawnfunc(weapon_minstanex) { spawnfunc_weapon_vaporizer(this); }
 
-void W_RocketMinsta_Explosion(vector loc)
-{SELFPARAM();
+void W_RocketMinsta_Explosion(entity actor, vector loc)
+{entity this = actor;
        if(accuracy_canbegooddamage(self))
                accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
        entity dmgent = spawn();
@@ -178,8 +178,8 @@ void W_RocketMinsta_Explosion(vector loc)
        remove(dmgent);
 }
 
-void W_Vaporizer_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_Vaporizer_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
        bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
        float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
 
@@ -190,7 +190,7 @@ void W_Vaporizer_Attack(Weapon thiswep)
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
+       FireRailgunBullet(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
 
        // do this now, as goodhits is disabled below
        SendCSQCVaporizerBeamParticle(self, damage_goodhits);
@@ -207,13 +207,13 @@ void W_Vaporizer_Attack(Weapon thiswep)
 
        if(autocvar_g_rm)
        if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
-               W_RocketMinsta_Explosion(trace_endpos);
+               W_RocketMinsta_Explosion(self, trace_endpos);
 
        W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
 }
 
-void W_RocketMinsta_Laser_Explode ()
-{SELFPARAM();
+void W_RocketMinsta_Laser_Explode (entity this)
+{
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -229,19 +229,19 @@ void W_RocketMinsta_Laser_Explode ()
 
 void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger)
 {
-       WITHSELF(this, W_RocketMinsta_Laser_Explode());
+       WITHSELF(this, W_RocketMinsta_Laser_Explode(this));
 }
 
-void W_RocketMinsta_Laser_Touch ()
-{SELFPARAM();
-       PROJECTILE_TOUCH;
+void W_RocketMinsta_Laser_Touch (entity this)
+{
+       PROJECTILE_TOUCH(this);
        //W_RocketMinsta_Laser_Explode ();
        RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
        remove(self);
 }
 
-void W_RocketMinsta_Attack2()
-{SELFPARAM();
+void W_RocketMinsta_Attack2(entity actor)
+{entity this = actor;
        makevectors(self.v_angle);
 
        entity proj;
@@ -264,7 +264,7 @@ void W_RocketMinsta_Attack2()
         proj.bot_dodge = true;
         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
         proj.use = W_RocketMinsta_Laser_Explode_use;
-        proj.think = adaptor_think2use_hittype_splash;
+        setthink(proj, adaptor_think2use_hittype_splash);
         proj.nextthink = time + autocvar_g_rm_laser_lifetime;
         PROJECTILE_MAKETRIGGER(proj);
         proj.projectiledeathtype = WEP_ELECTRO.m_id;
@@ -282,7 +282,7 @@ void W_RocketMinsta_Attack2()
                proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5);
                proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
         proj.angles = vectoangles(proj.velocity);
-        proj.touch = W_RocketMinsta_Laser_Touch;
+        settouch(proj, W_RocketMinsta_Laser_Touch);
         setsize(proj, '0 0 -3', '0 0 -3');
         proj.flags = FL_PROJECTILE;
         proj.missile_flags = MIF_SPLASH;
@@ -294,8 +294,8 @@ void W_RocketMinsta_Attack2()
     }
 }
 
-void W_RocketMinsta_Attack3 ()
-{SELFPARAM();
+void W_RocketMinsta_Attack3 (entity actor)
+{entity this = actor;
        makevectors(self.v_angle);
 
        entity proj;
@@ -316,7 +316,7 @@ void W_RocketMinsta_Attack3 ()
         proj.bot_dodge = true;
         proj.bot_dodgerating = autocvar_g_rm_laser_damage;
         proj.use = W_RocketMinsta_Laser_Explode_use;
-        proj.think = adaptor_think2use_hittype_splash;
+        setthink(proj, adaptor_think2use_hittype_splash);
         proj.nextthink = time + autocvar_g_rm_laser_lifetime;
         PROJECTILE_MAKETRIGGER(proj);
         proj.projectiledeathtype = WEP_ELECTRO.m_id;
@@ -332,7 +332,7 @@ void W_RocketMinsta_Attack3 ()
                proj.velocity = w_shotdir * autocvar_g_rm_laser_speed;
                proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true);
         proj.angles = vectoangles(proj.velocity);
-        proj.touch = W_RocketMinsta_Laser_Touch;
+        settouch(proj, W_RocketMinsta_Laser_Touch);
         setsize(proj, '0 0 -3', '0 0 -3');
         proj.flags = FL_PROJECTILE;
         proj.missile_flags = MIF_SPLASH;
@@ -344,9 +344,9 @@ void W_RocketMinsta_Attack3 ()
     }
 }
 
-METHOD(Vaporizer, wr_aim, void(entity thiswep))
+METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(self.(thiswep.ammo_field) > 0)
         PHYS_INPUT_BUTTON_ATCK(self) = bot_aim(self, 1000000, 0, 1, false);
     else
@@ -365,7 +365,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     {
         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vaporizer, refire)))
         {
-            W_Vaporizer_Attack(thiswep);
+            W_Vaporizer_Attack(thiswep, actor);
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
         }
     }
@@ -381,13 +381,13 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
                 actor.jump_interval = time + autocvar_g_rm_laser_refire;
                 actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay;
                 damage_goodhits = 0;
-                W_RocketMinsta_Attack2();
+                W_RocketMinsta_Attack2(actor);
             }
             else if(rapid && actor.jump_interval2 <= time && actor.held_down)
             {
                 actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire;
                 damage_goodhits = 0;
-                W_RocketMinsta_Attack3();
+                W_RocketMinsta_Attack3(actor);
                 //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready);
             }
         }
@@ -426,37 +426,34 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     else
         actor.held_down = false;
 }
-METHOD(Vaporizer, wr_setup, void(entity thiswep))
+METHOD(Vaporizer, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.ammo_field = (thiswep.ammo_field);
     self.vaporizer_lasthit = 0;
 }
-METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
-    float ammo_amount = self.(thiswep.ammo_field) >= vaporizer_ammo;
-    ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
+    float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
+    ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
     return ammo_amount;
 }
-METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     if(!WEP_CVAR_SEC(vaporizer, ammo))
         return true;
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
-    ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
+    ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
     return ammo_amount;
 }
-METHOD(Vaporizer, wr_resetplayer, void(entity thiswep))
+METHOD(Vaporizer, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     self.vaporizer_lasthit = 0;
 }
 METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
     float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
     float used_ammo;
     if(WEP_CVAR_SEC(vaporizer, ammo))
@@ -464,7 +461,7 @@ METHOD(Vaporizer, wr_reload, void(entity thiswep, entity actor, .entity weaponen
     else
         used_ammo = vaporizer_ammo;
 
-    W_Reload(self, used_ammo, SND_RELOAD);
+    W_Reload(actor, used_ammo, SND_RELOAD);
 }
 METHOD(Vaporizer, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -478,9 +475,9 @@ METHOD(Vaporizer, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Vaporizer, wr_impacteffect, void(entity thiswep))
+METHOD(Vaporizer, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2 = w_org + w_backoff * 6;
     if(w_deathtype & HITTYPE_SECONDARY)
     {
index c0c434561736764acd3231140665e0152774b647..6459ad7a8da2a5b41eaacfdad0ee2737651950fc 100644 (file)
@@ -155,8 +155,8 @@ MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys)
        }
 }
 
-void W_Vortex_Attack(Weapon thiswep, float issecondary)
-{SELFPARAM();
+void W_Vortex_Attack(Weapon thiswep, entity actor, float issecondary)
+{entity this = actor;
        float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
 
        mydmg = WEP_CVAR_BOTH(vortex, !issecondary, damage);
@@ -190,7 +190,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
+       FireRailgunBullet(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
 
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
@@ -210,9 +210,9 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
 
 .float vortex_chargepool_pauseregen_finished;
 
-METHOD(Vortex, wr_aim, void(entity thiswep))
+METHOD(Vortex, wr_aim, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if(bot_aim(self, 1000000, 0, 1, false))
         PHYS_INPUT_BUTTON_ATCK(self) = true;
     else
@@ -242,7 +242,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
         {
             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(vortex, refire)))
             {
-                W_Vortex_Attack(thiswep, 0);
+                W_Vortex_Attack(thiswep, actor, 0);
                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
             }
         }
@@ -314,33 +314,30 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity
             {
                 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(vortex, refire)))
                 {
-                    W_Vortex_Attack(thiswep, 1);
+                    W_Vortex_Attack(thiswep, actor, 1);
                     weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
                 }
             }
         }
     }
 }
-METHOD(Vortex, wr_setup, void(entity thiswep))
+METHOD(Vortex, wr_setup, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    self.vortex_lasthit = 0;
+    actor.vortex_lasthit = 0;
 }
-METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
-    float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
-    ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
+    float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
+    ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
     return ammo_amount;
 }
-METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor))
 {
-    SELFPARAM();
     if(WEP_CVAR(vortex, secondary))
     {
         // don't allow charging if we don't have enough ammo
-        float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
-        ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
+        float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
+        ammo_amount += actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
         return ammo_amount;
     }
     else
@@ -348,9 +345,9 @@ METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
         return false; // zoom is not a fire mode
     }
 }
-METHOD(Vortex, wr_resetplayer, void(entity thiswep))
+METHOD(Vortex, wr_resetplayer, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     if (WEP_CVAR(vortex, charge)) {
         if (WEP_CVAR_SEC(vortex, chargepool)) {
             self.vortex_chargepool_ammo = 1;
@@ -361,8 +358,7 @@ METHOD(Vortex, wr_resetplayer, void(entity thiswep))
 }
 METHOD(Vortex, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
 {
-    SELFPARAM();
-    W_Reload(self, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD);
+    W_Reload(actor, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND_RELOAD);
 }
 METHOD(Vortex, wr_suicidemessage, Notification(entity thiswep))
 {
@@ -376,9 +372,9 @@ METHOD(Vortex, wr_killmessage, Notification(entity thiswep))
 #endif
 #ifdef CSQC
 
-METHOD(Vortex, wr_impacteffect, void(entity thiswep))
+METHOD(Vortex, wr_impacteffect, void(entity thiswep, entity actor))
 {
-    SELFPARAM();
+    entity this = actor;
     vector org2 = w_org + w_backoff * 6;
     pointparticles(EFFECT_VORTEX_IMPACT, org2, '0 0 0', 1);
     if(!w_issilent)
index d0125b5e315c83d2a11c57da8a54785b8157211d..f424d1a5de4dcfec5323851cabb41a712eed6adb 100644 (file)
@@ -43,5 +43,6 @@
 
 #define use use1
 .void(entity this, entity actor, entity trigger) use;
+#define touch move_touch
 
 #endif
index 13fb92749386f7ce5e6806e20879bce88e14ed59..0b0de75649aab42d97851711fca47dd1342c8bf8 100644 (file)
@@ -333,7 +333,7 @@ void CSQCPlayer_SetCamera()
                if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
                if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
                // note: these two only work in WIP2, but are harmless in WIP1
-               if (STAT(HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
+               if (STAT(HEALTH) <= 0 && STAT(HEALTH) != -666 && STAT(HEALTH) != -2342) refdefflags |= REFDEFFLAG_DEAD;
                if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
                V_CalcRefdef(view, refdefflags);
        }
index dc2e4021fbc405283e1de904b13b9546ebbc648a..b02df19e0015a25a0f96df60d8abe5a3f5984976 100644 (file)
@@ -30,9 +30,8 @@
 
 // generic CSQC model code
 
-bool CSQCModel_Send(entity to, int sf)
+bool CSQCModel_Send(entity this, entity to, int sf)
 {
-    SELFPARAM();
        // some nice flags for CSQCMODEL_IF
        noref bool isplayer = IS_CLIENT(this);
        noref bool islocalplayer = (this == to);
@@ -122,7 +121,8 @@ void CSQCModel_CheckUpdate(entity e)
 
 void CSQCModel_LinkEntity(entity e)
 {
-       e.SendEntity = CSQCModel_Send;
+       e.SendEntity = SendEntity_self;
+       e.SendEntity3 = CSQCModel_Send;
        e.SendFlags = 0xFFFFFF;
        CSQCModel_CheckUpdate(e);
 }
@@ -130,4 +130,5 @@ void CSQCModel_LinkEntity(entity e)
 void CSQCModel_UnlinkEntity(entity e)
 {
        e.SendEntity = func_null;
+       e.SendEntity3 = func_null;
 }
index 24764ae1585038b96257e139e857f7f30417dae5..d4a25089fc5a2bf88eddee18ccb51a91e6e85830 100644 (file)
@@ -7,8 +7,6 @@
 
        entityclass(Defer);
        class(Defer).entity owner;
-       class(Defer).void() think;
-       class(Defer).float nextthink;
        class(Defer).void(entity) defer_func;
 
        /** Remove self */
                remove(this);
        }
 
-       /** Remove self */
-       void SUB_Remove_self()
-       {
-               SELFPARAM();
-               remove(this);
-       }
-
-       void defer_think()
+       void defer_think(entity this)
        {
-               SELFPARAM();
-               this.think     = SUB_Remove_self;
+               setthink(this, SUB_Remove);
                this.nextthink = time;
                this.defer_func(this.owner);
        }
@@ -41,7 +31,7 @@
                entity e    = new_pure(deferred);
                e.owner     = this;
                e.defer_func = func;
-               e.think     = defer_think;
+               setthink(e, defer_think);
                e.nextthink = time + fdelay;
        }
 
index 03e5c9dd8941d6a1143effdf28ce3290638f9333..f0a9cc282dc4d24d28a7abb3d8b9097af3f0a982 100644 (file)
@@ -124,7 +124,7 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
                if (dt)
                {
                        e.nextthink = time + dt;
-                       e.think = SUB_Remove_self;
+                       setthink(e, SUB_Remove);
                }
        }
 
index 092a8945b7a25faf0286cef3a7234c315b837772..50196a03a97d4f614725faa16113d3fdcbc207ab 100644 (file)
@@ -19,6 +19,8 @@
 #if 1
     #undef self
     #define self (this, self)
+    #undef SELFPARAM
+    #define SELFPARAM() const entity this = __self
 #endif
 
 // Step 4: kill unstructured setself
 
 // Step 5: this should work
 #if 0
+    #undef self
     #define self (0, this)
 #endif
 
-// Step 6: Remove SELFPARAM in favor of a parameter
+// Step 6: remove SELFPARAM, add parameters
+#if 0
+    #undef SELFPARAM
+#endif
+
+// Step 7: remove WITHSELF, no replacement
+#if 0
+    #undef WITHSELF
+    #define WITHSELF(value, block) block
+#endif
+
+#define SELFWRAP(T, R, args, forward) \
+    .R() T; \
+    .R() __##T = T; \
+    .R args self##T; \
+    R T##_self() { SELFPARAM(); return this.self##T forward; }
+
+noref entity _selftemp;
+#define SELFWRAP_SET(T, e, f) \
+    (_selftemp = (e), _selftemp.__##T = ((f) ? T##_self : func_null), _selftemp.self##T = (f))
+#define SELFWRAP_GET(T, e) \
+    (0, (e).self##T)
+#define _SELFWRAP_SET(T, e, f) \
+    ((e).__##T = (f))
+#define _SELFWRAP_GET(T, e) \
+    (0, (e).__##T)
 
-.void(entity this) selftouch;
-void touch_self() { SELFPARAM(); this.selftouch(this); }
-#define settouch(e, f) (e.touch = touch_self, e.selftouch = f)
+SELFWRAP(think, void, (entity this), (this))
+#define setthink(e, f) SELFWRAP_SET(think, e, f)
+#define getthink(e) SELFWRAP_GET(think, e)
 
-//.void(entity this) selfuse;
-//void use_self() { SELFPARAM(); this.selfuse(this); }
-//#define setuse(e, f) (e.use = use_self, e.selfuse = f)
+SELFWRAP(touch, void, (entity this), (this))
+#define settouch(e, f) SELFWRAP_SET(touch, e, f)
+#define gettouch(e) SELFWRAP_GET(touch, e)
 
-.void(entity this) selfthink;
-void think_self() { SELFPARAM(); this.selfthink(this); }
-#define setthink(e, f) (e.think = think_self, e.selfthink = f)
+SELFWRAP(predraw, void, (entity this), (this))
+#define setpredraw(e, f) SELFWRAP_SET(predraw, e, f)
+
+#ifndef MENUQC
+void adaptor_think2touch(entity this) { WITH(entity, other, NULL, gettouch(this)(this)); }
+void adaptor_think2use(entity this) { if (this.use) this.use(this, NULL, NULL); }
+#endif
index 6467dad35a4d57b4fcebe762166b70216ef2fbec..44ae46fb14b08bcb0a63137a359c551e4b23491c 100644 (file)
@@ -25,7 +25,7 @@ void WarpZone_Fade_PreDraw(entity this)
                this.drawmask = MASK_NORMAL;
 }
 
-void WarpZone_Touch ();
+void WarpZone_Touch (entity this);
 NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
 {
        warpzone_warpzones_exist = 1;
@@ -241,7 +241,6 @@ void WarpZone_FixView()
 {
        entity e;
        vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
-       float f;
 
        warpzone_save_view_origin = org = getpropertyvec(VF_ORIGIN);
        warpzone_save_view_angles = ang = getpropertyvec(VF_ANGLES);
@@ -257,16 +256,21 @@ void WarpZone_FixView()
                WarpZone_View_Outside();
 
 #ifndef KEEP_ROLL
-       float rick;
-       if(autocvar_cl_rollkillspeed)
-               f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
-       else
-               f = 0;
-
-       rick = getproperty(VF_CL_VIEWANGLES_Z);
-       rick *= f;
-       setproperty(VF_CL_VIEWANGLES_Z, rick);
-       ang.z *= f;
+       static float rollkill;
+       if (STAT(HEALTH) <= 0 && STAT(HEALTH) != -666 && STAT(HEALTH) != -2342)
+       {
+               if(autocvar_cl_rollkillspeed)
+               {
+                       rollkill += frametime * autocvar_cl_rollkillspeed;
+                       rollkill = min(1, rollkill);
+               }
+               float rick;
+               rick = getproperty(VF_CL_VIEWANGLES_Z) * rollkill;
+               setproperty(VF_CL_VIEWANGLES_Z, rick);
+               ang.z *= rollkill;
+       }
+       else if(rollkill)
+               rollkill = 0;
 #endif
 
        setproperty(VF_ORIGIN, org);
index 130e1b2d14b82be54b0619811c6f0cb553a056d2..5967c1ba1a9d564db61f3bf52a6137ee9616387a 100644 (file)
@@ -667,8 +667,8 @@ entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
 }
 
 .entity WarpZone_refsys;
-void WarpZone_RefSys_GC()
-{SELFPARAM();
+void WarpZone_RefSys_GC(entity this)
+{
        // garbage collect unused reference systems
        this.nextthink = time + 1;
        if(this.owner.WarpZone_refsys != this)
@@ -680,7 +680,7 @@ void WarpZone_RefSys_CheckCreate(entity me)
        {
                me.WarpZone_refsys = new(warpzone_refsys);
                me.WarpZone_refsys.owner = me;
-               me.WarpZone_refsys.think = WarpZone_RefSys_GC;
+               setthink(me.WarpZone_refsys, WarpZone_RefSys_GC);
                me.WarpZone_refsys.nextthink = time + 1;
                WarpZone_Accumulator_Clear(me.WarpZone_refsys);
        }
@@ -786,9 +786,9 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
        return e;
 }
 
-float WarpZoneLib_ExactTrigger_Touch()
-{SELFPARAM();
-       return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, this, other);
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
+{
+       return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
 }
 
 
index ebea01108dc72927c5180964e4599ed85e2262ff..2cfa7ef9bc906e7beca25011b57c64527544186e 100644 (file)
@@ -107,10 +107,10 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me); // spawn().R = me.R
 float WarpZoneLib_MoveOutOfSolid(entity e);
 #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
 
-float WarpZoneLib_ExactTrigger_Touch();
-void WarpZoneLib_ExactTrigger_Init();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
+void WarpZoneLib_ExactTrigger_Init(entity this);
 
 // WARNING: this kills the trace globals
-#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return
-#define EXACTTRIGGER_INIT  WarpZoneLib_ExactTrigger_Init()
+#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch(this, other)) return
+#define EXACTTRIGGER_INIT  WarpZoneLib_ExactTrigger_Init(this)
 #endif
index f8260b5ad0a7c3c2b7c4fb52bef6699efe7ade73..0fb8dd235ff99033e04148fa9662ff9764ee43cc 100644 (file)
@@ -173,7 +173,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
                ts.SendEntity3 = WarpZone_Teleported_Send;
                ts.SendFlags = 0xFFFFFF;
                ts.drawonlytoclient = player;
-               ts.think = SUB_Remove_self;
+               setthink(ts, SUB_Remove);
                ts.nextthink = time + 1;
                ts.owner = player;
                ts.enemy = wz;
@@ -190,8 +190,8 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
        return 1;
 }
 
-void WarpZone_Touch ()
-{SELFPARAM();
+void WarpZone_Touch (entity this)
+{
        if(other.classname == "trigger_warpzone")
                return;
 
@@ -206,7 +206,7 @@ void WarpZone_Touch ()
 #endif
                return;
 
-       if(WarpZoneLib_ExactTrigger_Touch())
+       if(WarpZoneLib_ExactTrigger_Touch(self, other))
                return;
 
 #ifdef SVQC
@@ -363,7 +363,7 @@ bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
 
 #ifdef WARPZONELIB_KEEPDEBUG
 float WarpZone_CheckProjectileImpact(entity player)
-{SELFPARAM();
+{
        vector o0, v0;
 
        .vector orgvec, velvec;
@@ -435,8 +435,8 @@ float WarpZone_CheckProjectileImpact(entity player)
 #endif
 #endif
 
-float WarpZone_Projectile_Touch()
-{SELFPARAM();
+float WarpZone_Projectile_Touch(entity this)
+{
        if(other.classname == "trigger_warpzone")
                return true;
 
@@ -479,9 +479,8 @@ float WarpZone_Projectile_Touch()
                save_ent = trace_ent;
                save_inopen = trace_inopen;
                save_inwater = trace_inwater;
-               float f;
-               if((f = WarpZone_CheckProjectileImpact(this)) != 0)
-                       return (f > 0);
+               float f = WarpZone_CheckProjectileImpact(this);
+               if (f) return (f > 0);
                trace_dpstartcontents = save_dpstartcontents;
                trace_dphitcontents = save_dphitcontents;
                trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
@@ -543,8 +542,8 @@ void WarpZonePosition_InitStep_FindTarget(entity this)
        this.enemy.aiment = this;
 }
 
-void WarpZoneCamera_Think()
-{SELFPARAM();
+void WarpZoneCamera_Think(entity this)
+{
        if(this.warpzone_save_origin != this.origin
        || this.warpzone_save_angles != this.angles
        || this.warpzone_save_eorigin != this.enemy.origin
@@ -582,7 +581,7 @@ void WarpZoneCamera_InitStep_FindTarget(entity this)
        this.SendFlags = 0xFFFFFF;
        if(this.spawnflags & 1)
        {
-               this.think = WarpZoneCamera_Think;
+               setthink(this, WarpZoneCamera_Think);
                this.nextthink = time;
        }
        else
@@ -708,7 +707,7 @@ void WarpZone_InitStep_FindTarget(entity this)
        }
 }
 
-void WarpZone_Think();
+void WarpZone_Think(entity this);
 void WarpZone_InitStep_FinalizeTransform(entity this)
 {
        if(!this.enemy || this.enemy.enemy != this)
@@ -719,11 +718,11 @@ void WarpZone_InitStep_FinalizeTransform(entity this)
 
        warpzone_warpzones_exist = 1;
        WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
-       this.touch = WarpZone_Touch;
+       settouch(this, WarpZone_Touch);
        this.SendFlags = 0xFFFFFF;
        if(this.spawnflags & 1)
        {
-               this.think = WarpZone_Think;
+               setthink(this, WarpZone_Think);
                this.nextthink = time;
        }
        else
@@ -761,7 +760,7 @@ spawnfunc(trigger_warpzone)
                this.scale = 1;
        string m;
        m = this.model;
-       WarpZoneLib_ExactTrigger_Init();
+       WarpZoneLib_ExactTrigger_Init(this);
        if(m != "")
        {
                precache_model(m);
@@ -817,8 +816,8 @@ void WarpZones_Reconnect()
                WarpZone_InitStep_FinalizeTransform(e);
 }
 
-void WarpZone_Think()
-{SELFPARAM();
+void WarpZone_Think(entity this)
+{
        if(this.warpzone_save_origin != this.origin
        || this.warpzone_save_angles != this.angles
        || this.warpzone_save_eorigin != this.enemy.origin
@@ -838,7 +837,6 @@ void WarpZone_Think()
 
 void WarpZone_StartFrame()
 {
-       SELFPARAM();
        if (!warpzone_initialized)
        {
                warpzone_initialized = true;
@@ -866,24 +864,23 @@ void WarpZone_StartFrame()
 
                        // warpzones
                        if (warpzone_warpzones_exist) {
-                               setself(WarpZone_Find(it.origin + it.mins, it.origin + it.maxs));
-                               if (self)
-                               if (!WarpZoneLib_ExactTrigger_Touch())
-                               if (WarpZone_PlaneDist(self, it.origin + it.view_ofs) <= 0)
-                                       WarpZone_Teleport(self, it, -1, 0); // NOT triggering targets by this!
+                               entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
+                               if (e)
+                               if (!WarpZoneLib_ExactTrigger_Touch(e, other))
+                               if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
+                                       WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
                        }
 
                        // teleporters
                        if(other.teleportable)
                        {
-                               setself(Teleport_Find(it.origin + it.mins, it.origin + it.maxs));
-                               if (self)
-                               if (!WarpZoneLib_ExactTrigger_Touch())
-                                       Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
+                               entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
+                               if (ent)
+                               if (!WarpZoneLib_ExactTrigger_Touch(ent, other))
+                                       Simple_TeleportPlayer(ent, other); // NOT triggering targets by this!
                        }
                }
        });
-       setself(this);
        other = oldother;
 }
 
index db0ba59cc0c812f76a74290b110c2a6471ec13aa..c6c7b9840c9c86dee6b67093a1e38f6e8cd87189 100644 (file)
@@ -3,7 +3,7 @@
 
 #ifdef SVQC
 void WarpZone_StartFrame();
-float WarpZone_Projectile_Touch();
+float WarpZone_Projectile_Touch(entity this);
 
 // THESE must be defined by calling QC code:
 void WarpZone_PostTeleportPlayer_Callback(entity pl);
index be232a28187af10a9f059ea2044eff531160be82..73f09c0e07e871c65c738e887547ec95e8e46d31 100644 (file)
@@ -9,8 +9,8 @@
 #endif
 #include "common.qh"
 
-void WarpZoneLib_ExactTrigger_Init()
-{SELFPARAM();
+void WarpZoneLib_ExactTrigger_Init(entity this)
+{
        vector mi, ma;
        if (this.movedir == '0 0 0')
        if (this.angles != '0 0 0')
index 75df5d862656b06141a03fdb850506320fbe987f..39d1d24699caab93e8d209c4489844f7cbd6fb5c 100644 (file)
@@ -2,8 +2,8 @@
 #define LIB_WARPZONE_UTIL_SERVER_H
 
 float WarpZoneLib_MoveOutOfSolid(entity e);
-float WarpZoneLib_ExactTrigger_Touch();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
 #ifdef SVQC
-void WarpZoneLib_ExactTrigger_Init();
+void WarpZoneLib_ExactTrigger_Init(entity this);
 #endif
 #endif
index cff3fe21452ad42a9f1a931927dcbcc82e18670f..0d59fa6e4251f1fad85259692af0062e519113d1 100644 (file)
@@ -107,7 +107,7 @@ void havocbot_ai(entity this)
                if(this.weapons)
                {
                        Weapon w = PS(this).m_weapon;
-                       w.wr_aim(w);
+                       w.wr_aim(w, this);
                        if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(this))
                        {
                                PHYS_INPUT_BUTTON_ATCK(this) = false;
@@ -807,7 +807,7 @@ void havocbot_movetogoal(entity this)
                                this.aistatus |= AI_STATUS_DANGER_AHEAD;
                }
 
-               dodge = havocbot_dodge();
+               dodge = havocbot_dodge(this);
                dodge = dodge * bound(0,0.5+(skill+this.bot_dodgeskill)*0.1,1);
                evadelava = evadelava * bound(1,3-(skill+this.bot_dodgeskill),3); //Noobs fear lava a lot and take more distance from it
                traceline(this.origin, ( ( this.enemy.absmin + this.enemy.absmax ) * 0.5 ), true, world);
@@ -993,7 +993,7 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon)
        {
                bool other_weapon_available = false;
                FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       if(it.wr_checkammo1(it) + it.wr_checkammo2(it))
+                       if(it.wr_checkammo1(it, this) + it.wr_checkammo2(it, this))
                                other_weapon_available = true;
                ));
                if(other_weapon_available)
@@ -1268,12 +1268,11 @@ void havocbot_setupbot(entity this)
        havocbot_chooserole(this);
 }
 
-vector havocbot_dodge()
+vector havocbot_dodge(entity this)
 {
        // LordHavoc: disabled because this is too expensive
        return '0 0 0';
 #if 0
-SELFPARAM();
        entity head;
        vector dodge, v, n;
        float danger, bestdanger, vl, d;
index 36b4c33fd9b5a3bdcfdf5645c97afda9c915821d..4a391b6e7ceb9682a2df64023aa98751e88974d1 100644 (file)
@@ -47,7 +47,7 @@ float havocbot_resetgoal(entity this);
 float havocbot_moveto(entity this, vector pos);
 float havocbot_moveto_refresh_route(entity this);
 
-vector havocbot_dodge();
+vector havocbot_dodge(entity this);
 
 .void(entity this) havocbot_role;
 .void(entity this) havocbot_previous_role;
index bba6a1b9e2a7084b1fb9a1ad06a2a975c57b7596..ef8451efac92beea85914831f58ae0ad8a9433eb 100644 (file)
@@ -163,8 +163,8 @@ void waypoint_addlink(entity from, entity to)
 // relink this spawnfunc_waypoint
 // (precompile a list of all reachable waypoints from this spawnfunc_waypoint)
 // (SLOW!)
-void waypoint_think()
-{SELFPARAM();
+void waypoint_think(entity this)
+{
        entity e;
        vector sv, sm1, sm2, ev, em1, em2, dv;
 
@@ -289,7 +289,7 @@ void waypoint_schedulerelink(entity wp)
        if (!(wp.wpflags & WAYPOINTFLAG_NORELINK))
                waypoint_clearlinks(wp);
        // schedule an actual relink on next frame
-       wp.think = waypoint_think;
+       setthink(wp, waypoint_think);
        wp.nextthink = time;
        wp.effects = EF_LOWPRECISION;
 }
index a03155544f6688722ef8e3f462ae50f4531226a2..23c0fa63c3b66a4c168a7bbb5cd12b55fc55c77a 100644 (file)
@@ -39,7 +39,7 @@ float botframe_cachedwaypointlinks;
 
 spawnfunc(waypoint);
 void waypoint_addlink(entity from, entity to);
-void waypoint_think();
+void waypoint_think(entity this);
 void waypoint_clearlinks(entity wp);
 void waypoint_schedulerelink(entity wp);
 
index add6d535564b5e9bd4a855cfede7582678436c24..b9928f0b91213da871dbd68baacb0c3c7dd5f46f 100644 (file)
@@ -31,8 +31,8 @@ void CopyBody(entity this, float keepvelocity);
 
 #ifdef NOCHEATS
 
-float CheatImpulse(int imp) { return 0; }
-float CheatCommand(float argc) { return 0; }
+float CheatImpulse(entity this, int imp) { return 0; }
+float CheatCommand(entity this, int argc) { return 0; }
 float CheatFrame() { return 0; }
 void CheatInit() { cheatcount_total = world.cheatcount; }
 void CheatShutdown() { }
@@ -54,21 +54,21 @@ void CheatShutdown()
 {
 }
 
-float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
-{SELFPARAM();
+float CheatsAllowed(entity this, float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
+{
        // dead people cannot cheat
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
                return 0;
-       if(gamestart_sv_cheats < 2 && !IS_PLAYER(self))
+       if(gamestart_sv_cheats < 2 && !IS_PLAYER(this))
                return 0;
 
        // sv_clones
        if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse)
-               if(self.lip < sv_clones)
+               if(this.lip < sv_clones)
                        return 1;
 
        // haha
-       if(self.maycheat)
+       if(this.maycheat)
                return 1;
 
        // sv_cheats
@@ -77,13 +77,13 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
 
        // if we get here, player is not allowed to cheat. Log it.
        if(i)
-               bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", self.netname, i);
+               bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", this.netname, i);
        else if(argc)
-               bprintf("Player %s^7 tried to use cheat '%s'\n", self.netname, argv(0));
+               bprintf("Player %s^7 tried to use cheat '%s'\n", this.netname, argv(0));
        else if(fr)
-               bprintf("Player %s^7 tried to use cheat frame %d\n", self.netname, fr);
+               bprintf("Player %s^7 tried to use cheat frame %d\n", this.netname, fr);
        else
-               bprintf("Player %s^7 tried to use an unknown cheat\n", self.netname);
+               bprintf("Player %s^7 tried to use an unknown cheat\n", this.netname);
 
        return 0;
 }
@@ -99,24 +99,24 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
 #define END_CHEAT_FUNCTION() \
        ADD_CHEATS(this, cheating); \
        return attempting
-#define IS_CHEAT(i,argc,fr) \
-       if((++attempting, !CheatsAllowed(i,argc,fr))) \
+#define IS_CHEAT(ent,i,argc,fr) \
+       if((++attempting, !CheatsAllowed(ent,i,argc,fr))) \
                break
 
 float num_autoscreenshot;
 void info_autoscreenshot_findtarget(entity this)
 {
        entity e;
-       e = find(world, targetname, self.target);
+       e = find(world, targetname, this.target);
        if(!e)
        {
                objerror("Missing target. FAIL!");
                return;
        }
-       vector a = vectoangles(e.origin - self.origin);
+       vector a = vectoangles(e.origin - this.origin);
        a.x = -a.x; // don't ask
-       self.angles_x = a.x;
-       self.angles_y = a.y;
+       this.angles_x = a.x;
+       this.angles_y = a.y;
        // we leave Rick Roll alone
 }
 spawnfunc(info_autoscreenshot)
@@ -126,13 +126,13 @@ spawnfunc(info_autoscreenshot)
                objerror("Too many info_autoscreenshot entitites. FAIL!");
                return;
        }
-       if(self.target != "")
-               InitializeEntity(self, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET);
+       if(this.target != "")
+               InitializeEntity(this, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET);
        // this one just has to exist
 }
 
-float CheatImpulse(int imp)
-{SELFPARAM();
+float CheatImpulse(entity this, int imp)
+{
        BEGIN_CHEAT_FUNCTION();
        switch(imp)
        {
@@ -140,140 +140,140 @@ float CheatImpulse(int imp)
 
                case CHIMPULSE_SPEEDRUN_INIT.impulse: // deploy personal waypoint
                        // shared with regular waypoint init, so this is not a cheat by itself
-                       if(!self.personal)
+                       if(!this.personal)
                        {
-                               self.personal = new(personal_wp);
+                               this.personal = new(personal_wp);
                        }
-                       self.personal.origin = self.origin;
-                       self.personal.v_angle = self.v_angle;
-                       self.personal.velocity = self.velocity;
-                       self.personal.ammo_rockets = self.ammo_rockets;
-                       self.personal.ammo_nails = self.ammo_nails;
-                       self.personal.ammo_cells = self.ammo_cells;
-                       self.personal.ammo_plasma = self.ammo_plasma;
-                       self.personal.ammo_shells = self.ammo_shells;
-                       self.personal.ammo_fuel = self.ammo_fuel;
-                       self.personal.health = self.health;
-                       self.personal.armorvalue = self.armorvalue;
-                       self.personal.weapons = self.weapons;
-                       self.personal.items = self.items;
-                       self.personal.pauserotarmor_finished = self.pauserotarmor_finished;
-                       self.personal.pauserothealth_finished = self.pauserothealth_finished;
-                       self.personal.pauserotfuel_finished = self.pauserotfuel_finished;
-                       self.personal.pauseregen_finished = self.pauseregen_finished;
-                       self.personal.strength_finished = self.strength_finished;
-                       self.personal.invincible_finished = self.invincible_finished;
-                       self.personal.teleport_time = time;
-                       break; // this part itself doesn't cheat, so let's not count this
+                       this.personal.origin = this.origin;
+                       this.personal.v_angle = this.v_angle;
+                       this.personal.velocity = this.velocity;
+                       this.personal.ammo_rockets = this.ammo_rockets;
+                       this.personal.ammo_nails = this.ammo_nails;
+                       this.personal.ammo_cells = this.ammo_cells;
+                       this.personal.ammo_plasma = this.ammo_plasma;
+                       this.personal.ammo_shells = this.ammo_shells;
+                       this.personal.ammo_fuel = this.ammo_fuel;
+                       this.personal.health = this.health;
+                       this.personal.armorvalue = this.armorvalue;
+                       this.personal.weapons = this.weapons;
+                       this.personal.items = this.items;
+                       this.personal.pauserotarmor_finished = this.pauserotarmor_finished;
+                       this.personal.pauserothealth_finished = this.pauserothealth_finished;
+                       this.personal.pauserotfuel_finished = this.pauserotfuel_finished;
+                       this.personal.pauseregen_finished = this.pauseregen_finished;
+                       this.personal.strength_finished = this.strength_finished;
+                       this.personal.invincible_finished = this.invincible_finished;
+                       this.personal.teleport_time = time;
+                       break; // this part itthis doesn't cheat, so let's not count this
                case CHIMPULSE_CLONE_MOVING.impulse:
-                       IS_CHEAT(imp, 0, 0);
-                       makevectors (self.v_angle);
-                       self.velocity = self.velocity + v_forward * 300;
-                       CopyBody(self, 1);
-                       self.lip += 1;
-                       self.velocity = self.velocity - v_forward * 300;
+                       IS_CHEAT(this, imp, 0, 0);
+                       makevectors (this.v_angle);
+                       this.velocity = this.velocity + v_forward * 300;
+                       CopyBody(this, 1);
+                       this.lip += 1;
+                       this.velocity = this.velocity - v_forward * 300;
                        DID_CHEAT();
                        break;
                case CHIMPULSE_CLONE_STANDING.impulse:
-                       IS_CHEAT(imp, 0, 0);
-                       CopyBody(self, 0);
-                       self.lip += 1;
+                       IS_CHEAT(this, imp, 0, 0);
+                       CopyBody(this, 0);
+                       this.lip += 1;
                        DID_CHEAT();
                        break;
                case CHIMPULSE_GIVE_ALL.impulse:
-                       IS_CHEAT(imp, 0, 0);
-                       CheatCommand(tokenize_console("give all"));
+                       IS_CHEAT(this, imp, 0, 0);
+                       CheatCommand(this, tokenize_console("give all"));
                        break; // already counted as cheat
                case CHIMPULSE_SPEEDRUN.impulse:
-                       IS_CHEAT(imp, 0, 0);
-                       if(self.personal)
+                       IS_CHEAT(this, imp, 0, 0);
+                       if(this.personal)
                        {
-                               self.speedrunning = true;
-                               tracebox(self.personal.origin, self.mins, self.maxs, self.personal.origin, MOVE_WORLDONLY, self);
+                               this.speedrunning = true;
+                               tracebox(this.personal.origin, this.mins, this.maxs, this.personal.origin, MOVE_WORLDONLY, this);
                                if(trace_startsolid)
                                {
-                                       sprint(self, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
+                                       sprint(this, "Cannot move there, cheater - only waypoints set using g_waypointsprite_personal work\n");
                                }
                                else
                                {
                                        // Abort speedrun, teleport back
-                                       setorigin(self, self.personal.origin);
-                                       self.oldvelocity = self.velocity = self.personal.velocity;
-                                       self.angles = self.personal.v_angle;
-                                       self.fixangle = true;
+                                       setorigin(this, this.personal.origin);
+                                       this.oldvelocity = this.velocity = this.personal.velocity;
+                                       this.angles = this.personal.v_angle;
+                                       this.fixangle = true;
 
-                                       MUTATOR_CALLHOOK(AbortSpeedrun, self);
+                                       MUTATOR_CALLHOOK(AbortSpeedrun, this);
                                }
 
-                               self.ammo_rockets = self.personal.ammo_rockets;
-                               self.ammo_nails = self.personal.ammo_nails;
-                               self.ammo_cells = self.personal.ammo_cells;
-                               self.ammo_plasma = self.personal.ammo_plasma;
-                               self.ammo_shells = self.personal.ammo_shells;
-                               self.ammo_fuel = self.personal.ammo_fuel;
-                               self.health = self.personal.health;
-                               self.armorvalue = self.personal.armorvalue;
-                               self.weapons = self.personal.weapons;
-                               self.items = self.personal.items;
-                               self.pauserotarmor_finished = time + self.personal.pauserotarmor_finished - self.personal.teleport_time;
-                               self.pauserothealth_finished = time + self.personal.pauserothealth_finished - self.personal.teleport_time;
-                               self.pauserotfuel_finished = time + self.personal.pauserotfuel_finished - self.personal.teleport_time;
-                               self.pauseregen_finished = time + self.personal.pauseregen_finished - self.personal.teleport_time;
-                               self.strength_finished = time + self.personal.strength_finished - self.personal.teleport_time;
-                               self.invincible_finished = time + self.personal.invincible_finished - self.personal.teleport_time;
+                               this.ammo_rockets = this.personal.ammo_rockets;
+                               this.ammo_nails = this.personal.ammo_nails;
+                               this.ammo_cells = this.personal.ammo_cells;
+                               this.ammo_plasma = this.personal.ammo_plasma;
+                               this.ammo_shells = this.personal.ammo_shells;
+                               this.ammo_fuel = this.personal.ammo_fuel;
+                               this.health = this.personal.health;
+                               this.armorvalue = this.personal.armorvalue;
+                               this.weapons = this.personal.weapons;
+                               this.items = this.personal.items;
+                               this.pauserotarmor_finished = time + this.personal.pauserotarmor_finished - this.personal.teleport_time;
+                               this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
+                               this.pauserotfuel_finished = time + this.personal.pauserotfuel_finished - this.personal.teleport_time;
+                               this.pauseregen_finished = time + this.personal.pauseregen_finished - this.personal.teleport_time;
+                               this.strength_finished = time + this.personal.strength_finished - this.personal.teleport_time;
+                               this.invincible_finished = time + this.personal.invincible_finished - this.personal.teleport_time;
 
                                DID_CHEAT();
                                break;
                        }
-                       if(IS_DEAD(self))
-                               sprint(self, "UR DEAD AHAHAH))\n");
+                       if(IS_DEAD(this))
+                               sprint(this, "UR DEAD AHAHAH))\n");
                        else
-                               sprint(self, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
+                               sprint(this, "No waypoint set, cheater (use g_waypointsprite_personal to set one)\n");
                        break;
                case CHIMPULSE_TELEPORT.impulse:
-                       IS_CHEAT(imp, 0, 0);
-                       if(self.movetype == MOVETYPE_NOCLIP)
+                       IS_CHEAT(this, imp, 0, 0);
+                       if(this.movetype == MOVETYPE_NOCLIP)
                        {
                                e = find(world, classname, "info_autoscreenshot");
                                if(e)
                                {
-                                       sprint(self, "Emergency teleport used info_autoscreenshot location\n");
-                                       setorigin(self, e.origin);
-                                       self.angles = e.angles;
+                                       sprint(this, "Emergency teleport used info_autoscreenshot location\n");
+                                       setorigin(this, e.origin);
+                                       this.angles = e.angles;
                                        remove(e);
-                                       // should we? self.angles_x = -self.angles_x;
-                                       self.fixangle = true;
-                                       self.velocity = '0 0 0';
+                                       // should we? this.angles_x = -this.angles_x;
+                                       this.fixangle = true;
+                                       this.velocity = '0 0 0';
                                        DID_CHEAT();
                                        break;
                                }
                        }
-                       if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats < 2) ? 100 : 100000), 384, 384))
+                       if(MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats < 2) ? 100 : 100000), 384, 384))
                        {
-                               sprint(self, "Emergency teleport used random location\n");
-                               self.angles_x = -self.angles.x;
-                               self.fixangle = true;
-                               self.velocity = '0 0 0';
+                               sprint(this, "Emergency teleport used random location\n");
+                               this.angles_x = -this.angles.x;
+                               this.fixangle = true;
+                               this.velocity = '0 0 0';
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Emergency teleport could not find a good location, forget it!\n");
+                       sprint(this, "Emergency teleport could not find a good location, forget it!\n");
                        break;
                case CHIMPULSE_R00T.impulse:
-                       IS_CHEAT(imp, 0, 0);
+                       IS_CHEAT(this, imp, 0, 0);
                        RandomSelection_Init();
-                       FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, self), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
+                       FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && DIFF_TEAM(it, this), LAMBDA(RandomSelection_Add(it, 0, string_null, 1, 1)));
                        if(RandomSelection_chosen_ent)
                                e = RandomSelection_chosen_ent;
                        else
-                               e = self;
+                               e = this;
 
                        Send_Effect(EFFECT_ROCKET_EXPLODE, e.origin, '0 0 0', 1);
                        sound(e, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
                        e2 = spawn();
                        setorigin(e2, e.origin);
-                       RadiusDamage(e2, self, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
+                       RadiusDamage(e2, this, 1000, 0, 128, world, world, 500, DEATH_CHEAT.m_id, e);
                        remove(e2);
 
                        LOG_INFO("404 Sportsmanship not found.\n");
@@ -284,10 +284,10 @@ float CheatImpulse(int imp)
        END_CHEAT_FUNCTION();
 }
 
-void DragBox_Think();
+void DragBox_Think(entity this);
 float drag_lastcnt;
-float CheatCommand(float argc)
-{SELFPARAM();
+float CheatCommand(entity this, int argc)
+{
        BEGIN_CHEAT_FUNCTION();
        string cmd;
        cmd = argv(0);
@@ -298,7 +298,7 @@ float CheatCommand(float argc)
                entity oldself;
 
                case "pointparticles":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 5)
                        {
                                // arguments:
@@ -307,43 +307,43 @@ float CheatCommand(float argc)
                                //   velocity
                                //   howmany
                                f = stof(argv(2));
-                               crosshair_trace(self);
-                               start = (1-f) * self.origin + f * trace_endpos;
+                               crosshair_trace(this);
+                               start = (1-f) * this.origin + f * trace_endpos;
                                end = stov(argv(3));
                                f = stof(argv(4));
                                Send_Effect_(argv(1), start, end, f);
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
                        break;
                case "trailparticles":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 2)
                        {
                                // arguments:
                                //   effectname
                                effectnum = _particleeffectnum(argv(1));
-                               W_SetupShot(self, false, false, SND_Null, CH_WEAPON_A, 0);
-                               traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
-                               __trailparticles(self, effectnum, w_shotorg, trace_endpos);
+                               W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
+                               traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this);
+                               __trailparticles(this, effectnum, w_shotorg, trace_endpos);
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
                        break;
                case "make":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 3)
                        {
                                // arguments:
                                //   modelname mode
                                f = stof(argv(2));
-                               W_SetupShot(self, false, false, SND_Null, CH_WEAPON_A, 0);
-                               traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
+                               W_SetupShot(this, false, false, SND_Null, CH_WEAPON_A, 0);
+                               traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, this);
                                if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
                                {
-                                       sprint(self, "cannot make stuff there (bad surface)\n");
+                                       sprint(this, "cannot make stuff there (bad surface)\n");
                                }
                                else
                                {
@@ -366,7 +366,7 @@ float CheatCommand(float argc)
                                                if(trace_startsolid)
                                                {
                                                        remove(e);
-                                                       sprint(self, "cannot make stuff there (no space)\n");
+                                                       sprint(this, "cannot make stuff there (no space)\n");
                                                }
                                                else
                                                        DID_CHEAT();
@@ -376,22 +376,22 @@ float CheatCommand(float argc)
                                }
                        }
                        else
-                               sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
+                               sprint(this, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
                        break;
                case "penalty":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 3)
                        {
-                               race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
+                               race_ImposePenaltyTime(this, stof(argv(1)), argv(2));
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
                        break;
                case "dragbox_spawn": {
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        entity e = new(dragbox_box);
-                       e.think = DragBox_Think;
+                       setthink(e, DragBox_Think);
                        e.nextthink = time;
                        e.solid = -1; // black
                        setmodel(e, MDL_Null); // network it
@@ -409,7 +409,7 @@ float CheatCommand(float argc)
                                setorigin(e.aiment, stov(argv(2)));
                        else
                        {
-                               crosshair_trace(self);
+                               crosshair_trace(this);
                                setorigin(e.aiment, trace_endpos);
                        }
 
@@ -418,7 +418,7 @@ float CheatCommand(float argc)
                        setmodel(e.enemy, MDL_MARKER);
                        e.enemy.skin = 1;
                        setsize(e.enemy, '0 0 0', '0 0 0');
-                       end = normalize(self.origin + self.view_ofs - e.aiment.origin);
+                       end = normalize(this.origin + this.view_ofs - e.aiment.origin);
                        end.x = (end.x > 0) * 2 - 1;
                        end.y = (end.y > 0) * 2 - 1;
                        end.z = (end.z > 0) * 2 - 1;
@@ -439,9 +439,9 @@ float CheatCommand(float argc)
                        break;
                }
                case "dragpoint_spawn": {
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        entity e = new(dragpoint);
-                       e.think = DragBox_Think;
+                       setthink(e, DragBox_Think);
                        e.nextthink = time;
                        e.solid = 0; // nothing special
                        setmodel(e, MDL_MARKER);
@@ -455,8 +455,8 @@ float CheatCommand(float argc)
                                setorigin(e, stov(argv(2)));
                        else
                        {
-                               crosshair_trace(self);
-                               setorigin(e, trace_endpos + normalize(self.origin + self.view_ofs - trace_endpos));
+                               crosshair_trace(this);
+                               setorigin(e, trace_endpos + normalize(this.origin + this.view_ofs - trace_endpos));
                                move_out_of_solid(e);
                        }
 
@@ -472,9 +472,9 @@ float CheatCommand(float argc)
                        break;
                }
                case "drag_remove":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        RandomSelection_Init();
-                       crosshair_trace(self);
+                       crosshair_trace(this);
                        for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        for(entity e = world; (e = find(e, classname, "dragpoint")); )
@@ -492,11 +492,11 @@ float CheatCommand(float argc)
                        DID_CHEAT();
                        break;
                case "drag_setcnt":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 2)
                        {
                                RandomSelection_Init();
-                               crosshair_trace(self);
+                               crosshair_trace(this);
                                for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                        RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                for(entity e = world; (e = find(e, classname, "dragpoint")); )
@@ -511,10 +511,10 @@ float CheatCommand(float argc)
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
                        break;
                case "drag_save":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 2)
                        {
                                f = fopen(argv(1), FILE_WRITE);
@@ -531,10 +531,10 @@ float CheatCommand(float argc)
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
                        break;
                case "drag_saveraceent":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        if(argc == 2)
                        {
                                f = fopen(argv(1), FILE_WRITE);
@@ -600,10 +600,10 @@ float CheatCommand(float argc)
                                DID_CHEAT();
                                break;
                        }
-                       sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
+                       sprint(this, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
                        break;
                case "drag_clear":
-                       IS_CHEAT(0, argc, 0);
+                       IS_CHEAT(this, 0, argc, 0);
                        for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                remove(e);
                        for(entity e = world; (e = find(e, classname, "dragbox_corner_1")); )
@@ -617,98 +617,95 @@ float CheatCommand(float argc)
                        DID_CHEAT();
                        break;
                case "god":
-                       IS_CHEAT(0, argc, 0);
-                       BITXOR_ASSIGN(self.flags, FL_GODMODE);
-                       if(self.flags & FL_GODMODE)
+                       IS_CHEAT(this, 0, argc, 0);
+                       BITXOR_ASSIGN(this.flags, FL_GODMODE);
+                       if(this.flags & FL_GODMODE)
                        {
-                               sprint(self, "godmode ON\n");
+                               sprint(this, "godmode ON\n");
                                DID_CHEAT();
                        }
                        else
-                               sprint(self, "godmode OFF\n");
+                               sprint(this, "godmode OFF\n");
                        break;
                case "notarget":
-                       IS_CHEAT(0, argc, 0);
-                       BITXOR_ASSIGN(self.flags, FL_NOTARGET);
-                       if(self.flags & FL_NOTARGET)
+                       IS_CHEAT(this, 0, argc, 0);
+                       BITXOR_ASSIGN(this.flags, FL_NOTARGET);
+                       if(this.flags & FL_NOTARGET)
                        {
-                               sprint(self, "notarget ON\n");
+                               sprint(this, "notarget ON\n");
                                DID_CHEAT();
                        }
                        else
-                               sprint(self, "notarget OFF\n");
+                               sprint(this, "notarget OFF\n");
                        break;
                case "noclip":
-                       IS_CHEAT(0, argc, 0);
-                       if(self.movetype != MOVETYPE_NOCLIP)
+                       IS_CHEAT(this, 0, argc, 0);
+                       if(this.movetype != MOVETYPE_NOCLIP)
                        {
-                               self.movetype = MOVETYPE_NOCLIP;
-                               sprint(self, "noclip ON\n");
+                               this.movetype = MOVETYPE_NOCLIP;
+                               sprint(this, "noclip ON\n");
                                DID_CHEAT();
                        }
                        else
                        {
-                               self.movetype = MOVETYPE_WALK;
-                               sprint(self, "noclip OFF\n");
+                               this.movetype = MOVETYPE_WALK;
+                               sprint(this, "noclip OFF\n");
                        }
                        break;
                case "fly":
-                       IS_CHEAT(0, argc, 0);
-                       if(self.movetype != MOVETYPE_FLY)
+                       IS_CHEAT(this, 0, argc, 0);
+                       if(this.movetype != MOVETYPE_FLY)
                        {
-                               self.movetype = MOVETYPE_FLY;
-                               sprint(self, "flymode ON\n");
+                               this.movetype = MOVETYPE_FLY;
+                               sprint(this, "flymode ON\n");
                                DID_CHEAT();
                        }
                        else
                        {
-                               self.movetype = MOVETYPE_WALK;
-                               sprint(self, "flymode OFF\n");
+                               this.movetype = MOVETYPE_WALK;
+                               sprint(this, "flymode OFF\n");
                        }
                        break;
                case "give":
-                       IS_CHEAT(0, argc, 0);
-                       if(GiveItems(self, 1, argc))
+                       IS_CHEAT(this, 0, argc, 0);
+                       if(GiveItems(this, 1, argc))
                                DID_CHEAT();
                        break;
                case "usetarget":
-                       IS_CHEAT(0, argc, 0);
-                       setself(spawn());
-                       self.target = argv(1);
-                       SUB_UseTargets(self, this, NULL);
-                       remove(self);
-                       setself(this);
+                       IS_CHEAT(this, 0, argc, 0);
+                       entity e = spawn();
+                       e.target = argv(1);
+                       SUB_UseTargets(e, this, NULL);
+                       remove(e);
                        DID_CHEAT();
                        break;
                case "killtarget":
-                       IS_CHEAT(0, argc, 0);
-                       setself(spawn());
-                       self.killtarget = argv(1);
-                       SUB_UseTargets(self, this, NULL);
-                       remove(self);
-                       setself(this);
+                       IS_CHEAT(this, 0, argc, 0);
+                       entity e2 = spawn();
+                       e2.killtarget = argv(1);
+                       SUB_UseTargets(e2, this, NULL);
+                       remove(e2);
                        DID_CHEAT();
                        break;
                case "teleporttotarget":
-                       IS_CHEAT(0, argc, 0);
-                       setself(new(cheattriggerteleport));
-                       setorigin(self, self.origin);
-                       self.target = argv(1);
-                       teleport_findtarget(self);
-                       if(!wasfreed(self))
+                       IS_CHEAT(this, 0, argc, 0);
+                       entity ent = new(cheattriggerteleport);
+                       setorigin(ent, ent.origin);
+                       ent.target = argv(1);
+                       teleport_findtarget(ent);
+                       if(!wasfreed(ent))
                        {
-                               Simple_TeleportPlayer(self, this);
-                               remove(self);
+                               Simple_TeleportPlayer(ent, this);
+                               remove(ent);
                                DID_CHEAT();
                        }
-                       setself(this);
                        break;
        }
 
        END_CHEAT_FUNCTION();
 }
 
-float Drag(float force_allow_pick, float ischeat);
+float Drag(entity this, float force_allow_pick, float ischeat);
 void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
 void Drag_Finish(entity dragger);
 float Drag_IsDraggable(entity draggee);
@@ -738,11 +735,11 @@ float CheatFrame()
                        {
                                // use cheat dragging if cheats are enabled
                                crosshair_trace_plusvisibletriggers(this);
-                               Drag(true, true);
+                               Drag(this, true, true);
                        }
                        else
                        {
-                               Drag(false, false); // execute dragging
+                               Drag(this, false, false); // execute dragging
                        }
                        break;
        }
@@ -766,8 +763,8 @@ float CheatFrame()
 .entity draggedby;
 .float dragmovetype;
 
-float Drag(float force_allow_pick, float ischeat)
-{SELFPARAM();
+float Drag(entity this, float force_allow_pick, float ischeat)
+{
        BEGIN_CHEAT_FUNCTION();
 
        // returns true when an entity has been picked up
@@ -850,7 +847,7 @@ float Drag(float force_allow_pick, float ischeat)
                                                        if(Drag_IsDraggable(e))
                                                        {
                                                                if(ischeat)
-                                                                       IS_CHEAT(0, 0, CHRAME_DRAG);
+                                                                       IS_CHEAT(this, 0, 0, CHRAME_DRAG);
                                                                if(e.draggedby)
                                                                        Drag_Finish(e.draggedby);
                                                                if(e.tag_entity)
@@ -1043,8 +1040,8 @@ void Drag_MoveDrag(entity from, entity to)
        }
 }
 
-void DragBox_Think()
-{SELFPARAM();
+void DragBox_Think(entity this)
+{
        if(this.aiment && this.enemy)
        {
                this.origin_x = (this.aiment.origin.x + this.enemy.origin.x) * 0.5;
index 97df2467bd207013cc8dbbe1cc7fc2fc853f0b02..e688f8c138c5de93f3404cd031d18c88bc5aacb5 100644 (file)
@@ -8,8 +8,8 @@ float cheatcount_total;
 .float cheatcount;
 void CheatInit();
 void CheatShutdown();
-float CheatImpulse(int imp);
-float CheatCommand(float argc);
+float CheatImpulse(entity this, int imp);
+float CheatCommand(entity this, int argc);
 float CheatFrame();
 
 const float CHRAME_DRAG = 8;
index c157530fa7d39b9cbbb1e7597ce03aba5db0aa58..ad9a1ec542cc085844f77e1905f337da70f29a59 100644 (file)
@@ -196,7 +196,7 @@ void PutObserverInServer()
     }
 
     {
-        entity spot = SelectSpawnPoint(true);
+        entity spot = SelectSpawnPoint(this, true);
         if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
         this.angles = spot.angles;
         this.angles_z = 0;
@@ -294,7 +294,7 @@ void PutObserverInServer()
        this.superweapons_finished = 0;
        this.pushltime = 0;
        this.istypefrag = 0;
-       this.think = func_null;
+       setthink(this, func_null);
        this.nextthink = 0;
        this.hook_time = 0;
        this.deadflag = DEAD_NO;
@@ -471,7 +471,7 @@ void PutClientInServer()
                if (this.team < 0)
                        JoinBestTeam(this, false, true);
 
-               entity spot = SelectSpawnPoint(false);
+               entity spot = SelectSpawnPoint(this, false);
                if (!spot) {
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
                        return; // spawn failed
@@ -547,7 +547,7 @@ void PutClientInServer()
                this.pain_frame = 0;
                this.pain_finished = 0;
                this.pushltime = 0;
-               this.think = func_null; // players have no think function
+               setthink(this, func_null); // players have no think function
                this.nextthink = 0;
                this.dmg_team = 0;
                this.ballistics_density = autocvar_g_ballistics_density_player;
@@ -619,7 +619,7 @@ void PutClientInServer()
 
                // reset fields the weapons may use
                FOREACH(Weapons, true, LAMBDA(
-                       it.wr_resetplayer(it);
+                       it.wr_resetplayer(it, this);
                        // reload all reloadable weapons
                        if (it.spawnflags & WEP_FLAG_RELOADABLE) {
                                this.weapon_load[it.m_id] = it.reloading_ammo;
@@ -656,7 +656,7 @@ void PutClientInServer()
        }
 }
 
-void ClientInit_misc();
+void ClientInit_misc(entity this);
 
 .float ebouncefactor, ebouncestop; // electro's values
 // TODO do we need all these fields, or should we stop autodetecting runtime
@@ -670,12 +670,11 @@ bool ClientInit_SendEntity(entity this, entity to, int sf)
        // TODO: make easier to use
        Registry_send_all();
        W_PROP_reload(MSG_ONE, to);
-       ClientInit_misc();
+       ClientInit_misc(this);
        MUTATOR_CALLHOOK(Ent_Init);
 }
-void ClientInit_misc()
+void ClientInit_misc(entity this)
 {
-    SELFPARAM();
        int channel = MSG_ONE;
        WriteHeader(channel, ENT_CLIENT_INIT);
        WriteByte(channel, g_nexball_meter_period * 32);
@@ -697,8 +696,8 @@ void ClientInit_misc()
        WriteCoord(channel, autocvar_g_trueaim_minrange);
 }
 
-void ClientInit_CheckUpdate()
-{SELFPARAM();
+void ClientInit_CheckUpdate(entity this)
+{
        this.nextthink = time;
        if(this.count != autocvar_g_balance_armor_blockpercent)
        {
@@ -708,13 +707,12 @@ void ClientInit_CheckUpdate()
 }
 
 void ClientInit_Spawn()
-{SELFPARAM();
-
+{
        entity e = new_pure(clientinit);
-       e.think = ClientInit_CheckUpdate;
+       setthink(e, ClientInit_CheckUpdate);
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
-       WITHSELF(e, ClientInit_CheckUpdate());
+       WITHSELF(e, ClientInit_CheckUpdate(e));
 }
 
 /*
@@ -812,8 +810,8 @@ void ClientKill_Now()
 
        // now I am sure the player IS dead
 }
-void KillIndicator_Think()
-{SELFPARAM();
+void KillIndicator_Think(entity this)
+{
        if (gameover)
        {
                this.owner.killindicator = world;
@@ -893,7 +891,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        this.killindicator.scale = 0.5;
                        setattachment(this.killindicator, this, "");
                        setorigin(this.killindicator, '0 0 52');
-                       this.killindicator.think = KillIndicator_Think;
+                       setthink(this.killindicator, KillIndicator_Think);
                        this.killindicator.nextthink = starttime + (this.lip) * 0.05;
                        clientkilltime = max(clientkilltime, this.killindicator.nextthink + 0.05);
                        this.killindicator.cnt = ceil(killtime);
@@ -909,7 +907,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                                e.killindicator.scale = 0.5;
                                setattachment(e.killindicator, e, "");
                                setorigin(e.killindicator, '0 0 52');
-                               e.killindicator.think = KillIndicator_Think;
+                               setthink(e.killindicator, KillIndicator_Think);
                                e.killindicator.nextthink = starttime + (e.lip) * 0.05;
                                clientkilltime = max(clientkilltime, e.killindicator.nextthink + 0.05);
                                e.killindicator.cnt = ceil(killtime);
@@ -1142,7 +1140,7 @@ void ClientConnect()
                if (!autocvar_g_campaign)
                {
                        this.motd_actived_time = -1;
-                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
                }
 
                if (g_weaponarena_weapons == WEPSET(TUBA))
@@ -1224,8 +1222,8 @@ void ClientDisconnect()
        if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false);
 }
 
-void ChatBubbleThink()
-{SELFPARAM();
+void ChatBubbleThink(entity this)
+{
        this.nextthink = time;
        if ((this.owner.alpha < 0) || this.owner.chatbubbleentity != this)
        {
@@ -1260,7 +1258,7 @@ void UpdateChatBubble()
                this.chatbubbleentity = new(chatbubbleentity);
                this.chatbubbleentity.owner = this;
                this.chatbubbleentity.exteriormodeltoclient = this;
-               this.chatbubbleentity.think = ChatBubbleThink;
+               setthink(this.chatbubbleentity, ChatBubbleThink);
                this.chatbubbleentity.nextthink = time;
                setmodel(this.chatbubbleentity, MDL_CHAT); // precision set below
                //setorigin(this.chatbubbleentity, this.origin + '0 0 15' + this.maxs_z * '0 0 1');
@@ -1884,7 +1882,7 @@ void PrintWelcomeMessage(entity this)
                } else {
                        if (PHYS_INPUT_BUTTON_INFO(this)) {
                                this.motd_actived_time = time;
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
                        }
                }
        }
@@ -2066,7 +2064,6 @@ Called every frame for each client before the physics are run
 =============
 */
 .float usekeypressed;
-void() nexball_setstatus;
 .float last_vehiclecheck;
 .int items_added;
 void PlayerPreThink ()
@@ -2222,7 +2219,7 @@ void PlayerPreThink ()
                                bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this));
 
                                if (this.deadflag == DEAD_DYING) {
-                                       if ((this.respawn_flags & RESPAWN_FORCE) && !autocvar_g_respawn_delay_max) {
+                                       if ((this.respawn_flags & RESPAWN_FORCE) && !(this.respawn_time < this.respawn_time_max)) {
                                                this.deadflag = DEAD_RESPAWNING;
                                        } else if (!button_pressed) {
                                                this.deadflag = DEAD_DEAD;
@@ -2249,8 +2246,13 @@ void PlayerPreThink ()
 
                                if (this.respawn_flags & RESPAWN_SILENT)
                                        STAT(RESPAWN_TIME, this) = 0;
-                               else if ((this.respawn_flags & RESPAWN_FORCE) && autocvar_g_respawn_delay_max)
-                                       STAT(RESPAWN_TIME, this) = this.respawn_time_max;
+                               else if ((this.respawn_flags & RESPAWN_FORCE) && this.respawn_time < this.respawn_time_max)
+                               {
+                                       if (time < this.respawn_time)
+                                               STAT(RESPAWN_TIME, this) = this.respawn_time;
+                                       else if (this.deadflag != DEAD_RESPAWNING)
+                                               STAT(RESPAWN_TIME, this) = -this.respawn_time_max;
+                               }
                                else
                                        STAT(RESPAWN_TIME, this) = this.respawn_time;
                        }
index 14779525fdaa53cfe83c95bde9cbc04be2d4daa5..251c6921e423b2fbc0f5bc78f97ab12a999864fb 100644 (file)
@@ -61,7 +61,7 @@
                        this.impulse = IMP_weapon_group_##slot.impulse; \
                        return; \
                } \
-               W_NextWeaponOnImpulse(slot); \
+               W_NextWeaponOnImpulse(this, slot); \
        }
 X(1)
 X(2)
@@ -89,7 +89,7 @@ X(0)
                noref int prev = -1; \
                noref int best =  0; \
                noref int next = +1; \
-               W_CycleWeapon(this.cvar_cl_weaponpriorities[slot], dir); \
+               W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir); \
        }
 X(0, prev)
 X(1, prev)
@@ -136,7 +136,7 @@ X(9, next)
                        this.impulse = IMP_weapon_byid_##i.impulse; \
                        return; \
                } \
-               W_SwitchWeapon(Weapons_from(WEP_FIRST + i)); \
+               W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i)); \
        }
 X(0)
 X(1)
@@ -172,7 +172,7 @@ IMPULSE(weapon_next_byid)
                this.impulse = IMP_weapon_next_byid.impulse;
                return;
        }
-       W_NextWeapon(0);
+       W_NextWeapon(this, 0);
 }
 
 IMPULSE(weapon_prev_byid)
@@ -183,7 +183,7 @@ IMPULSE(weapon_prev_byid)
                this.impulse = IMP_weapon_prev_byid.impulse;
                return;
        }
-       W_PreviousWeapon(0);
+       W_PreviousWeapon(this, 0);
 }
 
 IMPULSE(weapon_next_bygroup)
@@ -194,7 +194,7 @@ IMPULSE(weapon_next_bygroup)
                this.impulse = IMP_weapon_next_bygroup.impulse;
                return;
        }
-       W_NextWeapon(1);
+       W_NextWeapon(this, 1);
 }
 
 IMPULSE(weapon_prev_bygroup)
@@ -205,7 +205,7 @@ IMPULSE(weapon_prev_bygroup)
                this.impulse = IMP_weapon_prev_bygroup.impulse;
                return;
        }
-       W_PreviousWeapon(1);
+       W_PreviousWeapon(this, 1);
 }
 
 IMPULSE(weapon_next_bypriority)
@@ -216,7 +216,7 @@ IMPULSE(weapon_next_bypriority)
                this.impulse = IMP_weapon_next_bypriority.impulse;
                return;
        }
-       W_NextWeapon(2);
+       W_NextWeapon(this, 2);
 }
 
 IMPULSE(weapon_prev_bypriority)
@@ -227,7 +227,7 @@ IMPULSE(weapon_prev_bypriority)
                this.impulse = IMP_weapon_prev_bypriority.impulse;
                return;
        }
-       W_PreviousWeapon(2);
+       W_PreviousWeapon(this, 2);
 }
 
 IMPULSE(weapon_last)
@@ -241,14 +241,14 @@ IMPULSE(weapon_best)
 {
        if (this.vehicle) return;
        if (IS_DEAD(this)) return;
-       W_SwitchWeapon(w_getbestweapon(this));
+       W_SwitchWeapon(this, w_getbestweapon(this));
 }
 
 IMPULSE(weapon_drop)
 {
        if (this.vehicle) return;
        if (IS_DEAD(this)) return;
-       W_ThrowWeapon(W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
+       W_ThrowWeapon(this, W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true);
 }
 
 IMPULSE(weapon_reload)
@@ -361,7 +361,7 @@ void ImpulseCommands(entity this)
 
        if (vehicle_impulse(this, imp)) return;
 
-       if (CheatImpulse(imp)) return;
+       if (CheatImpulse(this, imp)) return;
 
        FOREACH(IMPULSES, it.impulse == imp, {
                void(entity) f = it.impulse_handle;
index 8aaf68cda69dac1753364cfe1e84cd07c10129c3..85044c27409c948609d42a47f7aec70d0983816c 100644 (file)
@@ -37,16 +37,16 @@ void Drop_Special_Items(entity player)
        MUTATOR_CALLHOOK(DropSpecialItems, player);
 }
 
-void CopyBody_Think()
-{SELFPARAM();
+void CopyBody_Think(entity this)
+{
        if(this.CopyBody_nextthink && time > this.CopyBody_nextthink)
        {
-               this.CopyBody_think();
+               this.CopyBody_think(this);
                if(wasfreed(this))
                        return;
                this.CopyBody_nextthink = this.nextthink;
-               this.CopyBody_think = this.think;
-               this.think = CopyBody_Think;
+               this.CopyBody_think = getthink(this);
+               setthink(this, CopyBody_Think);
        }
        CSQCMODEL_AUTOUPDATE(this);
        this.nextthink = time;
@@ -118,9 +118,9 @@ void CopyBody(entity this, float keepvelocity)
 
        CSQCMODEL_AUTOINIT(clone);
        clone.CopyBody_nextthink = this.nextthink;
-       clone.CopyBody_think = this.think;
+       clone.CopyBody_think = getthink(this);
        clone.nextthink = time;
-       clone.think = CopyBody_Think;
+       setthink(clone, CopyBody_Think);
        // "bake" the current animation frame for clones (they don't get clientside animation)
        animdecide_load_if_needed(clone);
        animdecide_setframes(clone, false, frame, frame1time, frame2, frame2time);
@@ -556,7 +556,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                excess = frag_damage;
 
                Weapon wep = PS(this).m_weapon;
-               WITHSELF(this, wep.wr_playerdeath(wep));
+               WITHSELF(this, wep.wr_playerdeath(wep, this));
 
                RemoveGrapplingHook(this);
 
@@ -622,10 +622,10 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                // set up to fade out later
                SUB_SetFade (this, time + 6 + random (), 1);
                // reset body think wrapper broken by SUB_SetFade
-               if(this.classname == "body" && this.think != CopyBody_Think) {
-                       this.CopyBody_think = this.think;
+               if(this.classname == "body" && getthink(this) != CopyBody_Think) {
+                       this.CopyBody_think = getthink(this);
                        this.CopyBody_nextthink = this.nextthink;
-                       this.think = CopyBody_Think;
+                       setthink(this, CopyBody_Think);
                        this.nextthink = time;
                }
 
@@ -637,7 +637,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
 
                // reset fields the weapons may use just in case
                FOREACH(Weapons, it != WEP_Null, LAMBDA(
-                       WITHSELF(this, it.wr_resetplayer(it));
+                       WITHSELF(this, it.wr_resetplayer(it, this));
                        for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                        {
                                ATTACK_FINISHED_FOR(this, it.m_id, slot) = 0;
index 22c595f66d3cd9ca4a59ce2e507e0d9f65dc2524..16637fe327415e86ff4f5205322008cf55451ec1 100644 (file)
@@ -5,8 +5,8 @@
 .float istypefrag;
 
 .float CopyBody_nextthink;
-.void() CopyBody_think;
-void CopyBody_Think();
+.void(entity this) CopyBody_think;
+void CopyBody_Think(entity this);
 void CopyBody(entity this, float keepvelocity);
 
 void player_setupanimsformodel();
index e7cc3d4578c8a811d7509db00a23954ef785f50a..6c3c942a73d79d61c7ae0b7df8056f531a273592 100644 (file)
@@ -788,7 +788,7 @@ void SV_ParseClientCommand(string command)
        {
                return;  // handled by a mutator
        }
-       else if (CheatCommand(argc))
+       else if (CheatCommand(this, argc))
        {
                return;  // handled by server/cheats.qc
        }
index 14965d8c73be1189f3c0abb44675cd0af0ffcedc..14f7439a4fcc35f3971acb942f9a75e9121dc809 100644 (file)
@@ -183,19 +183,17 @@ void print_to(entity to, string input)
 // ==========================================
 
 // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
-void timeout_handler_reset()
+void timeout_handler_reset(entity this)
 {
-       SELFPARAM();
-       timeout_caller = world;
+       timeout_caller = NULL;
        timeout_time = 0;
        timeout_leadtime = 0;
 
-       remove(self);
+       remove(this);
 }
 
-void timeout_handler_think()
+void timeout_handler_think(entity this)
 {
-       SELFPARAM();
        switch (timeout_status)
        {
                case TIMEOUT_ACTIVE:
@@ -222,7 +220,7 @@ void timeout_handler_think()
                                        it.fixangle = false;
                                ));
 
-                               timeout_handler_reset();
+                               timeout_handler_reset(this);
                        }
 
                        return;
@@ -266,7 +264,7 @@ void timeout_handler_think()
                case TIMEOUT_INACTIVE:
                default:
                {
-                       timeout_handler_reset();
+                       timeout_handler_reset(this);
                        return;
                }
        }
@@ -473,7 +471,7 @@ void CommonCommand_info(float request, entity caller, float argc)
                {
                        string command = builtin_cvar_string(strcat("sv_info_", argv(1)));
 
-                       if (command) wordwrap_sprint(command, 1000);
+                       if (command) wordwrap_sprint(caller, command, 1000);
                        else print_to(caller, "ERROR: unsupported info command");
 
                        return;  // never fall through to usage
@@ -740,7 +738,7 @@ void CommonCommand_timeout(float request, entity caller)  // DEAR GOD THIS COMMA
                                        timeout_leadtime = autocvar_sv_timeout_leadtime;
 
                                        timeout_handler = spawn();
-                                       timeout_handler.think = timeout_handler_think;
+                                       setthink(timeout_handler, timeout_handler_think);
                                        timeout_handler.nextthink = time;  // always let the entity think asap
 
                                        Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_TIMEOUT);
index b79a570209ff46f7c0f2a10f73634443034cc0d3..63b1c708f21f1bdea6a7fe441988bc2dd57e97bd 100644 (file)
@@ -55,7 +55,7 @@ float timeout_status;    // (values: 0, 1, 2) contains whether a timeout is not
 .vector lastV_angle;     // used when pausing the game in order to force the player to keep his old view angle fixed
 
 // allow functions to be used in other code like g_world.qc and teamplay.qc
-void timeout_handler_think();
+void timeout_handler_think(entity this);
 
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 void CommonCommand_macro_write_aliases(float fh);
@@ -98,9 +98,9 @@ void print_to(entity to, string input);
 // ==========================================
 
 // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
-void timeout_handler_reset();
+void timeout_handler_reset(entity this);
 
-void timeout_handler_think();
+void timeout_handler_think(entity this);
 
 // ===================================================
 //  Common commands used in both sv_cmd.qc and cmd.qc
index 5105a5b19cc42d715cd37d382e86975b5c44e938..616727c5d66b5ad1acb63b46b5eee79f1e69f2ae 100644 (file)
@@ -210,9 +210,8 @@ void RadarMap_Next()
        remove(radarmapper);
        radarmapper = world;
 }
-void RadarMap_Think()
+void RadarMap_Think(entity this)
 {
-       SELFPARAM();
        // rough map entity
        //   cnt: current line
        //   size: pixel width/height
@@ -374,7 +373,7 @@ float RadarMap_Make(float argc)
        if (!radarmapper)
        {
                radarmapper = new(radarmapper);
-               radarmapper.think = RadarMap_Think;
+               setthink(radarmapper, RadarMap_Think);
                radarmapper.nextthink = time;
                radarmapper.count = 8;  // default to the --trace method, as it is faster now
                radarmapper.ltime = 1;
index 02e984e3c587e5eec84957cf6c628014c64e110c..f056f0ff2f64533954fff7a98651c6b4fc52ec27 100644 (file)
@@ -39,9 +39,8 @@ void PutObserverInServer();
 // =====================================================
 
 //  used by GameCommand_make_mapinfo()
-void make_mapinfo_Think()
+void make_mapinfo_Think(entity this)
 {
-       SELFPARAM();
        if (MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
        {
                LOG_INFO("Done rebuiling mapinfos.\n");
@@ -50,7 +49,7 @@ void make_mapinfo_Think()
        }
        else
        {
-               self.think = make_mapinfo_Think;
+               setthink(self, make_mapinfo_Think);
                self.nextthink = time;
        }
 }
@@ -190,7 +189,6 @@ void GameCommand_allready(float request)
 
 void GameCommand_allspec(float request, float argc)
 {
-       SELFPARAM();
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
@@ -970,7 +968,7 @@ void GameCommand_make_mapinfo(float request)
                        entity tmp_entity;
 
                        tmp_entity = new(make_mapinfo);
-                       tmp_entity.think = make_mapinfo_Think;
+                       setthink(tmp_entity, make_mapinfo_Think);
                        tmp_entity.nextthink = time;
                        MapInfo_Enumerate();
                        return;
@@ -989,7 +987,6 @@ void GameCommand_make_mapinfo(float request)
 
 void GameCommand_moveplayer(float request, float argc)
 {
-       SELFPARAM();
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1155,7 +1152,6 @@ void GameCommand_nospectators(float request)
 
 void GameCommand_playerdemo(float request, float argc)
 {
-       SELFPARAM();
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1178,7 +1174,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               WITHSELF(client, playerdemo_open_read(argv(next_token)));
+                                               playerdemo_open_read(client, argv(next_token));
                                                return;
                                        }
 
@@ -1193,7 +1189,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               WITHSELF(client, playerdemo_open_write(argv(next_token)));
+                                               playerdemo_open_write(client, argv(next_token));
                                                return;
                                        }
 
@@ -1327,7 +1323,6 @@ void GameCommand_setbots(float request, float argc)
 
 void GameCommand_shuffleteams(float request)
 {
-       SELFPARAM();
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1384,9 +1379,13 @@ void GameCommand_shuffleteams(float request)
                                                {
                                                        if (!(shuffleteams_players[z])) continue;  // not a player, move on to next random slot
 
-                                                       if (VerifyClientNumber(shuffleteams_players[z])) setself(edict_num(shuffleteams_players[z]));
+                                                       entity e = NULL;
+                                                       if(VerifyClientNumber(shuffleteams_players[z]))
+                                                               e = edict_num(shuffleteams_players[z]);
 
-                                                       if (self.team != team_color) MoveToTeam(self, team_color, 6);
+                                                       if(!e) continue; // unverified
+
+                                                       if (e.team != team_color) MoveToTeam(e, team_color, 6);
 
                                                        shuffleteams_players[z] = 0;
                                                        shuffleteams_teams[i] = shuffleteams_teams[i] + 1;
index 252ab2f852cbf45647ea9b8d81a5b402f1fad57c..982e55c9619ac9578d03c421421bfc5dc873aa58 100644 (file)
@@ -333,8 +333,6 @@ void VoteThink()
 // Resets the state of all clients, items, weapons, waypoints, ... of the map.
 void reset_map(bool dorespawn)
 {
-       SELFPARAM();
-
        if (time <= game_starttime && round_handler_IsActive()) round_handler_Reset(game_starttime);
 
        MUTATOR_CALLHOOK(reset_map_global);
@@ -363,7 +361,6 @@ void reset_map(bool dorespawn)
                if (!MUTATOR_CALLHOOK(reset_map_players))
                {
                        FOREACH_CLIENT(true, LAMBDA(
-                               setself(it);
                                /*
                                only reset players if a restart countdown is active
                                this can either be due to cvar sv_ready_restart_after_countdown having set
@@ -373,28 +370,25 @@ void reset_map(bool dorespawn)
                                if (restart_mapalreadyrestarted || (time < game_starttime))
                                {
                                        // NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
-                                       if (IS_PLAYER(self))
+                                       if (IS_PLAYER(it))
                                        {
-                                               // PlayerScore_Clear(self);
-                                               self.killcount = 0;
+                                               // PlayerScore_Clear(it);
+                                               it.killcount = 0;
                                                // stop the player from moving so that he stands still once he gets respawned
-                                               self.velocity = '0 0 0';
-                                               self.avelocity = '0 0 0';
-                                               self.movement = '0 0 0';
-                                               PutClientInServer();
+                                               it.velocity = '0 0 0';
+                                               it.avelocity = '0 0 0';
+                                               it.movement = '0 0 0';
+                                               WITHSELF(it, PutClientInServer());
                                        }
                                }
                        ));
-
-                       setself(this);
                }
        }
 }
 
 // Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
-void ReadyRestart_think()
+void ReadyRestart_think(entity this)
 {
-       SELFPARAM();
        restart_mapalreadyrestarted = true;
        reset_map(true);
        Score_ClearAll();
@@ -444,7 +438,7 @@ void ReadyRestart_force()
        if (autocvar_sv_ready_restart_after_countdown)
        {
                entity restart_timer = new_pure(restart_timer);
-               restart_timer.think = ReadyRestart_think;
+               setthink(restart_timer, ReadyRestart_think);
                restart_timer.nextthink = game_starttime;
        }
 
index 29374036cf4c4d5e7007b1d261ef1e2166e73563..fd6bf729366cbe628798e20eaf3bcc01bc57cb2f 100644 (file)
@@ -130,7 +130,7 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 
 // WEAPONTODO
 .float autoswitch;
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
 void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire);
 void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire);
 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
@@ -408,7 +408,7 @@ const float ACTIVE_TOGGLE   = 3;
 
 void PlayerUseKey();
 
-USING(spawn_evalfunc_t, vector(entity player, entity spot, vector current));
+USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current));
 .spawn_evalfunc_t spawn_evalfunc;
 
 string modname;
index 675b794ecdb902b73e018f3ccaad6356e4feeb42..730dad620b2d8818eec2ad8ba7a8bd00eeebd504 100644 (file)
@@ -501,8 +501,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
        if(targ.killcount) { targ.killcount = 0; }
 }
 
-void Ice_Think()
-{SELFPARAM();
+void Ice_Think(entity this)
+{
        if(!STAT(FROZEN, self.owner) || self.owner.iceblock != self)
        {
                remove(self);
@@ -531,7 +531,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
        entity ice = new(ice);
        ice.owner = targ;
        ice.scale = targ.scale;
-       ice.think = Ice_Think;
+       setthink(ice, Ice_Think);
        ice.nextthink = time;
        ice.frame = floor(random() * 21); // ice model has 20 different looking frames
        setmodel(ice, MDL_ICE);
@@ -541,7 +541,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
        targ.iceblock = ice;
        targ.revival_time = 0;
 
-       WITHSELF(ice, Ice_Think());
+       WITHSELF(ice, Ice_Think(ice));
 
        RemoveGrapplingHook(targ);
 
@@ -577,7 +577,7 @@ void Unfreeze (entity targ)
 }
 
 void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+{
        float mirrordamage;
        float mirrorforce;
        float complainteamdamage = 0;
@@ -588,11 +588,10 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        if (gameover || targ.killcount == FRAGS_SPECTATOR)
                return;
 
-       setself(targ);
-        damage_targ = targ;
-        damage_inflictor = inflictor;
-        damage_attacker = attacker;
-               attacker_save = attacker;
+    damage_targ = targ;
+    damage_inflictor = inflictor;
+    damage_attacker = attacker;
+       attacker_save = attacker;
 
        if(IS_PLAYER(targ))
                if(targ.hook)
@@ -603,19 +602,17 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        // special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
        if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
        {
-               if(IS_PLAYER(targ))
-                       if(SAME_TEAM(targ, attacker))
-                       {
-                               setself(this);
-                               return;
-                       }
+               if(IS_PLAYER(targ) && SAME_TEAM(targ, attacker))
+               {
+                       return;
+               }
        }
 
        if(deathtype == DEATH_KILL.m_id || deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
        {
                // exit the vehicle before killing (fixes a crash)
                if(IS_PLAYER(targ) && targ.vehicle)
-                       vehicles_exit(VHEF_RELEASE);
+                       WITHSELF(targ, vehicles_exit(VHEF_RELEASE));
 
                // These are ALWAYS lethal
                // No damage modification here
@@ -726,37 +723,34 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                {
                        Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
 
-                       setself(targ);
-                       entity spot = SelectSpawnPoint (false);
+                       entity spot = SelectSpawnPoint (targ, false);
 
                        if(spot)
                        {
                                damage = 0;
-                               self.deadflag = DEAD_NO;
+                               targ.deadflag = DEAD_NO;
 
-                               self.angles = spot.angles;
+                               targ.angles = spot.angles;
 
-                               self.effects = 0;
-                               self.effects |= EF_TELEPORT_BIT;
+                               targ.effects = 0;
+                               targ.effects |= EF_TELEPORT_BIT;
 
-                               self.angles_z = 0; // never spawn tilted even if the spot says to
-                               self.fixangle = true; // turn this way immediately
-                               self.velocity = '0 0 0';
-                               self.avelocity = '0 0 0';
-                               self.punchangle = '0 0 0';
-                               self.punchvector = '0 0 0';
-                               self.oldvelocity = self.velocity;
+                               targ.angles_z = 0; // never spawn tilted even if the spot says to
+                               targ.fixangle = true; // turn this way immediately
+                               targ.velocity = '0 0 0';
+                               targ.avelocity = '0 0 0';
+                               targ.punchangle = '0 0 0';
+                               targ.punchvector = '0 0 0';
+                               targ.oldvelocity = targ.velocity;
 
-                               self.spawnorigin = spot.origin;
-                               setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
+                               targ.spawnorigin = spot.origin;
+                               setorigin (targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24));
                                // don't reset back to last position, even if new position is stuck in solid
-                               self.oldorigin = self.origin;
-                               self.prevorigin = self.origin;
+                               targ.oldorigin = targ.origin;
+                               targ.prevorigin = targ.origin;
 
-                               Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
+                               Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
                        }
-
-                       setself(this);
                }
 
                if(!g_instagib)
@@ -841,37 +835,36 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        }
 
        // apply push
-       if (self.damageforcescale)
+       if (targ.damageforcescale)
        if (vlen(force))
-       if (!IS_PLAYER(self) || time >= self.spawnshieldtime || self == attacker)
+       if (!IS_PLAYER(targ) || time >= targ.spawnshieldtime || targ == attacker)
        {
-               vector farce = damage_explosion_calcpush(self.damageforcescale * force, self.velocity, autocvar_g_balance_damagepush_speedfactor);
-               if(self.movetype == MOVETYPE_PHYSICS)
+               vector farce = damage_explosion_calcpush(targ.damageforcescale * force, targ.velocity, autocvar_g_balance_damagepush_speedfactor);
+               if(targ.movetype == MOVETYPE_PHYSICS)
                {
                        entity farcent = new(farce);
-                       farcent.enemy = self;
+                       farcent.enemy = targ;
                        farcent.movedir = farce * 10;
-                       if(self.mass)
-                               farcent.movedir = farcent.movedir * self.mass;
+                       if(targ.mass)
+                               farcent.movedir = farcent.movedir * targ.mass;
                        farcent.origin = hitloc;
                        farcent.forcetype = FORCETYPE_FORCEATPOS;
                        farcent.nextthink = time + 0.1;
-                       farcent.think = SUB_Remove_self;
+                       setthink(farcent, SUB_Remove);
                }
                else
                {
-                       self.velocity = self.velocity + farce;
-                       self.move_velocity = self.velocity;
+                       targ.velocity = targ.velocity + farce;
+                       targ.move_velocity = targ.velocity;
                }
-               UNSET_ONGROUND(self);
-               self.move_flags &= ~FL_ONGROUND;
-               UpdateCSQCProjectile(self);
+               UNSET_ONGROUND(targ);
+               targ.move_flags &= ~FL_ONGROUND;
+               UpdateCSQCProjectile(targ);
        }
        // apply damage
-       if (damage != 0 || (self.damageforcescale && vlen(force)))
-       if (self.event_damage)
-               self.event_damage (self, inflictor, attacker, damage, deathtype, hitloc, force);
-       setself(this);
+       if (damage != 0 || (targ.damageforcescale && vlen(force)))
+       if (targ.event_damage)
+               targ.event_damage (targ, inflictor, attacker, damage, deathtype, hitloc, force);
 
        // apply mirror damage if any
        if(!autocvar_g_mirrordamage_onlyweapons || DEATH_WEAPONOF(deathtype) != WEP_Null)
@@ -1099,7 +1092,7 @@ float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
                {
                        // print("adding a fire burner to ", e.classname, "\n");
                        e.fire_burner = new(fireburner);
-                       e.fire_burner.think = fireburner_think;
+                       setthink(e.fire_burner, fireburner_think);
                        e.fire_burner.nextthink = time;
                        e.fire_burner.owner = e;
                }
@@ -1258,8 +1251,8 @@ void Fire_ApplyEffect(entity e)
                e.effects &= ~EF_FLAME;
 }
 
-void fireburner_think()
-{SELFPARAM();
+void fireburner_think(entity this)
+{
        // for players, this is done in the regular loop
        if(wasfreed(self.owner))
        {
index ca5c45b9efd3c01282d965cd812abd15b64c8cb2..e2c5ea2b35d7a3f665df6a222cb9535e599c1c98 100644 (file)
@@ -80,7 +80,7 @@ float Obituary_WeaponDeath(
 
 void Obituary(entity attacker, entity inflictor, entity targ, int deathtype);
 
-void Ice_Think();
+void Ice_Think(entity this);
 
 void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypoint);
 
@@ -106,7 +106,7 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e
 .float fire_hitsound;
 .entity fire_burner;
 
-void fireburner_think();
+void fireburner_think(entity this);
 
 float Fire_IsBurning(entity e);
 
@@ -115,5 +115,3 @@ float Fire_AddDamage(entity e, entity o, float d, float t, float dt);
 void Fire_ApplyDamage(entity e);
 
 void Fire_ApplyEffect(entity e);
-
-void fireburner_think();
index 86fb14b29c997be7a56166fd57958a43b274c59f..1b5e22bee56ed4e0ccd44c6f86847be5f46557b9 100644 (file)
@@ -90,16 +90,16 @@ void GrapplingHookReset(entity this)
                remove(this);
 }
 
-void GrapplingHookThink();
+void GrapplingHookThink(entity this);
 void GrapplingHook_Stop()
 {SELFPARAM();
        Send_Effect(EFFECT_HOOK_IMPACT, self.origin, '0 0 0', 1);
        sound (self, CH_SHOTS, SND_HOOK_IMPACT, VOL_BASE, ATTEN_NORM);
 
        self.state = 1;
-       self.think = GrapplingHookThink;
+       setthink(self, GrapplingHookThink);
        self.nextthink = time;
-       self.touch = func_null;
+       settouch(self, func_null);
        self.velocity = '0 0 0';
        self.movetype = MOVETYPE_NONE;
        self.hook_length = -1;
@@ -134,8 +134,8 @@ bool GrapplingHookSend(entity this, entity to, int sf)
 
 int autocvar_g_grappling_hook_tarzan;
 
-void GrapplingHookThink()
-{SELFPARAM();
+void GrapplingHookThink(entity this)
+{
        float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch;
        vector dir, org, end, v0, dv, v, myorg, vs;
        if(self.realowner.hook != self) // how did that happen?
@@ -301,11 +301,11 @@ void GrapplingHookThink()
        }
 }
 
-void GrapplingHookTouch ()
-{SELFPARAM();
+void GrapplingHookTouch (entity this)
+{
        if(other.movetype == MOVETYPE_FOLLOW)
                return;
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        GrapplingHook_Stop();
 
@@ -385,8 +385,8 @@ void FireGrapplingHook ()
        missile.angles = vectoangles (missile.velocity);
        //missile.glow_color = 250; // 244, 250
        //missile.glow_size = 120;
-       missile.touch = GrapplingHookTouch;
-       missile.think = GrapplingHookThink;
+       settouch(missile, GrapplingHookTouch);
+       setthink(missile, GrapplingHookThink);
        missile.nextthink = time;
 
        missile.effects = /*EF_FULLBRIGHT | EF_ADDITIVE |*/ EF_LOWPRECISION;
index 352f0be430469aa3c10fa698918ee0f91b9f92dc..796af16b13e5efe2a1a0307d32a0dc34d1cf3102 100644 (file)
@@ -1,6 +1,6 @@
 #include "g_lights.qh"
 
-void train_next();
+void train_next(entity this);
 
 const float LOOP = 1;
 
@@ -34,9 +34,8 @@ flags:
 "NOSHADOW" will not cast shadows in realtime lighting mode
 "FOLLOW" will follow the entity which "targetname" matches "target"
 */
-void dynlight_think()
+void dynlight_think(entity this)
 {
-    SELFPARAM();
        if(!self.owner)
                remove(self);
 
@@ -55,7 +54,7 @@ void dynlight_find_aiment(entity this)
        self.punchangle = targ.angles;
        self.view_ofs = self.origin - targ.origin;
        self.v_angle = self.angles - targ.angles;
-       self.think = dynlight_think;
+       setthink(self, dynlight_think);
        self.nextthink = time + 0.1;
 }
 void dynlight_find_path(entity this)
@@ -67,7 +66,7 @@ void dynlight_find_path(entity this)
        targ = find(world, targetname, self.target);
        self.target = targ.target;
        setorigin (self, targ.origin);
-       self.think = train_next;
+       setthink(self, train_next);
        self.nextthink = time + 0.1;
 }
 void dynlight_find_target(entity this)
@@ -79,7 +78,7 @@ void dynlight_find_target(entity this)
        targ = find(world, targetname, self.target);
        setattachment(self, targ, self.dtagname);
        self.owner = targ;
-       self.think = dynlight_think;
+       setthink(self, dynlight_think);
        self.nextthink = time + 0.1;
 }
 void dynlight_use(entity this, entity actor, entity trigger)
@@ -91,43 +90,43 @@ void dynlight_use(entity this, entity actor, entity trigger)
 }
 spawnfunc(dynlight)
 {
-       if (!self.light_lev)
-               self.light_lev = 200;
-       if (!self.color)
-               self.color = '1 1 1';
-       self.lefty = self.light_lev;
-       self.use = dynlight_use;
-       setsize (self, '0 0 0', '0 0 0');
-       setorigin (self, self.origin);
-       //self.pflags = PFLAGS_FULLDYNAMIC;
-       self.solid = SOLID_NOT;
-       //self.blocked = func_null;
-       //if (self.spawnflags & DNOSHADOW)
-       //      self.pflags = self.pflags + PFLAGS_NOSHADOW;
-       //if (self.spawnflags & START_OFF)
-       //      self.light_lev = 0;
+       if (!this.light_lev)
+               this.light_lev = 200;
+       if (!this.color)
+               this.color = '1 1 1';
+       this.lefty = this.light_lev;
+       this.use = dynlight_use;
+       setsize (this, '0 0 0', '0 0 0');
+       setorigin (this, this.origin);
+       //this.pflags = PFLAGS_FULLDYNAMIC;
+       this.solid = SOLID_NOT;
+       //this.blocked = func_null;
+       //if (this.spawnflags & DNOSHADOW)
+       //      this.pflags = this.pflags + PFLAGS_NOSHADOW;
+       //if (this.spawnflags & START_OFF)
+       //      this.light_lev = 0;
 
 //tag attaching
-       if (self.dtagname)
+       if (this.dtagname)
        {
-               InitializeEntity(self, dynlight_find_target, INITPRIO_FINDTARGET);
+               InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET);
                return;
        }
 
 // entity following
-       if (self.spawnflags & DFOLLOW)
+       if (this.spawnflags & DFOLLOW)
        {
-               InitializeEntity(self, dynlight_find_aiment, INITPRIO_FINDTARGET);
+               InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET);
                return;
        }
 // path following
-       if (self.target)
-//     if (!(self.spawnflags & DFOLLOW))
+       if (this.target)
+//     if (!(this.spawnflags & DFOLLOW))
        {
-               self.movetype = MOVETYPE_NOCLIP;
-               if (!self.speed)
-                       self.speed = 100;
-               InitializeEntity(self, dynlight_find_path, INITPRIO_FINDTARGET);
+               this.movetype = MOVETYPE_NOCLIP;
+               if (!this.speed)
+                       this.speed = 100;
+               InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET);
                return;
        }
 }
index 6623a0778e7c41be3db9d3677dd696b19c8c2e96..363650ce8c097d9e710d68d0fea885bd4d8f870b 100644 (file)
@@ -53,42 +53,42 @@ void g_clientmodel_use(entity this, entity actor, entity trigger)
 
 void g_model_dropbyspawnflags(entity this)
 {
-       if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
+       if((this.spawnflags & 3) == 1) // ALIGN_ORIGIN
        {
-               traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
-               setorigin(self, trace_endpos);
+               traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+               setorigin(this, trace_endpos);
        }
-       else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
+       else if((this.spawnflags & 3) == 2) // ALIGN_BOTTOM
        {
-               tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
-               setorigin(self, trace_endpos);
+               tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+               setorigin(this, trace_endpos);
        }
-       else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
+       else if((this.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
        {
-               traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
-               setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
+               traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
+               setorigin(this, trace_endpos - '0 0 1' * this.mins.z);
        }
 }
 
 void g_clientmodel_dropbyspawnflags(entity this)
 {
        vector o0;
-       o0 = self.origin;
-       g_model_dropbyspawnflags(self);
-       if(self.origin != o0)
-               self.SendFlags |= 2;
+       o0 = this.origin;
+       g_model_dropbyspawnflags(this);
+       if(this.origin != o0)
+               this.SendFlags |= 2;
 }
 
 bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
 {
        sf = sf & 0x0F;
-       if(self.angles != '0 0 0')
+       if(this.angles != '0 0 0')
                sf |= 0x10;
-       if(self.mins != '0 0 0' || self.maxs != '0 0 0')
+       if(this.mins != '0 0 0' || this.maxs != '0 0 0')
                sf |= 0x20;
-       if(self.colormap != 0)
+       if(this.colormap != 0)
                sf |= 0x40;
-       if(self.lodmodelindex1)
+       if(this.lodmodelindex1)
                sf |= 0x80;
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
@@ -97,23 +97,23 @@ bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
        if(sf & BIT(0))
        {
                if(sf & 0x40)
-                       WriteShort(MSG_ENTITY, self.colormap);
+                       WriteShort(MSG_ENTITY, this.colormap);
        }
 
        if(sf & BIT(1))
        {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
+               WriteCoord(MSG_ENTITY, this.origin.x);
+               WriteCoord(MSG_ENTITY, this.origin.y);
+               WriteCoord(MSG_ENTITY, this.origin.z);
        }
 
        if(sf & BIT(2))
        {
                if(sf & 0x10)
                {
-                       WriteAngle(MSG_ENTITY, self.angles.x);
-                       WriteAngle(MSG_ENTITY, self.angles.y);
-                       WriteAngle(MSG_ENTITY, self.angles.z);
+                       WriteAngle(MSG_ENTITY, this.angles.x);
+                       WriteAngle(MSG_ENTITY, this.angles.y);
+                       WriteAngle(MSG_ENTITY, this.angles.z);
                }
        }
 
@@ -121,78 +121,78 @@ bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
        {
                if(sf & 0x80)
                {
-                       WriteShort(MSG_ENTITY, self.lodmodelindex0);
-                       WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
-                       WriteShort(MSG_ENTITY, self.lodmodelindex1);
-                       WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
-                       WriteShort(MSG_ENTITY, self.lodmodelindex2);
+                       WriteShort(MSG_ENTITY, this.lodmodelindex0);
+                       WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 65535));
+                       WriteShort(MSG_ENTITY, this.lodmodelindex1);
+                       WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 65535));
+                       WriteShort(MSG_ENTITY, this.lodmodelindex2);
                }
                else
-                       WriteShort(MSG_ENTITY, self.modelindex);
-               WriteByte(MSG_ENTITY, self.solid);
-               WriteShort(MSG_ENTITY, floor(self.scale * 256));
+                       WriteShort(MSG_ENTITY, this.modelindex);
+               WriteByte(MSG_ENTITY, this.solid);
+               WriteShort(MSG_ENTITY, floor(this.scale * 256));
                if(sf & 0x20)
                {
-                       WriteCoord(MSG_ENTITY, self.mins.x);
-                       WriteCoord(MSG_ENTITY, self.mins.y);
-                       WriteCoord(MSG_ENTITY, self.mins.z);
-                       WriteCoord(MSG_ENTITY, self.maxs.x);
-                       WriteCoord(MSG_ENTITY, self.maxs.y);
-                       WriteCoord(MSG_ENTITY, self.maxs.z);
+                       WriteCoord(MSG_ENTITY, this.mins.x);
+                       WriteCoord(MSG_ENTITY, this.mins.y);
+                       WriteCoord(MSG_ENTITY, this.mins.z);
+                       WriteCoord(MSG_ENTITY, this.maxs.x);
+                       WriteCoord(MSG_ENTITY, this.maxs.y);
+                       WriteCoord(MSG_ENTITY, this.maxs.z);
                }
-               WriteString(MSG_ENTITY, self.bgmscript);
-               if(self.bgmscript != "")
+               WriteString(MSG_ENTITY, this.bgmscript);
+               if(this.bgmscript != "")
                {
-                       WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
-                       WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
-                       WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
-                       WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
-                       WriteCoord(MSG_ENTITY, self.movedir.x);
-                       WriteCoord(MSG_ENTITY, self.movedir.y);
-                       WriteCoord(MSG_ENTITY, self.movedir.z);
-                       WriteByte(MSG_ENTITY, floor(self.lip * 255));
+                       WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64));
+                       WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64));
+                       WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255));
+                       WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64));
+                       WriteCoord(MSG_ENTITY, this.movedir.x);
+                       WriteCoord(MSG_ENTITY, this.movedir.y);
+                       WriteCoord(MSG_ENTITY, this.movedir.z);
+                       WriteByte(MSG_ENTITY, floor(this.lip * 255));
                }
-               WriteShort(MSG_ENTITY, self.fade_start);
-               WriteShort(MSG_ENTITY, self.fade_end);
-               WriteShort(MSG_ENTITY, self.alpha_max);
-               WriteShort(MSG_ENTITY, self.alpha_min);
-               WriteShort(MSG_ENTITY, self.inactive);
-               WriteShort(MSG_ENTITY, self.fade_vertical_offset);
+               WriteShort(MSG_ENTITY, this.fade_start);
+               WriteShort(MSG_ENTITY, this.fade_end);
+               WriteShort(MSG_ENTITY, this.alpha_max);
+               WriteShort(MSG_ENTITY, this.alpha_min);
+               WriteShort(MSG_ENTITY, this.inactive);
+               WriteShort(MSG_ENTITY, this.fade_vertical_offset);
        }
 
        return true;
 }
 
 
-#define G_MODEL_INIT(sol) \
-       if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
-       if(!self.scale) self.scale = self.modelscale; \
+#define G_MODEL_INIT(ent,sol) \
+       if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) ent.movetype = MOVETYPE_PHYSICS; \
+       if(!ent.scale) ent.scale = ent.modelscale; \
        SetBrushEntityModel(); \
-       self.use = g_model_setcolormaptoactivator; \
-       InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
-       if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
+       ent.use = g_model_setcolormaptoactivator; \
+       InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
+       if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT;
 
-#define G_CLIENTMODEL_INIT(sol) \
-       if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
-       if(!self.scale) self.scale = self.modelscale; \
+#define G_CLIENTMODEL_INIT(ent,sol) \
+       if(ent.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) ent.movetype = MOVETYPE_PHYSICS; \
+       if(!ent.scale) ent.scale = ent.modelscale; \
        SetBrushEntityModel(); \
-       self.use = g_clientmodel_use; \
-       InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
-       if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
-       if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
-       Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
-       self.default_solid = sol;
+       ent.use = g_clientmodel_use; \
+       InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
+       if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; \
+       if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1; else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0; \
+       Net_LinkEntity(ent, true, 0, g_clientmodel_genericsendentity); \
+       ent.default_solid = sol;
 
 // non-solid model entities:
-spawnfunc(misc_gamemodel)         { self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // model entity
-spawnfunc(misc_clientmodel)       { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
-spawnfunc(misc_models)            { self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
+spawnfunc(misc_gamemodel)         { this.angles_x = -this.angles.x; G_MODEL_INIT      (this, SOLID_NOT) } // model entity
+spawnfunc(misc_clientmodel)       { this.angles_x = -this.angles.x; G_CLIENTMODEL_INIT(this, SOLID_NOT) } // model entity
+spawnfunc(misc_models)            { this.angles_x = -this.angles.x; G_MODEL_INIT      (this, SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
 
 // non-solid brush entities:
-spawnfunc(func_illusionary)       { G_MODEL_INIT      (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
-spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
-spawnfunc(func_static)            { G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old alias name from some other game
+spawnfunc(func_illusionary)       { G_MODEL_INIT      (this, SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
+spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(this, SOLID_NOT) } // brush entity
+spawnfunc(func_static)            { G_MODEL_INIT      (this, SOLID_NOT) } // DEPRECATED old alias name from some other game
 
 // solid brush entities
-spawnfunc(func_wall)              { G_MODEL_INIT      (SOLID_BSP) } // Q1 name
-spawnfunc(func_clientwall)        { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
+spawnfunc(func_wall)              { G_MODEL_INIT      (this, SOLID_BSP) } // Q1 name
+spawnfunc(func_clientwall)        { G_CLIENTMODEL_INIT(this, SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
index a2cbc5a431e4d2fd9ad6bb3ed462ac9d4c5dffc5..cc4d2c60d69da5900d4b87113aa9f75fbdb459d3 100644 (file)
@@ -8,7 +8,7 @@
 
 spawnfunc(info_null)
 {
-       remove(self);
+       remove(this);
        // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
 }
 
@@ -434,17 +434,17 @@ void InitSolidBSPTrigger()
        self.model = "";
 }
 
-float InitMovingBrushTrigger()
-{SELFPARAM();
+bool InitMovingBrushTrigger(entity this)
+{
 // trigger angles are used for one-way touches.  An angle of 0 is assumed
 // to mean no restrictions, so use a yaw of 360 instead.
-       self.solid = SOLID_BSP;
-       SetBrushEntityModel();
-       self.movetype = MOVETYPE_PUSH;
-       if(self.modelindex == 0)
+       this.solid = SOLID_BSP;
+       WITHSELF(this, SetBrushEntityModel());
+       this.movetype = MOVETYPE_PUSH;
+       if(this.modelindex == 0)
        {
                objerror("InitMovingBrushTrigger: no brushes found!");
-               return 0;
+               return false;
        }
-       return 1;
+       return true;
 }
index dc8ffe8c0dc875a4004cd99b7a568f2334fdf437..1b785c2f284b6f59232519cbc2c0d87301a52447 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once
 
-void SUB_NullThink();
+void SUB_NullThink(entity this);
 
-void()  SUB_CalcMoveDone;
-void() SUB_CalcAngleMoveDone;
+void SUB_CalcMoveDone(entity this);
+void SUB_CalcAngleMoveDone(entity this);
 
 spawnfunc(info_null);
 
@@ -26,7 +26,7 @@ Makes client invisible or removes non-client
 */
 void SUB_VanishOrRemove (entity ent);
 
-void SUB_SetFade_Think ();
+void SUB_SetFade_Think (entity this);
 
 /*
 ==================
@@ -45,20 +45,20 @@ calculate self.velocity and self.nextthink to reach dest from
 self.origin traveling at speed
 ===============
 */
-void SUB_CalcMoveDone ();
+void SUB_CalcMoveDone(entity this);
 
 .float platmovetype_turn;
-void SUB_CalcMove_controller_think ();
+void SUB_CalcMove_controller_think (entity this);
 
 void SUB_CalcMove_controller_setbezier (entity controller, vector org, vector control, vector dest);
 
 void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector dest);
 
-void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func);
 
-void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void(entity this) func);
 
-void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func);
+void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func);
 
 /*
 =============
@@ -70,12 +70,12 @@ self.angles rotating
 The calling function should make sure self.think is valid
 ===============
 */
-void SUB_CalcAngleMoveDone ();
+void SUB_CalcAngleMoveDone (entity this);
 
 // FIXME: I fixed this function only for rotation around the main axes
-void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func);
+void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void(entity this) func);
 
-void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func);
+void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func);
 
 /*
 ==================
@@ -162,4 +162,4 @@ void InitTrigger();
 
 void InitSolidBSPTrigger();
 
-float InitMovingBrushTrigger();
+bool InitMovingBrushTrigger(entity this);
index 054e19d7466589c9ae0b3146843b9329d21157b9..9d67d334669faa4802778388bd797d63206479ab 100644 (file)
@@ -41,8 +41,8 @@ const float LATENCY_THINKRATE = 10;
 .float latency_cnt;
 .float latency_time;
 entity pingplreport;
-void PingPLReport_Think()
-{SELFPARAM();
+void PingPLReport_Think(entity this)
+{
        float delta;
        entity e;
 
@@ -82,7 +82,7 @@ void PingPLReport_Think()
 void PingPLReport_Spawn()
 {
        pingplreport = new_pure(pingplreport);
-       pingplreport.think = PingPLReport_Think;
+       setthink(pingplreport, PingPLReport_Think);
        pingplreport.nextthink = time;
 }
 
@@ -104,8 +104,8 @@ void SetDefaultAlpha()
        }
 }
 
-void GotoFirstMap()
-{SELFPARAM();
+void GotoFirstMap(entity this)
+{
        float n;
        if(autocvar__sv_init)
        {
@@ -515,20 +515,20 @@ bool RandomSeed_Send(entity this, entity to, int sf)
        WriteShort(MSG_ENTITY, this.cnt);
        return true;
 }
-void RandomSeed_Think()
-{SELFPARAM();
+void RandomSeed_Think(entity this)
+{
        this.cnt = bound(0, floor(random() * 65536), 65535);
        this.nextthink = time + 5;
 
        this.SendFlags |= 1;
 }
 void RandomSeed_Spawn()
-{SELFPARAM();
+{
        randomseed = new_pure(randomseed);
-       randomseed.think = RandomSeed_Think;
+       setthink(randomseed, RandomSeed_Think);
        Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
 
-       WITHSELF(randomseed, randomseed.think()); // sets random seed and nextthink
+       WITHSELF(randomseed, getthink(randomseed)(randomseed)); // sets random seed and nextthink
 }
 
 spawnfunc(__init_dedicated_server)
@@ -543,7 +543,7 @@ spawnfunc(__init_dedicated_server)
        remove = remove_unsafely;
 
        entity e = spawn();
-       e.think = GotoFirstMap;
+       setthink(e, GotoFirstMap);
        e.nextthink = time; // this is usually 1 at this point
 
        e = new(info_player_deathmatch);  // safeguard against player joining
@@ -923,7 +923,7 @@ spawnfunc(worldspawn)
 spawnfunc(light)
 {
        //makestatic (self); // Who the f___ did that?
-       remove(self);
+       remove(this);
 }
 
 string GetGametype()
@@ -1522,7 +1522,6 @@ only called if a time or frag limit has expired
 */
 void NextLevel()
 {
-    SELFPARAM();
        gameover = true;
 
        intermission_running = 1;
@@ -2026,7 +2025,7 @@ void EndFrame()
 float redirection_timeout;
 float redirection_nextthink;
 float RedirectionThink()
-{SELFPARAM();
+{
        float clients_found;
 
        if(redirection_target == "")
@@ -2049,13 +2048,12 @@ float RedirectionThink()
 
        clients_found = 0;
        FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
-               setself(it);
                // TODO add timer
-               LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
+               LOG_INFO("Redirecting: sending connect command to ", it.netname, "\n");
                if(redirection_target == "self")
-                       stuffcmd(self, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
+                       stuffcmd(it, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
                else
-                       stuffcmd(self, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
+                       stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
                ++clients_found;
        ));
 
index d129d994f4db575187797ec149ab315626cba43b..5de4c56a7e796260d04e69b812ba8f8ffc2320e9 100644 (file)
@@ -196,8 +196,8 @@ LABEL(skip)
        }
 }
 
-void OnlineBanList_Think()
-{SELFPARAM();
+void OnlineBanList_Think(entity this)
+{
        float argc;
        string uri;
        float i, n;
@@ -319,7 +319,7 @@ void Ban_LoadBans()
        }
 
        entity e = new(bansyncer);
-       e.think = OnlineBanList_Think;
+       setthink(e, OnlineBanList_Think);
        e.nextthink = time + 1;
 }
 
index 9688d51db107977f3e2fd42c6f8df036a33a6a81..bf389377f726e8fdf0b907d71883a7d7fd7b0dc0 100644 (file)
@@ -68,8 +68,8 @@ item_key
 /**
  * Key touch handler.
  */
-void item_key_touch()
-{SELFPARAM();
+void item_key_touch(entity this)
+{
        if (!IS_PLAYER(other))
                return;
 
@@ -91,38 +91,38 @@ void item_key_touch()
 /**
  * Spawn a key with given model, key code and color.
  */
-void spawn_item_key()
-{SELFPARAM();
-       precache_model(self.model);
+void spawn_item_key(entity this)
+{
+       precache_model(this.model);
 
-       if (self.spawnflags & 1) // FLOATING
-               self.noalign = 1;
+       if (this.spawnflags & 1) // FLOATING
+               this.noalign = 1;
 
-       if (self.noalign)
-               self.movetype = MOVETYPE_NONE;
+       if (this.noalign)
+               this.movetype = MOVETYPE_NONE;
        else
-               self.movetype = MOVETYPE_TOSS;
+               this.movetype = MOVETYPE_TOSS;
 
-       precache_sound(self.noise);
+       precache_sound(this.noise);
 
-       self.mdl = self.model;
-       self.effects = EF_LOWPRECISION;
-       _setmodel(self, self.model);
-       //setsize(self, '-16 -16 -24', '16 16 32');
-       setorigin(self, self.origin + '0 0 32');
-       setsize(self, '-16 -16 -56', '16 16 0');
-       self.modelflags |= MF_ROTATE;
-       self.solid = SOLID_TRIGGER;
+       this.mdl = this.model;
+       this.effects = EF_LOWPRECISION;
+       _setmodel(this, this.model);
+       //setsize(this, '-16 -16 -24', '16 16 32');
+       setorigin(this, this.origin + '0 0 32');
+       setsize(this, '-16 -16 -56', '16 16 0');
+       this.modelflags |= MF_ROTATE;
+       this.solid = SOLID_TRIGGER;
 
-       if (!self.noalign)
+       if (!this.noalign)
        {
                // first nudge it off the floor a little bit to avoid math errors
-               setorigin(self, self.origin + '0 0 1');
+               setorigin(this, this.origin + '0 0 1');
                // note droptofloor returns false if stuck/or would fall too far
-               droptofloor();
+               WITHSELF(this, droptofloor());
        }
 
-       self.touch = item_key_touch;
+       settouch(this, item_key_touch);
 };
 
 
@@ -158,14 +158,14 @@ spawnfunc(item_key)
        vector _colormod;
 
        // reject this entity if more than one key was set!
-       if (self.itemkeys>0 && (self.itemkeys & (self.itemkeys-1)) != 0) {
+       if (this.itemkeys>0 && (this.itemkeys & (this.itemkeys-1)) != 0) {
                objerror("item_key.itemkeys must contain only 1 bit set specifying the key it represents!");
-               remove(self);
+               remove(this);
                return;
        }
 
        // find default netname and colormod
-       switch(self.itemkeys) {
+       switch(this.itemkeys) {
        case BIT(0):
                _netname = "GOLD key";
                _colormod = '1 .9 0';
@@ -200,9 +200,9 @@ spawnfunc(item_key)
                _netname = "FLUFFY PINK keycard";
                _colormod = '1 1 1';
 
-               if (self.netname == "") {
+               if (this.netname == "") {
                        objerror("item_key doesn't have a default name for this key and a custom one was not specified!");
-                       remove(self);
+                       remove(this);
                        return;
                }
                break;
@@ -211,40 +211,40 @@ spawnfunc(item_key)
 
        // find default model
        string _model = string_null;
-       if (self.itemkeys <= ITEM_KEY_BIT(2)) {
+       if (this.itemkeys <= ITEM_KEY_BIT(2)) {
                _model = "models/keys/key.md3";
-       } else if (self.itemkeys >= ITEM_KEY_BIT(3) && self.itemkeys <= ITEM_KEY_BIT(5)) {
+       } else if (this.itemkeys >= ITEM_KEY_BIT(3) && this.itemkeys <= ITEM_KEY_BIT(5)) {
                _model = "models/keys/key.md3"; // FIXME: replace it by a keycard model!
-       } else if (self.model == "") {
+       } else if (this.model == "") {
                objerror("item_key doesn't have a default model for this key and a custom one was not specified!");
-               remove(self);
+               remove(this);
                return;
        }
 
        // set defailt netname
-       if (self.netname == "")
-               self.netname = _netname;
+       if (this.netname == "")
+               this.netname = _netname;
 
        // set default colormod
-       if (!self.colormod)
-               self.colormod = _colormod;
+       if (!this.colormod)
+               this.colormod = _colormod;
 
        // set default model
-       if (self.model == "")
-               self.model = _model;
+       if (this.model == "")
+               this.model = _model;
 
        // set default pickup message
-       if (self.message == "")
-               self.message = strzone(strcat("You've picked up the ", self.netname, "!"));
+       if (this.message == "")
+               this.message = strzone(strcat("You've picked up the ", this.netname, "!"));
 
-       if (self.noise == "")
-               self.noise = strzone(SND(ITEMPICKUP));
+       if (this.noise == "")
+               this.noise = strzone(SND(ITEMPICKUP));
 
        // save the name for later
-       item_keys_names[lowestbit(self.itemkeys)] = self.netname;
+       item_keys_names[lowestbit(this.itemkeys)] = this.netname;
 
        // put the key on the map
-       spawn_item_key();
+       spawn_item_key(this);
 }
 
 /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) FLOATING
index 95ec703dbd873ebfe51dfe838bf7bfbb533e4b60..3a918c27307763e07b213a42fb84c8a06b942d98 100644 (file)
@@ -958,26 +958,13 @@ void EliminatedPlayers_Init(float(entity) isEliminated_func)
 }
 
 
-void adaptor_think2touch()
-{SELFPARAM();
-    entity o;
-    o = other;
-    other = world;
-    self.touch();
-    other = o;
-}
 
-void adaptor_think2use()
-{SELFPARAM();
-       if(this.use)
-       this.use(this, NULL, NULL);
-}
 
-void adaptor_think2use_hittype_splash() // for timed projectile detonation
-{SELFPARAM();
+void adaptor_think2use_hittype_splash(entity this) // for timed projectile detonation
+{
        if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
                this.projectiledeathtype |= HITTYPE_SPLASH;
-       WITHSELF(this, adaptor_think2use());
+       WITHSELF(this, adaptor_think2use(this));
 }
 
 // deferred dropping
index 2e947f29db24ca9bae03343c332df2c69c97a2a2..2d52916b1736141a58c67b814882029f7c95494c 100644 (file)
@@ -116,15 +116,13 @@ void WarpZone_crosshair_trace(entity pl);
 
 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
 
-void adaptor_think2use();
-
 #define IS_DEAD(s) ((s).deadflag != DEAD_NO)
 
 
 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
 #define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id))
 
-#define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return
+#define PROJECTILE_TOUCH(this) MACRO_BEGIN if (WarpZone_Projectile_Touch(this)) return; MACRO_END
 
 #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
 
index 8039d8348f0108d497e21560491d95760560de86..ad97997e2f53c2f4c0d61900688d9a6416c6e84c 100644 (file)
@@ -126,10 +126,16 @@ string format_message;
 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
 
 /** returns true if throwing the current weapon shall not be allowed */
-MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidThrowCurrentWeapon(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon);
 
 /** returns true if dropping the current weapon shall not be allowed at any time including death */
-MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_NO_ARGS);
+#define EV_ForbidDropCurrentWeapon(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon);
 
 /**  */
 MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS);
@@ -189,7 +195,10 @@ bool ret_bool;
 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
 
 /** return error to prevent entity spawn, or modify the entity */
-MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_NO_ARGS);
+#define EV_OnEntityPreSpawn(i, o) \
+    /** turret */ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
 
 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
 MUTATOR_HOOKABLE(PlayerPreThink, EV_NO_ARGS);
index e7785c7d0a907e8e2d66f5c43eab081c19cd9b3b..47544dacde8a9a4365179e9fdf33306c2c4eea1c 100644 (file)
@@ -85,9 +85,9 @@ void assault_objective_use(entity this, entity actor, entity trigger)
        }
 }
 
-vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
-       if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
+vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
+       if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE)
                return '-1 0 0';
        return current;
 }
@@ -157,13 +157,9 @@ void assault_setenemytoobjective(entity this)
                objerror("no objective as target - fix the map!");
 }
 
-float assault_decreaser_sprite_visible(entity e)
-{SELFPARAM();
-       entity decreaser;
-
-       decreaser = self.assault_decreaser;
-
-       if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
+bool assault_decreaser_sprite_visible(entity this, entity player, entity view)
+{
+       if(this.assault_decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
                return false;
 
        return true;
@@ -229,7 +225,7 @@ void assault_roundstart_use(entity this, entity actor, entity trigger)
                        it.team = NUM_TEAM_1;
 
                // Dubbles as teamchange
-               WITHSELF(it, turret_respawn());
+               WITHSELF(it, turret_respawn(it));
        ));
 }
 void assault_roundstart_use_this(entity this)
@@ -242,8 +238,8 @@ void assault_roundstart_use_self()
     assault_roundstart_use(this, NULL, NULL);
 }
 
-void assault_wall_think()
-{SELFPARAM();
+void assault_wall_think(entity this)
+{
        if(self.enemy.health < 0)
        {
                self.model = "";
@@ -261,7 +257,7 @@ void assault_wall_think()
 // trigger new round
 // reset objectives, toggle spawnpoints, reset triggers, ...
 void vehicles_clearreturn(entity veh);
-void vehicles_spawn();
+void vehicles_spawn(entity this);
 void assault_new_round()
 {SELFPARAM();
        //bprint("ASSAULT: new round\n");
@@ -271,7 +267,7 @@ void assault_new_round()
 
     FOREACH_ENTITY_FLAGS(vehicle_flags, VHF_ISVEHICLE, LAMBDA(
         vehicles_clearreturn(it);
-        WITHSELF(it, vehicles_spawn());
+        WITHSELF(it, vehicles_spawn(it));
     ));
 
        // up round counter
@@ -297,7 +293,6 @@ void assault_new_round()
 // they win. Otherwise the defending team wins once the timelimit passes.
 int WinningCondition_Assault()
 {
-    SELFPARAM();
        WinningConditionHelper(); // set worldstatus
 
        int status = WINNING_NO;
@@ -406,7 +401,7 @@ spawnfunc(func_assault_wall)
        this.mdl = this.model;
        _setmodel(this, this.mdl);
        this.solid = SOLID_BSP;
-       this.think = assault_wall_think;
+       setthink(this, assault_wall_think);
        this.nextthink = time;
        InitializeEntity(this, assault_setenemytoobjective, INITPRIO_FINDTARGET);
 }
index 072fe90ddee9566093d39bd2de0577a8c7fdc3c1..8835d11a9cdaac326642cb9811bfb2986dd699af 100644 (file)
@@ -242,7 +242,6 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
 
 MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 {
-    SELFPARAM();
        FOREACH_CLIENT(true, {
                it.killcount = 0;
                if (!it.caplayer && IS_BOT_CLIENT(it))
index 702ff45743214da4efcfc61623802c22a9a1f611..bb949a49de9869fe87609336f36825dd23cf1f5b 100644 (file)
@@ -286,8 +286,8 @@ bool ctf_CaptureShield_Customize()
        return true;
 }
 
-void ctf_CaptureShield_Touch()
-{SELFPARAM();
+void ctf_CaptureShield_Touch(entity this)
+{
        if(!other.ctf_captureshielded) { return; }
        if(CTF_SAMETEAM(self, other)) { return; }
 
@@ -304,7 +304,7 @@ void ctf_CaptureShield_Spawn(entity flag)
 
        shield.enemy = self;
        shield.team = self.team;
-       shield.touch = ctf_CaptureShield_Touch;
+       settouch(shield, ctf_CaptureShield_Touch);
        shield.customizeentityforclient = ctf_CaptureShield_Customize;
        shield.effects = EF_ADDITIVE;
        shield.movetype = MOVETYPE_NOCLIP;
@@ -851,8 +851,8 @@ void ctf_FlagDamage(entity this, entity inflictor, entity attacker, float damage
        }
 }
 
-void ctf_FlagThink()
-{SELFPARAM();
+void ctf_FlagThink(entity this)
+{
        // declarations
        entity tmp_entity;
 
@@ -943,10 +943,8 @@ void ctf_FlagThink()
                                self.health = 0;
                                ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
 
-                               setself(self.owner);
-                               self.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
-                               ImpulseCommands(self);
-                               setself(this);
+                               self.owner.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
+                               ImpulseCommands(self.owner);
                        }
                        if(autocvar_g_ctf_stalemate)
                        {
@@ -1188,9 +1186,6 @@ void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map
 
 void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
 {
-       // declarations
-       setself(flag); // for later usage with droptofloor()
-
        // main setup
        flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
        ctf_worldflaglist = flag;
@@ -1216,8 +1211,8 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        flag.velocity = '0 0 0';
        flag.mangle = flag.angles;
        flag.reset = ctf_Reset;
-       flag.touch = ctf_FlagTouch;
-       flag.think = ctf_FlagThink;
+       settouch(flag, ctf_FlagTouch);
+       setthink(flag, ctf_FlagThink);
        flag.nextthink = time + FLAG_THINKRATE;
        flag.ctf_status = FLAG_BASE;
 
@@ -1290,8 +1285,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        else // drop to floor, automatically find a platform and set that as spawn origin
        {
                flag.noalign = false;
-               setself(flag);
-               droptofloor();
+               WITHSELF(flag, droptofloor());
                flag.movetype = MOVETYPE_TOSS;
        }
 
@@ -2421,9 +2415,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team1)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_1, self);
+       ctf_FlagSetup(NUM_TEAM_1, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2439,9 +2433,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team2)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_2, self);
+       ctf_FlagSetup(NUM_TEAM_2, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team3 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2457,9 +2451,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team3)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_3, self);
+       ctf_FlagSetup(NUM_TEAM_3, this);
 }
 
 /*QUAKED spawnfunc_item_flag_team4 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2475,9 +2469,9 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_team4)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       ctf_FlagSetup(NUM_TEAM_4, self);
+       ctf_FlagSetup(NUM_TEAM_4, this);
 }
 
 /*QUAKED spawnfunc_item_flag_neutral (0 0.5 0.8) (-48 -48 -37) (48 48 37)
@@ -2493,10 +2487,10 @@ Keys:
 "noise5" sound played when flag touches the ground... */
 spawnfunc(item_flag_neutral)
 {
-       if(!g_ctf) { remove(self); return; }
-       if(!cvar("g_ctf_oneflag")) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
+       if(!cvar("g_ctf_oneflag")) { remove(this); return; }
 
-       ctf_FlagSetup(0, self);
+       ctf_FlagSetup(0, this);
 }
 
 /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
@@ -2507,10 +2501,10 @@ Keys:
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 spawnfunc(ctf_team)
 {
-       if(!g_ctf) { remove(self); return; }
+       if(!g_ctf) { remove(this); return; }
 
-       self.classname = "ctf_team";
-       self.team = self.cnt + 1;
+       this.classname = "ctf_team";
+       this.team = this.cnt + 1;
 }
 
 // compatibility for quake maps
index c44dfc3743783e2062d77eb2ab370fae1b240099..95e0bcd424ded55bc032f93b0706baf02eb4f882 100644 (file)
@@ -20,7 +20,7 @@ CLASS(Flag, Pickup)
     ATTRIB(Flag, m_maxs, vector, PL_MAX_CONST + '0 0 -13')
 ENDCLASS(Flag)
 Flag CTF_FLAG; STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
-void ctf_FlagTouch() { SELFPARAM(); ITEM_HANDLE(Pickup, CTF_FLAG, this, other); }
+void ctf_FlagTouch(entity this) { ITEM_HANDLE(Pickup, CTF_FLAG, this, other); }
 
 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
 
index f05b53ce8cbc6998407f91ac71998a0d13c9a5bf..1584933063e2386780479cc319f9252fcaed254c 100644 (file)
@@ -96,12 +96,12 @@ void cts_EventLog(string mode, entity actor) // use an alias for easy changing a
                GameLogEcho(strcat(":cts:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
 }
 
-void KillIndicator_Think();
+void KillIndicator_Think(entity this);
 void CTS_ClientKill(entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed
 {
     e.killindicator = spawn();
     e.killindicator.owner = e;
-    e.killindicator.think = KillIndicator_Think;
+    setthink(e.killindicator, KillIndicator_Think);
     e.killindicator.nextthink = time + (e.lip) * 0.05;
     e.killindicator.cnt = ceil(autocvar_g_cts_finish_kill_delay);
     e.killindicator.health = 1; // this is used to indicate that it should be silent
@@ -214,7 +214,7 @@ MUTATOR_HOOKFUNCTION(cts, reset_map_global)
 
 MUTATOR_HOOKFUNCTION(cts, ClientConnect)
 {SELFPARAM();
-       race_PreparePlayer();
+       race_PreparePlayer(this);
        self.race_checkpoint = -1;
 
        if(IS_REAL_CLIENT(self))
@@ -246,7 +246,7 @@ MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver)
        else
                self.frags = FRAGS_SPECTATOR;
 
-       race_PreparePlayer();
+       race_PreparePlayer(this);
        self.race_checkpoint = -1;
 
        return false;
@@ -256,7 +256,7 @@ MUTATOR_HOOKFUNCTION(cts, PlayerSpawn)
 {SELFPARAM();
        if(spawn_spot.target == "")
                // Emergency: this wasn't a real spawnpoint. Can this ever happen?
-               race_PreparePlayer();
+               race_PreparePlayer(this);
 
        // if we need to respawn, do it right
        self.race_respawn_checkpoint = self.race_checkpoint;
@@ -273,9 +273,9 @@ MUTATOR_HOOKFUNCTION(cts, PutClientInServer)
        if(!gameover)
        {
                if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
-                       race_PreparePlayer();
+                       race_PreparePlayer(this);
                else // respawn
-                       race_RetractPlayer();
+                       race_RetractPlayer(this);
 
                race_AbandonRaceCheck(self);
        }
index 141837c260071c9e71f3ce928fb1a10d82a98b10..5514ed201b8c01eb1992f0b658725b87b90b4823 100644 (file)
@@ -207,8 +207,8 @@ void AnimateDomPoint()
                self.frame = 0;
 }
 
-void dompointthink()
-{SELFPARAM();
+void dompointthink(entity this)
+{
        float fragamt;
 
        self.nextthink = time + 0.1;
@@ -251,8 +251,8 @@ void dompointthink()
        }
 }
 
-void dompointtouch()
-{SELFPARAM();
+void dompointtouch(entity this)
+{
        entity head;
        if (!IS_PLAYER(other))
                return;
@@ -306,8 +306,6 @@ void dompointtouch()
        dompoint_captured();
 }
 
-void dom_controlpoint_setup(entity this);
-void dom_controlpoint_setup_self() { SELFPARAM(); dom_controlpoint_setup(this); }
 void dom_controlpoint_setup(entity this)
 {
        entity head;
@@ -350,9 +348,9 @@ void dom_controlpoint_setup(entity this)
        if(!self.t_length)
                self.t_length = 239; // maximum frame
 
-       self.think = dompointthink;
+       setthink(self, dompointthink);
        self.nextthink = time;
-       self.touch = dompointtouch;
+       settouch(self, dompointtouch);
        self.solid = SOLID_TRIGGER;
        self.flags = FL_ITEM;
        setsize(self, '-32 -32 -32', '32 32 32');
@@ -496,15 +494,14 @@ MUTATOR_HOOKFUNCTION(dom, GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(dom, reset_map_players)
-{SELFPARAM();
+{
        total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
-               setself(it);
-               PutClientInServer();
+               WITHSELF(it, PutClientInServer());
                if(domination_roundbased)
-                       self.player_blocked = 1;
-               if(IS_REAL_CLIENT(self))
-                       set_dom_state(self);
+                       it.player_blocked = 1;
+               if(IS_REAL_CLIENT(it))
+                       set_dom_state(it);
        ));
        return 1;
 }
@@ -538,19 +535,19 @@ spawnfunc(dom_controlpoint)
 {
        if(!g_domination)
        {
-               remove(self);
+               remove(this);
                return;
        }
-       self.think = dom_controlpoint_setup_self;
-       self.nextthink = time + 0.1;
-       self.reset = dom_controlpoint_setup;
+       setthink(this, dom_controlpoint_setup);
+       this.nextthink = time + 0.1;
+       this.reset = dom_controlpoint_setup;
 
-       if(!self.scale)
-               self.scale = 0.6;
+       if(!this.scale)
+               this.scale = 0.6;
 
-       self.effects = self.effects | EF_LOWPRECISION;
+       this.effects = this.effects | EF_LOWPRECISION;
        if (autocvar_g_domination_point_fullbright)
-               self.effects |= EF_FULLBRIGHT;
+               this.effects |= EF_FULLBRIGHT;
 }
 
 /*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32)
@@ -583,23 +580,23 @@ spawnfunc(dom_team)
 {
        if(!g_domination || autocvar_g_domination_teams_override >= 2)
        {
-               remove(self);
+               remove(this);
                return;
        }
-       precache_model(self.model);
-       if (self.noise != "")
-               precache_sound(self.noise);
-       if (self.noise1 != "")
-               precache_sound(self.noise1);
-       self.classname = "dom_team";
-       _setmodel(self, self.model); // precision not needed
-       self.mdl = self.model;
-       self.dmg = self.modelindex;
-       self.model = "";
-       self.modelindex = 0;
+       precache_model(this.model);
+       if (this.noise != "")
+               precache_sound(this.noise);
+       if (this.noise1 != "")
+               precache_sound(this.noise1);
+       this.classname = "dom_team";
+       _setmodel(this, this.model); // precision not needed
+       this.mdl = this.model;
+       this.dmg = this.modelindex;
+       this.model = "";
+       this.modelindex = 0;
        // this would have to be changed if used in quakeworld
-       if(self.cnt)
-               self.team = self.cnt + 1; // WHY are these different anyway?
+       if(this.cnt)
+               this.team = this.cnt + 1; // WHY are these different anyway?
 }
 
 // scoreboard setup
@@ -630,41 +627,37 @@ void ScoreRules_dom(float teams)
 
 // code from here on is just to support maps that don't have control point and team entities
 void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
-{SELFPARAM();
+{
     TC(Sound, capsound);
-       setself(spawn());
-       self.classname = "dom_team";
-       self.netname = strzone(teamname);
-       self.cnt = teamcolor;
-       self.model = pointmodel;
-       self.skin = pointskin;
-       self.noise = strzone(Sound_fixpath(capsound));
-       self.noise1 = strzone(capnarration);
-       self.message = strzone(capmessage);
+    entity e = new_pure(dom_team);
+       e.netname = strzone(teamname);
+       e.cnt = teamcolor;
+       e.model = pointmodel;
+       e.skin = pointskin;
+       e.noise = strzone(Sound_fixpath(capsound));
+       e.noise1 = strzone(capnarration);
+       e.message = strzone(capmessage);
 
        // this code is identical to spawnfunc_dom_team
-       _setmodel(self, self.model); // precision not needed
-       self.mdl = self.model;
-       self.dmg = self.modelindex;
-       self.model = "";
-       self.modelindex = 0;
+       _setmodel(e, e.model); // precision not needed
+       e.mdl = e.model;
+       e.dmg = e.modelindex;
+       e.model = "";
+       e.modelindex = 0;
        // this would have to be changed if used in quakeworld
-       self.team = self.cnt + 1;
+       e.team = e.cnt + 1;
 
-       //eprint(self);
-       setself(this);
+       //eprint(e);
 }
 
-void self_spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); }
 void dom_spawnpoint(vector org)
-{SELFPARAM();
-       setself(spawn());
-       self.classname = "dom_controlpoint";
-       self.think = self_spawnfunc_dom_controlpoint;
-       self.nextthink = time;
-       setorigin(self, org);
-       spawnfunc_dom_controlpoint(this);
-       setself(this);
+{
+       entity e = spawn();
+       e.classname = "dom_controlpoint";
+       setthink(e, spawnfunc_dom_controlpoint);
+       e.nextthink = time;
+       setorigin(e, org);
+       spawnfunc_dom_controlpoint(e);
 }
 
 // spawn some default teams if the map is not set up for domination
index f57661fba9617c1fb2d27683bdeb55e59eebeb4a..5e11666b856d5163bcd1f5e6b3a228ab55a2c53d 100644 (file)
@@ -375,7 +375,6 @@ MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver)
 
 MUTATOR_HOOKFUNCTION(ft, PlayerDies)
 {
-    SELFPARAM();
        if(round_handler_IsActive())
        if(round_handler_CountdownRunning())
        {
@@ -456,8 +455,7 @@ MUTATOR_HOOKFUNCTION(ft, reset_map_players)
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                it.killcount = 0;
                it.freezetag_frozen_timeout = -1;
-               setself(it);
-               PutClientInServer();
+               WITHSELF(it, PutClientInServer());
                it.freezetag_frozen_timeout = 0;
        ));
        freezetag_count_alive_players();
index e49bf3d546e2d726c3b3cff23075b19e2d268bf5..d3e40465c1376323c526c52193c83b8ecee32445 100644 (file)
@@ -77,13 +77,13 @@ float autocvar_g_invasion_spawn_delay;
 
 spawnfunc(invasion_spawnpoint)
 {
-       if(!g_invasion) { remove(self); return; }
+       if(!g_invasion) { remove(this); return; }
 
-       self.classname = "invasion_spawnpoint";
+       this.classname = "invasion_spawnpoint";
 
        if(autocvar_g_invasion_zombies_only) // precache only if it hasn't been already
-       if(self.monsterid) {
-               Monster mon = get_monsterinfo(self.monsterid);
+       if(this.monsterid) {
+               Monster mon = get_monsterinfo(this.monsterid);
                mon.mr_precache(mon);
        }
 }
@@ -141,7 +141,7 @@ void invasion_SpawnChosenMonster(float mon)
                        monster = spawnmonster("", mon, world, world, e.origin, false, false, 2);
                else return;
 
-               e.think = SUB_Remove_self;
+               setthink(e, SUB_Remove);
                e.nextthink = time + 0.1;
        }
        else
index a3960066c16c228dd1a30f9904a3a230cc0fee8c..22ae10f7c46810c17120a9ef73ba3b72ea61ca8e 100644 (file)
@@ -64,10 +64,10 @@ int autocvar_g_keepawayball_effects;
 float autocvar_g_keepawayball_respawntime;
 int autocvar_g_keepawayball_trail_color;
 
-float ka_ballcarrier_waypointsprite_visible_for_player(entity e) // runs on waypoints which are attached to ballcarriers, updates once per frame
+bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs on waypoints which are attached to ballcarriers, updates once per frame
 {
-       if(e.ballcarried)
-               if(IS_SPEC(other))
+       if(view.ballcarried)
+               if(IS_SPEC(player))
                        return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
 
        // TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup
@@ -81,7 +81,8 @@ void ka_EventLog(string mode, entity actor) // use an alias for easy changing an
                GameLogEcho(strcat(":ka:", mode, ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
 }
 
-void ka_TouchEvent();
+void ka_TouchEvent(entity this);
+void ka_RespawnBall(entity this);
 void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
 {
        if(gameover) { return; }
@@ -89,7 +90,7 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
 
        if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
        {
-               entity spot = SelectSpawnPoint(true);
+               entity spot = SelectSpawnPoint(this, true);
                setorigin(self, spot.origin);
                self.angles = spot.angles;
        }
@@ -99,7 +100,7 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
        self.velocity = '0 0 200';
        self.angles = '0 0 0';
        self.effects = autocvar_g_keepawayball_effects;
-       self.touch = ka_TouchEvent;
+       settouch(self, ka_TouchEvent);
        setthink(self, ka_RespawnBall);
        self.nextthink = time + autocvar_g_keepawayball_respawntime;
 
@@ -112,8 +113,8 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
        sound(self, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
 }
 
-void ka_TimeScoring()
-{SELFPARAM();
+void ka_TimeScoring(entity this)
+{
        if(self.owner.ballcarried)
        { // add points for holding the ball after a certain amount of time
                if(autocvar_g_keepaway_score_timepoints)
@@ -124,8 +125,8 @@ void ka_TimeScoring()
        }
 }
 
-void ka_TouchEvent() // runs any time that the ball comes in contact with something
-{SELFPARAM();
+void ka_TouchEvent(entity this) // runs any time that the ball comes in contact with something
+{
        if(gameover) { return; }
        if(!self) { return; }
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
@@ -153,8 +154,8 @@ void ka_TouchEvent() // runs any time that the ball comes in contact with someth
        self.velocity = '0 0 0';
        self.movetype = MOVETYPE_NONE;
        self.effects |= EF_NODRAW;
-       self.touch = func_null;
-       self.think = ka_TimeScoring;
+       settouch(self, func_null);
+       setthink(self, ka_TimeScoring);
        self.nextthink = time + autocvar_g_keepaway_score_timeinterval;
        self.takedamage = DAMAGE_NO;
 
@@ -192,7 +193,7 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
        setattachment(ball, world, "");
        ball.movetype = MOVETYPE_BOUNCE;
        ball.wait = time + 1;
-       ball.touch = ka_TouchEvent;
+       settouch(ball, ka_TouchEvent);
        setthink(ball, ka_RespawnBall);
        ball.nextthink = time + autocvar_g_keepawayball_respawntime;
        ball.takedamage = DAMAGE_YES;
@@ -231,7 +232,7 @@ void ka_Reset(entity this)
        if(time < game_starttime)
        {
                setthink(this, ka_RespawnBall);
-               this.touch = func_null;
+               settouch(this, func_null);
                this.nextthink = game_starttime;
        }
        else
@@ -478,7 +479,7 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star
        e.flags = FL_ITEM;
        e.pushable = true;
        e.reset = ka_Reset;
-       e.touch = ka_TouchEvent;
+       settouch(e, ka_TouchEvent);
        e.owner = world;
        ka_ball = e;
 
index e311f72c1303830f49535beda0c59b242c6eaa6e..4d65abf9e0b7a98ae7793cea950dc123750fc5dc 100644 (file)
@@ -157,22 +157,22 @@ void kh_ScoreRules(float teams)
        ScoreRules_basics_end();
 }
 
-float kh_KeyCarrier_waypointsprite_visible_for_player(entity e)  // runs all the time
-{SELFPARAM();
-       if(!IS_PLAYER(e) || DIFF_TEAM(self, e))
+bool kh_KeyCarrier_waypointsprite_visible_for_player(entity this, entity player, entity view)  // runs all the time
+{
+       if(!IS_PLAYER(view) || DIFF_TEAM(this, view))
                if(!kh_tracking_enabled)
                        return false;
 
        return true;
 }
 
-float kh_Key_waypointsprite_visible_for_player(entity e) // ??
-{SELFPARAM();
+bool kh_Key_waypointsprite_visible_for_player(entity this, entity player, entity view)
+{
        if(!kh_tracking_enabled)
                return false;
-       if(!self.owner)
+       if(!this.owner)
                return true;
-       if(!self.owner.owner)
+       if(!this.owner.owner)
                return true;
        return false;  // draw only when key is not owned
 }
@@ -215,12 +215,12 @@ void kh_Controller_SetThink(float t, kh_Think_t func)  // runs occasionaly
                kh_controller.nextthink = time; // force
 }
 void kh_WaitForPlayers();
-void kh_Controller_Think()  // called a lot
-{SELFPARAM();
+void kh_Controller_Think(entity this)  // called a lot
+{
        if(intermission_running)
                return;
        if(self.cnt > 0)
-       { if(self.think != kh_WaitForPlayers) { self.cnt -= 1; } }
+       { if(getthink(self) != kh_WaitForPlayers) { self.cnt -= 1; } }
        else if(self.cnt == 0)
        {
                self.cnt -= 1;
@@ -505,8 +505,8 @@ void kh_Key_Collect(entity key, entity player)  //a player picks up a dropped ke
        kh_Key_AssignTo(key, player); // this also updates .kh_state
 }
 
-void kh_Key_Touch()  // runs many, many times when a key has been dropped and can be picked up
-{SELFPARAM();
+void kh_Key_Touch(entity this)  // runs many, many times when a key has been dropped and can be picked up
+{
        if(intermission_running)
                return;
 
@@ -726,8 +726,8 @@ void kh_LoserTeam(float teem, entity lostkey)  // runs when a player pushes a fl
        kh_FinishRound();
 }
 
-void kh_Key_Think()  // runs all the time
-{SELFPARAM();
+void kh_Key_Think(entity this)  // runs all the time
+{
        if(intermission_running)
                return;
 
@@ -792,8 +792,8 @@ void kh_Key_Spawn(entity initial_owner, float _angle, float i)  // runs every ti
        entity key = spawn();
        key.count = i;
        key.classname = STR_ITEM_KH_KEY;
-       key.touch = kh_Key_Touch;
-       key.think = kh_Key_Think;
+       settouch(key, kh_Key_Touch);
+       setthink(key, kh_Key_Think);
        key.nextthink = time;
        key.items = IT_KEY1 | IT_KEY2;
        key.cnt = _angle;
@@ -1058,7 +1058,7 @@ void kh_Initialize()  // sets up th KH environment
 
        // make a KH entity for controlling the game
        kh_controller = spawn();
-       kh_controller.think = kh_Controller_Think;
+       setthink(kh_controller, kh_Controller_Think);
        kh_Controller_SetThink(0, kh_WaitForPlayers);
 
        setmodel(kh_controller, MDL_KH_KEY);
index 22850d8b8be9221dbae26169b3a2bed7a2632539..98eb9cdcf301fcc1b64c63578d69fc2a51d9235b 100644 (file)
@@ -298,8 +298,8 @@ MUTATOR_HOOKFUNCTION(lms, FilterItem)
        return true;
 }
 
-void lms_extralife()
-{SELFPARAM();
+void lms_extralife(entity this)
+{
        StartItem(this, ITEM_ExtraLife);
 }
 
@@ -312,7 +312,7 @@ MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
        if (self.classname != "item_health_mega") return false;
 
        entity e = spawn();
-       e.think = lms_extralife;
+       setthink(e, lms_extralife);
 
        e.nextthink = time + 0.1;
        e.spawnflags = self.spawnflags;
index 7b769e29ff152f193fd1573c09697da7dede3dd6..fc87ae9793ae29999bde64967800661c8eb6712f 100644 (file)
@@ -246,7 +246,7 @@ MUTATOR_HOOKFUNCTION(rc, reset_map_global)
 
 MUTATOR_HOOKFUNCTION(rc, ClientConnect)
 {SELFPARAM();
-       race_PreparePlayer();
+       race_PreparePlayer(this);
        self.race_checkpoint = -1;
 
        string rr = RACE_RECORD;
@@ -279,7 +279,7 @@ MUTATOR_HOOKFUNCTION(rc, MakePlayerObserver)
        else
                self.frags = FRAGS_SPECTATOR;
 
-       race_PreparePlayer();
+       race_PreparePlayer(this);
        self.race_checkpoint = -1;
 
        return false;
@@ -289,7 +289,7 @@ MUTATOR_HOOKFUNCTION(rc, PlayerSpawn)
 {SELFPARAM();
        if(spawn_spot.target == "")
                // Emergency: this wasn't a real spawnpoint. Can this ever happen?
-               race_PreparePlayer();
+               race_PreparePlayer(this);
 
        // if we need to respawn, do it right
        self.race_respawn_checkpoint = self.race_checkpoint;
@@ -306,9 +306,9 @@ MUTATOR_HOOKFUNCTION(rc, PutClientInServer)
        if(!gameover)
        {
                if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
-                       race_PreparePlayer();
+                       race_PreparePlayer(this);
                else // respawn
-                       race_RetractPlayer();
+                       race_RetractPlayer(this);
 
                race_AbandonRaceCheck(self);
        }
index 6c22a8e198fceaace9cf96812449f5d216a19497..d391f11b23c6232d72ac6640e5d144167bd31cc8 100644 (file)
@@ -51,10 +51,10 @@ Keys:
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 spawnfunc(tdm_team)
 {
-       if(!g_tdm || !self.cnt) { remove(self); return; }
+       if(!g_tdm || !this.cnt) { remove(this); return; }
 
-       self.classname = "tdm_team";
-       self.team = self.cnt + 1;
+       this.classname = "tdm_team";
+       this.team = this.cnt + 1;
 }
 
 // code from here on is just to support maps that don't have team entities
index 16f31e6efb691d56ec288327da5b6b5844fa867f..09b81724ec1168ac49046317fb873c9c18e06f85 100644 (file)
@@ -23,32 +23,32 @@ void pathlib_showpath(entity start)
     }
 }
 
-void path_dbg_think()
-{SELFPARAM();
-    pathlib_showpath(self);
-    self.nextthink = time + 1;
+void path_dbg_think(entity this)
+{
+    pathlib_showpath(this);
+    this.nextthink = time + 1;
 }
 
-void __showpath2_think()
-{SELFPARAM();
+void __showpath2_think(entity this)
+{
     #ifdef TURRET_DEBUG
        mark_info(self.origin,1);
        #endif
     if(self.path_next)
     {
-        self.path_next.think     = __showpath2_think;
+        setthink(self.path_next, __showpath2_think);
         self.path_next.nextthink = time + 0.15;
     }
     else
     {
-        self.owner.think     = __showpath2_think;
+        setthink(self.owner, __showpath2_think);
         self.owner.nextthink = time + 0.15;
     }
 }
 
 void pathlib_showpath2(entity path)
 {
-    path.think     = __showpath2_think;
+    setthink(path, __showpath2_think);
     path.nextthink = time;
 }
 
@@ -82,7 +82,7 @@ void pathlib_showsquare(vector where,float goodsquare,float _lifetime)
 
     s           = spawn();
     s.alpha     = 0.25;
-    s.think     = SUB_Remove_self;
+    setthink(s, SUB_Remove);
     s.nextthink = _lifetime;
     s.scale     = pathlib_gridsize / 512.001;
     s.solid     = SOLID_NOT;
@@ -107,7 +107,7 @@ void pathlib_showedge(vector where,float _lifetime,float rot)
 
     e           = spawn();
     e.alpha     = 0.25;
-    e.think     = SUB_Remove_self;
+    setthink(e, SUB_Remove);
     e.nextthink = _lifetime;
     e.scale     = pathlib_gridsize / 512;
     e.solid     = SOLID_NOT;
index 972c09c9782ce7372742ca9176d9f444105a6d97..700ba41c0e10ed9d7b203467d3d86f96288e4479 100644 (file)
@@ -102,7 +102,7 @@ float pathlib_expandnode_star(entity node, vector start, vector goal)
     r = PLIB_RIGHT   * pathlib_gridsize;
 
     if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
-        node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
+        node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
 
     if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
     {
index d0c70b2b88dff8e9ec43c838c5f2b7dc4eb9907b..c033f3f52a6c4f9955becffb46ba20d4aed9e5a6 100644 (file)
@@ -11,7 +11,7 @@ void pathlib_deletepath(entity start)
     e = findchainentity(owner, start);
     while(e)
     {
-        e.think = SUB_Remove_self;
+        setthink(e, SUB_Remove);
         e.nextthink = time;
         e = e.chain;
     }
@@ -23,7 +23,7 @@ const float PATHLIB_NODEEXPIRE = 20;
 void dumpnode(entity n)
 {
     n.is_path_node = false;
-    n.think        = SUB_Remove_self;
+    setthink(n, SUB_Remove);
     n.nextthink    = time;
 }
 
@@ -49,7 +49,7 @@ entity pathlib_mknode(vector where,entity parent)
 
     node = spawn();
 
-    node.think        = SUB_Remove_self;
+    setthink(node, SUB_Remove);
     node.nextthink    = time + PATHLIB_NODEEXPIRE;
     node.is_path_node = true;
     node.owner        = openlist;
@@ -133,7 +133,7 @@ float pathlib_makenode_adaptive(entity parent,vector start, vector to, vector go
         return 1;
     }
 
-    where = pathlib_movenode(parent.origin, to, 0);
+    where = pathlib_movenode(parent, parent.origin, to, 0);
 
     if (!pathlib_movenode_goodnode)
     {
@@ -155,7 +155,7 @@ float pathlib_makenode_adaptive(entity parent,vector start, vector to, vector go
 
 
     if(doedge)
-        if (!tile_check(where))
+        if (!tile_check(parent, where))
         {
             LOG_TRACE("tile_check fail\n");
 #if DEBUGPATHING
@@ -180,7 +180,7 @@ float pathlib_makenode_adaptive(entity parent,vector start, vector to, vector go
             {
                 if(node.pathlib_node_g > g)
                 {
-                    //pathlib_movenode(where,node.origin,0);
+                    //pathlib_movenode(node, where,node.origin,0);
                     //if(pathlib_movenode_goodnode)
                     //{
                         //mark_error(node.origin + '0 0 128',30);
@@ -263,11 +263,11 @@ void pathlib_close_node(entity node,vector goal)
 
     node.owner = closedlist;
 
-    if(vlen(node.origin - goal) <= pathlib_gridsize)
+    if(vdist(node.origin - goal, <=, pathlib_gridsize))
     {
         vector goalmove;
 
-        goalmove = pathlib_walknode(node.origin,goal,1);
+        goalmove = pathlib_walknode(node, node.origin, goal, 1);
         if(pathlib_movenode_goodnode)
         {
             goal_node         = node;
@@ -336,9 +336,9 @@ float buildpath_nodefilter_directional(vector n,vector c,vector p)
     return 0;
 }
 
-float buildpath_nodefilter_moveskip(vector n,vector c,vector p)
+float buildpath_nodefilter_moveskip(entity this, vector n,vector c,vector p)
 {
-    pathlib_walknode(p,n,1);
+    pathlib_walknode(this, p, n, 1);
     if(pathlib_movenode_goodnode)
         return 1;
 
@@ -379,8 +379,8 @@ entity path_build(entity next, vector where, entity prev, entity start)
     return path;
 }
 
-entity pathlib_astar(vector from,vector to)
-{SELFPARAM();
+entity pathlib_astar(entity this, vector from,vector to)
+{
     entity path, start, end, open, n, ln;
     float ptime, ftime, ctime;
 
@@ -442,8 +442,8 @@ entity pathlib_astar(vector from,vector to)
     pathlib_movecost_waterfactor = 25000000;
     pathlib_foundgoal      = 0;
 
-    movenode_boxmax   = self.maxs * 1.1;
-    movenode_boxmin   = self.mins * 1.1;
+    movenode_boxmax   = this.maxs * 1.1;
+    movenode_boxmin   = this.mins * 1.1;
 
     movenode_stepsize = pathlib_gridsize * 0.25;
 
index d1a4e68dff095c1e00019ecb4fbb740c355b936b..52d0005a1efb583aa51887f2da9605918f7e5954 100644 (file)
@@ -5,8 +5,8 @@
 
 .vector        pos1, pos2;
 
-vector pathlib_wateroutnode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
+{
     vector surface;
 
     pathlib_movenode_goodnode = 0;
@@ -14,7 +14,7 @@ vector pathlib_wateroutnode(vector start,vector end, float doedge)
     end.x = fsnap(end.x, pathlib_gridsize);
     end.y = fsnap(end.y, pathlib_gridsize);
 
-    traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,self);
+    traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
     end = trace_endpos;
 
     if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
@@ -29,7 +29,7 @@ vector pathlib_wateroutnode(vector start,vector end, float doedge)
     if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
         return end;
 
-    tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, self);
+    tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
     if(trace_fraction == 1)
         pathlib_movenode_goodnode = 1;
 
@@ -39,8 +39,8 @@ vector pathlib_wateroutnode(vector start,vector end, float doedge)
     return end;
 }
 
-vector pathlib_swimnode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
+{
     pathlib_movenode_goodnode = 0;
 
     if(pointcontents(start) != CONTENT_WATER)
@@ -50,40 +50,40 @@ vector pathlib_swimnode(vector start,vector end, float doedge)
     end.y = fsnap(end.y, pathlib_gridsize);
 
     if(pointcontents(end) == CONTENT_EMPTY)
-        return pathlib_wateroutnode( start, end, doedge);
+        return pathlib_wateroutnode(this, start, end, doedge);
 
-    tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
+    tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
     if(trace_fraction == 1)
         pathlib_movenode_goodnode = 1;
 
     return end;
 }
 
-vector pathlib_flynode(vector start,vector end, float doedge)
-{SELFPARAM();
+vector pathlib_flynode(entity this, vector start, vector end, float doedge)
+{
     pathlib_movenode_goodnode = 0;
 
     end.x = fsnap(end.x, pathlib_gridsize);
     end.y = fsnap(end.y, pathlib_gridsize);
 
-    tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
+    tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
     if(trace_fraction == 1)
         pathlib_movenode_goodnode = 1;
 
     return end;
 }
 
-void a_think()
-{SELFPARAM();
-    te_lightning1(self,self.origin, self.pos1);
-    if(self.cnt < time)
-        remove(self);
+void a_think(entity this)
+{
+    te_lightning1(this,this.origin, this.pos1);
+    if(this.cnt < time)
+        remove(this);
     else
-        self.nextthink = time + 0.2;
+        this.nextthink = time + 0.2;
 }
 
-vector pathlib_walknode(vector start,vector end,float doedge)
-{SELFPARAM();
+vector pathlib_walknode(entity this, vector start, vector end, float doedge)
+{
     vector direction,point,last_point,s,e;
     float steps, distance, i;
 
@@ -97,12 +97,12 @@ vector pathlib_walknode(vector start,vector end,float doedge)
     start.y = fsnap(start.y,pathlib_gridsize);
 
     // Find the floor
-    traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, self);
+    traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
     if(trace_fraction == 1.0)
     {
         entity a;
         a = spawn();
-        a.think = a_think;
+        setthink(a, a_think);
         a.nextthink = time;
         setorigin(a,start + movenode_stepup);
         a.pos1 = trace_endpos;
@@ -127,7 +127,7 @@ vector pathlib_walknode(vector start,vector end,float doedge)
     for(i = 1; i < steps; ++i)
     {
         point = last_point + (direction * movenode_stepsize);
-        traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,self);
+        traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
         if(trace_fraction == 1.0)
             return trace_endpos;
 
@@ -141,13 +141,13 @@ vector pathlib_walknode(vector start,vector end,float doedge)
     //dprint("end_x:  ",ftos(end_x),  "  end_y:  ",ftos(end_y),"\n");
     //dprint("point_x:",ftos(point_x),"  point_y:",ftos(point_y),"\n\n");
 
-    traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,self);
+    traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
     if(trace_fraction == 1.0)
         return trace_endpos;
 
     last_point = trace_endpos;
 
-    tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, self);
+    tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
     if(trace_fraction != 1.0)
         return trace_endpos;
 
index 849514c37c8d975a4a7d71378a5ee59a0ce87fc4..f86c270b04b3e32ad6ff14294190983f7e7ca699 100644 (file)
@@ -234,18 +234,18 @@ entity pathlib_waypointpath_step()
 
     return world;
 }
-void plas_think()
-{SELFPARAM();
+void plas_think(entity this)
+{
     pathlib_waypointpath_step();
     if(pathlib_foundgoal)
         return;
-    self.nextthink = time + 0.1;
+    this.nextthink = time + 0.1;
 }
 
 void pathlib_waypointpath_autostep()
 {
     entity n;
     n = spawn();
-    n.think = plas_think;
+    setthink(n, plas_think);
     n.nextthink = time + 0.1;
 }
index 7364440240e719e51afcbeaab3f9e5f41c36d32f..a5f36da4a349d0059bfdc7846e98409847951b52 100644 (file)
@@ -63,10 +63,10 @@ entity best_open_node;
 vector tile_check_up;
 vector tile_check_down;
 float  tile_check_size;
-float     tile_check_cross(vector where);
-float     tile_check_plus(vector where);
-float     tile_check_star(vector where);
-var float tile_check(vector where);
+float     tile_check_cross(entity this, vector where);
+float     tile_check_plus(entity this, vector where);
+float     tile_check_star(entity this, vector where);
+var float tile_check(entity this, vector where);
 
 float  movenode_stepsize;
 vector movenode_stepup;
@@ -76,11 +76,11 @@ vector movenode_boxmax;
 vector movenode_boxmin;
 float  pathlib_movenode_goodnode;
 
-vector     pathlib_wateroutnode(vector start, vector end, float doedge);
-vector     pathlib_swimnode(vector start, vector end, float doedge);
-vector     pathlib_flynode(vector start, vector end, float doedge);
-vector     pathlib_walknode(vector start, vector end, float doedge);
-var vector pathlib_movenode(vector start, vector end, float doedge);
+vector     pathlib_wateroutnode(entity this, vector start, vector end, float doedge);
+vector     pathlib_swimnode(entity this, vector start, vector end, float doedge);
+vector     pathlib_flynode(entity this, vector start, vector end, float doedge);
+vector     pathlib_walknode(entity this, vector start, vector end, float doedge);
+var vector pathlib_movenode(entity this, vector start, vector end, float doedge);
 
 float      pathlib_expandnode_star(entity node, vector start, vector goal);
 float      pathlib_expandnode_box(entity node, vector start, vector goal);
index 9028f85e4f8be3ab4d65a21656634151522ecb4f..979b227b20096d0a23488112b2f49ddbbcb2a355 100644 (file)
@@ -71,8 +71,8 @@ entity pathlib_nodeatpoint(vector where)
     return world;
 }
 
-float tile_check_cross(vector where)
-{SELFPARAM();
+float tile_check_cross(entity this, vector where)
+{
     vector p,f,r;
 
     f = PLIB_FORWARD * tile_check_size;
@@ -81,33 +81,33 @@ float tile_check_cross(vector where)
 
     // forward-right
     p = where + f + r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (!location_isok(trace_endpos, 1, 0))
         return 0;
 
     // Forward-left
     p = where + f - r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (!location_isok(trace_endpos, 1, 0))
         return 0;
 
     // Back-right
     p = where - f + r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (!location_isok(trace_endpos, 1 ,0))
         return 0;
 
     //Back-left
     p = where - f - r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (!location_isok(trace_endpos, 1, 0))
         return 0;
 
     return 1;
 }
 
-float tile_check_plus(vector where)
-{SELFPARAM();
+float tile_check_plus(entity this, vector where)
+{
     vector p,f,r;
 
     f = PLIB_FORWARD * tile_check_size;
@@ -115,34 +115,34 @@ float tile_check_plus(vector where)
 
     // forward
     p = where + f;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (!location_isok(trace_endpos,1,0))
         return 0;
 
 
     //left
     p = where - r;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (!location_isok(trace_endpos,1,0))
         return 0;
 
     // Right
     p = where + r;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (!location_isok(trace_endpos,1,0))
         return 0;
 
     //Back
     p = where - f;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (!location_isok(trace_endpos,1,0))
         return 0;
 
     return 1;
 }
 
-float tile_check_plus2(vector where)
-{SELFPARAM();
+float tile_check_plus2(entity this, vector where)
+{
     vector p,f,r;
     float i = 0, e = 0;
 
@@ -156,7 +156,7 @@ float tile_check_plus2(vector where)
 
     // forward
     p = where + f;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (location_isok(trace_endpos,1,0))
     {
        ++i;
@@ -166,7 +166,7 @@ float tile_check_plus2(vector where)
 
     //left
     p = where - r;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (location_isok(trace_endpos,1,0))
     {
        ++i;
@@ -176,7 +176,7 @@ float tile_check_plus2(vector where)
 
     // Right
     p = where + r;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (location_isok(trace_endpos,1,0))
     {
        ++i;
@@ -185,7 +185,7 @@ float tile_check_plus2(vector where)
 
     //Back
     p = where - f;
-    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
+    traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
     if (location_isok(trace_endpos,1,0))
     {
        ++i;
@@ -194,7 +194,7 @@ float tile_check_plus2(vector where)
 
     // forward-right
     p = where + f + r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (location_isok(trace_endpos, 1, 0))
     {
        ++i;
@@ -203,7 +203,7 @@ float tile_check_plus2(vector where)
 
     // Forward-left
     p = where + f - r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (location_isok(trace_endpos, 1, 0))
     {
        ++i;
@@ -212,7 +212,7 @@ float tile_check_plus2(vector where)
 
     // Back-right
     p = where - f + r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (location_isok(trace_endpos, 1 ,0))
     {
        ++i;
@@ -221,7 +221,7 @@ float tile_check_plus2(vector where)
 
     //Back-left
     p = where - f - r;
-    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
+    traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
     if (location_isok(trace_endpos, 1, 0))
     {
        ++i;
@@ -235,10 +235,10 @@ float tile_check_plus2(vector where)
     return e;
 }
 
-float tile_check_star(vector where)
+float tile_check_star(entity this, vector where)
 {
-    if(tile_check_plus(where))
-        return tile_check_cross(where);
+    if(tile_check_plus(this, where))
+        return tile_check_cross(this, where);
 
     return 0;
 }
index 3544e86ca2b659125a3a99a3bfef5dab008e9f07..da4ace73e5bd14c56c9634d4753b2588595bb390 100644 (file)
@@ -2,4 +2,4 @@
 
 float fsnap(float val,float fsize);
 entity pathlib_nodeatpoint(vector where);
-float tile_check_plus2(vector where);
+float tile_check_plus2(entity this, vector where);
index 9f3fd6d28f952db4ffa59fb5983e605825cfb5a7..3a01cb0756d93fbae542494e99e49948d6677783 100644 (file)
@@ -17,33 +17,33 @@ void playerdemo_init(entity this)
 {
        this.playerdemo_mode = PLAYERDEMO_MODE_OFF;
 }
-void playerdemo_shutdown()
-{SELFPARAM();
-       if(self.playerdemo_mode != PLAYERDEMO_MODE_OFF)
+void playerdemo_shutdown(entity this)
+{
+       if(this.playerdemo_mode != PLAYERDEMO_MODE_OFF)
        {
-               LOG_INFO("playerdemo: ", self.netname, " closed\n");
-               fclose(self.playerdemo_fh);
+               LOG_INFO("playerdemo: ", this.netname, " closed\n");
+               fclose(this.playerdemo_fh);
        }
-       self.playerdemo_mode = 0;
+       this.playerdemo_mode = 0;
 }
-void playerdemo_open_read(string f)
-{SELFPARAM();
-       playerdemo_shutdown();
-       self.playerdemo_mode = PLAYERDEMO_MODE_READING;
-       self.playerdemo_fh = fopen(f, FILE_READ);
-       self.playerdemo_starttime = time - 1;
-       self.playerdemo_time = stof(fgets(self.playerdemo_fh));
-       self.playerdemo_time += self.playerdemo_starttime;
-       self.movetype = MOVETYPE_NONE;
-       LOG_INFO("playerdemo: ", self.netname, " reading from ", f, "\n");
-}
-void playerdemo_open_write(string f)
-{SELFPARAM();
-       playerdemo_shutdown();
-       self.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
-       self.playerdemo_fh = fopen(f, FILE_WRITE);
-       self.playerdemo_starttime = time - 1;
-       LOG_INFO("playerdemo: ", self.netname, " writing to ", f, "\n");
+void playerdemo_open_read(entity this, string f)
+{
+       playerdemo_shutdown(this);
+       this.playerdemo_mode = PLAYERDEMO_MODE_READING;
+       this.playerdemo_fh = fopen(f, FILE_READ);
+       this.playerdemo_starttime = time - 1;
+       this.playerdemo_time = stof(fgets(this.playerdemo_fh));
+       this.playerdemo_time += this.playerdemo_starttime;
+       this.movetype = MOVETYPE_NONE;
+       LOG_INFO("playerdemo: ", this.netname, " reading from ", f, "\n");
+}
+void playerdemo_open_write(entity this, string f)
+{
+       playerdemo_shutdown(this);
+       this.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
+       this.playerdemo_fh = fopen(f, FILE_WRITE);
+       this.playerdemo_starttime = time - 1;
+       LOG_INFO("playerdemo: ", this.netname, " writing to ", f, "\n");
        LOG_INFO("WARNING: playerdemo file format is incomplete and not stable yet. DO NOT RELY ON IT!\n");
 }
 #define PLAYERDEMO_FIELD(func,t,f) func##t(f,#f);
index 0fd42dca6b24257fad827cae16124d3edc8156cc..c44f414f97e18e39a6e32575c444f113b00150bd 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once
 
 void playerdemo_init(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
 void playerdemo_write();
 float playerdemo_read(entity this);
 
-void playerdemo_open_read(string f);
-void playerdemo_open_write(string f);
+void playerdemo_open_read(entity this, string f);
+void playerdemo_open_write(entity this, string f);
index e3cba938335f83b3752732db2bdbe7f8bebe95a1..f0728b720084d011d909ce684835f2fb1c5aacd8 100644 (file)
@@ -249,13 +249,13 @@ float Portal_WillHitPlane(vector eorg, vector emins, vector emaxs, vector evel,
 #endif
 }
 
-void Portal_Touch()
-{SELFPARAM();
+void Portal_Touch(entity this)
+{
        vector g;
 
 #ifdef PORTALS_ARE_NOT_SOLID
        // portal is being removed?
-       if(self.solid != SOLID_TRIGGER)
+       if(this.solid != SOLID_TRIGGER)
                return; // possibly engine bug
 
        if(IS_PLAYER(other))
@@ -272,7 +272,7 @@ void Portal_Touch()
        if(other.vehicle_flags & VHF_ISVEHICLE)
                return; // no teleporting vehicles?
 
-       if(!self.enemy)
+       if(!this.enemy)
                error("Portal_Touch called for a broken portal\n");
 
 #ifdef PORTALS_ARE_NOT_SOLID
@@ -285,26 +285,26 @@ void Portal_Touch()
 
        if(other.classname == "porto")
        {
-               if(other.portal_id == self.portal_id)
+               if(other.portal_id == this.portal_id)
                        return;
        }
-       if(time < self.portal_activatetime)
-               if(other == self.aiment)
+       if(time < this.portal_activatetime)
+               if(other == this.aiment)
                {
-                       self.portal_activatetime = time + 0.1;
+                       this.portal_activatetime = time + 0.1;
                        return;
                }
-       if(other != self.aiment)
+       if(other != this.aiment)
                if(IS_PLAYER(other))
-                       if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+                       if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
                                return; // cannot go through someone else's portal
-       if(other.aiment != self.aiment)
+       if(other.aiment != this.aiment)
                if(IS_PLAYER(other.aiment))
-                       if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(self.aiment))
+                       if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(this.aiment))
                                return; // cannot go through someone else's portal
-       fixedmakevectors(self.mangle);
+       fixedmakevectors(this.mangle);
        g = frametime * '0 0 -1' * autocvar_sv_gravity;
-       if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, self.origin, v_forward, self.maxs.x))
+       if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, this.origin, v_forward, this.maxs.x))
                return;
 
        /*
@@ -316,19 +316,19 @@ void Portal_Touch()
        }
        */
 
-       if(Portal_TeleportPlayer(self, other))
+       if(Portal_TeleportPlayer(this, other))
                if(other.classname == "porto")
                        if(other.effects & EF_RED)
                                other.effects += EF_BLUE - EF_RED;
 }
 
-void Portal_Think();
+void Portal_Think(entity this);
 void Portal_MakeBrokenPortal(entity portal)
 {
        portal.skin = 2;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
-       portal.think = func_null;
+       settouch(portal, func_null);
+       setthink(portal, func_null);
        portal.effects = 0;
        portal.nextthink = 0;
        portal.takedamage = DAMAGE_NO;
@@ -338,8 +338,8 @@ void Portal_MakeWaitingPortal(entity portal)
 {
        portal.skin = 2;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
-       portal.think = func_null;
+       settouch(portal, func_null);
+       setthink(portal, func_null);
        portal.effects = EF_ADDITIVE;
        portal.nextthink = 0;
        portal.takedamage = DAMAGE_YES;
@@ -349,8 +349,8 @@ void Portal_MakeInPortal(entity portal)
 {
        portal.skin = 0;
        portal.solid = SOLID_NOT; // this is done when connecting them!
-       portal.touch = Portal_Touch;
-       portal.think = Portal_Think;
+       settouch(portal, Portal_Touch);
+       setthink(portal, Portal_Think);
        portal.effects = EF_RED;
        portal.nextthink = time;
        portal.takedamage = DAMAGE_NO;
@@ -360,8 +360,8 @@ void Portal_MakeOutPortal(entity portal)
 {
        portal.skin = 1;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
-       portal.think = func_null;
+       settouch(portal, func_null);
+       setthink(portal, func_null);
        portal.effects = EF_STARDUST | EF_BLUE;
        portal.nextthink = 0;
        portal.takedamage = DAMAGE_YES;
@@ -440,75 +440,75 @@ void Portal_Damage(entity this, entity inflictor, entity attacker, float damage,
                Portal_Remove(this, 1);
 }
 
-void Portal_Think_TryTeleportPlayer(entity e, vector g)
-{SELFPARAM();
-       if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x))
+void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g)
+{
+       if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, this.origin, v_forward, this.maxs.x))
                return;
 
        // if e would hit the portal in a frame...
        // already teleport him
        tracebox(e.origin, e.mins, e.maxs, e.origin + e.velocity * 2 * frametime, MOVE_NORMAL, e);
-       if(trace_ent == self)
-               Portal_TeleportPlayer(self, e);
+       if(trace_ent == this)
+               Portal_TeleportPlayer(this, e);
 }
 
-void Portal_Think()
-{SELFPARAM();
+void Portal_Think(entity this)
+{
        entity o;
        vector g;
 
 #ifdef PORTALS_ARE_NOT_SOLID
        // portal is being removed?
-       if(self.solid != SOLID_TRIGGER)
+       if(this.solid != SOLID_TRIGGER)
                return; // possibly engine bug
 
-       if(!self.enemy)
+       if(!this.enemy)
                error("Portal_Think called for a broken portal\n");
 
-       o = self.aiment;
-       self.solid = SOLID_BBOX;
-       self.aiment = world;
+       o = this.aiment;
+       this.solid = SOLID_BBOX;
+       this.aiment = world;
 
        g = frametime * '0 0 -1' * autocvar_sv_gravity;
 
-       fixedmakevectors(self.mangle);
+       fixedmakevectors(this.mangle);
 
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                if(it != o)
                        if(IS_INDEPENDENT_PLAYER(it) || IS_INDEPENDENT_PLAYER(o))
                                continue; // cannot go through someone else's portal
 
-               if(it != o || time >= self.portal_activatetime)
-                       Portal_Think_TryTeleportPlayer(it, g);
+               if(it != o || time >= this.portal_activatetime)
+                       Portal_Think_TryTeleportPlayer(this, it, g);
 
                if(it.hook)
-                       Portal_Think_TryTeleportPlayer(it.hook, g);
+                       Portal_Think_TryTeleportPlayer(this, it.hook, g);
        ));
-       self.solid = SOLID_TRIGGER;
-       self.aiment = o;
+       this.solid = SOLID_TRIGGER;
+       this.aiment = o;
 #endif
 
-       self.nextthink = time;
+       this.nextthink = time;
 
-       if(time > self.fade_time)
-               Portal_Remove(self, 0);
+       if(time > this.fade_time)
+               Portal_Remove(this, 0);
 }
 
 float Portal_Customize()
 {SELFPARAM();
        if(IS_SPEC(other))
                other = other.enemy;
-       if(other == self.aiment)
+       if(other == this.aiment)
        {
-               self.modelindex = self.savemodelindex;
+               this.modelindex = this.savemodelindex;
        }
-       else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+       else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
        {
-               self.modelindex = 0;
+               this.modelindex = 0;
        }
        else
        {
-               self.modelindex = self.savemodelindex;
+               this.modelindex = this.savemodelindex;
        }
        return true;
 }
@@ -574,15 +574,15 @@ void Portal_ClearAll(entity own)
        Portal_ClearAll_PortalsOnly(own);
        W_Porto_Remove(own);
 }
-void Portal_RemoveLater_Think()
-{SELFPARAM();
-       Portal_Remove(self, self.cnt);
+void Portal_RemoveLater_Think(entity this)
+{
+       Portal_Remove(this, this.cnt);
 }
 void Portal_RemoveLater(entity portal, float kill)
 {
        Portal_MakeBrokenPortal(portal);
        portal.cnt = kill;
-       portal.think = Portal_RemoveLater_Think;
+       setthink(portal, Portal_RemoveLater_Think);
        portal.nextthink = time;
 }
 void Portal_ClearAllLater_PortalsOnly(entity own)
@@ -629,7 +629,7 @@ entity Portal_Spawn(entity own, vector org, vector ang)
        portal.mangle = ang;
        portal.angles = ang;
        portal.angles_x = -portal.angles.x; // is a bmodel
-       portal.think = Portal_Think;
+       setthink(portal, Portal_Think);
        portal.nextthink = 0;
        portal.portal_activatetime = time + 0.1;
        portal.takedamage = DAMAGE_AIM;
index d24a0769b5a4b1b7834c76ca04fca34d588c63ab..6fc5cf712a1cdd572d091781a74f5228ac34a0f0 100644 (file)
@@ -22,7 +22,7 @@ void race_InitSpectator()
                        race_SendNextCheckpoint(msg_entity.enemy, 1);
 }
 
-void W_Porto_Fail(float failhard);
+void W_Porto_Fail(entity this, float failhard);
 
 float race_readTime(string map, float pos)
 {
@@ -561,46 +561,45 @@ void dumpsurface(entity e)
        }
 }
 
-void checkpoint_passed()
-{SELFPARAM();
+void checkpoint_passed(entity this, entity player)
+{
        string oldmsg;
        entity cp;
 
-       if(other.classname == "porto")
+       if(player.classname == "porto")
        {
                // do not allow portalling through checkpoints
-               trace_plane_normal = normalize(-1 * other.velocity);
-               setself(other);
-               W_Porto_Fail(0);
+               trace_plane_normal = normalize(-1 * player.velocity);
+               W_Porto_Fail(player, 0);
                return;
        }
 
        /*
         * Trigger targets
         */
-       if (!((self.spawnflags & 2) && (IS_PLAYER(other))))
+       if (!((this.spawnflags & 2) && (IS_PLAYER(player))))
        {
-               oldmsg = self.message;
-               self.message = "";
-               SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
-               self.message = oldmsg;
+               oldmsg = this.message;
+               this.message = "";
+               SUB_UseTargets(this, player, player);
+               this.message = oldmsg;
        }
 
-       if (!IS_PLAYER(other))
+       if (!IS_PLAYER(player))
                return;
 
        /*
         * Remove unauthorized equipment
         */
-       Portal_ClearAll(other);
+       Portal_ClearAll(player);
 
-       other.porto_forbidden = 2; // decreased by 1 each StartFrame
+       player.porto_forbidden = 2; // decreased by 1 each StartFrame
 
        if(defrag_ents)
        {
-               if(self.race_checkpoint == -2)
+               if(this.race_checkpoint == -2)
                {
-                       self.race_checkpoint = other.race_checkpoint;
+                       this.race_checkpoint = player.race_checkpoint;
                }
 
                float largest_cp_id = 0;
@@ -632,51 +631,51 @@ void checkpoint_passed()
                }
        }
 
-       if((other.race_checkpoint == -1 && self.race_checkpoint == 0) || (other.race_checkpoint == self.race_checkpoint))
+       if((player.race_checkpoint == -1 && this.race_checkpoint == 0) || (player.race_checkpoint == this.race_checkpoint))
        {
-               if(self.race_penalty)
+               if(this.race_penalty)
                {
-                       if(other.race_lastpenalty != self)
+                       if(player.race_lastpenalty != this)
                        {
-                               other.race_lastpenalty = self;
-                               race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
+                               player.race_lastpenalty = this;
+                               race_ImposePenaltyTime(player, this.race_penalty, this.race_penalty_reason);
                        }
                }
 
-               if(other.race_penalty)
+               if(player.race_penalty)
                        return;
 
                /*
                 * Trigger targets
                 */
-               if(self.spawnflags & 2)
+               if(this.spawnflags & 2)
                {
-                       oldmsg = self.message;
-                       self.message = "";
-                       SUB_UseTargets(self, other, other); // TODO: should we be using other for the trigger here?
-                       self.message = oldmsg;
+                       oldmsg = this.message;
+                       this.message = "";
+                       SUB_UseTargets(this, player, player); // TODO: should we be using other for the trigger here?
+                       this.message = oldmsg;
                }
 
-               if(other.race_respawn_checkpoint != self.race_checkpoint || !other.race_started)
-                       other.race_respawn_spotref = self; // this is not a spot but a CP, but spawnpoint selection will deal with that
-               other.race_respawn_checkpoint = self.race_checkpoint;
-               other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
-               other.race_started = 1;
+               if(player.race_respawn_checkpoint != this.race_checkpoint || !player.race_started)
+                       player.race_respawn_spotref = this; // this is not a spot but a CP, but spawnpoint selection will deal with that
+               player.race_respawn_checkpoint = this.race_checkpoint;
+               player.race_checkpoint = race_NextCheckpoint(this.race_checkpoint);
+               player.race_started = 1;
 
-               race_SendTime(other, self.race_checkpoint, other.race_movetime, boolean(other.race_laptime));
+               race_SendTime(player, this.race_checkpoint, player.race_movetime, boolean(player.race_laptime));
 
-               if(!self.race_checkpoint) // start line
+               if(!this.race_checkpoint) // start line
                {
-                       other.race_laptime = time;
-                       other.race_movetime = other.race_movetime_frac = other.race_movetime_count = 0;
-                       other.race_penalty_accumulator = 0;
-                       other.race_lastpenalty = world;
+                       player.race_laptime = time;
+                       player.race_movetime = player.race_movetime_frac = player.race_movetime_count = 0;
+                       player.race_penalty_accumulator = 0;
+                       player.race_lastpenalty = world;
                }
 
                if(g_race_qualifying)
-                       race_SendNextCheckpoint(other, 0);
+                       race_SendNextCheckpoint(player, 0);
 
-               if(defrag_ents && defragcpexists < 0 && self.classname == "target_stopTimer")
+               if(defrag_ents && defragcpexists < 0 && this.classname == "target_stopTimer")
                {
                        float fh;
                        defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_WRITE);
@@ -688,21 +687,21 @@ void checkpoint_passed()
                        fclose(fh);
                }
        }
-       else if(other.race_checkpoint == race_NextCheckpoint(self.race_checkpoint))
+       else if(player.race_checkpoint == race_NextCheckpoint(this.race_checkpoint))
        {
                // ignored
        }
        else
        {
-               if(self.spawnflags & 4)
-                       Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0');
+               if(this.spawnflags & 4)
+                       Damage (player, this, this, 10000, DEATH_HURTTRIGGER.m_id, player.origin, '0 0 0');
        }
 }
 
-void checkpoint_touch()
+void checkpoint_touch(entity this)
 {
        EXACTTRIGGER_TOUCH;
-       checkpoint_passed();
+       checkpoint_passed(this, other);
 }
 
 void checkpoint_use(entity this, entity actor, entity trigger)
@@ -710,15 +709,14 @@ void checkpoint_use(entity this, entity actor, entity trigger)
        if(trigger.classname == "info_player_deathmatch") // a spawn, a spawn
                return;
 
-       other = actor;
-       checkpoint_passed();
+       checkpoint_passed(this, actor);
 }
 
-float race_waypointsprite_visible_for_player(entity e)
-{SELFPARAM();
-       if(e.race_checkpoint == -1 || self.owner.race_checkpoint == -2)
+bool race_waypointsprite_visible_for_player(entity this, entity player, entity view)
+{
+       if(view.race_checkpoint == -1 || this.owner.race_checkpoint == -2)
                return true;
-       else if(e.race_checkpoint == self.owner.race_checkpoint)
+       else if(view.race_checkpoint == this.owner.race_checkpoint)
                return true;
        else
                return false;
@@ -742,7 +740,7 @@ void trigger_race_checkpoint_verify(entity this)
                        // race only (middle of the race)
                        g_race_qualifying = false;
                        pl_race_place = 0;
-                       if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                       if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out"));
             }
 
@@ -750,7 +748,7 @@ void trigger_race_checkpoint_verify(entity this)
                                // qualifying only
                                g_race_qualifying = 1;
                                pl_race_place = race_lowest_place_spawn;
-                               if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                               if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                        error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
                 }
 
@@ -758,7 +756,7 @@ void trigger_race_checkpoint_verify(entity this)
                                g_race_qualifying = 0;
                                for (int p = 1; p <= race_highest_place_spawn; ++p) {
                                        pl_race_place = p;
-                                       if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                                       if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                                error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out"));
                     }
                                }
@@ -769,7 +767,7 @@ void trigger_race_checkpoint_verify(entity this)
                pl_race_checkpoint = race_NextCheckpoint(0);
                g_race_qualifying = 1;
                pl_race_place = race_lowest_place_spawn;
-               if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+               if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                        error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
         }
        } else {
@@ -873,27 +871,26 @@ void trigger_race_checkpoint_verify(entity this)
        }
 }
 
-vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
+vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
        if(g_race_qualifying)
        {
                // spawn at first
-               if(self.race_checkpoint != 0)
+               if(this.race_checkpoint != 0)
                        return '-1 0 0';
                if(spot.race_place != race_lowest_place_spawn)
                        return '-1 0 0';
        }
        else
        {
-               if(self.race_checkpoint != player.race_respawn_checkpoint)
+               if(this.race_checkpoint != player.race_respawn_checkpoint)
                        return '-1 0 0';
                // try reusing the previous spawn
-               if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref)
+               if(this == player.race_respawn_spotref || spot == player.race_respawn_spotref)
                        current.x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN;
-               if(self.race_checkpoint == 0)
+               if(this.race_checkpoint == 0)
                {
-                       float pl;
-                       pl = player.race_place;
+                       int pl = player.race_place;
                        if(pl > race_highest_place_spawn)
                                pl = 0;
                        if(pl == 0 && !player.race_started)
@@ -908,90 +905,90 @@ vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector
 spawnfunc(trigger_race_checkpoint)
 {
        vector o;
-       if(!g_race && !g_cts) { remove(self); return; }
+       if(!g_race && !g_cts) { remove(this); return; }
 
        EXACTTRIGGER_INIT;
 
-       self.use = checkpoint_use;
-       if (!(self.spawnflags & 1))
-               self.touch = checkpoint_touch;
+       this.use = checkpoint_use;
+       if (!(this.spawnflags & 1))
+               settouch(this, checkpoint_touch);
 
-       o = (self.absmin + self.absmax) * 0.5;
-       tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
-       waypoint_spawnforitem_force(self, trace_endpos);
-       self.nearestwaypointtimeout = time + 1000000000;
+       o = (this.absmin + this.absmax) * 0.5;
+       tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - this.absmin.z), MOVE_NORMAL, this);
+       waypoint_spawnforitem_force(this, trace_endpos);
+       this.nearestwaypointtimeout = time + 1000000000;
 
-       if(self.message == "")
-               self.message = "went backwards";
-       if (self.message2 == "")
-               self.message2 = "was pushed backwards by";
-       if (self.race_penalty_reason == "")
-               self.race_penalty_reason = "missing a checkpoint";
+       if(this.message == "")
+               this.message = "went backwards";
+       if (this.message2 == "")
+               this.message2 = "was pushed backwards by";
+       if (this.race_penalty_reason == "")
+               this.race_penalty_reason = "missing a checkpoint";
 
-       self.race_checkpoint = self.cnt;
+       this.race_checkpoint = this.cnt;
 
-       if(self.race_checkpoint > race_highest_checkpoint)
+       if(this.race_checkpoint > race_highest_checkpoint)
        {
-               race_highest_checkpoint = self.race_checkpoint;
-               if(self.spawnflags & 8)
-                       race_timed_checkpoint = self.race_checkpoint;
+               race_highest_checkpoint = this.race_checkpoint;
+               if(this.spawnflags & 8)
+                       race_timed_checkpoint = this.race_checkpoint;
                else
                        race_timed_checkpoint = 0;
        }
 
-       if(!self.race_penalty)
+       if(!this.race_penalty)
        {
-               if(self.race_checkpoint)
-                       WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, self, sprite, RADARICON_NONE);
+               if(this.race_checkpoint)
+                       WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, this, sprite, RADARICON_NONE);
                else
-                       WaypointSprite_SpawnFixed(WP_RaceStartFinish, o, self, sprite, RADARICON_NONE);
+                       WaypointSprite_SpawnFixed(WP_RaceStartFinish, o, this, sprite, RADARICON_NONE);
        }
 
-       self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
-       self.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
+       this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
+       this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
 
-       InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
+       InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
 }
 
 spawnfunc(target_checkpoint) // defrag entity
 {
        vector o;
-       if(!g_race && !g_cts) { remove(self); return; }
+       if(!g_race && !g_cts) { remove(this); return; }
        defrag_ents = 1;
 
        EXACTTRIGGER_INIT;
 
-       self.use = checkpoint_use;
-       if (!(self.spawnflags & 1))
-               self.touch = checkpoint_touch;
+       this.use = checkpoint_use;
+       if (!(this.spawnflags & 1))
+               settouch(this, checkpoint_touch);
 
-       o = (self.absmin + self.absmax) * 0.5;
-       tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self);
-       waypoint_spawnforitem_force(self, trace_endpos);
-       self.nearestwaypointtimeout = time + 1000000000;
+       o = (this.absmin + this.absmax) * 0.5;
+       tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - this.absmin.z), MOVE_NORMAL, this);
+       waypoint_spawnforitem_force(this, trace_endpos);
+       this.nearestwaypointtimeout = time + 1000000000;
 
-       if(self.message == "")
-               self.message = "went backwards";
-       if (self.message2 == "")
-               self.message2 = "was pushed backwards by";
-       if (self.race_penalty_reason == "")
-               self.race_penalty_reason = "missing a checkpoint";
+       if(this.message == "")
+               this.message = "went backwards";
+       if (this.message2 == "")
+               this.message2 = "was pushed backwards by";
+       if (this.race_penalty_reason == "")
+               this.race_penalty_reason = "missing a checkpoint";
 
-       if(self.classname == "target_startTimer")
-               self.race_checkpoint = 0;
+       if(this.classname == "target_startTimer")
+               this.race_checkpoint = 0;
        else
-               self.race_checkpoint = -2;
+               this.race_checkpoint = -2;
 
        race_timed_checkpoint = 1;
 
-       if(self.race_checkpoint == 0)
-               WaypointSprite_SpawnFixed(WP_RaceStart, o, self, sprite, RADARICON_NONE);
+       if(this.race_checkpoint == 0)
+               WaypointSprite_SpawnFixed(WP_RaceStart, o, this, sprite, RADARICON_NONE);
        else
-               WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, self, sprite, RADARICON_NONE);
+               WaypointSprite_SpawnFixed(WP_RaceCheckpoint, o, this, sprite, RADARICON_NONE);
 
-       self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
+       this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
 
-       InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
+       InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
 }
 
 spawnfunc(target_startTimer) { spawnfunc_target_checkpoint(this); }
@@ -1014,38 +1011,38 @@ void race_StartCompleting()
        FOREACH_CLIENT(IS_PLAYER(it) && IS_DEAD(it), LAMBDA(race_AbandonRaceCheck(it)));
 }
 
-void race_PreparePlayer()
-{SELFPARAM();
-       race_ClearTime(self);
-       self.race_place = 0;
-       self.race_started = 0;
-       self.race_respawn_checkpoint = 0;
-       self.race_respawn_spotref = world;
+void race_PreparePlayer(entity this)
+{
+       race_ClearTime(this);
+       this.race_place = 0;
+       this.race_started = 0;
+       this.race_respawn_checkpoint = 0;
+       this.race_respawn_spotref = world;
 }
 
-void race_RetractPlayer()
-{SELFPARAM();
+void race_RetractPlayer(entity this)
+{
        if(!g_race && !g_cts)
                return;
-       if(self.race_respawn_checkpoint == 0 || self.race_respawn_checkpoint == race_timed_checkpoint)
-               race_ClearTime(self);
-       self.race_checkpoint = self.race_respawn_checkpoint;
+       if(this.race_respawn_checkpoint == 0 || this.race_respawn_checkpoint == race_timed_checkpoint)
+               race_ClearTime(this);
+       this.race_checkpoint = this.race_respawn_checkpoint;
 }
 
 spawnfunc(info_player_race)
 {
-       if(!g_race && !g_cts) { remove(self); return; }
+       if(!g_race && !g_cts) { remove(this); return; }
        ++race_spawns;
        spawnfunc_info_player_deathmatch(this);
 
-       if(self.race_place > race_highest_place_spawn)
-               race_highest_place_spawn = self.race_place;
-       if(self.race_place < race_lowest_place_spawn)
-               race_lowest_place_spawn = self.race_place;
+       if(this.race_place > race_highest_place_spawn)
+               race_highest_place_spawn = this.race_place;
+       if(this.race_place < race_lowest_place_spawn)
+               race_lowest_place_spawn = this.race_place;
 }
 
 void race_ClearRecords()
-{SELFPARAM();
+{
        float i;
 
        for(i = 0; i < MAX_CHECKPOINTS; ++i)
@@ -1058,7 +1055,7 @@ void race_ClearRecords()
 
        FOREACH_CLIENT(true, LAMBDA(
                float p = it.race_place;
-               WITHSELF(it, race_PreparePlayer());
+               race_PreparePlayer(it);
                it.race_place = p;
        ));
 }
@@ -1095,13 +1092,13 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason)
        }
 }
 
-void penalty_touch()
-{SELFPARAM();
+void penalty_touch(entity this)
+{
        EXACTTRIGGER_TOUCH;
-       if(other.race_lastpenalty != self)
+       if(other.race_lastpenalty != this)
        {
-               other.race_lastpenalty = self;
-               race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
+               other.race_lastpenalty = this;
+               race_ImposePenaltyTime(other, this.race_penalty, this.race_penalty_reason);
        }
 }
 
@@ -1113,18 +1110,18 @@ void penalty_use(entity this, entity actor, entity trigger)
 spawnfunc(trigger_race_penalty)
 {
        // TODO: find out why this wasnt done:
-       //if(!g_cts && !g_race) { remove(self); return; }
+       //if(!g_cts && !g_race) { remove(this); return; }
 
        EXACTTRIGGER_INIT;
 
-       self.use = penalty_use;
-       if (!(self.spawnflags & 1))
-               self.touch = penalty_touch;
+       this.use = penalty_use;
+       if (!(this.spawnflags & 1))
+               settouch(this, penalty_touch);
 
-       if (self.race_penalty_reason == "")
-               self.race_penalty_reason = "missing a checkpoint";
-       if (!self.race_penalty)
-               self.race_penalty = 5;
+       if (this.race_penalty_reason == "")
+               this.race_penalty_reason = "missing a checkpoint";
+       if (!this.race_penalty)
+               this.race_penalty = 5;
 }
 
 float race_GetFractionalLapCount(entity e)
index 51ec4590019abf277b06cc03632f6fa8d110a3b1..b69b0006a96d1a8a1b381fd4a4aaaf785657fe8a 100644 (file)
@@ -44,7 +44,7 @@ string race_readUID(string map, float pos);
 string race_readName(string map, float pos);
 void race_ClearRecords();
 void race_SendNextCheckpoint(entity e, float spec);
-void race_PreparePlayer();
+void race_PreparePlayer(entity this);
 void race_send_recordtime(float msg);
 void race_send_speedaward(float msg);
 
@@ -62,6 +62,6 @@ void race_send_speedaward_alltimebest(float msg);
 
 void race_SendRankings(float pos, float prevpos, float del, float msg);
 
-void race_RetractPlayer();
+void race_RetractPlayer(entity this);
 
 void race_InitSpectator();
index 8fb1a787be1904edee99e5e3bd93831fb7f7194d..ad0fcaae66278f5a93a47b76f76603874e6deda2 100644 (file)
@@ -3,10 +3,8 @@
 #include "command/vote.qh"
 #include "../common/util.qh"
 
-void round_handler_Think()
+void round_handler_Think(entity this)
 {
-       SELFPARAM();
-
        if (time < game_starttime)
        {
                round_handler_Reset(game_starttime);
@@ -76,11 +74,10 @@ void round_handler_Init(float the_delay, float the_count, float the_round_timeli
 
 // NOTE: this is only needed because if round_handler spawns at time 1
 // gamestarttime isn't initialized yet
-void round_handler_FirstThink()
+void round_handler_FirstThink(entity this)
 {
-       SELFPARAM();
        round_starttime = max(time, game_starttime) + this.count;
-       this.think = round_handler_Think;
+       setthink(this, round_handler_Think);
        this.nextthink = max(time, game_starttime);
 }
 
@@ -93,7 +90,7 @@ void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, v
        }
        entity this = round_handler = new(round_handler);
 
-       this.think = round_handler_FirstThink;
+       setthink(this, round_handler_FirstThink);
        this.canRoundStart = canRoundStart_func;
        this.canRoundEnd = canRoundEnd_func;
        this.roundStart = roundStart_func;
index b09657e6a5832d8b93bae23b537daaa26fe6946e..efefcd17aaa26cf16897100a0123270dba7eba42 100644 (file)
@@ -65,7 +65,7 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
 
        longflags = 0;
        for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
-               if(self.(teamscores[i]) > 127 || self.(teamscores[i]) <= -128)
+               if(this.(teamscores[i]) > 127 || this.(teamscores[i]) <= -128)
                        longflags |= p;
 
 #if MAX_TEAMSCORE <= 8
@@ -79,9 +79,9 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
                if(sendflags & p)
                {
                        if(longflags & p)
-                               WriteInt24_t(MSG_ENTITY, self.(teamscores[i]));
+                               WriteInt24_t(MSG_ENTITY, this.(teamscores[i]));
                        else
-                               WriteChar(MSG_ENTITY, self.(teamscores[i]));
+                               WriteChar(MSG_ENTITY, this.(teamscores[i]));
                }
 
        return true;
@@ -233,11 +233,11 @@ bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
        float i, p, longflags;
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
-       WriteByte(MSG_ENTITY, etof(self.owner));
+       WriteByte(MSG_ENTITY, etof(this.owner));
 
        longflags = 0;
        for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
-               if(self.(scores[i]) > 127 || self.(scores[i]) <= -128)
+               if(this.(scores[i]) > 127 || this.(scores[i]) <= -128)
                        longflags |= p;
 
 #if MAX_SCORE <= 8
@@ -251,9 +251,9 @@ bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
                if(sendflags & p)
                {
                        if(longflags & p)
-                               WriteInt24_t(MSG_ENTITY, self.(scores[i]));
+                               WriteInt24_t(MSG_ENTITY, this.(scores[i]));
                        else
-                               WriteChar(MSG_ENTITY, self.(scores[i]));
+                               WriteChar(MSG_ENTITY, this.(scores[i]));
                }
 
        return true;
@@ -406,7 +406,7 @@ void WinningConditionHelper()
        s = GetGametype();
        s = strcat(s, ":", autocvar_g_xonoticversion);
        s = strcat(s, ":P", ftos(cvar_purechanges_count));
-       s = strcat(s, ":S", ftos(nJoinAllowed(self, world)));
+       s = strcat(s, ":S", ftos(nJoinAllowed(this, world))); // note: self/this is most likely world in this case
        s = strcat(s, ":F", ftos(serverflags));
        s = strcat(s, ":M", modname);
        s = strcat(s, "::", GetPlayerScoreString(world, (fullstatus ? 1 : 2)));
index 711b15df560536d11057ff34b19ef5b506253559..69c1360851f2c41e9d694a3790a4552e784847ba 100644 (file)
@@ -14,10 +14,10 @@ bool SpawnPoint_Send(entity this, entity to, int sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
 
-       WriteByte(MSG_ENTITY, self.team);
-       WriteCoord(MSG_ENTITY, self.origin.x);
-       WriteCoord(MSG_ENTITY, self.origin.y);
-       WriteCoord(MSG_ENTITY, self.origin.z);
+       WriteByte(MSG_ENTITY, this.team);
+       WriteCoord(MSG_ENTITY, this.origin.x);
+       WriteCoord(MSG_ENTITY, this.origin.y);
+       WriteCoord(MSG_ENTITY, this.origin.z);
 
        return true;
 }
@@ -47,9 +47,8 @@ bool SpawnEvent_Send(entity this, entity to, int sf)
 }
 
 .vector spawnpoint_prevorigin;
-void spawnpoint_think()
+void spawnpoint_think(entity this)
 {
-    SELFPARAM();
        this.nextthink = time + 0.1;
        if(this.origin != this.spawnpoint_prevorigin)
        {
@@ -69,24 +68,24 @@ void spawnpoint_use(entity this, entity actor, entity trigger)
        //LOG_INFO("spawnpoint was used!\n");
 }
 
-void relocate_spawnpoint()
-{SELFPARAM();
+void relocate_spawnpoint(entity this)
+{
     // nudge off the floor
-    setorigin(self, self.origin + '0 0 1');
+    setorigin(this, this.origin + '0 0 1');
 
-    tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self);
+    tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, true, this);
     if (trace_startsolid)
     {
         vector o;
-        o = self.origin;
-        self.mins = PL_MIN_CONST;
-        self.maxs = PL_MAX_CONST;
-        if (!move_out_of_solid(self))
+        o = this.origin;
+        this.mins = PL_MIN_CONST;
+        this.maxs = PL_MAX_CONST;
+        if (!move_out_of_solid(this))
             objerror("could not get out of solid at all!");
         LOG_INFO("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1'));
-        LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
-        LOG_INFO(" ", ftos(self.origin.y - o.y));
-        LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
+        LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+        LOG_INFO(" ", ftos(this.origin.y - o.y));
+        LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
         if (autocvar_g_spawnpoints_auto_move_out_of_solid)
         {
             if (!spawnpoint_nag)
@@ -95,31 +94,31 @@ void relocate_spawnpoint()
         }
         else
         {
-            setorigin(self, o);
-            self.mins = self.maxs = '0 0 0';
+            setorigin(this, o);
+            this.mins = this.maxs = '0 0 0';
             objerror("player spawn point in solid, mapper sucks!\n");
             return;
         }
     }
 
-    self.use = spawnpoint_use;
-    self.think = spawnpoint_think;
-    self.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
-    self.team_saved = self.team;
-    if (!self.cnt)
-        self.cnt = 1;
+    this.use = spawnpoint_use;
+    setthink(this, spawnpoint_think);
+    this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
+    this.team_saved = this.team;
+    if (!this.cnt)
+        this.cnt = 1;
 
     if (have_team_spawns != 0)
-        if (self.team)
+        if (this.team)
             have_team_spawns = 1;
-    have_team_spawns_forteam[self.team] = 1;
+    have_team_spawns_forteam[this.team] = 1;
 
     if (autocvar_r_showbboxes)
     {
         // show where spawnpoints point at too
-        makevectors(self.angles);
+        makevectors(this.angles);
         entity e = new(info_player_foo);
-        setorigin(e, self.origin + v_forward * 24);
+        setorigin(e, this.origin + v_forward * 24);
         setsize(e, '-8 -8 -8', '8 8 8');
         e.solid = SOLID_TRIGGER;
     }
@@ -131,27 +130,27 @@ void relocate_spawnpoint()
                !(
                        ( // if this passes, there is a DM spawn on a team match
                                teamplay
-                               && (self.team != NUM_TEAM_1)
-                               && (self.team != NUM_TEAM_2)
-                               && (self.team != NUM_TEAM_3)
-                               && (self.team != NUM_TEAM_4)
+                               && (this.team != NUM_TEAM_1)
+                               && (this.team != NUM_TEAM_2)
+                               && (this.team != NUM_TEAM_3)
+                               && (this.team != NUM_TEAM_4)
                        )
                        ||
                        ( // if this passes, there is a team spawn on a DM match
                                !teamplay
                                &&
                                (
-                                       (self.team == NUM_TEAM_1)
-                                       || (self.team == NUM_TEAM_2)
-                                       || (self.team == NUM_TEAM_3)
-                                       || (self.team == NUM_TEAM_4)
+                                       (this.team == NUM_TEAM_1)
+                                       || (this.team == NUM_TEAM_2)
+                                       || (this.team == NUM_TEAM_3)
+                                       || (this.team == NUM_TEAM_4)
                                )
                        )
                )
                ||
                autocvar_g_spawn_useallspawns
        )
-       { Net_LinkEntity(self, false, 0, SpawnPoint_Send); }
+       { Net_LinkEntity(this, false, 0, SpawnPoint_Send); }
 }
 
 spawnfunc(info_player_survivor)
@@ -166,8 +165,8 @@ spawnfunc(info_player_start)
 
 spawnfunc(info_player_deathmatch)
 {
-       self.classname = "info_player_deathmatch";
-       relocate_spawnpoint();
+       this.classname = "info_player_deathmatch";
+       relocate_spawnpoint(this);
 }
 
 /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
@@ -211,8 +210,8 @@ spawnfunc(info_player_team4)
 // Returns:
 //   _x: prio (-1 if unusable)
 //   _y: weight
-vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{SELFPARAM();
+vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck)
+{
        float shortest, thisdist;
        float prio;
 
@@ -227,7 +226,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if(spot.target == "")
                        return '-1 0 0';
 
-       if(IS_REAL_CLIENT(self))
+       if(IS_REAL_CLIENT(this))
        {
                if(spot.restriction == 1)
                        return '-1 0 0';
@@ -239,7 +238,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
        }
 
        shortest = vlen(world.maxs - world.mins);
-       FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
                thisdist = vlen(it.origin - spot.origin);
                if (thisdist < shortest)
                        shortest = thisdist;
@@ -261,7 +260,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
+                               spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score);
                                if(spawn_score.x < 0)
                                        return spawn_score;
                        }
@@ -274,25 +273,25 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                }
        }
 
-       MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
+       MUTATOR_CALLHOOK(Spawn_Score, this, spawn_spot, spawn_score);
        return spawn_score;
 }
 
-void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck)
+void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck)
 {
        entity spot;
        for(spot = firstspot; spot; spot = spot.chain)
-               spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck);
+               spot.spawnpoint_score = Spawn_Score(this, spot, mindist, teamcheck);
 }
 
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck)
 {
        entity spot, spotlist, spotlistend;
 
        spotlist = world;
        spotlistend = world;
 
-       Spawn_ScoreAll(firstspot, mindist, teamcheck);
+       Spawn_ScoreAll(this, firstspot, mindist, teamcheck);
 
        for(spot = firstspot; spot; spot = spot.chain)
        {
@@ -331,8 +330,8 @@ SelectSpawnPoint
 Finds a point to respawn
 =============
 */
-entity SelectSpawnPoint (float anypoint)
-{SELFPARAM();
+entity SelectSpawnPoint(entity this, bool anypoint)
+{
        float teamcheck;
        entity spot, firstspot;
 
@@ -344,7 +343,7 @@ entity SelectSpawnPoint (float anypoint)
                teamcheck = -1;
        else if(have_team_spawns > 0)
        {
-               if(have_team_spawns_forteam[self.team] == 0)
+               if(have_team_spawns_forteam[this.team] == 0)
                {
                        // we request a spawn for a team, and we have team
                        // spawns, but that team has no spawns?
@@ -356,7 +355,7 @@ entity SelectSpawnPoint (float anypoint)
                                teamcheck = -1;
                }
                else
-                       teamcheck = self.team; // MUST be team
+                       teamcheck = this.team; // MUST be team
        }
        else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
                teamcheck = 0; // MUST be noteam
@@ -375,7 +374,7 @@ entity SelectSpawnPoint (float anypoint)
        }
        else
        {
-               firstspot = Spawn_FilterOutBadSpots(firstspot, 100, teamcheck);
+               firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck);
 
                // there is 50/50 chance of choosing a random spot or the furthest spot
                // (this means that roughly every other spawn will be furthest, so you
index a22ebb60c82323c89b018d40447ccef70bd0710a..56e00b5ac5258c7bc7b8f8a82bea0a0f75eb8bf3 100644 (file)
@@ -3,7 +3,7 @@
 .vector spawnpoint_score;
 float spawnpoint_nag;
 bool SpawnEvent_Send(entity this, entity to, int sf);
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck);
-entity SelectSpawnPoint (float anypoint);
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck);
+entity SelectSpawnPoint(entity this, bool anypoint);
 spawnfunc(info_player_deathmatch);
 void spawnpoint_use(entity this, entity actor, entity trigger);
index 24800165661c95361ab2662b4037df977c2e1a15..b68432cb19f2482d4e327bdc59cbf4e74820c927 100644 (file)
@@ -7,44 +7,44 @@
 /**
     Uniform pull towards a point
 **/
-vector steerlib_pull(vector point)
-{SELFPARAM();
-    return normalize(point - self.origin);
+vector steerlib_pull(entity this, vector point)
+{
+    return normalize(point - this.origin);
 }
 
 /**
     Uniform push from a point
 **/
-#define steerlib_push(point) normalize(self.origin - point)
+#define steerlib_push(ent,point) normalize(ent.origin - point)
 /*
-vector steerlib_push(vector point)
+vector steerlib_push(entity this, vector point)
 {
-    return normalize(self.origin - point);
+    return normalize(this.origin - point);
 }
 */
 /**
     Pull toward a point, The further away, the stronger the pull.
 **/
-vector steerlib_arrive(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_arrive(entity this, vector point, float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(point - self.origin);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(point - this.origin);
     return  direction * (distance / maximal_distance);
 }
 
 /**
     Pull toward a point increasing the pull the closer we get
 **/
-vector steerlib_attract(vector point, float maximal_distance)
-{SELFPARAM();
+vector steerlib_attract(entity this, vector point, float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(point - self.origin);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(point - this.origin);
 
     return  direction * (1-(distance / maximal_distance));
 }
@@ -73,12 +73,12 @@ vector steerlib_attract2(vector point, float maximal_distance,float min_influens
     float i_target,i_current;
 
     if(!distance)
-        distance = vlen(self.origin - point);
+        distance = vlen(this.origin - point);
 
     distance = bound(0.001,distance,maximal_distance);
 
-    target_direction = normalize(point - self.origin);
-    current_direction = normalize(self.velocity);
+    target_direction = normalize(point - this.origin);
+    current_direction = normalize(this.velocity);
 
     i_target = bound(min_influense,(1-(distance / maximal_distance)),max_influense);
     i_current = 1 - i_target;
@@ -97,13 +97,13 @@ vector steerlib_attract2(vector point, float maximal_distance,float min_influens
 /**
     Move away from a point.
 **/
-vector steerlib_repell(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_repell(entity this, vector point,float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(self.origin - point);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(this.origin - point);
 
     return  direction * (1-(distance / maximal_distance));
 }
@@ -111,21 +111,21 @@ vector steerlib_repell(vector point,float maximal_distance)
 /**
     Try to keep at ideal_distance away from point
 **/
-vector steerlib_standoff(vector point,float ideal_distance)
-{SELFPARAM();
+vector steerlib_standoff(entity this, vector point,float ideal_distance)
+{
     float distance;
     vector direction;
 
-    distance = vlen(self.origin - point);
+    distance = vlen(this.origin - point);
 
 
     if(distance < ideal_distance)
     {
-        direction = normalize(self.origin - point);
+        direction = normalize(this.origin - point);
         return direction * (distance / ideal_distance);
     }
 
-    direction = normalize(point - self.origin);
+    direction = normalize(point - this.origin);
     return direction * (ideal_distance / distance);
 
 }
@@ -134,12 +134,12 @@ vector steerlib_standoff(vector point,float ideal_distance)
     A random heading in a forward halfcicrle
 
     use like:
-    self.target = steerlib_wander(256,32,self.target)
+    this.target = steerlib_wander(256,32,this.target)
 
     where range is the cicrle radius and tresh is how close we need to be to pick a new heading.
 **/
-vector steerlib_wander(float range,float tresh,vector oldpoint)
-{SELFPARAM();
+vector steerlib_wander(entity this, float range, float tresh, vector oldpoint)
+{
     vector wander_point;
     wander_point = v_forward - oldpoint;
 
@@ -148,20 +148,20 @@ vector steerlib_wander(float range,float tresh,vector oldpoint)
 
     range = bound(0,range,1);
 
-    wander_point = self.origin + v_forward * 128;
+    wander_point = this.origin + v_forward * 128;
     wander_point = wander_point + randomvec() * (range * 128) - randomvec() * (range * 128);
 
-    return normalize(wander_point - self.origin);
+    return normalize(wander_point - this.origin);
 }
 
 /**
     Dodge a point. dont work to well.
 **/
-vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
-{SELFPARAM();
+vector steerlib_dodge(entity this, vector point, vector dodge_dir, float min_distance)
+{
     float distance;
 
-    distance = max(vlen(self.origin - point),min_distance);
+    distance = max(vlen(this.origin - point),min_distance);
     if (min_distance < distance)
         return '0 0 0';
 
@@ -173,21 +173,21 @@ vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
     Group will move towards the unified direction while keeping close to eachother.
 **/
 .float flock_id;
-vector steerlib_flock(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
 
-    flock_member = findradius(self.origin, _radius);
+    flock_member = findradius(this.origin, _radius);
     while(flock_member)
     {
-        if(flock_member != self)
-        if(flock_member.flock_id == self.flock_id)
+        if(flock_member != this)
+        if(flock_member.flock_id == this.flock_id)
         {
             ++ccount;
-            push = push + (steerlib_repell(flock_member.origin,standoff) * separation_force);
-            pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+            push = push + (steerlib_repell(this, flock_member.origin,standoff) * separation_force);
+            pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
         }
         flock_member = flock_member.chain;
     }
@@ -199,21 +199,21 @@ vector steerlib_flock(float _radius, float standoff,float separation_force,float
     Group will move towards the unified direction while keeping close to eachother.
     xy only version (for ground movers).
 **/
-vector steerlib_flock2d(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock2d(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
 
-    flock_member = findradius(self.origin,_radius);
+    flock_member = findradius(this.origin,_radius);
     while(flock_member)
     {
-        if(flock_member != self)
-        if(flock_member.flock_id == self.flock_id)
+        if(flock_member != this)
+        if(flock_member.flock_id == this.flock_id)
         {
             ++ccount;
-            push = push + (steerlib_repell(flock_member.origin, standoff) * separation_force);
-            pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+            push = push + (steerlib_repell(this, flock_member.origin, standoff) * separation_force);
+            pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
         }
         flock_member = flock_member.chain;
     }
@@ -230,27 +230,27 @@ vector steerlib_flock2d(float _radius, float standoff,float separation_force,flo
 
     This results in a aligned movement (?!) much like flocking.
 **/
-vector steerlib_swarm(float _radius, float standoff,float separation_force,float swarm_force)
-{SELFPARAM();
+vector steerlib_swarm(entity this, float _radius, float standoff,float separation_force,float swarm_force)
+{
     entity swarm_member;
     vector force = '0 0 0', center = '0 0 0';
     float ccount = 0;
 
-    swarm_member = findradius(self.origin,_radius);
+    swarm_member = findradius(this.origin,_radius);
 
     while(swarm_member)
     {
-        if(swarm_member.flock_id == self.flock_id)
+        if(swarm_member.flock_id == this.flock_id)
         {
             ++ccount;
             center = center + swarm_member.origin;
-            force = force + (steerlib_repell(swarm_member.origin,standoff) * separation_force);
+            force = force + (steerlib_repell(this, swarm_member.origin,standoff) * separation_force);
         }
         swarm_member = swarm_member.chain;
     }
 
     center = center * (1 / ccount);
-    force = force + (steerlib_arrive(center,_radius) * swarm_force);
+    force = force + (steerlib_arrive(this, center,_radius) * swarm_force);
 
     return force;
 }
@@ -260,8 +260,8 @@ vector steerlib_swarm(float _radius, float standoff,float separation_force,float
     Run four tracelines in a forward funnel, bias each diretion negative if something is found there.
     You need to call makevectors() (or equivalent) before this function to set v_forward and v_right
 **/
-vector steerlib_traceavoid(float pitch,float length)
-{SELFPARAM();
+vector steerlib_traceavoid(entity this, float pitch,float length)
+{
     vector vup_left,vup_right,vdown_left,vdown_right;
     float fup_left,fup_right,fdown_left,fdown_right;
     vector upwish,downwish,leftwish,rightwish;
@@ -272,28 +272,28 @@ vector steerlib_traceavoid(float pitch,float length)
     v_down = v_up * -1;
 
     vup_left = (v_forward + (v_left * pitch + v_up * pitch)) * length;
-    traceline(self.origin, self.origin +  vup_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin, this.origin +  vup_left,MOVE_NOMONSTERS,this);
     fup_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vup_right = (v_forward + (v_right * pitch + v_up * pitch)) * length;
-    traceline(self.origin,self.origin + vup_right ,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vup_right ,MOVE_NOMONSTERS,this);
     fup_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vdown_left = (v_forward + (v_left * pitch + v_down * pitch)) * length;
-    traceline(self.origin,self.origin + vdown_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vdown_left,MOVE_NOMONSTERS,this);
     fdown_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vdown_right = (v_forward + (v_right * pitch + v_down * pitch)) * length;
-    traceline(self.origin,self.origin + vdown_right,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vdown_right,MOVE_NOMONSTERS,this);
     fdown_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
     upwish    = v_up    * (fup_left   + fup_right);
     downwish  = v_down  * (fdown_left + fdown_right);
     leftwish  = v_left  * (fup_left   + fdown_left);
@@ -307,8 +307,8 @@ vector steerlib_traceavoid(float pitch,float length)
     Steer towards the direction least obstructed.
     Run tracelines in a forward trident, bias each direction negative if something is found there.
 **/
-vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
-{SELFPARAM();
+vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector vofs)
+{
     vector vt_left, vt_right,vt_front;
     float f_left, f_right,f_front;
     vector leftwish, rightwish,frontwish, v_left;
@@ -317,20 +317,20 @@ vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
 
 
     vt_front = v_forward * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_front,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_front,MOVE_NOMONSTERS,this);
     f_front = trace_fraction;
 
     vt_left = (v_forward + (v_left * pitch)) * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_left,MOVE_NOMONSTERS,this);
     f_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vt_right = (v_forward + (v_right * pitch)) * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_right ,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_right ,MOVE_NOMONSTERS,this);
     f_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     leftwish  = v_left    * f_left;
     rightwish = v_right   * f_right;
@@ -379,15 +379,15 @@ float beamsweep_badpoint(vector point,float waterok)
 }
 
 //#define BEAMSTEER_VISUAL
-float beamsweep(vector from, vector dir,float length, float step,float step_up, float step_down)
-{SELFPARAM();
+float beamsweep(entity this, vector from, vector dir,float length, float step,float step_up, float step_down)
+{
     float i;
     vector a,b,u,d;
 
     u = '0 0 1' * step_up;
     d = '0 0 1' * step_down;
 
-    traceline(from + u, from - d,MOVE_NORMAL,self);
+    traceline(from + u, from - d,MOVE_NORMAL,this);
     if(trace_fraction == 1.0)
         return 0;
 
@@ -399,11 +399,11 @@ float beamsweep(vector from, vector dir,float length, float step,float step_up,
     {
 
         b = a + dir * step;
-        tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,self);
+        tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,this);
         if(trace_fraction != 1.0)
             return i / length;
 
-        traceline(b + u, b - d,MOVE_NORMAL,self);
+        traceline(b + u, b - d,MOVE_NORMAL,this);
         if(trace_fraction == 1.0)
             return i / length;
 
@@ -419,8 +419,8 @@ float beamsweep(vector from, vector dir,float length, float step,float step_up,
     return 1;
 }
 
-vector steerlib_beamsteer(vector dir, float length, float step, float step_up, float step_down)
-{SELFPARAM();
+vector steerlib_beamsteer(entity this, vector dir, float length, float step, float step_up, float step_down)
+{
     float bm_forward, bm_right, bm_left,p;
     vector vr,vl;
 
@@ -428,31 +428,28 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
     vr = vectoangles(dir);
     //vr_x *= -1;
 
-    tracebox(self.origin + '0 0 1' * step_up, self.mins, self.maxs, ('0 0 1' * step_up) + self.origin +  (dir * length), MOVE_NOMONSTERS, self);
+    tracebox(this.origin + '0 0 1' * step_up, this.mins, this.maxs, ('0 0 1' * step_up) + this.origin +  (dir * length), MOVE_NOMONSTERS, this);
     if(trace_fraction == 1.0)
     {
-        //te_lightning1(self,self.origin,self.origin +  (dir * length));
+        //te_lightning1(this,this.origin,this.origin +  (dir * length));
         return dir;
     }
 
-
-
-
     makevectors(vr);
-    bm_forward = beamsweep(self.origin, v_forward, length, step, step_up, step_down);
+    bm_forward = beamsweep(this, this.origin, v_forward, length, step, step_up, step_down);
 
     vr = normalize(v_forward + v_right * 0.125);
     vl = normalize(v_forward - v_right * 0.125);
 
-    bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-    bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+    bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+    bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
 
 
     p = bm_left + bm_right;
     if(p == 2)
     {
-        //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
-        //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+        //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+        //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
 
         return v_forward;
     }
@@ -461,8 +458,8 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
 
     vr = normalize(v_forward + v_right * p);
     vl = normalize(v_forward - v_right * p);
-    bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-    bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+    bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+    bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
 
 
     if(bm_left + bm_right < 0.15)
@@ -470,12 +467,12 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
         vr = normalize((v_forward*-1) + v_right * 0.75);
         vl = normalize((v_forward*-1) - v_right * 0.75);
 
-        bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-        bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+        bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+        bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
     }
 
-    //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
-    //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+    //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+    //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
 
     bm_forward *= bm_forward;
     bm_right   *= bm_right;
@@ -495,15 +492,15 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
 //////////////////////////////////////////////
 //#define TLIBS_TETSLIBS
 #ifdef TLIBS_TETSLIBS
-void flocker_die()
-{SELFPARAM();
-       Send_Effect(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
+void flocker_die(entity this)
+{
+       Send_Effect(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
 
-    self.owner.cnt += 1;
-    self.owner = world;
+    this.owner.cnt += 1;
+    this.owner = world;
 
-    self.nextthink = time;
-    self.think = SUB_Remove;
+    this.nextthink = time;
+    setthink(this, SUB_Remove);
 }
 
 
@@ -512,51 +509,51 @@ void flocker_think()
     vector dodgemove,swarmmove;
     vector reprellmove,wandermove,newmove;
 
-    self.angles_x = self.angles.x * -1;
-    makevectors(self.angles);
-    self.angles_x = self.angles.x * -1;
+    this.angles_x = this.angles.x * -1;
+    makevectors(this.angles);
+    this.angles_x = this.angles.x * -1;
 
-    dodgemove   = steerlib_traceavoid(0.35,1000);
-    swarmmove   = steerlib_flock(500,75,700,500);
-    reprellmove = steerlib_repell(self.owner.enemy.origin+self.enemy.velocity,2000) * 700;
+    dodgemove   = steerlib_traceavoid(this, 0.35,1000);
+    swarmmove   = steerlib_flock(this, 500,75,700,500);
+    reprellmove = steerlib_repell(this, this.owner.enemy.origin+this.enemy.velocity,2000) * 700;
 
-    if(vlen(dodgemove) == 0)
+    if(dodgemove == '0 0 0')
     {
-        self.pos1 = steerlib_wander(0.5,0.1,self.pos1);
-        wandermove  = self.pos1 * 50;
+        this.pos1 = steerlib_wander(this, 0.5,0.1,this.pos1);
+        wandermove  = this.pos1 * 50;
     }
     else
-        self.pos1 = normalize(self.velocity);
+        this.pos1 = normalize(this.velocity);
 
-    dodgemove = dodgemove * vlen(self.velocity) * 5;
+    dodgemove = dodgemove * vlen(this.velocity) * 5;
 
     newmove = swarmmove + reprellmove + wandermove + dodgemove;
-    self.velocity = movelib_inertmove_byspeed(newmove,300,0.2,0.9);
-    //self.velocity  = movelib_inertmove(dodgemove,0.65);
+    this.velocity = movelib_inertmove_byspeed(this, newmove,300,0.2,0.9);
+    //this.velocity  = movelib_inertmove(this, dodgemove,0.65);
 
-    self.velocity = movelib_dragvec(0.01,0.6);
+    this.velocity = movelib_dragvec(this, 0.01,0.6);
 
-    self.angles = vectoangles(self.velocity);
+    this.angles = vectoangles(this.velocity);
 
-    if(self.health <= 0)
-        flocker_die();
+    if(this.health <= 0)
+        flocker_die(this);
     else
-        self.nextthink = time + 0.1;
+        this.nextthink = time + 0.1;
 }
 
 MODEL(FLOCKER, "models/turrets/rocket.md3");
 
-void spawn_flocker()
-{SELFPARAM();
+void spawn_flocker(entity this)
+{
     entity flocker = new(flocker);
 
-    setorigin(flocker, self.origin + '0 0 32');
+    setorigin(flocker, this.origin + '0 0 32');
     setmodel (flocker, MDL_FLOCKER);
     setsize (flocker, '-3 -3 -3', '3 3 3');
 
-    flocker.flock_id   = self.flock_id;
-    flocker.owner      = self;
-    flocker.think      = flocker_think;
+    flocker.flock_id   = this.flock_id;
+    flocker.owner      = this;
+    setthink(flocker, flocker_think);
     flocker.nextthink  = time + random() * 5;
     PROJECTILE_MAKETRIGGER(flocker);
     flocker.movetype   = MOVETYPE_BOUNCEMISSILE;
@@ -566,18 +563,16 @@ void spawn_flocker()
     flocker.health     = 10;
     flocker.pos1      = normalize(flocker.velocity + randomvec() * 0.1);
 
-    self.cnt = self.cnt -1;
+    this.cnt = this.cnt -1;
 
 }
 
 void flockerspawn_think()
 {SELFPARAM();
+    if(this.cnt > 0)
+        spawn_flocker(this);
 
-
-    if(self.cnt > 0)
-        spawn_flocker();
-
-    self.nextthink = time + self.delay;
+    this.nextthink = time + this.delay;
 
 }
 
@@ -587,79 +582,79 @@ void flocker_hunter_think()
     entity e,ee;
     float d,bd;
 
-    self.angles_x = self.angles.x * -1;
-    makevectors(self.angles);
-    self.angles_x = self.angles.x * -1;
+    this.angles_x = this.angles.x * -1;
+    makevectors(this.angles);
+    this.angles_x = this.angles.x * -1;
 
-    if(self.enemy)
-    if(vdist(self.enemy.origin - self.origin, <, 64))
+    if(this.enemy)
+    if(vdist(this.enemy.origin - this.origin, <, 64))
     {
-        ee = self.enemy;
+        ee = this.enemy;
         ee.health = -1;
-        self.enemy = world;
+        this.enemy = world;
 
     }
 
-    if(!self.enemy)
+    if(!this.enemy)
     {
-        e = findchainfloat(flock_id,self.flock_id);
+        e = findchainfloat(flock_id,this.flock_id);
         while(e)
         {
-            d = vlen(self.origin - e.origin);
+            d = vlen(this.origin - e.origin);
 
-            if(e != self.owner)
+            if(e != this.owner)
             if(e != ee)
             if(d > bd)
             {
-                self.enemy = e;
+                this.enemy = e;
                 bd = d;
             }
             e = e.chain;
         }
     }
 
-    if(self.enemy)
-        attractmove = steerlib_attract(self.enemy.origin+self.enemy.velocity * 0.1,5000) * 1250;
+    if(this.enemy)
+        attractmove = steerlib_attract(this, this.enemy.origin+this.enemy.velocity * 0.1,5000) * 1250;
     else
-        attractmove = normalize(self.velocity) * 200;
+        attractmove = normalize(this.velocity) * 200;
 
-    dodgemove = steerlib_traceavoid(0.35,1500) * vlen(self.velocity);
+    dodgemove = steerlib_traceavoid(this, 0.35,1500) * vlen(this.velocity);
 
     newmove = dodgemove + attractmove;
-    self.velocity = movelib_inertmove_byspeed(newmove,1250,0.3,0.7);
-    self.velocity = movelib_dragvec(0.01,0.5);
+    this.velocity = movelib_inertmove_byspeed(this, newmove,1250,0.3,0.7);
+    this.velocity = movelib_dragvec(this, 0.01,0.5);
 
 
-    self.angles = vectoangles(self.velocity);
-    self.nextthink = time + 0.1;
+    this.angles = vectoangles(this.velocity);
+    this.nextthink = time + 0.1;
 }
 
 
 float globflockcnt;
 spawnfunc(flockerspawn)
-{SELFPARAM();
+{
     ++globflockcnt;
 
-    if(!self.cnt)      self.cnt = 20;
-    if(!self.delay)    self.delay = 0.25;
-    if(!self.flock_id) self.flock_id = globflockcnt;
+    if(!this.cnt)      this.cnt = 20;
+    if(!this.delay)    this.delay = 0.25;
+    if(!this.flock_id) this.flock_id = globflockcnt;
 
-    self.think     = flockerspawn_think;
-    self.nextthink = time + 0.25;
+    setthink(this, flockerspawn_think);
+    this.nextthink = time + 0.25;
 
-    self.enemy = new(FLock Hunter);
+    this.enemy = new(FLock Hunter);
 
-    setmodel(self.enemy, MDL_FLOCKER);
-    setorigin(self.enemy,self.origin + '0 0 768' + (randomvec() * 128));
+    setmodel(this.enemy, MDL_FLOCKER);
+    setorigin(this.enemy,this.origin + '0 0 768' + (randomvec() * 128));
 
-    self.enemy.scale     = 3;
-    self.enemy.effects   = EF_LOWPRECISION;
-    self.enemy.movetype  = MOVETYPE_BOUNCEMISSILE;
-    PROJECTILE_MAKETRIGGER(self.enemy);
-    self.enemy.think     = flocker_hunter_think;
-    self.enemy.nextthink = time + 10;
-    self.enemy.flock_id  = self.flock_id;
-    self.enemy.owner     = self;
+    this.enemy.scale     = 3;
+    this.enemy.effects   = EF_LOWPRECISION;
+    this.enemy.movetype  = MOVETYPE_BOUNCEMISSILE;
+    PROJECTILE_MAKETRIGGER(this.enemy);
+    setthink(this.enemy, flocker_hunter_think);
+    this.enemy.nextthink = time + 10;
+    this.enemy.flock_id  = this.flock_id;
+    this.enemy.owner     = this;
 }
 #endif
 
index 32ac07c3cda37b75d951f8e00197beb0428d30ee..fa21610f042d29c794149cb2a28a0ec02a824569 100644 (file)
@@ -2,6 +2,6 @@
 
 .vector steerto;
 
-vector steerlib_arrive(vector point,float maximal_distance);
-vector steerlib_attract2(entity this, vector point, float min_influense,float max_distance,float max_influense);
-vector steerlib_pull(vector point);
+vector steerlib_arrive(entity this, vector point, float maximal_distance);
+vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense);
+vector steerlib_pull(entity this, vector point);
index e7d6dbfb5b2b9f34cc5eb967930ce4d3d34e5ca7..b33b96db1b2cb02cd24af7205b5e005d82ec406f 100644 (file)
@@ -236,24 +236,24 @@ void StartFrame()
 .float anglejitter;
 .string gametypefilter;
 .string cvarfilter;
-float DoesQ3ARemoveThisEntity();
+bool DoesQ3ARemoveThisEntity(entity this);
 void SV_OnEntityPreSpawnFunction()
 {SELFPARAM();
        __spawnfunc_expect = this;
-       if (self)
-       if (self.gametypefilter != "")
-       if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
+       if (this)
+       if (this.gametypefilter != "")
+       if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, this.gametypefilter))
        {
-               remove(self);
+               remove(this);
                return;
        }
-       if(self.cvarfilter != "")
+       if(this.cvarfilter != "")
        {
                float n, i, o, inv;
                string s, k, v;
                inv = 0;
 
-               s = self.cvarfilter;
+               s = this.cvarfilter;
                if(substring(s, 0, 1) == "+")
                {
                        s = substring(s, 1, -1);
@@ -352,41 +352,41 @@ LABEL(cvar_fail)
                if (!inv)
                {
                        //print("cvarfilter fail\n");
-                       remove(self);
+                       remove(this);
                        return;
                }
        }
 
-       if(DoesQ3ARemoveThisEntity())
+       if(DoesQ3ARemoveThisEntity(this))
        {
-               remove(self);
+               remove(this);
                return;
        }
 
        // support special -1 and -2 angle from radiant
-       if (self.angles == '0 -1 0')
-               self.angles = '-90 0 0';
-       else if (self.angles == '0 -2 0')
-               self.angles = '+90 0 0';
-
-       if(self.originjitter.x != 0)
-               self.origin_x = self.origin.x + (random() * 2 - 1) * self.originjitter.x;
-       if(self.originjitter.y != 0)
-               self.origin_y = self.origin.y + (random() * 2 - 1) * self.originjitter.y;
-       if(self.originjitter.z != 0)
-               self.origin_z = self.origin.z + (random() * 2 - 1) * self.originjitter.z;
-       if(self.anglesjitter.x != 0)
-               self.angles_x = self.angles.x + (random() * 2 - 1) * self.anglesjitter.x;
-       if(self.anglesjitter.y != 0)
-               self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglesjitter.y;
-       if(self.anglesjitter.z != 0)
-               self.angles_z = self.angles.z + (random() * 2 - 1) * self.anglesjitter.z;
-       if(self.anglejitter != 0)
-               self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglejitter;
-
-       if(MUTATOR_CALLHOOK(OnEntityPreSpawn))
+       if (this.angles == '0 -1 0')
+               this.angles = '-90 0 0';
+       else if (this.angles == '0 -2 0')
+               this.angles = '+90 0 0';
+
+       if(this.originjitter.x != 0)
+               this.origin_x = this.origin.x + (random() * 2 - 1) * this.originjitter.x;
+       if(this.originjitter.y != 0)
+               this.origin_y = this.origin.y + (random() * 2 - 1) * this.originjitter.y;
+       if(this.originjitter.z != 0)
+               this.origin_z = this.origin.z + (random() * 2 - 1) * this.originjitter.z;
+       if(this.anglesjitter.x != 0)
+               this.angles_x = this.angles.x + (random() * 2 - 1) * this.anglesjitter.x;
+       if(this.anglesjitter.y != 0)
+               this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglesjitter.y;
+       if(this.anglesjitter.z != 0)
+               this.angles_z = this.angles.z + (random() * 2 - 1) * this.anglesjitter.z;
+       if(this.anglejitter != 0)
+               this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglejitter;
+
+       if(MUTATOR_CALLHOOK(OnEntityPreSpawn, this))
        {
-               remove(self);
+               remove(this);
                return;
        }
 }
index c41f8ccf8cd5c50b739e2f720337e7985bbb9f5e..9096acc23576aecce3d20fd93d0759c0622bbb76 100644 (file)
@@ -21,8 +21,8 @@ spawnfunc(weapon_supershotgun) {spawnfunc_weapon_machinegun(this);}
 spawnfunc(item_spikes) {spawnfunc_item_bullets(this);}
 //spawnfunc(item_armor1) {spawnfunc_item_armor_medium(this);}  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
 spawnfunc(item_armor2) {spawnfunc_item_armor_large(this);}
-void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(self);}
-spawnfunc(item_health) {if (self.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
+void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(this);} // FIXME: we require spawnfunc_ prefix for functions to be map entities
+spawnfunc(item_health) {if (this.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
 
 //spawnfunc_item_spikes
 //spawnfunc_item_health
index ef614c7ac3eaf55885ae4bb8d99246e8ac9d09f3..4caadee23834008b4ca124baeffe25baf7859296 100644 (file)
@@ -88,58 +88,58 @@ void target_init_verify(entity this)
 
 spawnfunc(target_init)
 {
-       self.spawnflags = 0; // remove all weapons except the ones listed below
-       self.netname = "shotgun"; // keep these weapons through the remove trigger
+       this.spawnflags = 0; // remove all weapons except the ones listed below
+       this.netname = "shotgun"; // keep these weapons through the remove trigger
        spawnfunc_target_items(this);
-       InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+       InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
 }
 
 // weapon give ent from defrag
 void target_give_init(entity this)
 {
        entity targ;
-       for (targ = world; (targ = find(targ, targetname, self.target)); ) {
+       for (targ = world; (targ = find(targ, targetname, this.target)); ) {
                if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
-                       self.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
-                       self.netname = "devastator";
+                       this.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
+                       this.netname = "devastator";
                }
                else if (targ.classname == "weapon_plasmagun") {
-                       self.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
-                       if(self.netname == "")
-                               self.netname = "hagar";
+                       this.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
+                       if(this.netname == "")
+                               this.netname = "hagar";
                        else
-                               self.netname = strcat(self.netname, " hagar");
+                               this.netname = strcat(this.netname, " hagar");
                }
                else if (targ.classname == "weapon_bfg") {
-                       self.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
-                       if(self.netname == "")
-                               self.netname = "crylink";
+                       this.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
+                       if(this.netname == "")
+                               this.netname = "crylink";
                        else
-                               self.netname = strcat(self.netname, " crylink");
+                               this.netname = strcat(this.netname, " crylink");
                }
                else if (targ.classname == "weapon_grenadelauncher" || targ.classname == "weapon_mortar") {
-                       self.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
-                       if(self.netname == "")
-                               self.netname = "mortar";
+                       this.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
+                       if(this.netname == "")
+                               this.netname = "mortar";
                        else
-                               self.netname = strcat(self.netname, " mortar");
+                               this.netname = strcat(this.netname, " mortar");
                }
                else if (targ.classname == "item_armor_body")
-                       self.armorvalue = 100;
+                       this.armorvalue = 100;
                else if (targ.classname == "item_health_mega")
-                       self.health = 200;
+                       this.health = 200;
                //remove(targ); // removing ents in init functions causes havoc, workaround:
-        targ.think = SUB_Remove_self;
+        setthink(targ, SUB_Remove);
         targ.nextthink = time;
        }
-       self.spawnflags = 2;
+       this.spawnflags = 2;
        spawnfunc_target_items(this);
-       InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+       InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
 }
 
 spawnfunc(target_give)
 {
-       InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
+       InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
 }
 
 //spawnfunc(item_flight)       /* handled by jetpack */
@@ -164,31 +164,31 @@ spawnfunc(item_flight)
 .float notq3a;
 .float notta;
 .string gametype;
-float DoesQ3ARemoveThisEntity()
-{SELFPARAM();
+bool DoesQ3ARemoveThisEntity(entity this)
+{
        // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
 
-       if(self.notq3a)
+       if(this.notq3a)
                if(!teamplay || g_tdm || g_ctf)
-                       return 1;
+                       return true;
 
-       if(self.notta)
+       if(this.notta)
                if (!(!teamplay || g_tdm || g_ctf))
-                       return 1;
+                       return true;
 
-       if(self.notsingle)
+       if(this.notsingle)
                if(maxclients == 1)
-                       return 1;
+                       return true;
 
-       if(self.notteam)
+       if(this.notteam)
                if(teamplay)
-                       return 1;
+                       return true;
 
-       if(self.notfree)
+       if(this.notfree)
                if(!teamplay)
-                       return 1;
+                       return true;
 
-       if(self.gametype)
+       if(this.gametype)
        {
                string gametypename;
                // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
@@ -200,9 +200,9 @@ float DoesQ3ARemoveThisEntity()
                if(maxclients == 1)
                        gametypename = "single";
                // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
-               if(strstrofs(self.gametype, gametypename, 0) < 0)
-                       return 1;
+               if(strstrofs(this.gametype, gametypename, 0) < 0)
+                       return true;
        }
 
-       return 0;
+       return false;
 }
index c275faa7c300b3d97c1115f47603f06317108388..7d31de0aeab695c2834d06c6bac51638cd9cdd06 100644 (file)
@@ -80,11 +80,11 @@ void InitGameplayMode()
        InitializeEntity(world, default_delayedinit, INITPRIO_GAMETYPE_FALLBACK);
 }
 
-string GetClientVersionMessage()
-{SELFPARAM();
+string GetClientVersionMessage(entity this)
+{
        string versionmsg;
-       if (self.version_mismatch) {
-               if(self.version < autocvar_gameversion) {
+       if (this.version_mismatch) {
+               if(this.version < autocvar_gameversion) {
                        versionmsg = "^3Your client version is outdated.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nPlease update!!!^8";
                } else {
                        versionmsg = "^3This server is using an outdated Xonotic version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8";
@@ -95,7 +95,7 @@ string GetClientVersionMessage()
        return versionmsg;
 }
 
-string getwelcomemessage()
+string getwelcomemessage(entity this)
 {
        string s, modifications, motd;
 
@@ -123,8 +123,7 @@ string getwelcomemessage()
                modifications = strcat(modifications, ", Powerups");
        modifications = substring(modifications, 2, strlen(modifications) - 2);
 
-       string versionmessage;
-       versionmessage = GetClientVersionMessage();
+       string versionmessage = GetClientVersionMessage(this);
 
        s = strcat("This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage);
        s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n");
@@ -206,7 +205,7 @@ void SetPlayerTeam(entity pl, float t, float s, float noprint)
 
 // set c1...c4 to show what teams are allowed
 void CheckAllowedTeams (entity for_whom)
-{SELFPARAM();
+{
        int dm = 0;
 
        c1 = c2 = c3 = c4 = -1;
@@ -268,14 +267,17 @@ void CheckAllowedTeams (entity for_whom)
                }
        }
 
+       if(!for_whom)
+               return;
+
        // if player has a forced team, ONLY allow that one
-       if(self.team_forced == NUM_TEAM_1 && c1 >= 0)
+       if(for_whom.team_forced == NUM_TEAM_1 && c1 >= 0)
                c2 = c3 = c4 = -1;
-       else if(self.team_forced == NUM_TEAM_2 && c2 >= 0)
+       else if(for_whom.team_forced == NUM_TEAM_2 && c2 >= 0)
                c1 = c3 = c4 = -1;
-       else if(self.team_forced == NUM_TEAM_3 && c3 >= 0)
+       else if(for_whom.team_forced == NUM_TEAM_3 && c3 >= 0)
                c1 = c2 = c4 = -1;
-       else if(self.team_forced == NUM_TEAM_4 && c4 >= 0)
+       else if(for_whom.team_forced == NUM_TEAM_4 && c4 >= 0)
                c1 = c2 = c3 = -1;
 }
 
@@ -480,8 +482,8 @@ float FindSmallestTeam(entity pl, float ignore_pl)
        return RandomSelection_chosen_float;
 }
 
-int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam)
-{SELFPARAM();
+int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
+{
        float smallest, selectedteam;
 
        // don't join a team if we're not playing a team game
@@ -489,20 +491,20 @@ int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam)
                return 0;
 
        // find out what teams are available
-       CheckAllowedTeams(pl);
+       CheckAllowedTeams(this);
 
        // if we don't care what team he ends up on, put him on whatever team he entered as.
        // if he's not on a valid team, then let other code put him on the smallest team
        if(!forcebestteam)
        {
-               if(     c1 >= 0 && pl.team == NUM_TEAM_1)
-                       selectedteam = pl.team;
-               else if(c2 >= 0 && pl.team == NUM_TEAM_2)
-                       selectedteam = pl.team;
-               else if(c3 >= 0 && pl.team == NUM_TEAM_3)
-                       selectedteam = pl.team;
-               else if(c4 >= 0 && pl.team == NUM_TEAM_4)
-                       selectedteam = pl.team;
+               if(     c1 >= 0 && this.team == NUM_TEAM_1)
+                       selectedteam = this.team;
+               else if(c2 >= 0 && this.team == NUM_TEAM_2)
+                       selectedteam = this.team;
+               else if(c3 >= 0 && this.team == NUM_TEAM_3)
+                       selectedteam = this.team;
+               else if(c4 >= 0 && this.team == NUM_TEAM_4)
+                       selectedteam = this.team;
                else
                        selectedteam = -1;
 
@@ -510,47 +512,47 @@ int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam)
                {
                        if(!only_return_best)
                        {
-                               SetPlayerColors(pl, selectedteam - 1);
+                               SetPlayerColors(this, selectedteam - 1);
 
                                // when JoinBestTeam is called by client.qc/ClientKill_Now_TeamChange the players team is -1 and thus skipped
                                // when JoinBestTeam is called by cl_client.qc/ClientConnect the player_id is 0 the log attempt is rejected
-                               LogTeamchange(pl.playerid, pl.team, 99);
+                               LogTeamchange(this.playerid, this.team, 99);
                        }
                        return selectedteam;
                }
                // otherwise end up on the smallest team (handled below)
        }
 
-       smallest = FindSmallestTeam(pl, true);
+       smallest = FindSmallestTeam(this, true);
 
-       if(!only_return_best && !pl.bot_forced_team)
+       if(!only_return_best && !this.bot_forced_team)
        {
-               TeamchangeFrags(self);
+               TeamchangeFrags(this);
                if(smallest == 1)
                {
-                       SetPlayerColors(pl, NUM_TEAM_1 - 1);
+                       SetPlayerColors(this, NUM_TEAM_1 - 1);
                }
                else if(smallest == 2)
                {
-                       SetPlayerColors(pl, NUM_TEAM_2 - 1);
+                       SetPlayerColors(this, NUM_TEAM_2 - 1);
                }
                else if(smallest == 3)
                {
-                       SetPlayerColors(pl, NUM_TEAM_3 - 1);
+                       SetPlayerColors(this, NUM_TEAM_3 - 1);
                }
                else if(smallest == 4)
                {
-                       SetPlayerColors(pl, NUM_TEAM_4 - 1);
+                       SetPlayerColors(this, NUM_TEAM_4 - 1);
                }
                else
                {
                        error("smallest team: invalid team\n");
                }
 
-               LogTeamchange(pl.playerid, pl.team, 2); // log auto join
+               LogTeamchange(this.playerid, this.team, 2); // log auto join
 
-               if(!IS_DEAD(pl))
-                       Damage(pl, pl, pl, 100000, DEATH_TEAMCHANGE.m_id, pl.origin, '0 0 0');
+               if(!IS_DEAD(this))
+                       Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
        }
 
        return smallest;
@@ -563,19 +565,19 @@ void SV_ChangeTeam(float _color)
 
        // in normal deathmatch we can just apply the color and we're done
        if(!teamplay)
-               SetPlayerColors(self, _color);
+               SetPlayerColors(this, _color);
 
-       if(!IS_CLIENT(self))
+       if(!IS_CLIENT(this))
        {
                // since this is an engine function, and gamecode doesn't have any calls earlier than this, do the connecting message here
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CONNECTING, self.netname);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_CONNECTING, this.netname);
                return;
        }
 
        if(!teamplay)
                return;
 
-       scolor = self.clientcolors & 0x0F;
+       scolor = this.clientcolors & 0x0F;
        dcolor = _color & 0x0F;
 
        if(scolor == NUM_TEAM_1 - 1)
@@ -595,7 +597,7 @@ void SV_ChangeTeam(float _color)
        else // if(dcolor == NUM_TEAM_4 - 1)
                dteam = 4;
 
-       CheckAllowedTeams(self);
+       CheckAllowedTeams(this);
 
        if(dteam == 1 && c1 < 0) dteam = 4;
        if(dteam == 4 && c4 < 0) dteam = 3;
@@ -606,43 +608,43 @@ void SV_ChangeTeam(float _color)
        if(scolor == dcolor)
        {
                //bprint("same team change\n");
-               SetPlayerTeam(self, dteam, steam, true);
+               SetPlayerTeam(this, dteam, steam, true);
                return;
        }
 
-       if((autocvar_g_campaign) || (autocvar_g_changeteam_banned && self.wasplayer)) {
-               Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED);
+       if((autocvar_g_campaign) || (autocvar_g_changeteam_banned && this.wasplayer)) {
+               Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED);
                return; // changing teams is not allowed
        }
 
        // autocvar_g_balance_teams_prevent_imbalance only makes sense if autocvar_g_balance_teams is on, as it makes the team selection dialog pointless
        if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)
        {
-               GetTeamCounts(self);
-               if(!TeamSmallerEqThanTeam(dteam, steam, self))
+               GetTeamCounts(this);
+               if(!TeamSmallerEqThanTeam(dteam, steam, this))
                {
-                       Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
+                       Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
                        return;
                }
        }
 
 //     bprint("allow change teams from ", ftos(steam), " to ", ftos(dteam), "\n");
 
-       if(IS_PLAYER(self) && steam != dteam)
+       if(IS_PLAYER(this) && steam != dteam)
        {
                // reduce frags during a team change
-               TeamchangeFrags(self);
+               TeamchangeFrags(this);
        }
 
-       MUTATOR_CALLHOOK(Player_ChangeTeam, self, steam, dteam);
+       MUTATOR_CALLHOOK(Player_ChangeTeam, this, steam, dteam);
 
-       SetPlayerTeam(self, dteam, steam, !IS_CLIENT(self));
+       SetPlayerTeam(this, dteam, steam, !IS_CLIENT(this));
 
-       if(IS_PLAYER(self) && steam != dteam)
+       if(IS_PLAYER(this) && steam != dteam)
        {
                // kill player when changing teams
-               if(!IS_DEAD(self))
-                       Damage(self, self, self, 100000, DEATH_TEAMCHANGE.m_id, self.origin, '0 0 0');
+               if(!IS_DEAD(this))
+                       Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
        }
 }
 
index df82a9cae6040e830e077a22bee2f13db963db9d..c9713984e809a2a1fc49a1c4f7ca61910b0dcdb5 100644 (file)
@@ -22,9 +22,9 @@ void ActivateTeamplay();
 
 void InitGameplayMode();
 
-string GetClientVersionMessage();
+string GetClientVersionMessage(entity this);
 
-string getwelcomemessage();
+string getwelcomemessage(entity this);
 
 void SetPlayerColors(entity pl, float _color);
 
@@ -45,7 +45,7 @@ float TeamSmallerEqThanTeam(float ta, float tb, entity e);
 // NOTE: Assumes CheckAllowedTeams has already been called!
 float FindSmallestTeam(entity pl, float ignore_pl);
 
-int JoinBestTeam(entity pl, bool only_return_best, bool forcebestteam);
+int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam);
 
 //void() ctf_playerchanged;
 void SV_ChangeTeam(float _color);
index 4a06e16661027b650be469a327af68badd70b93d..954f82564fb9a5e17a8ee49924987c3c45e22a00 100644 (file)
@@ -73,7 +73,7 @@ float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype,
        return true; // if none of these return, then allow damage anyway.
 }
 
-void W_PrepareExplosionByDamage(entity this, entity attacker, void() explode)
+void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
 {
        this.takedamage = DAMAGE_NO;
        this.event_damage = func_null;
@@ -89,5 +89,5 @@ void W_PrepareExplosionByDamage(entity this, entity attacker, void() explode)
        // do not explode NOW but in the NEXT FRAME!
        // because recursive calls to RadiusDamage are not allowed
        this.nextthink = time;
-       this.think = explode;
+       setthink(this, explode);
 }
index 2ab8ea5acca6832f9eda13b257ff006cf0f8cbee..363941b3a71210d24917f897f37c92c52f254d5b 100644 (file)
@@ -5,4 +5,4 @@ void W_GiveWeapon (entity e, float wep);
 .float prevstrengthsoundattempt;
 void W_PlayStrengthSound(entity player);
 float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception);
-void W_PrepareExplosionByDamage(entity this, entity attacker, void() explode);
+void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode);
index f3e9f22ef6859a2b8e538a39e6b14be0b602c92f..0edf22664ae8eba7e89fff4851c5c98001019b17 100644 (file)
@@ -16,22 +16,22 @@ bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
        // note: flag 0x08 = no trail please (teleport bit)
        sf = sf & 0x0F;
 
-       if(self.csqcprojectile_clientanimate)
+       if(this.csqcprojectile_clientanimate)
                sf |= 0x80; // client animated, not interpolated
 
-       if(IS_ONGROUND(self))
+       if(IS_ONGROUND(this))
                sf |= 0x40;
 
        ft = fr = 0;
-       if(self.fade_time != 0 || self.fade_rate != 0)
+       if(this.fade_time != 0 || this.fade_rate != 0)
        {
-               ft = (self.fade_time - time) / sys_frametime;
-               fr = (1 / self.fade_rate) / sys_frametime;
+               ft = (this.fade_time - time) / sys_frametime;
+               fr = (1 / this.fade_rate) / sys_frametime;
                if(ft <= 255 && fr <= 255 && fr >= 1)
                        sf |= 0x20;
        }
 
-       if(self.gravity != 0)
+       if(this.gravity != 0)
                sf |= 0x10;
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
@@ -39,17 +39,17 @@ bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
 
        if(sf & 1)
        {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
+               WriteCoord(MSG_ENTITY, this.origin.x);
+               WriteCoord(MSG_ENTITY, this.origin.y);
+               WriteCoord(MSG_ENTITY, this.origin.z);
 
                if(sf & 0x80)
                {
-                       WriteCoord(MSG_ENTITY, self.velocity.x);
-                       WriteCoord(MSG_ENTITY, self.velocity.y);
-                       WriteCoord(MSG_ENTITY, self.velocity.z);
+                       WriteCoord(MSG_ENTITY, this.velocity.x);
+                       WriteCoord(MSG_ENTITY, this.velocity.y);
+                       WriteCoord(MSG_ENTITY, this.velocity.z);
                        if(sf & 0x10)
-                               WriteCoord(MSG_ENTITY, self.gravity);
+                               WriteCoord(MSG_ENTITY, this.gravity);
                }
 
                if(sf & 0x20)
@@ -58,11 +58,11 @@ bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
                        WriteByte(MSG_ENTITY, fr);
                }
 
-               WriteByte(MSG_ENTITY, self.realowner.team);
+               WriteByte(MSG_ENTITY, this.realowner.team);
        }
 
        if(sf & 2)
-               WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
+               WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
 
        return true;
 }
index 27d35643de1415f389a6ed61819ce3f22983e69c..70284a8f4b421055768b2db0658199ab7d4bd83c 100644 (file)
@@ -40,43 +40,42 @@ void Weapon_whereis(Weapon this, entity cl)
        }
 }
 
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain)
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
 {
-    SELFPARAM();
        float f = 0;
 
-       if (time < cl.hasweapon_complain_spam)
+       if (time < this.hasweapon_complain_spam)
                complain = 0;
 
        // ignore hook button when using other offhand equipment
-       if (cl.offhand != OFFHAND_HOOK)
-       if (wpn == WEP_HOOK && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
+       if (this.offhand != OFFHAND_HOOK)
+       if (wpn == WEP_HOOK && !((this.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
            complain = 0;
 
        if (complain)
-               cl.hasweapon_complain_spam = time + 0.2;
+               this.hasweapon_complain_spam = time + 0.2;
 
        if (wpn == WEP_Null)
        {
                if (complain)
-                       sprint(cl, "Invalid weapon\n");
+                       sprint(this, "Invalid weapon\n");
                return false;
        }
-       if (cl.weapons & WepSet_FromWeapon(wpn))
+       if (this.weapons & WepSet_FromWeapon(wpn))
        {
                if (andammo)
                {
-                       if(cl.items & IT_UNLIMITED_WEAPON_AMMO)
+                       if(this.items & IT_UNLIMITED_WEAPON_AMMO)
                        {
                                f = 1;
                        }
                        else
                        {
-                               WITHSELF(cl, f = wpn.wr_checkammo1(wpn) + wpn.wr_checkammo2(wpn));
+                               f = wpn.wr_checkammo1(wpn, this) + wpn.wr_checkammo2(wpn, this);
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
                                if(wpn == WEP_MINE_LAYER)
-                                       FOREACH_ENTITY_CLASS("mine", it.owner == cl,
+                                       FOREACH_ENTITY_CLASS("mine", it.owner == this,
                                        {
                                                f = 1;
                                                break; // no need to continue
@@ -85,10 +84,10 @@ bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain)
                        if (!f)
                        {
                                if (complain)
-                               if(IS_REAL_CLIENT(cl))
+                               if(IS_REAL_CLIENT(this))
                                {
-                                       play2(cl, SND(UNAVAILABLE));
-                                       Send_WeaponComplain (cl, wpn.m_id, 0);
+                                       play2(this, SND(UNAVAILABLE));
+                                       Send_WeaponComplain (this, wpn.m_id, 0);
                                }
                                return false;
                        }
@@ -101,21 +100,21 @@ bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain)
                // Report Proper Weapon Status / Modified Weapon Ownership Message
                if (weaponsInMap & WepSet_FromWeapon(wpn))
                {
-                       Send_WeaponComplain(cl, wpn.m_id, 1);
-                       Weapon_whereis(wpn, cl);
+                       Send_WeaponComplain(this, wpn.m_id, 1);
+                       Weapon_whereis(wpn, this);
                }
                else
                {
-                       Send_WeaponComplain (cl, wpn.m_id, 2);
+                       Send_WeaponComplain (this, wpn.m_id, 2);
                }
 
-               play2(cl, SND(UNAVAILABLE));
+               play2(this, SND(UNAVAILABLE));
        }
        return false;
 }
 
-float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
-{SELFPARAM();
+float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing)
+{
        // We cannot tokenize in this function, as GiveItems calls this
        // function. Thus we must use car/cdr.
        float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
@@ -125,10 +124,10 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        float weaponcur;
        entity wep;
 
-       if(skipmissing || pl.selectweapon == 0)
-               weaponcur = PS(pl).m_switchweapon.m_id;
+       if(skipmissing || this.selectweapon == 0)
+               weaponcur = PS(this).m_switchweapon.m_id;
        else
-               weaponcur = pl.selectweapon;
+               weaponcur = this.selectweapon;
 
        if(dir == 0)
                switchtonext = 1;
@@ -149,19 +148,19 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                FOREACH(Weapons, it != WEP_Null, {
                        if(i != weaponwant)
                        if(it.impulse == imp || imp < 0)
-                       if((pl.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+                       if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
                                have_other = true;
                });
 
                // skip weapons we don't own that aren't normal and aren't in the map
-               if(!(pl.weapons & wepset))
+               if(!(this.weapons & wepset))
                if(!(weaponsInMap & wepset))
                if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
                        continue;
 
                ++c;
 
-               if(!skipmissing || client_hasweapon(pl, wep, true, false))
+               if(!skipmissing || client_hasweapon(this, wep, true, false))
                {
                        if(switchtonext)
                                return weaponwant;
@@ -189,8 +188,8 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        // complain (but only for one weapon on the button that has been pressed)
        if(complain)
        {
-               self.weaponcomplainindex += 1;
-               c = (self.weaponcomplainindex % c) + 1;
+               this.weaponcomplainindex += 1;
+               c = (this.weaponcomplainindex % c) + 1;
                rest = weaponorder;
                while(rest != "")
                {
@@ -205,12 +204,12 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                        FOREACH(Weapons, it != WEP_Null, {
                                if(i != weaponwant)
                                if(it.impulse == imp || imp < 0)
-                               if((pl.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+                               if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
                                        have_other = true;
                        });
 
                        // skip weapons we don't own that aren't normal and aren't in the map
-                       if(!(pl.weapons & wepset))
+                       if(!(this.weapons & wepset))
                        if(!(weaponsInMap & wepset))
                        if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
                                continue;
@@ -218,7 +217,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                        --c;
                        if(c == 0)
                        {
-                               client_hasweapon(pl, wep, true, true);
+                               client_hasweapon(this, wep, true, true);
                                break;
                        }
                }
@@ -235,77 +234,77 @@ void W_SwitchWeapon_Force(Player this, Weapon wep)
 }
 
 // perform weapon to attack (weaponstate and attack_finished check is here)
-void W_SwitchToOtherWeapon(entity pl)
+void W_SwitchToOtherWeapon(entity this)
 {
        // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
        Weapon ww;
-       WepSet set = WepSet_FromWeapon(PS(pl).m_weapon);
-       if (pl.weapons & set)
+       WepSet set = WepSet_FromWeapon(PS(this).m_weapon);
+       if (this.weapons & set)
        {
-               pl.weapons &= ~set;
-               ww = w_getbestweapon(pl);
-               pl.weapons |= set;
+               this.weapons &= ~set;
+               ww = w_getbestweapon(this);
+               this.weapons |= set;
        }
        else
        {
-               ww = w_getbestweapon(pl);
+               ww = w_getbestweapon(this);
        }
        if (ww == WEP_Null) return;
-       W_SwitchWeapon_Force(pl, ww);
+       W_SwitchWeapon_Force(this, ww);
 }
 
-void W_SwitchWeapon(Weapon w)
-{SELFPARAM();
-       if (PS(self).m_switchweapon != w)
+void W_SwitchWeapon(entity this, Weapon w)
+{
+       if (PS(this).m_switchweapon != w)
        {
-               if (client_hasweapon(self, w, true, true))
-                       W_SwitchWeapon_Force(self, w);
+               if (client_hasweapon(this, w, true, true))
+                       W_SwitchWeapon_Force(this, w);
                else
-                       self.selectweapon = w.m_id; // update selectweapon ANYWAY
+                       this.selectweapon = w.m_id; // update selectweapon ANYWAY
        }
-       else if(!forbidWeaponUse(self)) {
+       else if(!forbidWeaponUse(this)) {
                entity actor = this;
                .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                w.wr_reload(w, actor, weaponentity);
        }
 }
 
-void W_CycleWeapon(string weaponorder, float dir)
-{SELFPARAM();
+void W_CycleWeapon(entity this, string weaponorder, float dir)
+{
        float w;
-       w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true);
+       w = W_GetCycleWeapon(this, weaponorder, dir, -1, 1, true);
        if(w > 0)
-               W_SwitchWeapon(Weapons_from(w));
+               W_SwitchWeapon(this, Weapons_from(w));
 }
 
-void W_NextWeaponOnImpulse(float imp)
-{SELFPARAM();
+void W_NextWeaponOnImpulse(entity this, float imp)
+{
        float w;
-       w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0));
+       w = W_GetCycleWeapon(this, this.cvar_cl_weaponpriority, +1, imp, 1, (this.cvar_cl_weaponimpulsemode == 0));
        if(w > 0)
-               W_SwitchWeapon(Weapons_from(w));
+               W_SwitchWeapon(this, Weapons_from(w));
 }
 
 // next weapon
-void W_NextWeapon(float list)
-{SELFPARAM();
+void W_NextWeapon(entity this, int list)
+{
        if(list == 0)
-               W_CycleWeapon(weaponorder_byid, -1);
+               W_CycleWeapon(this, weaponorder_byid, -1);
        else if(list == 1)
-               W_CycleWeapon(self.weaponorder_byimpulse, -1);
+               W_CycleWeapon(this, this.weaponorder_byimpulse, -1);
        else if(list == 2)
-               W_CycleWeapon(self.cvar_cl_weaponpriority, -1);
+               W_CycleWeapon(this, this.cvar_cl_weaponpriority, -1);
 }
 
 // prev weapon
-void W_PreviousWeapon(float list)
-{SELFPARAM();
+void W_PreviousWeapon(entity this, float list)
+{
        if(list == 0)
-               W_CycleWeapon(weaponorder_byid, +1);
+               W_CycleWeapon(this, weaponorder_byid, +1);
        else if(list == 1)
-               W_CycleWeapon(self.weaponorder_byimpulse, +1);
+               W_CycleWeapon(this, this.weaponorder_byimpulse, +1);
        else if(list == 2)
-               W_CycleWeapon(self.cvar_cl_weaponpriority, +1);
+               W_CycleWeapon(this, this.cvar_cl_weaponpriority, +1);
 }
 
 // previously used if exists and has ammo, (second) best otherwise
@@ -313,7 +312,7 @@ void W_LastWeapon(entity this)
 {
        Weapon wep = Weapons_from(this.cnt);
        if (client_hasweapon(this, wep, true, false))
-               W_SwitchWeapon(wep);
+               W_SwitchWeapon(this, wep);
        else
                W_SwitchToOtherWeapon(this);
 }
index 07f27f5b5d2f17e4c99f298caf3552090130beaa..0c30b7c1215040fd7bc2de7256f0dcd67b6095fc 100644 (file)
@@ -4,28 +4,28 @@
 void Send_WeaponComplain(entity e, float wpn, float type);
 
 .float hasweapon_complain_spam;
-bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain);
+bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain);
 
 .int weaponcomplainindex;
-float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing);
+float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing);
 
 #define w_getbestweapon(ent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true))
 
 void W_SwitchWeapon_Force(Player this, Weapon w);
 
 // perform weapon to attack (weaponstate and attack_finished check is here)
-void W_SwitchToOtherWeapon(entity pl);
-void W_SwitchWeapon(Weapon imp);
+void W_SwitchToOtherWeapon(entity this);
+void W_SwitchWeapon(entity this, Weapon imp);
 
-void W_CycleWeapon(string weaponorder, float dir);
+void W_CycleWeapon(entity this, string weaponorder, float dir);
 
-void W_NextWeaponOnImpulse(float imp);
+void W_NextWeaponOnImpulse(entity this, float imp);
 
 // next weapon
-void W_NextWeapon(float list);
+void W_NextWeapon(entity this, float list);
 
 // prev weapon
-void W_PreviousWeapon(float list);
+void W_PreviousWeapon(entity this, float list);
 
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(entity this);
index c06b08c08ac2a387618e90a6cc1f18357278b218..fe59b5bfbbc3a5f45a494021ad41960df96ac41f 100644 (file)
 #include <common/weapons/all.qh>
 #include <common/state.qh>
 
-void thrown_wep_think()
-{SELFPARAM();
-       self.nextthink = time;
-       if(self.oldorigin != self.origin)
+void thrown_wep_think(entity this)
+{
+       this.nextthink = time;
+       if(this.oldorigin != this.origin)
        {
-               self.SendFlags |= ISF_LOCATION;
-               self.oldorigin = self.origin;
+               this.SendFlags |= ISF_LOCATION;
+               this.oldorigin = this.origin;
        }
-       self.owner = world;
-       float timeleft = self.savenextthink - time;
+       this.owner = world;
+       float timeleft = this.savenextthink - time;
        if(timeleft > 1)
-               SUB_SetFade(self, self.savenextthink - 1, 1);
+               SUB_SetFade(this, this.savenextthink - 1, 1);
        else if(timeleft > 0)
-               SUB_SetFade(self, time, timeleft);
+               SUB_SetFade(this, time, timeleft);
        else
-               SUB_VanishOrRemove(self);
+               SUB_VanishOrRemove(this);
 }
 
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
-{SELFPARAM();
+{
        float thisammo;
        string s;
        Weapon info = Weapons_from(wpn);
@@ -80,7 +80,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        if(startitem_failed)
                return string_null;
        wep.glowmod = weaponentity_glowmod(info, own.clientcolors);
-       wep.think = thrown_wep_think;
+       setthink(wep, thrown_wep_think);
        wep.savenextthink = wep.nextthink;
        wep.nextthink = min(wep.nextthink, time + 0.5);
        wep.pickup_anyway = true; // these are ALWAYS pickable
@@ -97,11 +97,11 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                if(doreduce && g_weapon_stay == 2)
                {
                        // if our weapon is loaded, give its load back to the player
-                       int i = PS(self).m_weapon.m_id;
-                       if(self.(weapon_load[i]) > 0)
+                       int i = PS(own).m_weapon.m_id;
+                       if(own.(weapon_load[i]) > 0)
                        {
-                               own.(ammotype) += self.(weapon_load[i]);
-                               self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+                               own.(ammotype) += own.(weapon_load[i]);
+                               own.(weapon_load[i]) = -1; // schedule the weapon for reloading
                        }
 
                        wep.(ammotype) = 0;
@@ -109,11 +109,11 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                else if(doreduce)
                {
                        // if our weapon is loaded, give its load back to the player
-                       int i = PS(self).m_weapon.m_id;
-                       if(self.(weapon_load[i]) > 0)
+                       int i = PS(own).m_weapon.m_id;
+                       if(own.(weapon_load[i]) > 0)
                        {
-                               own.(ammotype) += self.(weapon_load[i]);
-                               self.(weapon_load[i]) = -1; // schedule the weapon for reloading
+                               own.(ammotype) += own.(weapon_load[i]);
+                               own.(weapon_load[i]) = -1; // schedule the weapon for reloading
                        }
 
                        thisammo = min(own.(ammotype), wep.(ammotype));
@@ -136,9 +136,9 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        }
 }
 
-bool W_IsWeaponThrowable(bool w)
+bool W_IsWeaponThrowable(entity this, int w)
 {
-       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon))
+       if (MUTATOR_CALLHOOK(ForbidDropCurrentWeapon, this))
                return false;
        if (!autocvar_g_pickup_items)
                return false;
@@ -165,35 +165,35 @@ bool W_IsWeaponThrowable(bool w)
 }
 
 // toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce)
-{SELFPARAM();
-       Weapon w = PS(self).m_weapon;
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce)
+{
+       Weapon w = PS(this).m_weapon;
        if (w == WEP_Null)
                return; // just in case
-       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon))
+       if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon, this))
                return;
        if(!autocvar_g_weapon_throwable)
                return;
        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-       if(self.(weaponentity).state != WS_READY)
+       if(this.(weaponentity).state != WS_READY)
                return;
-       if(!W_IsWeaponThrowable(w.m_id))
+       if(!W_IsWeaponThrowable(this, w.m_id))
                return;
 
        WepSet set = WepSet_FromWeapon(w);
-       if(!(self.weapons & set)) return;
-       self.weapons &= ~set;
+       if(!(this.weapons & set)) return;
+       this.weapons &= ~set;
 
-       W_SwitchWeapon_Force(self, w_getbestweapon(self));
-       string a = W_ThrowNewWeapon(self, w.m_id, doreduce, self.origin + delta, velo);
+       W_SwitchWeapon_Force(this, w_getbestweapon(this));
+       string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo);
 
        if(!a) return;
-       Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
+       Send_Notification(NOTIF_ONE, this, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
 }
 
 void SpawnThrownWeapon(entity this, vector org, float w)
 {
        if(this.weapons & WepSet_FromWeapon(PS(this).m_weapon))
-               if(W_IsWeaponThrowable(PS(this).m_weapon.m_id))
+               if(W_IsWeaponThrowable(this, PS(this).m_weapon.m_id))
                        W_ThrowNewWeapon(this, PS(this).m_weapon.m_id, false, org, randomvec() * 125 + '0 0 200');
 }
index 488791295b59bf8ed52df983ed949c6164abb2a6..5a27025bc8bfcd146ed19a9a52eed1600ed66f75 100644 (file)
@@ -1,14 +1,14 @@
 #pragma once
 
 .float savenextthink;
-void thrown_wep_think();
+void thrown_wep_think(entity this);
 
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
 
-float W_IsWeaponThrowable(float w);
+bool W_IsWeaponThrowable(entity this, int w);
 
 // toss current weapon
-void W_ThrowWeapon(vector velo, vector delta, float doreduce);
+void W_ThrowWeapon(entity this, vector velo, vector delta, float doreduce);
 
 void SpawnThrownWeapon(entity this, vector org, float w);
index 311edd0883586944d3bd5b28e6e61c2afe5d7d8a..81fa73d49391e99b2f35d902dca09b2eac08e069 100644 (file)
@@ -197,8 +197,8 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p
 //  Ballistics Tracing
 // ====================
 
-void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
-{SELFPARAM();
+void FireRailgunBullet (entity this, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
+{
        vector hitloc, force, endpoint, dir;
        entity ent, endent;
        float endq3surfaceflags;
@@ -225,13 +225,13 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
        // trace multiple times until we hit a wall, each obstacle will be made
        // non-solid so we can hit the next, while doing this we spawn effects and
        // note down which entities were hit so we can damage them later
-       o = self;
+       o = this;
        while (1)
        {
-               if(CS(self).antilag_debug)
-                       WarpZone_traceline_antilag (self, start, end, false, o, CS(self).antilag_debug);
+               if(CS(this).antilag_debug)
+                       WarpZone_traceline_antilag (this, start, end, false, o, CS(this).antilag_debug);
                else
-                       WarpZone_traceline_antilag (self, start, end, false, o, ANTILAG_LATENCY(self));
+                       WarpZone_traceline_antilag (this, start, end, false, o, ANTILAG_LATENCY(this));
                if(o && WarpZone_trace_firstzone)
                {
                        o = world;
@@ -239,7 +239,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
                }
 
                if(trace_ent.solid == SOLID_BSP || trace_ent.solid == SOLID_SLIDEBOX)
-                       Damage_DamageInfo(trace_endpos, bdamage, 0, 0, force, deathtype, trace_ent.species, self);
+                       Damage_DamageInfo(trace_endpos, bdamage, 0, 0, force, deathtype, trace_ent.species, this);
 
                // if it is world we can't hurt it so stop now
                if (trace_ent == world || trace_fraction == 1)
@@ -279,9 +279,9 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
        // Find all non-hit players the beam passed close by
        if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id)
        {
-               FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self, LAMBDA(
+               FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != this, LAMBDA(
                        if(!it.railgunhit)
-                       if(!(IS_SPEC(it) && it.enemy == self))
+                       if(!(IS_SPEC(it) && it.enemy == this))
                        {
                                msg_entity = it;
                                // nearest point on the beam
@@ -313,16 +313,16 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
                f = ExponentialFalloff(mindist, maxdist, halflifedist, ent.railgundistance);
                ffs = ExponentialFalloff(mindist, maxdist, forcehalflifedist, ent.railgundistance);
 
-               if(accuracy_isgooddamage(self, ent))
+               if(accuracy_isgooddamage(this, ent))
                        totaldmg += bdamage * f;
 
                // apply the damage
                if (ent.takedamage)
-                       Damage (ent, self, self, bdamage * f, deathtype, hitloc, ent.railgunforce * ffs);
+                       Damage (ent, this, this, bdamage * f, deathtype, hitloc, ent.railgunforce * ffs);
 
                // create a small explosion to throw gibs around (if applicable)
                //setorigin (explosion, hitloc);
-               //RadiusDamage (explosion, self, 10, 0, 50, world, world, 300, deathtype);
+               //RadiusDamage (explosion, this, 10, 0, 50, world, world, 300, deathtype);
 
                ent.railgunhitloc = '0 0 0';
                ent.railgunhitsolidbackup = SOLID_NOT;
@@ -334,7 +334,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
        }
 
        // calculate hits and fired shots for hitscan
-       accuracy_add(self, PS(self).m_weapon.m_id, 0, min(bdamage, totaldmg));
+       accuracy_add(this, PS(this).m_weapon.m_id, 0, min(bdamage, totaldmg));
 
        trace_endpos = endpoint;
        trace_ent = endent;
index fed7364b2556f2435a0a7a8635d5b6977c61e9e5..decdc39d95a1e5637555147683eed05e5e9e46dd 100644 (file)
@@ -49,7 +49,7 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p
 
 .float railgundistance;
 .vector railgunforce;
-void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
+void FireRailgunBullet (entity this, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype);
 
 entity fireBullet_trace_callback_eff;
 entity fireBullet_last_hit;
index f44b3929013c2a5929abed8cb8add8679145017e..d5a89b3a1e5b84088276fe94d2e5c9153660a766 100644 (file)
@@ -62,9 +62,8 @@ vector CL_Weapon_GetShotOrg(int wpn)
 ..entity weaponentity_fld;
 .float m_alpha;
 
-void CL_Weaponentity_Think()
+void CL_Weaponentity_Think(entity this)
 {
-       SELFPARAM();
        this.nextthink = time;
        if (intermission_running) this.frame = this.anim_idle.x;
        .entity weaponentity = this.weaponentity_fld;
@@ -107,9 +106,8 @@ void CL_Weaponentity_Think()
        }
 }
 
-void CL_ExteriorWeaponentity_Think()
+void CL_ExteriorWeaponentity_Think(entity this)
 {
-       SELFPARAM();
        this.nextthink = time;
        if (this.owner.exteriorweaponentity != this)
        {
@@ -168,7 +166,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
        setmodel(view, MDL_Null);  // precision set when changed
        setorigin(view, '0 0 0');
        view.weaponentity_fld = weaponentity;
-       view.think = CL_Weaponentity_Think;
+       setthink(view, CL_Weaponentity_Think);
        view.nextthink = time;
        view.viewmodelforclient = actor;
        view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
@@ -179,7 +177,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
                exterior.solid = SOLID_NOT;
                exterior.owner = actor;
                setorigin(exterior, '0 0 0');
-               exterior.think = CL_ExteriorWeaponentity_Think;
+               setthink(exterior, CL_ExteriorWeaponentity_Think);
                exterior.nextthink = time;
 
                CSQCMODEL_AUTOINIT(exterior);
@@ -210,11 +208,10 @@ void w_ready(Weapon thiswep, entity actor, .entity weaponentity, int fire)
 .float prevwarntime;
 bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary)
 {
-    SELFPARAM();
        if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
        bool ammo = false;
-       if (secondary) WITHSELF(actor, ammo = thiswep.wr_checkammo2(thiswep));
-       else WITHSELF(actor, ammo = thiswep.wr_checkammo1(thiswep));
+       if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
+       else ammo = thiswep.wr_checkammo1(thiswep, actor);
        if (ammo) return true;
        // always keep the Mine Layer if we placed mines, so that we can detonate them
        if (thiswep == WEP_MINE_LAYER)
@@ -232,8 +229,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
 
        // check if the other firing mode has enough ammo
        bool ammo_other = false;
-       if (secondary) WITHSELF(actor, ammo_other = thiswep.wr_checkammo1(thiswep));
-       else WITHSELF(actor, ammo_other = thiswep.wr_checkammo2(thiswep));
+       if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
+       else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
        if (ammo_other)
        {
                if (time - actor.prevwarntime > 1)
@@ -472,7 +469,7 @@ void W_WeaponFrame(Player actor)
                                actor.weaponname = newwep.mdl;
                                actor.bulletcounter = 0;
                                actor.ammo_field = newwep.ammo_field;
-                               newwep.wr_setup(newwep);
+                               newwep.wr_setup(newwep, actor);
                                this.state = WS_RAISE;
 
                                // set our clip load to the load of the weapon we switched to, if it's reloadable
@@ -545,7 +542,7 @@ void W_WeaponFrame(Player actor)
                        else
                        {
                                if (key_pressed && PS(actor).m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
-                                       W_SwitchWeapon(WEP_HOOK);
+                                       W_SwitchWeapon(actor, WEP_HOOK);
                                actor.hook_switchweapon = key_pressed;
                                Weapon h = WEP_HOOK;
                                block_weapon = (PS(actor).m_weapon == h && (PHYS_INPUT_BUTTON_ATCK(actor) || key_pressed));
@@ -567,7 +564,7 @@ void W_WeaponFrame(Player actor)
                        }
                        else if (e)
                        {
-                               e.wr_gonethink(e);
+                               e.wr_gonethink(e, actor);
                        }
                }
 
@@ -731,7 +728,7 @@ void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound)
                                }
                                // switch away if the amount of ammo is not enough to keep using this weapon
                                Weapon w = PS(actor).m_weapon;
-                               if (!(w.wr_checkammo1(w) + w.wr_checkammo2(w)))
+                               if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
                                {
                                        actor.clip_load = -1;  // reload later
                                        W_SwitchToOtherWeapon(actor);
@@ -767,10 +764,9 @@ void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound)
        actor.clip_load = actor.(weapon_load[PS(actor).m_weapon.m_id]) = -1;
 }
 
-void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item)
+void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item)
 {
-    SELFPARAM();
        Weapon w = Weapons_from(weapon_type);
        weapon_dropevent_item = weapon_item;
-       WITHSELF(player, w.event(w));
+       WITHSELF(player, w.event(w, player));
 }
index 74d120150fc788e917a591beeb98e2c1f7655818..a43a40c2f95d0567d73d932f647b0315abcfe877 100644 (file)
@@ -14,7 +14,7 @@ void W_AttachToShotorg(entity actor, entity flash, vector offset);
 
 void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use);
 
-void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item);
+void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item);
 
 void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound);