Skip to content

Commit

Permalink
Datumizes microbatteries (#26900)
Browse files Browse the repository at this point in the history
* Datumize microbattery

* comments + feedback when you're revivable

* More comment

* more datumization

* Explaining myself

* Being able to charge while not having a microbattery

* Better comment

Co-authored-by: 1080pCat <[email protected]>
Signed-off-by: BiancaWilkson <[email protected]>

* Changes proc name to be more accurate

---------

Signed-off-by: BiancaWilkson <[email protected]>
Co-authored-by: 1080pCat <[email protected]>
  • Loading branch information
BiancaWilkson and 1080pCat authored Oct 18, 2024
1 parent 20dfb3a commit 074da2b
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 16 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// Organ datum defines. Each one of these represents a slot for organ datums in internal_organ_datums
#define ORGAN_DATUM_HEART "heart"
#define ORGAN_DATUM_LUNGS "lungs"
#define ORGAN_DATUM_BATTERY "battery"

// For limb resistance flags
#define CANNOT_BREAK (1 << 0)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/miniantags/abduction/gland.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
dead_icon = null
status = ORGAN_ROBOT
origin_tech = "materials=4;biotech=7;abductor=3"
organ_datums = list(/datum/organ/heart/always_beating) // alien glands are immune to stopping
organ_datums = list(/datum/organ/heart/always_beating, /datum/organ/battery) // alien glands are immune to stopping, and provide power to IPCs
tough = TRUE //not easily broken by combat damage

var/cooldown_low = 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
icon = 'icons/obj/surgery.dmi'
icon_state = "demon_heart"
origin_tech = "combat=5;biotech=7"
organ_datums = list(/datum/organ/heart/always_beating)
organ_datums = list(/datum/organ/heart/always_beating, /datum/organ/battery)

/obj/item/organ/internal/heart/demon/update_icon_state()
return //always beating visually
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/rechargestation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
R.cell.charge = min(R.cell.charge + recharge_speed, R.cell.maxcharge)
else if(ishuman(occupant))
var/mob/living/carbon/human/H = occupant
if(H.get_int_organ(/obj/item/organ/internal/cell))
if(ismachineperson(H))
if(H.nutrition < NUTRITION_LEVEL_FULL - 1)
H.set_nutrition(min(H.nutrition + recharge_speed_nutrition, NUTRITION_LEVEL_FULL - 1))
if(repairs)
Expand Down Expand Up @@ -206,7 +206,7 @@
if(occupant)
to_chat(H, "<span class='warning'>The cell is already occupied!</span>")
return
if(ismodcontrol(H.back) || H.get_int_organ(/obj/item/organ/internal/cell))
if(ismodcontrol(H.back) || ismachineperson(H))
can_accept_user = TRUE

if(!can_accept_user)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/carbon_update_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
death()
create_debug_log("died of damage, trigger reason: [reason]")
return
if(HAS_TRAIT(src, TRAIT_KNOCKEDOUT) || (check_death_method() && getOxyLoss() > 50) || HAS_TRAIT(src, TRAIT_FAKEDEATH) || health < HEALTH_THRESHOLD_KNOCKOUT && check_death_method() || health <= HEALTH_THRESHOLD_DEAD)
if(HAS_TRAIT(src, TRAIT_KNOCKEDOUT) || (check_death_method() && getOxyLoss() > 50) || HAS_TRAIT(src, TRAIT_FAKEDEATH) || health < HEALTH_THRESHOLD_KNOCKOUT && check_death_method() || health <= HEALTH_THRESHOLD_DEAD) // In case anyone is wondering where oldcrit is handled, it's here.
if(stat == CONSCIOUS)
KnockOut()
create_debug_log("fell unconscious, trigger reason: [reason]")
Expand Down
8 changes: 6 additions & 2 deletions code/modules/mob/living/carbon/human/human_update_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
return
..(reason)
if(stat == DEAD)
if(dna.species && dna.species.can_revive_by_healing)
if(dna.species && dna.species.can_revive_by_healing) // Here's where IPC revival is handled
var/obj/item/organ/internal/brain/B = get_int_organ(/obj/item/organ/internal/brain)
if(B)
if((health >= (HEALTH_THRESHOLD_DEAD + HEALTH_THRESHOLD_CRIT) * 0.5) && check_vital_organs() && !suiciding)
if((health >= (HEALTH_THRESHOLD_DEAD + HEALTH_THRESHOLD_CRIT) * 0.5) && ipc_vital_organ_check() && !suiciding)
var/mob/dead/observer/ghost = get_ghost()
if(ghost)
to_chat(ghost, "<span class='ghostalert'>Your chassis has been repaired and repowered, re-enter if you want to continue playing!</span> (Verbs -> Ghost -> Re-enter corpse)")
SEND_SOUND(ghost, sound('sound/effects/genetics.ogg'))
update_revive()
create_debug_log("revived from healing, trigger reason: [reason]")

Expand Down
10 changes: 3 additions & 7 deletions code/modules/surgery/organs/augments_arms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,8 @@
user.changeNext_move(CLICK_CD_MELEE)
var/obj/machinery/power/apc/A = target
var/mob/living/carbon/human/H = user
if(H.get_int_organ(/obj/item/organ/internal/cell) || H.get_int_organ(/obj/item/organ/internal/heart))
var/obj/item/organ/internal/heart/robotic = H.get_int_organ(/obj/item/organ/internal/heart)
if(robotic)
if(!(robotic.status & ORGAN_ROBOT) && !H.get_int_organ(/obj/item/organ/internal/heart/demon/pulse))
to_chat(user, "<span class='warning'>You lack a cell in which to store charge!</span>")
return
var/datum/organ/battery/power_source = H.get_int_organ_datum(ORGAN_DATUM_BATTERY)
if(istype(power_source))
if(A.emagged || A.stat & BROKEN)
do_sparks(3, 1, A)
to_chat(H, "<span class='warning'>The APC power currents surge erratically, damaging your chassis!</span>")
Expand All @@ -443,7 +439,7 @@
else
to_chat(user, "<span class='warning'>There is no charge to draw from that APC.</span>")
else
to_chat(user, "<span class='warning'>You lack a cell in which to store charge!</span>")
to_chat(user, "<span class='warning'>You lack a power source in which to store charge!</span>")

/obj/item/apc_powercord/proc/powerdraw_loop(obj/machinery/power/apc/A, mob/living/carbon/human/H)
H.visible_message("<span class='notice'>[H] inserts a power connector into \the [A].</span>", "<span class='notice'>You begin to draw power from \the [A].</span>")
Expand Down
2 changes: 2 additions & 0 deletions code/modules/surgery/organs/heart.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
base_icon_state = "cursedheart"
origin_tech = "biotech=6"
actions_types = list(/datum/action/item_action/organ_action/cursed_heart)
organ_datums = list(/datum/organ/heart, /datum/organ/battery) // This doesn't actually work for IPCs but it also doesn't kill you, and it's funny
var/last_pump = 0
var/pump_delay = 30 //you can pump 1 second early, for lag, but no more (otherwise you could spam heal)
var/blood_loss = 100 //600 blood is human default, so 5 failures (below 122 blood is where humans die because reasons?)
Expand Down Expand Up @@ -191,6 +192,7 @@
base_icon_state = "heart-c"
dead_icon = "heart-c-off"
status = ORGAN_ROBOT
organ_datums = list(/datum/organ/heart, /datum/organ/battery)

/obj/item/organ/internal/heart/cybernetic/upgraded
name = "upgraded cybernetic heart"
Expand Down
5 changes: 5 additions & 0 deletions code/modules/surgery/organs/organ_datums/battery_datum.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
For any species that doesn't have a heart datum but does have heart-like organs, so just IPCs right now. Microbatteries currently have no behavior.
*/
/datum/organ/battery
organ_tag = ORGAN_DATUM_BATTERY
9 changes: 7 additions & 2 deletions code/modules/surgery/organs/organ_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@
.++
if(affecting.body_part == LEG_LEFT)
.++
///Returns true if all the mob's vital organs are functional, otherwise returns false
/mob/living/carbon/human/proc/check_vital_organs()
/* Returns true if all the mob's vital organs are functional, otherwise returns false.
* This proc is only used for checking if IPCs can revive from death, so calling it on a non IPC will always return false (right now)
*/
/mob/living/carbon/human/proc/ipc_vital_organ_check()
var/has_battery = get_int_organ_datum(ORGAN_DATUM_BATTERY)
if(!has_battery)
return FALSE
for(var/obj/item/organ/internal/organ in internal_organs)
if(organ.vital && (organ.damage >= organ.max_damage))
return FALSE
Expand Down
1 change: 1 addition & 0 deletions code/modules/surgery/organs/subtypes/machine_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
vital = TRUE
status = ORGAN_ROBOT
requires_robotic_bodypart = TRUE
organ_datums = list(/datum/organ/battery)

/obj/item/organ/internal/eyes/optical_sensor
name = "optical sensor"
Expand Down
1 change: 1 addition & 0 deletions paradise.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,7 @@
#include "code\modules\surgery\organs\robolimbs.dm"
#include "code\modules\surgery\organs\skeleton_organs.dm"
#include "code\modules\surgery\organs\vocal_cords.dm"
#include "code\modules\surgery\organs\organ_datums\battery_datum.dm"
#include "code\modules\surgery\organs\organ_datums\heart_datum.dm"
#include "code\modules\surgery\organs\organ_datums\lung_datum.dm"
#include "code\modules\surgery\organs\organ_datums\organ_datum.dm"
Expand Down

0 comments on commit 074da2b

Please sign in to comment.