mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-04 05:51:54 +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 /🆑
190 lines
5.8 KiB
Plaintext
190 lines
5.8 KiB
Plaintext
/datum/action/item_action/mod
|
|
background_icon_state = "bg_mod"
|
|
overlay_icon_state = "bg_mod_border"
|
|
button_icon = 'icons/mob/actions/actions_mod.dmi'
|
|
check_flags = AB_CHECK_CONSCIOUS
|
|
/// Whether this action is intended for the AI. Stuff breaks a lot if this is done differently.
|
|
var/ai_action = FALSE
|
|
|
|
/datum/action/item_action/mod/New(Target)
|
|
..()
|
|
if(!istype(Target, /obj/item/mod/control))
|
|
qdel(src)
|
|
return
|
|
if(ai_action)
|
|
background_icon_state = ACTION_BUTTON_DEFAULT_BACKGROUND
|
|
|
|
/datum/action/item_action/mod/Grant(mob/user)
|
|
var/obj/item/mod/control/mod = target
|
|
if(ai_action && user != mod.ai_assistant)
|
|
return
|
|
else if(!ai_action && user == mod.ai_assistant)
|
|
return
|
|
return ..()
|
|
|
|
/datum/action/item_action/mod/Remove(mob/user)
|
|
var/obj/item/mod/control/mod = target
|
|
if(ai_action && user != mod.ai_assistant)
|
|
return
|
|
else if(!ai_action && user == mod.ai_assistant)
|
|
return
|
|
return ..()
|
|
|
|
/datum/action/item_action/mod/Trigger(trigger_flags)
|
|
if(!IsAvailable(feedback = TRUE))
|
|
return FALSE
|
|
var/obj/item/mod/control/mod = target
|
|
if(mod.malfunctioning && prob(75))
|
|
mod.balloon_alert(usr, "button malfunctions!")
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/datum/action/item_action/mod/deploy
|
|
name = "Deploy MODsuit"
|
|
desc = "LMB: Deploy/Undeploy part. RMB: Deploy/Undeploy full suit."
|
|
button_icon_state = "deploy"
|
|
|
|
/datum/action/item_action/mod/deploy/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
var/obj/item/mod/control/mod = target
|
|
if(trigger_flags & TRIGGER_SECONDARY_ACTION)
|
|
mod.quick_deploy(usr)
|
|
else
|
|
mod.choose_deploy(usr)
|
|
|
|
/datum/action/item_action/mod/deploy/ai
|
|
ai_action = TRUE
|
|
|
|
/datum/action/item_action/mod/activate
|
|
name = "Activate MODsuit"
|
|
desc = "LMB: Activate/Deactivate suit with prompt. RMB: Activate/Deactivate suit skipping prompt."
|
|
button_icon_state = "activate"
|
|
/// First time clicking this will set it to TRUE, second time will activate it.
|
|
var/ready = FALSE
|
|
|
|
/datum/action/item_action/mod/activate/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
if(!(trigger_flags & TRIGGER_SECONDARY_ACTION) && !ready)
|
|
ready = TRUE
|
|
button_icon_state = "activate-ready"
|
|
build_all_button_icons()
|
|
addtimer(CALLBACK(src, PROC_REF(reset_ready)), 3 SECONDS)
|
|
return
|
|
var/obj/item/mod/control/mod = target
|
|
reset_ready()
|
|
mod.toggle_activate(usr)
|
|
|
|
/// Resets the state requiring to be doubleclicked again.
|
|
/datum/action/item_action/mod/activate/proc/reset_ready()
|
|
ready = FALSE
|
|
button_icon_state = initial(button_icon_state)
|
|
build_all_button_icons()
|
|
|
|
/datum/action/item_action/mod/activate/ai
|
|
ai_action = TRUE
|
|
|
|
/datum/action/item_action/mod/module
|
|
name = "Toggle Module"
|
|
desc = "Toggle a MODsuit module."
|
|
button_icon_state = "module"
|
|
|
|
/datum/action/item_action/mod/module/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
var/obj/item/mod/control/mod = target
|
|
mod.quick_module(usr)
|
|
|
|
/datum/action/item_action/mod/module/ai
|
|
ai_action = TRUE
|
|
|
|
/datum/action/item_action/mod/panel
|
|
name = "MODsuit Panel"
|
|
desc = "Open the MODsuit's panel."
|
|
button_icon_state = "panel"
|
|
|
|
/datum/action/item_action/mod/panel/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
var/obj/item/mod/control/mod = target
|
|
mod.ui_interact(usr)
|
|
|
|
/datum/action/item_action/mod/panel/ai
|
|
ai_action = TRUE
|
|
|
|
/datum/action/item_action/mod/pinned_module
|
|
desc = "Activate the module."
|
|
/// Overrides the icon applications.
|
|
var/override = FALSE
|
|
/// Module we are linked to.
|
|
var/obj/item/mod/module/module
|
|
/// A reference to the mob we are pinned to.
|
|
var/mob/pinner
|
|
|
|
/datum/action/item_action/mod/pinned_module/New(Target, obj/item/mod/module/linked_module, mob/user)
|
|
var/obj/item/mod/control/mod = Target
|
|
if(user == mod.ai_assistant)
|
|
ai_action = TRUE
|
|
button_icon = linked_module.icon
|
|
button_icon_state = linked_module.icon_state
|
|
. = ..()
|
|
module = linked_module
|
|
pinner = user
|
|
module.pinned_to[REF(user)] = src
|
|
if(linked_module.allow_flags & MODULE_ALLOW_INCAPACITATED)
|
|
// clears check hands and check conscious
|
|
check_flags = NONE
|
|
name = "Activate [capitalize(linked_module.name)]"
|
|
desc = "Quickly activate [linked_module]."
|
|
RegisterSignals(linked_module, list(COMSIG_MODULE_ACTIVATED, COMSIG_MODULE_DEACTIVATED, COMSIG_MODULE_USED), PROC_REF(module_interacted_with))
|
|
RegisterSignal(user, COMSIG_QDELETING, PROC_REF(pinner_deleted))
|
|
|
|
/datum/action/item_action/mod/pinned_module/Destroy()
|
|
UnregisterSignal(module, list(COMSIG_MODULE_ACTIVATED, COMSIG_MODULE_DEACTIVATED, COMSIG_MODULE_USED))
|
|
module.pinned_to -= REF(pinner)
|
|
module = null
|
|
pinner = null
|
|
return ..()
|
|
|
|
/datum/action/item_action/mod/pinned_module/Grant(mob/user)
|
|
if(pinner != user)
|
|
return
|
|
return ..()
|
|
|
|
/datum/action/item_action/mod/pinned_module/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
module.on_select()
|
|
|
|
/// If the guy whose UI we are pinned to got deleted
|
|
/datum/action/item_action/mod/pinned_module/proc/pinner_deleted()
|
|
pinner = null
|
|
qdel(src)
|
|
|
|
/datum/action/item_action/mod/pinned_module/apply_button_overlay(atom/movable/screen/movable/action_button/current_button, force)
|
|
current_button.cut_overlays()
|
|
if(override)
|
|
return ..()
|
|
|
|
var/obj/item/mod/control/mod = target
|
|
if(module == mod.selected_module)
|
|
current_button.add_overlay(image(icon = 'icons/hud/radial.dmi', icon_state = "module_selected", layer = FLOAT_LAYER-0.1))
|
|
else if(module.active)
|
|
current_button.add_overlay(image(icon = 'icons/hud/radial.dmi', icon_state = "module_active", layer = FLOAT_LAYER-0.1))
|
|
if(!COOLDOWN_FINISHED(module, cooldown_timer))
|
|
var/image/cooldown_image = image(icon = 'icons/hud/radial.dmi', icon_state = "module_cooldown")
|
|
current_button.add_overlay(cooldown_image)
|
|
addtimer(CALLBACK(current_button, TYPE_PROC_REF(/image, cut_overlay), cooldown_image), COOLDOWN_TIMELEFT(module, cooldown_timer))
|
|
return ..()
|
|
|
|
/datum/action/item_action/mod/pinned_module/proc/module_interacted_with(datum/source)
|
|
SIGNAL_HANDLER
|
|
|
|
build_all_button_icons(UPDATE_BUTTON_OVERLAY|UPDATE_BUTTON_STATUS)
|