Skip to content

Commit

Permalink
[MIRROR] Creates a "busy" animation for players (#1818)
Browse files Browse the repository at this point in the history
* Creates a "busy" animation for players

* Conflict resolution

---------

Co-authored-by: Jeremiah <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Apr 7, 2024
1 parent 9f6e117 commit dd56a0a
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 36 deletions.
11 changes: 10 additions & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ GLOBAL_LIST_EMPTY(species_list)
* @param {string} interaction_key - The assoc key under which the do_after is capped, with max_interact_count being the cap. Interaction key will default to target if not set.
*
* @param {number} max_interact_count - The maximum amount of interactions allowed.
*
* @param {boolean} hidden - By default, any action 1 second or longer shows a cog over the user while it is in progress. If hidden is set to TRUE, the cog will not be shown.
*/
/proc/do_after(mob/user, delay, atom/target, timed_action_flags = NONE, progress = TRUE, datum/callback/extra_checks, interaction_key, max_interact_count = 1)
/proc/do_after(mob/user, delay, atom/target, timed_action_flags = NONE, progress = TRUE, datum/callback/extra_checks, interaction_key, max_interact_count = 1, hidden = FALSE)
if(!user)
return FALSE
if(!isnum(delay))
Expand All @@ -295,10 +297,15 @@ GLOBAL_LIST_EMPTY(species_list)
delay *= user.cached_multiplicative_actions_slowdown

var/datum/progressbar/progbar
var/datum/cogbar/cog

if(progress)
if(user.client)
progbar = new(user, delay, target || user)

if(!hidden && delay >= 1 SECONDS)
cog = new(user)

SEND_SIGNAL(user, COMSIG_DO_AFTER_BEGAN)

var/endtime = world.time + delay
Expand Down Expand Up @@ -330,6 +337,8 @@ GLOBAL_LIST_EMPTY(species_list)

if(!QDELETED(progbar))
progbar.end_progress()

cog?.remove()

if(interaction_key)
var/reduced_interaction_count = (LAZYACCESS(user.do_afters, interaction_key) || 0) - 1
Expand Down
87 changes: 87 additions & 0 deletions code/datums/cogbar.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#define COGBAR_ANIMATION_TIME 5 DECISECONDS

/**
* ### Cogbar
* Represents that the user is busy doing something.
*/
/datum/cogbar
/// Who's doing the thing
var/mob/user
/// The user client
var/client/user_client
/// The visible element to other players
var/obj/effect/overlay/vis/cog
/// The blank image that overlaps the cog - hides it from the source user
var/image/blank
/// The offset of the icon
var/offset_y


/datum/cogbar/New(mob/user)
src.user = user
src.user_client = user.client

var/list/icon_offsets = user.get_oversized_icon_offsets()
offset_y = icon_offsets["y"]

add_cog_to_user()

RegisterSignal(user, COMSIG_QDELETING, PROC_REF(on_user_delete))


/datum/cogbar/Destroy()
if(user)
SSvis_overlays.remove_vis_overlay(user, user.managed_vis_overlays)
user_client?.images -= blank

user = null
user_client = null
cog = null
QDEL_NULL(blank)

return ..()


/// Adds the cog to the user, visible by other players
/datum/cogbar/proc/add_cog_to_user()
cog = SSvis_overlays.add_vis_overlay(user,
icon = 'icons/effects/progressbar.dmi',
iconstate = "cog",
plane = HIGH_GAME_PLANE,
add_appearance_flags = APPEARANCE_UI_IGNORE_ALPHA,
unique = TRUE,
alpha = 0,
)
cog.pixel_y = world.icon_size + offset_y
animate(cog, alpha = 255, time = COGBAR_ANIMATION_TIME)

if(isnull(user_client))
return

blank = image('icons/blanks/32x32.dmi', cog, "nothing")
SET_PLANE_EXPLICIT(blank, HIGH_GAME_PLANE, user)
blank.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
blank.override = TRUE

user_client.images += blank


/// Removes the cog from the user
/datum/cogbar/proc/remove()
if(isnull(cog))
qdel(src)
return

animate(cog, alpha = 0, time = COGBAR_ANIMATION_TIME)

QDEL_IN(src, COGBAR_ANIMATION_TIME)


/// When the user is deleted, remove the cog
/datum/cogbar/proc/on_user_delete(datum/source)
SIGNAL_HANDLER

qdel(src)


#undef COGBAR_ANIMATION_TIME
2 changes: 1 addition & 1 deletion code/game/machinery/fat_sucker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
user.visible_message(span_notice("You see [user] kicking against the door of [src]!"), \
span_notice("You lean on the back of [src] and start pushing the door open... (this will take about [DisplayTimeText(breakout_time)].)"), \
span_hear("You hear a metallic creaking from [src]."))
if(do_after(user, breakout_time, target = src))
if(do_after(user, breakout_time, target = src, hidden = TRUE))
if(!user || user.stat != CONSCIOUS || user.loc != src || state_open)
return
free_exit = TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/syndie_spraycan.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
if(HAS_TRAIT(user, TRAIT_TAGGER))
wait_time *= 0.5

if(!do_after(user, wait_time, target))
if(!do_after(user, wait_time, target, hidden = TRUE))
user.balloon_alert(user, "interrupted!")
drawing_rune = FALSE
return FALSE
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/syndicate_uplink_beacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
return
var/datum/looping_sound/typing/typing_sounds = new(src, start_immediately = TRUE)
balloon_alert(user, "synchronizing...")
if(!do_after(user = user, delay = 3 SECONDS, target = src, interaction_key = REF(src)))
if(!do_after(user = user, delay = 3 SECONDS, target = src, interaction_key = REF(src), hidden = TRUE))
typing_sounds.stop()
return
typing_sounds.stop()
Expand All @@ -52,7 +52,7 @@
/obj/structure/syndicate_uplink_beacon/screwdriver_act_secondary(mob/living/user, obj/item/tool)
tool.play_tool_sound(src)
balloon_alert(user, "deconstructing...")
if (!do_after(user, 5 SECONDS, target = src))
if (!do_after(user, 5 SECONDS, target = src, hidden = TRUE))
return FALSE
var/turf/beacon_tile = get_turf(src)
new /obj/item/stack/sheet/iron/five(beacon_tile)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/changeling/powers/absorb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
target.take_overall_damage(40)

SSblackbox.record_feedback("nested tally", "changeling_powers", 1, list("Absorb DNA", "[absorbing_iteration]"))
if(!do_after(owner, 15 SECONDS, target))
if(!do_after(owner, 15 SECONDS, target, hidden = TRUE))
owner.balloon_alert(owner, "interrupted!")
is_absorbing = FALSE
return FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/heretic_antag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
else
drawing_effect = new(target_turf, rune_colour)

if(!do_after(user, drawing_time, target_turf, extra_checks = additional_checks))
if(!do_after(user, drawing_time, target_turf, extra_checks = additional_checks, hidden = TRUE))
target_turf.balloon_alert(user, "interrupted!")
new /obj/effect/temp_visual/drawing_heretic_rune/fail(target_turf, rune_colour)
qdel(drawing_effect)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/influences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
being_drained = TRUE
balloon_alert(user, "draining influence...")

if(!do_after(user, 10 SECONDS, src))
if(!do_after(user, 10 SECONDS, src, hidden = TRUE))
being_drained = FALSE
balloon_alert(user, "interrupted!")
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/magic/manse_link.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
to_chat(owner, span_notice("You begin linking [linkee]'s mind to yours..."))
to_chat(linkee, span_warning("You feel your mind being pulled somewhere... connected... intertwined with the very fabric of reality..."))

if(!do_after(owner, link_time, linkee))
if(!do_after(owner, link_time, linkee, hidden = TRUE))
to_chat(owner, span_warning("You fail to link to [linkee]'s mind."))
to_chat(linkee, span_warning("The foreign presence leaves your mind."))
return FALSE
Expand Down
4 changes: 2 additions & 2 deletions code/modules/antagonists/heretic/magic/mirror_walk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

jaunter.Beam(nearby_reflection, icon_state = "light_beam", time = phase_out_time)
nearby_reflection.visible_message(span_warning("[nearby_reflection] begins to shimmer and shake slightly!"))
if(!do_after(jaunter, phase_out_time, nearby_reflection, IGNORE_USER_LOC_CHANGE|IGNORE_INCAPACITATED))
if(!do_after(jaunter, phase_out_time, nearby_reflection, IGNORE_USER_LOC_CHANGE|IGNORE_INCAPACITATED, hidden = TRUE))
return

playsound(jaunter, 'sound/magic/ethereal_enter.ogg', 50, TRUE, -1)
Expand Down Expand Up @@ -96,7 +96,7 @@

nearby_reflection.Beam(phase_turf, icon_state = "light_beam", time = phase_in_time)
nearby_reflection.visible_message(span_warning("[nearby_reflection] begins to shimmer and shake slightly!"))
if(!do_after(unjaunter, phase_in_time, nearby_reflection))
if(!do_after(unjaunter, phase_in_time, nearby_reflection, hidden = TRUE))
return FALSE

// We can move around while phasing in, but we'll always end up where we started it.
Expand Down
30 changes: 15 additions & 15 deletions code/modules/antagonists/ninja/ninjaDrainAct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if(hacking_module.mod.get_charge() + drain > hacking_module.mod.get_max_charge())
drain = hacking_module.mod.get_max_charge() - hacking_module.mod.get_charge()
maxcapacity = TRUE//Reached maximum battery capacity.
if (do_after(ninja, 1 SECONDS, target = src))
if (do_after(ninja, 1 SECONDS, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cell.use(drain)
Expand Down Expand Up @@ -68,7 +68,7 @@
if(hacking_module.mod.get_charge() + drain > hacking_module.mod.get_max_charge())
drain = hacking_module.mod.get_max_charge() - hacking_module.mod.get_charge()
maxcapacity = TRUE
if (do_after(ninja, 1 SECONDS, target = src))
if (do_after(ninja, 1 SECONDS, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
charge -= drain
Expand All @@ -88,7 +88,7 @@

/obj/item/stock_parts/cell/proc/ninjadrain_charge(mob/living/carbon/human/ninja, obj/item/mod/module/hacker/hacking_module)
var/drain_total = 0
if(charge && !do_after(ninja, 3 SECONDS, target = src))
if(charge && !do_after(ninja, 3 SECONDS, target = src, hidden = TRUE))
drain_total = charge
if(hacking_module.mod.get_charge() + charge > hacking_module.mod.get_max_charge())
drain_total = hacking_module.mod.get_max_charge() - hacking_module.mod.get_charge()
Expand All @@ -112,7 +112,7 @@
return COMPONENT_CANCEL_ATTACK_CHAIN

/obj/machinery/rnd/server/master/ninjadrain_charge(mob/living/carbon/human/ninja, obj/item/mod/module/hacker/hacking_module)
if(!do_after(ninja, 30 SECONDS, target = src))
if(!do_after(ninja, 30 SECONDS, target = src, hidden = TRUE))
return
overload_source_code_hdd()
to_chat(ninja, span_notice("Sabotage complete. Storage device overloaded."))
Expand All @@ -131,7 +131,7 @@
return COMPONENT_CANCEL_ATTACK_CHAIN

/obj/machinery/rnd/server/proc/ninjadrain_charge(mob/living/carbon/human/ninja, obj/item/mod/module/hacker/hacking_module)
if(!do_after(ninja, 30 SECONDS, target = src))
if(!do_after(ninja, 30 SECONDS, target = src, hidden = TRUE))
return
stored_research.modify_points_all(0)
to_chat(ninja, span_notice("Sabotage complete. Research notes corrupted."))
Expand All @@ -154,7 +154,7 @@
return COMPONENT_CANCEL_ATTACK_CHAIN

/obj/machinery/computer/records/security/proc/ninjadrain_charge(mob/living/carbon/human/ninja, obj/item/mod/module/hacker/hacking_module)
if(!do_after(ninja, 20 SECONDS, src, extra_checks = CALLBACK(src, PROC_REF(can_hack), ninja)))
if(!do_after(ninja, 20 SECONDS, src, extra_checks = CALLBACK(src, PROC_REF(can_hack), ninja), hidden = TRUE))
return
for(var/datum/record/crew/target in GLOB.manifest.general)
target.wanted_status = WANTED_ARREST
Expand Down Expand Up @@ -230,7 +230,7 @@
while(!maxcapacity && src)
drain = (round((rand(hacking_module.mindrain, hacking_module.maxdrain))/2))
var/drained = 0
if(wire_powernet && do_after(ninja, 1 SECONDS, target = src))
if(wire_powernet && do_after(ninja, 1 SECONDS, target = src, hidden = TRUE))
drained = min(drain, delayed_surplus())
add_delayedload(drained)
if(drained < drain)//if no power on net, drain apcs
Expand Down Expand Up @@ -270,7 +270,7 @@
if(hacking_module.mod.get_charge() + drain > hacking_module.mod.get_max_charge())
drain = hacking_module.mod.get_max_charge() - hacking_module.mod.get_charge()
maxcapacity = TRUE
if (do_after(ninja, 1 SECONDS, target = src))
if (do_after(ninja, 1 SECONDS, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cell.use(drain)
Expand All @@ -296,7 +296,7 @@
modelselected["Medical"] = "/obj/item/robot_model/ninja/ninja_medical"
modelselected["Saboteur"] = "/obj/item/robot_model/ninja_saboteur"
//NOVA EDIT: ADDITION END
if(!do_after(ninja, 6 SECONDS, target = src))
if(!do_after(ninja, 6 SECONDS, target = src, hidden = TRUE))
return
spark_system.start()
playsound(loc, SFX_SPARKS, 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
Expand Down Expand Up @@ -353,7 +353,7 @@
//BOTS//
/mob/living/simple_animal/bot/ninjadrain_act(mob/living/carbon/human/ninja, obj/item/mod/module/hacker/hacking_module)
to_chat(src, span_boldwarning("Your circutry suddenly begins heating up!"))
if(!do_after(ninja, 1.5 SECONDS, target = src))
if(!do_after(ninja, 1.5 SECONDS, target = src, hidden = TRUE))
return COMPONENT_CANCEL_ATTACK_CHAIN

if(!hacking_module.mod.subtract_charge(DEFAULT_CHARGE_DRAIN * 7))
Expand All @@ -379,7 +379,7 @@
balloon_alert(ninja, "no energy!")
return COMPONENT_CANCEL_ATTACK_CHAIN

if(!do_after(ninja, 1.5 SECONDS, target = src))
if(!do_after(ninja, 1.5 SECONDS, target = src, hidden = TRUE))
return COMPONENT_CANCEL_ATTACK_CHAIN

hacking_module.mod.add_charge(cell.charge)
Expand All @@ -396,7 +396,7 @@
balloon_alert(ninja, "already hacked!")
return COMPONENT_CANCEL_ATTACK_CHAIN

if(!do_after(ninja, 2 SECONDS, target = src))
if(!do_after(ninja, 2 SECONDS, target = src, hidden = TRUE))
return COMPONENT_CANCEL_ATTACK_CHAIN

if(!hacking_module.mod.subtract_charge(DEFAULT_CHARGE_DRAIN * 5))
Expand All @@ -414,7 +414,7 @@
return COMPONENT_CANCEL_ATTACK_CHAIN

AI_notify_hack()
if(!do_after(ninja, 30 SECONDS, target = src))
if(!do_after(ninja, 30 SECONDS, target = src, hidden = TRUE))
return COMPONENT_CANCEL_ATTACK_CHAIN

do_sparks(3, cardinal_only = FALSE, source = src)
Expand All @@ -428,7 +428,7 @@
balloon_alert(ninja, "already hacked!")
return COMPONENT_CANCEL_ATTACK_CHAIN

if(!do_after(ninja, 2 SECONDS, target = src))
if(!do_after(ninja, 2 SECONDS, target = src, hidden = TRUE))
return COMPONENT_CANCEL_ATTACK_CHAIN

do_sparks(3, cardinal_only = FALSE, source = src)
Expand All @@ -449,7 +449,7 @@

AI_notify_hack()

if(!do_after(ninja, 20 SECONDS, target = src)) //Shorter due to how incredibly easy it is for someone to (even accidentally) interrupt.
if(!do_after(ninja, 20 SECONDS, target = src, hidden = TRUE)) //Shorter due to how incredibly easy it is for someone to (even accidentally) interrupt.
return COMPONENT_CANCEL_ATTACK_CHAIN

force_event(/datum/round_event_control/tram_malfunction, "ninja interference")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/nukeop/equipment/borgchameleon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
to_chat(user, span_notice("You activate \the [src]."))
playsound(src, 'sound/effects/seedling_chargeup.ogg', 100, TRUE, -6)
apply_wibbly_filters(user)
if (do_after(user, 5 SECONDS, target=user) && user.cell.use(ACTIVATION_COST))
if (do_after(user, 5 SECONDS, target = user, hidden = TRUE) && user.cell.use(ACTIVATION_COST))
playsound(src, 'sound/effects/bamf.ogg', 100, TRUE, -6)
to_chat(user, span_notice("You are now disguised as the Nanotrasen engineering borg \"[friendlyName]\"."))
activate(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ GLOBAL_VAR(station_nuke_source)
if(istype(weapon, /obj/item/nuke_core_container))
var/obj/item/nuke_core_container/core_box = weapon
to_chat(user, span_notice("You start loading the plutonium core into [core_box]..."))
if(do_after(user, 5 SECONDS, target=src))
if(do_after(user, 5 SECONDS, target = src, hidden = TRUE))
if(core_box.load(core, user))
to_chat(user, span_notice("You load the plutonium core into [core_box]."))
deconstruction_state = NUKESTATE_CORE_REMOVED
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/spy/spy_uplink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
span_notice("You start scanning [stealing], preparing it for extraction."),
)

if(!do_after(spy, bounty.theft_time, stealing, interaction_key = REF(src)))
if(!do_after(spy, bounty.theft_time, stealing, interaction_key = REF(src), hidden = TRUE))
return FALSE
if(bounty.claimed)
to_chat(spy, span_warning("Your uplinks blinks red: The bounty for [stealing] has been claimed by another spy!"))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/traitor/objectives/infect.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
to_chat(affected_mob, span_warning("You feel someone try to inject you with something."))
balloon_alert(user, "injecting...")
log_combat(user, affected_mob, "attempted to inject", src)
if(!do_after(user, 1.5 SECONDS))
if(!do_after(user, 1.5 SECONDS, hidden = TRUE))
balloon_alert(user, "interrupted!")
return
// THE FLUFFY FRONTIER BEGIN EDIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
for(var/mob/living/silicon/ai/ai_player in GLOB.player_list)
to_chat(ai_player, alertstr)

if(!do_after(user, 30 SECONDS, src, IGNORE_USER_LOC_CHANGE | IGNORE_TARGET_LOC_CHANGE | IGNORE_HELD_ITEM | IGNORE_INCAPACITATED | IGNORE_SLOWDOWNS, extra_checks = CALLBACK(src, PROC_REF(scan_checks), user, user_area, objective)))
if(!do_after(user, 30 SECONDS, src, IGNORE_USER_LOC_CHANGE | IGNORE_TARGET_LOC_CHANGE | IGNORE_HELD_ITEM | IGNORE_INCAPACITATED | IGNORE_SLOWDOWNS, extra_checks = CALLBACK(src, PROC_REF(scan_checks), user, user_area, objective), hidden = TRUE))
playsound(user, 'sound/machines/buzz-sigh.ogg', 30, TRUE)
return

Expand Down
Loading

0 comments on commit dd56a0a

Please sign in to comment.