]> 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 037aca006a15102948c5f1d1500f5bdf81403c87..8d59e2bbd8091e29ef0944a184db052fe4972a42 100644 (file)
@@ -1,11 +1,12 @@
 .float regurgitate_prepare;\r
-.float swallow_delay, digest_button_delay, regurgitate_button_delay;\r
+.float system_delay, swallow_delay, digest_button_delay, regurgitate_button_delay;\r
 .float complain_swallow;\r
 const float complain_delay = 1;\r
 const float button_delay = 0.5;\r
 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
@@ -25,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
@@ -55,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
@@ -71,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
@@ -78,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 = TRUE;\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
@@ -94,6 +126,8 @@ void Vore_Swallow(entity e)
        e.eater.stomach_load += 1;\r
        e.eater.regurgitate_prepare = 0;\r
        Vore_Weight_apply(e.eater);\r
+\r
+       e.system_delay = e.eater.system_delay = time + system_delay_time;\r
 }\r
 \r
 void Vore_Regurgitate(entity e)\r
@@ -102,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.alpha = 0; // best way of hiding / showing the eaten player\r
-       e.view_ofs_z *= 2; // best positioning for the stomach model\r
-       e.stat_eaten = FALSE;\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
 \r
        // velocities\r
        local vector oldforward, oldright, oldup;\r
@@ -123,10 +156,14 @@ void Vore_Regurgitate(entity e)
        pointparticles(particleeffectnum("regurgitate"), e.eater.origin, '0 0 0', 1);\r
        e.eater.stomach_load -= 1;\r
        e.eater.regurgitate_prepare = 0;\r
+       e.eater.swallow_delay = time + cvar("g_balance_vore_swallow_delay");\r
        Vore_Weight_apply(e.eater);\r
+\r
+       e.system_delay = e.eater.system_delay = time + system_delay_time;\r
        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
@@ -134,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 = FALSE;\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
@@ -150,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
@@ -166,7 +203,7 @@ void Vore_Digest()
                if (self.eater.digestsound_finished < time)\r
                {\r
                        self.eater.digestsound_finished = time + 0.5;\r
-                       sound (self.eater, CHAN_PLAYER, "player/digest.wav", VOL_BASE, ATTN_NORM);\r
+                       PlayerSound (self.eater, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
                }\r
                self.eater.digestion_step = time;\r
        }\r
@@ -190,32 +227,52 @@ void Vore_Teamheal()
 .float stomachkick_delay;\r
 void Vore_StomachKick()\r
 {\r
-       // allows prey to kick the predator's stomach and do some damage, 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\r
-       if(self.BUTTON_ATCK)\r
        if(time > self.stomachkick_delay)\r
        {\r
                float damage;\r
                damage = ceil(random() * (cvar("g_balance_vore_kick_damage_max") - cvar("g_balance_vore_kick_damage_min")) + cvar("g_balance_vore_kick_damage_min"));\r
-\r
                Damage(self.eater, self, self, damage, DEATH_STOMACHKICK, self.eater.origin, '0 0 0');\r
                sound(self.eater, CHAN_PROJECTILE, "weapons/stomachkick.ogg", VOL_BASE, ATTN_NORM);\r
+\r
+               if(cvar("g_balance_vore_kick_escapeprobability") >= random())\r
+                       Vore_Regurgitate(self);\r
+\r
                self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay");\r
        }\r
+}\r
 \r
-       // start the predator's digestion\r
-       if(self.BUTTON_ATCK2)\r
+.float gurglesound_finished, gurglesound_oldstomachload;\r
+void Vore_Gurglesound()\r
+{\r
+       if(time > self.gurglesound_finished || self.gurglesound_oldstomachload != self.stomach_load)\r
        {\r
-               centerprint(self.eater, strcat(self.netname, " triggered your digestion"));\r
-               self.eater.digesting = TRUE;\r
+               GlobalSound(self.playersound_gurgle, CHAN_TRIGGER, VOICETYPE_GURGLE);\r
+\r
+               self.gurglesound_finished = time + 11; // yes, hard coded sound length. I know it's bad but what can I do?\r
+               self.gurglesound_oldstomachload = self.stomach_load;\r
        }\r
 }\r
 \r
 void Vore()\r
 {\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
        {\r
@@ -224,6 +281,8 @@ void Vore()
        }\r
        if(self.spectatee_status)\r
                return;\r
+       if(time < self.system_delay)\r
+               return;\r
 \r
 // --------------------------------\r
 // Code that addresses predators:\r
@@ -288,6 +347,9 @@ void Vore()
                }\r
        }\r
 \r
+       if(cvar("g_vore_gurglesound"))\r
+               Vore_Gurglesound();\r
+\r
 // --------------------------------\r
 // Code that addresses the prey:\r
 // --------------------------------\r
@@ -315,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