Files
Bubberstation/code/datums/elements/venomous.dm
SkyratBot 650d64f6d4 [MIRROR] afterattack now returns a flag if it's reasonable to suspect the user intends to act on an item [MDB IGNORE] (#18519)
* afterattack now returns a flag if it's reasonable to suspect the user intends to act on an item

* Update _neck.dm

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: Zonespace <41448081+Zonespace27@users.noreply.github.com>
2023-01-07 06:55:38 +00:00

64 lines
2.0 KiB
Plaintext

/**
* Venomous element; which makes the attacks of the simplemob attached poison the enemy.
*
* Used for spiders, frogs, and bees!
*/
/datum/element/venomous
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
///Path of the reagent added
var/poison_type
///How much of the reagent added. if it's a list, it'll pick a range with the range being list(lower_value, upper_value)
var/list/amount_added
/datum/element/venomous/Attach(datum/target, poison_type, amount_added)
. = ..()
if(ismachinery(target) || isstructure(target) || isgun(target) || isprojectilespell(target))
RegisterSignal(target, COMSIG_PROJECTILE_ON_HIT, PROC_REF(projectile_hit))
else if(isitem(target))
RegisterSignal(target, COMSIG_ITEM_AFTERATTACK, PROC_REF(item_afterattack))
else if(ishostile(target) || isbasicmob(target))
RegisterSignal(target, COMSIG_HOSTILE_POST_ATTACKINGTARGET, PROC_REF(hostile_attackingtarget))
else
return ELEMENT_INCOMPATIBLE
src.poison_type = poison_type
src.amount_added = amount_added
/datum/element/venomous/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_PROJECTILE_ON_HIT, COMSIG_ITEM_AFTERATTACK, COMSIG_HOSTILE_POST_ATTACKINGTARGET))
return ..()
/datum/element/venomous/proc/projectile_hit(atom/fired_from, atom/movable/firer, atom/target, Angle)
SIGNAL_HANDLER
add_reagent(target)
/datum/element/venomous/proc/item_afterattack(obj/item/source, atom/target, mob/user, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(!proximity_flag)
return
add_reagent(target)
return COMPONENT_AFTERATTACK_PROCESSED_ITEM
/datum/element/venomous/proc/hostile_attackingtarget(mob/living/simple_animal/hostile/attacker, atom/target, success)
SIGNAL_HANDLER
if(!success)
return
add_reagent(target)
/datum/element/venomous/proc/add_reagent(mob/living/target)
if(!istype(target))
return
if(target.stat == DEAD)
return
var/final_amount_added
if(islist(amount_added))
final_amount_added = rand(amount_added[1], amount_added[2])
else
final_amount_added = amount_added
target.reagents?.add_reagent(poison_type, final_amount_added)