]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Limit g_balance_vore_swallow_limit between 1 and 9. This fixes some small bugs, such...
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 871b199a6d09bf5c8404e30c1ecadd5faa4e5e46..0b0e01cd115677bd1d5fa31959204123b95d9f1c 100644 (file)
@@ -1,5 +1,5 @@
 .float regurgitate_prepare;\r
-.float system_delay, swallow_delay, digest_button_delay_time, regurgitate_button_delay_time;\r
+.float stomachkick_delay, system_delay, action_delay, digest_button_delay_time, regurgitate_button_delay_time;\r
 .float complain_vore;\r
 .float vore_oldmovetype, vore_oldsolid, vore_oldstomachload;\r
 \r
@@ -33,9 +33,9 @@ float Swallow_condition_check(entity prey)
        // checks the necessary conditions for swallowing a player\r
 \r
        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(prey.classname == "player" && !prey.stat_eaten && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach\r
+       if(self.classname == "player" && !self.stat_eaten && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves\r
+       if(!self.BUTTON_REGURGITATE && time > self.action_delay)\r
        if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap"))\r
        {\r
                string swallow_complain;\r
@@ -43,10 +43,12 @@ float Swallow_condition_check(entity prey)
                        swallow_complain = "You cannot swallow your team mates\n";\r
                else if(!cvar("g_vore_spawnshield") && prey.spawnshieldtime > time)\r
                        swallow_complain = "You cannot swallow someone protected by the spawn shield\n";\r
-               else if(self.stomach_load >= cvar("g_balance_vore_swallow_limit"))\r
-                       swallow_complain = strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n");\r
+               else if(self.stomach_load >= g_balance_vore_swallow_limit)\r
+                       swallow_complain = strcat("You cannot swallow more than ^2", ftos(g_balance_vore_swallow_limit), "^7 players at a time\n");\r
                else if(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load)\r
                        swallow_complain = "You cannot swallow someone with a bigger stomach than yours\n";\r
+               else if(cvar("g_vore_biggersize") && prey.scale > self.scale)\r
+                       swallow_complain = "You cannot swallow someone larger than you\n";\r
 \r
                if(swallow_complain != "")\r
                {\r
@@ -81,7 +83,7 @@ float Stomach_TeamMates_check(entity pred)
 \r
 float Vore_CanLeave()\r
 {\r
-       if(self.predator.classname == "player")\r
+       if(self.stat_eaten)\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
@@ -94,19 +96,67 @@ float Vore_CanLeave()
 }\r
 \r
 // position the camera properly for prey\r
-void Vore_SetCamera()\r
+void Vore_SetPreyPositions()\r
 {\r
-       if not(self.predator.classname == "player" || self.fakeprey > 1)\r
-               return;\r
+       // self is the predator and head is the prey\r
 \r
-       self.view_ofs = PL_PREY_VIEW_OFS;\r
+       local entity head;\r
+       local vector origin_apply;\r
+       local float position_counter;\r
 \r
-       float prey_height;\r
-       if(self.fakeprey > 1)\r
-               prey_height = (self.scale - self.fakepredator.scale) * cvar("g_healthsize_vore_pos");\r
-       else\r
-               prey_height = (self.scale - self.predator.scale) * cvar("g_healthsize_vore_pos");\r
-       self.view_ofs_z += prey_height;\r
+       // In order to allow prey to see each other in the stomach, we must position each occupant differently,\r
+       // else all players overlap in the center. To do this, we run a loop on all players in the same stomach.\r
+       // For each player, the origin is updated, then a new origin is used for the next player.\r
+       // This requires that no more than 9 players may be in the stomach at a time!\r
+       FOR_EACH_PLAYER(head)\r
+       {\r
+               if(head.predator == self)\r
+               {\r
+                       switch(position_counter)\r
+                       {\r
+                               case 0:\r
+                                       origin_apply = '0 0 0'; // first occupant sits in the middle\r
+                                       break;\r
+                               case 1:\r
+                                       origin_apply = '1 0 0'; // second occupant sits in the front\r
+                                       break;\r
+                               case 2:\r
+                                       origin_apply = '-1 0 0'; // third occupant sits in the back\r
+                                       break;\r
+                               case 3:\r
+                                       origin_apply = '0 1 0'; // fourth occupant sits in the right\r
+                                       break;\r
+                               case 4:\r
+                                       origin_apply = '0 -1 0'; // fifth occupant sits in the left\r
+                                       break;\r
+                               case 5:\r
+                                       origin_apply = '1 1 0'; // sixth occupant sits in the front-right\r
+                                       break;\r
+                               case 6:\r
+                                       origin_apply = '-1 1 0'; // seventh occupant sits in the back-right\r
+                                       break;\r
+                               case 7:\r
+                                       origin_apply = '1 -1 0'; // eigth occupant sits in the front-left\r
+                                       break;\r
+                               case 8:\r
+                                       origin_apply = '-1 -1 0'; // ninth occupant sits in the back-left\r
+                                       break;\r
+                               default:\r
+                                       break;\r
+                       }\r
+\r
+                       // since prey have their predators set as an aiment, view_ofs will specify the real origin of prey, not just the view offset\r
+                       head.view_ofs = PL_PREY_VIEW_OFS + origin_apply * cvar("g_vore_neighborprey_distance");\r
+                       head.view_ofs_z *= self.scale; // stomach center depends on predator scale\r
+\r
+                       // change prey height based on scale\r
+                       float prey_height;\r
+                               prey_height = (head.scale - self.scale) * cvar("g_healthsize_vore_pos");\r
+                       head.view_ofs_z += prey_height;\r
+\r
+                       position_counter += 1;\r
+               }\r
+       }\r
 }\r
 \r
 .float gurgle_oldstomachload;\r
@@ -192,8 +242,9 @@ void Vore_Swallow(entity e)
 \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
-       e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay");\r
+       e.predator.action_delay = time + cvar("g_balance_vore_action_delay");\r
        e.system_delay = e.predator.system_delay = time + system_delay_time;\r
+       e.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); // don't kick immediately after being swallowed\r
 }\r
 \r
 void Vore_Regurgitate(entity e)\r
@@ -226,7 +277,7 @@ void Vore_Regurgitate(entity e)
        e.predator.punchangle_x += cvar("g_balance_vore_regurgitate_punchangle");\r
        e.predator.stomach_load -= 1;\r
        e.predator.regurgitate_prepare = 0;\r
-       e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay");\r
+       e.predator.action_delay = time + cvar("g_balance_vore_action_delay");\r
        Vore_WeightApply(e.predator);\r
 \r
        // block firing for a small amount of time, or we'll be firing the next frame\r
@@ -239,12 +290,12 @@ void Vore_DeadPrey_Configure(entity e)
 {\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
+       if(e.fakeprey || !e.stat_eaten) // we already configured everything\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 = 2; // is fakeprey in a stomach\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
@@ -268,7 +319,8 @@ void Vore_DeadPrey_Detach(entity e)
                return;\r
 \r
        e.fakepredator = world;\r
-       e.fakeprey = 1; // was fakeprey but is now detached\r
+       e.fakeprey = TRUE; // keep fakeprey status\r
+       e.stat_eaten = 0;\r
        e.aiment = world;\r
        e.movetype = MOVETYPE_TOSS;\r
 }\r
@@ -277,12 +329,12 @@ void Vore_PreyRelease(entity e, float pred_disconnect)
 {\r
        if(pred_disconnect)\r
        {\r
-               if(e.fakeprey > 1)\r
+               if(e.fakeprey)\r
                        Vore_DeadPrey_Detach(e);\r
                else\r
                        Vore_Regurgitate(e);\r
        }\r
-       else\r
+       else if(self.stat_eaten && !self.fakeprey)\r
        {\r
                // if the keepdeadprey feature is on, don't spit a dead prey's carcass out\r
                if(e.deadflag != DEAD_NO && random() < cvar("g_vore_keepdeadprey"))\r
@@ -297,7 +349,7 @@ void Vore_Disconnect()
        // 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
+       if(self.stat_eaten)\r
                Vore_PreyRelease(self, TRUE);\r
 \r
        // pred disconnects or goes spectating with players in their belly\r
@@ -317,18 +369,25 @@ void Vore_Digest()
 {\r
        // apply digestion to prey\r
 \r
-       if(time > self.predator.digestion_step)\r
+       if(time > self.digestion_step)\r
        {\r
-               Damage(self, self.predator, self.predator, cvar("g_balance_vore_digestion_damage"), DEATH_DIGESTION, self.origin, '0 0 0');\r
+               // if distributed digestion is enabled, reduce digestion strength by the number of prey in our stomach\r
+               float reduce;\r
+               if(cvar("g_balance_vore_digestion_distribute"))\r
+                       reduce = self.predator.stomach_load;\r
+               else\r
+                       reduce = 1;\r
+\r
+               Damage(self, self.predator, self.predator, cvar("g_balance_vore_digestion_damage") / reduce, DEATH_DIGESTION, self.origin, '0 0 0');\r
                if(cvar("g_balance_vore_digestion_vampire") && self.predator.health < cvar("g_balance_vore_digestion_vampire_stable"))\r
-                       self.predator.health += cvar("g_balance_vore_digestion_vampire");\r
+                       self.predator.health += cvar("g_balance_vore_digestion_vampire") / reduce;\r
 \r
                if (self.predator.digestsound_finished < time)\r
                {\r
                        PlayerSound (self.predator, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
                        self.predator.digestsound_finished = time + 0.5;\r
                }\r
-               self.predator.digestion_step = time + steptime;\r
+               self.digestion_step = time + steptime;\r
        }\r
 \r
        if(self.deadflag != DEAD_NO)\r
@@ -356,7 +415,6 @@ void Vore_Teamheal()
        }\r
 }\r
 \r
-.float stomachkick_delay;\r
 void Vore_StomachKick()\r
 {\r
        // allows prey to kick the predator's stomach and do some damage or attempt to escape\r
@@ -371,9 +429,6 @@ void Vore_StomachKick()
                self.predator.punchangle_x -= cvar("g_balance_vore_kick_predator_punchangle");\r
                self.punchangle_x += cvar("g_balance_vore_kick_prey_punchangle");\r
 \r
-               if(random() < cvar("g_balance_vore_kick_escapeprobability"))\r
-                       Vore_Regurgitate(self);\r
-\r
                self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay");\r
        }\r
 }\r
@@ -414,7 +469,7 @@ void Vore_AutoTaunt()
        }\r
 \r
        // prey taunts\r
-       if(self.predator.classname == "player" && !(teams_matter && self.team == self.predator.team))\r
+       if(self.stat_eaten && !(teams_matter && self.team == self.predator.team))\r
        {\r
                if(!self.taunt_soundtime) // taunt_soundtime becomes 0 once the taunt has played\r
                {\r
@@ -429,6 +484,35 @@ void Vore_AutoTaunt()
        }\r
 }\r
 \r
+void Vore_SetSbarRings()\r
+{\r
+       // first clear the ring stats, then configure them if needed\r
+       self.stat_sbring1_type = self.stat_sbring1_clip = 0;\r
+       self.stat_sbring2_type = self.stat_sbring2_clip = 0;\r
+\r
+       if(self.stat_eaten)\r
+       {\r
+               if(time <= self.stomachkick_delay)\r
+               {\r
+                       self.stat_sbring1_type = 2; // ring shows stomach kick delay, empties with progress\r
+                       self.stat_sbring1_clip = bound(0, (time / self.stomachkick_delay - 1) / ((self.stomachkick_delay - cvar("g_balance_vore_kick_delay")) / self.stomachkick_delay - 1), 1);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if(time <= self.action_delay)\r
+               {\r
+                       self.stat_sbring1_type = 1; // ring shows vore action delay, empties with progress\r
+                       self.stat_sbring1_clip = bound(0, (time / self.action_delay - 1) / ((self.action_delay - cvar("g_balance_vore_action_delay")) / self.action_delay - 1), 1);\r
+               }\r
+               if(time <= self.regurgitate_prepare)\r
+               {\r
+                       self.stat_sbring2_type = 1; // ring shows regurgitation preparing, fills with progress\r
+                       self.stat_sbring2_clip = 1 - bound(0, (time / self.regurgitate_prepare - 1) / ((self.regurgitate_prepare - cvar("g_balance_vore_regurgitate_delay")) / self.regurgitate_prepare - 1), 1);\r
+               }\r
+       }\r
+}\r
+\r
 void Vore()\r
 {\r
        // main vore code, this is where it all happens\r
@@ -442,7 +526,7 @@ void Vore()
        Vore_AutoTaunt();\r
 \r
        // wash the goo away from players once they leave the stomach\r
-       if(self.predator.classname != "player")\r
+       if(!self.stat_eaten)\r
        if(stov(cvar_string("g_vore_regurgitatecolor_release")))\r
        if(self.colormod)\r
        if(cvar("g_vore_regurgitatecolor_release_fade"))\r
@@ -459,7 +543,8 @@ void Vore()
        }\r
 \r
        // set all vore stats\r
-       if(self.fakeprey > 1)\r
+       Vore_SetSbarRings();\r
+       if(self.fakepredator.classname == "player")\r
                self.stat_eaten = num_for_edict(self.fakepredator);\r
        else if(self.predator.classname == "player")\r
        {\r
@@ -478,7 +563,7 @@ void Vore()
        // don't allow a player inside a player inside another player :)\r
        // prevent this by checking if such has happened, and taking the proper measures\r
        // this code has a high priority and must not be stopped by any delay, so run it here\r
-       if(self.predator.predator.classname == "player")\r
+       if(self.predator.stat_eaten)\r
        {\r
                entity target_predator, target_predator_predator, oldself;\r
                target_predator = self.predator;\r
@@ -555,7 +640,7 @@ void Vore()
                self.digesting = FALSE;\r
 \r
        // predator wishes to regurgitate his prey\r
-       if(self.BUTTON_REGURGITATE)\r
+       if(self.BUTTON_REGURGITATE && time > self.action_delay)\r
        {\r
                if(self.stomach_load)\r
                {\r
@@ -581,14 +666,14 @@ void Vore()
 // Code that addresses the prey:\r
 // --------------------------------\r
 \r
-       Vore_SetCamera();\r
+       Vore_SetPreyPositions();\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
+       if(self.fakeprey)\r
+       if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.stat_eaten)\r
                Vore_DeadPrey_Detach(self);\r
 \r
-       if(self.predator.classname != "player")\r
+       if(!self.stat_eaten)\r
                return;\r
 \r
        if(self.deadflag != DEAD_NO)\r