From cd4fe5affa8ae3659f8ae9f8fed8f94a5919e288 Mon Sep 17 00:00:00 2001 From: ZomgPonies Date: Mon, 19 Aug 2013 19:27:47 -0400 Subject: [PATCH] Malf AI action - Robot Factory --- .../gamemodes/malfunction/Malf_Modules.dm | 70 ++++++++++++++++++- code/game/machinery/transformer.dm | 60 +++++++++++++--- code/modules/recycling/conveyor2.dm | 26 +++++-- 3 files changed, 142 insertions(+), 14 deletions(-) diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 104fbf1cdb7..6f3252d9a4b 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -178,6 +178,63 @@ rcd light flash thingy on matter drain else usr << "Out of uses." +/datum/AI_Module/large/place_cyborg_transformer + module_name = "Place Robotic Factory" + mod_pick_name = "robfactory" + +/mob/living/silicon/ai/proc/place_transformer() + set name = "Place Robotic Factory" + set category = "Malfunction" + + if(eyeobj) + return + + if(!isturf(usr.loc)) // AI must be in it's core. + return + + var/datum/AI_Module/large/place_cyborg_transformer/PCT = locate(/datum/AI_Module/large/place_cyborg_transformer) in usr:current_modules + if(!PCT) + return + + if(PCT.uses < 1) + usr << "Out of uses." + return + + var/sure = alert(usr, "Make sure the room it is in is big enough, there is camera vision and that there is a 1x3 area for the machine. Are you sure you want to place the machine here?", "Are you sure?", "Yes", "No") + if(sure != "Yes") + return + + // Make sure there is enough room. + var/turf/middle = get_turf(eyeobj.loc) + var/list/turfs = list(middle, locate(middle.x - 1, middle.y, middle.z), locate(middle.x + 1, middle.y, middle.z)) + + var/alert_msg = "There isn't enough room. Make sure you are placing the machine in a clear area and on a floor." + + var/datum/camerachunk/C = cameranet.getCameraChunk(middle.x, middle.y, middle.z) + if(!C.visibleTurfs[middle]) + alert(usr, "We cannot get camera vision of this location.") + return + + for(var/T in turfs) + + // Make sure the turfs are clear and the correct type. + if(!istype(T, /turf/simulated/floor)) + alert(usr, alert_msg) + return + + var/turf/simulated/floor/F = T + for(var/atom/movable/AM in F.contents) + if(AM.density) + alert(usr, alert_msg) + return + + // All clear, place the transformer + new /obj/machinery/transformer/conveyor(middle) + playsound(middle, 'sound/effects/phasein.ogg', 100, 1) +// usr.can_shunt = 0 + PCT.uses -= 1 +// usr << "You cannot shunt anymore." + /datum/AI_Module/module_picker var/temp = null @@ -217,7 +274,18 @@ rcd light flash thingy on matter drain /datum/AI_Module/module_picker/Topic(href, href_list) ..() - if (href_list["coreup"]) + if (href_list["robfactory"]) + var/already + for (var/datum/AI_Module/mod in usr:current_modules) + if(istype(mod, /datum/AI_Module/large/place_cyborg_transformer)) + already = 1 + if (!already) + usr:current_modules += new /datum/AI_Module/large/place_cyborg_transformer + usr.verbs += /mob/living/silicon/ai/proc/place_transformer + src.temp = "Place a Robot Factory to turn humans into cyborgs." + else src.temp = "Additional Robot Factory." + src.processing_time -= 100 + else if (href_list["coreup"]) var/already for (var/datum/AI_Module/mod in usr:current_modules) if(istype(mod, /datum/AI_Module/large/fireproof_core)) diff --git a/code/game/machinery/transformer.dm b/code/game/machinery/transformer.dm index a817c2c3a55..262357bb63b 100644 --- a/code/game/machinery/transformer.dm +++ b/code/game/machinery/transformer.dm @@ -1,6 +1,6 @@ /obj/machinery/transformer name = "Automatic Robotic Factory 5000" - desc = "A large metalic machine with an entrance and an exit. A sign on the side reads, 'human go in, robot come out', human must be lying down and alive." + desc = "A large metalic machine with an entrance and an exit. A sign on the side reads, 'human go in, robot come out', human must be lying down and alive. Has to cooldown between each use." icon = 'icons/obj/recycling.dmi' icon_state = "separator-AO1" layer = MOB_LAYER+1 // Overhead @@ -8,13 +8,31 @@ density = 1 var/transform_dead = 0 var/transform_standing = 0 + var/cooldown_duration = 600 // 1 minute + var/cooldown = 0 + var/robot_cell_charge = 5000 /obj/machinery/transformer/New() // On us ..() - new /obj/machinery/conveyor(loc, WEST, 1) + new /obj/machinery/conveyor/auto(loc, WEST) + +/obj/machinery/transformer/power_change() + ..() + update_icon() + +/obj/machinery/transformer/update_icon() + ..() + if(stat & (BROKEN|NOPOWER) || cooldown == 1) + icon_state = "separator-AO0" + else + icon_state = initial(icon_state) /obj/machinery/transformer/Bumped(var/atom/movable/AM) + + if(cooldown == 1) + return + // HasEntered didn't like people lying down. if(ishuman(AM)) // Only humans can enter from the west side, while lying down. @@ -27,17 +45,41 @@ /obj/machinery/transformer/proc/transform(var/mob/living/carbon/human/H) if(stat & (BROKEN|NOPOWER)) return + if(cooldown == 1) + return + if(!transform_dead && H.stat == DEAD) playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) return + playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) + H.emote("scream") // It is painful + H.adjustBruteLoss(max(0, 80 - H.getBruteLoss())) // Hurt the human, don't try to kill them though. + H.handle_regular_hud_updates() // Make sure they see the pain. + + // Sleep for a couple of ticks to allow the human to see the pain + sleep(5) + use_power(5000) // Use a lot of power. - var/mob/living/silicon/robot = H.Robotize() - robot.lying = 1 - spawn(50) // So he can't jump out the gate right away. + var/mob/living/silicon/robot/R = H.Robotize(1) // Delete the items or they'll all pile up in a single tile and lag + + R.cell.maxcharge = robot_cell_charge + R.cell.charge = robot_cell_charge + + // So he can't jump out the gate right away. + R.lockcharge = !R.lockcharge + spawn(50) playsound(src.loc, 'sound/machines/ping.ogg', 50, 0) - if(robot) - robot.lying = 0 + sleep(30) + if(R) + R.lockcharge = !R.lockcharge + + // Activate the cooldown + cooldown = 1 + update_icon() + spawn(cooldown_duration) + cooldown = 0 + update_icon() /obj/machinery/transformer/conveyor/New() ..() @@ -48,9 +90,9 @@ //East var/turf/east = locate(T.x + 1, T.y, T.z) if(istype(east, /turf/simulated/floor)) - new /obj/machinery/conveyor(east, WEST, 1) + new /obj/machinery/conveyor/auto(east, WEST) // West var/turf/west = locate(T.x - 1, T.y, T.z) if(istype(west, /turf/simulated/floor)) - new /obj/machinery/conveyor(west, WEST, 1) \ No newline at end of file + new /obj/machinery/conveyor/auto(west, WEST) \ No newline at end of file diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 9ba14f5d74d..b328d5d495a 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -19,8 +19,29 @@ /obj/machinery/conveyor/centcom_auto id = "round_end_belt" + +// Auto conveyour is always on unless unpowered + +/obj/machinery/conveyor/auto/New(loc, newdir) + ..(loc, newdir) + operating = 1 + setmove() + +/obj/machinery/conveyor/auto/update() + if(stat & BROKEN) + icon_state = "conveyor-broken" + operating = 0 + return + else if(!operable) + operating = 0 + else if(stat & NOPOWER) + operating = 0 + else + operating = 1 + icon_state = "conveyor[operating]" + // create a conveyor -/obj/machinery/conveyor/New(loc, newdir, on = 0) +/obj/machinery/conveyor/New(loc, newdir) ..(loc) if(newdir) dir = newdir @@ -49,9 +70,6 @@ if(SOUTHWEST) forwards = WEST backwards = NORTH - if(on) - operating = 1 - setmove() /obj/machinery/conveyor/proc/setmove() if(operating == 1)