]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Fix one more bug that broke the old digestion method
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 61330cd49e2d8c844407c83ef4a8e0c53d7afa05..e51b0b81b887702182ce379cc030defa54faf1f7 100644 (file)
@@ -76,6 +76,8 @@ float Vore_CanLeave()
 {\r
        if(self.predator.classname == "player")\r
        {\r
+               if(!cvar("g_vore_kick")) // you are defenseless in the stomach if you can't kick, so allow leaving\r
+                       return TRUE;\r
                if(teams_matter && self.team == self.predator.team)\r
                        return TRUE;\r
                if(g_rpg && cvar("g_rpg_canleave"))\r
@@ -115,7 +117,7 @@ void Vore_CameraEffect_Apply()
 }\r
 \r
 .float gurgle_oldstomachload;\r
-void Vore_Gurglesound()\r
+void Vore_GurgleSound()\r
 {\r
        if(time > self.gurglesound_finished || self.gurgle_oldstomachload != self.stomach_load)\r
        {\r
@@ -126,7 +128,7 @@ void Vore_Gurglesound()
        }\r
 }\r
 \r
-void Vore_Weight_apply(entity e)\r
+void Vore_WeightApply(entity e)\r
 {\r
        // apply stomach weight that makes you heavier the more you eat\r
        // slowing the player is done in cl_physics.qc\r
@@ -177,7 +179,7 @@ void Vore_Swallow(entity e)
        e.predator.stomach_load += 1;\r
        e.predator.regurgitate_prepare = 0;\r
        e.predator.spawnshieldtime = 0; // lose spawn shield when we vore\r
-       Vore_Weight_apply(e.predator);\r
+       Vore_WeightApply(e.predator);\r
 \r
        // block firing for a small amount of time, or we'll be firing the next frame after we swallow\r
        e.predator.weapon_delay = time + button_delay_time;\r
@@ -217,7 +219,7 @@ void Vore_Regurgitate(entity e)
        e.predator.stomach_load -= 1;\r
        e.predator.regurgitate_prepare = 0;\r
        e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay");\r
-       Vore_Weight_apply(e.predator);\r
+       Vore_WeightApply(e.predator);\r
 \r
        // block firing for a small amount of time, or we'll be firing the next frame\r
        e.weapon_delay = time + button_delay_time;\r
@@ -225,13 +227,70 @@ void Vore_Regurgitate(entity e)
        e.predator = world;\r
 }\r
 \r
+void Vore_DeadPrey_Configure(entity e)\r
+{\r
+       // ran when the fulldigest feature is enabled and prey stays inside the stomach after dying\r
+\r
+       if(e.fakeprey || e.predator.classname != "player") // already configured\r
+               return;\r
+\r
+       // this entity is like e.predator but for dead prey, to avoid conflicts\r
+       e.fakepredator = e.predator;\r
+       e.fakeprey = TRUE;\r
+\r
+       // first release the prey from the predator, as dead prey needs to be attached differently\r
+       // the predator's stomach load is also decreased, as dead prey doesn't count any more\r
+       e.predator.stomach_load -= 1;\r
+       Vore_WeightApply(e.predator);\r
+       e.predator = world;\r
+\r
+       // now put our dead prey inside the predator's stomach, but only as an effect\r
+       e.movetype = MOVETYPE_FOLLOW;\r
+       e.takedamage = DAMAGE_NO;\r
+       e.solid = SOLID_NOT;\r
+       e.aiment = e.fakepredator;\r
+\r
+       // completely remove the dead body\r
+       e.alpha = -1;\r
+}\r
+\r
+void Vore_DeadPrey_Detach(entity e)\r
+{\r
+       // ran when dead prey must be detached from the stomach (eg: they are respawning)\r
+       // should only execute after Vore_DeadPrey_Configure has ran first\r
+\r
+       if not(cvar("g_vore_fulldigest"))\r
+               return;\r
+\r
+       e.fakepredator = world;\r
+       e.aiment = world;\r
+\r
+       if(!e.deadflag)\r
+               e.fakeprey = FALSE;\r
+}\r
+\r
+void Vore_PreyRelease(entity e)\r
+{\r
+       // if the fulldigest feature is on, don't spit a dead prey's carcass out\r
+       if(e.health <= 0 && cvar("g_vore_fulldigest"))\r
+       {\r
+               Vore_DeadPrey_Configure(e);\r
+\r
+               // if fulldigest is enabled and the predator is dead or disconnected, detach the dead prey from him\r
+               if(self.fakepredator.classname != "player" || self.fakepredator.deadflag != DEAD_NO)\r
+                       Vore_DeadPrey_Detach(self);\r
+       }\r
+       else if(self.predator.classname != "player")\r
+               Vore_Regurgitate(e);\r
+}\r
+\r
 void Vore_Disconnect()\r
 {\r
        // frees prey from their predators when someone disconnects or goes spectating, or in other circumstances\r
 \r
        // prey disconnects or goes spectating while inside someone's belly\r
        if(self.predator.classname == "player")\r
-               Vore_Regurgitate(self);\r
+               Vore_PreyRelease(self);\r
 \r
        // pred disconnects or goes spectating with players in their belly\r
        else if(self.stomach_load > 0)\r
@@ -240,9 +299,9 @@ void Vore_Disconnect()
                FOR_EACH_PLAYER(head)\r
                {\r
                        if(head.predator == self)\r
-                               Vore_Regurgitate(head);\r
+                               Vore_PreyRelease(head);\r
                }\r
-               Vore_Gurglesound(); // stop the gurgling sound\r
+               Vore_GurgleSound(); // stop the gurgling sound\r
        }\r
 \r
        self.stomach_load = self.gravity = 0; // prevents a bug\r
@@ -253,9 +312,6 @@ void Vore_Digest()
 {\r
        // apply digestion to prey\r
 \r
-       if(!cvar("g_vore_digestion"))\r
-               return;\r
-\r
        if(time > self.predator.digestion_step)\r
        {\r
                Damage(self, self.predator, self.predator, cvar("g_balance_vore_digestion_damage"), DEATH_DIGESTION, self.origin, '0 0 0');\r
@@ -293,9 +349,6 @@ void Vore_StomachKick()
 {\r
        // allows prey to kick the predator's stomach and do some damage or attempt to escape\r
 \r
-       if(!cvar("g_vore_kick"))\r
-               return;\r
-\r
        if(time > self.stomachkick_delay)\r
        {\r
                float damage;\r
@@ -334,6 +387,23 @@ void Vore()
                return;\r
        }\r
 \r
+       // wash the goo away from players once they leave the stomach\r
+       if(self.predator.classname != "player")\r
+       if(stov(cvar_string("g_vore_regurgitatecolor_release")))\r
+       if(self.colormod)\r
+       if(cvar("g_vore_regurgitatecolor_release_fade"))\r
+       {\r
+               self.colormod_x += cvar("g_vore_regurgitatecolor_release_fade") * frametime;\r
+               if(self.colormod_x > 1)\r
+                       self.colormod_x = 1;\r
+               self.colormod_y += cvar("g_vore_regurgitatecolor_release_fade") * frametime;\r
+               if(self.colormod_y > 1)\r
+                       self.colormod_y = 1;\r
+               self.colormod_z += cvar("g_vore_regurgitatecolor_release_fade") * frametime;\r
+               if(self.colormod_z > 1)\r
+                       self.colormod_z = 1;\r
+       }\r
+\r
        // set all vore related stats\r
        if(self.predator.classname == "player")\r
        {\r
@@ -397,7 +467,7 @@ void Vore()
                Vore_Swallow(prey);\r
 \r
        // toggle digestion, if the player has someone in their stomach\r
-       if(self.BUTTON_DIGEST)\r
+       if(self.BUTTON_DIGEST && cvar("g_vore_digestion"))\r
        {\r
                if(self.stomach_load)\r
                {\r
@@ -414,7 +484,7 @@ void Vore()
                        self.complain_vore = time + complain_delay_time;\r
                }\r
        }\r
-       if(!self.stomach_load)\r
+       if(!self.stomach_load || !cvar("g_vore_digestion"))\r
                self.digesting = FALSE;\r
 \r
        // predator wishes to regurgitate his prey\r
@@ -438,16 +508,22 @@ void Vore()
        }\r
 \r
        if(cvar("g_vore_gurglesound"))\r
-               Vore_Gurglesound();\r
+               Vore_GurgleSound();\r
 \r
 // --------------------------------\r
 // Code that addresses the prey:\r
 // --------------------------------\r
 \r
+       if(self.deadflag)\r
+       {\r
+               Vore_PreyRelease(self);\r
+               return;\r
+       }\r
+\r
        if(self.predator.classname != "player")\r
                return;\r
 \r
-       if(self.deadflag || self.predator.deadflag)\r
+       if(self.predator.deadflag)\r
                Vore_Regurgitate(self);\r
        else if(vlen(self.predator.velocity) > cvar("g_balance_vore_regurgitate_speedcap"))\r
                Vore_Regurgitate(self);\r
@@ -468,7 +544,7 @@ void Vore()
                Vore_Teamheal();\r
 \r
        // execute prey commands\r
-       if(self.BUTTON_ATCK)\r
+       if(self.BUTTON_ATCK && cvar("g_vore_kick"))\r
                Vore_StomachKick();\r
        if(self.BUTTON_JUMP)\r
                Vore_StomachLeave();\r