]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Fix a bug causing regurgitation to loop if holding the regurgitate button down. Mainl...
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index aac9eda24ddff885d53a0d5becc9b8a197ec2987..464afe503b6966e736aa3a0640fadc8deaee8115 100644 (file)
@@ -1,4 +1,3 @@
-.float regurgitate_prepare;\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;\r
@@ -6,7 +5,6 @@
 const float system_delay_time = 0.1;\r
 const float complain_delay_time = 1;\r
 const float button_delay_time = 0.5;\r
-const float steptime = 0.1;\r
 \r
 entity Swallow_player_check()\r
 {\r
@@ -139,7 +137,7 @@ void Vore_SetPreyPositions(entity pred)
 .float gurgle_oldstomachload;\r
 void Vore_GurgleSound()\r
 {\r
-       if(time > self.gurglesound_finished || self.gurgle_oldstomachload != self.stomach_load)\r
+       if(time > self.gurglesound_finished || (self.gurgle_oldstomachload != self.stomach_load && !self.digesting))\r
        {\r
                GlobalSound(self.playersound_gurgle, CHAN_TRIGGER, VOICETYPE_GURGLE);\r
 \r
@@ -148,6 +146,22 @@ void Vore_GurgleSound()
        }\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(!cvar("g_vore_digestion") || e.digesting)\r
+               return;\r
+       if(clienttype(e) != CLIENTTYPE_REAL)\r
+               return; // this feature is only for players, not bots\r
+       if(e.stomach_load)\r
+               return; // don't start digestion if we already ate someone, as that means we manually disabled it after the first prey and want it off\r
+       if(Stomach_TeamMates_check(e))\r
+               return; // never begin automatic digestion if we've swallowed a team mate\r
+\r
+       e.digesting = TRUE;\r
+}\r
+\r
 void Vore_StomachLoad_Apply()\r
 {\r
        // apply stomach weight that makes you heavier and larger the more you eat\r
@@ -156,15 +170,14 @@ void Vore_StomachLoad_Apply()
                return;\r
 \r
        entity e;\r
-       float prey_mass;\r
+       float prey_mass, final_load;\r
 \r
        // apply the stomach capacity of the predator\r
        self.stomach_maxload = cvar("g_balance_vore_load_pred_capacity");\r
        if(cvar("g_healthsize"))\r
                self.stomach_maxload *= self.scale;\r
-       self.stomach_maxload = floor(self.stomach_maxload);\r
+       self.stomach_maxload = ceil(self.stomach_maxload);\r
 \r
-       self.stomach_load = 0; // start from zero\r
        FOR_EACH_PLAYER(e)\r
        {\r
                if(e.predator == self)\r
@@ -172,14 +185,21 @@ void Vore_StomachLoad_Apply()
                        prey_mass = cvar("g_balance_vore_load_prey_mass");\r
                        if(cvar("g_healthsize"))\r
                                prey_mass *= e.scale;\r
-                       self.stomach_load += floor(prey_mass);\r
+                       final_load += ceil(prey_mass);\r
+                       if(self.cvar_cl_vore_autodigest > 1)\r
+                               Vore_AutoDigest(self);\r
                }\r
        }\r
        for(e = world; (e = find(e, classname, "consumable")); )\r
        {\r
                if(e.predator == self)\r
-                       self.stomach_load += floor(e.dmg);\r
+               {\r
+                       final_load += ceil(e.dmg);\r
+                       if(self.cvar_cl_vore_autodigest > 0)\r
+                               Vore_AutoDigest(self);\r
+               }\r
        }\r
+       self.stomach_load = final_load;\r
 \r
        // apply weight\r
        self.gravity = 1 + (self.stomach_load / self.stomach_maxload) * cvar("g_balance_vore_load_pred_weight");\r
@@ -187,22 +207,6 @@ void Vore_StomachLoad_Apply()
                self.gravity = 0.00001; // 0 becomes 1 for gravity, so do this to allow 0 gravity\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(!cvar("g_vore_digestion") || e.digesting)\r
-               return;\r
-       if(!e.cvar_cl_vore_autodigest || clienttype(e) != CLIENTTYPE_REAL)\r
-               return; // this feature is only for players, not bots\r
-       if(e.stomach_load)\r
-               return; // don't start digestion if we already ate someone, as that means we manually disabled it after the first prey and want it off\r
-       if(Stomach_TeamMates_check(e))\r
-               return; // never begin automatic digestion if we've swallowed a team mate\r
-\r
-       e.digesting = TRUE;\r
-}\r
-\r
 .entity swallow_model;\r
 float Vore_SwallowModel_CustomizeEntityForClient()\r
 {\r
@@ -314,7 +318,6 @@ void Vore_Swallow(entity e)
        e.predator.regurgitate_prepare = 0;\r
        e.predator.spawnshieldtime = 0; // lose spawn shield when we vore\r
        e.predator.hitsound += 1; // play this for team mates too, as we could be swallowing them to heal them\r
-       Vore_AutoDigest(e.predator);\r
        Vore_SetPreyPositions(e.predator);\r
 \r
        // block firing for a small amount of time, or we'll be firing the next frame after we swallow\r
@@ -332,6 +335,10 @@ void Vore_SwallowStep(entity e)
                return;\r
        }\r
 \r
