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.
/🆑
This commit is contained in:
John Willard
2024-01-23 14:14:36 -05:00
committed by GitHub
parent e0bf763928
commit 8f91d34c2a
2 changed files with 21 additions and 5 deletions

View File

@@ -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")