5f835bfc26
Please refer to #20867 and #20870 for a easier view of the changes. Those two PRs show all meaningful changes (hopefully) and doesn't show the files changed with just 3 lines changed. This PR does three things: It makes all children of /obj/ use the same damage system. Previously to make your new machine/structure be destroyable you needed to give it a var/health, and its own version of many damage related proc such as bullet_act(), take_damage(), attacked_by(), attack_animal(), attack_hulk(), ex_act(), etc... But now, all /obj/ use the same version of those procs at the /obj/ level in code/game/obj_defense.dm. All these obj share the same necessary vars: obj_integrity (health), max_integrity, integrity_failure (optional, below that health level failure happens), and the armor list var which was previously only for items, as well as the resistance_flags bitfield. When you want your new object to be destroyable, you only have to give it a value for those vars and maybe override one proc if you want a special behavior but that's it. This reorganization removes a lot of copypasta (most bullet_act() version for each obj were nearly identical). Two new elements are added to the armor list var: fire and acid armor values. How much damage an obj take depends on the armor value for each damage category. But some objects are INDESTRUCTIBLE and simply never take any damage no matter the type. The armor categories are: -melee(punches, item attacks, xeno/animal/hulk attacks, blob attacks, thrown weapons) -bullet -laser -energy (used by projectiles like ionrifle, taser, and also by EMPs) -bio (unused for this, only here because clothes use them when worn) -rad (same) -bomb (self-explanatory) -fire (for fire damage, not for heat damage though) -acid For machines and structures, when their health reaches zero the object is not just deleted but gets somewhat forcedeconstructed (the proc used is shared with the actual deconstruction system) which can drops things. To not frustrates players most of these objects drop most of the elements necessary to rebuild them (think window dropping shards). Machines drop a machine frame and all components for example (but the frame can then be itself smashed to pieces). For clothes, when they are damaged, they get a "damaged" overlay, which can also be seen when worn, similar to the "bloody" overlay. It refactors acid. See #20537. Some objects are ACID_PROOF and take no damage from acid, while others take varying amounts of damage depending on their acid armor value. Some objects are even UNACIDABLE, no acid effect can even land on them. Acid on objects can be washed off using water. It changes some aspect of damage from fires. All /obj/ can now take fire damage and be flammable, instead of just items. And instead of having just FLAMMABLE objs that become ON_FIRE as soon as some fire touch them (paper), we now have objects that are non flammable but do take damage from fire and become ashes if their health reaches zero (only for items). The damage taken varies depending on the obj's fire armor value and total health. There's also still obj and items that are FIRE_PROOF (although some might still be melted by lava if they're not LAVA_PROOF). When a mob is on fire, its clothes now take fire damage and can turn to ashes. Similarly, when a mob takes melee damages, its clothes gets damaged a bit and can turn to shreds. You can repair clothes with cloth that is produceable by botany's biogenerator. It also does many minor things: Clicking a structure/machine with an item on help intent never results in an attack (so you don't destroy a structure while trying to figure out which tool to use). I moved a lot of objects away from /obj/effect, it should only be used for visual effects, decals and stuff, not for things you can hit and destroy. I tweaked a bit how clothes shredding from bombs work. I made a machine or structure un/anchorable with the wrench, I don't remember which object... Since I changed the meaning of the FIRE_PROOF bitflag to actually mean fire immune, I'm buffing the slime extract that you apply on items to make them fire proof. well now they're really 100% fire proof! animals with environment_smash = 1 no longer one-hit destroy tables and stuff, we give them a decent obj_damage value so they can destroy most obj relatively fast depending on the animal. Probably a million things I forgot. If you want to know how the damage system works all you need is the three obj vars "obj_integrity", "max_integrity", "integrity_failure", as well as the armor list var and the resistance_flags bitfield, and read the file obj_defense.dm
278 lines
9.5 KiB
Plaintext
278 lines
9.5 KiB
Plaintext
/obj/structure/AIcore
|
|
density = 1
|
|
anchored = 0
|
|
name = "\improper AI core"
|
|
icon = 'icons/mob/AI.dmi'
|
|
icon_state = "0"
|
|
obj_integrity = 500
|
|
max_integrity = 500
|
|
var/state = 0
|
|
var/datum/ai_laws/laws = new()
|
|
var/obj/item/weapon/circuitboard/circuit = null
|
|
var/obj/item/device/mmi/brain = null
|
|
|
|
/obj/structure/AIcore/New()
|
|
..()
|
|
laws.set_laws_config()
|
|
|
|
/obj/structure/AIcore/Destroy()
|
|
if(circuit)
|
|
qdel(circuit)
|
|
circuit = null
|
|
if(brain)
|
|
brain.forceMove(loc)
|
|
brain = null
|
|
return ..()
|
|
|
|
/obj/structure/AIcore/attackby(obj/item/P, mob/user, params)
|
|
switch(state)
|
|
if(0)
|
|
if(istype(P, /obj/item/weapon/wrench))
|
|
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
|
|
user << "<span class='notice'>You start wrenching the frame into place...</span>"
|
|
if(do_after(user, 20/P.toolspeed, target = src))
|
|
user << "<span class='notice'>You wrench the frame into place.</span>"
|
|
anchored = 1
|
|
state = 1
|
|
return
|
|
if(istype(P, /obj/item/weapon/weldingtool))
|
|
var/obj/item/weapon/weldingtool/WT = P
|
|
if(!WT.isOn())
|
|
user << "<span class='warning'>The welder must be on for this task!</span>"
|
|
return
|
|
playsound(loc, 'sound/items/Welder.ogg', 50, 1)
|
|
user << "<span class='notice'>You start to deconstruct the frame...</span>"
|
|
if(do_after(user, 20/P.toolspeed, target = src))
|
|
if(!src || !WT.remove_fuel(0, user)) return
|
|
user << "<span class='notice'>You deconstruct the frame.</span>"
|
|
new /obj/item/stack/sheet/plasteel( loc, 4)
|
|
qdel(src)
|
|
return
|
|
if(1)
|
|
if(istype(P, /obj/item/weapon/wrench))
|
|
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
|
|
user << "<span class='notice'>You start to unfasten the frame...</span>"
|
|
if(do_after(user, 20/P.toolspeed, target = src))
|
|
user << "<span class='notice'>You unfasten the frame.</span>"
|
|
anchored = 0
|
|
state = 0
|
|
return
|
|
if(istype(P, /obj/item/weapon/circuitboard/aicore) && !circuit)
|
|
if(!user.drop_item())
|
|
return
|
|
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
|
|
P.loc = src
|
|
return
|
|
if(istype(P, /obj/item/weapon/screwdriver) && circuit)
|
|
playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
|
user << "<span class='notice'>You screw the circuit board into place.</span>"
|
|
state = 2
|
|
icon_state = "2"
|
|
return
|
|
if(istype(P, /obj/item/weapon/crowbar) && circuit)
|
|
playsound(loc, 'sound/items/Crowbar.ogg', 50, 1)
|
|
user << "<span class='notice'>You remove the circuit board.</span>"
|
|
state = 1
|
|
icon_state = "0"
|
|
circuit.loc = loc
|
|
circuit = null
|
|
return
|
|
if(2)
|
|
if(istype(P, /obj/item/weapon/screwdriver) && circuit)
|
|
playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
|
user << "<span class='notice'>You unfasten the circuit board.</span>"
|
|
state = 1
|
|
icon_state = "1"
|
|
return
|
|
if(istype(P, /obj/item/stack/cable_coil))
|
|
var/obj/item/stack/cable_coil/C = P
|
|
if(C.get_amount() >= 5)
|
|
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
|
user << "<span class='notice'>You start to add cables to the frame...</span>"
|
|
if(do_after(user, 20, target = src))
|
|
if (C.get_amount() >= 5 && state == 2)
|
|
C.use(5)
|
|
user << "<span class='notice'>You add cables to the frame.</span>"
|
|
state = 3
|
|
icon_state = "3"
|
|
else
|
|
user << "<span class='warning'>You need five lengths of cable to wire the AI core!</span>"
|
|
return
|
|
if(3)
|
|
if(istype(P, /obj/item/weapon/wirecutters))
|
|
if (brain)
|
|
user << "<span class='warning'>Get that brain out of there first!</span>"
|
|
else
|
|
playsound(loc, 'sound/items/Wirecutter.ogg', 50, 1)
|
|
user << "<span class='notice'>You remove the cables.</span>"
|
|
state = 2
|
|
icon_state = "2"
|
|
new /obj/item/stack/cable_coil(loc, 5)
|
|
return
|
|
|
|
if(istype(P, /obj/item/stack/sheet/rglass))
|
|
var/obj/item/stack/sheet/rglass/G = P
|
|
if(G.get_amount() >= 2)
|
|
playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
|
user << "<span class='notice'>You start to put in the glass panel...</span>"
|
|
if(do_after(user, 20, target = src))
|
|
if (G.get_amount() >= 2 && state == 3)
|
|
G.use(2)
|
|
user << "<span class='notice'>You put in the glass panel.</span>"
|
|
state = 4
|
|
icon_state = "4"
|
|
else
|
|
user << "<span class='warning'>You need two sheets of reinforced glass to insert them into the AI core!</span>"
|
|
return
|
|
|
|
if(istype(P, /obj/item/weapon/aiModule))
|
|
var/obj/item/weapon/aiModule/module = P
|
|
module.install(laws, user)
|
|
return
|
|
|
|
if(istype(P, /obj/item/device/mmi))
|
|
var/obj/item/device/mmi/M = P
|
|
if(!M.brainmob)
|
|
user << "<span class='warning'>Sticking an empty MMI into the frame would sort of defeat the purpose!</span>"
|
|
return
|
|
if(M.brainmob.stat == DEAD)
|
|
user << "<span class='warning'>Sticking a dead brain into the frame would sort of defeat the purpose!</span>"
|
|
return
|
|
|
|
if(!M.brainmob.client)
|
|
user << "<span class='warning'>Sticking an inactive brain into the frame would sort of defeat the purpose.</span>"
|
|
return
|
|
|
|
if((config) && (!config.allow_ai))
|
|
user << "<span class='warning'>This MMI does not seem to fit!</span>"
|
|
return
|
|
|
|
if(jobban_isbanned(M.brainmob, "AI"))
|
|
user << "<span class='warning'>This MMI does not seem to fit!</span>"
|
|
return
|
|
|
|
if(M.hacked || M.clockwork)
|
|
user << "<span class='warning'>This MMI does not seem to fit!</span>"
|
|
return
|
|
|
|
if(!M.brainmob.mind)
|
|
user << "<span class='warning'>This MMI is mindless!</span>"
|
|
return
|
|
|
|
if(!user.drop_item())
|
|
return
|
|
|
|
ticker.mode.remove_antag_for_borging(M.brainmob.mind)
|
|
remove_servant_of_ratvar(M, TRUE)
|
|
M.loc = src
|
|
brain = M
|
|
user << "<span class='notice'>Added a brain.</span>"
|
|
icon_state = "3b"
|
|
return
|
|
|
|
if(istype(P, /obj/item/weapon/crowbar) && brain)
|
|
playsound(loc, 'sound/items/Crowbar.ogg', 50, 1)
|
|
user << "<span class='notice'>You remove the brain.</span>"
|
|
brain.forceMove(loc)
|
|
brain = null
|
|
icon_state = "3"
|
|
return
|
|
|
|
if(4)
|
|
if(istype(P, /obj/item/weapon/crowbar))
|
|
playsound(loc, 'sound/items/Crowbar.ogg', 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/sheet/rglass(loc, 2)
|
|
return
|
|
|
|
if(istype(P, /obj/item/weapon/screwdriver))
|
|
playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
|
user << "<span class='notice'>You connect the monitor.</span>"
|
|
new /mob/living/silicon/ai (loc, laws, brain)
|
|
feedback_inc("cyborg_ais_created",1)
|
|
qdel(src)
|
|
return
|
|
return ..()
|
|
|
|
|
|
/obj/structure/AIcore/deconstruct(disassembled = TRUE)
|
|
if(state == 4)
|
|
new /obj/item/stack/sheet/rglass(loc, 2)
|
|
if(state >= 3)
|
|
new /obj/item/stack/cable_coil(loc, 5)
|
|
if(circuit)
|
|
circuit.forceMove(loc)
|
|
circuit = null
|
|
new /obj/item/stack/sheet/plasteel( loc, 4)
|
|
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/attackby(obj/item/A, mob/user, params)
|
|
if(istype(A, /obj/item/device/aicard))//Is it?
|
|
A.transfer_ai("INACTIVE","AICARD",src,user)
|
|
else if(istype(A, /obj/item/weapon/wrench))
|
|
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
|
|
user.visible_message("[user] [anchored ? "fastens" : "unfastens"] [src].", \
|
|
"<span class='notice'>You start to [anchored ? "fasten [src] to" : "unfasten [src] from"] the floor...</span>")
|
|
switch(anchored)
|
|
if(0)
|
|
if(do_after(user, 20, target = src))
|
|
user << "<span class='notice'>You fasten the core into place.</span>"
|
|
anchored = 1
|
|
if(1)
|
|
if(do_after(user, 20, target = src))
|
|
user << "<span class='notice'>You unfasten the core.</span>"
|
|
anchored = 0
|
|
else
|
|
return ..()
|
|
|
|
/*
|
|
This is a good place for AI-related object verbs so I'm sticking it here.
|
|
If adding stuff to this, don't forget that an AI need to cancel_camera() whenever it physically moves to a different location.
|
|
That prevents a few funky behaviors.
|
|
*/
|
|
//The type of interaction, the player performing the operation, the AI itself, and the card object, if any.
|
|
|
|
|
|
atom/proc/transfer_ai(interaction, mob/user, mob/living/silicon/ai/AI, obj/item/device/aicard/card)
|
|
if(istype(card))
|
|
if(card.flush)
|
|
user << "<span class='boldannounce'>ERROR</span>: AI flush is in progress, cannot execute transfer protocol."
|
|
return 0
|
|
return 1
|
|
|
|
|
|
/obj/structure/AIcore/deactivated/transfer_ai(interaction, mob/user, mob/living/silicon/ai/AI, obj/item/device/aicard/card)
|
|
if(!..())
|
|
return
|
|
//Transferring a carded AI to a core.
|
|
if(interaction == AI_TRANS_FROM_CARD)
|
|
AI.control_disabled = 0
|
|
AI.radio_enabled = 1
|
|
AI.forceMove(loc) // to replace the terminal.
|
|
AI << "You have been uploaded to a stationary terminal. Remote device connection restored."
|
|
user << "<span class='boldnotice'>Transfer successful</span>: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed."
|
|
card.AI = null
|
|
qdel(src)
|
|
else //If for some reason you use an empty card on an empty AI terminal.
|
|
user << "There is no AI loaded on this terminal!"
|
|
|
|
|
|
/obj/item/weapon/circuitboard/aicore
|
|
name = "circuit board (AI core)"
|
|
origin_tech = "programming=3"
|