]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/t_items.qc
First attempt to make health possible to swallow slowly. Incomplete and still buggy...
[voretournament/voretournament.git] / data / qcsrc / server / t_items.qc
index 9faf08821fb325c3b9a5da7e5eb278fbab0e104f..8053a4dbb879a0ae3967332d1975b08bcc5966b0 100644 (file)
@@ -414,6 +414,37 @@ void Item_DroppedConsumable_Spawn(entity e)
        SUB_SetFade(item, time + 20, 1);\r
 }\r
 \r
+float Item_Swallow(entity item, entity player)\r
+{\r
+       float pickedup;\r
+       pickedup = FALSE;\r
+\r
+       item.swallow_progress_prey = min(item.swallow_progress_prey + 0.02, 1);\r
+       if(item.swallow_progress_prey < 1)\r
+               return FALSE; // item not eaten yet\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.swallow_progress_prey = 0;\r
+                       Item_Consumable_Spawn(item, player);\r
+               }\r
+       }\r
+       else if (player.health < item.max_health)\r
+       {\r
+               pickedup = TRUE;\r
+               item.swallow_progress_prey = 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
+       player.swallow_progress_pred = item.swallow_progress_prey;\r
+       return pickedup;\r
+}\r
+\r
 float Item_GiveTo(entity item, entity player)\r
 {\r
        float _switchweapon;\r
@@ -496,23 +527,7 @@ float Item_GiveTo(entity item, entity player)
                }\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
@@ -538,6 +553,17 @@ float Item_GiveTo(entity item, entity player)
        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
@@ -722,7 +748,6 @@ float commodity_pickupevalfunc(entity player, entity item)
        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
@@ -875,6 +900,8 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        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