From a1021977f488ca489efc52c241046d4331695f78 Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Tue, 3 Sep 2019 18:21:23 -0400 Subject: [PATCH 1/3] Re-add verbs for overload/override machine --- .../gamemodes/malfunction/Malf_Modules.dm | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 9a40cb58881..09c0b488ca9 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -36,6 +36,10 @@ if(initial(uses) > 1) //no need to tell 'em if it was one-use anyway! to_chat(owner, "[name] has run out of uses!") qdel(src) + if(istype(src, /datum/action/innate/ai/overload_machine)) + usr.verbs -= /mob/living/silicon/ai/proc/overload_machine + else if(istype(src, /datum/action/innate/ai/override_machine)) + usr.verbs -= /mob/living/silicon/ai/proc/override_machine //Framework for ranged abilities that can have different effects by left-clicking stuff. /datum/action/innate/ai/ranged @@ -105,6 +109,8 @@ for(var/datum/action/A in AI.actions) if(istype(A, initial(AM.power_type))) qdel(A) + AI.verbs -= /mob/living/silicon/ai/proc/overload_machine + AI.verbs -= /mob/living/silicon/ai/proc/override_machine /datum/module_picker/proc/use(user as mob) var/dat @@ -155,6 +161,16 @@ if(AM.power_type) if(!action) //Unlocking for the first time var/datum/action/AC = new AM.power_type + + // These two powers are annoying as fuck to have as action buttons ONLY. We need verbs for them too, so we can right click on machines to overload/override + // Still adding them as action buttons just to have a neat icon and a tooltip for the amount of charges left + if(istype(AC, /datum/action/innate/ai/overload_machine)) + A.view_core() //A BYOND bug requires you to be viewing your core before your verbs update + A.verbs += /mob/living/silicon/ai/proc/overload_machine + else if(istype(AC, /datum/action/innate/ai/override_machine)) + A.view_core() + A.verbs += /mob/living/silicon/ai/proc/override_machine + AC.Grant(A) A.current_modules += new AM.type temp = AM.description @@ -165,6 +181,13 @@ if(AM.unlock_sound) A.playsound_local(A, AM.unlock_sound, 50, 0) else //Adding uses to an existing module + if(istype(action, /datum/action/innate/ai/overload_machine)) + for(var/datum/AI_Module/small/overload_machine/overload in A.current_modules) + overload.uses += 2 + else if(istype(action, /datum/action/innate/ai/override_machine)) + for(var/datum/AI_Module/small/override_machine/override in A.current_modules) + override.uses += 4 + action.uses += initial(action.uses) action.desc = "[initial(action.desc)] It has [action.uses] use\s remaining." action.UpdateButtonIcon() @@ -188,6 +211,7 @@ var/upgrade //If the module gives a passive upgrade, use this. Mutually exclusive with power_type. var/unlock_text = "Hello World!" //Text shown when an ability is unlocked var/unlock_sound //Sound played when an ability is unlocked + var/uses /datum/AI_Module/proc/upgrade(mob/living/silicon/AI/AI) //Apply upgrades! return @@ -454,6 +478,7 @@ mod_pick_name = "overload" description = "Overheats an electrical machine, causing a small explosion and destroying it. Two uses per purchase." cost = 20 + uses = 2 power_type = /datum/action/innate/ai/overload_machine unlock_text = "You enable the ability for the station's APCs to direct intense energy into machinery." @@ -493,12 +518,45 @@ to_chat(owner, "That's not a machine.") return +/mob/living/silicon/ai/proc/overload_machine(obj/machinery/M in GLOB.machines) + set name = "Overload Machine" + set category = "Malfunction" + + if(stat) + return + + if(istype(M, /obj/machinery)) + for(var/datum/AI_Module/small/overload_machine/overload in current_modules) + if(overload.uses > 0) + overload.uses-- + + // This section is for updating the ability's associated action button tooltip after using the right click verb to overload + for(var/datum/action/innate/ai/A in usr.actions) + if(istype(A, /datum/action/innate/ai/overload_machine)) + A.adjust_uses(-1) + A.desc = "[initial(A.desc)] It has [overload.uses] use\s remaining." + A.UpdateButtonIcon() + break + + audible_message("You hear a loud electrical buzzing sound!") + to_chat(src, "Overloading machine circuitry...") + spawn(50) + if(M) + explosion(get_turf(M), 0,1,1,0) + qdel(M) + + if(overload.uses == 0) + usr.verbs -= /mob/living/silicon/ai/proc/overload_machine + else + to_chat(src, "That's not a machine.") + //Override Machine: Allows the AI to override a machine, animating it into an angry, living version of itself. /datum/AI_Module/small/override_machine module_name = "Machine Override" mod_pick_name = "override" description = "Overrides a machine's programming, causing it to rise up and attack everyone except other machines. Four uses." cost = 30 + uses = 4 power_type = /datum/action/innate/ai/override_machine unlock_text = "You procure a virus from the Space Dark Web and prepare to distribute it to the station's machines." @@ -540,6 +598,39 @@ to_chat(owner, "That's not a machine.") return +/mob/living/silicon/ai/proc/override_machine(obj/machinery/M in GLOB.machines) + set name = "Override Machine" + set category = "Malfunction" + + if(stat) + return + + if(istype(M, /obj/machinery)) + if(!M.can_be_overridden()) + to_chat(src, "Can't override this device.") + for(var/datum/AI_Module/small/override_machine/override in current_modules) + if(override.uses > 0) + override.uses-- + + // This section is for updating the ability's associated action tooltip button after using the right click verb to override + for(var/datum/action/innate/ai/A in usr.actions) + if(istype(A, /datum/action/innate/ai/override_machine)) + A.adjust_uses(-1) + A.desc = "[initial(A.desc)] It has [override.uses] use\s remaining." + A.UpdateButtonIcon() + break + + audible_message("You hear a loud electrical buzzing sound!") + to_chat(src, "Reprogramming machine behaviour...") + spawn(50) + if(M && !QDELETED(M)) + new /mob/living/simple_animal/hostile/mimic/copy/machine(get_turf(M), M, src, 1) + + if(override.uses == 0) + usr.verbs -= /mob/living/silicon/ai/proc/override_machine + else + to_chat(src, "That's not a machine.") + //Robotic Factory: Places a large machine that converts humans that go through it into cyborgs. Unlocking this ability removes shunting. /datum/AI_Module/large/place_cyborg_transformer module_name = "Robotic Factory (Removes Shunting)" From 641153815756c5e4cf80e04a50f5fc731b71aeac Mon Sep 17 00:00:00 2001 From: SteelSlayer Date: Wed, 4 Sep 2019 21:05:43 -0400 Subject: [PATCH 2/3] these abilities are point and click now --- code/datums/spell.dm | 3 + .../gamemodes/malfunction/Malf_Modules.dm | 220 ++++++------------ icons/effects/overload_machine_target.dmi | Bin 0 -> 457 bytes icons/effects/override_machine_target.dmi | Bin 0 -> 380 bytes 4 files changed, 77 insertions(+), 146 deletions(-) create mode 100644 icons/effects/overload_machine_target.dmi create mode 100644 icons/effects/override_machine_target.dmi diff --git a/code/datums/spell.dm b/code/datums/spell.dm index d8c7b26554c..b510434f467 100644 --- a/code/datums/spell.dm +++ b/code/datums/spell.dm @@ -5,6 +5,7 @@ var/panel = "Debug"//What panel the proc holder needs to go on. var/active = FALSE //Used by toggle based abilities. var/ranged_mousepointer + var/mob/living/ranged_ability_user var/list/spells = typesof(/obj/effect/proc_holder/spell) //needed for the badmin verb for now @@ -24,6 +25,7 @@ var/list/spells = typesof(/obj/effect/proc_holder/spell) //needed for the badmin to_chat(user, "[user.ranged_ability.name] has been replaced by [name].") user.ranged_ability.remove_ranged_ability(user) user.ranged_ability = src + ranged_ability_user = user user.client.click_intercept = user.ranged_ability add_mousepointer(user.client) active = TRUE @@ -43,6 +45,7 @@ var/list/spells = typesof(/obj/effect/proc_holder/spell) //needed for the badmin if(!user || !user.client || (user.ranged_ability && user.ranged_ability != src)) //To avoid removing the wrong ability return user.ranged_ability = null + ranged_ability_user = null user.client.click_intercept = null remove_mousepointer(user.client) active = FALSE diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 09c0b488ca9..1a6fea2af6c 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -36,10 +36,6 @@ if(initial(uses) > 1) //no need to tell 'em if it was one-use anyway! to_chat(owner, "[name] has run out of uses!") qdel(src) - if(istype(src, /datum/action/innate/ai/overload_machine)) - usr.verbs -= /mob/living/silicon/ai/proc/overload_machine - else if(istype(src, /datum/action/innate/ai/override_machine)) - usr.verbs -= /mob/living/silicon/ai/proc/override_machine //Framework for ranged abilities that can have different effects by left-clicking stuff. /datum/action/innate/ai/ranged @@ -81,13 +77,13 @@ var/disable_text = "Goodbye Cruel World!" //Context clues! var/datum/action/innate/ai/ranged/attached_action -/obj/effect/proc_holder/ranged_ai/Destroy() - QDEL_NULL(attached_action) - return ..() +// /obj/effect/proc_holder/ranged_ai/Destroy() +// QDEL_NULL(attached_action) +// return ..() /obj/effect/proc_holder/ranged_ai/proc/toggle(mob/user) if(active) - remove_ranged_ability(disable_text) + remove_ranged_ability(user, disable_text) else add_ranged_ability(user, enable_text) @@ -109,8 +105,6 @@ for(var/datum/action/A in AI.actions) if(istype(A, initial(AM.power_type))) qdel(A) - AI.verbs -= /mob/living/silicon/ai/proc/overload_machine - AI.verbs -= /mob/living/silicon/ai/proc/override_machine /datum/module_picker/proc/use(user as mob) var/dat @@ -161,16 +155,6 @@ if(AM.power_type) if(!action) //Unlocking for the first time var/datum/action/AC = new AM.power_type - - // These two powers are annoying as fuck to have as action buttons ONLY. We need verbs for them too, so we can right click on machines to overload/override - // Still adding them as action buttons just to have a neat icon and a tooltip for the amount of charges left - if(istype(AC, /datum/action/innate/ai/overload_machine)) - A.view_core() //A BYOND bug requires you to be viewing your core before your verbs update - A.verbs += /mob/living/silicon/ai/proc/overload_machine - else if(istype(AC, /datum/action/innate/ai/override_machine)) - A.view_core() - A.verbs += /mob/living/silicon/ai/proc/override_machine - AC.Grant(A) A.current_modules += new AM.type temp = AM.description @@ -181,13 +165,6 @@ if(AM.unlock_sound) A.playsound_local(A, AM.unlock_sound, 50, 0) else //Adding uses to an existing module - if(istype(action, /datum/action/innate/ai/overload_machine)) - for(var/datum/AI_Module/small/overload_machine/overload in A.current_modules) - overload.uses += 2 - else if(istype(action, /datum/action/innate/ai/override_machine)) - for(var/datum/AI_Module/small/override_machine/override in A.current_modules) - override.uses += 4 - action.uses += initial(action.uses) action.desc = "[initial(action.desc)] It has [action.uses] use\s remaining." action.UpdateButtonIcon() @@ -373,7 +350,7 @@ for(var/obj/machinery/door/D in GLOB.airlocks) if(!is_station_level(D.z)) continue - INVOKE_ASYNC(D, /obj/machinery/door.proc/hostile_lockdown, src) + INVOKE_ASYNC(D, /obj/machinery/door.proc/hostile_lockdown, owner) addtimer(CALLBACK(D, /obj/machinery/door.proc/disable_lockdown), 900) post_status("alert", "lockdown") @@ -472,83 +449,60 @@ to_chat(owner, "All air alarm safeties on the station have been overriden. Air alarms may now use the Flood environmental mode.") owner.playsound_local(owner, 'sound/machines/terminal_off.ogg', 50, 0) + //Overload Machine: Allows the AI to overload a machine, detonating it after a delay. Two uses per purchase. /datum/AI_Module/small/overload_machine module_name = "Machine Overload" mod_pick_name = "overload" description = "Overheats an electrical machine, causing a small explosion and destroying it. Two uses per purchase." cost = 20 - uses = 2 - power_type = /datum/action/innate/ai/overload_machine + power_type = /datum/action/innate/ai/ranged/overload_machine unlock_text = "You enable the ability for the station's APCs to direct intense energy into machinery." -/datum/action/innate/ai/overload_machine +/datum/action/innate/ai/ranged/overload_machine name = "Overload Machine" desc = "Overheats a machine, causing a small explosion after a short time." button_icon_state = "overload_machine" uses = 2 - auto_use_uses = FALSE + linked_ability_type = /obj/effect/proc_holder/ranged_ai/overload_machine -/datum/action/innate/ai/overload_machine/New() +/datum/action/innate/ai/ranged/overload_machine/New() ..() desc = "[desc] It has [uses] use\s remaining." button.desc = desc -/datum/action/innate/ai/overload_machine/Activate() - var/select = input("Choose a device to overload", "Overload Machine", null, null) as null|anything in GLOB.machines - if(!select) +/datum/action/innate/ai/ranged/overload_machine/proc/detonate_machine(obj/machinery/M) + if(M && !QDELETED(M)) + explosion(get_turf(M), 0,1,1,0) + if(M) //to check if the explosion killed it before we try to delete it + qdel(M) + +/obj/effect/proc_holder/ranged_ai/overload_machine + active = FALSE + ranged_mousepointer = 'icons/effects/overload_machine_target.dmi' + enable_text = "You tap into the station's powernet. Click on a machine to detonate it, or use the ability again to cancel." + disable_text = "You release your hold on the powernet." + +/obj/effect/proc_holder/ranged_ai/overload_machine/InterceptClickOn(mob/living/caller, params, obj/machinery/target) + if(..()) + return + if(ranged_ability_user.incapacitated()) + remove_ranged_ability() + return + if(!istype(target)) + to_chat(ranged_ability_user, "You can only overload machines!") return - var/obj/machinery/M = select - if(istype(M, /obj/machinery)) - if(uses > 0) - adjust_uses(-1) - if(src && uses) //Not sure if not having src here would cause a runtime, so it's here to be safe - desc = "[initial(desc)] It has [uses] use\s remaining." - UpdateButtonIcon() - M.audible_message("You hear a loud electrical buzzing sound!") - to_chat(owner, "Overloading machine circuitry...") - spawn(50) - if(M) - explosion(get_turf(M), 0,1,1,0) - qdel(M) - else - to_chat(owner, "Out of uses.") - else - to_chat(owner, "That's not a machine.") - return + ranged_ability_user.playsound_local(ranged_ability_user, "sparks", 50, 0) + attached_action.adjust_uses(-1) + if(attached_action && attached_action.uses) + attached_action.desc = "[initial(attached_action.desc)] It has [attached_action.uses] use\s remaining." + attached_action.UpdateButtonIcon() + target.audible_message("You hear a loud electrical buzzing sound!") + addtimer(CALLBACK(attached_action, /datum/action/innate/ai/ranged/overload_machine.proc/detonate_machine, target), 50) //kaboom! + remove_ranged_ability(ranged_ability_user, "Overloading machine circuitry...") + return TRUE -/mob/living/silicon/ai/proc/overload_machine(obj/machinery/M in GLOB.machines) - set name = "Overload Machine" - set category = "Malfunction" - - if(stat) - return - - if(istype(M, /obj/machinery)) - for(var/datum/AI_Module/small/overload_machine/overload in current_modules) - if(overload.uses > 0) - overload.uses-- - - // This section is for updating the ability's associated action button tooltip after using the right click verb to overload - for(var/datum/action/innate/ai/A in usr.actions) - if(istype(A, /datum/action/innate/ai/overload_machine)) - A.adjust_uses(-1) - A.desc = "[initial(A.desc)] It has [overload.uses] use\s remaining." - A.UpdateButtonIcon() - break - - audible_message("You hear a loud electrical buzzing sound!") - to_chat(src, "Overloading machine circuitry...") - spawn(50) - if(M) - explosion(get_turf(M), 0,1,1,0) - qdel(M) - - if(overload.uses == 0) - usr.verbs -= /mob/living/silicon/ai/proc/overload_machine - else - to_chat(src, "That's not a machine.") //Override Machine: Allows the AI to override a machine, animating it into an angry, living version of itself. /datum/AI_Module/small/override_machine @@ -556,80 +510,54 @@ mod_pick_name = "override" description = "Overrides a machine's programming, causing it to rise up and attack everyone except other machines. Four uses." cost = 30 - uses = 4 - power_type = /datum/action/innate/ai/override_machine - unlock_text = "You procure a virus from the Space Dark Web and prepare to distribute it to the station's machines." + power_type = /datum/action/innate/ai/ranged/override_machine + unlock_text = "You procure a virus from the Space Dark Web and distribute it to the station's machines." -/datum/action/innate/ai/override_machine +/datum/action/innate/ai/ranged/override_machine name = "Override Machine" desc = "Animates a targeted machine, causing it to attack anyone nearby." button_icon_state = "override_machine" uses = 4 - auto_use_uses = FALSE + linked_ability_type = /obj/effect/proc_holder/ranged_ai/override_machine -/datum/action/innate/ai/override_machine/New() +/datum/action/innate/ai/ranged/override_machine/New() ..() desc = "[desc] It has [uses] use\s remaining." button.desc = desc -/datum/action/innate/ai/override_machine/Activate() - var/select = input("Choose a device to override", "Override Machine", null, null) as null|anything in GLOB.machines - if(!select) +/datum/action/innate/ai/ranged/override_machine/proc/animate_machine(obj/machinery/M) + if(M && !QDELETED(M)) + new/mob/living/simple_animal/hostile/mimic/copy/machine(get_turf(M), M, owner, 1) + +/obj/effect/proc_holder/ranged_ai/override_machine + active = FALSE + ranged_mousepointer = 'icons/effects/override_machine_target.dmi' + enable_text = "You tap into the station's powernet. Click on a machine to animate it, or use the ability again to cancel." + disable_text = "You release your hold on the powernet." + +/obj/effect/proc_holder/ranged_ai/override_machine/InterceptClickOn(mob/living/caller, params, obj/machinery/target) + if(..()) + return + if(ranged_ability_user.incapacitated()) + remove_ranged_ability() + return + if(!istype(target)) + to_chat(ranged_ability_user, "You can only animate machines!") + return + if(!target.can_be_overridden()) + to_chat(ranged_ability_user, "That machine can't be overridden!") return - var/obj/machinery/M = select - if(istype(M, /obj/machinery)) - if(!M.can_be_overridden()) - to_chat(owner, "Can't override this device.") - return - else if(uses > 0) - adjust_uses(-1) - if(src && uses) //Not sure if not having src here would cause a runtime, so it's here to be safe - desc = "[initial(desc)] It has [uses] use\s remaining." - UpdateButtonIcon() - M.audible_message("You hear a loud electrical buzzing sound!") - to_chat(owner, "Reprogramming machine behaviour...") - spawn(50) - if(M && !QDELETED(M)) - new /mob/living/simple_animal/hostile/mimic/copy/machine(get_turf(M), M, src, 1) - else - to_chat(owner, "Out of uses.") - else - to_chat(owner, "That's not a machine.") - return + ranged_ability_user.playsound_local(ranged_ability_user, 'sound/misc/interference.ogg', 50, 0) + attached_action.adjust_uses(-1) + if(attached_action && attached_action.uses) + attached_action.desc = "[initial(attached_action.desc)] It has [attached_action.uses] use\s remaining." + attached_action.UpdateButtonIcon() + target.audible_message("You hear a loud electrical buzzing sound coming from [target]!") + addtimer(CALLBACK(attached_action, /datum/action/innate/ai/ranged/override_machine.proc/animate_machine, target), 50) //kabeep! + remove_ranged_ability(ranged_ability_user, "Sending override signal...") + return TRUE -/mob/living/silicon/ai/proc/override_machine(obj/machinery/M in GLOB.machines) - set name = "Override Machine" - set category = "Malfunction" - - if(stat) - return - - if(istype(M, /obj/machinery)) - if(!M.can_be_overridden()) - to_chat(src, "Can't override this device.") - for(var/datum/AI_Module/small/override_machine/override in current_modules) - if(override.uses > 0) - override.uses-- - - // This section is for updating the ability's associated action tooltip button after using the right click verb to override - for(var/datum/action/innate/ai/A in usr.actions) - if(istype(A, /datum/action/innate/ai/override_machine)) - A.adjust_uses(-1) - A.desc = "[initial(A.desc)] It has [override.uses] use\s remaining." - A.UpdateButtonIcon() - break - - audible_message("You hear a loud electrical buzzing sound!") - to_chat(src, "Reprogramming machine behaviour...") - spawn(50) - if(M && !QDELETED(M)) - new /mob/living/simple_animal/hostile/mimic/copy/machine(get_turf(M), M, src, 1) - - if(override.uses == 0) - usr.verbs -= /mob/living/silicon/ai/proc/override_machine - else - to_chat(src, "That's not a machine.") //Robotic Factory: Places a large machine that converts humans that go through it into cyborgs. Unlocking this ability removes shunting. /datum/AI_Module/large/place_cyborg_transformer diff --git a/icons/effects/overload_machine_target.dmi b/icons/effects/overload_machine_target.dmi new file mode 100644 index 0000000000000000000000000000000000000000..8bc67cdab6c9fd9682b6e4e465b6d97b8ae82214 GIT binary patch literal 457 zcmeAS@N?(olHy`uVBq!ia0vp^2|(oB*9*|78b%_n&WPd@ta z&`iAfaH_l5am({hc;8(MnRMCOsY_REZ*u2#m+6bje5M4iUQ)Kk^6pC4t&1;BlXDNY zekFFhE%xn=P{7d9Y>IJF~NZS6WzsIKH+_-J~XA7WT7(8A5T-G@yGywn*Kfmw* literal 0 HcmV?d00001 diff --git a/icons/effects/override_machine_target.dmi b/icons/effects/override_machine_target.dmi new file mode 100644 index 0000000000000000000000000000000000000000..77dbb4ba32bca0aaa2b3960384dadcc6a8b04f10 GIT binary patch literal 380 zcmV-?0fYXDP)vH|SBicLI86WSQ{^xy3rJ|rA?L;y@kTPb^vJEcR(ai>LEl^pjc1BK&G zOBHDxcRiu^`-yYEUV-CIX;nDx008hcZV$}B>%oZoy}vMUdSC`#59|$24@TS`m;rhK a{^ta-S}cD*)J_@z0000 Date: Fri, 6 Sep 2019 15:54:10 -0400 Subject: [PATCH 3/3] removes Destroy(), adds target back to overload --- code/game/gamemodes/malfunction/Malf_Modules.dm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 1a6fea2af6c..eb54b52c225 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -77,10 +77,6 @@ var/disable_text = "Goodbye Cruel World!" //Context clues! var/datum/action/innate/ai/ranged/attached_action -// /obj/effect/proc_holder/ranged_ai/Destroy() -// QDEL_NULL(attached_action) -// return ..() - /obj/effect/proc_holder/ranged_ai/proc/toggle(mob/user) if(active) remove_ranged_ability(user, disable_text) @@ -498,7 +494,7 @@ if(attached_action && attached_action.uses) attached_action.desc = "[initial(attached_action.desc)] It has [attached_action.uses] use\s remaining." attached_action.UpdateButtonIcon() - target.audible_message("You hear a loud electrical buzzing sound!") + target.audible_message("You hear a loud electrical buzzing sound coming from [target]!") addtimer(CALLBACK(attached_action, /datum/action/innate/ai/ranged/overload_machine.proc/detonate_machine, target), 50) //kaboom! remove_ranged_ability(ranged_ability_user, "Overloading machine circuitry...") return TRUE