Files
siliconsandGitHub 483d595d3e mass turf repath (#6865)
enough is enough with these damn planet subtypes

also drops unused 140x140's
2024-11-25 22:43:28 -07:00

237 lines
7.0 KiB
Plaintext

/obj/machinery/shield
name = "Emergency energy shield"
desc = "An energy shield used to contain hull breaches."
icon = 'icons/effects/effects.dmi'
icon_state = "shield-old"
density = TRUE
anchored = TRUE
integrity_flags = INTEGRITY_ACIDPROOF | INTEGRITY_FIREPROOF | INTEGRITY_LAVAPROOF
CanAtmosPass = ATMOS_PASS_AIR_BLOCKED
CanAtmosPassVertical = ATMOS_PASS_AIR_BLOCKED
integrity = 200
integrity_max = 200
hit_sound_brute = 'sound/effects/EMPulse.ogg'
hit_sound_burn = 'sound/effects/EMPulse.ogg'
var/shield_generate_power = 7500 //how much power we use when regenerating
var/shield_idle_power = 1500 //how much power we use when just being sustained.
/obj/machinery/shield/Initialize(mapload)
. = ..()
setDir(pick(1,2,3,4))
update_nearby_tiles()
/obj/machinery/shield/Destroy()
CanAtmosPass = ATMOS_PASS_NOT_BLOCKED
CanAtmosPassVertical = ATMOS_PASS_NOT_BLOCKED
update_nearby_tiles()
return ..()
/obj/machinery/shield/emp_act(severity)
switch(severity)
if(1)
qdel(src)
if(2)
if(prob(75))
qdel(src)
if(3)
if(prob(50))
qdel(src)
if(4)
if(prob(25))
qdel(src)
/obj/machinery/shield/malfai
name = "emergency forcefield"
desc = "A weak forcefield which seems to be projected by the station's emergency atmosphere containment field"
/obj/machinery/shield/malfai/process(delta_time)
damage_integrity(0.5, TRUE)
/obj/machinery/shieldgen
name = "Emergency shield projector"
desc = "Used to seal minor hull breaches."
icon = 'icons/obj/objects.dmi'
icon_state = "shieldoff"
density = 1
opacity = 0
anchored = 0
pressure_resistance = 2*ONE_ATMOSPHERE
req_access = list(ACCESS_ENGINEERING_MAIN)
integrity = 200
integrity_max = 200
var/active = 0
var/malfunction = 0 //Malfunction causes parts of the shield to slowly dissapate
var/list/deployed_shields = list()
var/list/regenerating = list()
var/is_open = 0 //Whether or not the wires are exposed
var/locked = 0
var/check_delay = 60 //periodically recheck if we need to rebuild a shield
use_power = USE_POWER_OFF
idle_power_usage = 0
var/global/list/blockedturfs = list(
/turf/space,
/turf/simulated/floor/plating/outdoors,
) //For Future additions to exterior tiles, add them on this list.
/obj/machinery/shieldgen/Destroy()
collapse_shields()
..()
/obj/machinery/shieldgen/proc/shields_up()
if(active) return 0 //If it's already turned on, how did this get called?
src.active = 1
update_icon()
create_shields()
idle_power_usage = 0
for(var/obj/machinery/shield/shield_tile in deployed_shields)
idle_power_usage += shield_tile.shield_idle_power
update_use_power(USE_POWER_IDLE)
/obj/machinery/shieldgen/proc/shields_down()
if(!active) return 0 //If it's already off, how did this get called?
src.active = 0
update_icon()
collapse_shields()
update_use_power(USE_POWER_OFF)
/obj/machinery/shieldgen/proc/create_shields()
for(var/turf/target_tile in range(2, src))
if (is_type_in_list(target_tile,blockedturfs) && !(locate(/obj/machinery/shield) in target_tile))
if (malfunction && prob(33) || !malfunction)
var/obj/machinery/shield/S = new/obj/machinery/shield(target_tile)
deployed_shields += S
use_power(S.shield_generate_power)
/obj/machinery/shieldgen/proc/collapse_shields()
for(var/obj/machinery/shield/shield_tile in deployed_shields)
qdel(shield_tile)
/obj/machinery/shieldgen/power_change()
..()
if(!active) return
if(machine_stat & NOPOWER)
collapse_shields()
else
create_shields()
update_icon()
/obj/machinery/shieldgen/process(delta_time)
if(!active || (machine_stat & NOPOWER))
return
if(malfunction)
if(deployed_shields.len && prob(5))
qdel(pick(deployed_shields))
else
if (check_delay <= 0)
create_shields()
var/new_power_usage = 0
for(var/obj/machinery/shield/shield_tile in deployed_shields)
new_power_usage += shield_tile.shield_idle_power
if (new_power_usage != idle_power_usage)
idle_power_usage = new_power_usage
use_power(USE_POWER_OFF)
check_delay = 60
else
check_delay--
/obj/machinery/shieldgen/attack_hand(mob/user, datum/event_args/actor/clickchain/e_args)
if(locked)
to_chat(user, "The machine is locked, you are unable to use it.")
return
if(is_open)
to_chat(user, "The panel must be closed before operating this machine.")
return
if (src.active)
user.visible_message("<font color=#4F49AF>[icon2html(thing = src, target = world)] [user] deactivated the shield generator.</font>", \
"<font color=#4F49AF>[icon2html(thing = src, target = user)] You deactivate the shield generator.</font>", \
"You hear heavy droning fade out.")
src.shields_down()
else
if(anchored)
user.visible_message("<font color=#4F49AF>[icon2html(thing = src, target = world)] [user] activated the shield generator.</font>", \
"<font color=#4F49AF>[icon2html(thing = src, target = user)] You activate the shield generator.</font>", \
"You hear heavy droning.")
src.shields_up()
else
to_chat(user, "The device must first be secured to the floor.")
return
/obj/machinery/shieldgen/emag_act(var/remaining_charges, var/mob/user)
if(!malfunction)
malfunction = 1
update_icon()
return 1
/obj/machinery/shieldgen/attackby(obj/item/W as obj, mob/user as mob)
if(W.is_screwdriver())
playsound(src, W.tool_sound, 100, 1)
if(is_open)
to_chat(user, "<font color=#4F49AF>You close the panel.</font>")
is_open = 0
else
to_chat(user, "<font color=#4F49AF>You open the panel and expose the wiring.</font>")
is_open = 1
else if(istype(W, /obj/item/stack/cable_coil) && malfunction && is_open)
var/obj/item/stack/cable_coil/coil = W
to_chat(user, "<span class='notice'>You begin to replace the wires.</span>")
//if(do_after(user, min(60, round( ((getMaxHealth()/health)*10)+(malfunction*10) ))) //Take longer to repair heavier damage
if(do_after(user, 30))
if (coil.use(1))
integrity = integrity_max
malfunction = 0
to_chat(user, "<span class='notice'>You repair the [src]!</span>")
update_icon()
else if(W.is_wrench())
if(locked)
to_chat(user, "The bolts are covered, unlocking this would retract the covers.")
return
if(anchored)
playsound(src, W.tool_sound, 100, 1)
to_chat(user, "<font color=#4F49AF>You unsecure the [src] from the floor!</font>")
if(active)
to_chat(user, "<font color=#4F49AF>The [src] shuts off!</font>")
src.shields_down()
anchored = 0
else
if(istype(get_turf(src), /turf/space)) return //No wrenching these in space!
playsound(src, W.tool_sound, 100, 1)
to_chat(user, "<font color=#4F49AF>You secure the [src] to the floor!</font>")
anchored = 1
else if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
if(src.allowed(user))
src.locked = !src.locked
to_chat(user, "The controls are now [src.locked ? "locked." : "unlocked."]")
else
to_chat(user, "<font color='red'>Access denied.</font>")
else
..()
/obj/machinery/shieldgen/update_icon()
if(active && !(machine_stat & NOPOWER))
src.icon_state = malfunction ? "shieldonbr":"shieldon"
else
src.icon_state = malfunction ? "shieldoffbr":"shieldoff"
return