From 3a0cbdb1b14d198a28c42c71e81c417bd55f9ada Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Mon, 23 Mar 2020 21:34:07 -0400 Subject: [PATCH] Mecha omni-shield generator --- .../game/mecha/equipment/tools/shield_omni.dm | 97 +++++++++++++++++++ code/modules/research/mechfab_designs.dm | 8 ++ code/modules/shieldgen/directional_shield.dm | 12 ++- vorestation.dme | 1 + 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 code/game/mecha/equipment/tools/shield_omni.dm diff --git a/code/game/mecha/equipment/tools/shield_omni.dm b/code/game/mecha/equipment/tools/shield_omni.dm new file mode 100644 index 0000000000..8088cf296a --- /dev/null +++ b/code/game/mecha/equipment/tools/shield_omni.dm @@ -0,0 +1,97 @@ +#define OMNI_SHIELD_DRAIN 30 + +/obj/item/mecha_parts/mecha_equipment/omni_shield + name = "omni shield" + desc = "A shield generator that forms an ennlosing, omnidirectional shield around the exosuit." + icon_state = "shield" + origin_tech = list(TECH_PHORON = 3, TECH_MAGNET = 6, TECH_ILLEGAL = 4) + equip_cooldown = 5 + energy_drain = OMNI_SHIELD_DRAIN + range = 0 + + var/obj/item/shield_projector/shields = null + var/shield_type = /obj/item/shield_projector/rectangle/mecha + + equip_type = EQUIP_HULL + +/obj/item/mecha_parts/mecha_equipment/omni_shield/critfail() + ..() + shields.adjust_health(-200) + +/obj/item/mecha_parts/mecha_equipment/omni_shield/Destroy() + QDEL_NULL(shields) + ..() + +/obj/item/mecha_parts/mecha_equipment/omni_shield/attach(obj/mecha/M as obj) + . = ..() + if(chassis) + shields = new shield_type(chassis) + +/obj/item/mecha_parts/mecha_equipment/omni_shield/detach() + if(chassis) + QDEL_NULL(shields) + . = ..() + +/obj/item/mecha_parts/mecha_equipment/omni_shield/handle_movement_action() + if(chassis && shields) + shields.update_shield_positions() + +/obj/item/mecha_parts/mecha_equipment/omni_shield/proc/toggle_shield() + ..() + if(shields) + shields.set_on(!shields.active) + if(shields.active) + set_ready_state(0) + log_message("Activated.") + else + set_ready_state(1) + log_message("Deactivated.") + +/obj/item/mecha_parts/mecha_equipment/omni_shield/Topic(href, href_list) + ..() + if(href_list["toggle_omnishield"]) + toggle_shield() + +/obj/item/mecha_parts/mecha_equipment/omni_shield/get_equip_info() + if(!chassis) return + return "* [src.name] - [shields?.active?"Dea":"A"]ctivate" + + +////// The shield projector object +/obj/item/shield_projector/rectangle/mecha + shield_health = 200 + max_shield_health = 200 + shield_regen_delay = 10 SECONDS + shield_regen_amount = 10 + size_x = 1 + size_y = 1 + + var/shift_x = 0 + var/shift_y = 0 + + var/obj/mecha/my_mech = null + +/obj/item/shield_projector/rectangle/mecha/Initialize() + . = ..() + my_mech = loc + GLOB.moved_event.register(my_mech, src, /obj/item/shield_projector/proc/update_shield_positions) + +/obj/item/shield_projector/rectangle/mecha/Destroy() + GLOB.moved_event.unregister(my_mech, src, /obj/item/shield_projector/proc/update_shield_positions) + my_mech = null + ..() + +/obj/item/shield_projector/rectangle/mecha/create_shield() + . = ..() + if(shift_x || shift_y) + var/obj/effect/directional_shield/newshield = active_shields[active_shields.len] + newshield.pixel_x = shift_x + newshield.pixel_y = shift_y + +/obj/item/shield_projector/rectangle/mecha/adjust_health(amount) + . = ..() + my_mech.use_power(OMNI_SHIELD_DRAIN) + if(!active && shield_health < shield_regen_amount) + my_mech.use_power(OMNI_SHIELD_DRAIN * 4) + +#undef OMNI_SHIELD_DRAIN diff --git a/code/modules/research/mechfab_designs.dm b/code/modules/research/mechfab_designs.dm index af8afc44fb..fce2ffd6e0 100644 --- a/code/modules/research/mechfab_designs.dm +++ b/code/modules/research/mechfab_designs.dm @@ -570,6 +570,14 @@ materials = list(DEFAULT_WALL_MATERIAL = 8000, "gold" = 2000, "silver" = 3000, "phoron" = 5000, "glass" = 3750) build_path = /obj/item/mecha_parts/mecha_equipment/combat_shield +/datum/design/item/mecha/omni_shield + name = "Omni Shield" + desc = "Integral shield projector. Can only protect the exosuit, but has no weak angles." + id = "mech_shield_omni" + req_tech = list(TECH_PHORON = 3, TECH_MAGNET = 6, TECH_ILLEGAL = 4) + materials = list(DEFAULT_WALL_MATERIAL = 8000, "gold" = 2000, "silver" = 3000, "phoron" = 5000, "glass" = 3750) + build_path = /obj/item/mecha_parts/mecha_equipment/omni_shield + /datum/design/item/mecha/crisis_drone name = "Crisis Drone" desc = "Deploys a small medical drone capable of patching small wounds in order to stabilize nearby patients." diff --git a/code/modules/shieldgen/directional_shield.dm b/code/modules/shieldgen/directional_shield.dm index 9cc0454620..00c416895e 100644 --- a/code/modules/shieldgen/directional_shield.dm +++ b/code/modules/shieldgen/directional_shield.dm @@ -125,6 +125,7 @@ for(var/obj/effect/directional_shield/S in active_shields) active_shields -= S qdel(S) + set_light(0) active = FALSE /obj/item/shield_projector/proc/update_shield_positions() @@ -179,13 +180,18 @@ if(always_on) to_chat(user, "You can't seem to deactivate \the [src].") return - - destroy_shields() + set_on(FALSE) else set_dir(user.dir) // Needed for linear shields. - create_shields() + set_on(TRUE) visible_message("\The [user] [!active ? "de":""]activates \the [src].") +/obj/item/shield_projector/proc/set_on(var/on) + if(isnull(on)) + return + + on ? create_shields() : destroy_shields() // Harmless if called when in the wrong state. + /obj/item/shield_projector/process() if(shield_health < max_shield_health && ( (last_damaged_time + shield_regen_delay) < world.time) ) adjust_health(shield_regen_amount) diff --git a/vorestation.dme b/vorestation.dme index 25c5888cdc..442a19d35a 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -932,6 +932,7 @@ #include "code\game\mecha\equipment\tools\rcd.dm" #include "code\game\mecha\equipment\tools\repair_droid.dm" #include "code\game\mecha\equipment\tools\shield.dm" +#include "code\game\mecha\equipment\tools\shield_omni.dm" #include "code\game\mecha\equipment\tools\sleeper.dm" #include "code\game\mecha\equipment\tools\speedboost.dm" #include "code\game\mecha\equipment\tools\syringe_gun.dm"