Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify health vars at /obj level #3524

Merged
merged 5 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__defines/damage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
///The decimal precision for health values. Health will be rounded against this value.
#define HEALTH_ROUNDING 0.01
2 changes: 2 additions & 0 deletions code/__defines/temperature.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define ATOM_SHOULD_TEMPERATURE_ENQUEUE(A) (ATOM_IS_TEMPERATURE_SENSITIVE(A) && !QDELETED(A))
#define ATOM_TEMPERATURE_EQUILIBRIUM_THRESHOLD 5
#define ATOM_TEMPERATURE_EQUILIBRIUM_CONSTANT 0.25
#define MIN_TEMPERATURE_COEFFICIENT 1
#define MAX_TEMPERATURE_COEFFICIENT 10

#define ADJUST_ATOM_TEMPERATURE(_atom, _temp) \
_atom.temperature = _temp; \
Expand Down
14 changes: 0 additions & 14 deletions code/game/atoms_temperature.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#define MIN_TEMPERATURE_COEFFICIENT 1
#define MAX_TEMPERATURE_COEFFICIENT 10

/atom
var/temperature = T20C
var/temperature_coefficient = MAX_TEMPERATURE_COEFFICIENT
Expand All @@ -18,14 +15,6 @@
/turf
temperature_coefficient = MIN_TEMPERATURE_COEFFICIENT

/obj/Initialize(mapload)
. = ..()
temperature_coefficient = isnull(temperature_coefficient) ? clamp(MAX_TEMPERATURE_COEFFICIENT - w_class, MIN_TEMPERATURE_COEFFICIENT, MAX_TEMPERATURE_COEFFICIENT) : temperature_coefficient
create_matter()
//Only apply directional offsets if the mappers haven't set any offsets already
if(!pixel_x && !pixel_y && !pixel_w && !pixel_z)
update_directional_offset()

/obj/proc/HandleObjectHeating(var/obj/item/heated_by, var/mob/user, var/adjust_temp)
if(ATOM_SHOULD_TEMPERATURE_ENQUEUE(src))
visible_message(SPAN_NOTICE("\The [user] carefully heats \the [src] with \the [heated_by]."))
Expand Down Expand Up @@ -59,6 +48,3 @@
else
temperature = adjust_temp
return PROCESS_KILL

#undef MIN_TEMPERATURE_COEFFICIENT
#undef MAX_TEMPERATURE_COEFFICIENT
4 changes: 1 addition & 3 deletions code/game/gamemodes/cult/runes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,11 @@
color = "#ff0000"
anchored = TRUE
density = TRUE
max_health = 200
var/obj/effect/rune/wall/rune
var/health
var/max_health = 200

/obj/effect/cultwall/Initialize(mapload, var/bcolor)
. = ..()
health = max_health
if(bcolor)
color = bcolor

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/godmode/god_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/obj/structure/deity
icon = 'icons/obj/cult.dmi'
maxhealth = 10
max_health = 10
density = TRUE
anchored = TRUE
icon_state = "tomealtar"
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/atmoalter/canister.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
icon = 'icons/obj/atmos.dmi'
icon_state = "yellow"
density = TRUE
var/health = 100.0
max_health = 100
obj_flags = OBJ_FLAG_CONDUCTIBLE
w_class = ITEM_SIZE_GARGANTUAN
construct_state = /decl/machine_construction/pipe/welder
Expand Down
7 changes: 3 additions & 4 deletions code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
anchored = FALSE
density = TRUE
icon_state = "barrier0"
var/health = 100.0
var/maxhealth = 100.0
max_health = 100
var/locked = 0.0

/obj/machinery/deployable/barrier/Initialize()
Expand All @@ -39,8 +38,8 @@
return
return
else if(IS_WRENCH(W))
if (src.health < src.maxhealth)
src.health = src.maxhealth
if (src.health < src.max_health)
src.health = src.max_health
src.emagged = 0
src.req_access = list(access_security)
visible_message("<span class='warning'>[user] repairs \the [src]!</span>")
Expand Down
31 changes: 15 additions & 16 deletions code/game/machinery/doors/_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
construct_state = /decl/machine_construction/default/panel_closed/door
uncreated_component_parts = null
required_interaction_dexterity = DEXTERITY_SIMPLE_MACHINES
max_health = 300

