mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-08 23:39:32 +00:00
## About The Pull Request Ressurects this old concept from (#64530), if we're making pAIs conform to being personal assistants more often then they should be better at assisting your person. You can insert a pAI into a MODsuit simply by using the card on a MODsuit with an open panel. You can eject it again from the MODsuit control panel UI (though the maintenance panel still needs to be unscrewed). Inserted pAIs can: - Deploy and undeploy suit parts. - Turn the suit on and off. - Monitor any stats on the MODsuit panel. - Activate any of your suit actions. Inserted pAIs cannot: - Move the suit. This does not remove the ability to place AIs into your suit. AIs can do all of the above but can _also_ move the suit around while you are critically injured. You can't have _both_ an AI and a pAI in your suit at the same time. Additionally I had to mess around with the backend for pinning actions a little bit. AIs who tried to pin MODsuit actions to their screen would pin them to the UI of the person wearing the suit instead, because it passed through `grant_item_action`. We _want_ to use that interface for the other stuff it does, but we need to catch and override who is _actually_ being granted the action so it goes to the person who pinned it rather than the person wearing the suit. ## Why It's Good For The Game Gives more things for your pAI to do, now you can delegate manging some suit functions to your little buddy. ## Changelog 🆑 add: pAIs can be inserted into MODsuits and can control suit modules (but are not capable of moving the suit). fix: AIs/pAIs in MODsuits can properly pin actions /🆑
112 lines
3.4 KiB
Plaintext
112 lines
3.4 KiB
Plaintext
/obj/item/mod/control/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "MODsuit", name)
|
|
ui.open()
|
|
|
|
/obj/item/mod/control/ui_data(mob/user)
|
|
var/data = list()
|
|
// Suit information
|
|
var/suit_status = list(
|
|
"core_name" = core?.name,
|
|
"cell_charge_current" = get_charge(),
|
|
"cell_charge_max" = get_max_charge(),
|
|
"active" = active,
|
|
"ai_name" = ai_assistant?.name,
|
|
"has_pai" = ispAI(ai_assistant),
|
|
"is_ai" = ai_assistant && ai_assistant == user,
|
|
// Wires
|
|
"open" = open,
|
|
"seconds_electrified" = seconds_electrified,
|
|
"malfunctioning" = malfunctioning,
|
|
"locked" = locked,
|
|
"interface_break" = interface_break,
|
|
// Modules
|
|
"complexity" = complexity,
|
|
)
|
|
data["suit_status"] = suit_status
|
|
// User information
|
|
var/user_status = list(
|
|
"user_name" = wearer ? (wearer.get_authentification_name("Unknown") || "Unknown") : "",
|
|
"user_assignment" = wearer ? wearer.get_assignment("Unknown", "Unknown", FALSE) : "",
|
|
)
|
|
data["user_status"] = user_status
|
|
// Module information
|
|
var/module_custom_status = list()
|
|
var/module_info = list()
|
|
for(var/obj/item/mod/module/module as anything in modules)
|
|
module_custom_status += module.add_ui_data()
|
|
module_info += list(list(
|
|
"module_name" = module.name,
|
|
"description" = module.desc,
|
|
"module_type" = module.module_type,
|
|
"module_active" = module.active,
|
|
"pinned" = module.pinned_to[REF(user)],
|
|
"idle_power" = module.idle_power_cost,
|
|
"active_power" = module.active_power_cost,
|
|
"use_power" = module.use_power_cost,
|
|
"module_complexity" = module.complexity,
|
|
"cooldown_time" = module.cooldown_time,
|
|
"cooldown" = round(COOLDOWN_TIMELEFT(module, cooldown_timer), 1 SECONDS),
|
|
"id" = module.tgui_id,
|
|
"ref" = REF(module),
|
|
"configuration_data" = module.get_configuration()
|
|
))
|
|
data["module_custom_status"] = module_custom_status
|
|
data["module_info"] = module_info
|
|
return data
|
|
|
|
/obj/item/mod/control/ui_static_data(mob/user)
|
|
var/data = list()
|
|
data["ui_theme"] = ui_theme
|
|
data["control"] = name
|
|
data["complexity_max"] = complexity_max
|
|
data["helmet"] = helmet?.name
|
|
data["chestplate"] = chestplate?.name
|
|
data["gauntlets"] = gauntlets?.name
|
|
data["boots"] = boots?.name
|
|
return data
|
|
|
|
/obj/item/mod/control/ui_state(mob/user)
|
|
if(user == ai_assistant)
|
|
return GLOB.contained_state
|
|
return ..()
|
|
|
|
/obj/item/mod/control/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
if(locked && (!allowed(usr) || !ispAI(usr))) // pAIs automatically fail out of allowed()
|
|
balloon_alert(usr, "insufficient access!")
|
|
playsound(src, 'sound/machines/scanbuzz.ogg', 25, TRUE, SILENCED_SOUND_EXTRARANGE)
|
|
return
|
|
if(malfunctioning && prob(75))
|
|
balloon_alert(usr, "button malfunctions!")
|
|
return
|
|
switch(action)
|
|
if("lock")
|
|
locked = !locked
|
|
balloon_alert(usr, "[locked ? "locked" : "unlocked"]!")
|
|
if("activate")
|
|
toggle_activate(usr)
|
|
if("select")
|
|
var/obj/item/mod/module/module = locate(params["ref"]) in modules
|
|
if(!module)
|
|
return
|
|
module.on_select()
|
|
if("configure")
|
|
var/obj/item/mod/module/module = locate(params["ref"]) in modules
|
|
if(!module)
|
|
return
|
|
module.configure_edit(params["key"], params["value"])
|
|
if("pin")
|
|
var/obj/item/mod/module/module = locate(params["ref"]) in modules
|
|
if(!module)
|
|
return
|
|
module.pin(usr)
|
|
if("eject_pai")
|
|
if (!ishuman(usr))
|
|
return
|
|
remove_pai(usr)
|
|
return TRUE
|