mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Ninja Suit Initialization Refactor + Cleanup (#50563)
* ninja cleanup * documentation * missed these
This commit is contained in:
@@ -7,10 +7,6 @@ Contents:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// /obj/item/clothing/suit/space/space_ninja
|
||||
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja
|
||||
name = "ninja suit"
|
||||
desc = "A unique, vacuum-proof suit of nano-enhanced armor designed specifically for Spider Clan assassins."
|
||||
@@ -24,19 +20,19 @@ Contents:
|
||||
min_cold_protection_temperature = SPACE_SUIT_MIN_TEMP_PROTECT
|
||||
actions_types = list(/datum/action/item_action/initialize_ninja_suit, /datum/action/item_action/ninjasmoke, /datum/action/item_action/ninjaboost, /datum/action/item_action/ninjapulse, /datum/action/item_action/ninjastar, /datum/action/item_action/ninjanet, /datum/action/item_action/ninja_sword_recall, /datum/action/item_action/ninja_stealth, /datum/action/item_action/toggle_glove)
|
||||
|
||||
//Important parts of the suit.
|
||||
//Important parts of the suit.
|
||||
var/mob/living/carbon/human/affecting = null
|
||||
var/datum/effect_system/spark_spread/spark_system
|
||||
var/datum/techweb/stored_research
|
||||
var/obj/item/disk/tech_disk/t_disk//To copy design onto disk.
|
||||
var/obj/item/energy_katana/energyKatana //For teleporting the katana back to the ninja (It's an ability)
|
||||
|
||||
//Other articles of ninja gear worn together, used to easily reference them after initializing.
|
||||
//Other articles of ninja gear worn together, used to easily reference them after initializing.
|
||||
var/obj/item/clothing/head/helmet/space/space_ninja/n_hood
|
||||
var/obj/item/clothing/shoes/space_ninja/n_shoes
|
||||
var/obj/item/clothing/gloves/space_ninja/n_gloves
|
||||
|
||||
//Main function variables.
|
||||
//Main function variables.
|
||||
var/s_initialized = 0//Suit starts off.
|
||||
var/s_coold = 0//If the suit is on cooldown. Can be used to attach different cooldowns to abilities. Ticks down every second based on suit ntick().
|
||||
var/s_cost = 5//Base energy cost each ntick.
|
||||
@@ -46,11 +42,11 @@ Contents:
|
||||
var/a_maxamount = 7//Maximum number of adrenaline boosts.
|
||||
var/s_maxamount = 20//Maximum number of smoke bombs.
|
||||
|
||||
//Support function variables.
|
||||
//Support function variables.
|
||||
var/stealth = FALSE//Stealth off.
|
||||
var/s_busy = FALSE//Is the suit busy with a process? Like AI hacking. Used for safety functions.
|
||||
|
||||
//Ability function variables.
|
||||
//Ability function variables.
|
||||
var/s_bombs = 10//Number of smoke bombs.
|
||||
var/a_boost = 3//Number of adrenaline boosters.
|
||||
|
||||
@@ -84,6 +80,21 @@ Contents:
|
||||
var/mob/living/carbon/human/user = src.loc
|
||||
if(!user || !ishuman(user) || !(user.wear_suit == src))
|
||||
return
|
||||
|
||||
// Check for energy usage
|
||||
if(s_initialized)
|
||||
if(!affecting)
|
||||
terminate() // Kills the suit and attached objects.
|
||||
else if(cell.charge > 0)
|
||||
if(s_coold)
|
||||
s_coold-- // Checks for ability s_cooldown first.
|
||||
cell.charge -= s_cost // s_cost is the default energy cost each ntick, usually 5.
|
||||
if(stealth) // If stealth is active.
|
||||
cell.charge -= s_acost
|
||||
else
|
||||
cell.charge = 0
|
||||
cancel_stealth()
|
||||
|
||||
user.adjust_bodytemperature(BODYTEMP_NORMAL - user.bodytemperature)
|
||||
|
||||
//Simply deletes all the attachments and self, killing all related procs.
|
||||
|
||||
@@ -1,94 +1,122 @@
|
||||
#define NINJA_LOCK_PHASE 1
|
||||
#define NINJA_ICON_GENERATE_PHASE 3
|
||||
#define NINJA_COMPLETE_PHASE 6
|
||||
#define NINJA_DEINIT_LOGOFF_PHASE 1
|
||||
#define NINJA_DEINIT_STEALTH_PHASE 5
|
||||
|
||||
GLOBAL_LIST_INIT(ninja_initialize_messages, list(
|
||||
"Now initializing...",
|
||||
"Securing external locking mechanism...\nNeural-net established.",
|
||||
"Extending neural-net interface...\nNow monitoring brain wave pattern...",
|
||||
"Linking neural-net interface...\nPattern <b class='nicegreen'>GREEN</b>, continuing operation.",
|
||||
"VOID-shift device status: <B>ONLINE</B>.\nCLOAK-tech device status: <B>ONLINE</B>.",
|
||||
"Primary system status: <B>ONLINE</B>.\nBackup system status: <B>ONLINE</B>.\nCurrent energy capacity: ",
|
||||
"All systems operational. Welcome to <B>SpiderOS</B>, "
|
||||
))
|
||||
|
||||
GLOBAL_LIST_INIT(ninja_deinitialize_messages, list(
|
||||
"Now de-initializing...",
|
||||
"Shutting down <B>SpiderOS</B>.",
|
||||
"Primary system status: <B>OFFLINE</B>.\nBackup system status: <B>OFFLINE</B>.",
|
||||
"VOID-shift device status: <B>OFFLINE</B>.\nCLOAK-tech device status: <B>OFFLINE</B>.",
|
||||
"Disconnecting neural-net interface...<b class='nicegreen'>Success</b>.",
|
||||
"Disengaging neural-net interface... <b class='nicegreen'>Success</b>.",
|
||||
"Unsecuring external locking mechanism...\nNeural-net abolished.\nOperation status: <B>FINISHED</B>."
|
||||
))
|
||||
|
||||
/**
|
||||
* Toggles the ninja suit on/off
|
||||
*
|
||||
* Attempts to initialize or deinitialize the ninja suit
|
||||
*/
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/toggle_on_off()
|
||||
. = TRUE
|
||||
if(s_busy)
|
||||
to_chat(loc, "<span class='warning'>ERROR</span>: You cannot use this function at this time.")
|
||||
return FALSE
|
||||
s_busy = TRUE
|
||||
if(s_initialized)
|
||||
deinitialize()
|
||||
else
|
||||
ninitialize()
|
||||
. = TRUE
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize(delay = s_delay, mob/living/carbon/human/U = loc)
|
||||
if(!U.mind)
|
||||
return //Not sure how this could happen.
|
||||
s_busy = TRUE
|
||||
to_chat(U, "<span class='notice'>Now initializing...</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_two, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_two(delay, mob/living/carbon/human/U)
|
||||
if(!lock_suit(U))//To lock the suit onto wearer.
|
||||
/**
|
||||
* Initializes the ninja suit
|
||||
*
|
||||
* Initializes the ninja suit through seven phases, each of which calls this proc with an incremented phase
|
||||
* Arguments:
|
||||
* * delay - The delay between each phase of initialization
|
||||
* * U - The human who is being affected by the suit
|
||||
* * phase - The phase of initialization
|
||||
*/
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize(delay = s_delay, mob/living/carbon/human/U = loc, phase = 0)
|
||||
if(!U || !U.mind)
|
||||
s_busy = FALSE
|
||||
return
|
||||
to_chat(U, "<span class='notice'>Securing external locking mechanism...\nNeural-net established.</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_three, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_three(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Extending neural-net interface...\nNow monitoring brain wave pattern...</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_four, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_four(delay, mob/living/carbon/human/U)
|
||||
if(U.stat == DEAD|| U.health <= 0)
|
||||
if (phase > NINJA_LOCK_PHASE && (U.stat == DEAD || U.health <= 0))
|
||||
to_chat(U, "<span class='danger'><B>FÄAL �Rr�R</B>: 344--93#�&&21 BR��N |/|/aV� PATT$RN <B>RED</B>\nA-A-aB�rT�NG...</span>")
|
||||
unlock_suit()
|
||||
s_busy = FALSE
|
||||
return
|
||||
lockIcons(U)//Check for icons.
|
||||
U.regenerate_icons()
|
||||
to_chat(U, "<span class='notice'>Linking neural-net interface...\nPattern</span>\green <B>GREEN</B><span class='notice'>, continuing operation.</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_five, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_five(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>VOID-shift device status: <B>ONLINE</B>.\nCLOAK-tech device status: <B>ONLINE</B>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_six, delay, U), delay)
|
||||
var/message = GLOB.ninja_initialize_messages[phase + 1]
|
||||
switch(phase)
|
||||
if (NINJA_LOCK_PHASE)
|
||||
if(!lock_suit(U))//To lock the suit onto wearer.
|
||||
s_busy = FALSE
|
||||
return
|
||||
if (NINJA_ICON_GENERATE_PHASE)
|
||||
lockIcons(U)//Check for icons.
|
||||
U.regenerate_icons()
|
||||
if (NINJA_COMPLETE_PHASE - 1)
|
||||
message += "<B>[DisplayEnergy(cell.charge)]</B>."
|
||||
if (NINJA_COMPLETE_PHASE)
|
||||
message += "[U.real_name]."
|
||||
s_initialized = TRUE
|
||||
s_busy = FALSE
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_six(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Primary system status: <B>ONLINE</B>.\nBackup system status: <B>ONLINE</B>.\nCurrent energy capacity: <B>[DisplayEnergy(cell.charge)]</B>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/ninitialize_seven, delay, U), delay)
|
||||
to_chat(U, "<span class='notice'>[message]</span>")
|
||||
playsound(U, 'sound/effects/sparks1.ogg', 10, TRUE)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ninitialize_seven(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>All systems operational. Welcome to <B>SpiderOS</B>, [U.real_name].</span>")
|
||||
s_initialized = TRUE
|
||||
ntick()
|
||||
s_busy = FALSE
|
||||
if (phase < NINJA_COMPLETE_PHASE)
|
||||
addtimer(CALLBACK(src, .proc/ninitialize, delay, U, phase + 1), delay)
|
||||
|
||||
/**
|
||||
* Deinitializes the ninja suit
|
||||
*
|
||||
* Deinitializes the ninja suit through eight phases, each of which calls this proc with an incremented phase
|
||||
* Arguments:
|
||||
* * delay - The delay between each phase of deinitialization
|
||||
* * U - The human who is being affected by the suit
|
||||
* * phase - The phase of deinitialization
|
||||
*/
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize(delay = s_delay, mob/living/carbon/human/U = affecting == loc ? affecting : null, phase = 0)
|
||||
if (!U || !U.mind)
|
||||
s_busy = FALSE
|
||||
return
|
||||
if (phase == 0 && alert("Are you certain you wish to remove the suit? This will take time and remove all abilities.",,"Yes","No") == "No")
|
||||
s_busy = FALSE
|
||||
return
|
||||
|
||||
var/message = GLOB.ninja_deinitialize_messages[phase + 1]
|
||||
switch(phase)
|
||||
if(NINJA_DEINIT_LOGOFF_PHASE)
|
||||
message = "Logging off, [U.real_name]. " + message
|
||||
if(NINJA_DEINIT_STEALTH_PHASE)
|
||||
cancel_stealth()
|
||||
to_chat(U, "<span class='notice'>[message]</span>")
|
||||
playsound(U, 'sound/items/deconstruct.ogg', 10, TRUE)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize(delay = s_delay)
|
||||
if(affecting==loc)
|
||||
var/mob/living/carbon/human/U = affecting
|
||||
if(alert("Are you certain you wish to remove the suit? This will take time and remove all abilities.",,"Yes","No")=="No")
|
||||
return
|
||||
s_busy = TRUE
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_two, delay, U), delay)
|
||||
if (phase < NINJA_COMPLETE_PHASE)
|
||||
addtimer(CALLBACK(src, .proc/deinitialize, delay, U, phase + 1), delay)
|
||||
else
|
||||
unlock_suit()
|
||||
U.regenerate_icons()
|
||||
s_initialized = FALSE
|
||||
s_busy = FALSE
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_two(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Now de-initializing...</span>")
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_three, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_three(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Logging off, [U.real_name]. Shutting down <B>SpiderOS</B>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_four, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_four(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Primary system status: <B>OFFLINE</B>.\nBackup system status: <B>OFFLINE</B>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_five, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_five(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>VOID-shift device status: <B>OFFLINE</B>.\nCLOAK-tech device status: <B>OFFLINE</B>.</span>")
|
||||
cancel_stealth()//Shutdowns stealth.
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_six, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_six(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Disconnecting neural-net interface...</span>\green<B>Success</B><span class='notice'>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_seven, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_seven(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Disengaging neural-net interface...</span>\green<B>Success</B><span class='notice'>.</span>")
|
||||
addtimer(CALLBACK(src, .proc/deinitialize_eight, delay, U), delay)
|
||||
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/deinitialize_eight(delay, mob/living/carbon/human/U)
|
||||
to_chat(U, "<span class='notice'>Unsecuring external locking mechanism...\nNeural-net abolished.\nOperation status: <B>FINISHED</B>.</span>")
|
||||
unlock_suit()
|
||||
U.regenerate_icons()
|
||||
s_initialized = FALSE
|
||||
s_busy = FALSE
|
||||
#undef NINJA_LOCK_PHASE
|
||||
#undef NINJA_ICON_GENERATE_PHASE
|
||||
#undef NINJA_COMPLETE_PHASE
|
||||
#undef NINJA_DEINIT_LOGOFF_PHASE
|
||||
#undef NINJA_DEINIT_STEALTH_PHASE
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/obj/item/clothing/suit/space/space_ninja/proc/ntick(mob/living/carbon/human/U = affecting)
|
||||
//Runs in the background while the suit is initialized.
|
||||
//Requires charge or stealth to process.
|
||||
spawn while(s_initialized)
|
||||
if(!affecting)
|
||||
terminate()//Kills the suit and attached objects.
|
||||
|
||||
else if(cell.charge > 0)
|
||||
if(s_coold)
|
||||
s_coold--//Checks for ability s_cooldown first.
|
||||
|
||||
cell.charge -= s_cost//s_cost is the default energy cost each ntick, usually 5.
|
||||
if(stealth)//If stealth is active.
|
||||
cell.charge -= s_acost
|
||||
|
||||
else
|
||||
cell.charge = 0
|
||||
cancel_stealth()
|
||||
|
||||
sleep(10)//Checks every second.
|
||||
@@ -2473,7 +2473,6 @@
|
||||
#include "code\modules\ninja\suit\suit.dm"
|
||||
#include "code\modules\ninja\suit\suit_attackby.dm"
|
||||
#include "code\modules\ninja\suit\suit_initialisation.dm"
|
||||
#include "code\modules\ninja\suit\suit_process.dm"
|
||||
#include "code\modules\ninja\suit\n_suit_verbs\energy_net_nets.dm"
|
||||
#include "code\modules\ninja\suit\n_suit_verbs\ninja_adrenaline.dm"
|
||||
#include "code\modules\ninja\suit\n_suit_verbs\ninja_cost_check.dm"
|
||||
|
||||
Reference in New Issue
Block a user