Fixes Shadow Walk (#77518)

## About The Pull Request

Phased mobs are not turfs so the new check failed.

Fixes this and adds a unit test for it.

Also makes shadow walk VV-able to any level of lightness.

## Changelog

🆑 Melbert
fix: Fixes Shadow Walk
/🆑
This commit is contained in:
MrMelbert
2023-08-11 21:44:31 -05:00
committed by GitHub
parent 9b64dba625
commit b83f115501
4 changed files with 43 additions and 6 deletions

View File

@@ -19,6 +19,12 @@
/// What dummy mob type do we put jaunters in on jaunt?
var/jaunt_type = /obj/effect/dummy/phased_mob
/datum/action/cooldown/spell/jaunt/get_caster_from_target(atom/target)
if(istype(target.loc, jaunt_type))
return target
return ..()
/datum/action/cooldown/spell/jaunt/before_cast(atom/cast_on)
return ..() | SPELL_NO_FEEDBACK // Don't do the feedback until after we're jaunting

View File

@@ -9,6 +9,9 @@
spell_requirements = NONE
jaunt_type = /obj/effect/dummy/phased_mob/shadow
/// The max amount of lumens on a turf allowed before we can no longer enter jaunt with this
var/light_threshold = SHADOW_SPECIES_LIGHT_THRESHOLD
/datum/action/cooldown/spell/jaunt/shadow_walk/Grant(mob/grant_to)
. = ..()
RegisterSignal(grant_to, COMSIG_MOVABLE_MOVED, PROC_REF(update_status_on_signal))
@@ -17,6 +20,12 @@
. = ..()
UnregisterSignal(remove_from, COMSIG_MOVABLE_MOVED)
/datum/action/cooldown/spell/jaunt/shadow_walk/enter_jaunt(mob/living/jaunter, turf/loc_override)
var/obj/effect/dummy/phased_mob/shadow/shadow = ..()
if(istype(shadow))
shadow.light_max = light_threshold
return shadow
/datum/action/cooldown/spell/jaunt/shadow_walk/can_cast_spell(feedback = TRUE)
. = ..()
if(!.)
@@ -24,7 +33,7 @@
if(is_jaunting(owner))
return TRUE
var/turf/cast_turf = get_turf(owner)
if(cast_turf.get_lumcount() >= SHADOW_SPECIES_LIGHT_THRESHOLD)
if(cast_turf.get_lumcount() >= light_threshold)
if(feedback)
to_chat(owner, span_warning("It isn't dark enough here!"))
return FALSE
@@ -44,6 +53,8 @@
/obj/effect/dummy/phased_mob/shadow
name = "shadows"
/// Max amount of light permitted before being kicked out
var/light_max = SHADOW_SPECIES_LIGHT_THRESHOLD
/// The amount that shadow heals us per SSobj tick (times seconds_per_tick)
var/healing_rate = 1.5
/// When cooldown is active, you are prevented from moving into tiles that would eject you from your jaunt
@@ -109,11 +120,9 @@
* * location_to_check - The location to have its light level checked.
*/
/obj/effect/dummy/phased_mob/shadow/proc/check_light_level(location_to_check)
var/turf/T = get_turf(location_to_check)
var/light_amount = T.get_lumcount()
if(light_amount > 0.2) // jaunt ends
return TRUE
/obj/effect/dummy/phased_mob/shadow/proc/check_light_level(atom/location_to_check)
var/turf/light_turf = get_turf(location_to_check)
return light_turf.get_lumcount() > light_max // jaunt ends on TRUE
/**
* Checks if the user should recieve a warning that they're moving into light.

View File

@@ -229,6 +229,7 @@
#include "species_unique_id.dm"
#include "species_whitelists.dm"
#include "spell_invocations.dm"
#include "spell_jaunt.dm"
#include "spell_mindswap.dm"
#include "spell_names.dm"
#include "spell_shapeshift.dm"

View File

@@ -0,0 +1,21 @@
/// Tests Shadow Walk can be entered and exited
/datum/unit_test/shadow_jaunt
/datum/unit_test/shadow_jaunt/Run()
var/mob/living/carbon/human/jaunter = allocate(/mob/living/carbon/human/consistent)
var/datum/action/cooldown/spell/jaunt/shadow_walk/walk = allocate(/datum/action/cooldown/spell/jaunt/shadow_walk, jaunter)
walk.Grant(jaunter)
var/turf/jaunt_turf = jaunter.loc
TEST_ASSERT(istype(jaunt_turf), "Jaunter was not allocated to a turf, instead to [jaunt_turf || "nullspace"].")
TEST_ASSERT(walk.IsAvailable(), "Unit test room is not suitable to test [walk].")
walk.Trigger()
TEST_ASSERT_NOTEQUAL(jaunter.loc, jaunt_turf, "Jaunter's loc did not change on casting [walk].")
TEST_ASSERT(istype(jaunter.loc, walk.jaunt_type), "Jaunter failed to enter jaunt on casting [walk].")
walk.next_use_time = -1
walk.Trigger()
TEST_ASSERT_EQUAL(jaunter.loc, jaunt_turf, "Jaunter failed to exit jaunt on exiting [walk].")