Robot_module and cyborg stack refactor (#13527)

* robot_module refactor

* some fixes

1. adds medical stacks of 25 for the syndi medical borg
2. fixes various construction steps that weren't using `use()` or `get_amount()`

* review tweaks + other stuff

1. Makes a bunch of for loops into istypeless loops
2. Adds a readout of the current out of stacks a borg has, in the status panel
3. Slightly reorganizes the medical, syndi medical, engineering and syndi engineering cyborgs items

* fixes after upstream merge

* blank line for travis

* fixes and improvements

1. Fixed welder icon's not updating periodically if you were charging in a borg recharger
2. Fixes solar panels dropping /cyborg type glass when they were deconstructed.
3. Band-aid fix (incase #2 doesn't fix this) for cyborg stack's `source` var being null which resulted in tons of "cannot read null.energy" runtimes

* more fixes + constructable frame runtime fix

* removes toy sword placeholder

remove comment

* remove these as well

* .amount to .get_amount(), really should have done this before

* refactors robot_upgrades to work with the new system

- more cleanup
- adds documentation
- fixed a bug I made where you could delete your robot stack via crafting

* moves some unemag logic to the module file, makes more loops typless

* farie review

* fox review

* affected review and more TM bugfixes

* fixes comment

Co-authored-by: SteelSlayer <SteelSlayer@users.noreply.github.com>
This commit is contained in:
SteelSlayer
2021-05-24 10:24:25 -05:00
committed by GitHub
parent 663eff7b5e
commit e4bbd94d6a
46 changed files with 1057 additions and 914 deletions
+102 -126
View File
@@ -7,19 +7,72 @@
icon = 'icons/obj/module.dmi'
icon_state = "cyborg_upgrade"
origin_tech = "programming=2"
var/locked = 0
var/installed = 0
/// Whether or not the cyborg needs to have a chosen module before they can recieve this upgrade.
var/require_module = FALSE
/// The type of module this upgrade is compatible with: Engineering, Medical, etc.
var/module_type = null
/// A list of items, and their replacements that this upgrade should replace on installation, in the format of `item_type_to_replace = replacement_item_type`.
var/list/items_to_replace = list()
/// A list of replacement items will need to be placed into a cyborg module's `special_rechargable` list after this upgrade is installed.
var/list/special_rechargables = list()
/**
* Called when someone clicks on a borg with an upgrade in their hand.
*
* Arguments:
* * R - the cyborg that was clicked on with an upgrade.
*/
/obj/item/borg/upgrade/proc/action(mob/living/silicon/robot/R)
if(!pre_install_checks(R))
return
if(!do_install(R))
return
after_install(R)
return TRUE
/**
* Checks if the upgrade is able to be applied to the cyborg, before actually applying it.
*
* Arguments:
* * R - the cyborg that was clicked on with an upgrade.
*/
/obj/item/borg/upgrade/proc/pre_install_checks(mob/living/silicon/robot/R)
if(R.stat == DEAD)
to_chat(usr, "<span class='notice'>[src] will not function on a deceased cyborg.</span>")
return TRUE
to_chat(usr, "<span class='warning'>[src] will not function on a deceased cyborg.</span>")
return FALSE
if(module_type && !istype(R.module, module_type))
to_chat(R, "Upgrade mounting error! No suitable hardpoint detected!")
to_chat(usr, "There's no mounting point for the module!")
return TRUE
to_chat(R, "<span class='warning'>Upgrade mounting error! No suitable hardpoint detected!</span>")
to_chat(usr, "<span class='warning'>There's no mounting point for the module!</span>")
return FALSE
return TRUE
/**
* Executes code that will modify the cyborg or its module.
*
* Arguments:
* * R - the cyborg we're applying the upgrade to.
*/
/obj/item/borg/upgrade/proc/do_install(mob/living/silicon/robot/R)
return TRUE
/**
* Executes code after the module has been installed and the cyborg has been modified in some way.
*
* Arguments:
* * R - the cyborg that we've applied the upgrade to.
*/
/obj/item/borg/upgrade/proc/after_install(mob/living/silicon/robot/R)
for(var/item in items_to_replace)
var/replacement_type = items_to_replace[item]
var/obj/item/replacement = new replacement_type(R.module)
R.module.remove_item_from_lists(item)
R.module.basic_modules += replacement
if(replacement_type in special_rechargables)
R.module.special_rechargables += replacement
R.module.rebuild_modules()
return TRUE
/obj/item/borg/upgrade/reset
name = "cyborg module reset board"
@@ -27,14 +80,13 @@
icon_state = "cyborg_upgrade1"
require_module = TRUE
/obj/item/borg/upgrade/reset/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/reset/do_install(mob/living/silicon/robot/R)
R.reset_module()
return TRUE
/obj/item/borg/upgrade/reset/after_install(mob/living/silicon/robot/R)
return // We don't need to give them replacement items, or rebuild their module list. It's going to be a blank borg.
/obj/item/borg/upgrade/rename
name = "cyborg reclassification board"
desc = "Used to rename a cyborg."
@@ -44,9 +96,7 @@
/obj/item/borg/upgrade/rename/attack_self(mob/user)
heldname = stripped_input(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN)
/obj/item/borg/upgrade/rename/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/rename/do_install(mob/living/silicon/robot/R)
if(!R.allow_rename)
to_chat(R, "<span class='warning'>Internal diagnostic error: incompatible upgrade module detected.</span>")
return 0
@@ -63,7 +113,7 @@
desc = "Used to force a reboot of a disabled-but-repaired cyborg, bringing it back online."
icon_state = "cyborg_upgrade1"
/obj/item/borg/upgrade/restart/action(mob/living/silicon/robot/R)
/obj/item/borg/upgrade/restart/do_install(mob/living/silicon/robot/R)
if(R.health < 0)
to_chat(usr, "<span class='warning'>You have to repair the cyborg before using this module!</span>")
return 0
@@ -88,9 +138,7 @@
require_module = TRUE
origin_tech = "engineering=4;materials=5;programming=4"
/obj/item/borg/upgrade/vtec/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/vtec/do_install(mob/living/silicon/robot/R)
if(R.speed < 0)
to_chat(R, "<span class='notice'>A VTEC unit is already installed!</span>")
to_chat(usr, "<span class='notice'>There's no room for another VTEC unit!</span>")
@@ -108,10 +156,7 @@
require_module = TRUE
module_type = /obj/item/robot_module/security
/obj/item/borg/upgrade/disablercooler/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/disablercooler/do_install(mob/living/silicon/robot/R)
var/obj/item/gun/energy/disabler/cyborg/T = locate() in R.module.modules
if(!T)
to_chat(usr, "<span class='notice'>There's no disabler in this unit!</span>")
@@ -131,10 +176,7 @@
icon_state = "cyborg_upgrade3"
origin_tech = "engineering=4;powerstorage=4"
/obj/item/borg/upgrade/thrusters/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/thrusters/do_install(mob/living/silicon/robot/R)
if(R.ionpulse)
to_chat(usr, "<span class='notice'>This unit already has ion thrusters installed!</span>")
return
@@ -149,20 +191,9 @@
origin_tech = "engineering=4;materials=5"
require_module = TRUE
module_type = /obj/item/robot_module/miner
/obj/item/borg/upgrade/ddrill/action(mob/living/silicon/robot/R)
if(..())
return
for(var/obj/item/pickaxe/drill/cyborg/D in R.module.modules)
qdel(D)
for(var/obj/item/shovel/S in R.module.modules)
qdel(S)
R.module.modules += new /obj/item/pickaxe/drill/cyborg/diamond(R.module)
R.module.rebuild()
return TRUE
items_to_replace = list(
/obj/item/pickaxe/drill/cyborg = /obj/item/pickaxe/drill/cyborg/diamond
)
/obj/item/borg/upgrade/soh
name = "mining cyborg satchel of holding"
@@ -171,18 +202,9 @@
origin_tech = "engineering=4;materials=4;bluespace=4"
require_module = TRUE
module_type = /obj/item/robot_module/miner
/obj/item/borg/upgrade/soh/action(mob/living/silicon/robot/R)
if(..())
return
for(var/obj/item/storage/bag/ore/cyborg/S in R.module.modules)
qdel(S)
R.module.modules += new /obj/item/storage/bag/ore/holding(R.module)
R.module.rebuild()
return TRUE
items_to_replace = list(
/obj/item/storage/bag/ore/cyborg = /obj/item/storage/bag/ore/holding
)
/obj/item/borg/upgrade/abductor_engi
name = "engineering cyborg abductor upgrade"
@@ -191,33 +213,17 @@
origin_tech = "engineering=6;materials=6;abductor=3"
require_module = TRUE
module_type = /obj/item/robot_module/engineering
/obj/item/borg/upgrade/abductor_engi/action(mob/living/silicon/robot/R)
if(..())
return
for(var/obj/item/weldingtool/largetank/cyborg/W in R.module.modules)
qdel(W)
for(var/obj/item/screwdriver/cyborg/S in R.module.modules)
qdel(S)
for(var/obj/item/wrench/cyborg/E in R.module.modules)
qdel(E)
for(var/obj/item/crowbar/cyborg/C in R.module.modules)
qdel(C)
for(var/obj/item/wirecutters/cyborg/I in R.module.modules)
qdel(I)
for(var/obj/item/multitool/cyborg/M in R.module.modules)
qdel(M)
R.module.modules += new /obj/item/weldingtool/abductor(R.module)
R.module.modules += new /obj/item/wrench/abductor(R.module)
R.module.modules += new /obj/item/screwdriver/abductor(R.module)
R.module.modules += new /obj/item/crowbar/abductor(R.module)
R.module.modules += new /obj/item/wirecutters/abductor(R.module)
R.module.modules += new /obj/item/multitool/abductor(R.module)
R.module.rebuild()
return TRUE
items_to_replace = list(
/obj/item/weldingtool = /obj/item/weldingtool/abductor,
/obj/item/wrench = /obj/item/wrench/abductor,
/obj/item/screwdriver = /obj/item/screwdriver/abductor,
/obj/item/crowbar = /obj/item/crowbar/abductor,
/obj/item/wirecutters = /obj/item/wirecutters/abductor,
/obj/item/multitool = /obj/item/multitool/abductor
)
special_rechargables = list(
/obj/item/weldingtool/abductor
)
/obj/item/borg/upgrade/abductor_medi
name = "medical cyborg abductor upgrade"
@@ -226,39 +232,16 @@
origin_tech = "biotech=6;materials=6;abductor=3"
require_module = TRUE
module_type = /obj/item/robot_module/medical
/obj/item/borg/upgrade/abductor_medi/action(mob/living/silicon/robot/R)
if(..())
return
for(var/obj/item/scalpel/laser/laser1/L in R.module.modules)
qdel(L)
for(var/obj/item/hemostat/H in R.module.modules)
qdel(H)
for(var/obj/item/retractor/E in R.module.modules)
qdel(E)
for(var/obj/item/bonegel/B in R.module.modules)
qdel(B)
for(var/obj/item/FixOVein/F in R.module.modules)
qdel(F)
for(var/obj/item/bonesetter/S in R.module.modules)
qdel(S)
for(var/obj/item/circular_saw/C in R.module.modules)
qdel(C)
for(var/obj/item/surgicaldrill/D in R.module.modules)
qdel(D)
R.module.modules += new /obj/item/scalpel/laser/laser3(R.module) //no abductor laser scalpel, so next best thing.
R.module.modules += new /obj/item/hemostat/alien(R.module)
R.module.modules += new /obj/item/retractor/alien(R.module)
R.module.modules += new /obj/item/bonegel/alien(R.module)
R.module.modules += new /obj/item/FixOVein/alien(R.module)
R.module.modules += new /obj/item/bonesetter/alien(R.module)
R.module.modules += new /obj/item/circular_saw/alien(R.module)
R.module.modules += new /obj/item/surgicaldrill/alien(R.module)
R.module.rebuild()
return TRUE
items_to_replace = list(
/obj/item/scalpel/laser/laser1 = /obj/item/scalpel/laser/laser3, // No abductor laser scalpel, so next best thing.
/obj/item/hemostat = /obj/item/hemostat/alien,
/obj/item/retractor = /obj/item/retractor/alien,
/obj/item/bonegel = /obj/item/bonegel/alien,
/obj/item/FixOVein = /obj/item/FixOVein/alien,
/obj/item/bonesetter = /obj/item/bonesetter/alien,
/obj/item/circular_saw = /obj/item/circular_saw/alien,
/obj/item/surgicaldrill = /obj/item/surgicaldrill/alien
)
/obj/item/borg/upgrade/syndicate
name = "safety override module"
@@ -267,13 +250,11 @@
origin_tech = "combat=6;materials=6"
require_module = TRUE
/obj/item/borg/upgrade/syndicate/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/syndicate/do_install(mob/living/silicon/robot/R)
if(R.weapons_unlock)
to_chat(R, "<span class='warning'>Warning: Safety Overide Protocols have be disabled.</span>")
return
R.weapons_unlock = 1
return // They already had the safety override upgrade, or they're a cyborg type which has this by default.
R.weapons_unlock = TRUE
to_chat(R, "<span class='warning'>Warning: Safety Overide Protocols have be disabled.</span>")
return TRUE
/obj/item/borg/upgrade/lavaproof
@@ -284,9 +265,7 @@
require_module = TRUE
module_type = /obj/item/robot_module/miner
/obj/item/borg/upgrade/lavaproof/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/lavaproof/do_install(mob/living/silicon/robot/R)
if(istype(R))
R.weather_immunities += "lava"
return TRUE
@@ -303,10 +282,7 @@
var/powercost = 10
var/mob/living/silicon/robot/cyborg
/obj/item/borg/upgrade/selfrepair/action(mob/living/silicon/robot/R)
if(..())
return
/obj/item/borg/upgrade/selfrepair/do_install(mob/living/silicon/robot/R)
var/obj/item/borg/upgrade/selfrepair/U = locate() in R
if(U)
to_chat(usr, "<span class='warning'>This unit is already equipped with a self-repair module.</span>")