Skip to content

Commit

Permalink
Changes to atom integrity (#863)
Browse files Browse the repository at this point in the history
* more breakable shit

* fix
  • Loading branch information
Kapu1178 authored Mar 4, 2024
1 parent 2c20899 commit 259dcfd
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 21 deletions.
13 changes: 9 additions & 4 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
var/is_right_clicking = LAZYACCESS(params2list(params), RIGHT_CLICK)

if(tool_behaviour && (target.tool_act(user, src, tool_behaviour, is_right_clicking) & TOOL_ACT_MELEE_CHAIN_BLOCKING))
var/mob/living/L = user
if(tool_behaviour && (!istype(L) || !L.combat_mode) && (target.tool_act(user, src, tool_behaviour, is_right_clicking) & TOOL_ACT_MELEE_CHAIN_BLOCKING))
return TRUE

var/pre_attack_result
Expand Down Expand Up @@ -253,9 +254,13 @@
var/damage = take_damage(attacking_item.force, attacking_item.damtype, BLUNT, 1)

//only witnesses close by and the victim see a hit message.
user.visible_message(span_danger("[user] hits [src] with [attacking_item][damage ? "." : ", without leaving a mark!"]"), \
span_danger("You hit [src] with [attacking_item][damage ? "." : ", without leaving a mark!"]"), null, COMBAT_MESSAGE_RANGE)
log_combat(user, src, "attacked", attacking_item)
user.visible_message(
span_danger("[user] hits [src] with [attacking_item][damage ? "." : ", without leaving a mark."]"),
null,
COMBAT_MESSAGE_RANGE
)

log_combat(user, src, "attacked ([damage] damage)", attacking_item)

/area/attacked_by(obj/item/attacking_item, mob/living/user)
CRASH("areas are NOT supposed to have attacked_by() called on them!")
Expand Down
1 change: 1 addition & 0 deletions code/datums/components/acid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
/datum/component/acid/proc/process_obj(obj/target, delta_time)
if(target.resistance_flags & ACID_PROOF)
return

target.take_damage(min(1 + round(sqrt(acid_power * acid_volume)*0.3), OBJ_ACID_DAMAGE_MAX) * delta_time, BURN, ACID, 0)

/// Handles processing on a [/mob/living].
Expand Down
7 changes: 6 additions & 1 deletion code/game/atom_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
play_attack_sound(damage_amount, damage_type, damage_flag)
if(resistance_flags & INDESTRUCTIBLE)
return

damage_amount = run_atom_armor(damage_amount, damage_type, damage_flag, attack_dir, armor_penetration)
if(damage_amount < DAMAGE_PRECISION)
return

if(SEND_SIGNAL(src, COMSIG_ATOM_TAKE_DAMAGE, damage_amount, damage_type, damage_flag, sound_effect, attack_dir, armor_penetration) & COMPONENT_NO_TAKE_DAMAGE)
return

Expand Down Expand Up @@ -73,19 +75,22 @@
if(!uses_integrity)
CRASH("/atom/proc/run_atom_armor was called on [src] without being implemented as a type that uses integrity!")

if(damage_flag == BLUNT && damage_amount < damage_deflection)
if(damage_flag == BLUNT && (damage_amount < damage_deflection))
return 0

switch(damage_type)
if(BRUTE)
if(BURN)
else
return 0

var/armor_protection = 0
if(damage_flag)
armor_protection = returnArmor().getRating(damage_flag)

if(armor_protection) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
armor_protection = clamp(armor_protection - armor_penetration, min(armor_protection, 0), 100)

return round(damage_amount * (100 - armor_protection)*0.01, DAMAGE_PRECISION)

///the sound played when the atom is damaged.
Expand Down
28 changes: 26 additions & 2 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@
#define AIRLOCK_INTEGRITY_MULTIPLIER 1.5 // How much reinforced doors health increases
/// How much extra health airlocks get when braced with a seal
#define AIRLOCK_SEAL_MULTIPLIER 2
#define AIRLOCK_DAMAGE_DEFLECTION_N 21 // Normal airlock damage deflection
#define AIRLOCK_DAMAGE_DEFLECTION_R 30 // Reinforced airlock damage deflection

// Airlocks ignore damage below this value
#define AIRLOCK_DAMAGE_DEFLECTION_N (/obj/item/wrench::force)
/// Reinforced airlocks ignore damage below this value
#define AIRLOCK_DAMAGE_DEFLECTION_R (/obj/item/storage/toolbox::force)

#define AIRLOCK_DENY_ANIMATION_TIME (0.6 SECONDS) /// The amount of time for the airlock deny animation to show

Expand All @@ -91,12 +94,15 @@
desc = "An air-tight mechanical door."
icon = 'icons/obj/doors/airlocks/station/airlock.dmi'
icon_state = "closed"

max_integrity = 300

var/normal_integrity = AIRLOCK_INTEGRITY_N
integrity_failure = 0.25
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_N
autoclose = TRUE
secondsElectrified = MACHINE_NOT_ELECTRIFIED //How many seconds remain until the door is no longer electrified. -1/MACHINE_ELECTRIFIED_PERMANENT = permanently electrified until someone fixes it.

assemblytype = /obj/structure/door_assembly
normalspeed = 1
explosion_block = 1
Expand Down Expand Up @@ -166,14 +172,17 @@
wires = set_wires()
if(frequency)
set_frequency(frequency)

if(security_level > AIRLOCK_SECURITY_IRON)
atom_integrity = normal_integrity * AIRLOCK_INTEGRITY_MULTIPLIER
max_integrity = normal_integrity * AIRLOCK_INTEGRITY_MULTIPLIER
else
atom_integrity = normal_integrity
max_integrity = normal_integrity

if(damage_deflection == AIRLOCK_DAMAGE_DEFLECTION_N && security_level > AIRLOCK_SECURITY_IRON)
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_R

prepare_huds()
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
diag_hud.add_to_hud(src)
Expand Down Expand Up @@ -902,9 +911,14 @@

C.leave_evidence(user, src)

var/mob/living/L = user
if(L.combat_mode)
return ..()

if(is_wire_tool(C) && panel_open)
attempt_wire_interaction(user)
return

else if(panel_open && security_level == AIRLOCK_SECURITY_NONE && istype(C, /obj/item/stack/sheet))
if(istype(C, /obj/item/stack/sheet/iron))
return try_reinforce(user, C, 2, AIRLOCK_SECURITY_IRON)
Expand All @@ -920,8 +934,10 @@
else if(istype(C, /obj/item/pai_cable))
var/obj/item/pai_cable/cable = C
cable.plugin(src, user)

else if(istype(C, /obj/item/airlock_painter))
change_paintjob(C, user)

else if(istype(C, /obj/item/door_seal)) //adding the seal
var/obj/item/door_seal/airlockseal = C
if(!density)
Expand All @@ -930,19 +946,24 @@
if(seal)
to_chat(user, span_warning("[src] has already been sealed!"))
return

user.visible_message(span_notice("[user] begins sealing [src]."), span_notice("You begin sealing [src]."))
playsound(src, 'sound/items/jaws_pry.ogg', 30, TRUE)
if(!do_after(user, src, airlockseal.seal_time))
return

if(!density)
to_chat(user, span_warning("[src] must be closed before you can seal it!"))
return

if(seal)
to_chat(user, span_warning("[src] has already been sealed!"))
return

if(!user.transferItemToLoc(airlockseal, src))
to_chat(user, span_warning("For some reason, you can't attach [airlockseal]!"))
return

playsound(src, forcedClosed, 30, TRUE)
user.visible_message(span_notice("[user] finishes sealing [src]."), span_notice("You finish sealing [src]."))
seal = airlockseal
Expand All @@ -956,6 +977,7 @@
if(!user.transferItemToLoc(C, src))
to_chat(user, span_warning("For some reason, you can't attach [C]!"))
return

user.visible_message(span_notice("[user] pins [C] to [src]."), span_notice("You pin [C] to [src]."), span_hear("You hear a metallic thud."))
note = C
update_appearance()
Expand Down Expand Up @@ -1354,7 +1376,9 @@
/obj/machinery/door/airlock/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir)
if((damage_amount >= atom_integrity) && (damage_flag == BOMB))
flags_1 |= NODECONSTRUCT_1 //If an explosive took us out, don't drop the assembly

