Skip to content

Commit

Permalink
Players now get visual 'Balloon' Alert when Defender Crest is Lowered. (
Browse files Browse the repository at this point in the history
#7720)

**TM before Merging**

# About the pull request

This PR add "balloon alert" above defender, warning them that crest is
lowered and cannot use other ability.
(check video to see what balloon alert is)

# Explain why it's good for the game

I am not only person who had this issue, when crest was lowered and
didn't notice that during "heat of battle" and try to use tail swing or
fortify to only get killed by that mistake, there is no big chat alert
to make people realize they have it lowered.

This PR changes that by adding "Balloon Alert" (the ones that spitters
have when using 'charge_spit' ability.


# Testing Photographs and Procedure
<details>
<summary>Click HERE to see that Video:</summary>


https://github.com/user-attachments/assets/9ca5d86f-7b88-4c6a-9da3-e81a08f250fb


</details>


# Changelog
:cl: Venuska1117
code: Add "Delay" option for balloon alerts to prevent notification
spam.
qol: Added Balloon Alerts to notify player that crest is lowered when
trying to use Tail Swing or Fortify.
/:cl:

---------

Co-authored-by: Venuska1117 <[email protected]>
Co-authored-by: harryob <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2024
1 parent 83741ad commit 408036b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions code/datums/balloon_alerts/balloon_alerts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@
/// The amount of characters needed before this increase takes into effect
#define BALLOON_TEXT_CHAR_LIFETIME_INCREASE_MIN 10

/// Creates text that will float from the atom upwards to the viewer.
/atom/proc/balloon_alert(mob/viewer, text, text_color)
/// The world.time the last balloon alert was displayed
/atom/var/last_balloon_alert_time = 0

/proc/can_display_balloon_alert(atom/source, delay)
// Check if enough time has passed since the last alert
if (source.last_balloon_alert_time && (world.time - source.last_balloon_alert_time < delay))
return FALSE
return TRUE

/atom/proc/balloon_alert(mob/viewer, text, text_color, delay = 0)
SHOULD_NOT_SLEEP(TRUE)

if (delay > 0 && !can_display_balloon_alert(src, delay))
return

src.last_balloon_alert_time = world.time
INVOKE_ASYNC(src, PROC_REF(balloon_alert_perform), viewer, text, text_color)

/// Create balloon alerts (text that floats up) to everything within range.
/// Will only display to people who can see.
/atom/proc/balloon_alert_to_viewers(message, self_message, max_distance = DEFAULT_MESSAGE_RANGE, list/ignored_mobs, text_color)
/atom/proc/balloon_alert_to_viewers(message, self_message, max_distance = DEFAULT_MESSAGE_RANGE, list/ignored_mobs, text_color, delay = 0)
SHOULD_NOT_SLEEP(TRUE)

var/list/hearers = get_mobs_in_view(max_distance, src)
Expand All @@ -25,7 +37,6 @@
for(var/mob/hearer in hearers)
if(is_blind(hearer))
continue

balloon_alert(hearer, (hearer == src && self_message) || message, text_color)

// Do not use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
return

if(xeno.crest_defense)
to_chat(src, SPAN_XENOWARNING("We cannot use tail swipe with our crest lowered."))
xeno.balloon_alert(xeno, "our crest is lowered!", text_color = "#7d32bb", delay = 1 SECONDS)
return

xeno.visible_message(SPAN_XENOWARNING("[xeno] sweeps its tail in a wide circle!"), \
Expand Down Expand Up @@ -155,7 +155,7 @@
return

if(xeno.crest_defense)
to_chat(src, SPAN_XENOWARNING("We cannot use fortify with our crest lowered."))
xeno.balloon_alert(xeno, "our crest is lowered!", text_color = "#7d32bb", delay = 1 SECONDS)
return

if(!xeno.check_state())
Expand Down

0 comments on commit 408036b

Please sign in to comment.