Skip to content

Commit

Permalink
Fix veil of shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit committed Sep 30, 2023
1 parent 7d4a2e7 commit acb0315
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions code/modules/spells/general/veil_of_shadows.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "Veil of Shadows"
desc = "Become intangable, invisible. Like a ghost."
charge_max = 400
spell_flags = NEEDSCLOTHES | Z2NOCAST
invocation_type = INVOKE_EMOTE
invocation = "flickers out of existance"
spell_flags = 0
Expand All @@ -14,18 +15,23 @@
spell_cost = 3
mana_cost = 20

/datum/spell/veil_of_shadows/cast_check(skipcharge = FALSE, mob/user = usr, list/targets)
if(!ishuman(user))
return FALSE
if(user.GetMovementHandler(/datum/movement_handler/mob/incorporeal))
return FALSE
return ..()

/datum/spell/veil_of_shadows/choose_targets(mob/user = usr)
if(!timer_id && istype(holder, /mob/living/carbon/human))
perform(user, list(holder))
perform(user, null)

/datum/spell/veil_of_shadows/cast(list/targets, mob/user)
var/mob/living/carbon/human/H = user
H.AddMovementHandler(/datum/movement_handler/mob/incorporeal)
if(H.add_cloaking_source(src))
H.visible_message("<span class='warning'>\The [H] shrinks from view!</span>")
GLOB.moved_event.register(H,src,.proc/check_light)
timer_id = addtimer(CALLBACK(src,.proc/cancel_veil),duration, TIMER_STOPPABLE)
GLOB.moved_event.register(H, src,.proc/check_light)
timer_id = addtimer(CALLBACK(src, .proc/cancel_veil), duration, TIMER_STOPPABLE)

/datum/spell/veil_of_shadows/proc/cancel_veil()
var/mob/living/carbon/human/H = holder
Expand All @@ -36,8 +42,8 @@
if(T.get_lumcount() > 0.1) //If we're somewhere somewhat shadowy we can stay invis as long as we stand still
drop_cloak()
else
GLOB.moved_event.unregister(H,src)
GLOB.moved_event.register(H,src,.proc/drop_cloak)
GLOB.moved_event.unregister(H, src)
GLOB.moved_event.register(H, src, .proc/drop_cloak)

/datum/spell/veil_of_shadows/proc/drop_cloak()
var/mob/living/carbon/human/H = holder
Expand All @@ -56,4 +62,4 @@
/datum/spell/veil_of_shadows/Destroy()
deltimer(timer_id)
cancel_veil()
.= ..()
return ..()

0 comments on commit acb0315

Please sign in to comment.