Introduce touch accessors
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 May 2016 09:03:42 +0000 (19:03 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 May 2016 10:17:11 +0000 (20:17 +1000)
65 files changed:
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.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/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/mutators/mutator/physical_items/physical_items.qc
qcsrc/common/mutators/mutator/sandbox/sandbox.qc
qcsrc/common/t_items.qc
qcsrc/common/triggers/func/button.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/ladder.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/teleporters.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/keylock.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/trigger/secret.qc
qcsrc/common/triggers/trigger/swamp.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/targettrigger.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
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/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/lib/self.qh
qcsrc/lib/warpzone/server.qc
qcsrc/server/g_hook.qc
qcsrc/server/item_key.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/portals.qc
qcsrc/server/race.qc

index bbe3ad9..a72536b 100644 (file)
@@ -144,7 +144,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
index 21ebc33..cc24cfd 100644 (file)
@@ -166,7 +166,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.
 
@@ -201,7 +201,7 @@ void DropBall(entity ball, vector org, vector vel)
        ball.scale = ball_scale;
        ball.velocity = vel;
        ball.nb_droptime = time;
-       ball.touch = basketball_touch;
+       settouch(ball, basketball_touch);
        ball.think = ResetBall;
        ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime);
 
@@ -226,9 +226,9 @@ void InitBall()
        UNSET_ONGROUND(this);
        this.movetype = MOVETYPE_BOUNCE;
        if(this.classname == "nexball_basketball")
-               this.touch = basketball_touch;
+               settouch(this, basketball_touch);
        else if(this.classname == "nexball_football")
-               this.touch = football_touch;
+               settouch(this, football_touch);
        this.cnt = 0;
        this.think = ResetBall;
        this.nextthink = time + autocvar_g_nexball_delay_idle + 3;
@@ -247,7 +247,7 @@ void ResetBall()
                if(time == this.teamtime)
                        bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
 
-               this.touch = func_null;
+               settouch(this, func_null);
                this.movetype = MOVETYPE_NOCLIP;
                this.velocity = '0 0 0'; // just in case?
                if(!this.cnt)
@@ -429,7 +429,7 @@ void GoalTouch()
        ball.cnt = 1;
        ball.think = 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);
 }
 
@@ -623,7 +623,7 @@ void SpawnGoal(entity this)
        if(this.noise == "")
                this.noise = "ctf/respawn.wav";
        precache_sound(this.noise);
-       this.touch = GoalTouch;
+       settouch(this, GoalTouch);
 }
 
 spawnfunc(nexball_redgoal)
@@ -815,7 +815,7 @@ 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;
+       settouch(missile, W_Nexball_Touch);
        missile.think = SUB_Remove_self;
        missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
 
index b2d0a84..0f13881 100644 (file)
@@ -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;
@@ -865,7 +865,7 @@ void ons_ControlPoint_Setup(entity cp)
        cp.team = 0;
        cp.solid = SOLID_BBOX;
        cp.movetype = MOVETYPE_NONE;
-       cp.touch = ons_ControlPoint_Touch;
+       settouch(cp, ons_ControlPoint_Touch);
        cp.think = ons_ControlPoint_Think;
        cp.nextthink = time + ONS_CP_THINKRATE;
        cp.reset = ons_ControlPoint_Reset;
@@ -1117,7 +1117,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.iscaptured = true;
        gen.islinked = true;
        gen.isshielded = true;
-       gen.touch = onslaught_generator_touch;
+       settouch(gen, onslaught_generator_touch);
 
        // appearence
        // model handled by CSQC
index de7bccb..e746e43 100644 (file)
@@ -241,7 +241,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 97e0d49..d830264 100644 (file)
@@ -163,7 +163,7 @@ void M_Shambler_Attack_Lightning(entity this)
        gren.nextthink = time;
        gren.think = 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 0b2e365..5f8add4 100644 (file)
@@ -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 c52ce3f..07f5161 100644 (file)
@@ -73,7 +73,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity
                missile.avelocity = '300 300 300';
                missile.nextthink = time + 5;
                missile.think = M_Wyvern_Attack_Fireball_Explode;
-               missile.touch = M_Wyvern_Attack_Fireball_Touch;
+               settouch(missile, M_Wyvern_Attack_Fireball_Touch);
                CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
 
         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
