]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/t_items.qc
Fix consumable health giving one health unit more than it should
[voretournament/voretournament.git] / data / qcsrc / server / t_items.qc
index 6aca1abf3ae16da007a657f1b5f1de0883ec840d..69ff60da05c4514ff6ff66c2b69fbd6e15223a38 100644 (file)
@@ -256,7 +256,7 @@ 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_offset /= (1 - (self.predator.stomach_load / self.predator.stomach_maxload) * bound(0, cvar("g_balance_vore_digestion_distribute"), 1));\r
                        damage = ceil(cvar("g_balance_vore_digestion_damage_item") / damage_offset);\r
 \r
                        self.health -= damage;\r
@@ -297,7 +297,9 @@ void Item_Consumable_Remove(entity e, float regurgitate)
                PlayerSound(e.predator, playersound_regurgitate, CHAN_VOICE, VOICETYPE_PLAYERSOUND);\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_predator_punchangle_item");\r
+               e.predator.punchangle_x = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item");\r
+               e.predator.punchangle_y = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item");\r
+               e.predator.punchangle_z = crandom() * cvar("g_balance_vore_regurgitate_predator_punchangle_item");\r
                e.predator.regurgitate_prepare = 0;\r
                e.predator.action_delay = time + cvar("g_balance_vore_action_delay");\r
 \r
@@ -335,7 +337,8 @@ void Item_Consumable_Spawn(entity e, entity pl)
        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
@@ -347,10 +350,11 @@ void Item_Consumable_Spawn(entity e, entity pl)
        // predator effects, some common to those in Vore_Swallow\r
        PlayerSound(pl, playersound_swallow, CHAN_VOICE, VOICETYPE_PLAYERSOUND);\r
        setanim(pl, pl.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating\r
-       pl.punchangle_x -= cvar("g_balance_vore_swallow_predator_punchangle_item");\r
+       pl.punchangle_x = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item");\r
+       pl.punchangle_y = crandom() * cvar("g_balance_vore_swallow_predator_punchangle_item");\r
+       pl.punchangle_z = crandom() * 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
@@ -359,7 +363,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
@@ -480,6 +485,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