From a9c7702e783ba345dde58c56160c02b43cd6578c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 27 Mar 2013 05:32:14 +1100 Subject: [PATCH] Move touchexplode to a mutator --- qcsrc/server/autocvars.qh | 4 ++ qcsrc/server/cl_client.qc | 36 --------------- qcsrc/server/cl_physics.qc | 2 +- qcsrc/server/miscfunctions.qc | 14 +----- qcsrc/server/mutators/mutator_touchexplode.qc | 46 +++++++++++++++++++ qcsrc/server/mutators/mutators.qh | 1 + qcsrc/server/progs.src | 1 + 7 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 qcsrc/server/mutators/mutator_touchexplode.qc diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 1febc23d2..15ad76c87 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1222,3 +1222,7 @@ float autocvar_physics_ode; float autocvar_g_physical_items; float autocvar_g_physical_items_damageforcescale; float autocvar_g_physical_items_reset; +float autocvar_g_touchexplode_radius; +float autocvar_g_touchexplode_damage; +float autocvar_g_touchexplode_edgedamage; +float autocvar_g_touchexplode_force; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4c7d5c575..ccf5ee800 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -627,21 +627,6 @@ void FixPlayermodel() setcolor(self, stof(autocvar_sv_defaultplayercolors)); } -void PlayerTouchExplode(entity p1, entity p2) -{ - vector org; - org = (p1.origin + p2.origin) * 0.5; - org_z += (p1.mins_z + p2.mins_z) * 0.5; - - te_explosion(org); - - entity e; - e = spawn(); - setorigin(e, org); - RadiusDamage(e, world, g_touchexplode_damage, g_touchexplode_edgedamage, g_touchexplode_radius, world, g_touchexplode_force, DEATH_TOUCHEXPLODE, world); - remove(e); -} - /* ============= PutClientInServer @@ -2497,8 +2482,6 @@ void PlayerUseKey() MUTATOR_CALLHOOK(PlayerUseKey); } -.float touchexplode_time; - /* ============= PlayerPreThink @@ -2697,25 +2680,6 @@ void PlayerPreThink (void) return; } - // FIXME from now on self.deadflag is always 0 (and self.health is never < 1) - // so (self.deadflag == DEAD_NO) is always true in the code below - - if(g_touchexplode) - if(time > self.touchexplode_time) - if(self.classname == "player") - if(self.deadflag == DEAD_NO) - if not(IS_INDEPENDENT_PLAYER(self)) - FOR_EACH_PLAYER(other) if(self != other) - { - if(time > other.touchexplode_time) - if(other.deadflag == DEAD_NO) - if not(IS_INDEPENDENT_PLAYER(other)) - if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax)) - { - PlayerTouchExplode(self, other); - self.touchexplode_time = other.touchexplode_time = time + 0.2; - } - } if(g_lms && !self.deadflag && autocvar_g_lms_campcheck_interval) { diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 6ddf7b69e..a929e368c 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -358,7 +358,7 @@ void RaceCarPhysics() rigvel_z -= frametime * autocvar_sv_gravity; // 4x gravity plays better rigvel_xy = vec2(rigvel); - if(g_bugrigs_planar_movement_car_jumping && !g_touchexplode) // touchexplode is a better way to handle collisions + if(g_bugrigs_planar_movement_car_jumping) mt = MOVE_NORMAL; else mt = MOVE_NOMONSTERS; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 17a26821d..545aa31b2 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -993,12 +993,6 @@ float g_bugrigs_speed_ref; float g_bugrigs_speed_pow; float g_bugrigs_steer; -float g_touchexplode; -float g_touchexplode_radius; -float g_touchexplode_damage; -float g_touchexplode_edgedamage; -float g_touchexplode_force; - float sv_autotaunt; float sv_taunt; @@ -1014,6 +1008,8 @@ void readlevelcvars(void) MUTATOR_ADD(mutator_spawn_near_teammate); if(cvar("g_physical_items")) MUTATOR_ADD(mutator_physical_items); + if(cvar("g_touchexplode")) + MUTATOR_ADD(mutator_touchexplode); if(!g_minstagib) { if(cvar("g_invincible_projectiles")) @@ -1053,12 +1049,6 @@ void readlevelcvars(void) g_bugrigs_speed_pow = cvar("g_bugrigs_speed_pow"); g_bugrigs_steer = cvar("g_bugrigs_steer"); - g_touchexplode = cvar("g_touchexplode"); - g_touchexplode_radius = cvar("g_touchexplode_radius"); - g_touchexplode_damage = cvar("g_touchexplode_damage"); - g_touchexplode_edgedamage = cvar("g_touchexplode_edgedamage"); - g_touchexplode_force = cvar("g_touchexplode_force"); - sv_clones = cvar("sv_clones"); sv_foginterval = cvar("sv_foginterval"); g_cloaked = cvar("g_cloaked"); diff --git a/qcsrc/server/mutators/mutator_touchexplode.qc b/qcsrc/server/mutators/mutator_touchexplode.qc new file mode 100644 index 000000000..f51ed653a --- /dev/null +++ b/qcsrc/server/mutators/mutator_touchexplode.qc @@ -0,0 +1,46 @@ +.float touchexplode_time; + +void PlayerTouchExplode(entity p1, entity p2) +{ + vector org; + org = (p1.origin + p2.origin) * 0.5; + org_z += (p1.mins_z + p2.mins_z) * 0.5; + + sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM); + pointparticles(particleeffectnum("explosion_small"), org, '0 0 0', 1); + + entity e; + e = spawn(); + setorigin(e, org); + RadiusDamage(e, world, autocvar_g_touchexplode_damage, autocvar_g_touchexplode_edgedamage, autocvar_g_touchexplode_radius, world, autocvar_g_touchexplode_force, DEATH_TOUCHEXPLODE, world); + remove(e); +} + +MUTATOR_HOOKFUNCTION(touchexplode_PlayerThink) +{ + if(time > self.touchexplode_time) + if not(gameover) + if(IS_PLAYER(self)) + if(self.deadflag == DEAD_NO) + if not(IS_INDEPENDENT_PLAYER(self)) + FOR_EACH_PLAYER(other) if(self != other) + { + if(time > other.touchexplode_time) + if(other.deadflag == DEAD_NO) + if not(IS_INDEPENDENT_PLAYER(other)) + if(boxesoverlap(self.absmin, self.absmax, other.absmin, other.absmax)) + { + PlayerTouchExplode(self, other); + self.touchexplode_time = other.touchexplode_time = time + 0.2; + } + } + + return FALSE; +} + +MUTATOR_DEFINITION(mutator_touchexplode) +{ + MUTATOR_HOOK(PlayerPreThink, touchexplode_PlayerThink, CBC_ORDER_ANY); + + return FALSE; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index 4bdcbb282..cf90b957e 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -15,5 +15,6 @@ MUTATOR_DECLARATION(mutator_spawn_near_teammate); MUTATOR_DECLARATION(mutator_physical_items); MUTATOR_DECLARATION(mutator_vampire); MUTATOR_DECLARATION(mutator_superspec); +MUTATOR_DECLARATION(mutator_touchexplode); MUTATOR_DECLARATION(sandbox); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index f33be85b9..157aa38a4 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -231,6 +231,7 @@ mutators/mutator_spawn_near_teammate.qc mutators/mutator_physical_items.qc mutators/sandbox.qc mutators/mutator_superspec.qc +mutators/mutator_touchexplode.qc ../warpzonelib/anglestransform.qc ../warpzonelib/mathlib.qc -- 2.39.2