]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Implement full digest feature. When enabled, the pred doesn't spit the prey's dead...
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 1c8b2d058f7ca659372d806063adf726ac719c38..70bdd8632066b3703a96bd2b349771be62dffd77 100644 (file)
@@ -1,7 +1,7 @@
 .float regurgitate_prepare;\r
 .float system_delay, swallow_delay, digest_button_delay_time, regurgitate_button_delay_time;\r
 .float complain_vore;\r
-.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload, vore_oldview_ofs_z;\r
+.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload;\r
 \r
 const float system_delay_time = 0.1;\r
 const float complain_delay_time = 1;\r
@@ -30,13 +30,25 @@ float Swallow_condition_check(entity prey)
        if(prey != self)\r
        if(prey.classname == "player" && prey.predator.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.predator.classname != "player" && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves\r
+       if(!self.BUTTON_REGURGITATE && self.swallow_delay < time)\r
        if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap"))\r
        {\r
+               if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore"))\r
+               {\r
+                       if(time > self.complain_vore)\r
+                       {\r
+                               play2(self, "misc/unavailable.wav");\r
+                               sprint(self, "You cannot swallow your team mates\n");\r
+                               self.complain_vore = time + complain_delay_time;\r
+                       }\r
+                       return FALSE;\r
+               }\r
+\r
                if(self.stomach_load >= cvar("g_balance_vore_swallow_limit"))\r
                {\r
                        if(time > self.complain_vore)\r
                        {\r
-                               play2(self, "weapons/unavailable.wav");\r
+                               play2(self, "misc/unavailable.wav");\r
                                sprint(self, strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n"));\r
                                self.complain_vore = time + complain_delay_time;\r
                        }\r
@@ -48,7 +60,7 @@ float Swallow_condition_check(entity prey)
                {\r
                        if(time > self.complain_vore)\r
                        {\r
-                               play2(self, "weapons/unavailable.wav");\r
+                               play2(self, "misc/unavailable.wav");\r
                                sprint(self, "You cannot swallow someone with a bigger stomach than yours\n");\r
                                self.complain_vore = time + complain_delay_time;\r
                        }\r
@@ -64,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
@@ -99,7 +113,7 @@ void Vore_CameraEffect_Apply()
        else\r
                self.cameraeffect_current = self.cameraeffect_target;\r
 \r
-       self.view_ofs_z = self.vore_oldview_ofs_z / self.cameraeffect_current;\r
+       self.view_ofs_z = PL_VIEW_OFS_z / self.cameraeffect_current;\r
 }\r
 \r
 .float gurgle_oldstomachload;\r
@@ -134,7 +148,6 @@ void Vore_Swallow(entity e)
 \r
        e.vore_oldmovetype = e.movetype;\r
        e.vore_oldsolid = e.solid;\r
-       e.vore_oldview_ofs_z = e.view_ofs_z;\r
 \r
        e.predator = self;\r
        setorigin(e, e.predator.origin);\r
@@ -165,6 +178,7 @@ void Vore_Swallow(entity e)
        e.predator.punchangle_x -= e.predator.cvar_cl_vore_punchangle;\r
        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
 \r
        // block firing for a small amount of time, or we'll be firing the next frame after we swallow\r
@@ -180,7 +194,7 @@ 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.view_ofs_z = PL_VIEW_OFS_z;\r
        e.alpha = default_player_alpha;\r
 \r
        // apply velocities\r
@@ -213,13 +227,68 @@ 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.fakepredator.classname == "player")\r
+               return;\r
+\r
+       // this entity is pretty much like e.predator but for dead prey, to avoid some conflicts\r
+       e.fakepredator = e.predator;\r
+\r
+       // first release the prey from the predator, as dead prey needs to be attached to predators differently\r
+       // the predator's stomach load is also decreased, as our dead prey doesn't count as actual prey any more\r
+       e.predator.stomach_load -= 1;\r
+       Vore_Weight_apply(e.predator);\r
+       e.predator = world;\r
+\r
+       // now, keep our dead prey inside the predator's stomach\r
+       e.movetype = MOVETYPE_FOLLOW;\r
+       e.aiment = e.fakepredator;\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
+\r
+       if(e.fakepredator.classname != "player")\r
+               return;\r
+\r
+       e.movetype = e.vore_oldmovetype;\r
+       e.view_ofs_z = PL_VIEW_OFS_z;\r
+       e.alpha = default_player_alpha;\r
+\r
+       // if we disconnect dead prey from the predator, gib it's body\r
+       if(e.health <= 0)\r
+               e.health = -1000;\r
+\r
+       e.fakepredator = world;\r
+}\r
+\r
+void Vore_ChoosePreyRelease(entity e)\r
+{\r
+       // if the fulldigest feature is on, we 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 the predator's dead, we detach the dead prey from him\r
+               if(e.fakepredator.deadflag != DEAD_NO)\r
+                       Vore_DeadPrey_Detach(e);\r
+       }\r
+       else\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_ChoosePreyRelease(self);\r
 \r
        // pred disconnects or goes spectating with players in their belly\r
        else if(self.stomach_load > 0)\r
@@ -228,10 +297,12 @@ void Vore_Disconnect()
                FOR_EACH_PLAYER(head)\r
                {\r
                        if(head.predator == self)\r
-                               Vore_Regurgitate(head);\r
+                               Vore_ChoosePreyRelease(head);\r
                }\r
                Vore_Gurglesound(); // stop the gurgling sound\r
        }\r
+\r
+       self.stomach_load = self.gravity = 0; // prevents a bug\r
 }\r
 \r
 .float digestion_step;\r
