Skip to content

Commit

Permalink
Converting auras, cloaking and stasis into mob modifiers, something l…
Browse files Browse the repository at this point in the history
…ike the HUD effect markers on Polaris.
  • Loading branch information
MistakeNot4892 committed Feb 7, 2025
1 parent 77bef4b commit 7dabe31
Show file tree
Hide file tree
Showing 159 changed files with 1,487 additions and 1,032 deletions.
1 change: 1 addition & 0 deletions code/__defines/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define HUD_FIRE /decl/hud_element/fire
#define HUD_CHARGE /decl/hud_element/charge
#define HUD_ROBOT_MODULE /decl/hud_element/module_selection
#define HUD_MODIFIERS /decl/hud_element/modifiers

#define GET_HUD_ALERT(M, A) ((istype(M?.hud_used, /datum/hud) && (A in M.hud_used.alerts)) ? M.hud_used.alerts[A] : 0)
#define CLEAR_HUD_ALERTS(M) if(istype(M?.hud_used, /datum/hud) && M.hud_used.alerts) { M.hud_used.alerts = null; }
Expand Down
11 changes: 11 additions & 0 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,14 @@
// Default UI style applied to client prefs.
#define DEFAULT_UI_STYLE /decl/ui_style/midnight

// Indicates a modifier will never expire.
#define MOB_MODIFIER_INDEFINITE (-1)

// Indicators for attack checking proc.
#define MM_ATTACK_TYPE_WEAPON 0
#define MM_ATTACK_TYPE_THROWN 1
#define MM_ATTACK_TYPE_PROJECTILE 2

#define MM_ATTACK_RESULT_NONE 0
#define MM_ATTACK_RESULT_DEFLECTED BITFLAG(0)
#define MM_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)))
16 changes: 3 additions & 13 deletions code/__defines/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define UNCONSCIOUS 1
#define DEAD 2

// Bitflags defining which status effects could be or are inflicted on a mob.
// Bitflags defining which status conditions could be or are inflicted on a mob.
#define CANSTUN BITFLAG(0)
#define CANWEAKEN BITFLAG(1)
#define CANPARALYSE BITFLAG(2)
Expand Down Expand Up @@ -278,17 +278,6 @@
#define SURGERY_RETRACTED 2
#define SURGERY_ENCASED 3

#define STASIS_MISC "misc"
#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 @@ -387,7 +376,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
3 changes: 3 additions & 0 deletions code/_onclick/hud/hud_elements/hud_auxilliary.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/decl/hud_element/attack
elem_type = /obj/screen/default_attack_selector

/decl/hud_element/modifiers
elem_type = /obj/screen/mob_modifier_master

/decl/hud_element/stamina
elem_type = /obj/screen/stamina
elem_updates_in_life = TRUE
Expand Down
11 changes: 11 additions & 0 deletions code/_onclick/hud/hud_types/_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@
return FALSE

/datum/hud/proc/handle_life_hud_update()

if(mymob.buckled || mymob.restrained())
mymob.add_mob_modifier(/decl/mob_modifier/restrained, source = mymob)
else
mymob.remove_mob_modifier(/decl/mob_modifier/restrained, source = mymob)

if(mymob.current_posture?.prone)
mymob.add_mob_modifier(/decl/mob_modifier/prone, source = mymob)
else
mymob.remove_mob_modifier(/decl/mob_modifier/prone, source = mymob)

for(var/obj/screen/elem as anything in hud_elements_update_in_life)
elem.update_icon()

Expand Down
155 changes: 155 additions & 0 deletions code/_onclick/hud/screen/screen_mob_modifier.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/obj/screen/mob_modifier_master
screen_loc = "CENTER,TOP"
icon_state = "blank"
requires_ui_style = FALSE

// Disable these due to vis_contents behaving oddly with them.
use_supplied_ui_color = FALSE
use_supplied_ui_alpha = FALSE

// TODO: consider pooling these.
var/list/elements

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

/obj/screen/mob_modifier_master/Destroy()
STOP_PROCESSING(SSprocessing, src)
QDEL_NULL_LIST(elements)
return ..()

/obj/screen/mob_modifier_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/mob_modifier/element in elements)
var/expire_time = MOB_MODIFIER_INDEFINITE
for(var/datum/mob_modifier/modifier in LAZYACCESS(owner._mob_modifiers, element.archetype))
if(modifier.expire_time == MOB_MODIFIER_INDEFINITE)
expire_time = MOB_MODIFIER_INDEFINITE
break
expire_time = max(expire_time, modifier.expire_time)
if(istype(element))
element.update_maptext(expire_time == MOB_MODIFIER_INDEFINITE ? MOB_MODIFIER_INDEFINITE : (expire_time - world.time))

/obj/screen/mob_modifier_master/on_update_icon()