var/can_open_manually = TRUE

Expand All @@ -26,8 +27,6 @@
var/glass = 0
var/normalspeed = 1
var/heat_proof = 0 // For glass airlocks/opacity firedoors
var/maxhealth = 300
var/health
var/destroy_hits = 10 //How many strong hits it takes to destroy the door
var/min_force = 10 //minimum amount of force needed to damage the door with a melee weapon
var/hitsound = 'sound/weapons/smash.ogg' //sound door makes when hit with a weapon
Expand Down Expand Up @@ -93,7 +92,7 @@
if (turf_hand_priority)
set_extension(src, /datum/extension/turf_hand, turf_hand_priority)

health = maxhealth
health = max_health
#ifdef UNIT_TEST
if(autoset_access && length(req_access))
PRINT_STACK_TRACE("A door with mapped access restrictions was set to autoinitialize access.")
Expand Down Expand Up @@ -254,15 +253,15 @@
if(reason_broken & MACHINE_BROKEN_GENERIC)
to_chat(user, "<span class='notice'>It looks like \the [src] is pretty busted. It's going to need more than just patching up now.</span>")
return TRUE
if(health >= maxhealth)
if(health >= max_health)
to_chat(user, "<span class='notice'>Nothing to fix!</span>")
return TRUE
if(!density)
to_chat(user, "<span class='warning'>\The [src] must be closed before you can repair it.</span>")
return TRUE

//figure out how much metal we need
var/amount_needed = (maxhealth - health) / DOOR_REPAIR_AMOUNT
var/amount_needed = (max_health - health) / DOOR_REPAIR_AMOUNT
amount_needed = CEILING(amount_needed)

var/obj/item/stack/stack = I
Expand Down Expand Up @@ -294,7 +293,7 @@
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(do_after(user, 5 * repairing.amount, src) && welder && welder.isOn())
to_chat(user, "<span class='notice'>You finish repairing the damage to \the [src].</span>")
health = clamp(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, maxhealth)
health = clamp(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, max_health)
update_icon()
qdel(repairing)
repairing = null
Expand Down Expand Up @@ -349,33 +348,33 @@
if(health <= 0 && initialhealth > 0)
visible_message(SPAN_WARNING("\The [src] breaks down!"))
set_broken(TRUE)
else if(health < maxhealth / 4 && initialhealth >= maxhealth / 4)
else if(health < max_health / 4 && initialhealth >= max_health / 4)
visible_message(SPAN_WARNING("\The [src] looks like it's about to break!"))
else if(health < maxhealth / 2 && initialhealth >= maxhealth / 2)
else if(health < max_health / 2 && initialhealth >= max_health / 2)
visible_message(SPAN_WARNING("\The [src] looks seriously damaged!"))
else if(health < maxhealth * 3/4 && initialhealth >= maxhealth * 3/4)
else if(health < max_health * 3/4 && initialhealth >= max_health * 3/4)
visible_message(SPAN_WARNING("\The [src] shows signs of damage!"))

..(component_damage, damtype)
update_icon()

//How much damage should be passed to components inside even when door health is non zero
/obj/machinery/door/proc/get_damage_leakthrough(var/damage, damtype=BRUTE)
if(health > 0.75 * maxhealth && damage < 10)
if(health > 0.75 * max_health && damage < 10)
return 0
. = round((1 - health/maxhealth) * damage)
. = round((1 - health/max_health) * damage)

