Skip to content

Commit

Permalink
[REFACTOR] Remove the flying var, adds the flying trait. (#26881)
Browse files Browse the repository at this point in the history
* Remove the flying var, adds the flying trait

* Remove flight when broomstick is unwielded

* Adds some comments

* tab indentation

* Fix carp flight

* Remove comment

---------

Co-authored-by: Adrer <[email protected]>
  • Loading branch information
Adrer and Adrer authored Oct 16, 2024
1 parent be2cdeb commit c3d7734
Show file tree
Hide file tree
Showing 51 changed files with 86 additions and 78 deletions.
2 changes: 1 addition & 1 deletion code/__HELPERS/paths/path.dm
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
src.can_ventcrawl = living_construct.ventcrawler == VENTCRAWLER_ALWAYS || living_construct.ventcrawler == VENTCRAWLER_NUDE
src.mob_size = living_construct.mob_size
src.incorporeal_move = living_construct.incorporeal_move
is_flying = living_construct.flying
is_flying = HAS_TRAIT(living_construct, TRAIT_FLYING)
if(iscameramob(construct_from))
src.camera_type = construct_from.type
src.is_bot = isbot(construct_from)
Expand Down
10 changes: 10 additions & 0 deletions code/__HELPERS/trait_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_NPC_ZOMBIE "npc_zombie" // A trait for checking if a zombie should act like an NPC and attack
#define TRAIT_ABSTRACT_HANDS "abstract_hands" // Mobs with this trait can only pick up abstract items.
#define TRAIT_LANGUAGE_LOCKED "language_locked" // cant add/remove languages until removed (excludes babel because fuck everything i guess)
#define TRAIT_FLYING "flying"

//***** MIND TRAITS *****/
#define TRAIT_HOLY "is_holy" // The mob is holy in regards to religion
Expand Down Expand Up @@ -412,3 +413,12 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
//***** EFFECT TRAITS *****//
// Causes the effect to go through a teleporter instead of being deleted by it.
#define TRAIT_EFFECT_CAN_TELEPORT "trait_effect_can_teleport"

//***** PROC WRAPPERS *****//
/// Proc wrapper of add_trait. You should only use this for callback. Otherwise, use the macro.
/proc/callback_add_trait(datum/target, trait, source)
ADD_TRAIT(target, trait, source)

/// Proc wrapper of remove_trait. You should only use this for callback. Otherwise, use the macro.
/proc/callback_remove_trait(datum/target, trait, source)
REMOVE_TRAIT(target, trait, source)
2 changes: 1 addition & 1 deletion code/datums/components/caltrop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
if(bypass_shoes && ((H?.shoes?.flags & THICKMATERIAL) || (H?.wear_suit?.flags & THICKMATERIAL)))
return

if(H.flying || H.floating || H.buckled)
if(HAS_TRAIT(H, TRAIT_FLYING) || H.floating || H.buckled)
return

if(IS_HORIZONTAL(H) && HAS_TRAIT(H, TRAIT_CONTORTED_BODY))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
return

var/mob/living/LM = parent
if(!T.footstep || !(LM.mobility_flags & MOBILITY_MOVE) || LM.buckled || LM.throwing || LM.flying || istype(LM.loc, /obj/machinery/atmospherics))
if(!T.footstep || !(LM.mobility_flags & MOBILITY_MOVE) || LM.buckled || LM.throwing || HAS_TRAIT(LM, TRAIT_FLYING) || istype(LM.loc, /obj/machinery/atmospherics))
return

steps++
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/slippery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Additionally calls the parent's `after_slip()` proc on the `victim`.
*/
/datum/component/slippery/proc/Slip(datum/source, mob/living/carbon/human/victim)
if(istype(victim) && !victim.flying)
if(istype(victim) && !HAS_TRAIT(victim, TRAIT_FLYING))
var/atom/movable/owner = parent
if(!isturf(owner.loc))
return
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/squeak.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
return
if(ismob(crossing))
var/mob/M = crossing
if(M.flying)
if(HAS_TRAIT(M, TRAIT_FLYING))
return
if(isliving(crossing))
var/mob/living/L = M
Expand All @@ -94,7 +94,7 @@
return
if(ismob(source))
var/mob/M = source
if(M.flying)
if(HAS_TRAIT(M, TRAIT_FLYING))
return
if(isliving(source))
var/mob/living/L = M
Expand Down
2 changes: 1 addition & 1 deletion code/datums/weather/weather_types/floor_is_lava.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
return
if(!L.client) //Only sentient people are going along with it!
return
if(L.flying)
if(HAS_TRAIT(L, TRAIT_FLYING))
return
L.adjustFireLoss(3)

Expand Down
5 changes: 2 additions & 3 deletions code/game/dna/mutations/mutation_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,9 @@
"<span class='notice'>You hear the flexing of powerful muscles and suddenly a crash as a body hits the floor.</span>")
return FALSE
var/prevLayer = user.layer
var/prevFlying = user.flying
user.layer = 9