. = ..()

if(atom_integrity < (0.75 * max_integrity))
update_appearance()

Expand Down
12 changes: 7 additions & 5 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ DEFINE_INTERACTABLE(/obj/machinery/door)
can_atmos_pass = CANPASS_PROC
flags_1 = PREVENT_CLICK_UNDER_1
receive_ricochet_chance_mod = 0.8
damage_deflection = 10

interaction_flags_atom = INTERACT_ATOM_UI_INTERACT | INTERACT_ATOM_NO_FINGERPRINT_ATTACK_HAND
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
Expand Down Expand Up @@ -358,13 +357,16 @@ DEFINE_INTERACTABLE(/obj/machinery/door)
return TOOL_ACT_TOOLTYPE_SUCCESS

/obj/machinery/door/attackby(obj/item/I, mob/living/user, params)
if(!user.combat_mode && istype(I, /obj/item/fireaxe))
if((I.item_flags & NOBLUDGEON) || user.combat_mode)
return ..()

if(istype(I, /obj/item/fireaxe))
try_to_crowbar(I, user, FALSE)
return TRUE
else if(I.item_flags & NOBLUDGEON || user.combat_mode)
return ..()
else if(try_to_activate_door(user, attackedby = I))

if(try_to_activate_door(user, attackedby = I))
return TRUE

return ..()

