Files
Paradise/code/datums/components/squish.dm
Luc b33d6aa080 Tipping vending machines for freebies and/or crushes (#20060)
* Initial commit

* Add RNG tip behavior, including free items.

* Add some additional checks

* Small cleanups

* Add squishing, drop normal damage to 40

* Haha, unless? (this is how it is on tg)

* Datumizes vendor tips, part one

* Datumizing, part 2

* Remove unused

* Remove old "key" var

* Fix .proc call

* double dwarf damage

* Update code/game/machinery/vendors/vending.dm

Thanks, sean

Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>

* Add a warning hit

* squish component review

* update visible message

* remove extra defines

* charlie review

* Add explosion tilts, some slight cleanups

* Review changes
- Tweaks self knockover damage slightly to not be the same as crit damage
- farie's reviews

* Unindent, clean up crit logic

* Refactor some code out of main vendor proc
also re-adds the head-popping crit lol

* making linter happy :)

* Removes global list in favor of static one

---------

Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
2023-03-04 09:22:07 +01:00

44 lines
1.4 KiB
Plaintext

#define SHORT_SCALE (5/7)
#define TALL_SCALE (7/5)
/**
* squish.dm
*
* It's an element that squishes things. After the duration passes, it reverses the transformation it squished with, taking into account if they are a different orientation than they started (read: rotationally-fluid)
*
* Normal squishes apply vertically, as if the target is being squished from above, but you can set reverse to TRUE if you want to squish them from the sides, like if they pancake into a wall from the East or West
*/
/datum/element/squish
element_flags = ELEMENT_DETACH
/datum/element/squish/Attach(datum/target, duration = 20 SECONDS, reverse = FALSE)
. = ..()
if(!iscarbon(target))
return ELEMENT_INCOMPATIBLE
var/mob/living/carbon/C = target
var/was_lying = C.body_position == LYING_DOWN
addtimer(CALLBACK(src, PROC_REF(Detach), C, was_lying, reverse), duration)
if(reverse)
C.transform = C.transform.Scale(SHORT_SCALE, TALL_SCALE)
else
C.transform = C.transform.Scale(TALL_SCALE, SHORT_SCALE)
/datum/element/squish/Detach(mob/living/carbon/C, was_lying, reverse)
. = ..()
if(!istype(C))
return
var/is_lying = C.body_position == LYING_DOWN
if(reverse)
is_lying = !is_lying
if(was_lying == is_lying)
C.transform = C.transform.Scale(SHORT_SCALE, TALL_SCALE)
else
C.transform = C.transform.Scale(TALL_SCALE, SHORT_SCALE)
#undef SHORT_SCALE
#undef TALL_SCALE