Files
Bubberstation/code/datums/components/plundering_attacks.dm
SkyratBot 0923ef2b26 [MIRROR] Basic Pirate NPCs [MDB IGNORE] (#24654)
* Basic Pirate NPCs (#79284)

## About The Pull Request

Converts hostile pirate NPCs to basic mobs - specifically, a subtype of
trooper. As their behavior is not meaningfully distinct from other
troopers, this conversion mostly just sticks them on the existing AI
behavior while keeping the rest the same.

Pirates do have one new thing going for them, though, to differentiate
them from other troopers. They use the new **plundering attacks**
component, which means that every time they land a melee attack, they
steal money from the bank account of whoever they hit. This requires the
target to be wearing an ID with a linked bank account, so it's not the
hardest thing in the world to hide your money from them - but it's still
something to be wary of! If killed, any mob with this component will
drop everything they've stolen in a convenient holochip.
## Why It's Good For The Game

Takes down 5 more simplemobs, and (I think) converts the last remaining
trooper-type enemy to be a basic trooper. (It's possible there's more
I've forgotten that could use the same AI, though.)

The money-stealing behavior is mostly good because I think it's funny,
but it also makes the pirates something a little distinct from "yet
another mob that runs at you and punches you until you die". They still
do that, but now there's a little twist! This can be placed on other
mobs too, if we want to make any other sorts of thieves or brigands.
## Changelog
🆑
refactor: Pirate NPCs now use the basic mob framework. They'll be a
little smarter in combat, and if you're wearing your ID they'll siphon
your bank account with every melee attack! Beware! Please report any
bugs.
/🆑

* Basic Pirate NPCs

* Modular paths

---------

Co-authored-by: lizardqueenlexi <105025397+lizardqueenlexi@users.noreply.github.com>
Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
2023-10-31 02:17:34 -04:00

55 lines
1.9 KiB
Plaintext

/**
* Component that makes basic mobs' melee attacks steal money from the target's ID card.
* Plundered money is stored and dropped on death or removal of the component.
*/
/datum/component/plundering_attacks
/// How many credits do we steal per attack?
var/plunder_amount = 25
/// How much plunder do we have stored?
var/plunder_stored = 0
/datum/component/plundering_attacks/Initialize(
plunder_amount = 25,
)
. = ..()
if(!isbasicmob(parent))
return COMPONENT_INCOMPATIBLE
src.plunder_amount = plunder_amount
/datum/component/plundering_attacks/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_HOSTILE_POST_ATTACKINGTARGET, PROC_REF(attempt_plunder))
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(drop_plunder))
/datum/component/plundering_attacks/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(COMSIG_HOSTILE_POST_ATTACKINGTARGET, COMSIG_LIVING_DEATH))
drop_plunder()
/datum/component/plundering_attacks/proc/attempt_plunder(mob/living/attacker, mob/living/carbon/human/target, success)
SIGNAL_HANDLER
if(!istype(target) || !success)
return
var/obj/item/card/id/id_card = target.wear_id?.GetID()
if(isnull(id_card))
return
var/datum/bank_account/account_to_rob = id_card.registered_account
if(isnull(account_to_rob) || account_to_rob.account_balance == 0)
return
var/amount_to_steal = plunder_amount
if(account_to_rob.account_balance < plunder_amount) //If there isn't enough, just take what's left
amount_to_steal = account_to_rob.account_balance
plunder_stored += amount_to_steal
account_to_rob.adjust_money(-amount_to_steal)
account_to_rob.bank_card_talk("Transaction confirmed! Transferred [amount_to_steal] credits to \<NULL_ACCOUNT\>!")
/datum/component/plundering_attacks/proc/drop_plunder()
SIGNAL_HANDLER
if(plunder_stored == 0)
return
new /obj/item/holochip(get_turf(parent), plunder_stored)
plunder_stored = 0