]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/t_items.qc
Don't pickup health items when they no longer offer a health boost. This was removed...
[voretournament/voretournament.git] / data / qcsrc / server / t_items.qc
index 092b287d4db21a26b2dc97c474d535f470cef06f..299632a85e68797819e46b1d93031c2cbcb33880 100644 (file)
@@ -240,7 +240,7 @@ void Item_Consumable_Think()
 \r
        self.scale = self.health / self.inithealth; // scale matches the item's digestion progress\r
        self.dmg = self.initdmg * self.scale;\r
-       if(self.health < 1)\r
+       if(self.health <= 0)\r
        {\r
                // this item is done\r
                Item_Consumable_Remove(self, FALSE);\r
@@ -256,11 +256,15 @@ void Item_Consumable_Think()
 \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 = ceil(cvar("g_balance_vore_digestion_damage_item") / damage_offset);\r
+                               damage_offset /= (1 - (self.predator.stomach_load / self.predator.stomach_maxload) * bound(0, cvar("g_balance_vore_digestion_distribute"), 1));\r
+                       damage = cvar("g_balance_vore_digestion_damage_item") / damage_offset;\r
 \r
                        self.health -= damage;\r
-                       self.predator.health += damage;\r
+                       if(self.predator.health + damage <= self.max_health)\r
+                               self.predator.health += damage;\r
+                       else if(self.predator.health < self.max_health)\r
+                               self.predator.health = self.max_health;\r
+                       self.predator.pauserothealth_finished = max(self.predator.pauserothealth_finished, time + cvar("g_balance_pause_health_rot"));\r
 \r
                        self.item_digestion_step = time + vore_steptime;\r
                }\r
@@ -315,15 +319,24 @@ void Item_Consumable_Spawn(entity e, entity pl)
        item.solid = SOLID_NOT;\r
        setmodel(item, e.model);\r
        item.health = e.health;\r
-       item.inithealth = e.health;\r
+       if(e.inithealth)\r
+       {\r
+               item.inithealth = e.inithealth;\r
+               item.initdmg = e.initdmg;\r
+       }\r
+       else\r
+       {\r
+               item.inithealth = e.health;\r
+               item.initdmg = e.dmg;\r
+       }\r
        item.max_health = e.max_health;\r
-       item.initdmg = e.dmg;\r
 \r
        item.predator = pl;\r
        item.aiment = pl;\r
        item.view_ofs_x = CONSUMABLE_VIEW_OFS_x + crandom() * cvar("g_vore_neighborprey_distance_item");\r
        item.view_ofs_y = CONSUMABLE_VIEW_OFS_y + crandom() * cvar("g_vore_neighborprey_distance_item");\r
-       item.view_ofs_z = CONSUMABLE_VIEW_OFS_z;\r
+       item.view_ofs_z = CONSUMABLE_VIEW_OFS_z + crandom() * cvar("g_vore_neighborprey_distance_item");\r
+       item.angles = randomvec() * 360;\r
 \r
        item.customizeentityforclient = Item_Consumable_Customizeentityforclient;\r
        item.think = Item_Consumable_Think;\r
@@ -338,7 +351,6 @@ void Item_Consumable_Spawn(entity e, entity pl)
        pl.punchangle_x -= cvar("g_balance_vore_swallow_predator_punchangle_item");\r
        pl.regurgitate_prepare = 0;\r
        pl.action_delay = time + cvar("g_balance_vore_action_delay");\r
-       Vore_AutoDigest(pl);\r
 }\r
 \r
 void Item_DroppedConsumable_Touch()\r
@@ -347,7 +359,8 @@ void Item_DroppedConsumable_Touch()
                return;\r
 \r
        // give the consumable item to the player touching it\r
-       if(other.stomach_load + self.dmg <= other.stomach_maxload)\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
        {\r
                Item_Consumable_Spawn(self, other);\r
                remove(self);\r
@@ -366,8 +379,8 @@ void Item_DroppedConsumable_Spawn(entity e)
        setmodel(item, e.model);\r
        item.health = e.health;\r
        item.inithealth = e.inithealth;\r
-       item.max_health = e.max_health;\r
        item.initdmg = e.initdmg;\r
+       item.max_health = e.max_health;\r
        item.scale = e.scale;\r
        item.colormod = e.colormod;\r
 \r
@@ -468,6 +481,7 @@ float Item_GiveTo(entity item, entity player)
                        if(item.dmg) // consumable item\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