index b28bb8d..ffbb06c 100644 (file)
@@ -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 0179a25..48e5103 100644 (file)
@@ -415,7 +415,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);
@@ -835,7 +835,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])
@@ -1022,7 +1022,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;
@@ -1331,7 +1331,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 1884176..302eea3 100644 (file)
@@ -423,7 +423,7 @@ void buff_Init(entity this)
        this.solid = SOLID_TRIGGER;
        this.flags = FL_ITEM;
        this.think = buff_Think;
-       this.touch = buff_Touch;
+       settouch(this, buff_Touch);
        this.reset = buff_Reset;
        this.nextthink = time + 0.1;
        this.gravity = 1;
@@ -885,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)());
                                        other = oldother;
                                }
                        }
index 9be8f96..c33ccf0 100644 (file)
@@ -575,7 +575,7 @@ void nade_heal_boom(entity this)
        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;
@@ -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;
index f16b702..bf531e3 100644 (file)
@@ -132,7 +132,7 @@ 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;
        missile.cnt = time + WEP_CVAR(rpc, lifetime);
index aaad9d4..bd68f2b 100644 (file)
@@ -118,7 +118,7 @@ MUTATOR_HOOKFUNCTION(physical_items, Item_Spawn)
 
        wep.think = 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 6391e1f..5ab3ca0 100644 (file)
@@ -187,7 +187,7 @@ entity sandbox_ObjectSpawn(float database)
        e.frame = 0;
        e.skin = 0;
        e.material = string_null;
-       e.touch = sandbox_ObjectFunction_Touch;
+       settouch(e, sandbox_ObjectFunction_Touch);
        e.think = sandbox_ObjectFunction_Think;
        e.nextthink = time;
        //e.effects |= EF_SELECTABLE; // don't do this all the time, maybe just when editing objects?
index 15cb36c..dcbbb95 100644 (file)
@@ -1182,7 +1182,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;
 
index ecc1fdf..0a0547b 100644 (file)
@@ -131,7 +131,7 @@ spawnfunc(func_button)
                this.takedamage = DAMAGE_YES;
        }
        else
-               this.touch = button_touch;
+               settouch(this, button_touch);
 
        if (!this.speed)
                this.speed = 40;
index 1b77131..f288347 100644 (file)
@@ -446,7 +446,7 @@ void door_spawnfield(vector fmins, vector fmaxs)
        trigger.solid = SOLID_TRIGGER;
        trigger.owner = self;
 #ifdef SVQC
-       trigger.touch = door_trigger_touch;
+       settouch(trigger, door_trigger_touch);
 #elif defined(CSQC)
        trigger.trigger_touch = door_trigger_touch;
        trigger.draw = trigger_draw_generic;
@@ -771,7 +771,7 @@ spawnfunc(func_door)
        if (this.items)
                this.wait = -1;
 
-       this.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.
index ae7918c..77061ec 100644 (file)
@@ -115,7 +115,7 @@ spawnfunc(func_door_rotating)
        if (this.items)
                this.wait = -1;
 
-       this.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.
index aa00cd4..f999969 100644 (file)
@@ -213,7 +213,7 @@ spawnfunc(func_door_secret)
        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 570ef3b..a853fb4 100644 (file)