user.flying = TRUE
ADD_TRAIT(user, TRAIT_FLYING, "leap")
for(var/i in 1 to leap_distance)
var/turf/hit_turf = get_step(user, user.dir)
var/atom/hit_atom = get_blocking_atom(hit_turf)
Expand All @@ -560,7 +559,7 @@
user.pixel_y -= 8
sleep(1)

user.flying = prevFlying
REMOVE_TRAIT(user, TRAIT_FLYING, "leap")
user.pixel_y = 0 // In case leap was varedited to be longer or shorter

if(HAS_TRAIT(user, TRAIT_FAT) && prob(66))
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/miniantags/guardian/guardian.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
a_intent = INTENT_HARM
can_change_intents = FALSE
stop_automated_movement = TRUE
flying = TRUE
attack_sound = 'sound/weapons/punch1.ogg'
minbodytemp = 0
maxbodytemp = INFINITY
Expand All @@ -31,6 +30,7 @@
AIStatus = AI_OFF
butcher_results = list(/obj/item/food/ectoplasm = 1)
hud_type = /datum/hud/guardian
initial_traits = list(TRAIT_FLYING)
var/summoned = FALSE
var/cooldown = 0
var/damage_transfer = 1 //how much damage from each attack we transfer to the owner
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/miniantags/pulsedemon/pulsedemon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
maxHealth = 50
health = 50
speed = -0.5
flying = TRUE
mob_size = MOB_SIZE_TINY
density = FALSE
del_on_death = TRUE
Expand All @@ -53,6 +52,7 @@
// this makes the demon able to speak through holopads, due to the overriden say, PD cannot speak normally regardless
universal_speak = TRUE
loot = list(/obj/item/organ/internal/heart/demon/pulse)
initial_traits = list(TRAIT_FLYING)

/// List of sounds that is picked from when the demon speaks.
var/list/speech_sounds = list("sound/voice/pdvoice1.ogg", "sound/voice/pdvoice2.ogg", "sound/voice/pdvoice3.ogg")
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/miniantags/revenant/revenant.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
status_flags = 0
wander = FALSE
density = FALSE
flying = TRUE
move_resist = INFINITY
mob_size = MOB_SIZE_TINY
pass_flags = PASSTABLE | PASSGRILLE | PASSMOB
atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
initial_traits = list(TRAIT_FLYING)

/// The revenant's idle icon
var/icon_idle = "revenant_idle"
Expand Down
6 changes: 3 additions & 3 deletions code/game/gamemodes/wizard/magic_tarot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,10 @@
card_icon = "the_hanged_man"

/datum/tarot/the_hanged_man/activate(mob/living/target)
if(target.flying)
if(HAS_TRAIT(target, TRAIT_FLYING))
return
target.flying = TRUE
addtimer(VARSET_CALLBACK(target, flying, FALSE), 60 SECONDS)
ADD_TRAIT(target, TRAIT_FLYING, "tarot")
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(callback_remove_trait), target, TRAIT_FLYING, "tarot"), 60 SECONDS)

/datum/tarot/death
name = "XIII - Death"
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/alien_acid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/obj/effect/acid/Crossed(AM as mob|obj)
if(isliving(AM))
var/mob/living/L = AM
if(L.flying)
if(HAS_TRAIT(L, TRAIT_FLYING))
return
if(L.m_intent != MOVE_INTENT_WALK && prob(40))
var/acid_used = min(acid_level * 0.05, 20)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/mines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var/mob/living/M = AM
if(faction && (faction in M.faction))
return
if(M.flying)
if(HAS_TRAIT(M, TRAIT_FLYING))
return
triggermine(M)

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/legcuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
return ..()

var/mob/living/L = AM
if((iscarbon(AM) || isanimal(AM)) && !L.flying)
if((iscarbon(AM) || isanimal(AM)) && HAS_TRAIT(L, TRAIT_FLYING))
spring_trap(AM)

if(ishuman(AM))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/shards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

