diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index f9dbff89d76..06dd2733e26 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -71,6 +71,7 @@ #define INIT_ORDER_LIGHTING -20 #define INIT_ORDER_SHUTTLE -21 #define INIT_ORDER_NIGHTSHIFT -22 +#define INIT_ORDER_NANOMOB -23 #define INIT_ORDER_SQUEAK -40 #define INIT_ORDER_PATH -50 #define INIT_ORDER_PERSISTENCE -100 @@ -78,6 +79,7 @@ // Subsystem fire priority, from lowest to highest priority // If the subsystem isn't listed here it's either DEFAULT or PROCESS (if it's a processing subsystem child) +#define FIRE_PRIORITY_NANOMOB 10 #define FIRE_PRIORITY_NIGHTSHIFT 10 #define FIRE_PRIORITY_IDLE_NPC 10 #define FIRE_PRIORITY_SERVER_MAINT 10 diff --git a/code/controllers/Processes/nano_mob_hunter.dm b/code/controllers/subsystem/nano_mob_hunter.dm similarity index 84% rename from code/controllers/Processes/nano_mob_hunter.dm rename to code/controllers/subsystem/nano_mob_hunter.dm index dc5dcba805b..a634f091013 100644 --- a/code/controllers/Processes/nano_mob_hunter.dm +++ b/code/controllers/subsystem/nano_mob_hunter.dm @@ -1,6 +1,7 @@ -var/global/datum/controller/process/mob_hunt/mob_hunt_server - -/datum/controller/process/mob_hunt +SUBSYSTEM_DEF(mob_hunt) + name = "Nano-Mob Hunter GO Server" + init_order = INIT_ORDER_NANOMOB + priority = FIRE_PRIORITY_NANOMOB // Low priority, no need for MC_TICK_CHECK due to extremely low performance impact. var/max_normal_spawns = 15 //change this to adjust the number of normal spawns that can exist at one time. trapped spawns (from traitors) don't count towards this var/list/normal_spawns = list() var/max_trap_spawns = 15 //change this to adjust the number of trap spawns that can exist at one time. traps spawned beyond this point clear the oldest traps @@ -12,11 +13,7 @@ var/global/datum/controller/process/mob_hunt/mob_hunt_server var/obj/machinery/computer/mob_battle_terminal/blue_terminal var/battle_turn = null -/datum/controller/process/mob_hunt/setup() - name = "Nano-Mob Hunter GO Server" - start_delay = 20 - -/datum/controller/process/mob_hunt/doWork() +/datum/controller/subsystem/mob_hunt/fire(resumed = FALSE) if(reset_cooldown) //if reset_cooldown is set (we are on cooldown, duh), reduce the remaining cooldown every cycle reset_cooldown-- if(!server_status) @@ -25,10 +22,8 @@ var/global/datum/controller/process/mob_hunt/mob_hunt_server if(normal_spawns.len < max_normal_spawns) spawn_mob() -DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) - //leaving this here in case admins want to use it for a random mini-event or something -/datum/controller/process/mob_hunt/proc/server_crash(recover_time = 3000) +/datum/controller/subsystem/mob_hunt/proc/server_crash(recover_time = 3000) server_status = 0 for(var/datum/data/pda/app/mob_hunter_game/client in connected_clients) client.disconnect("Server Crash") @@ -46,7 +41,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) //set a timer to automatically recover after recover_time has passed (can be manually restarted if you get impatient too) addtimer(CALLBACK(src, .proc/auto_recover), recover_time, TIMER_UNIQUE) -/datum/controller/process/mob_hunt/proc/client_mob_update() +/datum/controller/subsystem/mob_hunt/proc/client_mob_update() var/list/ex_players = list() for(var/datum/data/pda/app/mob_hunter_game/client in connected_clients) var/mob/living/carbon/human/H = client.get_player() @@ -58,14 +53,14 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) for(var/obj/effect/nanomob/N in (normal_spawns + trap_spawns)) N.conceal(ex_players) -/datum/controller/process/mob_hunt/proc/auto_recover() +/datum/controller/subsystem/mob_hunt/proc/auto_recover() if(server_status != 0) return server_status = 1 while(normal_spawns.len < max_normal_spawns) //repopulate the server's spawns completely if we auto-recover from crash spawn_mob() -/datum/controller/process/mob_hunt/proc/manual_reboot() +/datum/controller/subsystem/mob_hunt/proc/manual_reboot() if(server_status && reset_cooldown) return 0 for(var/obj/effect/nanomob/N in trap_spawns) @@ -76,12 +71,12 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) reset_cooldown = 25 //25 controller cycle cooldown for manual restarts return 1 -/datum/controller/process/mob_hunt/proc/spawn_mob() +/datum/controller/subsystem/mob_hunt/proc/spawn_mob() var/list/nanomob_types = subtypesof(/datum/mob_hunt) var/datum/mob_hunt/mob_info = pick(nanomob_types) new mob_info() -/datum/controller/process/mob_hunt/proc/register_spawn(datum/mob_hunt/mob_info) +/datum/controller/subsystem/mob_hunt/proc/register_spawn(datum/mob_hunt/mob_info) if(!mob_info) return 0 var/obj/effect/nanomob/new_mob = new /obj/effect/nanomob(mob_info.spawn_point, mob_info) @@ -89,7 +84,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) new_mob.reveal() return 1 -/datum/controller/process/mob_hunt/proc/register_trap(datum/mob_hunt/mob_info) +/datum/controller/subsystem/mob_hunt/proc/register_trap(datum/mob_hunt/mob_info) if(!mob_info) return 0 if(!mob_info.is_trap) @@ -102,7 +97,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) old_trap.despawn() return 1 -/datum/controller/process/mob_hunt/proc/start_check() +/datum/controller/subsystem/mob_hunt/proc/start_check() if(battle_turn) //somehow we got called mid-battle, so lets just stop now return if(red_terminal && red_terminal.ready && blue_terminal && blue_terminal.ready) @@ -114,7 +109,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) else if(battle_turn == "Blue") blue_terminal.audible_message("Blue Player's Turn!", null, 5) -/datum/controller/process/mob_hunt/proc/launch_attack(team, raw_damage, datum/mob_type/attack_type) +/datum/controller/subsystem/mob_hunt/proc/launch_attack(team, raw_damage, datum/mob_type/attack_type) if(!team || !raw_damage) return var/obj/machinery/computer/mob_battle_terminal/target = null @@ -126,7 +121,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) return target.receive_attack(raw_damage, attack_type) -/datum/controller/process/mob_hunt/proc/end_battle(loser, surrender = 0) +/datum/controller/subsystem/mob_hunt/proc/end_battle(loser, surrender = 0) var/obj/machinery/computer/mob_battle_terminal/winner_terminal = null var/obj/machinery/computer/mob_battle_terminal/loser_terminal = null if(loser == "Red") @@ -145,7 +140,7 @@ DECLARE_GLOBAL_CONTROLLER(mob_hunt, mob_hunt_server) winner_terminal.audible_message("[winner_terminal.team] Player wins!", null, 5) winner_terminal.audible_message(progress_message, null, 2) -/datum/controller/process/mob_hunt/proc/end_turn() +/datum/controller/subsystem/mob_hunt/proc/end_turn() red_terminal.updateUsrDialog() blue_terminal.updateUsrDialog() if(!battle_turn) diff --git a/code/controllers/verbs.dm b/code/controllers/verbs.dm index 4e9380e2fed..4d1d2aab81f 100644 --- a/code/controllers/verbs.dm +++ b/code/controllers/verbs.dm @@ -100,7 +100,7 @@ debug_variables(space_manager) feedback_add_details("admin_verb","DSpace") if("Mob Hunt Server") - debug_variables(mob_hunt_server) + debug_variables(SSmob_hunt) feedback_add_details("admin_verb","DMobHuntServer") message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.") diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index 865f683946e..8ee5936cb29 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -288,8 +288,8 @@ setMenuState(usr,COMM_SCREEN_MAIN) if("RestartNanoMob") - if(mob_hunt_server) - if(mob_hunt_server.manual_reboot()) + if(SSmob_hunt) + if(SSmob_hunt.manual_reboot()) var/loading_msg = pick("Respawning spawns", "Reticulating splines", "Flipping hat", "Capturing all of them", "Fixing minor text issues", "Being the very best", "Nerfing this", "Not communicating with playerbase", "Coding a ripoff in a 2D spaceman game") diff --git a/code/modules/arcade/mob_hunt/battle_computer.dm b/code/modules/arcade/mob_hunt/battle_computer.dm index 8ae577fe338..1330bb64641 100644 --- a/code/modules/arcade/mob_hunt/battle_computer.dm +++ b/code/modules/arcade/mob_hunt/battle_computer.dm @@ -44,13 +44,13 @@ /obj/machinery/computer/mob_battle_terminal/Destroy() eject_card(1) - if(mob_hunt_server) - if(mob_hunt_server.battle_turn) - mob_hunt_server.battle_turn = null - if(mob_hunt_server.red_terminal == src) - mob_hunt_server.red_terminal = null - if(mob_hunt_server.blue_terminal == src) - mob_hunt_server.blue_terminal = null + if(SSmob_hunt) + if(SSmob_hunt.battle_turn) + SSmob_hunt.battle_turn = null + if(SSmob_hunt.red_terminal == src) + SSmob_hunt.red_terminal = null + if(SSmob_hunt.blue_terminal == src) + SSmob_hunt.blue_terminal = null QDEL_NULL(avatar) return ..() @@ -80,7 +80,7 @@ /obj/machinery/computer/mob_battle_terminal/proc/eject_card(override = 0) if(!override) - if(ready && mob_hunt_server.battle_turn != team) + if(ready && SSmob_hunt.battle_turn != team) audible_message("You can't recall on your rival's turn!", null, 2) return card.mob_data = mob_info @@ -126,7 +126,7 @@ dat += "

