Skip to content

Commit

Permalink
Makes the xeno pounce a manager. Also enables it again (#27656)
Browse files Browse the repository at this point in the history
* Rewrites xeno pounce

* Not yet

* Adds it to the list

* Autodoc
  • Loading branch information
DGamerL authored Jan 6, 2025
1 parent 7b91294 commit 5cd21a0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 79 deletions.
79 changes: 0 additions & 79 deletions code/modules/hallucinations/effects/major.dm
Original file line number Diff line number Diff line change
Expand Up @@ -329,82 +329,3 @@
target.visible_message("<span class='warning'>[target] recoils as if hit by something, before suddenly collapsing!</span>",
"<span class='userdanger'>[name] has [attack_verb] [target]!</span>")
QDEL_IN(src, 3 SECONDS)

/**
* # Hallucination - Xeno Pounce
*
* An imaginary alien hunter pounces towards the target.
*/
/obj/effect/hallucination/xeno_pounce
duration = 15 SECONDS
// Settings
/// Maximum number of times the alien will pounce.
var/num_pounces = 3
/// How often to pounce in deciseconds.
var/pounce_interval = 5 SECONDS
// Variables
/// The xeno hallucination reference.
var/obj/effect/hallucination/xeno_pouncer/xeno = null

/obj/effect/hallucination/xeno_pounce/Initialize(mapload, mob/living/carbon/target)
. = ..()

// Find a vent around us
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/vent in range(world.view / 2, target))
vents += vent
if(!length(vents))
return

var/turf/T = get_turf(pick(vents))
xeno = new(T, target)
xeno.dir = get_dir(T, target)
addtimer(CALLBACK(src, PROC_REF(do_pounce)), pounce_interval)

/obj/effect/hallucination/xeno_pounce/proc/do_pounce()
if(QDELETED(xeno) || QDELETED(target))
return

xeno.leap_to(target)
if(--num_pounces > 0)
addtimer(CALLBACK(src, PROC_REF(do_pounce)), pounce_interval)

/obj/effect/hallucination/xeno_pouncer
hallucination_icon = 'icons/mob/alien.dmi'
hallucination_icon_state = "alienh_pounce"
hallucination_override = TRUE

/obj/effect/hallucination/xeno_pouncer/Initialize(mapload, mob/living/carbon/target)
. = ..()
name = "\proper alien hunter ([rand(100, 999)])"

/obj/effect/hallucination/xeno_pouncer/throw_impact(A)
if(A == target)
forceMove(get_turf(target))
target.Weaken(10 SECONDS)
target.visible_message("<span class='danger'>[target] recoils backwards and falls flat!</span>",
"<span class='userdanger'>[name] pounces on you!</span>")

to_chat(target, "<span class='notice'>[name] begins climbing into the ventilation system...</span>")
QDEL_IN(src, 2 SECONDS)

/**
* Throws the xeno towards the given loc.
*
* Arguments:
* * dest - The loc to leap to.
*/
/obj/effect/hallucination/xeno_pouncer/proc/leap_to(dest)
if(images && images[1])
images[1].icon = 'icons/mob/alienleap.dmi'
images[1].icon_state = "alienh_leap"
dir = get_dir(get_turf(src), dest)
throw_at(dest, 7, 1, spin = FALSE, diagonals_first = TRUE, callback = CALLBACK(src, PROC_REF(reset_icon)))

/**
* Resets the xeno's icon to a resting state.
*/
/obj/effect/hallucination/xeno_pouncer/proc/reset_icon()
if(images && images[1])
images[1].icon = 'icons/mob/alien.dmi'
images[1].icon_state = "alienh_pounce"
90 changes: 90 additions & 0 deletions code/modules/hallucinations/effects/xeno_pounce.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* # Hallucination - Xeno Pounce
*
* An imaginary alien hunter pounces towards the target.
*/
/datum/hallucination_manager/xeno_pounce
trigger_time = 5 SECONDS
initial_hallucination = /obj/effect/hallucination/no_delete/xeno_pouncer
/// Typecasted reference to the xeno pouncer
var/obj/effect/hallucination/no_delete/xeno_pouncer/xeno

