-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
111 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/datum/element/reagent_attack | ||
element_flags = ELEMENT_BESPOKE | ||
id_arg_index = 2 | ||
/// Which reagent we will inject | ||
var/reagent_id | ||
/// How much reagent we will inject | ||
var/reagent_amount | ||
/// Will we inject anyway or check can_inject | ||
var/piercing | ||
/// Limitation of our reagent in target | ||
var/reagent_limit | ||
/// Override zones over item or mob | ||
var/allowed_zones | ||
|
||
/datum/element/reagent_attack/Attach(atom/source, reagent_id, reagent_amount, piercing, reagent_limit, list/allowed_zones) | ||
. = ..() | ||
|
||
if(!isitem(source) || !ismob(source)) | ||
return ELEMENT_INCOMPATIBLE | ||
|
||
src.reagent_id = reagent_id | ||
src.reagent_amount = reagent_amount | ||
src.piercing = piercing | ||
src.reagent_limit = reagent_limit | ||
src.allowed_zones = allowed_zones | ||
|
||
if(isitem(source)) | ||
RegisterSignal(source, COMSIG_ITEM_ATTACK, PROC_REF(item_attack)) | ||
|
||
if(ismob(attaker)) | ||
RegisterSignal(source, COMSIG_MOB_PRE_UNARMED_ATTACK, PROC_REF(mob_attack)) | ||
|
||
/datum/element/reagent_attack/Detach(atom/source) | ||
. = ..() | ||
|
||
if(isitem(source)) | ||
UnregisterSignal(source, COMSIG_ITEM_ATTACK) | ||
|
||
if(ismob(source)) | ||
UnregisterSignal(source, COMSIG_MOB_PRE_UNARMED_ATTACK) | ||
|
||
/datum/element/reagent_attack/proc/item_attack(mob/target, mob/living/user, params, def_zone) | ||
SIGNAL_HANDLER | ||
|
||
var/picked_zone = allowed_zones ? pick(allowed_zones) : def_zone | ||
if(!can_inject(target, picked_zone)) | ||
return | ||
|
||
INVOKE_ASYNC(src, PROC_REF(inject), user, target, picked_zone) | ||
|
||
/datum/element/reagent_attack/proc/mob_attack(mob/source, mob/target, params) | ||
SIGNAL_HANDLER | ||
|
||
var/picked_zone = allowed_zones ? pick(allowed_zones) : source.zone_selected | ||
if(!can_inject(target, picked_zone)) | ||
return | ||
|
||
INVOKE_ASYNC(src, PROC_REF(inject), source, target, picked_zone) | ||
|
||
/datum/element/reagent_attack/proc/can_inject(mob/living/carbon/target, target_zone) | ||
if(!istype(target)) | ||
return FALSE | ||
if(reagent_limit && target.reagents.has_reagent(reagent_id, reagent_limit)) | ||
return FALSE | ||
if(!piercing && !target.can_inject(null, FALSE, target_zone, FALSE)) | ||
return FALSE | ||
return TRUE | ||
|
||
/datum/element/reagent_attack/proc/inject(atom/source, mob/living/carbon/target, target_zone) | ||
if(reagent_id && reagent_amount) | ||
target.reagents.add_reagent(reagent_id, reagent_amount) | ||
SEND_SIGNAL(source, COMSIG_REAGENT_INJECTED, source, target, reagent_id, reagent_amount, target_zone) // custom injections! | ||
return | ||
|
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