Files
Bubberstation/code/datums/components/bane.dm
SkyratBot e890b1282b [MIRROR] Replaces intents with combat mode (#3063)
* Replaces intents with combat mode

* updates

* a

* Update living_defense.dm

* https://github.com/tgstation/tgstation/pull/56638/files

* gunsafety!

Co-authored-by: Qustinnus <Floydje123@hotmail.com>
Co-authored-by: Gandalf2k15 <jzo123@hotmail.com>
2021-02-05 16:58:16 +01:00

50 lines
1.4 KiB
Plaintext

/datum/component/bane
dupe_mode = COMPONENT_DUPE_ALLOWED
var/mobtype
var/speciestype
var/damage_multiplier
/datum/component/bane/Initialize(mobtype, damage_multiplier=1)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
if(ispath(mobtype, /mob/living))
src.mobtype = mobtype
else if(ispath(mobtype, /datum/species))
speciestype = mobtype
else
return COMPONENT_INCOMPATIBLE
src.damage_multiplier = damage_multiplier
/datum/component/bane/RegisterWithParent()
if(speciestype)
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, .proc/speciesCheck)
else
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, .proc/mobCheck)
/datum/component/bane/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ITEM_AFTERATTACK)
/datum/component/bane/proc/speciesCheck(obj/item/source, atom/target, mob/user, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(!proximity_flag || !is_species(target, speciestype))
return
activate(source, target, user)
/datum/component/bane/proc/mobCheck(obj/item/source, atom/target, mob/user, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(!proximity_flag || !istype(target, mobtype))
return
activate(source, target, user)
/datum/component/bane/proc/activate(obj/item/source, mob/living/target, mob/living/attacker)
if(!attacker.combat_mode)
return
var/extra_damage = max(0, source.force * damage_multiplier)
target.apply_damage(extra_damage, source.damtype, attacker.zone_selected)