Files
Bubberstation/code/game/objects/structures/fireaxe.dm
SkyratBot 71b5f92eda [MIRROR] [MDB IGNORE] dir sanity, primarily on WALLITEMs [MDB IGNORE] (#9315)
* [MDB IGNORE] dir sanity, primarily on WALLITEMs (#62601)

About The Pull Request

Wall items mostly use the direction from the floor to the wall in the named mapping helper. Wall items mostly use the direction from the wall to the floor for the internal dir variable.

This leads to a headache when it comes to working out what conflicts with what, and what needs placing where.

Wall frames provided a member, inverse, which specified whether or not to invert the direction of the item when looking for conflicts. It was also used to specify whether to look for conflicts outside of the wall (cameras and lights appear external to the wall) or inside the wall (most wall items). This flag was set for Intercoms, APCs, and Lights. Since APCs and Lights expect a floor-to-wall direction, and Intercoms expect a wall-to-floor direction, this means that APCs and Lights were getting the correct direction, and Intercoms were getting the wrong direction.

Some implications of this setup were:

    You could build an APC on top of another wall item, provided there was nothing external attached to the wall and the area didn't have an APC.
    You could stack Intercoms indefinitely on top of the same wall, provided you weren't in a one-tile wide corridor with something on the opposite wall.

Or both! Here's twenty Intercoms placed on the wall, and a freshly placed APC frame after placing all Intercoms and deconstructing the old APC:

endless-stack-of-intercoms

Not everything used this inverse variable to adjust to the correct direction. For example, /obj/machinery/defibrillator_mount just used a negative pixel_offset to be visually placed in the correct direction, even though the internal direction was wrong, and never set! This also let you stack an indefinite number of defib mounts on the same wall, provided it wasn't a northern wall... except you could do this to northern walls too, since defibs weren't considered a wall item for the purposes of checking collisions at all!

Ultimately, every constructable interior wall item either used this inverse variable to adjust to the correct placement, set a negative pixel_offset variable to have its offset adjusted to the correct placement, or overrode New or Initialize to run its own checks and assignment to pixel_x and pixel_y!
Inventory: Table of various paths, related paths, and the adjustments they used

Unfortunately, untangling /obj/structure/sign is going to be another major headache, and this has already exploded in scope enough already, so we can't get rid of the get_turf_pixel call just yet. This also doesn't fix problems with the special 2x1 /obj/structure/sign/barsign.

Some non-wall items have been made to use the new MAPPING_DIRECTIONAL_HELPERS as part of the directional cleanup.

tl;dr: All wall mounted items and some directional objects now use the same direction that they were labelled as. More consistent directional types everywhere.
Why It's Good For The Game

fml
Changelog

cl
refactor: Wall mounted and directional objects have undergone major internal simplification. Please report anything unusual!
fix: You can no longer stack an indefinite amount of Intercoms on the same wall.
fix: Defibrillator Mounts, Bluespace Gas Vendors, Turret Controlers, and Ticket Machines are now considered wall items.
fix: Wall mounted items on top of the wall now consistently check against other items on top of the wall, and items coming out of the wall now consistently check against other items coming out of the wall.
fix: The various directional pixel offsets within an APC, Fire Extinguisher Cabinet, Intercom, or Newscaster have been made consistent with each other.
fix: The pixel offsets of Intercoms, Fire Alarms, Fire Extinguisher Cabinets, Flashers, and Newscasters have been made consistent between roundstart and constructed instances.
fix: Constructed Turret Controls will no longer oddly overhang the wall they were placed on.
qol: Defibrillator mounts now better indicate which side of the wall they are on.
fix: Some instances where there were multiple identical lights on the same tile have been fixed to only have one.
/cl

* [MDB IGNORE] dir sanity, primarily on WALLITEMs

* apc directionals

* bluespace vendor fix

* defib fix

Co-authored-by: esainane <esainane+github@gmail.com>
Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
2021-11-10 17:17:26 -05:00

190 lines
5.1 KiB
Plaintext

/obj/structure/fireaxecabinet
name = "fire axe cabinet"
desc = "There is a small label that reads \"For Emergency use only\" along with details for safe use of the axe. As if."
icon = 'icons/obj/wallmounts.dmi'
icon_state = "fireaxe"
anchored = TRUE
density = FALSE
armor = list(MELEE = 50, BULLET = 20, LASER = 0, ENERGY = 100, BOMB = 10, BIO = 100, FIRE = 90, ACID = 50)
max_integrity = 150
integrity_failure = 0.33
var/locked = TRUE
var/open = FALSE
var/obj/item/fireaxe/fireaxe
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet, 32)
/obj/structure/fireaxecabinet/Initialize(mapload)
. = ..()
fireaxe = new
update_appearance()
/obj/structure/fireaxecabinet/Destroy()
if(fireaxe)
QDEL_NULL(fireaxe)
return ..()
/obj/structure/fireaxecabinet/attackby(obj/item/I, mob/living/user, params)
if(iscyborg(user) || I.tool_behaviour == TOOL_MULTITOOL)
toggle_lock(user)
else if(I.tool_behaviour == TOOL_WELDER && !user.combat_mode && !broken)
if(atom_integrity < max_integrity)
if(!I.tool_start_check(user, amount=2))
return
to_chat(user, span_notice("You begin repairing [src]."))
if(I.use_tool(src, user, 40, volume=50, amount=2))
atom_integrity = max_integrity
update_appearance()
to_chat(user, span_notice("You repair [src]."))
else
to_chat(user, span_warning("[src] is already in good condition!"))
return
else if(istype(I, /obj/item/stack/sheet/glass) && broken)
var/obj/item/stack/sheet/glass/G = I
if(G.get_amount() < 2)
to_chat(user, span_warning("You need two glass sheets to fix [src]!"))
return
to_chat(user, span_notice("You start fixing [src]..."))
if(do_after(user, 20, target = src) && G.use(2))
broken = FALSE
atom_integrity = max_integrity
update_appearance()
else if(open || broken)
if(istype(I, /obj/item/fireaxe) && !fireaxe)
var/obj/item/fireaxe/F = I
if(F?.wielded)
to_chat(user, span_warning("Unwield the [F.name] first."))
return
if(!user.transferItemToLoc(F, src))
return
fireaxe = F
to_chat(user, span_notice("You place the [F.name] back in the [name]."))
update_appearance()
return
else if(!broken)
toggle_open()
else
return ..()
/obj/structure/fireaxecabinet/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
switch(damage_type)
if(BRUTE)
if(broken)
playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 90, TRUE)
else
playsound(loc, 'sound/effects/glasshit.ogg', 90, TRUE)
if(BURN)
playsound(src.loc, 'sound/items/welder.ogg', 100, TRUE)
/obj/structure/fireaxecabinet/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = TRUE, attack_dir)
if(open)
return
. = ..()
if(.)
update_appearance()
/obj/structure/fireaxecabinet/atom_break(damage_flag)
. = ..()
if(!broken && !(flags_1 & NODECONSTRUCT_1))
update_appearance()
broken = TRUE
playsound(src, 'sound/effects/glassbr3.ogg', 100, TRUE)
new /obj/item/shard(loc)
new /obj/item/shard(loc)
/obj/structure/fireaxecabinet/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
if(fireaxe && loc)
fireaxe.forceMove(loc)
fireaxe = null
new /obj/item/stack/sheet/iron(loc, 2)
qdel(src)
/obj/structure/fireaxecabinet/blob_act(obj/structure/blob/B)
if(fireaxe)
fireaxe.forceMove(loc)
fireaxe = null
qdel(src)
/obj/structure/fireaxecabinet/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
if(open || broken)
if(fireaxe)
user.put_in_hands(fireaxe)
fireaxe = null
to_chat(user, span_notice("You take the fire axe from the [name]."))
src.add_fingerprint(user)
update_appearance()
return
if(locked)
to_chat(user, span_warning("The [name] won't budge!"))
return
else
open = !open
update_appearance()
return
/obj/structure/fireaxecabinet/attack_paw(mob/living/user, list/modifiers)
return attack_hand(user, modifiers)
/obj/structure/fireaxecabinet/attack_ai(mob/user)
toggle_lock(user)
return
/obj/structure/fireaxecabinet/attack_tk(mob/user)
. = COMPONENT_CANCEL_ATTACK_CHAIN
if(locked)
to_chat(user, span_warning("The [name] won't budge!"))
return
open = !open
update_appearance()
/obj/structure/fireaxecabinet/update_overlays()
. = ..()
if(fireaxe)
. += "axe"
if(open)
. += "glass_raised"
return
var/hp_percent = atom_integrity/max_integrity * 100
if(broken)
. += "glass4"
else
switch(hp_percent)
if(-INFINITY to 40)
. += "glass3"
if(40 to 60)
. += "glass2"
if(60 to 80)
. += "glass1"
if(80 to INFINITY)
. += "glass"
. += locked ? "locked" : "unlocked"
/obj/structure/fireaxecabinet/proc/toggle_lock(mob/user)
to_chat(user, span_notice("Resetting circuitry..."))
playsound(src, 'sound/machines/locktoggle.ogg', 50, TRUE)
if(do_after(user, 20, target = src))
to_chat(user, span_notice("You [locked ? "disable" : "re-enable"] the locking modules."))
locked = !locked
update_appearance()
/obj/structure/fireaxecabinet/verb/toggle_open()
set name = "Open/Close"
set category = "Object"
set src in oview(1)
if(locked)
to_chat(usr, span_warning("The [name] won't budge!"))
return
else
open = !open
update_appearance()
return