pl.punchangle_z = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item") * scalediff;\r
pl.regurgitate_prepare = 0;\r
pl.action_delay = time + cvar("g_balance_vore_action_delay");\r
+ pl.last_pickup = time;\r
}\r
\r
+float Item_Swallow(entity item, entity player);\r
void Item_DroppedConsumable_Touch()\r
{\r
if(time < self.cnt)\r
return;\r
\r
// give the consumable item to the player touching it\r
- if not(other.stomach_load + self.dmg > other.stomach_maxload || other.stomach_load + self.initdmg > other.stomach_maxload)\r
- if not(!cvar("g_balance_health_consumable_alwayspickup") && other.health >= self.max_health)\r
+ if(Item_Swallow(self, other))\r
{\r
- Item_Consumable_Spawn(self, other);\r
remove(self);\r
self = world;\r
}\r
setmodel(item, e.model);\r
item.health = e.health;\r
item.inithealth = e.inithealth;\r
+ item.dmg = e.dmg;\r
item.initdmg = e.initdmg;\r
item.max_health = e.max_health;\r
item.scale = e.scale;\r
SUB_SetFade(item, time + 20, 1);\r
}\r
\r
+float Item_Swallow(entity item, entity player)\r
+{\r
+ float pickedup, usage;\r
+ if(item.dmg && cvar("g_vore"))\r
+ {\r
+ if(player.stomach_load + item.dmg <= player.stomach_maxload)\r
+ if not(!cvar("g_balance_health_consumable_alwayspickup") && player.health >= item.max_health)\r
+ usage = 2; // consumable item, only if the vore system is enabled\r
+ }\r
+ else if (player.health < item.max_health)\r
+ usage = 1; // normal item\r
+ if(!usage)\r
+ return FALSE;\r
+\r
+ // since map items don't have a scale, calculate one based on player size center and the item's health, in order to determine swallowing speed\r
+ float scalediff;\r
+ scalediff = pow((item.health / cvar("g_healthsize_center")) / player.scale, cvar("g_balance_vore_swallow_speed_fill_scalediff_item"));\r
+\r
+ item.swallow_progress_prey += cvar("g_balance_vore_swallow_speed_fill_item") / scalediff;\r
+ player.swallow_progress_pred = item.swallow_progress_prey;\r
+ if(item.swallow_progress_prey < 1 && cvar("g_balance_vore_swallow_speed_fill_item"))\r
+ return FALSE; // swallow progress not full yet, or slow swallowing of items is disabled\r
+\r
+ if(usage > 1)\r
+ {\r
+ pickedup = TRUE;\r
+ item.swallow_progress_prey = player.swallow_progress_pred = 0;\r
+ Item_Consumable_Spawn(item, player);\r
+ }\r
+ else\r
+ {\r
+ pickedup = TRUE;\r
+ item.swallow_progress_prey = player.swallow_progress_pred = 0;\r
+ player.health = min(player.health + item.health, item.max_health);\r
+ player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));\r
+ }\r
+\r
+ return pickedup;\r
+}\r
+\r
float Item_GiveTo(entity item, entity player)\r
{\r
float _switchweapon;\r
}\r
\r
if (item.health)\r
- {\r
- if(item.dmg && cvar("g_vore")) // consumable item, only if the vore system is enabled\r
- {\r
- if(player.stomach_load + item.dmg <= player.stomach_maxload)\r
- if not(!cvar("g_balance_health_consumable_alwayspickup") && player.health >= item.max_health)\r
- {\r
- pickedup = TRUE;\r
- Item_Consumable_Spawn(self, player);\r
- }\r
- }\r
- else if (player.health < item.max_health)\r
- {\r
- pickedup = TRUE;\r
- player.health = min(player.health + item.health, item.max_health);\r
- player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));\r
- }\r
- }\r
+ pickedup = Item_Swallow(item, player);\r
if (item.armorvalue)\r
if (player.armorvalue < item.max_armorvalue)\r
{\r
return 1;\r
}\r
\r
+void Item_Think()\r
+{\r
+ self.nextthink = time;\r
+\r
+ if(!self.swallow_progress_prey)\r
+ return;\r
+\r
+ self.swallow_progress_prey = max(0, self.swallow_progress_prey - 0.01);\r
+ self.alpha = 1 - self.swallow_progress_prey;\r
+}\r
+\r
void Item_Touch (void)\r
{\r
entity e, head;\r
return item.bot_pickupbasevalue * c;\r
};\r
\r
-\r
.float is_item;\r
void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)\r
{\r
self.weapons = weaponid;\r
self.flags = FL_ITEM | itemflags;\r
self.touch = Item_Touch;\r
+ self.think = Item_Think;\r
+ self.nextthink = time;\r
setmodel (self, self.mdl); // precision set below\r
self.effects |= EF_LOWPRECISION;\r
if((itemflags & FL_POWERUP) || self.health || self.armorvalue)\r
}\r
\r
void spawnfunc_item_health_mega (void) {\r
- if(!cvar("g_powerup_superhealth"))\r
- return;\r
-\r
- if((g_arena || g_ca) && !cvar("g_arena_powerups"))\r
- return;\r
-\r
if(!self.max_health)\r
self.max_health = g_pickup_healthmega_max;\r
if(!self.health)\r