@@ -41,7 +41,7 @@ void func_ladder_link(entity this)
 
 void func_ladder_init(entity this)
 {
-       this.touch = func_ladder_touch;
+       settouch(this, func_ladder_touch);
 
        trigger_init(this);
        func_ladder_link(this);
index 710a6db..ba8a817 100644 (file)
@@ -23,7 +23,7 @@ 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;
index 64fdb4d..68e006c 100644 (file)
@@ -281,7 +281,7 @@ void teleport_findtarget(entity this)
 
        // now enable touch
 #ifdef SVQC
-       this.touch = Teleport_Touch;
+       settouch(this, Teleport_Touch);
 
        trigger_teleport_link(this);
 #elif defined(CSQC)
index 86039d2..f2f8a84 100644 (file)
@@ -91,7 +91,7 @@ spawnfunc(trigger_gravity)
                return;
 
        EXACTTRIGGER_INIT;
-       this.touch = trigger_gravity_touch;
+       settouch(this, trigger_gravity_touch);
        if(this.noise != "")
                precache_sound(this.noise);
 
index b585744..e5a98b8 100644 (file)
@@ -30,7 +30,7 @@ spawnfunc(trigger_heal)
        this.active = ACTIVE_ACTIVE;
 
        EXACTTRIGGER_INIT;
-       this.touch = trigger_heal_touch;
+       settouch(this, trigger_heal_touch);
        if (!this.health)
                this.health = 10;
        if (!this.max_health)
index efd23a5..8eaf0ec 100644 (file)
@@ -61,7 +61,7 @@ spawnfunc(trigger_hurt)
 {
        EXACTTRIGGER_INIT;
        this.active = ACTIVE_ACTIVE;
-       this.touch = trigger_hurt_touch;
+       settouch(this, trigger_hurt_touch);
        this.use = trigger_hurt_use;
        this.enemy = world; // I hate you all
        if (!this.dmg)
index cd98627..02c253e 100644 (file)
@@ -195,20 +195,20 @@ spawnfunc(trigger_impulse)
                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);
-               this.touch = trigger_impulse_touch3;
+               settouch(this, trigger_impulse_touch3);
        }
        else
        {
                if(this.target)
                {
                        if(!this.strength) this.strength = 950 * autocvar_g_triggerimpulse_directional_multiplier;
-                       this.touch = trigger_impulse_touch1;
+                       settouch(this, trigger_impulse_touch1);
                }
                else
                {
                        if(!this.strength) this.strength = 0.9;
                        this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier;
-                       this.touch = trigger_impulse_touch2;
+                       settouch(this, trigger_impulse_touch2);
                }
        }
 
index 67fd752..f8283b1 100644 (file)
@@ -262,7 +262,7 @@ void trigger_push_touch()
 
        if (this.spawnflags & PUSH_ONCE)
        {
-               this.touch = func_null;
+               settouch(this, func_null);
                this.think = SUB_Remove_self;
                this.nextthink = time;
        }
@@ -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)
index 1ac9a29..e436f2c 100644 (file)
@@ -156,7 +156,7 @@ spawnfunc(trigger_keylock)
 
        EXACTTRIGGER_INIT;
 
-       this.touch = trigger_keylock_touch;
+       settouch(this, trigger_keylock_touch);
 
        trigger_keylock_link(this);
 }
index 4e93f80..5edf1df 100644 (file)
@@ -55,7 +55,7 @@ void multi_trigger(entity this)
        else
        {       // we can't just remove (this) here, because this is a touch function
                // called wheil C code is looping through area links...
-               this.touch = func_null;
+               settouch(this, func_null);
        }
 }
 
@@ -116,7 +116,7 @@ void multi_eventdamage(entity this, entity inflictor, entity attacker, float dam
 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;
@@ -178,7 +178,7 @@ spawnfunc(trigger_multiple)
        {
                if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
                {
-                       this.touch = multi_touch;
+                       settouch(this, multi_touch);
                        setorigin (this, this.origin);  // make sure it links into the world
                }
        }
index 5cae4ed..e6e4c4b 100644 (file)
@@ -80,7 +80,7 @@ spawnfunc(trigger_secret)
        spawnfunc_trigger_once(this);
 
        // take over the touch() function, so we can mark secret as found
-       this.touch = trigger_secret_touch;
+       settouch(this, trigger_secret_touch);
        // ignore triggering;
        this.use = func_null;
 }
index 4b66f72..32999b7 100644 (file)
@@ -121,7 +121,7 @@ spawnfunc(trigger_swamp)
 {
        // Init stuff
        trigger_init(this);
-       this.touch = swamp_touch;
+       settouch(this, swamp_touch);
 
        // Setup default keys, if missing
        if(this.dmg <= 0)
index f810153..36283fc 100644 (file)
@@ -472,7 +472,7 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
        proj.bot_dodge    = true;
        proj.bot_dodgerating = self.shot_dmg;
        proj.think                = turret_projectile_explode;
-       proj.touch                = turret_projectile_touch;
+       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;
index aa1322c..01dced5 100644 (file)
@@ -20,5 +20,5 @@ spawnfunc(turret_targettrigger)
 
     WITHSELF(this, InitTrigger());
 
-    this.touch = turret_targettrigger_touch;
+    settouch(this, turret_targettrigger_touch);
 }