No Nano-Mob card loaded.

" dat += "" dat += "" - if(ready && mob_hunt_server.battle_turn) //offer the surrender option if they are in a battle (ready), but don't have a card loaded + if(ready && SSmob_hunt.battle_turn) //offer the surrender option if they are in a battle (ready), but don't have a card loaded dat += "" dat += "Surrender!" dat += "" @@ -170,7 +170,7 @@ dat += "" dat += "Battle!" dat += "" - if(ready && !mob_hunt_server.battle_turn) + if(ready && !SSmob_hunt.battle_turn) dat += "" dat += "Cancel Battle!" dat += "" @@ -205,23 +205,23 @@ /obj/machinery/computer/mob_battle_terminal/proc/check_connection() if(team == "Red") - if(mob_hunt_server && !mob_hunt_server.red_terminal) - mob_hunt_server.red_terminal = src + if(SSmob_hunt && !SSmob_hunt.red_terminal) + SSmob_hunt.red_terminal = src else if(team == "Blue") - if(mob_hunt_server && !mob_hunt_server.blue_terminal) - mob_hunt_server.blue_terminal = src + if(SSmob_hunt && !SSmob_hunt.blue_terminal) + SSmob_hunt.blue_terminal = src /obj/machinery/computer/mob_battle_terminal/proc/do_attack() if(!ready) //no attacking if you arent ready to fight (duh) return - if(!mob_hunt_server || team != mob_hunt_server.battle_turn) //don't attack unless it is actually our turn + if(!SSmob_hunt || team != SSmob_hunt.battle_turn) //don't attack unless it is actually our turn return else var/message = "[mob_info.mob_name] attacks!" if(mob_info.nickname) message = "[mob_info.nickname] attacks!" audible_message(message, null, 5) - mob_hunt_server.launch_attack(team, mob_info.get_raw_damage(), mob_info.get_attack_type()) + SSmob_hunt.launch_attack(team, mob_info.get_raw_damage(), mob_info.get_attack_type()) /obj/machinery/computer/mob_battle_terminal/proc/start_battle() if(ready) //don't do anything if we are still ready @@ -230,20 +230,20 @@ return ready = 1 audible_message("[team] Player is ready for battle! Waiting for rival...", null, 5) - mob_hunt_server.start_check() + SSmob_hunt.start_check() /obj/machinery/computer/mob_battle_terminal/proc/receive_attack(raw_damage, datum/mob_type/attack_type) var/message = mob_info.take_damage(raw_damage, attack_type) avatar.audible_message(message, null, 5) if(!mob_info.cur_health) - mob_hunt_server.end_battle(team) + SSmob_hunt.end_battle(team) eject_card(1) //force the card out, they were defeated else - mob_hunt_server.end_turn() + SSmob_hunt.end_turn() /obj/machinery/computer/mob_battle_terminal/proc/surrender() audible_message("[team] Player surrenders the battle!", null, 5) - mob_hunt_server.end_battle(team, 1) + SSmob_hunt.end_battle(team, 1) ////////////////////////////// // Mob Healing Terminal // diff --git a/code/modules/arcade/mob_hunt/mob_avatar.dm b/code/modules/arcade/mob_hunt/mob_avatar.dm index e4ea98a44a6..d407a305446 100644 --- a/code/modules/arcade/mob_hunt/mob_avatar.dm +++ b/code/modules/arcade/mob_hunt/mob_avatar.dm @@ -94,33 +94,33 @@ P.audible_message(message, null, 4) /obj/effect/nanomob/proc/despawn() - if(mob_hunt_server) + if(SSmob_hunt) if(mob_info.is_trap) - mob_hunt_server.trap_spawns -= src + SSmob_hunt.trap_spawns -= src else - mob_hunt_server.normal_spawns -= src + SSmob_hunt.normal_spawns -= src qdel(src) /obj/effect/nanomob/proc/reveal() - if(!mob_hunt_server) + if(!SSmob_hunt) return var/list/show_to = list() - for(var/A in mob_hunt_server.connected_clients) - if((A in clients_encountered) || !mob_hunt_server.connected_clients[A]) + for(var/A in SSmob_hunt.connected_clients) + if((A in clients_encountered) || !SSmob_hunt.connected_clients[A]) continue - show_to |= mob_hunt_server.connected_clients[A] + show_to |= SSmob_hunt.connected_clients[A] display_alt_appearance("nanomob_avatar", show_to) /obj/effect/nanomob/proc/conceal(list/hide_from) - if(!mob_hunt_server) + if(!SSmob_hunt) return var/list/hiding_from = list() if(hide_from) hiding_from = hide_from else - for(var/A in mob_hunt_server.connected_clients) - if((A in clients_encountered) && mob_hunt_server.connected_clients[A]) - hiding_from |= mob_hunt_server.connected_clients[A] + for(var/A in SSmob_hunt.connected_clients) + if((A in clients_encountered) && SSmob_hunt.connected_clients[A]) + hiding_from |= SSmob_hunt.connected_clients[A] hide_alt_appearance("nanomob_avatar", hiding_from) // BATTLE MOB AVATARS diff --git a/code/modules/arcade/mob_hunt/mob_datums.dm b/code/modules/arcade/mob_hunt/mob_datums.dm index f6bc9dff826..dad3f528796 100644 --- a/code/modules/arcade/mob_hunt/mob_datums.dm +++ b/code/modules/arcade/mob_hunt/mob_datums.dm @@ -72,12 +72,12 @@ secondary_type = new secondary_type() if(no_register) //for booster pack cards return - if(mob_hunt_server) + if(SSmob_hunt) if(set_trap) - if(mob_hunt_server.register_trap(src)) + if(SSmob_hunt.register_trap(src)) return else if(select_spawn()) - if(mob_hunt_server.register_spawn(src)) + if(SSmob_hunt.register_spawn(src)) return qdel(src) //if you reach this, the datum is just pure clutter, so delete it diff --git a/code/modules/modular_computers/file_system/programs/command/comms.dm b/code/modules/modular_computers/file_system/programs/command/comms.dm index 2ca6d9928a3..8dfbbefd208 100644 --- a/code/modules/modular_computers/file_system/programs/command/comms.dm +++ b/code/modules/modular_computers/file_system/programs/command/comms.dm @@ -376,8 +376,8 @@ setMenuState(usr,COMM_SCREEN_MAIN) if("RestartNanoMob") - if(mob_hunt_server) - if(mob_hunt_server.manual_reboot()) + if(SSmob_hunt) + if(SSmob_hunt.manual_reboot()) var/loading_msg = pick("Respawning spawns", "Reticulating splines", "Flipping hat", "Capturing all of them", "Fixing minor text issues", "Being the very best", "Nerfing this", "Not communicating with playerbase", "Coding a ripoff in a 2D spaceman game") diff --git a/code/modules/pda/mob_hunt_game_app.dm b/code/modules/pda/mob_hunt_game_app.dm index 86005f98f5a..c08e64b7ae3 100644 --- a/code/modules/pda/mob_hunt_game_app.dm +++ b/code/modules/pda/mob_hunt_game_app.dm @@ -29,7 +29,7 @@ processing_objects.Remove(pda) /datum/data/pda/app/mob_hunter_game/proc/scan_nearby() - if(!mob_hunt_server || !connected) + if(!SSmob_hunt || !connected) return for(var/turf/T in range(scan_range, get_turf(pda))) for(var/obj/effect/nanomob/N in T.contents) @@ -41,10 +41,10 @@ N.reveal() /datum/data/pda/app/mob_hunter_game/proc/reconnect() - if(!mob_hunt_server || !mob_hunt_server.server_status || connected) + if(!SSmob_hunt || !SSmob_hunt.server_status || connected) //show a message about the server being unavailable (because it doesn't exist / didn't get set to the global var / is offline) return 0 - mob_hunt_server.connected_clients += src + SSmob_hunt.connected_clients += src connected = 1 if(pda) pda.audible_message("[bicon(pda)] Connection established. Capture all of the mobs, [pda.owner ? pda.owner : "hunter"]!", null, 2) @@ -59,10 +59,10 @@ return null /datum/data/pda/app/mob_hunter_game/proc/disconnect(reason = null) - if(!mob_hunt_server || !connected) + if(!SSmob_hunt || !connected) return - mob_hunt_server.connected_clients -= src - for(var/obj/effect/nanomob/N in (mob_hunt_server.normal_spawns + mob_hunt_server.trap_spawns)) + SSmob_hunt.connected_clients -= src + for(var/obj/effect/nanomob/N in (SSmob_hunt.normal_spawns + SSmob_hunt.trap_spawns)) N.conceal(list(get_player())) connected = 0 //show a disconnect message if we were disconnected involuntarily (reason argument provided) @@ -70,7 +70,7 @@ pda.audible_message("[bicon(pda)] Disconnected from server. Reason: [reason].", null, 2) /datum/data/pda/app/mob_hunter_game/program_process() - if(!mob_hunt_server || !connected) + if(!SSmob_hunt || !connected) return scan_nearby() @@ -83,7 +83,7 @@ return 1 /datum/data/pda/app/mob_hunter_game/update_ui(mob/user, list/data) - if(!mob_hunt_server || !(src in mob_hunt_server.connected_clients)) + if(!SSmob_hunt || !(src in SSmob_hunt.connected_clients)) data["connected"] = 0 else data["connected"] = 1 diff --git a/paradise.dme b/paradise.dme index 7c4deb70dd2..669d9080898 100644 --- a/paradise.dme +++ b/paradise.dme @@ -194,7 +194,6 @@ #include "code\controllers\Processes\event.dm" #include "code\controllers\Processes\fast_process.dm" #include "code\controllers\Processes\lighting.dm" -#include "code\controllers\Processes\nano_mob_hunter.dm" #include "code\controllers\Processes\npcai.dm" #include "code\controllers\Processes\npcpool.dm" #include "code\controllers\Processes\obj.dm" @@ -208,6 +207,7 @@ #include "code\controllers\subsystem\garbage.dm" #include "code\controllers\subsystem\machinery.dm" #include "code\controllers\subsystem\mobs.dm" +#include "code\controllers\subsystem\nano_mob_hunter.dm" #include "code\controllers\subsystem\nanoui.dm" #include "code\controllers\subsystem\nightshift.dm" #include "code\controllers\subsystem\spacedrift.dm"