diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_basic.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_basic.dm index 8420a486417..a5205a0589b 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_basic.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_basic.dm @@ -3,6 +3,10 @@ /// Sent from /mob/living/basic/proc/look_alive() : () #define COMSIG_BASICMOB_LOOK_ALIVE "basicmob_look_alive" +///from the ranged_attacks component for basic mobs: (mob/living/basic/firer, atom/target, modifiers) +#define COMSIG_BASICMOB_PRE_ATTACK_RANGED "basicmob_pre_attack_ranged" + #define COMPONENT_CANCEL_RANGED_ATTACK COMPONENT_CANCEL_ATTACK_CHAIN //! Cancel to prevent the attack from happening + ///from the ranged_attacks component for basic mobs: (mob/living/basic/firer, atom/target, modifiers) #define COMSIG_BASICMOB_POST_ATTACK_RANGED "basicmob_post_attack_ranged" diff --git a/code/datums/components/ranged_attacks.dm b/code/datums/components/ranged_attacks.dm index f75d29a10f4..2f9c6cb822d 100644 --- a/code/datums/components/ranged_attacks.dm +++ b/code/datums/components/ranged_attacks.dm @@ -55,7 +55,9 @@ /datum/component/ranged_attacks/proc/fire_ranged_attack(mob/living/basic/firer, atom/target, modifiers) SIGNAL_HANDLER - if (!COOLDOWN_FINISHED(src, fire_cooldown)) + if(!COOLDOWN_FINISHED(src, fire_cooldown)) + return + if(SEND_SIGNAL(firer, COMSIG_BASICMOB_PRE_ATTACK_RANGED, target, modifiers) & COMPONENT_CANCEL_RANGED_ATTACK) return COOLDOWN_START(src, fire_cooldown, cooldown_time) INVOKE_ASYNC(src, PROC_REF(async_fire_ranged_attack), firer, target, modifiers) diff --git a/code/modules/mob/living/basic/guardian/guardian_types/ranged.dm b/code/modules/mob/living/basic/guardian/guardian_types/ranged.dm index 293dbfc2320..c36602c765e 100644 --- a/code/modules/mob/living/basic/guardian/guardian_types/ranged.dm +++ b/code/modules/mob/living/basic/guardian/guardian_types/ranged.dm @@ -72,6 +72,7 @@ RegisterSignal(owner, COMSIG_GUARDIAN_MANIFESTED, PROC_REF(on_manifest)) RegisterSignal(owner, COMSIG_GUARDIAN_RECALLED, PROC_REF(on_recall)) RegisterSignal(owner, COMSIG_MOB_CLICKON, PROC_REF(on_click)) + RegisterSignal(owner, COMSIG_BASICMOB_PRE_ATTACK_RANGED, PROC_REF(on_ranged_attack)) var/mob/living/basic/guardian/guardian_mob = owner guardian_mob.unleash() @@ -80,7 +81,12 @@ /datum/status_effect/guardian_scout_mode/on_remove() animate(owner, alpha = initial(owner.alpha), time = 0.5 SECONDS) - UnregisterSignal(owner, list(COMSIG_GUARDIAN_MANIFESTED, COMSIG_GUARDIAN_RECALLED, COMSIG_MOB_CLICKON)) + UnregisterSignal(owner, list( + COMSIG_BASICMOB_PRE_ATTACK_RANGED, + COMSIG_GUARDIAN_MANIFESTED, + COMSIG_GUARDIAN_RECALLED, + COMSIG_MOB_CLICKON, + )) to_chat(owner, span_bolddanger("You return to your normal mode.")) var/mob/living/basic/guardian/guardian_mob = owner guardian_mob.leash_to(owner, guardian_mob.summoner) @@ -100,6 +106,11 @@ SIGNAL_HANDLER return COMSIG_MOB_CANCEL_CLICKON +/// We can't do any ranged attacks while in scout mode. +/datum/status_effect/guardian_scout_mode/proc/on_ranged_attack() + SIGNAL_HANDLER + owner.balloon_alert(owner, "need to be in ranged mode!") + return COMPONENT_CANCEL_RANGED_ATTACK /// Place an invisible trap which alerts the guardian when it is crossed /datum/action/cooldown/mob_cooldown/guardian_alarm_snare