index afe85bf..b923d0f 100644 (file)
@@ -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;
index eac4b67..bfb7351 100644 (file)
@@ -261,7 +261,7 @@ 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;
@@ -327,7 +327,7 @@ entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag,
        {
                _gib.think = vehicles_gib_explode;
                _gib.nextthink = time + random() * _explode;
-               _gib.touch = vehicles_gib_explode;
+               settouch(_gib, vehicles_gib_explode);
        }
        else
        {
@@ -1113,7 +1113,7 @@ void vehicles_spawn()
        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
@@ -1210,7 +1210,7 @@ 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;
+       settouch(this, vehicles_touch);
        this.think                                      = vehicles_spawn;
        this.nextthink                          = time;
        this.effects                            = EF_NODRAW;
index 724d23d..e61ab44 100644 (file)
@@ -650,7 +650,7 @@ void bumblebee_exit(float eject)
                return;
        }
 
-       self.touch = vehicles_touch;
+       settouch(self, vehicles_touch);
 
        if(!IS_DEAD(self))
        {
@@ -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;
 }
@@ -751,7 +751,7 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
                entity oldother = other;
                other = e;
                self.phase = 0;
-               self.touch();
+               gettouch(self)();
                other = oldother;
                return;
         }
@@ -763,7 +763,7 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
                entity oldother = other;
                other = e;
                self.phase = 0;
-               self.touch();
+               gettouch(self)();
                other = oldother;
             return;
         }
@@ -793,9 +793,9 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
     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;
     _body.nextthink = time;
@@ -817,7 +817,7 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
     instance.colormod          = '0 0 0';
     instance.avelocity         = '0 0 0';
     instance.velocity          = '0 0 0';
-    instance.touch                     = func_null;
+    settouch(instance, func_null);
     instance.nextthink                 = 0;
 
     setorigin(instance, instance.pos1);
index 26221f5..e79cab9 100644 (file)
@@ -638,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);
 
index d917540..76deddd 100644 (file)
@@ -534,7 +534,7 @@ void raptor_blowup()
        self.velocity      = '0 0 0';
 
        setorigin(self, self.pos1);
-       self.touch = func_null;
+       settouch(self, func_null);
        self.nextthink = 0;
 }
 
@@ -656,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))
 {
index 16b6eb8..14cc7c0 100644 (file)
@@ -78,7 +78,7 @@ 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);
     }
@@ -129,7 +129,7 @@ void raptor_bomb_burst()
         setorigin(bomblet, self.origin);
 
         bomblet.movetype       = MOVETYPE_TOSS;
-        bomblet.touch     = raptor_bomblet_touch;
+        settouch(bomblet, raptor_bomblet_touch);
         bomblet.think     = raptor_bomblet_boom;
         bomblet.nextthink   = time + 5;
         bomblet.owner     = self.owner;
@@ -157,7 +157,8 @@ 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;
+    settouch(bomb_1, raptor_bomb_burst);
+    settouch(bomb_2, raptor_bomb_burst);
     bomb_1.think               = bomb_2.think    = raptor_bomb_burst;
     bomb_1.cnt           = bomb_2.cnt          = time + 10;
 
index 57f1310..864c302 100644 (file)
@@ -571,7 +571,7 @@ 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;
     instance.nextthink                 = time;
index d8effde..a033d2a 100644 (file)
@@ -286,7 +286,7 @@ 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;
        missile.nextthink = time + WEP_CVAR(arc, bolt_lifetime);
index 24d5329..56465e5 100644 (file)
@@ -135,7 +135,7 @@ 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;
index b422992..fa7b825 100644 (file)
@@ -414,7 +414,7 @@ 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;
                if(counter == 0)
@@ -530,7 +530,7 @@ 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;
+               settouch(proj, W_Crylink_Touch);
                proj.think = W_Crylink_Fadethink;
                if(counter == (shots - 1) / 2)
                {
index 4e7b5cf..8c59a79 100644 (file)
@@ -384,7 +384,7 @@ 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;
+       settouch(missile, W_Devastator_Touch);
        missile.think = W_Devastator_Think;
        missile.nextthink = time;
        missile.cnt = time + WEP_CVAR(devastator, lifetime);
index b977ddb..9e13fe2 100644 (file)
@@ -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;
@@ -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);
index 245a05f..a180ede 100644 (file)
@@ -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;
@@ -337,7 +337,7 @@ 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);
index 54539f7..de576e6 100644 (file)
@@ -155,7 +155,7 @@ 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;
        missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
@@ -197,7 +197,7 @@ 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;
@@ -256,7 +256,7 @@ 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;
                missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
