mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
[MIRROR] robot upgrade overhaul + some fixes (#7640)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: CHOMPStation2 <chompsation2@gmail.com> Co-authored-by: Aroliacue <96730930+Aroliacue@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Guti <32563288+TheCaramelion@users.noreply.github.com> Co-authored-by: Raeschen <rycoop29@gmail.com> Co-authored-by: Eli <fracshun@gmail.com> Co-authored-by: tacoguy7765093 <karokaromaro@gmail.com> Co-authored-by: Nadyr <41974248+Darlantanis@users.noreply.github.com> Co-authored-by: Changelogs <action@github.com> Co-authored-by: TheGreatKitsune <88862343+TheGreatKitsune@users.noreply.github.com> Co-authored-by: Missile597 <150307788+Missile597@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
set name = "Modify Robot Module"
|
||||
set desc = "Allows to add or remove modules to/from robots."
|
||||
set category = "Admin"
|
||||
if(!check_rights(R_ADMIN, R_FUN, R_VAREDIT))
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
if(!istype(target) || !target.module)
|
||||
@@ -12,12 +12,16 @@
|
||||
if(!target.module.modules)
|
||||
return
|
||||
|
||||
var/list/modification_options = list(MODIFIY_ROBOT_MODULE_ADD,MODIFIY_ROBOT_MODULE_REMOVE, MODIFIY_ROBOT_APPLY_UPGRADE, MODIFIY_ROBOT_RADIOC_ADD, MODIFIY_ROBOT_RADIOC_REMOVE, MODIFIY_ROBOT_COMP_ADD, MODIFIY_ROBOT_COMP_REMOVE, MODIFIY_ROBOT_RESET_MODULE)
|
||||
var/list/modification_options = list(MODIFIY_ROBOT_MODULE_ADD,MODIFIY_ROBOT_MODULE_REMOVE, MODIFIY_ROBOT_APPLY_UPGRADE, MODIFIY_ROBOT_SUPP_ADD, MODIFIY_ROBOT_SUPP_REMOVE, MODIFIY_ROBOT_RADIOC_ADD, MODIFIY_ROBOT_RADIOC_REMOVE, MODIFIY_ROBOT_COMP_ADD, MODIFIY_ROBOT_COMP_REMOVE, MODIFIY_ROBOT_RESET_MODULE)
|
||||
|
||||
while(TRUE)
|
||||
var/modification_choice = tgui_input_list(usr, "Select if you want to add or remove a module to/from [target]","Choice", modification_options)
|
||||
if(!modification_choice || modification_choice == "Cancel")
|
||||
break
|
||||
return
|
||||
|
||||
if(!target.module || !target.module.modules)
|
||||
to_chat(usr, "<span class='danger'>[target] was recently reset, you must wait until module selection has been completed before continuing modifying.</span>")
|
||||
continue
|
||||
|
||||
log_and_message_admins("[key_name(src)] has used MODIFYROBOT ([modification_choice]) on [key_name(target)].")
|
||||
feedback_add_details("admin_verb","MODIFYROBOT") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
@@ -105,7 +109,8 @@
|
||||
if(MODIFIY_ROBOT_APPLY_UPGRADE)
|
||||
var/list/upgrades = list()
|
||||
for(var/datum/design/item/prosfab/robot_upgrade/upgrade)
|
||||
upgrades[initial(upgrade.name)] = initial(upgrade.build_path)
|
||||
if(!(target.has_upgrade(initial(upgrade.build_path))))
|
||||
upgrades[initial(upgrade.name)] = initial(upgrade.build_path)
|
||||
while(TRUE)
|
||||
var/selected_module_upgrade = tgui_input_list(usr, "Please select the module to remove", "Upgrades", upgrades)
|
||||
if(!selected_module_upgrade || selected_module_upgrade == "Cancel")
|
||||
@@ -114,9 +119,16 @@
|
||||
if(tgui_alert(usr, "Are you sure that you want to install [selected_module_upgrade] and reset the robot's module?","Confirm",list("Yes","No"))=="No")
|
||||
continue
|
||||
var/new_upgrade = upgrades[capitalize(selected_module_upgrade)]
|
||||
target.module.supported_upgrades += new_upgrade
|
||||
upgrades.Remove(selected_module_upgrade)
|
||||
var/obj/item/borg/upgrade/U = new new_upgrade(src)
|
||||
if(selected_module_upgrade == "Rename Module")
|
||||
var/obj/item/borg/upgrade/utility/rename/UN = U
|
||||
var/new_name = sanitizeSafe(tgui_input_text(usr, "Enter new robot name", "Robot Reclassification", UN.heldname, MAX_NAME_LEN), MAX_NAME_LEN)
|
||||
if(new_name)
|
||||
UN.heldname = new_name
|
||||
U = UN
|
||||
if(istype(U, /obj/item/borg/upgrade/restricted))
|
||||
target.module.supported_upgrades |= new_upgrade
|
||||
if(U.action(target))
|
||||
to_chat(usr, "<span class='danger'>You apply the [U] to [target]!</span>")
|
||||
usr.drop_item()
|
||||
@@ -143,6 +155,30 @@
|
||||
modkits.Remove(selected_ka_upgrade)
|
||||
M.install(kin, target)
|
||||
capacity = kin.get_remaining_mod_capacity()
|
||||
if(MODIFIY_ROBOT_SUPP_ADD)
|
||||
var/list/whitelisted_upgrades = list()
|
||||
for(var/datum/design/item/prosfab/robot_upgrade/restricted/upgrade)
|
||||
if(!(initial(upgrade.build_path) in target.module.supported_upgrades))
|
||||
whitelisted_upgrades[initial(upgrade.name)] = initial(upgrade.build_path)
|
||||
while(TRUE)
|
||||
var/selected_upgrade_type = tgui_input_list(usr, "Please select which upgrade you want this module to support", "Upgrades", whitelisted_upgrades)
|
||||
if(!selected_upgrade_type || selected_upgrade_type == "Cancel")
|
||||
break
|
||||
var/upgrade_path = whitelisted_upgrades[capitalize(selected_upgrade_type)]
|
||||
whitelisted_upgrades.Remove(selected_upgrade_type)
|
||||
target.module.supported_upgrades |= upgrade_path
|
||||
if(MODIFIY_ROBOT_SUPP_REMOVE)
|
||||
var/list/whitelisted_upgrades = list()
|
||||
for(var/datum/design/item/prosfab/robot_upgrade/restricted/upgrade)
|
||||
if((initial(upgrade.build_path) in target.module.supported_upgrades))
|
||||
whitelisted_upgrades[initial(upgrade.name)] = initial(upgrade.build_path)
|
||||
while(TRUE)
|
||||
var/selected_upgrade_type = tgui_input_list(usr, "Please select which upgrade you want this module to support", "Upgrades", whitelisted_upgrades)
|
||||
if(!selected_upgrade_type || selected_upgrade_type == "Cancel")
|
||||
break
|
||||
var/upgrade_path = whitelisted_upgrades[capitalize(selected_upgrade_type)]
|
||||
whitelisted_upgrades.Remove(selected_upgrade_type)
|
||||
target.module.supported_upgrades -= upgrade_path
|
||||
if(MODIFIY_ROBOT_RADIOC_ADD)
|
||||
var/list/available_channels = radiochannels.Copy()
|
||||
for(var/has_channel in target.radio.channels)
|
||||
@@ -240,6 +276,6 @@
|
||||
to_chat(usr, "<span class='danger'>You removed \"[C]\" from [target]</span>")
|
||||
if(MODIFIY_ROBOT_RESET_MODULE)
|
||||
if(tgui_alert(usr, "Are you sure that you want to reset the entire module?","Confirm",list("Yes","No"))=="No")
|
||||
return
|
||||
continue
|
||||
target.module_reset()
|
||||
to_chat(usr, "<span class='danger'>You resetted [target]'s module selection.</span>")
|
||||
|
||||
Reference in New Issue
Block a user