]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move touchexplode to a mutator
authorMario <mario.mario@y7mail.com>
Tue, 26 Mar 2013 18:32:14 +0000 (05:32 +1100)
committerMario <mario.mario@y7mail.com>
Tue, 26 Mar 2013 18:32:14 +0000 (05:32 +1100)
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_touchexplode.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src

index 1febc23d26801842d3f916d02357612009789d63..15ad76c8745c700de4f0c2a2d464eb42459c15e3 100644 (file)
@@ -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;
index 4c7d5c57564d8f7b674c610629e45faac08ab7b7..ccf5ee800245f6651e710b4a16c6f6a23587eeba 100644 (file)
@@ -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)
                {
index 6ddf7b69ed806e75bf81c1cea5de0307176a03b6..a929e368c184f3f1a0ea6431318ac5a96c772de8 100644 (file)
@@ -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;
index 17a26821d9a997005184152cf57c5304dcd2eaf4..545aa31b258f5dd64f888f834b3226c297ad1c5b 100644 (file)
@@ -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 (file)
index 0000000..f51ed65
--- /dev/null
@@ -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;
+}
index 4bdcbb28234834629ecc13f8f52767fcd1e4ce90..cf90b957ea5d96e259ef60f2b1558d5ed7654e43 100644 (file)
@@ -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);
index f33be85b9b4c3816451ef7de35efe6492e91800a..157aa38a4377e2dfc74927f741c3e1cd577cd1f7 100644 (file)
@@ -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