/obj/machinery/door/examine(mob/user)
. = ..()
if(src.health <= 0)
to_chat(user, "\The [src] is broken!")
else if(src.health < src.maxhealth / 4)
else if(src.health < src.max_health / 4)
to_chat(user, "\The [src] looks like it's about to break!")
else if(src.health < src.maxhealth / 2)
else if(src.health < src.max_health / 2)
to_chat(user, "\The [src] looks seriously damaged!")
else if(src.health < src.maxhealth * 3/4)
else if(src.health < src.max_health * 3/4)
to_chat(user, "\The [src] shows signs of damage!")
else if(src.health < src.maxhealth && get_dist(src, user) <= 1)
else if(src.health < src.max_health && get_dist(src, user) <= 1)
to_chat(user, "\The [src] has some minor scuffing.")

var/mob/living/carbon/human/H = user
Expand Down Expand Up @@ -502,7 +501,7 @@
dismantle(TRUE)

/obj/machinery/door/proc/CheckPenetration(var/base_chance, var/damage)
. = damage/maxhealth*180
. = damage/max_health*180
if(glass)
. *= 2
. = round(.)
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ About the new airlock wires panel:

if(stat & BROKEN)
damage_overlay = sparks_broken_file
else if(health < maxhealth * 3/4)
else if(health < max_health * 3/4)
damage_overlay = sparks_damaged_file

if(welded)
Expand Down Expand Up @@ -767,7 +767,7 @@ About the new airlock wires panel:
return TRUE
else if(!repairing)
// Add some minor damage as evidence of forcing.
if(health >= maxhealth)
if(health >= max_health)
take_damage(1)
if(arePowerSystemsOn())
to_chat(user, SPAN_WARNING("The airlock's motors resist your efforts to force it."))
Expand Down Expand Up @@ -1027,7 +1027,7 @@ About the new airlock wires panel:
glass = TRUE
set_opacity(0)
hitsound = 'sound/effects/Glasshit.ogg'
maxhealth = 300
max_health = 300
explosion_resistance = 5
else
door_color = mat.color
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/airlock_subtypes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
name = "Glass Airlock"
icon_state = "preview_glass"
hitsound = 'sound/effects/Glasshit.ogg'
maxhealth = 300
max_health = 300
explosion_resistance = 5
opacity = FALSE
glass = TRUE
Expand Down Expand Up @@ -193,7 +193,7 @@
opacity = FALSE

/obj/machinery/door/airlock/external/glass
maxhealth = 300
max_health = 300
explosion_resistance = 5
opacity = FALSE
glass = TRUE
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/doors/blast_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
to_chat(user, "<span class='notice'>[src]'s motors resist your effort.</span>")
return
if(istype(C, /obj/item/stack/material) && C.get_material_type() == /decl/material/solid/metal/plasteel)
var/amt = CEILING((maxhealth - health)/150)
var/amt = CEILING((max_health - health)/150)
if(!amt)
to_chat(user, "<span class='notice'>\The [src] is already fully functional.</span>")
return
Expand Down Expand Up @@ -209,7 +209,7 @@
// Parameters: None
// Description: Fully repairs the blast door.
/obj/machinery/door/blast/proc/repair()
health = maxhealth
health = max_health
set_broken(FALSE)
queue_icon_update()

Expand Down Expand Up @@ -312,7 +312,7 @@
icon_state_closed_broken = "closed_broken"

min_force = 30
maxhealth = 1000
max_health = 1000
block_air_zones = 1

var/icon_lower_door_open = "open_bottom"
Expand Down Expand Up @@ -354,7 +354,7 @@
open_sound = 'sound/machines/shutters_open.ogg'
close_sound = 'sound/machines/shutters_close.ogg'
min_force = 15
maxhealth = 500
max_health = 500
explosion_resistance = 10
pry_mod = 0.55
frame_type = /obj/structure/door_assembly/blast/shutter
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
icon_state = "left"
min_force = 4
hitsound = 'sound/effects/Glasshit.ogg'
maxhealth = 150 //If you change this, consiter changing ../door/window/brigdoor/ health at the bottom of this .dm file
max_health = 150 //If you change this, consiter changing ../door/window/brigdoor/ health at the bottom of this .dm file
health = 150
visible = 0.0
use_power = POWER_USE_OFF
Expand Down Expand Up @@ -212,7 +212,7 @@
icon = 'icons/obj/doors/windoor.dmi'
icon_state = "leftsecure"
base_state = "leftsecure"
maxhealth = 300
max_health = 300
health = 300.0 //Stronger doors for prison (regular window door health is 150)
pry_mod = 0.65

