Skip to content

Commit

Permalink
refactor: No Transform Trait (ss220-space#4961)
Browse files Browse the repository at this point in the history
* No Transform Trait

* Few Tweaks

---------

Co-authored-by: Daeberdir <[email protected]>
  • Loading branch information
Gottfrei and Daeberdir authored May 10, 2024
1 parent ed2320d commit cb1a832
Show file tree
Hide file tree
Showing 42 changed files with 141 additions and 116 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_EMOTE_MUTE "emote_mute"
#define TRAIT_IGNORESLOWDOWN "ignoreslow"
#define TRAIT_IGNOREDAMAGESLOWDOWN "ignoredamageslowdown"
/// "Magic" trait that blocks the mob from moving or interacting with anything. Used for transient stuff like mob transformations or incorporality in special cases.
/// Will block movement, `Life()` (!!!), and other stuff based on the mob.
#define TRAIT_NO_TRANSFORM "block_transformations"
/// This mob heals from carp rifts.
#define TRAIT_HEALS_FROM_CARP_RIFTS "heals_from_carp_rifts"
/// This mob heals from cult pylons.
Expand Down
14 changes: 13 additions & 1 deletion code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// The item is magically cursed
#define CURSED_ITEM_TRAIT(item_type) "cursed_item_[item_type]"
/// Gives a unique trait source for any given datum
#define UNIQUE_TRAIT_SOURCE(target) "unique_source_[UID(target)]"
#define UNIQUE_TRAIT_SOURCE(target) "unique_source_[UID_of(target)]"
/// Trait applied by element
#define ELEMENT_TRAIT(source) "element_trait_[source]"
/// A trait given by a specific status effect (not sure why we need both but whatever!)
Expand All @@ -22,13 +22,18 @@
/// cannot be removed without admin intervention
#define ROUNDSTART_TRAIT "roundstart"

#define CINEMATIC_TRAIT "cinematic"

#define CHASM_TRAIT "chasm_trait"

// unique trait sources
#define CULT_EYES "cult_eyes"
#define CLOCK_HANDS "clock_hands"
#define PULSEDEMON_TRAIT "pulse_demon"
#define CHANGELING_TRAIT "changeling"
#define VAMPIRE_TRAIT "vampire"
#define NINJA_TRAIT "space-ninja"
#define REVENANT_TRAIT "revenant"
/// (B)admins only.
#define ADMIN_TRAIT "admin"

Expand Down Expand Up @@ -63,6 +68,13 @@
/// A trait gained from a mob's leap action, like the leaper
#define LEAPING_TRAIT "leaping"

#define INCORPOREAL_TRAIT "incorporeal"

/// Will be removed once the transformation is complete.
#define TEMPORARY_TRANSFORMATION_TRAIT "temporary_transformation"
/// Considered "permanent" since we'll be deleting the old mob and the client will be inserted into a new one (without this trait)
#define PERMANENT_TRANSFORMATION_TRAIT "permanent_transformation"

/// Trait given by your current speed
#define SPEED_TRAIT "speed_trait"

Expand Down
7 changes: 7 additions & 0 deletions code/__HELPERS/unique_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ GLOBAL_LIST_EMPTY(uid_log)
GLOB.uid_log[type]++
return unique_datum_id


/proc/UID_of(datum/target)
if(!isdatum(target))
CRASH("Non-datum passed as argument.")
return target.UID()


/**
* Locates a datum based off of the UID
*
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_LASEREYES" = TRAIT_LASEREYES,
"TRAIT_MUTE" = TRAIT_MUTE,
"TRAIT_NEGATES_GRAVITY" = TRAIT_NEGATES_GRAVITY,
"TRAIT_NO_TRANSFORM" = TRAIT_NO_TRANSFORM,
"TRAIT_PACIFISM" = TRAIT_PACIFISM,
"TRAIT_PULL_BLOCKED" = TRAIT_PULL_BLOCKED,
"TRAIT_RESTRAINED" = TRAIT_RESTRAINED,
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/npcpool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SUBSYSTEM_DEF(npcpool)
GLOB.simple_animals[AI_ON] -= SA
continue

if(!SA.ckey && !SA.notransform)
if(!SA.ckey && !HAS_TRAIT(SA, TRAIT_NO_TRANSFORM))
if(SA.stat != DEAD)
SA.handle_automated_movement()
if(SA.stat != DEAD)
Expand Down
16 changes: 6 additions & 10 deletions code/datums/cinematics/cinematic_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/datum/cinematic
/// A list of all clients watching the cinematic
var/list/client/watching = list()
/// A list of all mobs who have notransform set while watching the cinematic
/// A list of all mobs who have TRAIT_NO_TRANSFORM set, while watching the cinematic
var/list/datum/locked = list()
/// Whether the cinematic is a global cinematic or not
var/is_global = FALSE
Expand All @@ -60,7 +60,7 @@

/datum/cinematic/Destroy()
QDEL_NULL(screen)
QDEL_NULL(special_callback)
special_callback = null
watching.Cut()
locked.Cut()
return ..()
Expand Down Expand Up @@ -126,11 +126,7 @@
/datum/cinematic/proc/show_to(mob/watching_mob, client/watching_client)
SIGNAL_HANDLER

// We could technically rip people out of notransform who shouldn't be,
// so we'll only lock down all viewing mobs who don't have it already set.
// This does potentially mean some mobs could lose their notrasnform and
// not be locked down by cinematics, but that should be very unlikely.
if(!watching_mob.notransform)
if(!HAS_TRAIT_FROM(watching_mob, TRAIT_NO_TRANSFORM, CINEMATIC_TRAIT))
lock_mob(watching_mob)

// Only show the actual cinematic to cliented mobs.
Expand Down Expand Up @@ -187,7 +183,7 @@
*/
/datum/cinematic/proc/lock_mob(mob/to_lock)
locked += to_lock
to_lock.notransform = TRUE
ADD_TRAIT(to_lock, TRAIT_NO_TRANSFORM, CINEMATIC_TRAIT)


/**
Expand All @@ -197,7 +193,7 @@
var/mob/locked_mob = mob_ref
if(isnull(locked_mob))
return
locked_mob.notransform = FALSE
REMOVE_TRAIT(locked_mob, TRAIT_NO_TRANSFORM, CINEMATIC_TRAIT)
UnregisterSignal(locked_mob, COMSIG_MOB_CLIENT_LOGIN)


Expand All @@ -212,7 +208,7 @@

UnregisterSignal(no_longer_watching, COMSIG_PARENT_QDELETING)
// We'll clear the cinematic if they have a mob which has one,
// but we won't remove notransform. Wait for the cinematic end to do that.
// but we won't remove TRAIT_NO_TRANSFORM. Wait for the cinematic end to do that.
no_longer_watching.mob?.clear_fullscreen("cinematic")
no_longer_watching.screen -= screen

Expand Down
4 changes: 2 additions & 2 deletions code/datums/diseases/viruses/transformation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
affected_mob.death(1)
return

if(affected_mob.notransform)
if(HAS_TRAIT(affected_mob, TRAIT_NO_TRANSFORM))
return

affected_mob.notransform = 1
ADD_TRAIT(affected_mob, TRAIT_NO_TRANSFORM, PERMANENT_TRANSFORMATION_TRAIT)
affected_mob.canmove = FALSE
affected_mob.icon = null
affected_mob.cut_overlays()
Expand Down
9 changes: 5 additions & 4 deletions code/datums/spells/bloodcrawl.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@


/obj/effect/proc_holder/spell/bloodcrawl/proc/post_phase_in(mob/living/user, obj/effect/dummy/slaughter/holder)
user.notransform = FALSE
REMOVE_TRAIT(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))


/obj/effect/proc_holder/spell/bloodcrawl/proc/phaseout(obj/effect/decal/cleanable/enter_point, mob/living/carbon/user)

if(istype(user) && !block_hands(user))
return FALSE

user.notransform = TRUE
ADD_TRAIT(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
INVOKE_ASYNC(src, PROC_REF(async_phase), enter_point, user)
return TRUE

Expand Down Expand Up @@ -244,8 +244,9 @@


/obj/effect/proc_holder/spell/bloodcrawl/proc/phasein(atom/enter_point, mob/living/user)

if(user.notransform)
if(HAS_TRAIT_NOT_FROM(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src)))
return FALSE
if(HAS_TRAIT_FROM(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src)))
to_chat(user, span_warning("Finish eating first!"))
return FALSE
rise_message(enter_point)
Expand Down
16 changes: 8 additions & 8 deletions code/datums/spells/devil.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
if(continuing)
to_chat(user,"<span class='warning'>You are now phasing in.</span>")
if(do_mob(user,user,150))
user.infernalphasein()
user.infernalphasein(src)
else
to_chat(user,"<span class='warning'>You can only re-appear near a potential signer or on a shuttle.</span>")
revert_cast()
Expand All @@ -134,8 +134,8 @@
user.fakefire()
to_chat(user,"<span class='warning'>You begin to phase back into sinful flames.</span>")
if(do_mob(user,user,150))
user.notransform = TRUE
user.infernalphaseout()
ADD_TRAIT(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
user.infernalphaseout(src)
else
to_chat(user,"<span class='warning'>You must remain still while exiting.</span>")
user.ExtinguishMob()
Expand All @@ -144,22 +144,22 @@
revert_cast()


/mob/living/proc/infernalphaseout()
/mob/living/proc/infernalphaseout(obj/effect/proc_holder/spell/infernal_jaunt/spell)
dust_animation()
visible_message("<span class='warning'>[src] disappears in a flashfire!</span>")
playsound(get_turf(src), 'sound/misc/enter_blood.ogg', 100, 1, -1)
var/obj/effect/dummy/slaughter/s_holder = new(loc)
ExtinguishMob()
forceMove(s_holder)
holder = s_holder
notransform = FALSE
REMOVE_TRAIT(src, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(spell))
fakefireextinguish()


/mob/living/proc/infernalphasein()
if(notransform)
/mob/living/proc/infernalphasein(obj/effect/proc_holder/spell/infernal_jaunt/spell)
if(HAS_TRAIT(src, TRAIT_NO_TRANSFORM))
to_chat(src,"<span class='warning'>You're too busy to jaunt in.</span>")
return 0
return FALSE
fakefire()
forceMove(get_turf(src))
visible_message("<span class='warning'><B>[src] appears in a firey blaze!</B></span>")
Expand Down
4 changes: 2 additions & 2 deletions code/datums/spells/ethereal_jaunt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

/obj/effect/proc_holder/spell/ethereal_jaunt/proc/do_jaunt(mob/living/target)
playsound(get_turf(target), sound_in, 50, TRUE, -1)
target.notransform = TRUE
ADD_TRAIT(target, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
var/turf/mobloc = get_turf(target)
var/obj/effect/dummy/spell_jaunt/holder = new jaunt_type_path(mobloc)
new jaunt_out_type(mobloc, target.dir)
target.ExtinguishMob()
target.forceMove(holder)
target.reset_perspective(holder)
target.notransform = FALSE //mob is safely inside holder now, no need for protection.
REMOVE_TRAIT(target, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
if(jaunt_water_effect)
jaunt_steam(mobloc)

Expand Down
11 changes: 8 additions & 3 deletions code/datums/spells/rod_form.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
var/turf/start = get_turf(M)
var/obj/effect/immovablerod/wizard/W = new(start, get_ranged_target_turf(M, M.dir, (15 + spell_level * 3)), rod_delay)
W.wizard = M
W.spell = src
W.max_distance += spell_level * 3 //You travel farther when you upgrade the spell
W.start_turf = start
M.forceMove(W)
M.notransform = TRUE
ADD_TRAIT(M, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
M.status_flags |= GODMODE


Expand All @@ -42,10 +43,11 @@
var/max_distance = 13
var/mob/living/wizard
var/turf/start_turf
var/obj/effect/proc_holder/spell/spell
notify = FALSE


/obj/effect/immovablerod/wizard/Move()
/obj/effect/immovablerod/wizard/Move(atom/newloc, direct = NONE, movetime)
if(get_dist(start_turf, get_turf(src)) >= max_distance)
qdel(src)
..()
Expand All @@ -54,7 +56,10 @@
/obj/effect/immovablerod/wizard/Destroy()
if(wizard)
wizard.status_flags &= ~GODMODE
wizard.notransform = FALSE
REMOVE_TRAIT(wizard, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(spell))
wizard.forceMove(get_turf(src))
wizard = null
spell = null
start_turf = null
return ..()

6 changes: 3 additions & 3 deletions code/game/gamemodes/cult/runes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ structure_check() searches for nearby cultist structures required for the invoca
new /obj/effect/temp_visual/dir_setting/cult/phase/out(location, user.dir)
new /obj/effect/temp_visual/dir_setting/cult/phase(target, user.dir)
// So that the mob only appears after the effect is finished
user.notransform = TRUE
ADD_TRAIT(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
user.invisibility = INVISIBILITY_MAXIMUM
sleep(12)
user.notransform = FALSE
sleep(1.2 SECONDS)
REMOVE_TRAIT(user, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
user.invisibility = 0

/obj/effect/rune/proc/do_invoke_glow()
Expand Down
8 changes: 4 additions & 4 deletions code/game/gamemodes/miniantags/revenant/revenant.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
to_chat(src, "<span class='revenboldnotice'>You are once more concealed.</span>")
if(unstun_time && world.time >= unstun_time)
unstun_time = 0
notransform = 0
REMOVE_TRAIT(src, TRAIT_NO_TRANSFORM, REVENANT_TRAIT)
to_chat(src, "<span class='revenboldnotice'>You can move again!</span>")
update_icon(UPDATE_ICON_STATE)

Expand Down Expand Up @@ -217,7 +217,7 @@
return FALSE

to_chat(src, "<span class='revendanger'>NO! No... it's too late, you can feel your essence breaking apart...</span>")
notransform = 1
ADD_TRAIT(src, TRAIT_NO_TRANSFORM, REVENANT_TRAIT)
revealed = 1
invisibility = 0
playsound(src, 'sound/effects/screech.ogg', 100, 1)
Expand Down Expand Up @@ -297,7 +297,7 @@
return
if(time <= 0)
return
notransform = 1
ADD_TRAIT(src, TRAIT_NO_TRANSFORM, REVENANT_TRAIT)
if(!unstun_time)
to_chat(src, "<span class='revendanger'>You cannot move!</span>")
unstun_time = world.time + time
Expand All @@ -308,7 +308,7 @@

/mob/living/simple_animal/revenant/update_icon_state()
if(revealed)
if(notransform)
if(HAS_TRAIT_FROM(src, TRAIT_NO_TRANSFORM, REVENANT_TRAIT))
if(draining)
icon_state = icon_drain
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ GLOBAL_LIST_INIT(possibleShadowlingNames, list("U'ruan", "Y`shej", "Nex", "Hel-u
return

if("Yes")
user.notransform = TRUE
ADD_TRAIT(user, TRAIT_NO_TRANSFORM, PERMANENT_TRANSFORMATION_TRAIT)
user.visible_message("<span class='warning'>[user] gently rises into the air, red light glowing in its eyes.</span>", \
"<span class='shadowling'>You rise into the air and get ready for your transformation.</span>")

Expand Down
10 changes: 4 additions & 6 deletions code/game/objects/items/weapons/anomaly_extract.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@


/obj/effect/proc_holder/spell/slime_degradation/proc/slime_transform(mob/living/carbon/human/user)
for(var/obj/item/I in user)
if(!istype(I, /obj/item/implant))
user.drop_item_ground(I, force = TRUE)
for(var/obj/item/check as anything in user.get_equipped_items(include_pockets = TRUE, include_hands = TRUE))
user.drop_item_ground(check, force = TRUE)

user.underwear = "Nude"
user.undershirt = "Nude"
Expand All @@ -116,7 +115,7 @@
span_notice("You hear something squishing..."))

original_body = user
user.notransform = TRUE
ADD_TRAIT(original_body, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
slimeme.status_flags |= GODMODE
user.status_flags |= GODMODE
slimeme.canmove = FALSE
Expand Down Expand Up @@ -148,7 +147,6 @@
cooldown_handler.start_recharge()
playsound(get_turf(usr), sound, 50, TRUE)
user.density = FALSE
original_body.notransform = TRUE
original_body.dir = SOUTH
original_body.forceMove(get_turf(user))
original_body.canmove = FALSE
Expand All @@ -170,7 +168,7 @@
stack_trace("Spell or original_body was qdeled during the [src] work.")
return

original_body.notransform = FALSE
REMOVE_TRAIT(original_body, TRAIT_NO_TRANSFORM, UNIQUE_TRAIT_SOURCE(src))
original_body.status_flags &= ~GODMODE
original_body.canmove = TRUE
is_transformed = FALSE
Expand Down
Loading

0 comments on commit cb1a832

Please sign in to comment.