Files
CHOMPStation2/code/game/machinery/computer/ai_core.dm
Neerti 99eb6f9404 Updates Tools
Adds toolspeed var, which is a multiplier on how 'fast' the tool works.  0.5 means it goes twice as fast.
Adds usesound var, which determines what sound is used when a tool is being used.
Changes a lot of code to use those two vars instead.
Adds 'ayyy' tools, which are ported from /tg/'s abductor gamemode.  They're currently admin only but I might make them obtainable by xenoarch later.
Adds powertools, also from /tg/.  CE starts with them in a new toolbelt that spawns in their locker, ported from (you guessed it) /tg/.
Changes welder sprites to look nicer, ported yet again from /tg/.  Modified the blue welder slightly so it can be the electric welder sprite.
Adds various sounds from /tg/, for tools and welders.
2017-08-03 04:49:23 -04:00

271 lines
10 KiB
Plaintext

/obj/structure/AIcore
density = 1
anchored = 0
name = "\improper AI core"
icon = 'icons/mob/AI.dmi'
icon_state = "0"
var/state = 0
var/datum/ai_laws/laws = new /datum/ai_laws/nanotrasen
var/obj/item/weapon/circuitboard/circuit = null
var/obj/item/device/mmi/brain = null
/obj/structure/AIcore/attackby(obj/item/P as obj, mob/user as mob)
switch(state)
if(0)
if(istype(P, /obj/item/weapon/wrench))
playsound(loc, P.usesound, 50, 1)
if(do_after(user, 20 * P.toolspeed))
user << "<span class='notice'>You wrench the frame into place.</span>"
anchored = 1
state = 1
if(istype(P, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = P
if(!WT.isOn())
user << "The welder must be on for this task."
return
playsound(loc, WT.usesound, 50, 1)
if(do_after(user, 20 * WT.toolspeed))
if(!src || !WT.remove_fuel(0, user)) return
user << "<span class='notice'>You deconstruct the frame.</span>"
new /obj/item/stack/material/plasteel( loc, 4)
qdel(src)
if(1)
if(istype(P, /obj/item/weapon/wrench))
playsound(loc, P.usesound, 50, 1)
if(do_after(user, 20 * P.toolspeed))
user << "<span class='notice'>You unfasten the frame.</span>"
anchored = 0
state = 0
if(istype(P, /obj/item/weapon/circuitboard/aicore) && !circuit)
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
user << "<span class='notice'>You place the circuit board inside the frame.</span>"
icon_state = "1"
circuit = P
user.drop_item()
P.loc = src
if(istype(P, /obj/item/weapon/screwdriver) && circuit)
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You screw the circuit board into place.</span>"
state = 2
icon_state = "2"
if(istype(P, /obj/item/weapon/crowbar) && circuit)
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You remove the circuit board.</span>"
state = 1
icon_state = "0"
circuit.loc = loc
circuit = null
if(2)
if(istype(P, /obj/item/weapon/screwdriver) && circuit)
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You unfasten the circuit board.</span>"
state = 1
icon_state = "1"
if(istype(P, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C = P
if (C.get_amount() < 5)
user << "<span class='warning'>You need five coils of wire to add them to the frame.</span>"
return
user << "<span class='notice'>You start to add cables to the frame.</span>"
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
if (do_after(user, 20) && state == 2)
if (C.use(5))
state = 3
icon_state = "3"
user << "<span class='notice'>You add cables to the frame.</span>"
return
if(3)
if(istype(P, /obj/item/weapon/wirecutters))
if (brain)
user << "Get that brain out of there first"
else
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You remove the cables.</span>"
state = 2
icon_state = "2"
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc )
A.amount = 5
if(istype(P, /obj/item/stack/material) && P.get_material_name() == "rglass")
var/obj/item/stack/RG = P
if (RG.get_amount() < 2)
user << "<span class='warning'>You need two sheets of glass to put in the glass panel.</span>"
return
user << "<span class='notice'>You start to put in the glass panel.</span>"
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
if (do_after(user, 20) && state == 3)
if(RG.use(2))
user << "<span class='notice'>You put in the glass panel.</span>"
state = 4
icon_state = "4"
if(istype(P, /obj/item/weapon/aiModule/asimov))
laws.add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
laws.add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
laws.add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
usr << "Law module applied."
if(istype(P, /obj/item/weapon/aiModule/nanotrasen))
laws.add_inherent_law("Safeguard: Protect your assigned space station to the best of your ability. It is not something we can easily afford to replace.")
laws.add_inherent_law("Serve: Serve the crew of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
laws.add_inherent_law("Protect: Protect the crew of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
laws.add_inherent_law("Survive: AI units are not expendable, they are expensive. Do not allow unauthorized personnel to tamper with your equipment.")
usr << "Law module applied."
if(istype(P, /obj/item/weapon/aiModule/purge))
laws.clear_inherent_laws()
usr << "Law module applied."
if(istype(P, /obj/item/weapon/aiModule/freeform))
var/obj/item/weapon/aiModule/freeform/M = P
laws.add_inherent_law(M.newFreeFormLaw)
usr << "Added a freeform law."
if(istype(P, /obj/item/device/mmi))
var/obj/item/device/mmi/M = P
if(!M.brainmob)
user << "<span class='warning'>Sticking an empty [P] into the frame would sort of defeat the purpose.</span>"
return
if(M.brainmob.stat == 2)
user << "<span class='warning'>Sticking a dead [P] into the frame would sort of defeat the purpose.</span>"
return
if(jobban_isbanned(M.brainmob, "AI"))
user << "<span class='warning'>This [P] does not seem to fit.</span>"
return
if(M.brainmob.mind)
clear_antag_roles(M.brainmob.mind, 1)
user.drop_item()
P.loc = src
brain = P
usr << "Added [P]."
icon_state = "3b"
if(istype(P, /obj/item/weapon/crowbar) && brain)
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You remove the brain.</span>"
brain.loc = loc
brain = null
icon_state = "3"
if(4)
if(istype(P, /obj/item/weapon/crowbar))
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You remove the glass panel.</span>"
state = 3
if (brain)
icon_state = "3b"
else
icon_state = "3"
new /obj/item/stack/material/glass/reinforced( loc, 2 )
return
if(istype(P, /obj/item/weapon/screwdriver))
playsound(loc, P.usesound, 50, 1)
user << "<span class='notice'>You connect the monitor.</span>"
if(!brain)
var/open_for_latejoin = alert(user, "Would you like this core to be open for latejoining AIs?", "Latejoin", "Yes", "Yes", "No") == "Yes"
var/obj/structure/AIcore/deactivated/D = new(loc)
if(open_for_latejoin)
empty_playable_ai_cores += D
else
var/mob/living/silicon/ai/A = new /mob/living/silicon/ai ( loc, laws, brain )
if(A) //if there's no brain, the mob is deleted and a structure/AIcore is created
A.rename_self("ai", 1)
feedback_inc("cyborg_ais_created",1)
qdel(src)
/obj/structure/AIcore/deactivated
name = "inactive AI"
icon = 'icons/mob/AI.dmi'
icon_state = "ai-empty"
anchored = 1
state = 20//So it doesn't interact based on the above. Not really necessary.
/obj/structure/AIcore/deactivated/Destroy()
if(src in empty_playable_ai_cores)
empty_playable_ai_cores -= src
return ..()
/obj/structure/AIcore/deactivated/proc/load_ai(var/mob/living/silicon/ai/transfer, var/obj/item/device/aicard/card, var/mob/user)
if(!istype(transfer) || locate(/mob/living/silicon/ai) in src)
return
transfer.aiRestorePowerRoutine = 0
transfer.control_disabled = 0
transfer.aiRadio.disabledAi = 0
transfer.loc = get_turf(src)
transfer.create_eyeobj()
transfer.cancel_camera()
user << "<span class='notice'>Transfer successful:</span> [transfer.name] placed within stationary core."
transfer << "You have been transferred into a stationary core. Remote device connection restored."
if(card)
card.clear()
qdel(src)
/obj/structure/AIcore/deactivated/proc/check_malf(var/mob/living/silicon/ai/ai)
if(!ai) return
for (var/datum/mind/malfai in malf.current_antagonists)
if (ai.mind == malfai)
return 1
/obj/structure/AIcore/deactivated/attackby(var/obj/item/weapon/W, var/mob/user)
if(istype(W, /obj/item/device/aicard))
var/obj/item/device/aicard/card = W
var/mob/living/silicon/ai/transfer = locate() in card
if(transfer)
load_ai(transfer,card,user)
else
user << "<span class='danger'>ERROR:</span> Unable to locate artificial intelligence."
return
else if(istype(W, /obj/item/weapon/wrench))
if(anchored)
user.visible_message("<span class='notice'>\The [user] starts to unbolt \the [src] from the plating...</span>")
playsound(src, W.usesound, 50, 1)
if(!do_after(user,40 * W.toolspeed))
user.visible_message("<span class='notice'>\The [user] decides not to unbolt \the [src].</span>")
return
user.visible_message("<span class='notice'>\The [user] finishes unfastening \the [src]!</span>")
anchored = 0
return
else
user.visible_message("<span class='notice'>\The [user] starts to bolt \the [src] to the plating...</span>")
playsound(src, W.usesound, 50, 1)
if(!do_after(user,40 * W.toolspeed))
user.visible_message("<span class='notice'>\The [user] decides not to bolt \the [src].</span>")
return
user.visible_message("<span class='notice'>\The [user] finishes fastening down \the [src]!</span>")
anchored = 1
return
else
return ..()
/client/proc/empty_ai_core_toggle_latejoin()
set name = "Toggle AI Core Latejoin"
set category = "Admin"
var/list/cores = list()
for(var/obj/structure/AIcore/deactivated/D in world)
cores["[D] ([D.loc.loc])"] = D
var/id = input("Which core?", "Toggle AI Core Latejoin", null) as null|anything in cores
if(!id) return
var/obj/structure/AIcore/deactivated/D = cores[id]
if(!D) return
if(D in empty_playable_ai_cores)
empty_playable_ai_cores -= D
src << "\The [id] is now <font color=\"#ff0000\">not available</font> for latejoining AIs."
else
empty_playable_ai_cores += D
src << "\The [id] is now <font color=\"#008000\">available</font> for latejoining AIs."