From a5bd74f44e82cc1ef4d6ecf9dcac61c27cb111ec Mon Sep 17 00:00:00 2001 From: emmanuelbassil <6874235+emmanuelbassil@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:23:40 +0300 Subject: [PATCH] [MIRROR] Vending machines have standardized health --- .../machinery/_machines_base/machinery.dm | 11 ++++++ code/game/machinery/doors/door.dm | 10 ----- code/game/machinery/vending/_vending.dm | 37 +++++++++---------- code/game/machinery/vending/coffee.dm | 4 +- .../xenoarcheaology/artifacts/artifact.dm | 9 ----- test/check-paths.sh | 2 +- 6 files changed, 31 insertions(+), 42 deletions(-) diff --git a/code/game/machinery/_machines_base/machinery.dm b/code/game/machinery/_machines_base/machinery.dm index 5861950fc2e6a..8a38cff459ba2 100644 --- a/code/game/machinery/_machines_base/machinery.dm +++ b/code/game/machinery/_machines_base/machinery.dm @@ -89,6 +89,17 @@ RefreshParts() power_change() +/obj/machinery/post_health_change(health_mod, prior_health, damage_type) + if (health_mod < 0 && !health_dead()) + var/initial_damage_percentage = Percent(get_max_health() - prior_health, get_max_health(), 0) + var/damage_percentage = get_damage_percentage() + if (damage_percentage >= 75 && initial_damage_percentage < 75) + visible_message("\The [src] looks like it's about to break!" ) + else if (damage_percentage >= 50 && initial_damage_percentage < 50) + visible_message("\The [src] looks seriously damaged!" ) + else if (damage_percentage >= 25 && initial_damage_percentage < 25) + visible_message("\The [src] shows signs of damage!" ) + /obj/machinery/Destroy() if(istype(wires)) QDEL_NULL(wires) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index e53219d89f641..9e1e44e8d86d7 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -289,16 +289,6 @@ /obj/machinery/door/post_health_change(health_mod, prior_health, damage_type) . = ..() queue_icon_update() - if (health_mod < 0 && !health_dead()) - var/initial_damage_percentage = round((prior_health / get_max_health()) * 100) - var/damage_percentage = get_damage_percentage() - if (damage_percentage >= 75 && initial_damage_percentage < 75) - visible_message("\The [src] looks like it's about to break!" ) - else if (damage_percentage >= 50 && initial_damage_percentage < 50) - visible_message("\The [src] looks seriously damaged!" ) - else if (damage_percentage >= 25 && initial_damage_percentage < 25) - visible_message("\The [src] shows signs of damage!" ) - /obj/machinery/door/on_revive() . = ..() diff --git a/code/game/machinery/vending/_vending.dm b/code/game/machinery/vending/_vending.dm index ddc15c2511237..f136f99ca6825 100644 --- a/code/game/machinery/vending/_vending.dm +++ b/code/game/machinery/vending/_vending.dm @@ -17,6 +17,7 @@ machine_desc = "Holds an internal stock of items that can be dispensed on-demand or when a charged ID card is swiped, depending on the brand." idle_power_usage = 10 wires = /datum/wires/vending + health_max = 80 /// The machine's wires, but typed. var/datum/wires/vending/vendor_wires @@ -84,7 +85,7 @@ var/vend_reply //Thank you for shopping! var/last_reply = 0 var/last_slogan = 0 //When did we last pitch? - var/slogan_delay = 10 MINUTES //How long until we can pitch again? + var/slogan_delay = 2 MINUTES //How long until we can pitch again? var/seconds_electrified = 0 //Shock customers like an airlock. var/shoot_inventory = FALSE //Fire items at customers! We're broken! var/shooting_chance = 2 //The chance that items are being shot per tick @@ -135,6 +136,18 @@ if (shoot_inventory && prob(shooting_chance)) throw_item() +/obj/machinery/vending/post_health_change(health_mod, prior_health, damage_type) + . = ..() + queue_icon_update() + if (health_mod < 0 && !health_dead()) + var/initial_damage_percentage = Percent(get_max_health() - prior_health, get_max_health(), 0) + var/damage_percentage = get_damage_percentage() + if (damage_percentage >= 25 && initial_damage_percentage < 25 && prob(75)) + shut_up = FALSE + else if (damage_percentage >= 50 && initial_damage_percentage < 50) + vendor_wires.RandomCut() + else if (damage_percentage >= 75 && initial_damage_percentage < 75 && prob(10)) + malfunction() /obj/machinery/vending/powered() return anchored && ..() @@ -162,26 +175,12 @@ icon_state = "[initial(icon_state)]-off" if (panel_open || IsShowingAntag()) AddOverlays(image(icon, "[initial(icon_state)]-panel")) - if (IsShowingAntag() && is_powered()) + if ((IsShowingAntag() || get_damage_percentage() >= 50) && is_powered()) AddOverlays(image(icon, "sparks")) AddOverlays(emissive_appearance(icon, "sparks")) if (!vend_ready) AddOverlays(image(icon, "[initial(icon_state)]-shelf[rand(max_overlays)]")) - -/obj/machinery/vending/ex_act(severity) - switch(severity) - if (EX_ACT_DEVASTATING) - qdel(src) - if (EX_ACT_HEAVY) - if (prob(50)) - qdel(src) - if (EX_ACT_LIGHT) - if (prob(25)) - spawn(0) - malfunction() - - /obj/machinery/vending/emag_act(remaining_charges, mob/living/user) if (emagged) return @@ -189,7 +188,6 @@ req_access.Cut() if (antag_slogans) shut_up = FALSE - slogan_delay = 2 MINUTES slogan_list.Cut() slogan_list += splittext(antag_slogans, ";") last_slogan = world.time + rand(0, slogan_delay) @@ -272,7 +270,6 @@ var/obj/item/material/coin/challenge/syndie/antagcoin = item if (antag_slogans) shut_up = FALSE - slogan_delay = 2 MINUTES slogan_list.Cut() slogan_list += splittext(antag_slogans, ";") last_slogan = world.time + rand(0, slogan_delay) @@ -549,7 +546,9 @@ /obj/machinery/vending/proc/malfunction() - for (var/datum/stored_items/vending_products/product in product_records) + for (var/datum/stored_items/vending_products/product in shuffle(product_records)) + if (product.category == VENDOR_CATEGORY_ANTAG) + continue while (product.get_amount() > 0) product.get_product(loc) break diff --git a/code/game/machinery/vending/coffee.dm b/code/game/machinery/vending/coffee.dm index 27459f1cc78ed..c68ded32ec319 100644 --- a/code/game/machinery/vending/coffee.dm +++ b/code/game/machinery/vending/coffee.dm @@ -71,7 +71,5 @@ /obj/machinery/vending/coffee/on_update_icon() ..() - if (MACHINE_IS_BROKEN(src) && prob(20)) - icon_state = "[initial(icon_state)]-hellfire" - else if (is_powered()) + if (is_powered()) AddOverlays(image(icon, "[initial(icon_state)]-screen")) diff --git a/code/modules/xenoarcheaology/artifacts/artifact.dm b/code/modules/xenoarcheaology/artifacts/artifact.dm index c5d073955e4d9..7781e74f0ecdd 100644 --- a/code/modules/xenoarcheaology/artifacts/artifact.dm +++ b/code/modules/xenoarcheaology/artifacts/artifact.dm @@ -208,15 +208,6 @@ ..() queue_icon_update() if (health_mod < 0) - var/initial_damage_percentage = round((prior_health / get_max_health()) * 100) - var/damage_percentage = get_damage_percentage() - if (damage_percentage >= 75 && initial_damage_percentage < 75) - visible_message("\The [src] looks like it's about to break!") - else if (damage_percentage >= 50 && initial_damage_percentage < 50) - visible_message("\The [src] looks seriously damaged!" ) - else if (damage_percentage >= 25 && initial_damage_percentage < 25) - visible_message("\The [src] shows signs of damage!" ) - for (var/datum/artifact_effect/A in list(my_effect, secondary_effect)) A.holder_damaged(get_current_health(), abs(health_mod)) diff --git a/test/check-paths.sh b/test/check-paths.sh index b5fd855e80bcd..648005bc5205a 100755 --- a/test/check-paths.sh +++ b/test/check-paths.sh @@ -48,7 +48,7 @@ exactly 24 "text2path uses" 'text2path' exactly 4 "update_icon() override" '/update_icon\((.*)\)' -P exactly 4 "goto use" 'goto ' exactly 1 "NOOP match" 'NOOP' -exactly 342 "spawn uses" '^\s*spawn\s*\(\s*(-\s*)?\d*\s*\)' -P +exactly 341 "spawn uses" '^\s*spawn\s*\(\s*(-\s*)?\d*\s*\)' -P exactly 0 "tag uses" '\stag = ' -P '**/*.dmm' exactly 0 "anchored = 0/1" 'anchored\s*=\s*\d' -P exactly 2 "density = 0/1" 'density\s*=\s*\d' -P