]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/t_items.qc
Make consumable health work. Currently, picking up health spawns a model which will...
[voretournament/voretournament.git] / data / qcsrc / server / t_items.qc
index 3505039f3fe1b525b2d1854712a5d0b48a2c7d6c..cf8d560483159101b8ba143d5d2be6bcc258bb74 100644 (file)
@@ -144,7 +144,6 @@ void Item_Respawn (void)
                sound (self, CHAN_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM);        // play respawn sound\r
        setorigin (self, self.origin);\r
 \r
-       //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);\r
        pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);\r
 }\r
 \r
@@ -220,6 +219,20 @@ void Item_ScheduleInitialRespawn(entity e)
        Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));\r
 }\r
 \r
+void Item_Consumable_Spawn(entity e, entity pl)\r
+{\r
+       entity item;\r
+       item = spawn();\r
+       item.owner = e;\r
+       item.classname = "consumable";\r
+       setmodel(item, e.model);\r
+       item.movetype = MOVETYPE_FOLLOW;\r
+       item.solid = SOLID_NOT;\r
+\r
+       item.predator = pl;\r
+       item.aiment = pl;\r
+}\r
+\r
 float Item_GiveTo(entity item, entity player)\r
 {\r
        float _switchweapon;\r
@@ -305,8 +318,13 @@ float Item_GiveTo(entity item, entity player)
                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
+                       if(item.dmg) // consumable item\r
+                               Item_Consumable_Spawn(self, player);\r
+                       else\r
+                       {\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
                if (item.armorvalue)\r
                if (player.armorvalue < item.max_armorvalue)\r
@@ -868,6 +886,7 @@ void spawnfunc_item_health_small (void) {
                self.max_health = g_pickup_healthsmall_max;\r
        if(!self.health)\r
                self.health = g_pickup_healthsmall;\r
+       self.dmg = g_pickup_healthsmall_consumable;\r
        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);\r
 }\r
 \r
@@ -876,6 +895,7 @@ void spawnfunc_item_health_medium (void) {
                self.max_health = g_pickup_healthmedium_max;\r
        if(!self.health)\r
                self.health = g_pickup_healthmedium;\r
+       self.dmg = g_pickup_healthmedium_consumable;\r
        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);\r
 }\r
 \r
@@ -884,6 +904,7 @@ void spawnfunc_item_health_large (void) {
                self.max_health = g_pickup_healthlarge_max;\r
        if(!self.health)\r
                self.health = g_pickup_healthlarge;\r
+       self.dmg = g_pickup_healthlarge_consumable;\r
        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);\r
 }\r
 \r
@@ -898,6 +919,7 @@ void spawnfunc_item_health_mega (void) {
                self.max_health = g_pickup_healthmega_max;\r
        if(!self.health)\r
                self.health = g_pickup_healthmega;\r
+       self.dmg = g_pickup_healthmega_consumable;\r
        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);\r
 }\r
 \r
@@ -1330,9 +1352,9 @@ float GiveItems(entity e, float beginarg, float endarg)
        }\r
        POSTGIVE_VALUE(e, strength_finished, 1, "misc/powerup.wav", "misc/poweroff.wav");\r
        POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", "misc/poweroff.wav");\r
-       POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, cvar("g_balance_pause_fuel_rot"), pauseregen_finished, cvar("g_balance_pause_fuel_regen"), "misc/itempickup.wav", string_null);\r
-       POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, cvar("g_balance_pause_armor_rot"), pauseregen_finished, cvar("g_balance_pause_health_regen"), "misc/armor25.wav", string_null);\r
-       POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, cvar("g_balance_pause_health_rot"), pauseregen_finished, cvar("g_balance_pause_health_regen"), "misc/megahealth.wav", string_null);\r
+       POSTGIVE_VALUE_ROT(e, ammo_fuel, 1, pauserotfuel_finished, cvar("g_balance_pause_fuel_rot"), pauseregenhealth_finished, cvar("g_balance_pause_fuel_regen"), "misc/itempickup.wav", string_null);\r
+       POSTGIVE_VALUE_ROT(e, armorvalue, 1, pauserotarmor_finished, cvar("g_balance_pause_armor_rot"), pauseregenarmor_finished, cvar("g_balance_pause_armor_regen"), "misc/armor25.wav", string_null);\r
+       POSTGIVE_VALUE_ROT(e, health, 1, pauserothealth_finished, cvar("g_balance_pause_health_rot"), pauseregenhealth_finished, cvar("g_balance_pause_health_regen"), "misc/megahealth.wav", string_null);\r
 \r
        if(e.strength_finished <= 0)\r
                e.strength_finished = 0;\r