Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: normally working invisibility #6071

Merged
merged 5 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
#define LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE 128 //For lighting alpha, small amounts lead to big changes. even at 128 its hard to figure out what is dark and what is light, at 64 you almost can't even tell.
#define LIGHTING_PLANE_ALPHA_INVISIBLE 0

#define ALPHA_SOURCE_DEFAULT "default"
#define ALPHA_SOURCE_CHAMELEON "chameleon_gene"
#define ALPHA_SOURCE_SHADOW_CLOAK "shadow_cloak_gene"
#define ALPHA_SOURCE_VAMPIRE "vampire"
#define ALPHA_SOURCE_SHADOW_THRALL "shadowling_thrall"
#define ALPHA_SOURCE_SHADOWLING "shadowling"
#define ALPHA_SOURCE_NINJA "ninja"
#define ALPHA_SOURCE_CLOCKROBE "clockrobe"


//code assumes higher numbers override lower numbers.
#define LIGHTING_NO_UPDATE 0
Expand Down
38 changes: 19 additions & 19 deletions code/game/dna/genes/goon_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,59 +31,59 @@
// Stealth Enhancers
/////////////////////////

/datum/dna/gene/basic/stealth
instability = GENE_INSTABILITY_MODERATE


/datum/dna/gene/basic/stealth/deactivate(mob/living/mutant, flags)
. = ..()
mutant.alpha = initial(mutant.alpha)


// WAS: /datum/bioEffect/darkcloak
/datum/dna/gene/basic/stealth/darkcloak
/datum/dna/gene/basic/darkcloak
name = "Cloak of Darkness"
desc = "Позволяет субъекту излучать вокруг себя слабое свечение, создавая эффект маскировки."
activation_messages = list("Вы начинаете исчезать в тени.")
deactivation_messages = list("Вы становитесь полностью видимым.")
activation_prob = 25
instability = GENE_INSTABILITY_MODERATE


/datum/dna/gene/basic/stealth/darkcloak/New()
/datum/dna/gene/basic/darkcloak/New()
..()
block = GLOB.shadowblock


/datum/dna/gene/basic/stealth/darkcloak/OnMobLife(mob/living/mutant)
/datum/dna/gene/basic/darkcloak/OnMobLife(mob/living/mutant)
var/turf/simulated/T = get_turf(mutant)
if(!istype(T))
return
var/light_available = T.get_lumcount() * 10
if(light_available <= 2)
mutant.alpha = round(mutant.alpha * 0.8)
mutant.alpha_multiply(0.8, ALPHA_SOURCE_SHADOW_CLOAK)
else
mutant.alpha = initial(mutant.alpha)
mutant.alpha_set(1, ALPHA_SOURCE_SHADOW_CLOAK)

/datum/dna/gene/basic/darkcloak/deactivate(mob/living/mutant, flags)
. = ..()
mutant.alpha_set(1, ALPHA_SOURCE_SHADOW_CLOAK)

//WAS: /datum/bioEffect/chameleon
/datum/dna/gene/basic/stealth/chameleon
/datum/dna/gene/basic/chameleon
name = "Chameleon"
desc = "Субъект обретает способность тонко изменять структуру света, чтобы оставаться невидимым до тех пор, пока он остается неподвижным."
activation_messages = list("Вы чувствуете себя единым целым с окружающим миром.")
deactivation_messages = list("Вы чувствуете себя необычайно заметным.")
activation_prob = 25
instability = GENE_INSTABILITY_MODERATE


/datum/dna/gene/basic/stealth/chameleon/New()
/datum/dna/gene/basic/chameleon/New()
..()
block = GLOB.chameleonblock


/datum/dna/gene/basic/stealth/chameleon/OnMobLife(mob/living/mutant)
/datum/dna/gene/basic/chameleon/OnMobLife(mob/living/mutant)
if((world.time - mutant.last_movement) >= 30 && (mutant.mobility_flags & MOBILITY_MOVE) && !HAS_TRAIT(mutant, TRAIT_RESTRAINED))
mutant.alpha -= 25
mutant.alpha_add(-25 / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_CHAMELEON)
else
mutant.alpha = round(255 * 0.80)
mutant.alpha_set(0.80, ALPHA_SOURCE_CHAMELEON)

/datum/dna/gene/basic/darkcloak/deactivate(mob/living/mutant, flags)
. = ..()
mutant.alpha_set(1, ALPHA_SOURCE_CHAMELEON)