/datum/hallucination_manager/xeno_pounce/get_spawn_location()
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/vent in range(world.view / 2, owner))
vents += vent
if(!length(vents))
qdel(src)
return

return get_turf(pick(vents))

/datum/hallucination_manager/xeno_pounce/on_spawn()
initial_hallucination.dir = get_dir(initial_hallucination, owner)
xeno = initial_hallucination

/datum/hallucination_manager/xeno_pounce/on_trigger()
if(QDELETED(xeno) || QDELETED(owner))
qdel(src)
return

xeno.leap_to(owner)
trigger_timer = addtimer(CALLBACK(src, PROC_REF(on_second_trigger)), trigger_time, TIMER_DELETE_ME)

/datum/hallucination_manager/xeno_pounce/proc/on_second_trigger()
if(QDELETED(xeno) || QDELETED(owner))
qdel(src)
return

xeno.leap_to(owner)
trigger_timer = addtimer(CALLBACK(src, PROC_REF(on_last_trigger)), trigger_time, TIMER_DELETE_ME)

/datum/hallucination_manager/xeno_pounce/proc/on_last_trigger()
if(QDELETED(xeno) || QDELETED(owner))
qdel(src)
return

xeno.leap_to(owner)
qdel(src)

// MARK: The xeno pouncer hallucination

/obj/effect/hallucination/no_delete/xeno_pouncer
hallucination_icon = 'icons/mob/alien.dmi'
hallucination_icon_state = "alienh_pounce"
hallucination_override = TRUE

/obj/effect/hallucination/no_delete/xeno_pouncer/Initialize(mapload, mob/living/carbon/target)
. = ..()
name = "\proper alien hunter ([rand(100, 999)])"

/obj/effect/hallucination/no_delete/xeno_pouncer/throw_impact(A)
if(A == target)
forceMove(get_turf(target))
target.Weaken(10 SECONDS)
target.visible_message("<span class='danger'>[target] recoils backwards and falls flat!</span>",
"<span class='userdanger'>[name] pounces on you!</span>")

to_chat(target, "<span class='notice'>[name] begins climbing into the ventilation system...</span>")
QDEL_IN(src, 2 SECONDS)

/**
* Throws the xeno towards the given loc.
*
* Arguments:
* * dest - The loc to leap to.
*/
/obj/effect/hallucination/no_delete/xeno_pouncer/proc/leap_to(dest)
if(images && images[1])
images[1].icon = 'icons/mob/alienleap.dmi'
images[1].icon_state = "alienh_leap"
dir = get_dir(get_turf(src), dest)
throw_at(dest, 7, 1, spin = FALSE, diagonals_first = TRUE, callback = CALLBACK(src, PROC_REF(reset_icon)))

/**
* Resets the xeno's icon to a resting state.
*/
/obj/effect/hallucination/no_delete/xeno_pouncer/proc/reset_icon()
if(images && images[1])
images[1].icon = 'icons/mob/alien.dmi'
images[1].icon_state = "alienh_pounce"
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,
/datum/hallucination_manager/xeno_pounce = 10
)
))

Expand Down
1 change: 1 addition & 0 deletions paradise.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@
#include "code\modules\hallucinations\effects\major.dm"
#include "code\modules\hallucinations\effects\minor.dm"
#include "code\modules\hallucinations\effects\moderate.dm"
#include "code\modules\hallucinations\effects\xeno_pounce.dm"
#include "code\modules\holiday\christmas.dm"
#include "code\modules\holiday\holiday.dm"
#include "code\modules\hydroponics\biogenerator.dm"
Expand Down

0 comments on commit 5cd21a0

Please sign in to comment.