mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Improves ethereal APC sucking code (#64638)
* armhulen talk to me about the combat mode stuff * cleans up the istype issues * ryll please free me from slavery
This commit is contained in:
+19
-23
@@ -783,23 +783,21 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, APC_PIXEL_OFFSET
|
||||
return
|
||||
if(!ishuman(user))
|
||||
return
|
||||
var/mob/living/carbon/human/apc_interactor = user
|
||||
var/obj/item/organ/stomach/ethereal/maybe_ethereal_stomach = apc_interactor.getorganslot(ORGAN_SLOT_STOMACH)
|
||||
if(!istype(maybe_ethereal_stomach))
|
||||
togglelock(user)
|
||||
else
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/organ/stomach/maybe_stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
|
||||
if(!istype(maybe_stomach, /obj/item/organ/stomach/ethereal))
|
||||
if(maybe_ethereal_stomach.crystal_charge >= ETHEREAL_CHARGE_NORMAL)
|
||||
togglelock(user)
|
||||
else
|
||||
var/obj/item/organ/stomach/ethereal/stomach = maybe_stomach
|
||||
if(stomach.crystal_charge >= ETHEREAL_CHARGE_NORMAL)
|
||||
togglelock(user)
|
||||
ethereal_interact(user,modifiers)
|
||||
ethereal_interact(user,modifiers)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
|
||||
/obj/machinery/power/apc/proc/ethereal_interact(mob/living/user,list/modifiers)
|
||||
if(!ishuman(user))
|
||||
return
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/organ/stomach/maybe_stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
|
||||
var/mob/living/carbon/human/ethereal = user
|
||||
var/obj/item/organ/stomach/maybe_stomach = ethereal.getorganslot(ORGAN_SLOT_STOMACH)
|
||||
|
||||
if(!istype(maybe_stomach, /obj/item/organ/stomach/ethereal))
|
||||
return
|
||||
@@ -807,42 +805,40 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, APC_PIXEL_OFFSET
|
||||
var/obj/item/organ/stomach/ethereal/stomach = maybe_stomach
|
||||
if(!((stomach?.drain_time < world.time) && LAZYACCESS(modifiers, RIGHT_CLICK)))
|
||||
return
|
||||
if(H.combat_mode)
|
||||
if(ethereal.combat_mode)
|
||||
if(cell.charge <= (cell.maxcharge / 2)) // ethereals can't drain APCs under half charge, this is so that they are forced to look to alternative power sources if the station is running low
|
||||
to_chat(H, span_warning("The APC's syphon safeties prevent you from draining power!"))
|
||||
to_chat(ethereal, span_warning("The APC's syphon safeties prevent you from draining power!"))
|
||||
return
|
||||
if(stomach.crystal_charge > charge_limit)
|
||||
to_chat(H, span_warning("Your charge is full!"))
|
||||
to_chat(ethereal, span_warning("Your charge is full!"))
|
||||
return
|
||||
stomach.drain_time = world.time + APC_DRAIN_TIME
|
||||
to_chat(H, span_notice("You start channeling some power through the APC into your body."))
|
||||
to_chat(ethereal, span_notice("You start channeling some power through the APC into your body."))
|
||||
if(do_after(user, APC_DRAIN_TIME, target = src))
|
||||
if(cell.charge <= (cell.maxcharge / 2) || (stomach.crystal_charge > charge_limit))
|
||||
return
|
||||
to_chat(H, span_notice("You receive some charge from the APC."))
|
||||
to_chat(ethereal, span_notice("You receive some charge from the APC."))
|
||||
stomach.adjust_charge(APC_POWER_GAIN)
|
||||
cell.charge -= APC_POWER_GAIN
|
||||
return
|
||||
else
|
||||
if(cell.charge >= cell.maxcharge - APC_POWER_GAIN)
|
||||
to_chat(H, span_warning("The APC can't receive anymore power!"))
|
||||
to_chat(ethereal, span_warning("The APC can't receive anymore power!"))
|
||||
return
|
||||
if(stomach.crystal_charge < APC_POWER_GAIN)
|
||||
to_chat(H, span_warning("Your charge is too low!"))
|
||||
to_chat(ethereal, span_warning("Your charge is too low!"))
|
||||
return
|
||||
stomach.drain_time = world.time + APC_DRAIN_TIME
|
||||
to_chat(H, span_notice("You start channeling power through your body into the APC."))
|
||||
to_chat(ethereal, span_notice("You start channeling power through your body into the APC."))
|
||||
if(do_after(user, APC_DRAIN_TIME, target = src))
|
||||
if((cell.charge >= (cell.maxcharge - APC_POWER_GAIN)) || (stomach.crystal_charge < APC_POWER_GAIN))
|
||||
to_chat(H, span_warning("You can't transfer power to the APC!"))
|
||||
to_chat(ethereal, span_warning("You can't transfer power to the APC!"))
|
||||
return
|
||||
if(istype(stomach))
|
||||
to_chat(H, span_notice("You transfer some power to the APC."))
|
||||
to_chat(ethereal, span_notice("You transfer some power to the APC."))
|
||||
stomach.adjust_charge(-APC_POWER_GAIN)
|
||||
cell.charge += APC_POWER_GAIN
|
||||
else
|
||||
to_chat(H, span_warning("You can't transfer power to the APC!"))
|
||||
return
|
||||
to_chat(ethereal, span_warning("You can't transfer power to the APC!"))
|
||||
|
||||
/obj/machinery/power/apc/proc/togglelock(mob/living/user)
|
||||
if(obj_flags & EMAGGED)
|
||||
|
||||
Reference in New Issue
Block a user