/////////////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions code/game/gamemodes/clockwork/clockwork_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@
animate(carbon, alpha = 20, time = 1 SECONDS)
ADD_TRAIT(src, TRAIT_NODROP, CURSED_ITEM_TRAIT(INVIS_SPELL))
sleep(10)
carbon.alpha = 20
carbon.alpha_set(20 / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_CLOCKROBE)
add_attack_logs(user, user, "cloaked [src]", ATKLOG_ALL)
addtimer(CALLBACK(src, PROC_REF(uncloak), carbon), 10 SECONDS)
if(enchant_type == SPEED_SPELL)
Expand All @@ -729,11 +729,11 @@
else
ToggleHood()

/obj/item/clothing/suit/hooded/clockrobe/proc/uncloak(mob/user)
/obj/item/clothing/suit/hooded/clockrobe/proc/uncloak(mob/living/user)
animate(user, alpha = 255, time = 1 SECONDS)
REMOVE_TRAIT(src, TRAIT_NODROP, CURSED_ITEM_TRAIT(INVIS_SPELL))
sleep(10)
user.alpha = 255
user.alpha_set(1, ALPHA_SOURCE_CLOCKROBE)
deplete_spell()

/obj/item/clothing/suit/hooded/clockrobe/proc/unspeed(mob/living/carbon/carbon)
Expand Down
16 changes: 8 additions & 8 deletions code/game/gamemodes/shadowling/shadowling_abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
user.SetWeakened(0)
user.SetKnockdown(0)
user.incorporeal_move = INCORPOREAL_NORMAL
user.alpha = 0
user.alpha_set(0, ALPHA_SOURCE_SHADOWLING)
user.ExtinguishMob()
user.forceMove(get_turf(user)) //to properly move the mob out of a potential container
user.pulledby?.stop_pulling()
Expand All @@ -151,7 +151,7 @@

user.visible_message("<span class='warning'>[user] suddenly manifests!</span>", "<span class='shadowling'>The pressure becomes too much and you vacate the interdimensional darkness.</span>")
user.incorporeal_move = INCORPOREAL_NONE
user.alpha = 255
user.alpha_set(1, ALPHA_SOURCE_SHADOWLING)
user.forceMove(get_turf(user))


Expand All @@ -174,17 +174,17 @@
return new /datum/spell_targeting/self


/obj/effect/proc_holder/spell/shadowling_guise/cast(list/targets, mob/user = usr)
/obj/effect/proc_holder/spell/shadowling_guise/cast(list/targets, mob/living/user = usr)
user.visible_message("<span class='warning'>[user] suddenly fades away!</span>", "<span class='shadowling'>You veil yourself in darkness, making you harder to see.</span>")
user.alpha = 10
user.alpha_set(10 / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_SHADOW_THRALL)
addtimer(CALLBACK(src, PROC_REF(reveal), user), conseal_time)


/obj/effect/proc_holder/spell/shadowling_guise/proc/reveal(mob/user)
/obj/effect/proc_holder/spell/shadowling_guise/proc/reveal(mob/living/user)
if(QDELETED(user))
return

user.alpha = initial(user.alpha)
user.alpha_set(1, ALPHA_SOURCE_SHADOW_THRALL)
user.visible_message("<span class='warning'>[user] appears from nowhere!</span>", "<span class='shadowling'>Your shadowy guise slips away.</span>")


Expand Down Expand Up @@ -956,12 +956,12 @@
user.visible_message("<span class='danger'>[user] suddenly vanishes!</span>", \
"<span class='shadowling'>You begin phasing through planes of existence. Use the ability again to return.</span>")
user.incorporeal_move = INCORPOREAL_NORMAL
user.alpha = 0
user.alpha_set(0, ALPHA_SOURCE_SHADOWLING)
else
user.visible_message("<span class='danger'>[user] suddenly appears from nowhere!</span>", \
"<span class='shadowling'>You return from the space between worlds.</span>")
user.incorporeal_move = INCORPOREAL_NONE
user.alpha = 255
user.alpha_set(1, ALPHA_SOURCE_SHADOWLING)


/obj/effect/proc_holder/spell/aoe/ascendant_storm
Expand Down
8 changes: 5 additions & 3 deletions code/game/objects/items/weapons/tanks/jetpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,15 @@


/obj/item/tank/jetpack/suit/ninja/allow_thrust(num, use_fuel = TRUE)
var/mob/user = get_owner()
var/mob/living/user = get_owner()
if(!user)
return FALSE
if(!skip_trails && user.alpha == NINJA_ALPHA_INVISIBILITY)

