Files
CHOMPStation2/code/modules/shieldgen/handheld_defuser.dm
Leshana e2bd546f61 Ports advanced shield generators from Baystation
- Creates new advanced shield generators, designed to replace old hull and bubble shield generators.
- Upgrades the floor mounted and handheld shield diffusers.
- Makes underfloor shield diffusers actually constructable.
- Handheld diffusers orderable via uplink.
- Removes supply packs and research datums  for the old generators, but leaves their code in place for maps that still use them.
- Integrates with the meteor and electrical storm events.
- Integrates with mob AI (they know how to attack it)
2020-04-03 00:56:15 -04:00

58 lines
1.9 KiB
Plaintext

/obj/item/weapon/shield_diffuser
name = "portable shield diffuser"
desc = "A small handheld device designed to disrupt energy barriers."
description_info = "This device disrupts shields on directly adjacent tiles (in a + shaped pattern), in a similar way the floor mounted variant does. It is, however, portable and run by an internal battery. Can be recharged with a regular recharger."
icon = 'icons/obj/machines/shielding.dmi'
icon_state = "hdiffuser_off"
origin_tech = list(TECH_MAGNET = 5, TECH_POWER = 5, TECH_ILLEGAL = 2)
var/obj/item/weapon/cell/device/cell
var/enabled = 0
/obj/item/weapon/shield_diffuser/Initialize()
. = ..()
cell = new(src)
/obj/item/weapon/shield_diffuser/Destroy()
QDEL_NULL(cell)
if(enabled)
STOP_PROCESSING(SSobj, src)
. = ..()
/obj/item/weapon/shield_diffuser/get_cell()
return cell
/obj/item/weapon/shield_diffuser/process()
if(!enabled)
return PROCESS_KILL
for(var/direction in cardinal)
var/turf/simulated/shielded_tile = get_step(get_turf(src), direction)
for(var/obj/effect/shield/S in shielded_tile)
// 10kJ per pulse, but gap in the shield lasts for longer than regular diffusers.
if(istype(S) && !S.diffused_for && !S.disabled_for && cell.checked_use(10 KILOWATTS * CELLRATE))
S.diffuse(20)
// Legacy shield support
for(var/obj/effect/energy_field/S in shielded_tile)
if(istype(S) && cell.checked_use(10 KILOWATTS * CELLRATE))
qdel(S)
/obj/item/weapon/shield_diffuser/update_icon()
if(enabled)
icon_state = "hdiffuser_on"
else
icon_state = "hdiffuser_off"
/obj/item/weapon/shield_diffuser/attack_self(mob/user)
enabled = !enabled
update_icon()
if(enabled)
START_PROCESSING(SSobj, src)
else
STOP_PROCESSING(SSobj, src)
to_chat(user, "You turn \the [src] [enabled ? "on" : "off"].")
/obj/item/weapon/shield_diffuser/examine(mob/user)
. = ..()
to_chat(user, "The charge meter reads [cell ? cell.percent() : 0]%")
to_chat(user, "It is [enabled ? "enabled" : "disabled"].")