]> git.xonotic.org Git - voretournament/voretournament.git/commitdiff
New system for applying stomach load and weight
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 18 Jul 2011 11:28:42 +0000 (14:28 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 18 Jul 2011 11:28:42 +0000 (14:28 +0300)
data/qcsrc/server/vore.qc

index 9b8c85dd93ccf5aa9e85db42d2022b7e736f4d24..548e19b6089145724974ae0f1f4479b87226889b 100644 (file)
@@ -69,16 +69,6 @@ float Swallow_condition_check(entity prey)
        return FALSE;\r
 }\r
 \r
-float Prey_Mass(entity prey)\r
-{\r
-       float vore_mass;\r
-       vore_mass = cvar("g_balance_vore_load_prey_mass");\r
-       if(cvar("g_healthsize"))\r
-               vore_mass *= prey.scale;\r
-       vore_mass = ceil(vore_mass);\r
-       return vore_mass;\r
-}\r
-\r
 float Stomach_TeamMates_check(entity pred)\r
 {\r
        // checks if a player's stomach contains any team mates\r
@@ -185,16 +175,37 @@ void Vore_GurgleSound()
        }\r
 }\r
 \r
-void Vore_WeightApply(entity e)\r
+void Vore_StomachLoad_Apply()\r
 {\r
-       // apply stomach weight that makes you heavier the more you eat\r
+       // apply stomach weight that makes you heavier and larger the more you eat\r
        // slowing the player is done in cl_physics.qc\r
 \r
-       if(e.stomach_load != e.vore_oldstomachload)\r
-               e.gravity += 1 + (e.stomach_load / e.stomach_maxload * cvar("g_balance_vore_load_pred_weight") - e.vore_oldstomachload);\r
-       if(e.gravity == 0)\r
-               e.gravity = 0.00001; // 0 becomes 1 for gravity, so do this to allow 0 gravity\r
-       e.vore_oldstomachload = e.stomach_load;\r
+       entity e;\r
+       float vore_mass;\r
+\r
+       self.stomach_load = 0; // start from zero\r
+       FOR_EACH_PLAYER(e)\r
+       {\r
+               if(e.predator == self && e.classname == "player")\r
+               {\r
+                       vore_mass = cvar("g_balance_vore_load_prey_mass");\r
+                       if(cvar("g_healthsize"))\r
+                               vore_mass *= self.scale;\r
+                       self.stomach_load += floor(vore_mass);\r
+               }\r
+       }\r
+\r
+       if(self.stomach_load != self.vore_oldstomachload)\r
+               self.gravity += 1 + (self.stomach_load / self.stomach_maxload * cvar("g_balance_vore_load_pred_weight") - self.vore_oldstomachload);\r
+       if(self.gravity == 0)\r
+               self.gravity = 0.00001; // 0 becomes 1 for gravity, so do this to allow 0 gravity\r
+       self.vore_oldstomachload = self.stomach_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
 }\r
 \r
 void Vore_AutoDigest(entity e)\r
@@ -320,11 +331,9 @@ void Vore_Swallow(entity e)
        PlayerSound(e.predator, playersound_swallow, CHAN_VOICE, VOICETYPE_PLAYERSOUND);\r
        setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating\r
        e.predator.punchangle_x -= cvar("g_balance_vore_swallow_punchangle");\r
-       e.predator.stomach_load += Prey_Mass(e);\r
        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_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
@@ -411,10 +420,8 @@ void Vore_Regurgitate(entity e)
        setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating\r
        pointparticles(particleeffectnum("vore_regurgitate"), e.predator.origin, '0 0 0', 1);\r
        e.predator.punchangle_x += cvar("g_balance_vore_regurgitate_punchangle");\r
-       e.predator.stomach_load -= Prey_Mass(e);\r
        e.predator.regurgitate_prepare = 0;\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
        e.weapon_delay = time + button_delay_time;\r
@@ -435,8 +442,6 @@ void Vore_DeadPrey_Configure(entity e)
 \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 -= Prey_Mass(e);\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
@@ -794,11 +799,8 @@ void Vore()
        entity prey;\r
        prey = Swallow_player_check();\r
 \r
-       // set the predator's stomach capacity\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
+       // set the predator's stomach load and capacity\r
+       Vore_StomachLoad_Apply();\r
 \r
        // attempt to swallow our new prey if we pressed the attack button, and there's any in range\r
        self.stat_canswallow = 0;\r