Expand Down
9 changes: 4 additions & 5 deletions code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
idle_power_usage = 50 //when inactive, this turret takes up constant 50 Equipment power
active_power_usage = 300 //when active, this turret takes up constant 300 Equipment power
power_channel = EQUIP //drains power from the EQUIPMENT channel
max_health = 80

var/raised = 0 //if the turret cover is "open" and the turret is raised
var/raising= 0 //if the turret is currently opening or closing its cover
var/health = 80 //the turret's health
var/maxhealth = 80 //turrets maximal health.
var/auto_repair = 0 //if 1 the turret slowly repairs itself.
var/locked = 1 //if the turret's behaviour control access is locked
var/controllock = 0 //if the turret responds to control panels
Expand Down Expand Up @@ -80,7 +79,7 @@
ailock = 0
malf_upgraded = 1
to_chat(user, "\The [src] has been upgraded. It's damage and rate of fire has been increased. Auto-regeneration system has been enabled. Power usage has increased.")
maxhealth = round(initial(maxhealth) * 1.5)
max_health = round(initial(max_health) * 1.5)
shot_delay = round(initial(shot_delay) / 2)
auto_repair = 1
change_power_consumption(round(initial(active_power_usage) * 5), POWER_USE_ACTIVE)
Expand Down Expand Up @@ -415,9 +414,9 @@ var/global/list/turret_icons
if(!tryToShootAt(secondarytargets)) // if no valid targets, go for secondary targets
popDown() // no valid targets, close the cover

if(auto_repair && (health < maxhealth))
if(auto_repair && (health < max_health))
use_power_oneoff(20000)
health = min(health+1, maxhealth) // 1HP for 20kJ
health = min(health+1, max_health) // 1HP for 20kJ

/obj/machinery/porta_turret/proc/assess_and_assign(var/mob/living/L, var/list/targets, var/list/secondarytargets)
switch(assess_living(L))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/decals/posters/_poster.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
anchored = TRUE
directional_offset = "{'NORTH':{'y':32}, 'SOUTH':{'y':-32}, 'EAST':{'x':32}, 'WEST':{'x':-32}}"
material = /decl/material/solid/organic/paper
maxhealth = 10
max_health = 10
parts_type = /obj/item/poster
parts_amount = 1

Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/effects/spiders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
icon = 'icons/effects/effects.dmi'
anchored = TRUE
density = FALSE
var/health = 15
max_health = 15

//similar to weeds, but only barfed out by nurses manually
/obj/effect/spider/explosion_act(severity)
Expand Down Expand Up @@ -143,7 +143,7 @@
icon_state = "lesser"
anchored = FALSE
layer = BELOW_OBJ_LAYER
health = 3
max_health = 3
var/mob/living/simple_animal/hostile/giant_spider/greater_form
var/last_itch = 0
var/amount_grown = -1
Expand Down Expand Up @@ -334,7 +334,7 @@
name = "cocoon"
desc = "Something wrapped in silky spider web."
icon_state = "cocoon1"
health = 60
max_health = 60

/obj/effect/spider/cocoon/Initialize()
. = ..()
Expand Down
4 changes: 1 addition & 3 deletions code/game/objects/item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

var/image/blood_overlay = null //this saves our blood splatter overlay, which will be processed not to go over the edges of the sprite
var/randpixel = 6
var/health
var/max_health
var/material_health_multiplier = 0.2
var/hitsound
var/slot_flags = 0 //This is used to determine on which slots an item can fit.
Expand Down Expand Up @@ -208,7 +206,7 @@
var/desc_comp = "" //For "description composite"
desc_comp += "It is a [w_class_description()] item.<BR>"

var/desc_damage = get_examined_damage_string(health / max_health)
var/desc_damage = get_examined_damage_string()
if(length(desc_damage))
desc_comp += "[desc_damage]<BR>"

Expand Down
Loading