]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Implement digestible items and get them working properly
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 19 Nov 2011 14:29:50 +0000 (16:29 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 19 Nov 2011 14:29:50 +0000 (16:29 +0200)
data/qcsrc/server/t_items.qc

index 43756ab69ab742bff41388c233f76bdf7761cb60..d351beeb85350d81d83bac27e4e74694791085b2 100644 (file)
@@ -219,7 +219,7 @@ void Item_ScheduleInitialRespawn(entity e)
        Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));\r
 }\r
 \r
-.float inithealth;\r
+.float inithealth, initdmg;\r
 .float item_digestion_step;\r
 void Item_Consumable_Remove(entity e, float regurgitate);\r
 void Item_Consumable_Think()\r
@@ -238,6 +238,15 @@ void Item_Consumable_Think()
                return;\r
        }\r
 \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
+       {\r
+               // this item is done\r
+               Item_Consumable_Remove(self, FALSE);\r
+               return;\r
+       }\r
+\r
        if(self.predator.digesting)\r
        {\r
                if(time > self.item_digestion_step)\r
@@ -253,13 +262,12 @@ void Item_Consumable_Think()
 \r
                        self.health -= damage;\r
                        self.predator.health += damage;\r
-                       self.scale = self.health / self.inithealth; // scale matches the item's digestion progress\r
+\r
+                       self.item_digestion_step = time + vore_steptime;\r
                }\r
 \r
                if(stov(cvar_string("g_vore_regurgitatecolor_color_digest")))\r
                        self.colormod = stov(cvar_string("g_vore_regurgitatecolor_color_digest"));\r
-\r
-               self.item_digestion_step = time + vore_steptime;\r
        }\r
 \r
        self.nextthink = time;\r
@@ -310,7 +318,7 @@ void Item_Consumable_Spawn(entity e, entity pl)
        item.health = e.health;\r
        item.inithealth = e.health;\r
        item.max_health = e.max_health;\r
-       item.dmg = e.dmg;\r
+       item.initdmg = e.dmg;\r
 \r
        item.predator = pl;\r
        item.aiment = pl;\r
@@ -360,7 +368,7 @@ void Item_DroppedConsumable_Spawn(entity e)
        item.health = e.health;\r
        item.inithealth = e.inithealth;\r
        item.max_health = e.max_health;\r
-       item.dmg = e.dmg;\r
+       item.initdmg = e.initdmg;\r
        item.scale = e.scale;\r
        item.colormod = e.colormod;\r
 \r