.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, vore_oldstomachload;\r
+.float vore_oldmovetype, vore_oldsolid;\r
\r
const float system_delay_time = 0.1;\r
const float complain_delay_time = 1;\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_load_pred_speedcap") / (self.stomach_maxload / self.stomach_load))\r
{\r
+ float prey_mass;\r
+ prey_mass = cvar("g_balance_vore_load_prey_mass");\r
+ if(cvar("g_healthsize"))\r
+ prey_mass *= prey.scale;\r
+\r
string swallow_complain;\r
if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore"))\r
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 >= self.stomach_maxload)\r
- swallow_complain = "You do not have any more room to swallow this player.\n";\r
+ else if(self.stomach_load + prey_mass > self.stomach_maxload)\r
+ swallow_complain = "You don't have any more room to swallow this player.\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
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
}\r
\r
// position the camera properly for prey\r
-void Vore_SetPreyPositions()\r
+void Vore_SetPreyPositions(entity pred)\r
{\r
- // self is the predator and head is the prey\r
+ // pred is the predator and head is the prey\r
\r
local entity head;\r
local vector origin_apply;\r
- local float position_counter;\r
\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
+ // else all players overlap in the center. To do this, we use a random origin on all players in the same stomach.\r
FOR_EACH_PLAYER(head)\r
{\r
- if(head.predator == self)\r
+ if(head.predator == pred)\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
+ origin_apply_x = PL_PREY_VIEW_OFS_x + crandom() * cvar("g_vore_neighborprey_distance");\r
+ origin_apply_y = PL_PREY_VIEW_OFS_y + crandom() * cvar("g_vore_neighborprey_distance");\r
+ origin_apply_z = PL_PREY_VIEW_OFS_z;\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
+ head.view_ofs = origin_apply;\r
+ head.view_ofs_z *= pred.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
+ prey_height = (head.scale - pred.scale) * cvar("g_healthsize_vore_pos");\r
head.view_ofs_z += prey_height;\r
-\r
- position_counter += 1;\r
}\r
}\r
}\r
}\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 prey_mass;\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
+ self.stomach_load = 0; // start from zero\r
+ FOR_EACH_PLAYER(e)\r
+ {\r
+ if(e.predator == self && e.classname == "player")\r
+ {\r
+ 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
+ }\r
+ }\r
+\r
+ // apply weight\r
+ self.gravity = 1 + (self.stomach_load / self.stomach_maxload) * cvar("g_balance_vore_load_pred_weight");\r
+ if(!self.gravity && self.stomach_load)\r
+ 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
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
+ 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
e.predator.weapon_delay = time + button_delay_time;\r
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
+ Vore_SetPreyPositions(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
// this entity is like e.predator but for dead prey, to avoid conflicts\r
e.fakepredator = e.predator;\r
e.fakeprey = TRUE;\r
+ Vore_SetPreyPositions(e.predator);\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
- 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
{\r
// if distributed digestion is enabled, reduce digestion strength by the amount of prey in our stomach\r
float vore_offset;\r
- if(cvar("g_balance_vore_digestion_distribute"))\r
- vore_offset = self.predator.stomach_maxload / self.predator.stomach_load;\r
- else\r
- vore_offset = 1;\r
+ vore_offset = 1;\r
+ if(cvar("g_balance_vore_digestion_distribute")) // apply distributed digestion damage\r
+ vore_offset *= self.predator.stomach_load / self.predator.stomach_maxload;\r
+ if(cvar("g_healthsize") && cvar("g_balance_vore_digestion_scalediff")) // apply player scale to digestion damage\r
+ vore_offset *= pow(self.scale / self.predator.scale, cvar("g_balance_vore_digestion_scalediff"));\r
+ vore_offset = ceil(vore_offset);\r
\r
float damage;\r
damage = cvar("g_balance_vore_digestion_damage") / vore_offset;\r
\r
- // apply player scale to digestion damage\r
- if(cvar("g_healthsize") && cvar("g_balance_vore_digestion_scalediff"))\r
- damage *= pow(self.predator.scale / self.scale, cvar("g_balance_vore_digestion_scalediff"));\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 += cvar("g_balance_vore_digestion_vampire") / vore_offset;\r
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
// Code that addresses the prey:\r
// --------------------------------\r
\r
- Vore_SetPreyPositions();\r
-\r
// keepdeadprey - detach dead prey if their predator died or got swallowed\r
if(self.fakeprey)\r
if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.stat_eaten)\r
\r
if(self.predator.deadflag != DEAD_NO)\r
Vore_Regurgitate(self);\r
- else if(vlen(self.predator.velocity) > cvar("g_balance_vore_load_pred_speedcap") / (self.stomach_maxload / self.stomach_load))\r
+ else 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))\r
Vore_Regurgitate(self);\r
\r
// apply delayed regurgitating if it was scheduled\r