+       // when the predator starts swallowing, play his grab sound\r
+       if(!self.swallow_progress_pred)\r
+               PlayerSound(self, playersound_grab, CHAN_PAIN, VOICETYPE_PLAYERSOUND);\r
+\r
        Vore_SwallowModel_Update(e, self);\r
 \r
        // increase the progress value until it reaches 1, then swallow the player\r
@@ -342,7 +349,7 @@ void Vore_SwallowStep(entity e)
                if(cvar("g_healthsize") && cvar("g_balance_vore_swallow_speed_fill_scalediff")) // fill rate depends on predator size compared to prey size\r
                        fill *= pow(self.scale / e.scale, cvar("g_balance_vore_swallow_speed_fill_scalediff"));\r
                if(cvar("g_balance_vore_swallow_speed_fill_stomachload") && e.stomach_load) // fill rate is influenced by the prey's stomach load\r
-                       fill /= e.stomach_load;\r
+                       fill *= (1 - ((e.stomach_load / e.stomach_maxload) * bound(0, cvar("g_balance_vore_swallow_speed_fill_stomachload"), 1)));\r
 \r
                e.swallow_progress_prey += fill;\r
        }\r
@@ -375,17 +382,9 @@ void Vore_Regurgitate(entity e)
        }\r
 \r
        // apply velocities\r
-       local vector oldforward, oldright, oldup;\r
-       oldforward = v_forward;\r
-       oldright = v_right;\r
-       oldup = v_up;\r
        makevectors(e.predator.v_angle);\r
        e.velocity = v_forward * cvar("g_balance_vore_regurgitate_force");\r
        e.predator.velocity += -v_forward * cvar("g_balance_vore_regurgitate_predatorforce");\r
-       v_forward = oldforward;\r
-       v_right = oldright;\r
-       v_up = oldup;\r
-\r
        e.pusher = e.predator; // allows us to frag players by regurgitating them in deadly pits\r
        e.pushltime = time + cvar("g_maxpushtime");\r
 \r
@@ -439,9 +438,9 @@ void Vore_Disconnect()
                if(head.predator == self)\r
                        Vore_Regurgitate(head);\r
        }\r
-       Vore_GurgleSound(); // stop the gurgling sound\r
 \r
        self.stomach_load = self.gravity = 0; // prevents a bug\r
+       Vore_GurgleSound(); // stop the gurgling sound\r
 }\r
 \r
 .float digestion_step;\r
@@ -464,25 +463,23 @@ void Vore_Digest()
 \r
                damage_offset = 1;\r
                if(cvar("g_balance_vore_digestion_distribute")) // apply distributed digestion damage\r
-                       damage_offset *= self.predator.stomach_load / self.predator.stomach_maxload;\r
+                       damage_offset /= (1 - (self.predator.stomach_load / self.predator.stomach_maxload) * bound(0, cvar("g_balance_vore_digestion_distribute"), 1));\r
                if(cvar("g_healthsize") && cvar("g_balance_vore_digestion_scalediff")) // apply player scale to digestion damage\r
                        damage_offset *= pow(self.scale / self.predator.scale, cvar("g_balance_vore_digestion_scalediff"));\r
-               damage_offset = ceil(damage_offset);\r
 \r
-               damage = cvar("g_balance_vore_digestion_damage") / damage_offset;\r
-               if(cvar("g_balance_vore_digestion_damage_death") && self.deadflag != DEAD_NO) // amplify digestion damage for dead prey\r
-                       damage *= cvar("g_balance_vore_digestion_damage_death");\r
+               if(self.deadflag != DEAD_NO)\r
+                       damage = cvar("g_balance_vore_digestion_damage_death") / damage_offset;\r
+               else\r
+                       damage = cvar("g_balance_vore_digestion_damage") / damage_offset;\r
 \r
                Damage(self, self.predator, self.predator, damage, 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 += damage * cvar("g_balance_vore_digestion_vampire");\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
+                       self.predator.health += damage * cvar("g_balance_vore_digestion_vampire");\r
+                       self.predator.pauserothealth_finished = max(self.predator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));\r
                }\r
