]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Fix comments and move check
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 268798a0c11fad9af8803a7360e0394876df267f..8d59e2bbd8091e29ef0944a184db052fe4972a42 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
@@ -26,8 +26,8 @@ float Swallow_condition_check(entity prey)
 {\r
        // checks the necessary conditions for swallowing another player\r
        if(prey.classname == "player" && prey.eater.classname != "player" && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach\r
+       if(self.classname == "player" && self.eater.classname != "player" && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves\r
        if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_velocitylimit"))\r
-       if(self.eater.classname != "player") // we can't swallow players while inside someone's stomach ourselves\r
        {\r
                if(self.stomach_load >= cvar("g_balance_vore_swallow_limit"))\r
                {\r
@@ -56,6 +56,36 @@ 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
+       if(self.cvar_cl_vore_cameraspeed)\r
+       {\r
+               local float step;\r
+               step = self.cvar_cl_vore_cameraspeed * frametime;\r
+\r
+               // not sure if these maths are good, as the effect should be smoother\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
+       else\r
+               self.cameraeffect_current = self.cameraeffect_target;\r
+\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 +102,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,8 +110,8 @@ 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
-       e.stat_eaten = num_for_edict(e.eater);\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
@@ -105,9 +136,8 @@ 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
-       e.stat_eaten = 0;\r
 \r
        // velocities\r
        local vector oldforward, oldright, oldup;\r
@@ -133,6 +163,7 @@ void Vore_Regurgitate(entity e)
        e.eater = world;\r
 }\r
 \r
+void Vore_Gurglesound();\r
 void Vore_Disconnect()\r
 {\r
        // frees prey from their predators when someone disconnects or goes spectating\r
@@ -140,8 +171,7 @@ void Vore_Disconnect()
        // prey disconnects or goes spectating while inside someone's belly:\r
        if(self.eater.classname == "player")\r
        {\r
-               self.view_ofs_z += 25;\r
-               self.stat_eaten = 0;\r
+               self.view_ofs_z = self.vore_oldview_ofs_z;\r
                self.eater.stomach_load -= 1;\r
                Vore_Weight_apply(self.eater);\r
                self.eater = world;\r
@@ -156,6 +186,7 @@ void Vore_Disconnect()
                        if(head.eater == self)\r
                                Vore_Regurgitate(head);\r
                }\r
+               Vore_Gurglesound(); // stop the gurgling sound\r
        }\r
 }\r
 \r
@@ -196,12 +227,10 @@ void Vore_Teamheal()
 .float stomachkick_delay;\r
 void Vore_StomachKick()\r
 {\r
-       // allows prey to kick the predator's stomach and do some damage / attempt to escape, or bring the predator's digestion upon their self when there's no other option\r
+       // allows prey to kick the predator's stomach and do some damage / attempt to escape\r
        if(self.eater.classname != "player")\r
                return;\r
 \r
-       // kick the predator's stomach and do damage, or escape if we are lucky\r
-       if(self.BUTTON_ATCK)\r
        if(time > self.stomachkick_delay)\r
        {\r
                float damage;\r
@@ -214,13 +243,6 @@ void Vore_StomachKick()
 \r
                self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay");\r
        }\r
-\r
-       // start the predator's digestion\r
-       if(self.BUTTON_ATCK2)\r
-       {\r
-               centerprint(self.eater, strcat(self.netname, " has triggered your digestion"));\r
-               self.eater.digesting = TRUE;\r
-       }\r
 }\r
 \r
 .float gurglesound_finished, gurglesound_oldstomachload;\r
@@ -239,9 +261,17 @@ void Vore()
 {\r
        // if we are free, show our stomach load on the HUD. Otherwise, show the predator's\r
        if(self.eater.classname == "player")\r
+       {\r
                self.stat_stomachload = self.eater.stomach_load;\r
+               self.stat_digesting = self.eater.digesting;\r
+               self.stat_eaten = num_for_edict(self.eater);\r
+       }\r
        else\r
+       {\r
                self.stat_stomachload = self.stomach_load;\r
+               self.stat_digesting = self.digesting;\r
+               self.stat_eaten = 0;\r
+       }\r
 \r
        // skip the vore system under some circumstances\r
        if(time < game_starttime)\r
@@ -347,5 +377,8 @@ void Vore()
        if(teams_matter && self.team == self.eater.team)\r
                Vore_Teamheal();\r
 \r
-       Vore_StomachKick();\r
+       if(self.BUTTON_ATCK)\r
+               Vore_StomachKick();\r
+\r
+       Vore_CameraEffect_Apply();\r
 }
\ No newline at end of file