mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-14 16:44:33 +01:00
[FIX] Prevent duplicate cyborg upgrades (#26731)
* Disallows installing duplicate cyborg upgrades. * Prevent duplicate Cyborg modules * Unecessary spacing removed * Update code/game/objects/items/robot/robot_upgrades.dm Co-authored-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com> Signed-off-by: Adrer <erwin@lombok.demon.nl> * usr > user * Move nodrop check into do_install * ... Why did I do that? --------- Signed-off-by: Adrer <erwin@lombok.demon.nl> Co-authored-by: adrermail@gmail.com <adrermail@gmail.com> Co-authored-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
var/list/items_to_add = 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()
|
||||
/// Allow the same upgrade to be installed multiple times, FALSE by default
|
||||
var/allow_duplicate = FALSE
|
||||
/// Delete the module after installing it. For deleting upgrades that might be installed multiple times, like the rename/reset upgrades.
|
||||
var/delete_after_install = FALSE
|
||||
|
||||
/**
|
||||
* Called when someone clicks on a borg with an upgrade in their hand.
|
||||
@@ -24,12 +28,19 @@
|
||||
* 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))
|
||||
/obj/item/borg/upgrade/proc/action(mob/user, mob/living/silicon/robot/R)
|
||||
if(!pre_install_checks(user, R))
|
||||
return
|
||||
if(!do_install(R))
|
||||
if(!user.drop_item())
|
||||
to_chat(user, "<span class='notice'>\The [src] is stuck to your hand, you cannot install it in [R]</span>")
|
||||
return FALSE
|
||||
if(!do_install(user, R))
|
||||
return
|
||||
after_install(R)
|
||||
if(delete_after_install)
|
||||
qdel(src)
|
||||
else
|
||||
forceMove(R)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
@@ -38,13 +49,17 @@
|
||||
* Arguments:
|
||||
* * R - the cyborg that was clicked on with an upgrade.
|
||||
*/
|
||||
/obj/item/borg/upgrade/proc/pre_install_checks(mob/living/silicon/robot/R)
|
||||
/obj/item/borg/upgrade/proc/pre_install_checks(mob/user, mob/living/silicon/robot/R)
|
||||
if(R.stat == DEAD)
|
||||
to_chat(usr, "<span class='warning'>[src] will not function on a deceased cyborg.</span>")
|
||||
to_chat(user, "<span class='warning'>[src] will not function on a deceased cyborg.</span>")
|
||||
return
|
||||
if(module_type && !istype(R.module, module_type))
|
||||
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>")
|
||||
to_chat(R, "<span class='warning'>Upgrade mounting error! No suitable hardpoint detected!</span>")
|
||||
to_chat(user, "<span class='warning'>There's no mounting point for the module!</span>")
|
||||
return
|
||||
var/obj/item/borg/upgrade/u = locate(type) in R
|
||||
if(u && !allow_duplicate)
|
||||
to_chat(user, "<span class='notice'>This unit already has [src] installed!</span>")
|
||||
return
|
||||
return TRUE
|
||||
|
||||
@@ -89,6 +104,7 @@
|
||||
desc = "Used to reset a cyborg's module. Destroys any other upgrades applied to the cyborg."
|
||||
icon_state = "cyborg_upgrade1"
|
||||
require_module = TRUE
|
||||
delete_after_install = TRUE
|
||||
|
||||
/obj/item/borg/upgrade/reset/do_install(mob/living/silicon/robot/R)
|
||||
R.reset_module()
|
||||
@@ -101,6 +117,7 @@
|
||||
name = "cyborg reclassification board"
|
||||
desc = "Used to rename a cyborg."
|
||||
icon_state = "cyborg_upgrade1"
|
||||
delete_after_install = TRUE
|
||||
var/heldname = "default name"
|
||||
|
||||
/obj/item/borg/upgrade/rename/attack_self(mob/user)
|
||||
@@ -125,6 +142,7 @@
|
||||
name = "cyborg emergency reboot module"
|
||||
desc = "Used to force a reboot of a disabled-but-repaired cyborg, bringing it back online."
|
||||
icon_state = "cyborg_upgrade1"
|
||||
delete_after_install = TRUE
|
||||
|
||||
/obj/item/borg/upgrade/restart/do_install(mob/living/silicon/robot/R)
|
||||
if(R.health < 0)
|
||||
@@ -150,10 +168,6 @@
|
||||
origin_tech = "engineering=4;powerstorage=4"
|
||||
|
||||
/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
|
||||
|
||||
R.ionpulse = TRUE
|
||||
return TRUE
|
||||
|
||||
@@ -170,11 +184,6 @@
|
||||
var/mob/living/silicon/robot/cyborg
|
||||
|
||||
/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>")
|
||||
return
|
||||
|
||||
cyborg = R
|
||||
icon_state = "selfrepair_off"
|
||||
var/datum/action/A = new /datum/action/item_action/toggle(src)
|
||||
@@ -259,11 +268,6 @@
|
||||
origin_tech = "engineering=4;materials=5;programming=4"
|
||||
|
||||
/obj/item/borg/upgrade/vtec/do_install(mob/living/silicon/robot/R)
|
||||
for(var/obj/item/borg/upgrade/vtec/U in R.contents)
|
||||
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>")
|
||||
return
|
||||
|
||||
R.slowdown_cap = 3.5
|
||||
return TRUE
|
||||
|
||||
@@ -376,10 +380,6 @@
|
||||
var/mob/living/silicon/robot/cyborg
|
||||
|
||||
/obj/item/borg/upgrade/floorbuffer/do_install(mob/living/silicon/robot/R)
|
||||
for(var/obj/item/borg/upgrade/floorbuffer/U in R)
|
||||
to_chat(R, "<span class='notice'>A floor buffer unit is already installed!</span>")
|
||||
to_chat(usr, "<span class='notice'>There's no room for another floor buffer unit!</span>")
|
||||
return
|
||||
cyborg = R
|
||||
var/datum/action/A = new /datum/action/item_action/floor_buffer(src)
|
||||
A.Grant(R)
|
||||
|
||||
Reference in New Issue
Block a user