/obj/item/shard/Crossed(mob/living/L, oldloc)
if(istype(L) && has_gravity(loc))
if(L.incorporeal_move || L.flying || L.floating)
if(L.incorporeal_move || HAS_TRAIT(L, TRAIT_FLYING) || L.floating)
return
playsound(loc, 'sound/effects/glass_step.ogg', 50, TRUE)
return ..()
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/weapons/staff.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
user.update_inv_l_hand()
user.update_inv_r_hand()
if(iswizard(user))
user.flying = TRUE
ADD_TRAIT(user, TRAIT_FLYING, "broomstick")
user.say("QUID 'ITCH")
animate(user, pixel_y = pixel_y + 10 , time = 10, loop = 1, easing = SINE_EASING)
to_chat(user, "<span class='notice'>You hold [src] between your legs.</span>")
Expand All @@ -44,6 +44,7 @@
user.update_inv_l_hand()
user.update_inv_r_hand()
if(iswizard(user))
REMOVE_TRAIT(user, TRAIT_FLYING, "broomstick")
animate(user, pixel_y = pixel_y + 10 , time = 1, loop = 1)
animate(user, pixel_y = pixel_y, time = 10, loop = 1, easing = SINE_EASING)
animate(user)
Expand All @@ -58,8 +59,7 @@
..()

/obj/item/staff/broom/dropped(mob/user)
if(iswizard(user) && user.flying)
user.flying = FALSE
REMOVE_TRAIT(user, TRAIT_FLYING, "broomstick")
..()

/obj/item/staff/broom/horsebroom
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/railings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
return TRUE
if(ismob(mover))
var/mob/living/M = mover
if(M.flying || (istype(M) && IS_HORIZONTAL(M) && HAS_TRAIT(M, TRAIT_CONTORTED_BODY)))
if(HAS_TRAIT(M, TRAIT_FLYING) || (istype(M) && IS_HORIZONTAL(M) && HAS_TRAIT(M, TRAIT_CONTORTED_BODY)))
return TRUE
if(mover.throwing)
return TRUE
Expand All @@ -133,7 +133,7 @@
if(isprojectile(O))
return TRUE
if(istype(M))
if(M.flying || M.floating || (IS_HORIZONTAL(M) && HAS_TRAIT(M, TRAIT_CONTORTED_BODY)))
if(HAS_TRAIT(M, TRAIT_FLYING) || M.floating || (IS_HORIZONTAL(M) && HAS_TRAIT(M, TRAIT_CONTORTED_BODY)))
return TRUE
if(O.throwing)
return TRUE
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
if(istype(mover,/obj/item/projectile))
return (check_cover(mover,target))
var/mob/living/living_mover = mover
if(istype(living_mover) && (living_mover.flying || (IS_HORIZONTAL(living_mover) && HAS_TRAIT(living_mover, TRAIT_CONTORTED_BODY))))
if(istype(living_mover) && (HAS_TRAIT(living_mover, TRAIT_FLYING) || (IS_HORIZONTAL(living_mover) && HAS_TRAIT(living_mover, TRAIT_CONTORTED_BODY))))
return TRUE
if(istype(mover) && mover.checkpass(PASSTABLE))
return TRUE
Expand Down Expand Up @@ -484,7 +484,7 @@
if(!isliving(AM))
return
var/mob/living/L = AM
if(L.incorporeal_move || L.flying || L.floating)
if(L.incorporeal_move || HAS_TRAIT(L, TRAIT_FLYING) || L.floating)
return

// Don't break if they're just flying past
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/simulated.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
if(IS_HORIZONTAL(M))
return 1

if(M.flying)
if(HAS_TRAIT(M, TRAIT_FLYING))
return ..()

switch(src.wet)
Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/simulated/floor/chasm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
//Flies right over the chasm
if(isliving(AM))
var/mob/living/M = AM
if(M.flying || M.floating)
if(HAS_TRAIT(M, TRAIT_FLYING) || M.floating)
return FALSE
if(istype(M.buckled, /obj/tgvehicle/scooter/skateboard/hoverboard))
return FALSE
Expand Down Expand Up @@ -273,10 +273,10 @@
playsound(ourturf, 'sound/effects/bang.ogg', 50, TRUE)
ourturf.visible_message("<span class='boldwarning'>[escapee] busts through [ourturf], leaping out of the chasm below!</span>")
ourturf.ChangeTurf(ourturf.baseturf)
escapee.flying = TRUE
ADD_TRAIT(escapee, TRAIT_FLYING, "chasm_escape")
escapee.forceMove(ourturf)
escapee.throw_at(get_edge_target_turf(ourturf, pick(GLOB.alldirs)), rand(2, 10), rand(2, 10))
escapee.flying = FALSE
REMOVE_TRAIT(escapee, TRAIT_FLYING, "chasm_escape")
escapee.Sleeping(20 SECONDS)

