[MIRROR] Replaces some numbers with defines + grammar stuff in ethereal power draining code (#979)

* Replaces some numbers with defines + grammar stuff in ethereal power draining code (#53924)

* Replaces some numbers with defines + grammar stuff in ethereal power draining code

Co-authored-by: wesoda25 <37246588+wesoda25@users.noreply.github.com>
This commit is contained in:
SkyratBot
2020-09-25 14:27:57 +02:00
committed by GitHub
co-authored by wesoda25
parent 376e8978d3
commit fed00e5a62
3 changed files with 50 additions and 28 deletions
+21 -14
View File
@@ -38,6 +38,9 @@
#define APC_CHARGING 1
#define APC_FULLY_CHARGED 2
#define APC_DRAIN_TIME 75
#define APC_POWER_GAIN 10
// the Area Power Controller (APC), formerly Power Distribution Unit (PDU)
// one per area, needs wire connection to power network through a terminal
@@ -794,23 +797,24 @@
if(isethereal(user))
var/mob/living/carbon/human/H = user
var/datum/species/ethereal/E = H.dna.species
var/charge_limit = ETHEREAL_CHARGE_DANGEROUS - APC_POWER_GAIN
if((H.a_intent == INTENT_HARM) && (E.drain_time < world.time))
if(cell.charge <= (cell.maxcharge / 2)) // if charge is under 50% you shouldn't drain it
to_chat(H, "<span class='warning'>The APC doesn't have much power, you probably shouldn't drain any.</span>")
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 class='warning'>The APC's syphon safeties prevent you from draining power!</span>")
return
var/obj/item/organ/stomach/ethereal/stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
if(stomach.crystal_charge > 145)
if(stomach.crystal_charge > charge_limit)
to_chat(H, "<span class='warning'>Your charge is full!</span>")
return
E.drain_time = world.time + 75
E.drain_time = world.time + APC_DRAIN_TIME
to_chat(H, "<span class='notice'>You start channeling some power through the APC into your body.</span>")
if(do_after(user, 75, target = src))
if(cell.charge <= (cell.maxcharge / 2) || (stomach.crystal_charge > 145))
if(do_after(user, APC_DRAIN_TIME, target = src))
if(cell.charge <= (cell.maxcharge / 2) || (stomach.crystal_charge > charge_limit))
return
if(istype(stomach))
to_chat(H, "<span class='notice'>You receive some charge from the APC.</span>")
stomach.adjust_charge(10)
cell.charge -= 10
stomach.adjust_charge(APC_POWER_GAIN)
cell.charge -= APC_POWER_GAIN
else
to_chat(H, "<span class='warning'>You can't receive charge from the APC!</span>")
return
@@ -819,18 +823,18 @@
to_chat(H, "<span class='warning'>The APC is full!</span>")
return
var/obj/item/organ/stomach/ethereal/stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
if(stomach.crystal_charge < 10)
if(stomach.crystal_charge < APC_POWER_GAIN)
to_chat(H, "<span class='warning'>Your charge is too low!</span>")
return
E.drain_time = world.time + 75
E.drain_time = world.time + APC_DRAIN_TIME
to_chat(H, "<span class='notice'>You start channeling power through your body into the APC.</span>")
if(do_after(user, 75, target = src))
if(cell.charge == cell.maxcharge || (stomach.crystal_charge < 10))
if(do_after(user, APC_DRAIN_TIME, target = src))
if(cell.charge == cell.maxcharge || (stomach.crystal_charge < APC_POWER_GAIN))
return
if(istype(stomach))
to_chat(H, "<span class='notice'>You transfer some power to the APC.</span>")
stomach.adjust_charge(-10)
cell.charge += 10
stomach.adjust_charge(-APC_POWER_GAIN)
cell.charge += APC_POWER_GAIN
else
to_chat(H, "<span class='warning'>You can't transfer power to the APC!</span>")
return
@@ -1461,6 +1465,9 @@
#undef APC_CHARGING
#undef APC_FULLY_CHARGED
#undef APC_DRAIN_TIME
#undef APC_POWER_GAIN
//update_overlay
#undef APC_UPOVERLAY_CHARGEING0
#undef APC_UPOVERLAY_CHARGEING1
+20 -11
View File
@@ -1,3 +1,7 @@
#define CELL_DRAIN_TIME 20
#define CELL_POWER_GAIN 3
#define CELL_POWER_DRAIN 100
/obj/item/stock_parts/cell
name = "power cell"
desc = "A rechargeable electrochemical power cell."
@@ -154,26 +158,27 @@
if(isethereal(user))
var/mob/living/carbon/human/H = user
var/datum/species/ethereal/E = H.dna.species
var/charge_limit = ETHEREAL_CHARGE_DANGEROUS - CELL_POWER_GAIN
if(E.drain_time > world.time)
return
if(charge < 100)
to_chat(H, "<span class='warning'>The [src] doesn't have enough power!</span>")
if(charge < CELL_POWER_DRAIN)
to_chat(H, "<span class='warning'>[src] doesn't have enough power!</span>")
return
var/obj/item/organ/stomach/ethereal/stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
if(stomach.crystal_charge > 146)
if(stomach.crystal_charge > charge_limit)
to_chat(H, "<span class='warning'>Your charge is full!</span>")
return
to_chat(H, "<span class='notice'>You clumsily channel power through the [src] and into your body, wasting some in the process.</span>")
E.drain_time = world.time + 20
if(do_after(user, 20, target = src))
if((charge < 100) || (stomach.crystal_charge > 146))
to_chat(H, "<span class='notice'>You clumsily channel power through [src] and into your body, wasting some in the process.</span>")
E.drain_time = world.time + CELL_DRAIN_TIME
if(do_after(user, CELL_DRAIN_TIME, target = src))
if((charge < CELL_POWER_DRAIN) || (stomach.crystal_charge > charge_limit))
return
if(istype(stomach))
to_chat(H, "<span class='notice'>You receive some charge from the [src].</span>")
stomach.adjust_charge(3)
charge -= 100 //you waste way more than you receive, so that ethereals cant just steal one cell and forget about hunger
to_chat(H, "<span class='notice'>You receive some charge from [src].</span>")
stomach.adjust_charge(CELL_POWER_GAIN)
charge -= CELL_POWER_DRAIN //you waste way more than you receive, so that ethereals cant just steal one cell and forget about hunger
else
to_chat(H, "<span class='warning'>You can't receive charge from the [src]!</span>")
to_chat(H, "<span class='warning'>You can't receive charge from [src]!</span>")
return
@@ -398,3 +403,7 @@
var/area/A = get_area(src)
if(!A.lightswitch || !A.light_power)
charge = 0 //For naturally depowered areas, we start with no power
#undef CELL_DRAIN_TIME
#undef CELL_POWER_GAIN
#undef CELL_POWER_DRAIN
+9 -3
View File
@@ -12,6 +12,9 @@
#define BROKEN_SPARKS_MIN (30 SECONDS)
#define BROKEN_SPARKS_MAX (90 SECONDS)
#define LIGHT_DRAIN_TIME 30
#define LIGHT_POWER_GAIN 2
/obj/item/wallframe/light_fixture
name = "light fixture frame"
desc = "Used for building lights."
@@ -658,12 +661,12 @@
if(E.drain_time > world.time)
return
to_chat(H, "<span class='notice'>You start channeling some power through the [fitting] into your body.</span>")
E.drain_time = world.time + 30
if(do_after(user, 30, target = src))
E.drain_time = world.time + LIGHT_DRAIN_TIME
if(do_after(user, LIGHT_DRAIN_TIME, target = src))
var/obj/item/organ/stomach/ethereal/stomach = H.getorganslot(ORGAN_SLOT_STOMACH)
if(istype(stomach))
to_chat(H, "<span class='notice'>You receive some charge from the [fitting].</span>")
stomach.adjust_charge(2)
stomach.adjust_charge(LIGHT_POWER_GAIN)
else
to_chat(H, "<span class='warning'>You can't receive charge from the [fitting]!</span>")
return
@@ -916,3 +919,6 @@
layer = 2.5
light_type = /obj/item/light/bulb
fitting = "bulb"
#undef LIGHT_DRAIN_TIME
#undef LIGHT_POWER_GAIN