]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Autodigest client-side feature. When enabled, a player automatically begins digesting...
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 7e002a1aef7ecb8d1815a813c78ae60d7e4989b9..b4a2126eb58548a3760ffc540183119f98da9266 100644 (file)
@@ -140,6 +140,29 @@ void Vore_WeightApply(entity e)
        e.vore_oldstomachload = e.stomach_load;\r
 }\r
 \r
+void Vore_AutoDigest(entity e)\r
+{\r
+       // if the predator has the autodigest preference enabled, begin digesting new prey automatically\r
+\r
+       if not(e.cvar_cl_vore_autodigest)\r
+               return;\r
+       if not(cvar("g_vore_digestion"))\r
+               return;\r
+\r
+       entity head;\r
+       if(teams_matter)\r
+       {\r
+               FOR_EACH_PLAYER(head)\r
+               {\r
+                       // never begin automatic digestion if we've swallowed a team mate\r
+                       if(head.team == e.team)\r
+                               return;\r
+               }\r
+       }\r
+\r
+       e.digesting = TRUE;\r
+}\r
+\r
 .entity pusher;\r
 .float pushltime;\r
 void Vore_Swallow(entity e)\r
@@ -180,6 +203,7 @@ void Vore_Swallow(entity e)
        e.predator.regurgitate_prepare = 0;\r
        e.predator.spawnshieldtime = 0; // lose spawn shield when we vore\r
        Vore_WeightApply(e.predator);\r
+       Vore_AutoDigest(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
@@ -229,7 +253,7 @@ void Vore_Regurgitate(entity e)
 \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
+       // ran when the keepdeadprey 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
@@ -259,7 +283,7 @@ void Vore_DeadPrey_Detach(entity e)
        // 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
+       if not(cvar("g_vore_keepdeadprey"))\r
                return;\r
 \r
        e.fakepredator = world;\r
@@ -271,14 +295,14 @@ void Vore_DeadPrey_Detach(entity e)
 \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
+       // if the keepdeadprey feature is on, don't spit a dead prey's carcass out\r
+       if(e.health <= 0 && cvar("g_vore_keepdeadprey"))\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
+               // if keepdeadprey is enabled and the predator disconnected, detach the dead prey\r
+               if(e.fakepredator.classname != "player")\r
+                       Vore_DeadPrey_Detach(e);\r
        }\r
        else\r
                Vore_Regurgitate(e);\r
@@ -514,6 +538,11 @@ void Vore()
 // Code that addresses the prey:\r
 // --------------------------------\r
 \r
+       // keepdeadprey - detach dead prey if their predator died or got swallowed\r
+       if(self.fakepredator.classname == "player")\r
+       if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.predator.classname == "player")\r
+               Vore_DeadPrey_Detach(self);\r
+\r
        if(self.predator.classname != "player")\r
                return;\r
 \r