Makes obj_integrity only updated through procs (#59474)

Having things updating integrity directly is just going to cause more problems down the line as more elements and components depend on being notified of integrity changes. It's an easy mistake to make so making it private should deal with the problem.

get_integrity() might be useful in the future but is mainly a side effect of making obj_integrity private as that also disallows reads.
This commit is contained in:
Emmett Gaines
2021-06-04 11:48:05 -03:00
committed by GitHub
parent cf937160de
commit 43c5dc8bfa
49 changed files with 133 additions and 97 deletions
+4
View File
@@ -695,6 +695,8 @@
#define COMSIG_OBJ_TAKE_DAMAGE "obj_take_damage"
/// Return bitflags for the above signal which prevents the object taking any damage.
#define COMPONENT_NO_TAKE_DAMAGE (1<<0)
///from base of [/obj/proc/update_integrity]: ()
#define COMSIG_OBJ_INTEGRITY_CHANGED "obj_integrity_changed"
///from base of obj/deconstruct(): (disassembled)
#define COMSIG_OBJ_DECONSTRUCT "obj_deconstruct"
///from base of code/game/machinery
@@ -705,6 +707,8 @@
#define COMSIG_OBJ_PAINTED "obj_painted"
/// from /obj/proc/obj_break: ()
#define COMSIG_OBJ_BREAK "obj_break"
/// from base of [/obj/proc/obj_fix]: ()
#define COMSIG_OBJ_FIX "obj_fix"
// /obj/machinery signals
+2 -2
View File
@@ -56,7 +56,7 @@
else if(isobj(parent))
var/obj/O = parent
integrity = O.obj_integrity
integrity = O.get_integrity()
rewind_type = .proc/rewind_obj
addtimer(CALLBACK(src, rewind_type), rewind_interval)
@@ -107,5 +107,5 @@
/datum/component/dejavu/proc/rewind_obj()
var/obj/master = parent
master.obj_integrity = integrity
master.update_integrity(integrity)
rewind()
+3 -2
View File
@@ -72,10 +72,11 @@
return process_machine(master, airs)
/datum/component/gas_leaker/proc/process_leak(obj/master, list/airs)
if(master.obj_integrity > master.max_integrity * integrity_leak_percent)
var/current_integrity = master.get_integrity()
if(current_integrity > master.max_integrity * integrity_leak_percent)
return PROCESS_KILL
var/turf/location = get_turf(master)
var/true_rate = (1 - (master.obj_integrity / master.max_integrity)) * leak_rate
var/true_rate = (1 - (current_integrity / master.max_integrity)) * leak_rate
for(var/datum/gas_mixture/mix as anything in airs)
var/pressure = mix.return_pressure()
if(mix.release_gas_to(location.return_air(), pressure, true_rate))
+1 -1
View File
@@ -48,7 +48,7 @@
var/mult = 1
if(isobj(source))
var/obj/art_piece = source
mult = art_piece.obj_integrity/art_piece.max_integrity
mult = art_piece.get_integrity() / art_piece.max_integrity
apply_moodlet(source, user, impressiveness * mult)
+2 -3
View File
@@ -22,7 +22,7 @@
rate = _rate
RegisterSignal(target, COMSIG_OBJ_TAKE_DAMAGE, .proc/on_take_damage)
if(target.obj_integrity < target.max_integrity)
if(target.get_integrity() < target.max_integrity)
if(!length(processing))
START_PROCESSING(SSobj, src)
processing |= target
@@ -73,8 +73,7 @@
return
continue
regen_obj.obj_integrity = clamp(regen_obj.obj_integrity + (regen_obj.max_integrity * cached_rate), 0, regen_obj.max_integrity)
if(regen_obj.obj_integrity == regen_obj.max_integrity)
if(!regen_obj.repair_damage(regen_obj.max_integrity * cached_rate))
processing -= regen_obj
if(!length(processing))
STOP_PROCESSING(SSobj, src)
+1 -1
View File
@@ -568,7 +568,7 @@
. = new_frame
new_frame.set_anchored(anchored)
if(!disassembled)
new_frame.obj_integrity = new_frame.max_integrity * 0.5 //the frame is already half broken
new_frame.update_integrity(new_frame.max_integrity * 0.5) //the frame is already half broken
transfer_fingerprints_to(new_frame)
-1
View File
@@ -5,7 +5,6 @@
icon_state = "pdapainter"
base_icon_state = "pdapainter"
density = TRUE
obj_integrity = 200
max_integrity = 200
var/obj/item/bodypart/storedpart
var/static/list/style_list_icons = list("standard" = 'icons/mob/augmentation/augments.dmi', "engineer" = 'icons/mob/augmentation/augments_engineer.dmi', "security" = 'icons/mob/augmentation/augments_security.dmi', "mining" = 'icons/mob/augmentation/augments_mining.dmi')
+1 -1
View File
@@ -372,7 +372,7 @@
assembly = null
else
var/obj/item/I = new /obj/item/wallframe/camera (loc)
I.obj_integrity = I.max_integrity * 0.5
I.update_integrity(I.max_integrity * 0.5)
new /obj/item/stack/cable_coil(loc, 2)
qdel(src)
+1 -2
View File
@@ -1368,8 +1368,7 @@
A.update_appearance()
if(!disassembled)
if(A)
A.obj_integrity = A.max_integrity * 0.5
A?.update_integrity(A.max_integrity * 0.5)
else if(obj_flags & EMAGGED)
if(user)
to_chat(user, "<span class='warning'>You discard the damaged electronics.</span>")
+1 -1
View File
@@ -233,7 +233,7 @@
F.constructionStep = CONSTRUCTION_PANEL_OPEN
else
F.constructionStep = CONSTRUCTION_NO_CIRCUIT
F.obj_integrity = F.max_integrity * 0.5
F.update_integrity(F.max_integrity * 0.5)
F.update_appearance()
else
new /obj/item/electronics/firelock (T)
+2 -2
View File
@@ -51,7 +51,7 @@
update_appearance()
myarea = get_area(src)
LAZYADD(myarea.firealarms, src)
AddElement(/datum/element/atmos_sensitive, mapload)
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_security_level)
@@ -336,7 +336,7 @@
if(!(machine_stat & BROKEN))
var/obj/item/I = new /obj/item/electronics/firealarm(loc)
if(!disassembled)
I.obj_integrity = I.max_integrity * 0.5
I.update_integrity(I.max_integrity * 0.5)
new /obj/item/stack/cable_coil(loc, 3)
qdel(src)
+1 -1
View File
@@ -96,7 +96,7 @@
var/obj/machinery/power/supermatter_crystal/S = attached_to
if(!istype(S))
return
return "<div align='center' valign='middle' style='position:relative; top:0px; left:0px'>[round(S.get_integrity(), 1)]%</div>"
return "<div align='center' valign='middle' style='position:relative; top:0px; left:0px'>[round(S.get_integrity_percent(), 1)]%</div>"
/obj/effect/countdown/transformer
name = "transformer countdown"
@@ -7,7 +7,6 @@
flags_1 = CONDUCT_1
resistance_flags = FIRE_PROOF | UNACIDABLE
w_class = WEIGHT_CLASS_NORMAL
obj_integrity = 300
max_integrity = 300
inhand_icon_state = "reverse_bear_trap"
lefthand_file = 'icons/mob/inhands/items_lefthand.dmi'
+37 -3
View File
@@ -1,5 +1,5 @@
///the essential proc to call when an obj must receive damage of any kind.
/// The essential proc to call when an obj must receive damage of any kind.
/obj/proc/take_damage(damage_amount, damage_type = BRUTE, damage_flag = "", sound_effect = TRUE, attack_dir, armour_penetration = 0)
if(QDELETED(src))
stack_trace("[src] taking damage after deletion")
@@ -15,14 +15,43 @@
return
. = damage_amount
obj_integrity = max(obj_integrity - damage_amount, 0)
update_integrity(obj_integrity - damage_amount)
//BREAKING FIRST
if(integrity_failure && obj_integrity <= integrity_failure * max_integrity)
obj_break(damage_flag)
//DESTROYING SECOND
if(obj_integrity <= 0)
obj_destruction(damage_flag)
/// Proc for recovering obj_integrity. Returns the amount repaired by
/obj/proc/repair_damage(amount)
if(amount <= 0) // We only recover here
return
var/new_integrity = min(max_integrity, obj_integrity + amount)
. = new_integrity - obj_integrity
update_integrity(new_integrity)
if(integrity_failure && obj_integrity > integrity_failure * max_integrity)
obj_fix()
/// Handles the integrity of an object changing. This must be called instead of changing integrity directly.
/obj/proc/update_integrity(new_value)
SHOULD_NOT_OVERRIDE(TRUE)
new_value = max(0, new_value)
if(obj_integrity == new_value)
return
obj_integrity = new_value
SEND_SIGNAL(src, COMSIG_OBJ_INTEGRITY_CHANGED)
/// This mostly exists to keep obj_integrity private. Might be useful in the future.
/obj/proc/get_integrity()
SHOULD_BE_PURE(TRUE)
return obj_integrity
///returns the damage value of the attack after processing the obj's various armor protections
/obj/proc/run_obj_armor(damage_amount, damage_type, damage_flag = 0, attack_dir, armour_penetration = 0)
if(damage_flag == MELEE && damage_amount < damage_deflection)
@@ -223,11 +252,16 @@ GLOBAL_DATUM_INIT(acid_overlay, /mutable_appearance, mutable_appearance('icons/e
SEND_SIGNAL(src, COMSIG_OBJ_DECONSTRUCT, disassembled)
qdel(src)
///called after the obj takes damage and integrity is below integrity_failure level
/// Called after the obj takes damage and integrity is below integrity_failure level
/obj/proc/obj_break(damage_flag)
SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(src, COMSIG_OBJ_BREAK)
/// Called when integrity is repaired above the breaking point having been broken before
/obj/proc/obj_fix()
SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(src, COMSIG_OBJ_FIX)
///what happens when the obj's integrity reaches zero.
/obj/proc/obj_destruction(damage_flag)
if(damage_flag == ACID)
+2 -3
View File
@@ -14,7 +14,7 @@
var/bare_wound_bonus = 0
var/datum/armor/armor
var/obj_integrity //defaults to max_integrity
VAR_PRIVATE/obj_integrity //defaults to max_integrity
var/max_integrity = 500
var/integrity_failure = 0 //0 if we have no special broken behavior, otherwise is a percentage of at what point the obj breaks. 0.5 being 50%
///Damage under this value will be completely ignored
@@ -59,8 +59,7 @@
armor = getArmor()
else if (!istype(armor, /datum/armor))
stack_trace("Invalid type [armor.type] found in .armor during /obj Initialize()")
if(obj_integrity == null)
obj_integrity = max_integrity
obj_integrity = max_integrity
. = ..() //Do this after, else mat datums is mad.
+4 -1
View File
@@ -334,7 +334,10 @@
/obj/structure/grille/broken // Pre-broken grilles for map placement
icon_state = "brokengrille"
density = FALSE
obj_integrity = 20
broken = TRUE
rods_amount = 1
rods_broken = FALSE
/obj/structure/grille/broken/Initialize(mapload)
. = ..()
take_damage(max_integrity * 0.6)
@@ -53,7 +53,7 @@
unwrenched_plaque.desc = desc
unwrenched_plaque.engraved = engraved
unwrenched_plaque.icon_state = icon_state
unwrenched_plaque.obj_integrity = obj_integrity
unwrenched_plaque.update_integrity(get_integrity())
unwrenched_plaque.setDir(dir)
qdel(src) //The plaque structure on the wall goes poof and only the plaque item from unwrenching remains.
return TRUE
@@ -183,6 +183,6 @@
placed_plaque.desc = desc
placed_plaque.engraved = engraved
placed_plaque.icon_state = icon_state
placed_plaque.obj_integrity = obj_integrity
placed_plaque.update_integrity(get_integrity())
placed_plaque.setDir(dir)
qdel(src)
+2 -2
View File
@@ -88,7 +88,7 @@
unwrenched_sign.sign_path = type
unwrenched_sign.set_custom_materials(custom_materials) //This is here so picture frames and wooden things don't get messed up.
unwrenched_sign.is_editable = is_editable
unwrenched_sign.obj_integrity = obj_integrity //Transfer how damaged it is.
unwrenched_sign.update_integrity(get_integrity()) //Transfer how damaged it is.
unwrenched_sign.setDir(dir)
qdel(src) //The sign structure on the wall goes poof and only the sign item from unwrenching remains.
return TRUE
@@ -206,7 +206,7 @@
user.visible_message("<span class='notice'>[user] fastens [src] to [target_turf].</span>", \
"<span class='notice'>You attach the sign to [target_turf].</span>")
playsound(target_turf, 'sound/items/deconstruct.ogg', 50, TRUE)
placed_sign.obj_integrity = obj_integrity
placed_sign.update_integrity(get_integrity())
placed_sign.setDir(dir)
qdel(src)
@@ -7,23 +7,23 @@ GLOBAL_LIST_INIT(valid_blobstrains, subtypesof(/datum/blobstrain) - list(/datum/
/// The color that stuff like healing effects and the overmind camera gets
var/complementary_color = COLOR_BLACK
/// A short description of the power and its effects
var/shortdesc = null
var/shortdesc = null
/// Any long, blob-tile specific effects
var/effectdesc = null
var/effectdesc = null
/// Short descriptor of what the strain does damage-wise, generally seen in the reroll menu
var/analyzerdescdamage = "Unknown. Report this bug to a coder, or just adminhelp."
/// Short descriptor of what the strain does in general, generally seen in the reroll menu
var/analyzerdesceffect
/// Blobbernaut attack verb
var/blobbernaut_message = "slams"
var/blobbernaut_message = "slams"
/// Message sent to any mob hit by the blob
var/message = "The blob strikes you"
var/message = "The blob strikes you"
/// Gets added onto 'message' if the mob stuck is of type living
var/message_living = null
/// Stores world.time to figure out when to next give resources
var/resource_delay = 0
/// For blob-mobs and extinguishing-based effects
var/fire_based = FALSE
var/fire_based = FALSE
var/mob/camera/blob/overmind
/// The amount of health regenned on core_process
var/base_core_regen = BLOB_CORE_HP_REGEN
@@ -93,8 +93,7 @@ GLOBAL_LIST_INIT(valid_blobstrains, subtypesof(/datum/blobstrain) - list(/datum/
F.max_spores += factory_spore_bonus
for(var/obj/structure/blob/B as anything in overmind.all_blobs)
B.max_integrity *= max_structure_health_multiplier
B.obj_integrity *= max_structure_health_multiplier
B.modify_max_integrity(B.max_integrity * max_structure_health_multiplier)
B.update_appearance()
for(var/mob/living/simple_animal/hostile/blob/BM as anything in overmind.blob_mobs)
@@ -125,13 +124,12 @@ GLOBAL_LIST_INIT(valid_blobstrains, subtypesof(/datum/blobstrain) - list(/datum/
F.max_spores -= factory_spore_bonus
for(var/obj/structure/blob/B as anything in overmind.all_blobs)
B.max_integrity /= max_structure_health_multiplier
B.obj_integrity /= max_structure_health_multiplier
B.modify_max_integrity(B.max_integrity / max_structure_health_multiplier)
for(var/mob/living/simple_animal/hostile/blob/BM as anything in overmind.blob_mobs)
BM.maxHealth /= max_mob_health_multiplier
BM.health /= max_mob_health_multiplier
/datum/blobstrain/proc/on_sporedeath(mob/living/spore)
@@ -146,7 +144,7 @@ GLOBAL_LIST_INIT(valid_blobstrains, subtypesof(/datum/blobstrain) - list(/datum/
if(resource_delay <= world.time)
resource_delay = world.time + 10 // 1 second
overmind.add_points(point_rate+point_rate_bonus)
overmind.blob_core.obj_integrity = min(overmind.blob_core.max_integrity, overmind.blob_core.obj_integrity+base_core_regen+core_regen_bonus)
overmind.blob_core.repair_damage(base_core_regen + core_regen_bonus)
/datum/blobstrain/proc/attack_living(mob/living/L, list/nearby_blobs) // When the blob attacks people
send_message(L)
@@ -12,7 +12,7 @@
reagent = /datum/reagent/blob/distributed_neurons
/datum/blobstrain/reagent/distributed_neurons/damage_reaction(obj/structure/blob/B, damage, damage_type, damage_flag)
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && damage <= 20 && B.obj_integrity - damage <= 0 && prob(15)) //if the cause isn't fire or a bomb, the damage is less than 21, we're going to die from that damage, 15% chance of a shitty spore.
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && damage <= 20 && B.get_integrity() - damage <= 0 && prob(15)) //if the cause isn't fire or a bomb, the damage is less than 21, we're going to die from that damage, 15% chance of a shitty spore.
B.visible_message("<span class='warning'><b>A spore floats free of the blob!</b></span>")
var/mob/living/simple_animal/hostile/blob/blobspore/weak/BS = new/mob/living/simple_animal/hostile/blob/blobspore/weak(B.loc)
BS.overmind = B.overmind
@@ -10,7 +10,7 @@
reagent = /datum/reagent/blob/energized_jelly
/datum/blobstrain/reagent/energized_jelly/damage_reaction(obj/structure/blob/B, damage, damage_type, damage_flag)
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && B.obj_integrity - damage <= 0 && prob(10))
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && B.get_integrity() - damage <= 0 && prob(10))
do_sparks(rand(2, 4), FALSE, B)
return ..()
@@ -13,18 +13,18 @@
COOLDOWN_DECLARE(retaliate_cooldown)
/datum/blobstrain/reagent/reactive_spines/damage_reaction(obj/structure/blob/B, damage, damage_type, damage_flag)
if(damage && ((damage_type == BRUTE) || (damage_type == BURN)) && B.obj_integrity - damage > 0 && COOLDOWN_FINISHED(src, retaliate_cooldown)) // Is there any damage, is it burn or brute, will we be alive, and has the cooldown finished?
if(damage && ((damage_type == BRUTE) || (damage_type == BURN)) && B.get_integrity() - damage > 0 && COOLDOWN_FINISHED(src, retaliate_cooldown)) // Is there any damage, is it burn or brute, will we be alive, and has the cooldown finished?
COOLDOWN_START(src, retaliate_cooldown, 2.5 SECONDS) // 2.5 seconds before auto-retaliate can whack everything within 1 tile again
B.visible_message("<span class='boldwarning'>The blob retaliates, lashing out!</span>")
for(var/atom/A in range(1, B))
var/attacked_turf = get_turf(A)
if(isliving(A) && !isblobmonster(A)) // Make sure to inject strain-reagents with automatic attacks when needed.
if(isliving(A) && !isblobmonster(A)) // Make sure to inject strain-reagents with automatic attacks when needed.
B.blob_attack_animation(attacked_turf, overmind)
attack_living(A)
else if(A.blob_act(B)) // After checking for mobs, whack everything else with the standard attack
B.blob_attack_animation(attacked_turf, overmind) // Only play the animation if the attack did something meaningful
return ..()
/datum/reagent/blob/reactive_spines
@@ -13,10 +13,10 @@
/datum/blobstrain/reagent/replicating_foam/damage_reaction(obj/structure/blob/B, damage, damage_type, damage_flag)
if(damage_type == BRUTE)
damage = damage * 2
else if(damage_type == BURN && damage > 0 && B.obj_integrity - damage > 0 && prob(60))
else if(damage_type == BURN && damage > 0 && B.get_integrity() - damage > 0 && prob(60))
var/obj/structure/blob/newB = B.expand(null, null, 0)
if(newB)
newB.obj_integrity = B.obj_integrity - damage
newB.update_integrity(B.get_integrity() - damage)
newB.update_appearance()
return ..()
@@ -15,7 +15,7 @@
B.forceMove(T)
/datum/blobstrain/reagent/shifting_fragments/damage_reaction(obj/structure/blob/B, damage, damage_type, damage_flag)
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && damage > 0 && B.obj_integrity - damage > 0 && prob(60-damage))
if((damage_flag == MELEE || damage_flag == BULLET || damage_flag == LASER) && damage > 0 && B.get_integrity() - damage > 0 && prob(60-damage))
var/list/blobstopick = list()
for(var/obj/structure/blob/OB in orange(1, B))
if((istype(OB, /obj/structure/blob/normal) || (istype(OB, /obj/structure/blob/shield) && prob(25))) && OB.overmind && OB.overmind.blobstrain.type == B.overmind.blobstrain.type)
+2 -2
View File
@@ -222,7 +222,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
/mob/camera/blob/update_health_hud()
if(blob_core)
var/current_health = round((blob_core.obj_integrity / blob_core.max_integrity) * 100)
var/current_health = round((blob_core.get_integrity() / blob_core.max_integrity) * 100)
hud_used.healths.maptext = MAPTEXT("<div align='center' valign='middle' style='position:relative; top:0px; left:6px'><font color='#82ed00'>[current_health]%</font></div>")
for(var/mob/living/simple_animal/hostile/blob/blobbernaut/B in blob_mobs)
if(B.hud_used && B.hud_used.blobpwrdisplay)
@@ -273,7 +273,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
/mob/camera/blob/get_status_tab_items()
. = ..()
if(blob_core)
. += "Core Health: [blob_core.obj_integrity]"
. += "Core Health: [blob_core.get_integrity()]"
. += "Power Stored: [blob_points]/[max_blob_points]"
. += "Blobs to Win: [blobs_legit.len]/[blobwincount]"
if(free_strain_rerolls)
+3 -4
View File
@@ -116,7 +116,7 @@
if(S)
if(!can_buy(BLOB_UPGRADE_REFLECTOR_COST))
return
if(S.obj_integrity < S.max_integrity * 0.5)
if(S.get_integrity() < S.max_integrity * 0.5)
add_points(BLOB_UPGRADE_REFLECTOR_COST)
to_chat(src, "<span class='warning'>This shield blob is too damaged to be modified properly!</span>")
return
@@ -134,7 +134,7 @@
if(B.naut) //if it already made a blobbernaut, it can't do it again
to_chat(src, "<span class='warning'>This factory blob is already sustaining a blobbernaut.</span>")
return
if(B.obj_integrity < B.max_integrity * 0.5)
if(B.get_integrity() < B.max_integrity * 0.5)
to_chat(src, "<span class='warning'>This factory blob is too damaged to sustain a blobbernaut.</span>")
return
if(!can_buy(BLOBMOB_BLOBBERNAUT_RESOURCE_COST))
@@ -144,8 +144,7 @@
to_chat(src, "<span class='notice'>You attempt to produce a blobbernaut.</span>")
var/list/mob/dead/observer/candidates = pollGhostCandidates("Do you want to play as a [blobstrain.name] blobbernaut?", ROLE_BLOB, ROLE_BLOB, 50) //players must answer rapidly
if(LAZYLEN(candidates)) //if we got at least one candidate, they're a blobbernaut now.
B.max_integrity = initial(B.max_integrity) * 0.25 //factories that produced a blobbernaut have much lower health
B.obj_integrity = min(B.obj_integrity, B.max_integrity)
B.modify_max_integrity(initial(B.max_integrity) * 0.25) //factories that produced a blobbernaut have much lower health
B.update_appearance()
B.visible_message("<span class='warning'><b>The blobbernaut [pick("rips", "tears", "shreds")] its way out of the factory blob!</b></span>")
playsound(B.loc, 'sound/effects/splat.ogg', 50, TRUE)
@@ -817,7 +817,7 @@ GLOBAL_LIST_INIT(malf_modules, subtypesof(/datum/ai_module))
/datum/ai_module/upgrade/upgrade_turrets/upgrade(mob/living/silicon/ai/AI)
for(var/obj/machinery/porta_turret/ai/turret in GLOB.machines)
turret.obj_integrity += 30
turret.repair_damage(30)
turret.lethal_projectile = /obj/projectile/beam/laser/heavylaser //Once you see it, you will know what it means to FEAR.
turret.lethal_projectile_sound = 'sound/weapons/lasercannonfire.ogg'
@@ -880,7 +880,7 @@
new /obj/item/stack/sheet/iron(loc, 2)
var/obj/item/I = new /obj/item/electronics/airalarm(loc)
if(!disassembled)
I.obj_integrity = I.max_integrity * 0.5
I.take_damage(I.max_integrity * 0.5, sound_effect=FALSE)
new /obj/item/stack/cable_coil(loc, 3)
qdel(src)
@@ -417,7 +417,7 @@
var/obj/item/pipe/stored = new construction_type(loc, null, dir, src, pipe_color)
stored.setPipingLayer(piping_layer)
if(!disassembled)
stored.obj_integrity = stored.max_integrity * 0.5
stored.take_damage(stored.max_integrity * 0.5, sound_effect=FALSE)
transfer_fingerprints_to(stored)
. = stored
..()
@@ -259,7 +259,7 @@
data["power_level"] = connected_core.power_level
data["iron_content"] = connected_core.iron_content
data["integrity"] = connected_core.get_integrity()
data["integrity"] = connected_core.get_integrity_percent()
data["start_power"] = connected_core.start_power
data["start_cooling"] = connected_core.start_cooling
@@ -204,7 +204,7 @@
* Check the integrity level and returns the status of the machine
*/
/obj/machinery/atmospherics/components/unary/hypertorus/core/proc/get_status()
var/integrity = get_integrity()
var/integrity = get_integrity_percent()
if(integrity < HYPERTORUS_MELTING_PERCENT)
return HYPERTORUS_MELTING
@@ -239,7 +239,7 @@
/**
* Getter for the machine integrity
*/
/obj/machinery/atmospherics/components/unary/hypertorus/core/proc/get_integrity()
/obj/machinery/atmospherics/components/unary/hypertorus/core/proc/get_integrity_percent()
var/integrity = critical_threshold_proximity / melting_point
integrity = round(100 - integrity * 100, 0.01)
integrity = integrity < 0 ? 0 : integrity
@@ -257,18 +257,18 @@
alarm()
if(critical_threshold_proximity > emergency_point)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity()]%", common_channel)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity_percent()]%", common_channel)
lastwarning = REALTIMEOFDAY
if(!has_reached_emergency)
investigate_log("has reached the emergency point for the first time.", INVESTIGATE_HYPERTORUS)
message_admins("[src] has reached the emergency point [ADMIN_JMP(src)].")
has_reached_emergency = TRUE
else if(critical_threshold_proximity >= critical_threshold_proximity_archived) // The damage is still going up
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
lastwarning = REALTIMEOFDAY - (WARNING_TIME_DELAY * 5)
else // Phew, we're safe
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
lastwarning = REALTIMEOFDAY
//Melt
@@ -453,7 +453,7 @@
continue
if(isstructure(atm))
var/obj/structure/S = atm
S.obj_integrity = S.max_integrity
S.repair_damage(S.max_integrity - S.get_integrity())
else if(!is_type_in_typecache(atm, ctf_object_typecache))
qdel(atm)
+1 -2
View File
@@ -291,8 +291,7 @@
/datum/spacevine_mutation/woodening/on_grow(obj/structure/spacevine/holder)
if(holder.energy)
holder.density = TRUE
holder.max_integrity = 100
holder.obj_integrity = holder.max_integrity
holder.modify_max_integrity(100)
/datum/spacevine_mutation/woodening/on_hit(obj/structure/spacevine/holder, mob/living/hitter, obj/item/I, expected_damage)
if(I?.get_sharpness())
@@ -57,7 +57,7 @@
if(controlled_drone)
.["drone_status"] = controlled_drone.drone_status
.["drone_name"] = controlled_drone.name
.["drone_integrity"] = controlled_drone.obj_integrity
.["drone_integrity"] = controlled_drone.get_integrity()
.["drone_max_integrity"] = controlled_drone.max_integrity
.["drone_log"] = controlled_drone.drone_log
.["configurable"] = controlled_drone.drone_status == EXODRONE_IDLE
+1 -1
View File
@@ -72,7 +72,7 @@
if(LAZYLEN(turrets))
for(var/turret in turrets)
var/obj/machinery/porta_turret/aux_base/base_turret = turret
var/turret_integrity = max((base_turret.obj_integrity - base_turret.integrity_failure * base_turret.max_integrity) / (base_turret.max_integrity - base_turret.integrity_failure * max_integrity) * 100, 0)
var/turret_integrity = max((base_turret.get_integrity() - base_turret.integrity_failure * base_turret.max_integrity) / (base_turret.max_integrity - base_turret.integrity_failure * max_integrity) * 100, 0)
var/turret_status
if(base_turret.machine_stat & BROKEN)
turret_status = "ERROR"
@@ -116,12 +116,12 @@
/mob/living/simple_animal/hostile/hivebot/mechanic/AttackingTarget()
if(istype(target, /obj/machinery))
var/obj/machinery/fixable = target
if(fixable.obj_integrity >= fixable.max_integrity)
if(fixable.get_integrity() >= fixable.max_integrity)
to_chat(src, "<span class='warning'>Diagnostics indicate that this machine is at peak integrity.</span>")
return
to_chat(src, "<span class='warning'>You begin repairs...</span>")
if(do_after(src, 50, target = fixable))
fixable.obj_integrity = fixable.max_integrity
fixable.repair_damage(fixable.max_integrity - fixable.get_integrity())
do_sparks(3, TRUE, fixable)
to_chat(src, "<span class='warning'>Repairs complete.</span>")
return
@@ -121,7 +121,7 @@
return FALSE
if(!M.has_charge(required_mecha_charge))
return FALSE
if(M.obj_integrity < M.max_integrity*0.5)
if(M.get_integrity() < M.max_integrity*0.5)
return FALSE
return TRUE
@@ -215,7 +215,7 @@
return
//Too Much Damage - Eject
if(mecha.obj_integrity < mecha.max_integrity*0.1)
if(mecha.get_integrity() < mecha.max_integrity*0.1)
exit_mecha(mecha)
return
@@ -226,7 +226,7 @@
action.Trigger()
//Heavy damage - Defense Power or Retreat
if(mecha.obj_integrity < mecha.max_integrity*0.25)
if(mecha.get_integrity() < mecha.max_integrity*0.25)
if(prob(defense_mode_chance))
if(LAZYACCESSASSOC(mecha.occupant_actions, src, /datum/action/vehicle/sealed/mecha/mech_defense_mode) && !mecha.defense_mode)
var/datum/action/action = mecha.occupant_actions[src][/datum/action/vehicle/sealed/mecha/mech_defense_mode]
@@ -33,7 +33,7 @@
hardware_flag = machinery_computer.hardware_flag
max_hardware_size = machinery_computer.max_hardware_size
steel_sheet_cost = machinery_computer.steel_sheet_cost
obj_integrity = machinery_computer.obj_integrity
update_integrity(machinery_computer.get_integrity())
max_integrity = machinery_computer.max_integrity
integrity_failure = machinery_computer.integrity_failure
base_active_power_usage = machinery_computer.base_active_power_usage
@@ -82,7 +82,7 @@
else
. += cpu.active_program?.program_icon_state || screen_icon_state_menu
if(cpu && cpu.obj_integrity <= cpu.integrity_failure * cpu.max_integrity)
if(cpu && cpu.get_integrity() <= cpu.integrity_failure * cpu.max_integrity)
. += "bsod"
. += "broken"
@@ -129,7 +129,7 @@
return
data["active"] = TRUE
data["SM_integrity"] = active.get_integrity()
data["SM_integrity"] = active.get_integrity_percent()
data["SM_power"] = active.power
data["SM_ambienttemp"] = air.temperature
data["SM_ambientpressure"] = air.return_pressure()
@@ -159,7 +159,7 @@
if(A)
SMS.Add(list(list(
"area_name" = A.name,
"integrity" = S.get_integrity(),
"integrity" = S.get_integrity_percent(),
"uid" = S.uid
)))
+1 -1
View File
@@ -587,7 +587,7 @@
newlight.setDir(src.dir)
newlight.stage = cur_stage
if(!disassembled)
newlight.obj_integrity = newlight.max_integrity * 0.5
newlight.take_damage(newlight.max_integrity * 0.5, sound_effect=FALSE)
if(status != LIGHT_BROKEN)
break_light_tube()
if(status != LIGHT_EMPTY)
@@ -280,7 +280,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(!air)
return SUPERMATTER_ERROR
var/integrity = get_integrity()
var/integrity = get_integrity_percent()
if(integrity < SUPERMATTER_DELAM_PERCENT)
return SUPERMATTER_DELAMINATING
@@ -311,7 +311,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(SUPERMATTER_WARNING)
playsound(src, 'sound/machines/terminal_alert.ogg', 75)
/obj/machinery/power/supermatter_crystal/proc/get_integrity()
/obj/machinery/power/supermatter_crystal/proc/get_integrity_percent()
var/integrity = damage / explosion_point
integrity = round(100 - integrity * 100, 0.01)
integrity = integrity < 0 ? 0 : integrity
@@ -483,7 +483,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Check for holes in the SM inner chamber
for(var/turf/open/space/turf_to_check in RANGE_TURFS(1, loc))
if(LAZYLEN(turf_to_check.atmos_adjacent_turfs))
var/integrity = get_integrity()
var/integrity = get_integrity_percent()
if(integrity < 10)
damage += clamp((power * 0.0005) * DAMAGE_INCREASE_MULTIPLIER, 0, MAX_SPACE_EXPOSURE_DAMAGE)
else if(integrity < 25)
@@ -720,7 +720,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Oh shit it's bad, time to freak out
if(damage > emergency_point)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity()]%", common_channel)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity_percent()]%", common_channel)
SEND_SIGNAL(src, COMSIG_SUPERMATTER_DELAM_ALARM)
lastwarning = REALTIMEOFDAY
if(!has_reached_emergency)
@@ -728,12 +728,12 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
message_admins("[src] has reached the emergency point [ADMIN_JMP(src)].")
has_reached_emergency = TRUE
else if(damage >= damage_archived) // The damage is still going up
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
SEND_SIGNAL(src, COMSIG_SUPERMATTER_DELAM_ALARM)
lastwarning = REALTIMEOFDAY - (WARNING_DELAY * 5)
else // Phew, we're safe
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
lastwarning = REALTIMEOFDAY
if(power > POWER_PENALTY_THRESHOLD)
@@ -783,8 +783,8 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(!blob || isspaceturf(loc)) //does nothing in space
return
playsound(get_turf(src), 'sound/effects/supermatter.ogg', 50, TRUE)
damage += blob.obj_integrity * 0.5 //take damage equal to 50% of remaining blob health before it tried to eat us
if(blob.obj_integrity > 100)
damage += blob.get_integrity() * 0.5 //take damage equal to 50% of remaining blob health before it tried to eat us
if(blob.get_integrity() > 100)
blob.visible_message("<span class='danger'>\The [blob] strikes at \the [src] and flinches away!</span>",
"<span class='hear'>You hear a loud crack as you are washed with a wave of heat.</span>")
blob.take_damage(100, BURN)
+1 -1
View File
@@ -151,7 +151,7 @@
statue.set_visuals(becoming_statue.appearance)
statue.forceMove(get_turf(becoming_statue))
becoming_statue.forceMove(statue)
statue.obj_integrity = becoming_statue.health
statue.update_integrity(becoming_statue.health)
RegisterSignal(becoming_statue, COMSIG_MOVABLE_MOVED, .proc/human_left_statue)
//somehow they used an exploit/teleportation to leave statue, lets clean up
@@ -140,7 +140,6 @@ own integrity back to max. Shield is automatically dropped if we run out of powe
invisibility = INVISIBILITY_MAXIMUM //no showing on right-click
pixel_y = 4
max_integrity = 10000
obj_integrity = 10000
anchored = TRUE
light_system = MOVABLE_LIGHT
light_range = MINIMUM_USEFUL_LIGHT_RANGE
@@ -253,8 +253,8 @@
chassis.clear_internal_damage(int_dam_flag)
repaired = TRUE
break
if(h_boost<0 || chassis.obj_integrity < chassis.max_integrity)
chassis.obj_integrity += min(h_boost, chassis.max_integrity-chassis.obj_integrity)
if(h_boost<0 || chassis.get_integrity() < chassis.max_integrity)
chassis.repair_damage(h_boost)
repaired = TRUE
if(repaired)
if(!chassis.use_power(energy_drain))
@@ -373,10 +373,10 @@
marktwo.dna_lock = markone.dna_lock
marktwo.mecha_flags = markone.mecha_flags
marktwo.strafe = markone.strafe
marktwo.obj_integrity = round((markone.obj_integrity / markone.max_integrity) * marktwo.obj_integrity) //Integ set to the same percentage integ as the old mecha, rounded to be whole number
//Integ set to the same percentage integ as the old mecha, rounded to be whole number
marktwo.update_integrity(round((markone.get_integrity() / markone.max_integrity) * marktwo.get_integrity()))
if(markone.name != initial(markone.name))
marktwo.name = markone.name
markone.wreckage = FALSE
qdel(markone)
playsound(get_turf(marktwo),'sound/items/ratchet.ogg',50,TRUE)
return
+1 -1
View File
@@ -110,7 +110,7 @@
if(recharge_port && !QDELETED(recharge_port))
data["recharge_port"] = list("mech" = null)
if(recharge_port.recharging_mech && !QDELETED(recharge_port.recharging_mech))
data["recharge_port"]["mech"] = list("health" = recharge_port.recharging_mech.obj_integrity, "maxhealth" = recharge_port.recharging_mech.max_integrity, "cell" = null, "name" = recharge_port.recharging_mech.name,)
data["recharge_port"]["mech"] = list("health" = recharge_port.recharging_mech.get_integrity(), "maxhealth" = recharge_port.recharging_mech.max_integrity, "cell" = null, "name" = recharge_port.recharging_mech.name,)
if(recharge_port.recharging_mech.cell && !QDELETED(recharge_port.recharging_mech.cell))
data["recharge_port"]["mech"]["cell"] = list(
"charge" = recharge_port.recharging_mech.cell.charge,
@@ -26,7 +26,7 @@
var/obj/vehicle/sealed/mecha/M = MT.chassis
var/list/mech_data = list(
name = M.name,
integrity = round((M.obj_integrity / M.max_integrity) * 100),
integrity = round((M.get_integrity() / M.max_integrity) * 100),
charge = M.cell ? round(M.cell.percent()) : null,
airtank = M.internal_tank ? M.return_pressure() : null,
pilot = M.return_drivers(),
@@ -94,7 +94,7 @@
var/cell_charge = chassis.get_charge()
var/answer = {"<b>Name:</b> [chassis.name]<br>
<b>Integrity:</b> [round((chassis.obj_integrity/chassis.max_integrity * 100), 0.01)]%<br>
<b>Integrity:</b> [round((chassis.get_integrity()/chassis.max_integrity * 100), 0.01)]%<br>
<b>Cell Charge:</b> [isnull(cell_charge) ? "Not Found":"[chassis.cell.percent()]%"]<br>
<b>Airtank:</b> [chassis.internal_tank ? "[round(chassis.return_pressure(), 0.01)]" : "Not Equipped"] kPa<br>
<b>Pilot:</b> [chassis.return_drivers() || "None"]<br>
@@ -117,7 +117,10 @@
/obj/vehicle/sealed/mecha/working/ripley/mining
desc = "An old, dusty mining Ripley."
name = "\improper APLU \"Miner\""
obj_integrity = 75 //Low starting health
/obj/vehicle/sealed/mecha/working/ripley/mining/Initialize()
. = ..()
take_damage(125) // Low starting health
/obj/vehicle/sealed/mecha/working/ripley/mining/Initialize()
. = ..()
@@ -147,7 +150,6 @@
icon_state = "hauler"
base_icon_state = "hauler"
max_equip = 2
obj_integrity = 50 //Low starting health
max_integrity = 100 //Has half the health of a normal RIPLEY mech, so it's harder to use as a weapon.
/obj/vehicle/sealed/mecha/working/ripley/cargo/Initialize()
@@ -159,6 +161,8 @@
var/obj/item/mecha_parts/mecha_equipment/hydraulic_clamp/HC = new
HC.attach(src)
take_damage(max_integrity * 0.5, sound_effect=FALSE) //Low starting health
/obj/vehicle/sealed/mecha/working/ripley/Exit(atom/movable/O)
if(O in cargo)
return FALSE