Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes ejecting pAIs card without a pAI in it #1659

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions code/modules/modular_computers/computers/item/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -927,17 +927,16 @@
return FALSE
inserted_pai = card
balloon_alert(user, "inserted pai")
var/datum/action/innate/pai/messenger/messenger_ability = new(inserted_pai.pai)
messenger_ability.Grant(inserted_pai.pai)
if(inserted_pai.pai)
inserted_pai.pai.give_messenger_ability()
update_appearance(UPDATE_ICON)
return TRUE

/obj/item/modular_computer/proc/remove_pai(mob/user)
if(!inserted_pai)
return FALSE
var/datum/action/innate/pai/messenger/messenger_ability = locate() in inserted_pai.pai.actions
messenger_ability.Remove(inserted_pai.pai)
qdel(messenger_ability)
if(inserted_pai.pai)
inserted_pai.pai.remove_messenger_ability()
if(user)
user.put_in_hands(inserted_pai)
balloon_alert(user, "removed pAI")
Expand Down
17 changes: 17 additions & 0 deletions code/modules/pai/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
/// Remote signaler
var/obj/item/assembly/signaler/internal/signaler

///The messeenger ability that pAIs get when they are put in a PDA.
var/datum/action/innate/pai/messenger/messenger_ability

// Static lists
/// List of all available downloads
var/static/list/available_software = list(
Expand Down Expand Up @@ -149,6 +152,7 @@
return ..(target, action_bitflags)

/mob/living/silicon/pai/Destroy()
QDEL_NULL(messenger_ability)
QDEL_NULL(atmos_analyzer)
QDEL_NULL(hacking_cable)
QDEL_NULL(instrument)
Expand Down Expand Up @@ -203,6 +207,8 @@

/mob/living/silicon/pai/Initialize(mapload)
. = ..()
if(istype(loc, /obj/item/modular_computer))
give_messenger_ability()
START_PROCESSING(SSfastprocess, src)
GLOB.pai_list += src
make_laws()
Expand Down Expand Up @@ -457,3 +463,14 @@
if (new_distance < HOLOFORM_MIN_RANGE || new_distance > HOLOFORM_MAX_RANGE)
return
leash.set_distance(new_distance)

///Gives the messenger ability to the pAI, creating a new one if it doesn't have one already.
/mob/living/silicon/pai/proc/give_messenger_ability()
if(!messenger_ability)
messenger_ability = new(src)
messenger_ability.Grant(src)

///Removes the messenger ability from the pAI, but does not delete it.
/mob/living/silicon/pai/proc/remove_messenger_ability()
if(messenger_ability)
messenger_ability.Remove(src)
Loading