From 1add7fc6b9e512dcfcfd3180505046449ac782cd Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 22 May 2016 19:03:42 +1000 Subject: [PATCH] Introduce touch accessors --- qcsrc/common/effects/qc/gibs.qc | 2 +- .../gamemodes/gamemode/nexball/nexball.qc | 16 +++++----- .../gamemodes/gamemode/onslaught/onslaught.qc | 6 ++-- qcsrc/common/monsters/monster/mage.qc | 2 +- qcsrc/common/monsters/monster/shambler.qc | 2 +- qcsrc/common/monsters/monster/spider.qc | 2 +- qcsrc/common/monsters/monster/wyvern.qc | 2 +- qcsrc/common/monsters/monster/zombie.qc | 4 +-- qcsrc/common/monsters/sv_monsters.qc | 8 ++--- qcsrc/common/mutators/mutator/buffs/buffs.qc | 7 ++--- qcsrc/common/mutators/mutator/nades/nades.qc | 4 +-- qcsrc/common/mutators/mutator/overkill/rpc.qc | 2 +- .../mutator/physical_items/physical_items.qc | 2 +- .../mutators/mutator/sandbox/sandbox.qc | 2 +- qcsrc/common/t_items.qc | 2 +- qcsrc/common/triggers/func/button.qc | 2 +- qcsrc/common/triggers/func/door.qc | 4 +-- qcsrc/common/triggers/func/door_rotating.qc | 2 +- qcsrc/common/triggers/func/door_secret.qc | 2 +- qcsrc/common/triggers/func/ladder.qc | 2 +- qcsrc/common/triggers/platforms.qc | 2 +- qcsrc/common/triggers/teleporters.qc | 2 +- qcsrc/common/triggers/trigger/gravity.qc | 2 +- qcsrc/common/triggers/trigger/heal.qc | 2 +- qcsrc/common/triggers/trigger/hurt.qc | 2 +- qcsrc/common/triggers/trigger/impulse.qc | 6 ++-- qcsrc/common/triggers/trigger/jumppads.qc | 4 +-- qcsrc/common/triggers/trigger/keylock.qc | 2 +- qcsrc/common/triggers/trigger/multi.qc | 6 ++-- qcsrc/common/triggers/trigger/secret.qc | 2 +- qcsrc/common/triggers/trigger/swamp.qc | 2 +- qcsrc/common/turrets/sv_turrets.qc | 2 +- qcsrc/common/turrets/targettrigger.qc | 2 +- qcsrc/common/turrets/turret/walker.qc | 2 +- qcsrc/common/vehicles/sv_vehicles.qc | 8 ++--- qcsrc/common/vehicles/vehicle/bumblebee.qc | 14 ++++----- qcsrc/common/vehicles/vehicle/racer.qc | 2 +- qcsrc/common/vehicles/vehicle/raptor.qc | 4 +-- .../common/vehicles/vehicle/raptor_weapons.qc | 7 +++-- qcsrc/common/vehicles/vehicle/spiderbot.qc | 2 +- qcsrc/common/weapons/weapon/arc.qc | 2 +- qcsrc/common/weapons/weapon/blaster.qc | 2 +- qcsrc/common/weapons/weapon/crylink.qc | 4 +-- qcsrc/common/weapons/weapon/devastator.qc | 2 +- qcsrc/common/weapons/weapon/electro.qc | 4 +-- qcsrc/common/weapons/weapon/fireball.qc | 4 +-- qcsrc/common/weapons/weapon/hagar.qc | 6 ++-- qcsrc/common/weapons/weapon/hlac.qc | 4 +-- qcsrc/common/weapons/weapon/hook.qc | 4 +-- qcsrc/common/weapons/weapon/minelayer.qc | 4 +-- qcsrc/common/weapons/weapon/mortar.qc | 4 +-- qcsrc/common/weapons/weapon/porto.qc | 2 +- qcsrc/common/weapons/weapon/seeker.qc | 6 ++-- qcsrc/common/weapons/weapon/vaporizer.qc | 4 +-- qcsrc/lib/self.qh | 31 +++++++++++++------ qcsrc/lib/warpzone/server.qc | 2 +- qcsrc/server/g_hook.qc | 4 +-- qcsrc/server/item_key.qc | 2 +- qcsrc/server/miscfunctions.qc | 13 -------- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 4 +-- .../mutators/mutator/gamemode_domination.qc | 2 +- .../mutators/mutator/gamemode_keepaway.qc | 10 +++--- .../mutators/mutator/gamemode_keyhunt.qc | 2 +- qcsrc/server/portals.qc | 8 ++--- qcsrc/server/race.qc | 6 ++-- 65 files changed, 143 insertions(+), 143 deletions(-) diff --git a/qcsrc/common/effects/qc/gibs.qc b/qcsrc/common/effects/qc/gibs.qc index bbe3ad934..a72536b05 100644 --- a/qcsrc/common/effects/qc/gibs.qc +++ b/qcsrc/common/effects/qc/gibs.qc @@ -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 diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 21ebc33b9..cc24cfde6 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -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? diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index b2d0a84d3..0f138819a 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -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 diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index de7bccb4b..e746e4394 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -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; diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index 97e0d49ba..d83026474 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -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; diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 0b2e3650b..5f8add4ff 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -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; diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index c52ce3f99..07f51611e 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -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); diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index b28bb8d84..ffbb06c26 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -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); } } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 0179a251b..48e510361 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 18841767f..302eea34e 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -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; } } diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 9be8f96de..c33ccf05b 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index f16b7024d..bf531e3b4 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/physical_items/physical_items.qc b/qcsrc/common/mutators/mutator/physical_items/physical_items.qc index aaad9d47b..bd68f2bcd 100644 --- a/qcsrc/common/mutators/mutator/physical_items/physical_items.qc +++ b/qcsrc/common/mutators/mutator/physical_items/physical_items.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/sandbox/sandbox.qc b/qcsrc/common/mutators/mutator/sandbox/sandbox.qc index 6391e1f87..5ab3ca02b 100644 --- a/qcsrc/common/mutators/mutator/sandbox/sandbox.qc +++ b/qcsrc/common/mutators/mutator/sandbox/sandbox.qc @@ -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? diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 15cb36c92..dcbbb95e3 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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; diff --git a/qcsrc/common/triggers/func/button.qc b/qcsrc/common/triggers/func/button.qc index ecc1fdf8e..0a0547b58 100644 --- a/qcsrc/common/triggers/func/button.qc +++ b/qcsrc/common/triggers/func/button.qc @@ -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; diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 1b77131e7..f28834710 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -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. diff --git a/qcsrc/common/triggers/func/door_rotating.qc b/qcsrc/common/triggers/func/door_rotating.qc index ae7918c82..77061ecb3 100644 --- a/qcsrc/common/triggers/func/door_rotating.qc +++ b/qcsrc/common/triggers/func/door_rotating.qc @@ -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. diff --git a/qcsrc/common/triggers/func/door_secret.qc b/qcsrc/common/triggers/func/door_secret.qc index aa00cd45d..f99996955 100644 --- a/qcsrc/common/triggers/func/door_secret.qc +++ b/qcsrc/common/triggers/func/door_secret.qc @@ -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; diff --git a/qcsrc/common/triggers/func/ladder.qc b/qcsrc/common/triggers/func/ladder.qc index 570ef3bad..a853fb4e2 100644 --- a/qcsrc/common/triggers/func/ladder.qc +++ b/qcsrc/common/triggers/func/ladder.qc @@ -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); diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc index 710a6db3f..ba8a817ef 100644 --- a/qcsrc/common/triggers/platforms.qc +++ b/qcsrc/common/triggers/platforms.qc @@ -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; diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 64fdb4d46..68e006c2c 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -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) diff --git a/qcsrc/common/triggers/trigger/gravity.qc b/qcsrc/common/triggers/trigger/gravity.qc index 86039d20b..f2f8a845f 100644 --- a/qcsrc/common/triggers/trigger/gravity.qc +++ b/qcsrc/common/triggers/trigger/gravity.qc @@ -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); diff --git a/qcsrc/common/triggers/trigger/heal.qc b/qcsrc/common/triggers/trigger/heal.qc index b58574452..e5a98b8cb 100644 --- a/qcsrc/common/triggers/trigger/heal.qc +++ b/qcsrc/common/triggers/trigger/heal.qc @@ -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) diff --git a/qcsrc/common/triggers/trigger/hurt.qc b/qcsrc/common/triggers/trigger/hurt.qc index efd23a5de..8eaf0ec5e 100644 --- a/qcsrc/common/triggers/trigger/hurt.qc +++ b/qcsrc/common/triggers/trigger/hurt.qc @@ -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) diff --git a/qcsrc/common/triggers/trigger/impulse.qc b/qcsrc/common/triggers/trigger/impulse.qc index cd98627c8..02c253eb7 100644 --- a/qcsrc/common/triggers/trigger/impulse.qc +++ b/qcsrc/common/triggers/trigger/impulse.qc @@ -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); } } diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 67fd75220..f8283b19c 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -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) diff --git a/qcsrc/common/triggers/trigger/keylock.qc b/qcsrc/common/triggers/trigger/keylock.qc index 1ac9a295a..e436f2cb1 100644 --- a/qcsrc/common/triggers/trigger/keylock.qc +++ b/qcsrc/common/triggers/trigger/keylock.qc @@ -156,7 +156,7 @@ spawnfunc(trigger_keylock) EXACTTRIGGER_INIT; - this.touch = trigger_keylock_touch; + settouch(this, trigger_keylock_touch); trigger_keylock_link(this); } diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 4e93f805d..5edf1dfa5 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -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 } } diff --git a/qcsrc/common/triggers/trigger/secret.qc b/qcsrc/common/triggers/trigger/secret.qc index 5cae4ed4e..e6e4c4bf9 100644 --- a/qcsrc/common/triggers/trigger/secret.qc +++ b/qcsrc/common/triggers/trigger/secret.qc @@ -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; } diff --git a/qcsrc/common/triggers/trigger/swamp.qc b/qcsrc/common/triggers/trigger/swamp.qc index 4b66f723f..32999b71a 100644 --- a/qcsrc/common/triggers/trigger/swamp.qc +++ b/qcsrc/common/triggers/trigger/swamp.qc @@ -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) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index f8101535e..36283fc81 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -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; diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc index aa1322c44..01dced5f3 100644 --- a/qcsrc/common/turrets/targettrigger.qc +++ b/qcsrc/common/turrets/targettrigger.qc @@ -20,5 +20,5 @@ spawnfunc(turret_targettrigger) WITHSELF(this, InitTrigger()); - this.touch = turret_targettrigger_touch; + settouch(this, turret_targettrigger_touch); } diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index afe85bf8c..b923d0fc3 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -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; diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index eac4b6762..bfb735197 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 724d23d74..e61ab440d 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -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); diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 26221f5ed..e79cab9ec 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -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); diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index d91754024..76deddd9d 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -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)) { diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 16b6eb874..14cc7c0ff 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 57f1310c4..864c302d1 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index d8effdeb8..a033d2ab0 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 24d532934..56465e5c8 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index b42299264..fa7b82584 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 4e7b5cf10..8c59a7938 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index b977ddb91..9e13fe2fa 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 245a05ff3..a180ede56 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 54539f727..de576e609 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 932f3d17d..1fd9e0832 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 206223d01..77e0e1973 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 960e1d4a7..f397e9e99 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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)); diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 1e1c924e6..0fc5dd9bd 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 60d2a8b70..867dd286c 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index ce0aacd2d..448c4363a 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index cd05a8682..beba67995 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -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; diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index ecb1d6fe5..6b7201dcf 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -45,20 +45,33 @@ #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 diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 97abe0e6d..ddaa41657 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -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) { diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 86fb14b29..774e143e1 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -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; diff --git a/qcsrc/server/item_key.qc b/qcsrc/server/item_key.qc index c129127c3..ca4d8cf08 100644 --- a/qcsrc/server/item_key.qc +++ b/qcsrc/server/item_key.qc @@ -122,7 +122,7 @@ void spawn_item_key(entity this) WITHSELF(this, droptofloor()); } - this.touch = item_key_touch; + settouch(this, item_key_touch); }; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 95ec703db..5802a5b97 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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(); diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index cbefd4c73..0b354425a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -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; diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 8db6de10c..49623a36e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -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'); diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 4bed375b4..b6d3ca3c0 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -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; diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index e2b9d013d..8886753aa 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -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; diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index b6f1576d2..c6d31ecbb 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -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; diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index f2315035f..67e9d73ee 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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"; -- 2.39.2