Skip to content

Commit

Permalink
Reworking auras into something like the HUD effect markers on Polaris.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 26, 2025
1 parent a6f2110 commit 84fb8c7
Show file tree
Hide file tree
Showing 114 changed files with 1,212 additions and 860 deletions.
12 changes: 12 additions & 0 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,15 @@

// Default UI style applied to client prefs.
#define DEFAULT_UI_STYLE /decl/ui_style/midnight

// Indicates a status effect will never expire.
#define STATUS_EFFECT_INDEFINITE (-1)

// Indicators for attack checking proc.
#define SE_ATTACK_TYPE_WEAPON 0
#define SE_ATTACK_TYPE_THROWN 1
#define SE_ATTACK_TYPE_PROJECTILE 2

#define SE_ATTACK_RESULT_NONE 0
#define SE_ATTACK_RESULT_DEFLECTED BITFLAG(0)
#define SE_ATTACK_RESULT_BLOCKED BITFLAG(1)
4 changes: 2 additions & 2 deletions code/__defines/mob_status.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define PENDING_STATUS(MOB, COND) (LAZYACCESS(MOB.pending_status_counters, COND) || LAZYACCESS(MOB.status_counters, COND))
#define GET_STATUS(MOB, COND) (LAZYACCESS(MOB.status_counters, COND))
#define HAS_STATUS(MOB, COND) (GET_STATUS(MOB, COND) > 0)
#define ADJ_STATUS(MOB, COND, AMT) (MOB.set_status(COND, PENDING_STATUS(MOB, COND) + AMT))
#define SET_STATUS_MAX(MOB, COND, AMT) (MOB.set_status(COND, max(PENDING_STATUS(MOB, COND), AMT)))
#define ADJ_STATUS(MOB, COND, AMT) (MOB.set_status_condition(COND, PENDING_STATUS(MOB, COND) + AMT))
#define SET_STATUS_MAX(MOB, COND, AMT) (MOB.set_status_condition(COND, max(PENDING_STATUS(MOB, COND), AMT)))
10 changes: 2 additions & 8 deletions code/__defines/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,6 @@
#define STASIS_CRYOBAG "cryobag"
#define STASIS_COLD "cold"

#define AURA_CANCEL 1
#define AURA_FALSE 2
#define AURA_TYPE_BULLET "Bullet"
#define AURA_TYPE_WEAPON "Weapon"
#define AURA_TYPE_THROWN "Thrown"
#define AURA_TYPE_LIFE "Life"

#define SPECIES_BLOOD_DEFAULT 560