@@ -280,7 +351,7 @@ void Vore_StomachKick()
        {\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
-               Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, '0 0 0');\r
+               Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, v_forward * cvar("g_balance_vore_kick_force"));\r
                sound(self.predator, CHAN_PROJECTILE, "weapons/stomachkick.ogg", VOL_BASE, ATTN_NORM);\r
 \r
                if(random() < cvar("g_balance_vore_kick_escapeprobability"))\r
@@ -298,7 +369,7 @@ void Vore_StomachLeave()
                Vore_Regurgitate(self);\r
        else if(time > self.complain_vore)\r
        {\r
-               play2(self, "weapons/unavailable.wav");\r
+               play2(self, "misc/unavailable.wav");\r
                sprint(self, strcat("You cannot get out of ", self.predator.netname, "\n"));\r
                self.complain_vore = time + complain_delay_time;\r
        }\r
@@ -308,6 +379,29 @@ void Vore()
 {\r
        // main vore code, this is where it all happens\r
 \r
+       if(!cvar("g_vore")) // the vore system is disabled\r
+       {\r
+               Vore_Disconnect();\r
+               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
@@ -366,12 +460,12 @@ void Vore()
        prey = Swallow_player_check();\r
 \r
        // attempt to swallow our new prey if we pressed the attack button, and there's any in range\r
-       if(self.BUTTON_ATCK && !self.BUTTON_REGURGITATE && self.swallow_delay < time)\r
+       if(self.BUTTON_ATCK)\r
        if(Swallow_condition_check(prey))\r
                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
@@ -383,12 +477,12 @@ void Vore()
                }\r
                else if(time > self.complain_vore)\r
                {\r
-                       play2(self, "weapons/unavailable.wav");\r
+                       play2(self, "misc/unavailable.wav");\r
                        sprint(self, "There is nothing to digest\n");\r
                        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
@@ -405,7 +499,7 @@ void Vore()
                }\r
                else if(time > self.complain_vore)\r
                {\r
-                       play2(self, "weapons/unavailable.wav");\r
+                       play2(self, "misc/unavailable.wav");\r
                        sprint(self, "There is nothing to regurgitate\n");\r
                        self.complain_vore = time + complain_delay_time;\r
                }\r
@@ -418,10 +512,14 @@ void Vore()
 // Code that addresses the prey:\r
 // --------------------------------\r
 \r
+       if(self.deadflag)\r
+       {\r
+               Vore_ChoosePreyRelease(self);\r
+               return;\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
@@ -438,10 +536,11 @@ void Vore()
        if(self.predator.digesting == TRUE)\r
                Vore_Digest();\r
        if(teams_matter && self.team == self.predator.team)\r
+       if(cvar("g_balance_vore_teamheal") && cvar("g_vore_teamvore"))\r
                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