From: MirceaKitsune Date: Sat, 19 Nov 2011 11:24:51 +0000 (+0200) Subject: Make consumable health work. Currently, picking up health spawns a model which will... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=97a89d8ded9daa0afd6dc01945dbd0a3bc43b2db;p=voretournament%2Fvoretournament.git Make consumable health work. Currently, picking up health spawns a model which will follow the player, and no longer gives an instant health increase --- diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index bb039840..cf8d5604 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -219,6 +219,20 @@ void Item_ScheduleInitialRespawn(entity e) Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e)); } +void Item_Consumable_Spawn(entity e, entity pl) +{ + entity item; + item = spawn(); + item.owner = e; + item.classname = "consumable"; + setmodel(item, e.model); + item.movetype = MOVETYPE_FOLLOW; + item.solid = SOLID_NOT; + + item.predator = pl; + item.aiment = pl; +} + float Item_GiveTo(entity item, entity player) { float _switchweapon; @@ -304,8 +318,13 @@ float Item_GiveTo(entity item, entity player) if (player.health < item.max_health) { pickedup = TRUE; - player.health = min(player.health + item.health, item.max_health); - player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot")); + if(item.dmg) // consumable item + Item_Consumable_Spawn(self, player); + else + { + player.health = min(player.health + item.health, item.max_health); + player.pauserothealth_finished = max(player.pauserothealth_finished, time + cvar("g_balance_pause_health_rot")); + } } if (item.armorvalue) if (player.armorvalue < item.max_armorvalue) @@ -867,7 +886,7 @@ void spawnfunc_item_health_small (void) { self.max_health = g_pickup_healthsmall_max; if(!self.health) self.health = g_pickup_healthsmall; - self.cnt = g_pickup_healthsmall_consumable; + self.dmg = g_pickup_healthsmall_consumable; StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW); } @@ -876,7 +895,7 @@ void spawnfunc_item_health_medium (void) { self.max_health = g_pickup_healthmedium_max; if(!self.health) self.health = g_pickup_healthmedium; - self.cnt = g_pickup_healthmedium_consumable; + self.dmg = g_pickup_healthmedium_consumable; StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID); } @@ -885,7 +904,7 @@ void spawnfunc_item_health_large (void) { self.max_health = g_pickup_healthlarge_max; if(!self.health) self.health = g_pickup_healthlarge; - self.cnt = g_pickup_healthlarge_consumable; + self.dmg = g_pickup_healthlarge_consumable; StartItem ("models/items/g_h50.md3", "misc/largehealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID); } @@ -900,7 +919,7 @@ void spawnfunc_item_health_mega (void) { self.max_health = g_pickup_healthmega_max; if(!self.health) self.health = g_pickup_healthmega; - self.cnt = g_pickup_healthmega_consumable; + self.dmg = g_pickup_healthmega_consumable; StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH); }