index 932f3d1..1fd9e08 100644 (file)
@@ -104,7 +104,7 @@ 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;
+       settouch(missile, W_HLAC_Touch);
        missile.think = SUB_Remove_self;
 
     missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
@@ -146,7 +146,7 @@ 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;
+       settouch(missile, W_HLAC_Touch);
        missile.think = SUB_Remove_self;
 
     missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
index 206223d..77e0e19 100644 (file)
@@ -102,7 +102,7 @@ void W_Hook_ExplodeThink()
 void W_Hook_Explode2()
 {SELFPARAM();
        self.event_damage = func_null;
-       self.touch = func_null;
+       settouch(self, func_null);
        self.effects |= EF_NODRAW;
 
        self.think = W_Hook_ExplodeThink;
@@ -161,7 +161,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
        gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime);
        gren.think = 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);
index 960e1d4..f397e9e 100644 (file)
@@ -96,7 +96,7 @@ void W_MineLayer_Stick(entity to)
 
        newmine.mine_time = self.mine_time;
 
-       newmine.touch = func_null;
+       settouch(newmine, func_null);
        newmine.think = W_MineLayer_Think;
        newmine.nextthink = time;
        newmine.cnt = self.cnt;
@@ -355,7 +355,7 @@ 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;
+       settouch(mine, W_MineLayer_Touch);
        mine.think = W_MineLayer_Think;
        mine.nextthink = time;
        mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
index 1e1c924..0fc5dd9 100644 (file)
@@ -237,7 +237,7 @@ void W_Mortar_Attack(Weapon thiswep)
        gren.nextthink = time;
        gren.think = 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);
@@ -284,7 +284,7 @@ void W_Mortar_Attack2(Weapon thiswep)
        gren.nextthink = time + WEP_CVAR_SEC(mortar, lifetime);
        gren.think = 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);
index 60d2a8b..867dd28 100644 (file)
@@ -266,7 +266,7 @@ void W_Porto_Attack(float type)
 
        gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime);
        gren.think = W_Porto_Think;
-       gren.touch = W_Porto_Touch;
+       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);
index ce0aacd..448c436 100644 (file)
@@ -267,7 +267,7 @@ void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target)
        missile.bot_dodgerating = WEP_CVAR(seeker, missile_damage);
 
        missile.think           = W_Seeker_Missile_Think;
-       missile.touch           = W_Seeker_Missile_Touch;
+       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);
@@ -359,7 +359,7 @@ 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;
        missile.nextthink               = time + WEP_CVAR(seeker, flac_lifetime) + WEP_CVAR(seeker, flac_lifetime_rand);
@@ -572,7 +572,7 @@ 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;
+       settouch(missile, W_Seeker_Tag_Touch);
        missile.think           = SUB_Remove_self;
        missile.nextthink       = time + WEP_CVAR(seeker, tag_lifetime);
        missile.movetype        = MOVETYPE_FLY;
index cd05a86..beba679 100644 (file)
@@ -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;
@@ -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;
index ecb1d6f..6b7201d 100644 (file)
     #define WITHSELF(value, block) block
 #endif
 