-               self.digestion_step = time + steptime;\r
+\r
+               self.digestion_step = time + vore_steptime;\r
        }\r
 \r
        if(stov(cvar_string("g_vore_regurgitatecolor_color_digest")))\r
@@ -501,7 +498,7 @@ void Vore_Teamheal()
        if(time > self.teamheal_step)\r
        {\r
                self.health += cvar("g_balance_vore_teamheal");\r
-               self.teamheal_step = time + steptime;\r
+               self.teamheal_step = time + vore_steptime;\r
 \r
                // play beep sound when a team mate was healed to the maximum amount, to both the prey and the predator\r
                if(self.health >= cvar("g_balance_vore_teamheal_stable"))\r
@@ -709,26 +706,8 @@ void Vore()
        // 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.stat_eaten)\r
-       {\r
-               entity target_predator, target_predator_predator, oldself;\r
-               target_predator = self.predator;\r
-               target_predator_predator = self.predator.predator;\r
-\r
                Vore_Regurgitate(self);\r
 \r
-               // now steal our prey's prey if this probability applies\r
-               if(random() < cvar("g_balance_vore_swallow_stealprey"))\r
-               {\r
-                       oldself = self;\r
-                       self = target_predator_predator;\r
-                       if(Swallow_condition_check(oldself))\r
-                       if not(teams_matter && self.team == target_predator.team) // don't steal a team mate's prey\r
-                       if not(teams_matter && self.team == oldself.team) // if the prey we would be stealing is a team mate, don't do it\r
-                               Vore_Swallow(oldself);\r
-                       self = oldself;\r
-               }\r
-       }\r
-\r
        // the swallow progress of prey and preds idly decrease by this amount\r
        if(cvar("g_balance_vore_swallow_speed_decrease"))\r
        {\r
@@ -811,6 +790,7 @@ void Vore()
 \r
        // predator wishes to regurgitate his prey\r
        if(self.BUTTON_REGURGITATE && time > self.action_delay)\r
+       if(!self.regurgitate_prepare)\r
        {\r
                if(self.stomach_load)\r
                {\r
@@ -830,6 +810,23 @@ void Vore()
                }\r
        }\r
 \r
+       if(self.stomach_load > self.stomach_maxload) // the predator got beyond his capacity after eating, so some prey must pop out\r
+       {\r
+               self.regurgitate_prepare = -1;\r
+               return;\r
+       }\r
+       if(cvar("g_balance_vore_load_pred_speedcap") && self.stomach_load)\r
+       if(vlen(self.velocity) >= cvar("g_balance_vore_load_pred_speedcap") / (self.stomach_load / self.stomach_maxload)) // predator's going too fast, gets sick and throws up\r
+       {\r
+               self.regurgitate_prepare = -1;\r
+               return;\r
+       }\r
+\r
+       if (self.digesting && self.digestsound_finished < time)\r
+       {\r
+               PlayerSound (self, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
+               self.digestsound_finished = time + 0.5;\r
+       }\r
        if(cvar("g_vore_gurglesound"))\r
                Vore_GurgleSound();\r
 \r
@@ -863,23 +860,11 @@ void Vore()
                        self.predator.regurgitate_prepare = 0;\r
        }\r
 \r
-       if(self.predator.stomach_load > self.predator.stomach_maxload) // the predator got beyond his capacity after eating, so some prey must pop out\r
-       {\r
-               Vore_Regurgitate(self);\r
-               return;\r
-       }\r
-       if(cvar("g_balance_vore_load_pred_speedcap") && vlen(self.predator.velocity) >= cvar("g_balance_vore_load_pred_speedcap") / (self.predator.stomach_load / self.predator.stomach_maxload)) // predator's going too fast, gets sick and throws up\r
-       {\r
-               Vore_Regurgitate(self);\r
-               return;\r
-       }\r
-\r
        // apply delayed regurgitating if it was scheduled\r
        if(self.predator.regurgitate_prepare && time > self.predator.regurgitate_prepare)\r
        {\r
-               self.predator.regurgitate_prepare = 0;\r
-               self.predator.complain_vore = time + complain_delay_time; // prevent complaining the next frame if this empties our stomach\r
                Vore_Regurgitate(self);\r
+               self.predator.complain_vore = time + complain_delay_time; // prevent complaining the next frame if this empties our stomach\r
        }\r
 \r
        // execute digesting and team healing\r