if(QDELETED(src))
return

var/mob/living/owner = owner_ref?.resolve()
if(!istype(owner) || !istype(owner.hud_used))
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/mob_modifier/element in elements)
var/list/modifiers = LAZYACCESS(owner._mob_modifiers, element.archetype)
if(length(modifiers))
LAZYADD(elements_to_keep, element)
else
LAZYADD(elements_to_remove, element)
LAZYDISTINCTADD(seen_archetypes, element.archetype)

var/decl/ui_style/ui_style = owner.hud_used.get_ui_style_data()
var/ui_color = owner.hud_used.get_ui_color()
var/ui_alpha = owner.hud_used.get_ui_alpha()

// Create elements for new modifiers.
for(var/decl/mob_modifier/archetype in owner._mob_modifiers)
if(archetype in seen_archetypes)
continue
var/obj/screen/mob_modifier/element = new(null, owner, ui_style, ui_color, ui_alpha, HUD_MODIFIERS)
element.archetype = archetype
element.master = src
element.pixel_y = 32
element.alpha = 0
element.update_icon()
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/mob_modifier/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/mob_modifier
alpha = 0
screen_loc = null // not handled via screen loc, but via vis contents of the master object.
maptext_y = -3
icon_state = "modifier_base"
var/decl/mob_modifier/archetype
var/obj/screen/mob_modifier_master/master

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

/obj/screen/mob_modifier/rebuild_screen_overlays()
. = ..()
if(archetype)
add_overlay(overlay_image(archetype.hud_icon, archetype.hud_icon_state, COLOR_WHITE, RESET_COLOR))

/obj/screen/mob_modifier/proc/update_maptext(duration)
if(archetype.hide_expiry)
maptext = null
return

if(duration == MOB_MODIFIER_INDEFINITE)
if(archetype.show_indefinite_duration)
maptext = STYLE_SMALLFONTS_OUTLINE("<center>∞</center>", 12, COLOR_WHITE, COLOR_BLACK)
else
maptext = null
else if(duration <= 0)
maptext = STYLE_SMALLFONTS_OUTLINE("<center>0</center>", 7, COLOR_WHITE, COLOR_BLACK)
else
maptext = STYLE_SMALLFONTS_OUTLINE("<center>[ticks2shortreadable(duration) || 0]</center>", 7, COLOR_WHITE, COLOR_BLACK)

/obj/screen/mob_modifier/handle_click(mob/user, params)
if((. = ..()))
var/mob/living/owner = owner_ref?.resolve()
if(istype(owner) && archetype)
var/list/modifiers = LAZYACCESS(owner._mob_modifiers, archetype)
for(var/datum/mob_modifier/modifier in modifiers)
modifier.on_modifier_click(params)
return

/obj/screen/mob_modifier/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/mob_modifier/MouseDown()
closeToolTip(usr)
..()

/obj/screen/mob_modifier/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(target.mob_modifiers_block_attack(MM_ATTACK_TYPE_WEAPON, user, 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_camera_status(mended, usr)

if(CAMERA_WIRE_LIGHT)
C.light_disabled = !mended
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
/atom/proc/try_on_reagent_change()
SHOULD_NOT_OVERRIDE(TRUE)
set waitfor = FALSE
if(QDELETED(src) ||_reagent_update_started >= world.time)
if(QDELETED(src) || _reagent_update_started >= world.time)
return FALSE
_reagent_update_started = world.time
sleep(0) // Defer to end of tick so we don't drop subsequent reagent updates.
Expand Down
2 changes: 2 additions & 0 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,5 @@
return TRUE
return FALSE

/atom/movable/proc/get_cryogenic_power()
return 0
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
5 changes: 4 additions & 1 deletion code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
add_reagent_canister(null, new /obj/item/chems/chem_disp_cartridge/antitoxins())
add_reagent_canister(null, new /obj/item/chems/chem_disp_cartridge/oxy_meds())

/obj/machinery/sleeper/get_cryogenic_power()
return stasis

/obj/machinery/sleeper/Destroy()
QDEL_NULL(beaker)
QDEL_NULL_LIST(loaded_canisters)
Expand Down Expand Up @@ -168,7 +171,7 @@
toggle_lavage()

if(isliving(occupant) && stasis > 1)
occupant.set_stasis(stasis)
occupant.add_mob_modifier(/decl/mob_modifier/stasis, 2 SECONDS, source = src)

/obj/machinery/sleeper/on_update_icon()
cut_overlays()
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_component_status(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_component_status(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_component_status(machine, PART_STAT_PROCESSING)

/obj/item/stock_parts/proc/stop_processing(var/obj/machinery/machine)
if(istype(machine))
Expand Down
Loading

0 comments on commit 7dabe31

Please sign in to comment.