Skip to content

Commit

Permalink
[MIRROR] Fixes Ranged Guardians from Shooting while Incorporeal [MDB …
Browse files Browse the repository at this point in the history
…IGNORE] (#849)

* Fixes Ranged Guardians from Shooting while Incorporeal (#79925)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2023
1 parent 007d122 commit 3a983ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 3 additions & 1 deletion code/datums/components/ranged_attacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion code/modules/mob/living/basic/guardian/guardian_types/ranged.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3a983ac

Please sign in to comment.