-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Basic Pirate NPCs [MDB IGNORE] (#355)
* Basic Pirate NPCs (#79284) * Modular paths --------- Co-authored-by: lizardqueenlexi <[email protected]> Co-authored-by: Giz <[email protected]>
- Loading branch information
1 parent
580c5f2
commit 1f0ca6f
Showing
14 changed files
with
184 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* 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 |
Oops, something went wrong.