Files
Paradise/code/modules/hallucinations/effects/common.dm
T
Charlie 0f7a8707ef [Ready] Refactors stuns and status effects. (#17579)
* Fixes reviver runtime

* Confusion status effect

* Dizzy status effect

* Drowsiness status effect

* decaying -> transient

* Drunkenness status effect

* why use timer when SSfastprocessing work good

* stuns (mostly)

* weaken and immobalise

* stun/weaken times

* update_flags redundancies.

* Slowed()

* Silence + fixes transient decay

* Jittery

* sleeping

* Paralyze -> weaken

* Cult sluring

* paralyse

* Stammer

* slurring + projectile cleanups

* losebreath

* Hallucination

* forgor this

* eyeblurry

* eye blind

* Druggy

* affected didn't like my spacing

* review pass

* second review pass

* some cleanups

* documentation and signal framework

* confusion fix

* Fixes spec_stun

* rejuv fix

* removes a TODO

* conflicted myself

* fixes

* self review

* review

* removes TODOs

* adminfreeze

* TM fixes

* hallucination fix + others

* tones down alchol and runtime fixes

* confusion overlay suggestion

* more fixes

* runtime fix

* losebreath fix

* clamp => directional bounded sum

* steel review

* oops

Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>

* reduces the dizziness cycle rate

* borg hotfix

* sanctified decursening

Co-authored-by: mochi <1496804+dearmochi@users.noreply.github.com>
Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
2022-05-24 16:35:26 +01:00

133 lines
3.7 KiB
Plaintext

/**
* # Hallucination - Tripper
*
* A generic hallucination that causes the target to trip if they cross it.
*/
/obj/effect/hallucination/tripper
anchored = TRUE
/// Chance to trip when crossing.
var/trip_chance = 100
/// Stun to add when crossed.
var/stun = 4 SECONDS
/// Weaken to add when crossed.
var/weaken = 4 SECONDS
/obj/effect/hallucination/tripper/CanPass(atom/movable/mover, turf/T)
. = TRUE
if(isliving(mover) && mover == target)
var/mob/living/M = mover
if(M.lying || !prob(trip_chance))
return
M.Weaken(weaken)
on_crossed()
/**
* Called when the target crosses this hallucination.
*/
/obj/effect/hallucination/tripper/proc/on_crossed()
return
/**
* # Hallucination - Chaser
*
* A generic hallucination that chases the target.
*/
/obj/effect/hallucination/chaser
hallucination_icon = 'icons/mob/monkey.dmi'
hallucination_icon_state = "monkey1"
hallucination_override = TRUE
// Settings
// Minimum distance required between the target and us to keep chasing them.
var/min_distance = 1
/// Interval between two thinks in deciseconds. Shouldn't be too low to prevent lag.
var/think_interval = 1 SECONDS
// Variables
/// Think timer handle.
var/think_timer = null
/obj/effect/hallucination/chaser/Initialize(mapload, mob/living/carbon/target)
. = ..()
name = "\proper monkey ([rand(100, 999)])"
think_timer = addtimer(CALLBACK(src, .proc/think), think_interval, TIMER_LOOP | TIMER_STOPPABLE)
/obj/effect/hallucination/chaser/Destroy()
deltimer(think_timer)
return ..()
/**
* Called at regular intervals to determine what to do.
*/
/obj/effect/hallucination/chaser/proc/think()
if(QDELETED(src))
return
else if(QDELETED(target))
qdel(src)
return
if(get_dist(src, target) > min_distance)
chase()
else
within_range()
/**
* Called every Think when we are not close enough to the target.
*/
/obj/effect/hallucination/chaser/proc/chase()
step_towards(src, target)
/**
* Called every Think when we are close enough to the target.
*/
/obj/effect/hallucination/chaser/proc/within_range()
return
/**
* # Hallucination - Attacker
*
* A generic hallucination based on the Chaser that attacks if close enough.
*/
/obj/effect/hallucination/chaser/attacker
/// Chance to attack per Think spent in range.
var/attack_chance = 100
/// Stamina damage to heal on hit.
var/damage = 25
/// Whether to attack if the target is knocked down.
var/should_attack_weakened = FALSE
/obj/effect/hallucination/chaser/attacker/within_range()
if(!prob(attack_chance))
return
var/was_weakened = target.IsWeakened()
if(was_weakened && !should_attack_weakened)
return
attack(was_weakened)
/**
* Called every Think when we are attacking the target.
*
* Arguments:
* * was_weakened - Whether the target was already knocked down prior to this attack.
*/
/obj/effect/hallucination/chaser/attacker/proc/attack(was_weakened)
dir = get_dir(src, target)
attack_effects()
target.adjustStaminaLoss(damage)
if(!was_weakened && target.IsWeakened())
on_knockdown()
/**
* Called to handle the visual and audio effects of an attack.
*/
/obj/effect/hallucination/chaser/attacker/proc/attack_effects()
do_attack_animation(target, ATTACK_EFFECT_PUNCH)
target.playsound_local(get_turf(src), get_sfx("punch"), 25, TRUE)
to_chat(target, "<span class='userdanger'>[name] has punched [target]!</span>")
/**
* Called when one of our attacks put the target in stamina crit.
*/
/obj/effect/hallucination/chaser/attacker/proc/on_knockdown()
target.visible_message("<span class='warning'>[target] recoils as if hit by something, before suddenly collapsing!</span>",
"<span class='userdanger'>[src]'s blow was too much for you, causing you to collapse!</span>")