mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Unfastening objects will now check constantly during the do_after (#23881)
* Unfastening objects will now check constantly during the do_after for if you can * .
This commit is contained in:
@@ -72,9 +72,10 @@
|
||||
. *= min(max_integrity/max(obj_integrity, 1), 4)
|
||||
. = round(., 0.01)
|
||||
|
||||
/obj/structure/destructible/clockwork/can_be_unfasten_wrench(mob/user)
|
||||
/obj/structure/destructible/clockwork/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(anchored && obj_integrity <= round(max_integrity * 0.25, 1))
|
||||
user << "<span class='warning'>[src] is too damaged to unsecure!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] is too damaged to unsecure!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
@@ -158,9 +159,10 @@
|
||||
var/powered = total_accessable_power()
|
||||
return powered == PROCESS_KILL ? 25 : powered //make sure we don't accidentally return the arbitrary PROCESS_KILL define
|
||||
|
||||
/obj/structure/destructible/clockwork/powered/can_be_unfasten_wrench(mob/user)
|
||||
/obj/structure/destructible/clockwork/powered/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(active)
|
||||
user << "<span class='warning'>[src] needs to be disabled before it can be unsecured!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] needs to be disabled before it can be unsecured!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
if(is_servant_of_ratvar(user) || isobserver(user))
|
||||
user << "<span class='nzcrentr_small'>It requires <b>[hierophant_cost]W</b> to broadcast over the Hierophant Network, and <b>[gateway_cost]W</b> to open a Spatial Gateway.</span>"
|
||||
|
||||
/obj/structure/destructible/clockwork/powered/clockwork_obelisk/can_be_unfasten_wrench(mob/user)
|
||||
/obj/structure/destructible/clockwork/powered/clockwork_obelisk/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(active)
|
||||
user << "<span class='warning'>[src] is currently sustaining a gateway!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] is currently sustaining a gateway!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -32,14 +32,16 @@
|
||||
/obj/structure/destructible/clockwork/ocular_warden/hulk_damage()
|
||||
return 25
|
||||
|
||||
/obj/structure/destructible/clockwork/ocular_warden/can_be_unfasten_wrench(mob/user)
|
||||
/obj/structure/destructible/clockwork/ocular_warden/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(anchored)
|
||||
if(obj_integrity <= max_integrity * 0.25)
|
||||
user << "<span class='warning'>[src] is too damaged to unsecure!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] is too damaged to unsecure!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
else
|
||||
for(var/obj/structure/destructible/clockwork/ocular_warden/W in orange(3, src))
|
||||
user << "<span class='neovgre'>You sense another ocular warden too near this location. Activating this one this close would cause them to fight.</span>"
|
||||
if(!silent)
|
||||
user << "<span class='neovgre'>You sense another ocular warden too near this location. Activating this one this close would cause them to fight.</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return SUCCESSFUL_UNFASTEN
|
||||
|
||||
|
||||
@@ -356,13 +356,13 @@ Class Procs:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/proc/can_be_unfasten_wrench(mob/user)
|
||||
/obj/proc/can_be_unfasten_wrench(mob/user, silent) //if we can unwrench this object; returns SUCCESSFUL_UNFASTEN and FAILED_UNFASTEN, which are both TRUE, or CANT_UNFASTEN, which isn't.
|
||||
if(!isfloorturf(loc) && !anchored)
|
||||
user << "<span class='warning'>[src] needs to be on the floor to be secured!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return SUCCESSFUL_UNFASTEN
|
||||
|
||||
/obj/proc/default_unfasten_wrench(mob/user, obj/item/weapon/wrench/W, time = 20)
|
||||
/obj/proc/default_unfasten_wrench(mob/user, obj/item/weapon/wrench/W, time = 20) //try to unwrench an object in a WONDERFUL DYNAMIC WAY
|
||||
if(istype(W) && !(flags & NODECONSTRUCT))
|
||||
var/can_be_unfasten = can_be_unfasten_wrench(user)
|
||||
if(!can_be_unfasten || can_be_unfasten == FAILED_UNFASTEN)
|
||||
@@ -372,10 +372,7 @@ Class Procs:
|
||||
playsound(loc, W.usesound, 50, 1)
|
||||
var/prev_anchored = anchored
|
||||
//as long as we're the same anchored state and we're either on a floor or are anchored, toggle our anchored state
|
||||
if(!time || (do_after(user, time*W.toolspeed, target = src) && anchored == prev_anchored))
|
||||
can_be_unfasten = can_be_unfasten_wrench(user)
|
||||
if(!can_be_unfasten || can_be_unfasten == FAILED_UNFASTEN)
|
||||
return can_be_unfasten
|
||||
if(!time || do_after(user, time*W.toolspeed, target = src, extra_checks = CALLBACK(src, .proc/unfasten_wrench_check, prev_anchored, user)))
|
||||
user << "<span class='notice'>You [anchored ? "un" : ""]secure [src].</span>"
|
||||
anchored = !anchored
|
||||
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
||||
@@ -383,6 +380,13 @@ Class Procs:
|
||||
return FAILED_UNFASTEN
|
||||
return CANT_UNFASTEN
|
||||
|
||||
/obj/proc/unfasten_wrench_check(prev_anchored, mob/user) //for the do_after, this checks if unfastening conditions are still valid
|
||||
if(anchored != prev_anchored)
|
||||
return FALSE
|
||||
if(can_be_unfasten_wrench(user, TRUE) != SUCCESSFUL_UNFASTEN) //if we aren't explicitly successful, cancel the fuck out
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/proc/exchange_parts(mob/user, obj/item/weapon/storage/part_replacer/W)
|
||||
if(!istype(W))
|
||||
return
|
||||
|
||||
@@ -53,9 +53,10 @@ var/global/list/rad_collectors = list()
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/machinery/power/rad_collector/can_be_unfasten_wrench(mob/user)
|
||||
/obj/machinery/power/rad_collector/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(loaded_tank)
|
||||
user << "<span class='warning'>Remove the plasma tank first!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>Remove the plasma tank first!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/emitter/attack_animal(mob/living/simple_animal/M)
|
||||
if(ismegafauna(M))
|
||||
if(ismegafauna(M) && anchored)
|
||||
state = 0
|
||||
anchored = FALSE
|
||||
M.visible_message("<span class='warning'>[M] rips [src] free from its moorings!</span>")
|
||||
@@ -217,9 +217,10 @@
|
||||
A.starting = loc
|
||||
A.fire()
|
||||
|
||||
/obj/machinery/power/emitter/can_be_unfasten_wrench(mob/user)
|
||||
/obj/machinery/power/emitter/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(state == EM_WELDED)
|
||||
user << "<span class='warning'>[src] is welded to the floor!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] is welded to the floor!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -77,9 +77,10 @@ field_generator power level display
|
||||
else
|
||||
user << "<span class='warning'>The [src] needs to be firmly secured to the floor first!</span>"
|
||||
|
||||
/obj/machinery/field/generator/can_be_unfasten_wrench(mob/user)
|
||||
/obj/machinery/field/generator/can_be_unfasten_wrench(mob/user, silent)
|
||||
if(state == FG_WELDED)
|
||||
user << "<span class='warning'>[src] is welded to the floor!</span>"
|
||||
if(!silent)
|
||||
user << "<span class='warning'>[src] is welded to the floor!</span>"
|
||||
return FAILED_UNFASTEN
|
||||
return ..()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user