[MIRROR] Fixes ejecting pAIs card without a pAI in it (#26222)

* Fixes ejecting pAIs card without a pAI in it (#81047)

## About The Pull Request

I had made the bad assumption that a pAI card always had a pAI mob in
it, which is not the case.
This fixes the runtime error, thus allowing people to eject a pAI card
that doesn't have a pAI in it.
I've also added a check in the pAI's Initialize to give them the ability
to use the modPC if they are made in it, so you don't have to eject and
reinsert the pAI, fixing another issue.

## Why It's Good For The Game

Closes https://github.com/tgstation/tgstation/issues/81043
Fixes inconsistency and runtime.

## Changelog

🆑
fix: pAIs downloaded while in a PDA now gets the action button to
control said PDA.
fix: pAI cards can now be ejected from a PDA when there is no pAI
inhabiting it.
/🆑

* Fixes ejecting pAIs card without a pAI in it

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
This commit is contained in:
SkyratBot
2024-01-25 15:29:46 +01:00
committed by GitHub
parent 7551828a29
commit ebb21356e1
2 changed files with 21 additions and 5 deletions
@@ -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")