/obj/machinery/door/welder_act_secondary(mob/living/user, obj/item/tool)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
icon_state = "door_open"
opacity = FALSE
density = FALSE
max_integrity = 300
max_integrity = 50
resistance_flags = FIRE_PROOF
heat_proof = TRUE
glass = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/shutters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
icon = 'icons/obj/doors/shutters.dmi'
layer = SHUTTER_LAYER
closingLayer = SHUTTER_LAYER_CLOSED
damage_deflection = 20
damage_deflection = 5
armor = list(BLUNT = 20, PUNCTURE = 20, SLASH = 90, LASER = 20, ENERGY = 75, BOMB = 25, BIO = 100, FIRE = 100, ACID = 70)
max_integrity = 100
recipe_type = /datum/crafting_recipe/shutters
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
integrity_failure = 0.4
light_color = COLOR_WHITE
light_power = FLASH_LIGHT_POWER
damage_deflection = 10
damage_deflection = 5
var/obj/item/assembly/flash/handheld/bulb
var/id = null
var/range = 2 //this is roughly the size of brig cell
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,7 @@ DEFINE_INTERACTABLE(/obj/item)
var/obj/O = highest
if(!O.uses_integrity)
return

O.take_damage((w_class * 5) * levels)

if(ismob(highest))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
var/obj/O = highest
if(!O.uses_integrity)
return
O.take_damage(80 * levels)
O.take_damage(10 * levels)

if(ismob(highest))
var/mob/living/L = highest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
max_integrity = 250
armor = list(BLUNT = 30, PUNCTURE = 50, SLASH = 100, LASER = 50, ENERGY = 100, BOMB = 0, BIO = 0, FIRE = 80, ACID = 80)
secure = TRUE
damage_deflection = 20
damage_deflection = 18
3 changes: 2 additions & 1 deletion code/game/objects/structures/crates_lockers/crates/secure.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
max_integrity = 500
armor = list(BLUNT = 30, PUNCTURE = 50, SLASH = 100, LASER = 50, ENERGY = 100, BOMB = 0, BIO = 0, FIRE = 80, ACID = 80)
var/tamperproof = 0
damage_deflection = 25

damage_deflection = 18

/obj/structure/closet/crate/secure/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1)
if(prob(tamperproof) && damage_amount >= DAMAGE_PRECISION)
Expand Down
34 changes: 33 additions & 1 deletion code/game/objects/structures/door_assembly.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
icon_state = "construction"
anchored = FALSE
density = TRUE
max_integrity = 200

max_integrity = 120
armor = list(BLUNT = 30, PUNCTURE = 30, SLASH = 90, LASER = 20, ENERGY = 20, BOMB = 10, BIO = 100, FIRE = 80, ACID = 70)

var/state = AIRLOCK_ASSEMBLY_NEEDS_WIRES
var/base_name = "airlock"
var/mineral = null
Expand Down Expand Up @@ -382,3 +385,32 @@
qdel(src)
return TRUE
return FALSE

/obj/structure/door_assembly/attack_hand(mob/living/user, list/modifiers)
. = ..()
if(.)
return

density = FALSE
var/is_user_adjacent = user.Adjacent(src)
density = TRUE

if(!is_user_adjacent)
return

. = TRUE

if(!do_after(user, src, 5 SECONDS, DO_PUBLIC))
return

shimmy_through(user)

/// Move a mob into our loc.
/obj/structure/door_assembly/proc/shimmy_through(mob/living/user)
set_density(FALSE)
. = user.Move(get_turf(src), get_dir(user, src))
set_density(TRUE)

if(.)
user.visible_message(span_notice("[user] shimmies their way through [src]."))

2 changes: 1 addition & 1 deletion code/game/objects/structures/window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
heat_resistance = 50000
armor = list(BLUNT = 80, PUNCTURE = 20, SLASH = 90, LASER = 0, ENERGY = 0, BOMB = 60, BIO = 100, FIRE = 99, ACID = 100)
max_integrity = 500
damage_deflection = 21
damage_deflection = 18
explosion_block = 2
glass_type = /obj/item/stack/sheet/plasmarglass
melting_point = 25000
Expand Down
2 changes: 1 addition & 1 deletion code/modules/recycling/disposal/pipe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
max_integrity = 200
armor = list(BLUNT = 25, PUNCTURE = 10, SLASH = 0, LASER = 10, ENERGY = 100, BOMB = 0, BIO = 100, FIRE = 90, ACID = 30)
layer = DISPOSAL_PIPE_LAYER // slightly lower than wires and other pipes
damage_deflection = 10
damage_deflection = 5
var/dpdir = NONE // bitmask of pipe directions
var/initialize_dirs = NONE // bitflags of pipe directions added on init, see \code\_DEFINES\pipe_construction.dm
var/flip_type // If set, the pipe is flippable and becomes this type when flipped
Expand Down

0 comments on commit 259dcfd

Please sign in to comment.