(Hopefully) Fixes the runtime where a hallucination tries to pick from an empty list (#24276)

* This was an RNG PITA to test

* Also does energy sword
This commit is contained in:
DGamerL
2024-02-24 18:25:24 +00:00
committed by GitHub
parent b3bec16c2c
commit a44f9ca128
2 changed files with 10 additions and 19 deletions
@@ -344,11 +344,7 @@
/obj/effect/hallucination/stunprodding/Initialize(mapload, mob/living/carbon/target)
. = ..()
var/list/turfs = list()
for(var/turf/T in range(world.view, target))
turfs += T
var/turf/T = pick(turfs)
var/turf/T = pick(RANGE_TURFS(15, target))
target.playsound_local(T, 'sound/weapons/egloves.ogg', 25, TRUE)
target.playsound_local(T, get_sfx("bodyfall"), 25, TRUE)
target.playsound_local(T, "sparks", 50, TRUE)
@@ -370,12 +366,8 @@
/obj/effect/hallucination/energy_sword/Initialize(mapload, mob/living/carbon/target)
. = ..()
var/list/turfs = list()
for(var/turf/T in range(world.view, target))
turfs += T
var/turf/T = pick(turfs)
loc = T
var/turf/T = pick(RANGE_TURFS(15, target))
forceMove(T)
target.playsound_local(T, 'sound/weapons/saberon.ogg', 20, TRUE)
var/scream_sound = pick('sound/goonstation/voice/female_scream.ogg', 'sound/goonstation/voice/male_scream.ogg')
@@ -406,12 +398,8 @@
/obj/effect/hallucination/gunfire/Initialize(mapload, mob/living/carbon/target)
. = ..()
var/list/turfs = list()
for(var/turf/T in range(world.view, target))
turfs += T
var/turf/T = pick(turfs)
loc = T
var/turf/T = pick(RANGE_TURFS(15, target))
forceMove(T)
var/gun_sound = pick('sound/weapons/gunshots/gunshot_pistol.ogg', 'sound/weapons/gunshots/gunshot_strong.ogg')
var/scream_sound = pick('sound/goonstation/voice/female_scream.ogg', 'sound/goonstation/voice/male_scream.ogg')
@@ -52,9 +52,12 @@ GLOBAL_LIST_INIT(hallucinations, list(
/// Lazy list of images created as part of the hallucination. Cleared on destruction.
var/list/image/images = null
/obj/effect/hallucination/Initialize(mapload, mob/living/carbon/target)
/obj/effect/hallucination/Initialize(mapload, mob/living/carbon/hallucination_target)
. = ..()
src.target = target
if(QDELETED(hallucination_target))
qdel(src)
return
target = hallucination_target
if(hallucination_icon && hallucination_icon_state)
var/image/I = image(hallucination_icon, hallucination_override ? src : get_turf(src), hallucination_icon_state)
I.override = hallucination_override