#define SLIME_EVOLUTION_THRESHOLD 15
Expand Down Expand Up @@ -389,7 +382,8 @@ var/global/list/dexterity_levels = list(
#define HO_HANDCUFF_LAYER 25
#define HO_INHAND_LAYER 26
#define HO_FIRE_LAYER 27 //If you're on fire
#define TOTAL_OVER_LAYERS 27
#define HO_EFFECT_LAYER 28
#define TOTAL_OVER_LAYERS 28
//////////////////////////////////

// Underlay defines; vestigal implementation currently.
Expand Down
13 changes: 0 additions & 13 deletions code/__defines/xenoarcheaology.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
#define XENOFIND_APPLY_PREFIX BITFLAG(0)
#define XENOFIND_APPLY_DECOR BITFLAG(1)
#define XENOFIND_REPLACE_ICON BITFLAG(2)

#define EFFECT_TOUCH 0
#define EFFECT_AURA 1
#define EFFECT_PULSE 2
#define MAX_EFFECT 2

#define EFFECT_UNKNOWN 0
#define EFFECT_ENERGY 1
#define EFFECT_PSIONIC 2
#define EFFECT_ELECTRO 3
#define EFFECT_PARTICLE 4
#define EFFECT_ORGANIC 5
#define EFFECT_SYNTH 6
4 changes: 2 additions & 2 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@

#define JOINTEXT(X) jointext(X, null)

#define SPAN_STYLE(S, X) "<span style='[S]'>[X]</span>"
#define SPAN_STYLE(S, X) "<span style='" + S + "'>" + X + "</span>"
#define SPAN_CLASS(C, X) "<span class='" + C + "'>" + X + "</span>"

#define SPAN_CLASS(C, X) "<span class='[C]'>[X]</span>"
#define SPAN_ITALIC(X) SPAN_CLASS("italic", X)
#define SPAN_BOLD(X) SPAN_CLASS("bold", X)
#define SPAN_NOTICE(X) SPAN_CLASS("notice", X)
Expand Down
6 changes: 6 additions & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
var/obj/screen/action_button/hide_toggle/hide_actions_toggle
var/action_buttons_hidden = FALSE

var/obj/screen/status_effect_master/status_effect_indicators

/datum/hud/New(mob/owner)
mymob = owner
instantiate()
Expand Down Expand Up @@ -128,6 +130,10 @@
adding |= action_intent
hud_elements |= action_intent

status_effect_indicators = new(null, mymob)
adding |= status_effect_indicators
hud_elements |= status_effect_indicators

BuildInventoryUI()
BuildHandsUI()

Expand Down
129 changes: 129 additions & 0 deletions code/_onclick/hud/screen/screen_status_effect.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/obj/screen/status_effect_master
screen_loc = "CENTER,TOP"
requires_ui_style = FALSE
// TODO: consider pooling these.
var/list/elements

/obj/screen/status_effect_master/Initialize(mapload, mob/_owner, decl/ui_style/ui_style, ui_color, ui_alpha, ui_cat)
. = ..()
START_PROCESSING(SSprocessing, src)

/obj/screen/status_effect_master/Destroy()
STOP_PROCESSING(SSprocessing, src)
QDEL_NULL_LIST(elements)
var/mob/living/owner = owner_ref?.resolve()
if(istype(owner) && istype(owner.hud_used) && owner.hud_used.status_effect_indicators == src)
owner.hud_used.status_effect_indicators = null
return ..()

/obj/screen/status_effect_master/Process()
if(QDELETED(src))
return PROCESS_KILL
var/mob/living/owner = owner_ref?.resolve()
if(!istype(owner))
return PROCESS_KILL
for(var/obj/screen/status_effect/effect in elements)
var/datum/status_effect/effect_data = LAZYACCESS(owner.status_effects, effect.archetype)
if(istype(effect_data) && effect_data.expire_time != STATUS_EFFECT_INDEFINITE)
effect.update_maptext(effect_data.expire_time - world.time)

/obj/screen/status_effect_master/proc/refresh_status_effects()

if(QDELETED(src))
return

var/mob/living/owner = owner_ref?.resolve()
if(!istype(owner))
return

var/list/seen_archetypes
var/list/elements_to_keep
var/list/elements_to_add
var/list/elements_to_remove

// Track deltas for keeping/removing existing elements.
for(var/obj/screen/status_effect/element in elements)
var/effect = LAZYACCESS(owner.status_effects, element.archetype)
if(effect)
LAZYADD(elements_to_keep, element)
else
LAZYADD(elements_to_remove, element)
LAZYDISTINCTADD(seen_archetypes, element.archetype)

// Create elements for new effects.
for(var/decl/status_effect/archetype in owner.status_effects)
if(archetype in seen_archetypes)
continue
var/obj/screen/status_effect/element = new(null, owner)
element.archetype = archetype
element.master = src
element.pixel_y = 32
element.icon = archetype.hud_icon
element.icon_state = archetype.hud_icon_state
element.alpha = 0
LAZYADD(elements_to_add, element)

// Fade out and delete expired markers.
if(LAZYLEN(elements_to_remove))
LAZYREMOVE(elements, elements_to_remove)
for(var/obj/screen/status_effect/element in elements_to_remove)
animate(element, alpha = 0, pixel_y = 32, time = 5)
QDEL_IN(element, 5)

// Add our new records.
if(LAZYLEN(elements_to_add))
LAZYADD(elements, elements_to_add)
add_vis_contents(elements_to_add)

// Adjust positions and fade in new elements.
if(length(elements))
var/offset_x = -(((length(elements)-1) * (world.icon_size + 2)) / 2)
for(var/obj/screen/element in elements)
if(element in elements_to_add)
pixel_x = offset_x
animate(element, alpha = 255, pixel_y = 0, time = 5)
else
animate(element, alpha = 255, pixel_x = offset_x, pixel_y = 0, time = 5)
offset_x += world.icon_size + 2

/obj/screen/status_effect
alpha = 0
requires_ui_style = FALSE
screen_loc = null // not handled via screen loc, but via vis contents of the master object.
maptext_y = -3
var/decl/status_effect/archetype
var/obj/screen/status_effect_master/master

/obj/screen/status_effect/Destroy()
if(master)
LAZYREMOVE(master.elements, src)
master.remove_vis_contents(src)
master = null
return ..()

/obj/screen/status_effect/proc/update_maptext(duration)
if(duration < 0)
maptext = ""
else
maptext = STYLE_SMALLFONTS_OUTLINE("<center>[ticks2shortreadable(duration)]</center>", 7, COLOR_WHITE, COLOR_BLACK)

/obj/screen/status_effect/handle_click(mob/user, params)
if((. = ..()))
var/mob/living/owner = owner_ref?.resolve()
if(istype(owner) && archetype)
var/datum/status_effect/effect = LAZYACCESS(owner.status_effects, archetype)
if(istype(effect))
effect.on_effect_click(params)

/obj/screen/status_effect/MouseEntered(location, control, params)
if(archetype && (archetype.name || archetype.desc))
openToolTip(user = usr, tip_src = src, params = params, title = archetype.name, content = archetype.desc)
..()

/obj/screen/status_effect/MouseDown()
closeToolTip(usr)
..()

/obj/screen/status_effect/MouseExited()
closeToolTip(usr)
..()
3 changes: 2 additions & 1 deletion code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ avoid code duplication. This includes items that may sometimes act as a standard
user.setClickCooldown(attack_cooldown + w_class)
if(animate)
user.do_attack_animation(target)
if(!user.aura_check(AURA_TYPE_WEAPON, src, user))

if(user.status_effects_block_attack(SE_ATTACK_TYPE_WEAPON, src))
return FALSE

var/hit_zone = target.resolve_item_attack(src, user, user.get_target_zone())
Expand Down
4 changes: 2 additions & 2 deletions code/datums/cinematic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var/global/datum/cinematic/cinematic = new
if(M.client)
M.client.screen += cinematic_screen //show every client the cinematic
viewers[M.client] = GET_STATUS(M, STAT_STUN)
M.set_status(STAT_STUN, 8000)
M.set_status_condition(STAT_STUN, 8000)

override.nuke_act(cinematic_screen, station_missed) //cinematic happens here, as does mob death.
//If it's actually the end of the round, wait for it to end.
Expand All @@ -36,6 +36,6 @@ var/global/datum/cinematic/cinematic = new

for(var/client/C in viewers)
if(C.mob)
C.mob.set_status(STAT_STUN, viewers[C])
C.mob.set_status_condition(STAT_STUN, viewers[C])
C.screen -= cinematic_screen
QDEL_NULL(cinematic_screen)
2 changes: 1 addition & 1 deletion code/datums/wires/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var/global/const/CAMERA_WIRE_ALARM = 8

if(CAMERA_WIRE_POWER)
C.cut_power = !mended
C.set_status(mended, usr)
C.set_status_condition(mended, usr)

if(CAMERA_WIRE_LIGHT)
C.light_disabled = !mended
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/endgame/ftl_jump/ftl_jump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
if(M.client)
to_chat(M,"<span class='notice'>You feel oddly light, and somewhat disoriented as everything around you shimmers and warps ever so slightly.</span>")
M.overlay_fullscreen("wormhole", /obj/screen/fullscreen/wormhole_overlay)
M.set_status(STAT_CONFUSE, 20)
M.set_status_condition(STAT_CONFUSE, 20)
bluegoasts += new/obj/effect/bluegoast/(get_turf(M),M)

/datum/universal_state/jump/proc/clear_duplicated(var/mob/living/M)
if(M.client)
to_chat(M,"<span class='notice'>You feel rooted in material world again.</span>")
M.clear_fullscreen("wormhole")
M.set_status(STAT_CONFUSE, 0)
M.set_status_condition(STAT_CONFUSE, 0)
for(var/mob/goast in global.ghost_mob_list)
goast.mouse_opacity = initial(goast.mouse_opacity)
goast.set_invisibility(initial(goast.invisibility))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return FALSE // Can potentially add uninstall code here, but not currently supported.
return ..()

/obj/item/stock_parts/proc/set_status(var/obj/machinery/machine, var/flag)
/obj/item/stock_parts/proc/set_status_condition(var/obj/machinery/machine, var/flag)
var/old_stat = status
status |= flag
if(old_stat != status)
Expand All @@ -34,7 +34,7 @@
machine.component_stat_change(src, old_stat, flag)

/obj/item/stock_parts/proc/on_install(var/obj/machinery/machine)
set_status(machine, PART_STAT_INSTALLED)
set_status_condition(machine, PART_STAT_INSTALLED)

/obj/item/stock_parts/proc/on_uninstall(var/obj/machinery/machine, var/temporary = FALSE)
unset_status(machine, PART_STAT_INSTALLED)
Expand All @@ -48,7 +48,7 @@
if(istype(machine))
LAZYDISTINCTADD(machine.processing_parts, src)
START_PROCESSING_MACHINE(machine, MACHINERY_PROCESS_COMPONENTS)
set_status(machine, PART_STAT_PROCESSING)
set_status_condition(machine, PART_STAT_PROCESSING)

/obj/item/stock_parts/proc/stop_processing(var/obj/machinery/machine)
if(istype(machine))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if(istype(machine))
machine.power_change()
machine.queue_icon_update()
set_status(machine, PART_STAT_CONNECTED)
set_status_condition(machine, PART_STAT_CONNECTED)
update_icon()
return cell

Expand Down Expand Up @@ -112,7 +112,7 @@
/obj/item/stock_parts/power/battery/can_provide_power(var/obj/machinery/machine)
if(is_functional() && cell && cell.check_charge(CELLRATE * machine.get_power_usage()))
machine.update_power_channel(LOCAL)
set_status(machine, PART_STAT_ACTIVE)
set_status_condition(machine, PART_STAT_ACTIVE)
return TRUE
return FALSE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//Is willing to provide power if the wired contribution is nonnegligible and there is enough total local power to run the machine.
/obj/item/stock_parts/power/terminal/can_provide_power(var/obj/machinery/machine)
if(is_functional() && terminal && terminal.surplus() && machine.can_use_power_oneoff(machine.get_power_usage(), LOCAL) <= 0)
set_status(machine, PART_STAT_ACTIVE)
set_status_condition(machine, PART_STAT_ACTIVE)
machine.update_power_channel(LOCAL)
return TRUE
return FALSE
Expand Down Expand Up @@ -76,7 +76,7 @@
terminal.queue_icon_update()

set_extension(src, /datum/extension/event_registration/shuttle_stationary, GET_DECL(/decl/observ/moved), machine, PROC_REF(machine_moved), get_area(src))
set_status(machine, PART_STAT_CONNECTED)
set_status_condition(machine, PART_STAT_CONNECTED)
start_processing(machine)

/obj/item/stock_parts/power/terminal/proc/machine_moved(var/obj/machinery/machine, var/turf/old_loc, var/turf/new_loc)
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
set_extension(src, /datum/extension/network_device/camera, null, null, null, TRUE, preset_channels, c_tag, cameranet_enabled, requires_connection)

/obj/machinery/camera/Destroy()
set_status(0) //kick anyone viewing out
set_status_condition(0) //kick anyone viewing out
return ..()

/obj/machinery/camera/Process()
Expand Down Expand Up @@ -227,7 +227,7 @@
//sparks
spark_at(loc, amount=5)

/obj/machinery/camera/proc/set_status(var/newstatus, var/mob/user)
/obj/machinery/camera/proc/set_status_condition(var/newstatus, var/mob/user)
if (status != newstatus && (!cut_power || status == TRUE))
status = newstatus
// The only way for AI to reactivate cameras are malf abilities, this gives them different messages.
Expand Down Expand Up @@ -337,7 +337,7 @@
)

/obj/machinery/camera/proc/toggle_status()
set_status(!status)
set_status_condition(!status)

/decl/public_access/public_method/toggle_camera
name = "toggle camera"
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/airlock_interactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
for(var/i in 1 to round(crush_damage/AIRLOCK_CRUSH_INCREMENT, 1))
apply_damage(AIRLOCK_CRUSH_INCREMENT, BRUTE)

set_status(STAT_STUN, round(crush_damage / 8, 1))
set_status(STAT_WEAK, round(crush_damage / 8, 1))
set_status_condition(STAT_STUN, round(crush_damage / 8, 1))
set_status_condition(STAT_WEAK, round(crush_damage / 8, 1))

var/turf/T = loc
if(!istype(T))
Expand Down
Loading

0 comments on commit 84fb8c7

Please sign in to comment.