From c52d688352bae1d2dc80f68c7594d7de19ddc333 Mon Sep 17 00:00:00 2001 From: san7890 Date: Sat, 2 Dec 2023 19:42:16 -0700 Subject: [PATCH] Retools `IS_SPINNING_1` into a trait (#80060) ## About The Pull Request This did NOT need to be on the `/atom` level `flags_1`- when on earth is an area going to spin? Anyways, this was really only ever used on the `/mob` sublevel in `spin()` code, but I think this would work far better as a trait for source-management than moving it to a mob flag or something. So, let's do that. ## Why It's Good For The Game Frees up a slot on `flags_1`, which is neat, as well as makes the framework for managing "things that make you spin" potentially better for future expansion. It also properly scopes something that only works for mobs right now to mobs (kinda), so it's a bit better that way too. ## Changelog Nothing that concerns players. --- code/__DEFINES/_flags.dm | 18 ++++++++---------- code/__DEFINES/traits/declarations.dm | 2 ++ code/_globalvars/bitfields.dm | 1 - code/_globalvars/traits/_traits.dm | 1 + .../dna_infuser/organ_sets/roach_organs.dm | 2 +- .../heretic/knowledge/blade_lore.dm | 2 +- code/modules/assembly/flash.dm | 2 +- code/modules/basketball/basketball.dm | 4 ++-- code/modules/basketball/hoop.dm | 2 +- code/modules/mob/mob.dm | 8 ++++++-- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/_flags.dm b/code/__DEFINES/_flags.dm index f69e18910fa..7cd6a2b509c 100644 --- a/code/__DEFINES/_flags.dm +++ b/code/__DEFINES/_flags.dm @@ -37,27 +37,25 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define ALLOW_DARK_PAINTS_1 (1<<9) /// Should this object be unpaintable? #define UNPAINTABLE_1 (1<<10) -/// Is the thing currently spinning? -#define IS_SPINNING_1 (1<<11) /// Is this atom on top of another atom, and as such has click priority? -#define IS_ONTOP_1 (1<<12) +#define IS_ONTOP_1 (1<<11) /// Is this atom immune to being dusted by the supermatter? -#define SUPERMATTER_IGNORES_1 (1<<13) +#define SUPERMATTER_IGNORES_1 (1<<12) /// If a turf can be made dirty at roundstart. This is also used in areas. -#define CAN_BE_DIRTY_1 (1<<14) +#define CAN_BE_DIRTY_1 (1<<13) /// Should we use the initial icon for display? Mostly used by overlay only objects -#define HTML_USE_INITAL_ICON_1 (1<<15) +#define HTML_USE_INITAL_ICON_1 (1<<14) /// Can players recolor this in-game via vendors (and maybe more if support is added)? -#define IS_PLAYER_COLORABLE_1 (1<<16) +#define IS_PLAYER_COLORABLE_1 (1<<15) /// Whether or not this atom has contextual screentips when hovered OVER -#define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<17) +#define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<16) /// Whether or not this atom is storing contents for a disassociated storage object -#define HAS_DISASSOCIATED_STORAGE_1 (1<<18) +#define HAS_DISASSOCIATED_STORAGE_1 (1<<17) /// If this atom has experienced a decal element "init finished" sourced appearance update /// We use this to ensure stacked decals don't double up appearance updates for no rasin /// Flag as an optimization, don't make this a trait without profiling /// Yes I know this is a stupid flag, no you can't take him from me -#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<19) +#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<18) // Update flags for [/atom/proc/update_appearance] /// Update the atom's name diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm index 4b2f779da29..e031bc50ba8 100644 --- a/code/__DEFINES/traits/declarations.dm +++ b/code/__DEFINES/traits/declarations.dm @@ -892,6 +892,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define STATION_TRAIT_UNNATURAL_ATMOSPHERE "station_trait_unnatural_atmosphere" #define STATION_TRAIT_VENDING_SHORTAGE "station_trait_vending_shortage" +/// This atom is currently spinning. +#define TRAIT_SPINNING "spinning" /// Denotes that this id card was given via the job outfit, aka the first ID this player got. #define TRAIT_JOB_FIRST_ID_CARD "job_first_id_card" diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index cf1e5d387d6..055d32cc77a 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -125,7 +125,6 @@ DEFINE_BITFIELD(flags_1, list( "INITIALIZED_1" = INITIALIZED_1, "IS_ONTOP_1" = IS_ONTOP_1, "IS_PLAYER_COLORABLE_1" = IS_PLAYER_COLORABLE_1, - "IS_SPINNING_1" = IS_SPINNING_1, "NO_SCREENTIPS_1" = NO_SCREENTIPS_1, "NODECONSTRUCT_1" = NODECONSTRUCT_1, "ON_BORDER_1" = ON_BORDER_1, diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm index 5def212a5bb..72a98217efe 100644 --- a/code/_globalvars/traits/_traits.dm +++ b/code/_globalvars/traits/_traits.dm @@ -25,6 +25,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_MAT_TRANSMUTED" = TRAIT_MAT_TRANSMUTED, "TRAIT_RECENTLY_COINED" = TRAIT_RECENTLY_COINED, "TRAIT_RUSTY" = TRAIT_RUSTY, + "TRAIT_SPINNING" = TRAIT_SPINNING, "TRAIT_STICKERED" = TRAIT_STICKERED, ), /atom/movable = list( diff --git a/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm b/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm index 3c2d461e08c..f10c9b039f2 100644 --- a/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm +++ b/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm @@ -137,7 +137,7 @@ if(!ishuman(blocker) || blocker.stat >= UNCONSCIOUS) return FALSE // No tactical spinning - if(blocker.flags_1 & IS_SPINNING_1) + if(HAS_TRAIT(blocker, TRAIT_SPINNING)) return FALSE if(blocker.body_position == LYING_DOWN || (blocker.dir & attack_direction)) return TRUE diff --git a/code/modules/antagonists/heretic/knowledge/blade_lore.dm b/code/modules/antagonists/heretic/knowledge/blade_lore.dm index eae5b856318..03b9a716d53 100644 --- a/code/modules/antagonists/heretic/knowledge/blade_lore.dm +++ b/code/modules/antagonists/heretic/knowledge/blade_lore.dm @@ -70,7 +70,7 @@ var/are_we_behind = FALSE // No tactical spinning allowed - if(target.flags_1 & IS_SPINNING_1) + if(HAS_TRAIT(target, TRAIT_SPINNING)) are_we_behind = TRUE // We'll take "same tile" as "behind" for ease diff --git a/code/modules/assembly/flash.dm b/code/modules/assembly/flash.dm index 553118aae24..d474763048e 100644 --- a/code/modules/assembly/flash.dm +++ b/code/modules/assembly/flash.dm @@ -193,7 +193,7 @@ // Tactical combat emote-spinning should not counter intended gameplay mechanics. // This trumps same-loc checks to discourage floor spinning in general to counter flashes. // In short, combat spinning is silly and you should feel silly for doing it. - if(victim.flags_1 & IS_SPINNING_1) + if(HAS_TRAIT(victim, TRAIT_SPINNING)) return DEVIATION_NONE if(iscarbon(victim)) diff --git a/code/modules/basketball/basketball.dm b/code/modules/basketball/basketball.dm index 232b65d8e1c..9fe176715db 100644 --- a/code/modules/basketball/basketball.dm +++ b/code/modules/basketball/basketball.dm @@ -106,7 +106,7 @@ return // spinning gives you a lower disarm chance but it drains stamina - var/disarm_chance = baller.flags_1 & IS_SPINNING_1 ? 35 : 50 + var/disarm_chance = HAS_TRAIT(baller, TRAIT_SPINNING) ? 35 : 50 // ballers stamina results in lower disarm, stealer stamina results in higher disarm disarm_chance += (baller.getStaminaLoss() - stealer.getStaminaLoss()) / 2 // the lowest chance for disarm is 25% and the highest is 75% @@ -169,7 +169,7 @@ return // need a free hand and can't be spinning - if(!user.put_in_inactive_hand(src) || user.flags_1 & IS_SPINNING_1) + if(!user.put_in_inactive_hand(src) || HAS_TRAIT(user, TRAIT_SPINNING)) return last_use = world.time diff --git a/code/modules/basketball/hoop.dm b/code/modules/basketball/hoop.dm index 5de263c4786..dd0585e0742 100644 --- a/code/modules/basketball/hoop.dm +++ b/code/modules/basketball/hoop.dm @@ -164,7 +164,7 @@ score_chance *= 0.5 // aim penalty for spinning while shooting - if(istype(thrower) && thrower.flags_1 & IS_SPINNING_1) + if(istype(thrower) && HAS_TRAIT(thrower, TRAIT_SPINNING)) score_chance *= 0.5 if(prob(score_chance)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index ebdbd9a8d42..c22f7f7c960 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -705,6 +705,8 @@ /mob/proc/can_resist() return FALSE //overridden in living.dm +#define SPIN_PROC_TRAIT "trait_from_spin()" + ///Spin this mob around it's central axis /mob/proc/spin(spintime, speed) set waitfor = 0 @@ -712,7 +714,7 @@ if((spintime < 1) || (speed < 1) || !spintime || !speed) return - flags_1 |= IS_SPINNING_1 + ADD_TRAIT(src, TRAIT_SPINNING, SPIN_PROC_TRAIT) while(spintime >= speed) sleep(speed) switch(D) @@ -726,7 +728,9 @@ D = NORTH setDir(D) spintime -= speed - flags_1 &= ~IS_SPINNING_1 + REMOVE_TRAIT(src, TRAIT_SPINNING, SPIN_PROC_TRAIT) + +#undef SPIN_PROC_TRAIT ///Update the pulling hud icon /mob/proc/update_pull_hud_icon()