Files
Paradise/code/modules/hallucinations/effects/common.dm
warriorstar-orion 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00: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.mobility_flags & MOBILITY_MOVE) || !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_REF(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__legacy__attackchain(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__legacy__attackchain(was_weakened)
dir = get_dir(src, target)
attack_effects()
target.apply_damage(damage, STAMINA)
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>")