-#define SELFWRAP(T, R) \
-    [[alias(#T)]] .R() __##T; \
-    .R(entity this) self##T; \
-    R T##_self() { SELFPARAM(); return this.self##T(this); }
+#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 = T##_self, _selftemp.self##T = 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)
 
-SELFWRAP(think, void)
+SELFWRAP(think, void, (entity this), (this))
 #define setthink(e, f) SELFWRAP_SET(think, e, f)
 
-SELFWRAP(touch, void)
-#define settouch(e, f) SELFWRAP_SET(touch, e, f)
+SELFWRAP(touch, void, (entity this), (this))
+#define settouch(e, f) _SELFWRAP_SET(touch, e, f)
+#define gettouch(e) _SELFWRAP_GET(touch, e)
 
-SELFWRAP(predraw, void)
+SELFWRAP(predraw, void, (entity this), (this))
 #define setpredraw(e, f) SELFWRAP_SET(predraw, e, f)
+
+#ifndef MENUQC
+void adaptor_think2touch() { SELFPARAM(); WITH(entity, other, NULL, gettouch(this)()); }
+void adaptor_think2use() { SELFPARAM(); if (this.use) this.use(this, NULL, NULL); }
+#endif
index 97abe0e..ddaa416 100644 (file)
@@ -719,7 +719,7 @@ 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)
        {
index 86fb14b..774e143 100644 (file)
@@ -99,7 +99,7 @@ void GrapplingHook_Stop()
        self.state = 1;
        self.think = 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;
@@ -385,7 +385,7 @@ void FireGrapplingHook ()
        missile.angles = vectoangles (missile.velocity);
        //missile.glow_color = 250; // 244, 250
        //missile.glow_size = 120;
-       missile.touch = GrapplingHookTouch;
+       settouch(missile, GrapplingHookTouch);
        missile.think = GrapplingHookThink;
        missile.nextthink = time;
 
index c129127..ca4d8cf 100644 (file)
@@ -122,7 +122,7 @@ void spawn_item_key(entity this)
                WITHSELF(this, droptofloor());
        }
 
-       this.touch = item_key_touch;
+       settouch(this, item_key_touch);
 };
 
 
index 95ec703..5802a5b 100644 (file)
@@ -958,20 +958,7 @@ 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();
index cbefd4c..0b35442 100644 (file)
@@ -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;
@@ -1211,7 +1211,7 @@ 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;
+       settouch(flag, ctf_FlagTouch);
        flag.think = ctf_FlagThink;
        flag.nextthink = time + FLAG_THINKRATE;
        flag.ctf_status = FLAG_BASE;
index 8db6de1..49623a3 100644 (file)
@@ -352,7 +352,7 @@ void dom_controlpoint_setup(entity this)
 
        self.think = 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');
index 4bed375..b6d3ca3 100644 (file)
@@ -99,7 +99,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;
 
@@ -153,7 +153,7 @@ 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;
+       settouch(self, func_null);
        self.think = ka_TimeScoring;
        self.nextthink = time + autocvar_g_keepaway_score_timeinterval;
        self.takedamage = DAMAGE_NO;
@@ -192,7 +192,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 +231,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 +478,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 e2b9d01..8886753 100644 (file)
@@ -792,7 +792,7 @@ 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;
+       settouch(key, kh_Key_Touch);
        key.think = kh_Key_Think;
        key.nextthink = time;
        key.items = IT_KEY1 | IT_KEY2;
index b6f1576..c6d31ec 100644 (file)
@@ -327,7 +327,7 @@ void Portal_MakeBrokenPortal(entity portal)
 {
        portal.skin = 2;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
+       settouch(portal, func_null);
        portal.think = func_null;
        portal.effects = 0;
        portal.nextthink = 0;
@@ -338,7 +338,7 @@ void Portal_MakeWaitingPortal(entity portal)
 {
        portal.skin = 2;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
+       settouch(portal, func_null);
        portal.think = func_null;
        portal.effects = EF_ADDITIVE;
        portal.nextthink = 0;
@@ -349,7 +349,7 @@ void Portal_MakeInPortal(entity portal)
 {
        portal.skin = 0;
        portal.solid = SOLID_NOT; // this is done when connecting them!
-       portal.touch = Portal_Touch;
+       settouch(portal, Portal_Touch);
        portal.think = Portal_Think;
        portal.effects = EF_RED;
        portal.nextthink = time;
@@ -360,7 +360,7 @@ void Portal_MakeOutPortal(entity portal)
 {
        portal.skin = 1;
        portal.solid = SOLID_NOT;
-       portal.touch = func_null;
+       settouch(portal, func_null);
        portal.think = func_null;
        portal.effects = EF_STARDUST | EF_BLUE;
        portal.nextthink = 0;
index f231503..67e9d73 100644 (file)
@@ -912,7 +912,7 @@ spawnfunc(trigger_race_checkpoint)
 
        this.use = checkpoint_use;
        if (!(this.spawnflags & 1))
-               this.touch = checkpoint_touch;
+               settouch(this, checkpoint_touch);
 
        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);
@@ -961,7 +961,7 @@ spawnfunc(target_checkpoint) // defrag entity
 
        this.use = checkpoint_use;
        if (!(this.spawnflags & 1))
-               this.touch = checkpoint_touch;
+               settouch(this, checkpoint_touch);
 
        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);
@@ -1117,7 +1117,7 @@ spawnfunc(trigger_race_penalty)
 
        this.use = penalty_use;
        if (!(this.spawnflags & 1))
-               this.touch = penalty_touch;
+               settouch(this, penalty_touch);
 
        if (this.race_penalty_reason == "")
                this.race_penalty_reason = "missing a checkpoint";