]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Attempt to implement smooth camera lowering when we get swallowed (so we see our...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 5 Sep 2010 22:39:30 +0000 (01:39 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 5 Sep 2010 22:39:30 +0000 (01:39 +0300)
data/qcsrc/server/vore.qc

index 74801e4ca96ae01103596dae18461a0cac6ace02..fede02e63767dff5f4f55a0f7cd9c191b3073a9c 100644 (file)
@@ -6,7 +6,7 @@ const float button_delay = 0.5;
 const float steptime = 0.1;\r
 const float system_delay_time = 0.1;\r
 \r
-.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload;\r
+.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload, vore_oldview_ofs_z;\r
 \r
 entity Swallow_distance_check()\r
 {\r
@@ -56,6 +56,31 @@ float Swallow_condition_check(entity prey)
        return FALSE;\r
 }\r
 \r
+// make the camera smoothly lower itself when we get swallowed\r
+// the target we are going for is from normal view offset to half of the view offset (because half is the best positioning of the view for the stomach model)\r
+.float cameraeffect_current, cameraeffect_target;\r
+void Vore_CameraEffect_Set(entity e)\r
+{\r
+       e.cameraeffect_current = 1;\r
+       e.cameraeffect_target = 2;\r
+}\r
+void Vore_CameraEffect_Apply()\r
+{\r
+       if(self.eater.classname != "player")\r
+               return;\r
+\r
+       local float step;\r
+       step = 2 * frametime; // CVAR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
+\r
+       if(self.cameraeffect_current >= self.cameraeffect_target + step)\r
+               self.cameraeffect_current -= step;\r
+       else if(self.cameraeffect_current <= self.cameraeffect_target - step)\r
+               self.cameraeffect_current += step;\r
+\r
+bprint(strcat(ftos(self.cameraeffect_current), "<<-----------\n"));\r
+       self.view_ofs_z = self.vore_oldview_ofs_z / self.cameraeffect_current;\r
+}\r
+\r
 void Vore_Weight_apply(entity e)\r
 {\r
        // apply stomach weight that makes you heavier the more you eat\r
@@ -72,6 +97,7 @@ void Vore_Swallow(entity e)
        // this player is beening swallowed by another player, apply the proper changes\r
        e.vore_oldmovetype = e.movetype;\r
        e.vore_oldsolid = e.solid;\r
+       e.vore_oldview_ofs_z = e.view_ofs_z;\r
 \r
        setorigin(e, e.eater.origin);\r
        e.velocity = '0 0 0';\r
@@ -79,7 +105,11 @@ void Vore_Swallow(entity e)
        e.solid = SOLID_NOT;\r
        e.alpha = -1; // best way of hiding / showing the eaten player\r
        e.aiment = e.eater; // follow the predator. Is automatically unset\r
-       e.view_ofs_z /= 2; // best positioning for the stomach model\r
+\r
+       /*e.cameraeffect_current = e.view_ofs_z * 2;\r
+       e.cameraeffect_target = e.view_ofs_z / 2; // best positioning for the stomach model*/\r
+\r
+       Vore_CameraEffect_Set(e);\r
 \r
        // drop keys (KH) and flags (CTF) when we get swallowed\r
        kh_Key_DropAll(e, FALSE);\r
@@ -104,8 +134,10 @@ void Vore_Regurgitate(entity e)
        e.movetype = e.vore_oldmovetype;\r
        if(e.health > 0) // leave SOLID_NOT for dead bodies\r
                e.solid = e.vore_oldsolid;\r
+       e.view_ofs_z = e.vore_oldview_ofs_z;\r
        e.alpha = default_player_alpha; // best way of hiding / showing the eaten player\r
-       e.view_ofs_z *= 2; // best positioning for the stomach model\r
+\r
+       //e.view_ofs_z *= 2; // best positioning for the stomach model\r
 \r
        // velocities\r
        local vector oldforward, oldright, oldup;\r
@@ -355,4 +387,6 @@ void Vore()
                Vore_Teamheal();\r
 \r
        Vore_StomachKick();\r
+\r
+       Vore_CameraEffect_Apply();\r
 }
\ No newline at end of file