Skip to content

Commit

Permalink
[PTBF] Adds blob hallucinations in dark areas
Browse files Browse the repository at this point in the history
This hallucination looks for dark, unobstructed tiles within view of the
hallucinating target, and gradually expands a blob from one of those
tiles. It also spawns a blob zombie nearby. If the blob zombie knocks
the target down, the target will hallucinate becoming a blob zombie.
  • Loading branch information
asciodev committed Dec 22, 2024
1 parent 5c549ad commit 30e37b4
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
122 changes: 122 additions & 0 deletions code/modules/hallucinations/effects/major.dm
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,125 @@
if(images && images[1])
images[1].icon = 'icons/mob/alien.dmi'
images[1].icon_state = "alienh_pounce"

/obj/effect/hallucination/blob
duration = 30 SECONDS
/// The blob zombie hallucination.
var/obj/effect/hallucination/chaser/attacker/blob_zombie/zombie = null
/// The self delusion blob zombie hallucination, triggers on knockdown.
var/obj/effect/hallucination/blob_zombify/player_zombie = null
/// List of turfs that need expanding from.
var/list/turf/expand_queue = list()
/// Associative list of turfs that have already been processed.
var/list/turf/processed = list()
/// The delay at which the blob expands in deciseconds. Shouldn't be too low to prevent lag.
var/expand_delay = 7.5 SECONDS // Expand 6 times
/// Expand timer handle.
var/expand_timer = null

/obj/effect/hallucination/blob/Initialize(mapload, mob/living/carbon/target)
. = ..()
var/list/locs = list()
for(var/turf/T in oview(world.view / 2, target))
var/light_amount = min(1, T.get_lumcount()) - 0.5
if(!is_blocked_turf(T) && light_amount <= 0)
locs += T
if(!length(locs))
qdel(src)
return
var/turf/T = get_turf(pick(locs))
var/turf/Z = get_turf(pick(locs))
color = pick( COLOR_BLACK, COLOR_RIPPING_TENDRILS, COLOR_BOILING_OIL, COLOR_ENVENOMED_FILAMENTS, COLOR_LEXORIN_JELLY,
COLOR_KINETIC_GELATIN, COLOR_CRYOGENIC_LIQUID, COLOR_SORIUM, COLOR_TESLIUM_PASTE )
create_blob(T)
create_zombie(Z)
expand_queue += T
processed[T] = TRUE
expand_timer = addtimer(CALLBACK(src, PROC_REF(expand)), expand_delay, TIMER_LOOP | TIMER_STOPPABLE)

/obj/effect/hallucination/blob/Destroy()
deltimer(expand_timer)
QDEL_NULL(expand_queue)
QDEL_NULL(processed)
QDEL_NULL(zombie)
QDEL_NULL(player_zombie)
return ..()

/**
* Called regularly in a timer to process the blob expanding.
*/
/obj/effect/hallucination/blob/proc/expand()
// Brace for potentially expensive proc
for(var/t in expand_queue)
var/turf/source_turf = t
expand_queue -= source_turf
//Expand to each dir
for(var/direction in GLOB.cardinal)
var/turf/target_turf = get_step(source_turf, direction)
if(processed[target_turf] || !source_turf.CanAtmosPass(direction) || !target_turf.CanAtmosPass(turn(direction, 180)))
continue
create_blob(target_turf)
expand_queue += target_turf
processed[target_turf] = TRUE

/**
* Creates a fake blob overlay on the given turf.
*
* Arguments:
* * T - The turf to create a fake plasma overlay on.
*/
/obj/effect/hallucination/blob/proc/create_blob(turf/T)
var/image/I = image('icons/mob/blob.dmi', T, "blob", layer = FLY_LAYER)
I.plane = GAME_PLANE
I.color = color
add_icon(I)

/obj/effect/hallucination/blob/proc/create_zombie(turf/T)
zombie = new(T, target)
zombie.owning_hallucination = src

/obj/effect/hallucination/blob/proc/zombify(turf/T)
player_zombie = new(T, target, color)

/obj/effect/hallucination/chaser/attacker/blob_zombie
hallucination_icon = 'icons/mob/human.dmi'
hallucination_icon_state = "zombie2_s"
duration = 45 SECONDS
damage = 25
/// The hallucination that spawned us.
var/obj/effect/hallucination/blob/owning_hallucination = null
/// The color of the blob hallucination that spawned us.
var/blob_color = null

/obj/effect/hallucination/chaser/attacker/blob_zombie/Initialize(mapload, mob/living/carbon/target, color = COLOR_BLACK)
. = ..()
name = "blob zombie"
var/image/I = image('icons/mob/blob.dmi', icon_state = "blob_head")
blob_color = color
I.color = color
overlays += I

/obj/effect/hallucination/chaser/attacker/blob_zombie/attack_effects()
do_attack_animation(target)
target.playsound_local(get_turf(src), 'sound/weapons/genhit1.ogg', 50, TRUE)
to_chat(target, "<span class='userdanger'>[name] has hit [target]!</span>")

/obj/effect/hallucination/chaser/attacker/blob_zombie/on_knockdown()
if(!QDELETED(owning_hallucination))
target.visible_message("<span class='warning'>[target] recoils as if hit by something, before suddenly collapsing!</span>",
"<span class='warning'>The corpse of [target.name] suddenly rises!</span>")
owning_hallucination.zombify(target)
else
qdel(src)

/obj/effect/hallucination/blob_zombify
duration = 20 SECONDS

/obj/effect/hallucination/blob_zombify/Initialize(mapload, mob/living/carbon/target, blob_color)
. = ..()
var/image/I = image('icons/mob/human.dmi', target, "zombie2_s")
I.override = TRUE
add_icon(I)
var/image/J = image('icons/mob/blob.dmi', icon_state = "blob_head")
J.color = blob_color
overlays += J
1 change: 1 addition & 0 deletions code/modules/hallucinations/hallucinations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ GLOBAL_LIST_INIT(hallucinations, list(
/obj/effect/hallucination/assault = 10,
/obj/effect/hallucination/terror_infestation = 10,
/obj/effect/hallucination/loose_energy_ball = 10,
/obj/effect/hallucination/blob = 10,
)
))

Expand Down

0 comments on commit 30e37b4

Please sign in to comment.