diff --git a/nsv13.dme b/nsv13.dme index f09b32429d1..fe9140ba874 100644 --- a/nsv13.dme +++ b/nsv13.dme @@ -4047,6 +4047,7 @@ #include "nsv13\code\modules\overmap\weapons\weapons.dm" #include "nsv13\code\modules\paperwork\stamps.dm" #include "nsv13\code\modules\pixelshifting\pixelshifting.dm" +#include "nsv13\code\modules\power\gravitygenerator_modular.dm" #include "nsv13\code\modules\power\lighting.dm" #include "nsv13\code\modules\power\power.dm" #include "nsv13\code\modules\power\stormdrive.dm" diff --git a/nsv13/code/modules/power/gravitygenerator_modular.dm b/nsv13/code/modules/power/gravitygenerator_modular.dm new file mode 100644 index 00000000000..be6191514f2 --- /dev/null +++ b/nsv13/code/modules/power/gravitygenerator_modular.dm @@ -0,0 +1,73 @@ +///This is the modular NSV file for gravity generators, to keep the base file more clear of conflicts. + +//Modular proc attachment +/obj/machinery/gravity_generator/main/attackby(obj/item/I, mob/user, params) + if(!(obj_flags & EMAGGED)) + return ..() + if(I?.tool_behaviour != TOOL_MULTITOOL) + return ..() + if(on || charge_count > 0 || charging_state == POWER_UP) + to_chat(user, "You should not mess with [src]'s circuitry while it is active!") + return TRUE + if(machine_stat & BROKEN) + to_chat(user, "Fix [src]'s chassis first.") + return TRUE + to_chat(user, "You start resetting [src]'s control circuits and safety protocols.") + if(!do_after(user, 10 SECONDS, target = src, extra_checks = CALLBACK(src, PROC_REF(can_reset_generator)))) + return TRUE + to_chat(user, "You reset [src]'s control circuits to default.") + obj_flags &= (~EMAGGED) + change_setting(1) + ui_update() + if(ishuman(user)) + add_fibers(user) //..Fixing this thing is ALSO close and personal work. + investigate_log("was reset while emagged and will now generate 1G", INVESTIGATE_GRAVITY) + return TRUE + +///Is this gravity generator in need of a reset right now, and is this a valid state for it to be reset in? +/obj/machinery/gravity_generator/main/proc/can_reset_generator() + if(on || charge_count > 0 || charging_state == POWER_UP || !(obj_flags & EMAGGED) || (machine_stat & BROKEN)) + return FALSE + return TRUE + +///Can this gravity generator be emagged right now? +/obj/machinery/gravity_generator/main/proc/can_emag_generator() + if((obj_flags & EMAGGED) || !on) + return FALSE + return TRUE + +/obj/machinery/gravity_generator/main/emag_act(mob/user) + if(obj_flags & EMAGGED) + return FALSE + if(!on) + to_chat(user, "[src] must be active to override its controls.") + return FALSE + to_chat(user, "You start messing with [src]'s internals. This will take a moment to get done just right..") + if(!do_after(user, 5 SECONDS, target = src, extra_checks = CALLBACK(src, PROC_REF(can_emag_generator)))) + return FALSE + to_chat(user, "You override [src]'s safeties and crosswire it to double its target gravity.") + charge_count = 0 + set_state(0) + radiation_pulse(src, 1800) //You SHOULD wear protection when messing with this thing this badly. + obj_flags |= EMAGGED + change_setting(2) // :) + set_power(POWER_UP) + ui_update() + if(ishuman(user)) + add_fibers(user) //Emagging this thing is close and personal work. + investigate_log("was emagged and will now generate 2G", INVESTIGATE_GRAVITY) + message_admins("The gravity generator was emagged by [user] (real name: [user?.real_name])! [ADMIN_VERBOSEJMP(src)]") + return TRUE + +//Modular proc attachment +/obj/machinery/gravity_generator/main/ui_data(mob/user) + . = ..() + .["emagged"] = (obj_flags & EMAGGED) ? TRUE : FALSE //Trinary for safety because bitfield checks do not return just a pure TRUE / FALSE. + .["theme"] = (obj_flags & EMAGGED) ? "syndicate " : "ntos" + +///Modular proc OVERRIDE +/obj/machinery/gravity_generator/main/change_setting(value) + if(value != setting) + setting = value + if(on) //No reason to shake if grav is off. + shake_everyone() diff --git a/tgui/packages/tgui/interfaces/GravityGenerator.js b/tgui/packages/tgui/interfaces/GravityGenerator.js index 796a23e25c5..a2c008f8544 100644 --- a/tgui/packages/tgui/interfaces/GravityGenerator.js +++ b/tgui/packages/tgui/interfaces/GravityGenerator.js @@ -7,17 +7,27 @@ export const GravityGenerator = (props, context) => { const { charging_state, operational, - } = data; + emagged, + theme, + } = data; { /* NSV13 - added theme and emagged as vars*/ } return ( + height={600} + theme={theme}> {/* NSV13 - theme change on emag*/ } {!operational && ( No data available )} + {/* NSV13 - gravgen emag info*/ } + {!!operational && !!emagged && ( + + {'ERR - GR&!%$$ %$&/(!%$) ?)!&$ยง ERROR, #!&%# 2G'} + + )} + {/* NSV13 end*/ } {!!operational && charging_state !== 0 && ( WARNING - Radiation detected