if(!skip_trails && user.alpha_get(ALPHA_SOURCE_NINJA) == NINJA_ALPHA_INVISIBILITY / LIGHTING_PLANE_ALPHA_VISIBLE)
Anorak2024 marked this conversation as resolved.
Show resolved Hide resolved
configure_jetpack(skip_trails = TRUE)
else if(skip_trails && user.alpha != NINJA_ALPHA_INVISIBILITY)
else if(skip_trails && user.alpha_get(ALPHA_SOURCE_NINJA) != NINJA_ALPHA_INVISIBILITY / LIGHTING_PLANE_ALPHA_VISIBLE)
configure_jetpack(skip_trails = FALSE)

return ..()


Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
animate(ninja, color ="#00ff00", time = 6)
if(!stealth)
animate(ninja, alpha = NINJA_ALPHA_SPIRIT_FORM, time = 6) //Трогаем альфу - только если мы не в стелсе
ninja.alpha_set(NINJA_ALPHA_SPIRIT_FORM / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_NINJA)
Anorak2024 marked this conversation as resolved.
Show resolved Hide resolved
ninja.visible_message(span_warning("[ninja.name] looks very unstable and strange!"), span_notice("You now can pass almost through everything.")) //Если мы не в стелсе, пишем текст того, что видят другие
else
to_chat(ninja, span_notice("You now can pass almost through everything.")) // Если же невидимы - пишем только себе
Expand Down Expand Up @@ -67,6 +68,7 @@
animate(ninja, color = null, time = 6)
if(!stealth) //Не стоит трогать альфу, когда мы уже невидимы
animate(ninja, alpha = NINJA_ALPHA_NORMAL, time = 6)
ninja.alpha_set(NINJA_ALPHA_NORMAL / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_NINJA)
ninja.visible_message(span_warning("[ninja.name] becomes stable again!"), span_notice("You lose your ability to pass the corporeal...")) //Если мы не в стелсе, пишем текст того, что видят другие
else
to_chat(ninja, span_notice("You lose your ability to pass the corporeal...")) // Если же невидимы - пишем только себе
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
return
stealth = !stealth
n_shoes.silence_steps = TRUE
animate(ninja, alpha = NINJA_ALPHA_INVISIBILITY,time = 6) // Я долго думала над этим и решила, что с учётом того, что теперь любой выстрел/удар от/по ниндзя выводит его из инвиза. Можно спокойно выкрутить альфу в 0
animate(ninja, alpha = NINJA_ALPHA_INVISIBILITY, time = 6) // Я долго думала над этим и решила, что с учётом того, что теперь любой выстрел/удар от/по ниндзя выводит его из инвиза. Можно спокойно выкрутить альфу в 0
Anorak2024 marked this conversation as resolved.
Show resolved Hide resolved
ninja.alpha_set(NINJA_ALPHA_INVISIBILITY / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_NINJA)
new /obj/effect/temp_visual/dir_setting/ninja/cloak(get_turf(ninja), ninja.dir)
ninja.visible_message(span_warning("[ninja.name] расстворил[genderize_ru(ninja.gender, "ся", "ась", "ось", "ись") ] в воздухе!"), span_notice("Теперь вас невозможно увидеть невооружённым глазом. Ровно как и стандартными оптическими приборами. Нагрузка костюма начала увеличиваться..."))
ninja.AddComponent(/datum/component/ninja_states_breaker, src)
Expand Down Expand Up @@ -66,6 +67,7 @@
var/stealth_alpha
stealth_alpha = spirited ? NINJA_ALPHA_SPIRIT_FORM : NINJA_ALPHA_NORMAL
animate(ninja, alpha = stealth_alpha, time = 6)
ninja.alpha_set(stealth_alpha / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_NINJA)
new /obj/effect/temp_visual/dir_setting/ninja(get_turf(ninja), ninja.dir)
ninja.visible_message(span_warning("[ninja.name] появ[genderize_ru(ninja.gender, "ляется", "илась", "илось", "ились") ] из воздуха!"), span_notice("Теперь вас снова видно невооружённым глазом."))
qdel(ninja.GetComponent(/datum/component/ninja_states_breaker))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/antagonists/space_ninja/suit/suit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@
// Проверка во избежание потенциальных абузов инвиза
// Как например если после сканирования t-ray сканером сразу выключить инвиз...
// Что приводило к бесплатному инвизу.
if(ninja.alpha == NINJA_ALPHA_INVISIBILITY || ninja.alpha == NINJA_ALPHA_SPIRIT_FORM)
if(ninja.alpha_get(ALPHA_SOURCE_NINJA) == NINJA_ALPHA_INVISIBILITY / LIGHTING_PLANE_ALPHA_VISIBLE || ninja.alpha_get(ALPHA_SOURCE_NINJA) == NINJA_ALPHA_SPIRIT_FORM / LIGHTING_PLANE_ALPHA_VISIBLE)
if(!stealth && !spirited)
ninja.alpha = NINJA_ALPHA_NORMAL
ninja.alpha_set(NINJA_ALPHA_NORMAL / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_NINJA)
//Safe checks to prevent potential abuse of power.
if(!is_teleport_allowed(ninja.z) && spirited)
to_chat(ninja, span_warning("This place forcibly stabilizes your body somehow! You can't use \"Spirit Form\" there!"))
Expand Down
8 changes: 7 additions & 1 deletion code/modules/antagonists/vampire/vampire_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
user.dna?.species?.hunger_type = initial(user.dna.species.hunger_type)
user.dna?.species?.hunger_icon = initial(user.dna.species.hunger_icon)