/turf/simulated/floor/chasm/straight_down/lava_land_surface/normal_air
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/simulated/floor/lava.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
else if(isliving(thing))
. = TRUE
var/mob/living/L = thing
if(L.flying)
if(HAS_TRAIT(L, TRAIT_FLYING))
continue //YOU'RE FLYING OVER IT
var/buckle_check = L.buckling
if(!buckle_check)
Expand Down Expand Up @@ -221,7 +221,7 @@
continue
. = TRUE
var/mob/living/burn_living = thing
if(burn_living.flying)
if(HAS_TRAIT(burn_living, TRAIT_FLYING))
continue //YOU'RE FLYING OVER IT
var/buckle_check = burn_living.buckling
if(!buckle_check)
Expand Down
7 changes: 2 additions & 5 deletions code/modules/clothing/shoes/magboots.dm
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,8 @@
return

var/atom/target = get_edge_target_turf(user, user.dir) //gets the user's direction
var/do_callback = FALSE
if(!user.flying)
user.flying = TRUE
do_callback = TRUE
if(user.throw_at(target, jumpdistance, jumpspeed, spin = FALSE, diagonals_first = TRUE, callback = do_callback ? VARSET_CALLBACK(user, flying, FALSE) : null))
ADD_TRAIT(user, TRAIT_FLYING, "gravity_boots")
if(user.throw_at(target, jumpdistance, jumpspeed, spin = FALSE, diagonals_first = TRUE, callback = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(callback_remove_trait), user, TRAIT_FLYING, "gravity_boots")))
playsound(src, 'sound/effects/stealthoff.ogg', 50, TRUE, 1)
user.visible_message("<span class='warning'>[usr] dashes forward into the air!</span>")
recharging_time = world.time + recharging_rate
Expand Down
7 changes: 2 additions & 5 deletions code/modules/clothing/shoes/misc_shoes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,8 @@
return

var/atom/target = get_edge_target_turf(user, user.dir) //gets the user's direction
var/do_callback = FALSE
if(!user.flying)
user.flying = TRUE
do_callback = TRUE
if(user.throw_at(target, jumpdistance, jumpspeed, spin = FALSE, diagonals_first = TRUE, callback = do_callback ? VARSET_CALLBACK(user, flying, FALSE) : null))
ADD_TRAIT(user, TRAIT_FLYING, "bhop_shoes")
if(user.throw_at(target, jumpdistance, jumpspeed, spin = FALSE, diagonals_first = TRUE, callback = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(callback_remove_trait), user, TRAIT_FLYING, "bhop_shoes")))
playsound(src, 'sound/effects/stealthoff.ogg', 50, TRUE, 1)
user.visible_message("<span class='warning'>[usr] dashes forward into the air!</span>")
recharging_time = world.time + recharging_rate
Expand Down
2 changes: 1 addition & 1 deletion code/modules/events/blob/blob_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
environment_smash = ENVIRONMENT_SMASH_STRUCTURES
attacktext = "hits"
attack_sound = 'sound/weapons/genhit1.ogg'
flying = TRUE
initial_traits = list(TRAIT_FLYING)
speak_emote = list("pulses")
var/obj/structure/blob/factory/factory = null
var/list/human_overlays = list()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mining/lavaland/loot/colossus_loot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
harm_intent_damage = 1
friendly = "mends"
density = FALSE
flying = TRUE
initial_traits = list(TRAIT_FLYING)
obj_damage = 0
pass_flags = PASSTABLE | PASSGRILLE | PASSMOB
ventcrawler = VENTCRAWLER_ALWAYS
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/carbon_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven


/mob/living/carbon/proc/slip(description, knockdown, tilesSlipped, walkSafely, slipAny, slipVerb = "slip")
if(flying || buckled || (walkSafely && m_intent == MOVE_INTENT_WALK))
if(HAS_TRAIT(src, TRAIT_FLYING) || buckled || (walkSafely && m_intent == MOVE_INTENT_WALK))
return FALSE

if(IS_HORIZONTAL(src) && !tilesSlipped)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/species/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
if(HAS_TRAIT(H, TRAIT_IGNORESLOWDOWN))
ignoreslow = TRUE

var/flight = H.flying //Check for flight and flying items
var/flight = HAS_TRAIT(H, TRAIT_FLYING) //Check for flight and flying items

ADD_SLOWDOWN(speed_mod)

Expand Down
Loading

0 comments on commit c3d7734

Please sign in to comment.