From 6f2c47e5a9d559a5a70bc6ccd454913c5f52cab4 Mon Sep 17 00:00:00 2001 From: Anewbe Date: Sun, 11 Feb 2018 20:57:20 -0600 Subject: [PATCH] Trees take damage from bullets/lasers (#4786) --- code/game/objects/structures/flora/trees.dm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/game/objects/structures/flora/trees.dm b/code/game/objects/structures/flora/trees.dm index 872eea47d53..0c50bf189d1 100644 --- a/code/game/objects/structures/flora/trees.dm +++ b/code/game/objects/structures/flora/trees.dm @@ -47,13 +47,19 @@ animate(transform=null, pixel_x=init_px, time=6, easing=ELASTIC_EASING) // Used when the tree gets hurt. -/obj/structure/flora/tree/proc/adjust_health(var/amount) +/obj/structure/flora/tree/proc/adjust_health(var/amount, var/is_ranged = FALSE) if(is_stump) return + // Bullets and lasers ruin some of the wood + if(is_ranged && product_amount > 0) + var/wood = initial(product_amount) + product_amount -= round(wood * (abs(amount)/max_health)) + health = between(0, health + amount, max_health) if(health <= 0) die() + return // Called when the tree loses all health, for whatever reason. /obj/structure/flora/tree/proc/die() @@ -81,6 +87,9 @@ /obj/structure/flora/tree/ex_act(var/severity) adjust_health(-(max_health / severity)) +/obj/structure/flora/tree/bullet_act(var/obj/item/projectile/Proj) + if(Proj.get_structure_damage()) + adjust_health(-Proj.get_structure_damage(), TRUE) /obj/structure/flora/tree/get_description_interaction() var/list/results = list()