animate(user, alpha = 255)
REMOVE_TRAITS_IN(user, VAMPIRE_TRAIT)


Expand Down Expand Up @@ -577,7 +576,9 @@
/datum/antagonist/vampire/proc/handle_vampire_cloak()
if(!ishuman(owner.current))
animate(owner.current, time = 5, alpha = 255)
owner.current.alpha_set(1, ALPHA_SOURCE_VAMPIRE)
return

var/turf/simulated/owner_turf = get_turf(owner.current)
var/light_available = ((iscloaking)?owner_turf.get_lumcount():owner_turf.get_lumcount(0.5)) * 10

Expand All @@ -586,16 +587,21 @@

if(!iscloaking && !is_goon_cloak || owner.current.on_fire)
animate(owner.current, time = 5, alpha = 255)
owner.current.alpha_set(1, ALPHA_SOURCE_VAMPIRE)
owner.current.remove_movespeed_modifier(/datum/movespeed_modifier/vampire_cloak)
return

if(light_available <= 2)
animate(owner.current, time = 5, alpha = 38)
owner.current.alpha_set(38 / LIGHTING_PLANE_ALPHA_VISIBLE, ALPHA_SOURCE_VAMPIRE)
if(iscloaking)
owner.current.add_movespeed_modifier(/datum/movespeed_modifier/vampire_cloak)

return

owner.current.remove_movespeed_modifier(/datum/movespeed_modifier/vampire_cloak)
animate(owner.current, time = 5, alpha = 204) // 255 * 0.80
owner.current.alpha_set(0.8, ALPHA_SOURCE_VAMPIRE)


/datum/antagonist/vampire/vv_edit_var(var_name, var_value)
Expand Down
35 changes: 35 additions & 0 deletions code/modules/mob/living/alpha.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/mob/living/proc/alpha_update()
var/result = 1
for(var/source in alphas)
result *= alphas[source]

alpha = LIGHTING_PLANE_ALPHA_VISIBLE * result

/mob/living/proc/alpha_prepare(source)
if(!(source in alphas))
alphas[source] = 1

/mob/living/proc/alpha_finalise(source)
alphas[source] = clamp(alphas[source], 0, 1)
if(alphas[source] == 1 && source != ALPHA_SOURCE_DEFAULT)
alphas.Remove(source)

alpha_update()

/mob/living/proc/alpha_add(val, source = ALPHA_SOURCE_DEFAULT)
alpha_prepare(source)
alphas[source] += val
alpha_finalise(source)

/mob/living/proc/alpha_multiply(val, source = ALPHA_SOURCE_DEFAULT)
alpha_prepare(source)
alphas[source] *= val
alpha_finalise(source)

/mob/living/proc/alpha_set(val, source = ALPHA_SOURCE_DEFAULT)
alpha_prepare(source)
alphas[source] = val
alpha_finalise(source)

/mob/living/proc/alpha_get(source = ALPHA_SOURCE_DEFAULT)
return alphas[source]
3 changes: 3 additions & 0 deletions code/modules/mob/living/living_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@

/// Famous last words -- if succumbing, what the user's last words were
var/last_words

/// List of alpha changelog from various sources
var/list/alphas = list(ALPHA_SOURCE_DEFAULT = 1)
1 change: 1 addition & 0 deletions paradise.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,7 @@
#include "code\modules\mob\dead\observer\observer_say.dm"
#include "code\modules\mob\dead\observer\orbit.dm"
#include "code\modules\mob\dead\observer\spells.dm"
#include "code\modules\mob\living\alpha.dm"
#include "code\modules\mob\living\autohiss.dm"
#include "code\modules\mob\living\damage_procs.dm"
#include "code\modules\mob\living\death.dm"
Expand Down