Files
Citadel-Station-13-RP/code/datums/components/squeak.dm
silicons 934ad25bfe refactors: inventory, mousedrag, stripping, species bodytypes, inventory HUD, and probably some unrelated things (#4092)
* start

* i hate people who pack shit into one file

* sigh

* regex

* inventory rework

* stubs

* regex

* this is insanity

* oh no

* backend moment

* a

* changes

* wild

* regexing

* changes

* put in hands

* more errorS

* attackby

* more helpers

* replacements

* wild

* fixes

* pain

* fxies

* fixes

* unneeded

* ape

* ape

* wild

* wild

* more

* wild

* there

* fixes

* fixes

* l

* wild

* more

* moer

* fixes

* enough for todayd

* regexing

* long time coming

* shaking and crying

* end me

* fixes

* fixes

* e

* fxies

* rig refactor moment

* fixes

* fixes

* fixes

* fixes

* out with the shitcode

* thanks git

* partial rig rewrite here we go

* more

* fixes

* WWWW

* ok

* wild

* bitfield defines

* nobludgeon

* pain

* pain

* fixes

* more

* wild

* wild

* fixes

* pain

* move behaviorsr

* fixes

* next up, finishing core procs

* y

* .

* time to finish this

* time to finish this

* propagate accessories

* hate this accursed engine

* hate this accursed engine

* pain

* more

* cancer

* epic

* genuinely hate

* wild

* that

* why

* circuitry is my bane

* y

* how

* sort

* logging

* logging

* im dying

* fixes

* next

* f

* more

* epic style

* fixes

* on meta

* fix

* wild

* uh

* quirky

* fixes

* agh

* pain

* fixes

* fix

* sigh

* a

* epic1

* fixes

* ugh

* epic

* fixes

* uhh.

* is this even a fix

* fix

* fixes

* fixes

* we love optimization

* wear over system

* correct

* worn over stuff

* just augments

* coggy

* implant magnetic catch

* implant magnetic catch

* fixe

* a

* g

* t

* fix

* fix

* wack!

* fix

* a

* semantics

* fix

* that

* fixes

* handle denesting

* w

* fixes

* e

* bugs

* fixes

* fixes

* unit tests

* absolutely wild

* fixes

* fix

* fix

* fixes

* on god this is bad

* fixes

* fixes

* fix

* fix

* wacky!

* fix

* wack

* manual

* fixes

* closets

* OOPS

* wack

* pain

* pain

* flags

* regex

* fixes

* wakc

* changes

* more

* augh

* more

* replaces

* more

* that

* acc

* acc

* fix

* fix

* fix

* oh woops that was important

* wack

* epic

Co-authored-by: fake_vm_user <fake_vm_user>
Co-authored-by: VM_USER <VM_USER>
2022-07-29 00:20:47 -07:00

91 lines
3.5 KiB
Plaintext

/datum/component/squeak
var/static/list/default_squeak_sounds = list('sound/items/toysqueak1.ogg'=1, 'sound/items/toysqueak2.ogg'=1, 'sound/items/toysqueak3.ogg'=1)
var/list/override_squeak_sounds
var/squeak_chance = 100
var/volume = 30
// This is so shoes don't squeak every step
var/steps = 0
var/step_delay = 1
// This is to stop squeak spam from inhand usage
var/last_use = 0
var/use_delay = 20
/datum/component/squeak/Initialize(custom_sounds, volume_override, chance_override, step_delay_override, use_delay_override)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_BLOB_ACT, COMSIG_ATOM_HULK_ATTACK, COMSIG_PARENT_ATTACKBY), .proc/play_squeak)
if(ismovable(parent))
RegisterSignal(parent, list(COMSIG_MOVABLE_BUMP, COMSIG_MOVABLE_IMPACT), .proc/play_squeak)
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/play_squeak_crossed)
RegisterSignal(parent, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react)
if(isitem(parent))
RegisterSignal(parent, list(COMSIG_ITEM_ATTACK, COMSIG_ITEM_ATTACK_OBJ, COMSIG_ITEM_HIT_REACT), .proc/play_squeak)
RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, .proc/use_squeak)
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop)
if(istype(parent, /obj/item/clothing/shoes))
RegisterSignal(parent, COMSIG_SHOES_STEP_ACTION, .proc/step_squeak)
override_squeak_sounds = custom_sounds
if(chance_override)
squeak_chance = chance_override
if(volume_override)
volume = volume_override
if(isnum(step_delay_override))
step_delay = step_delay_override
if(isnum(use_delay_override))
use_delay = use_delay_override
/datum/component/squeak/proc/play_squeak()
if(prob(squeak_chance))
if(!override_squeak_sounds)
playsound(parent, pickweight(default_squeak_sounds), volume, TRUE, -1)
else
playsound(parent, pickweight(override_squeak_sounds), volume, TRUE, -1)
/datum/component/squeak/proc/step_squeak()
if(steps > step_delay)
play_squeak()
steps = 0
else
steps++
/datum/component/squeak/proc/play_squeak_crossed(datum/source, atom/movable/AM)
if(isitem(AM))
var/obj/item/I = AM
if(I.item_flags & ITEM_ABSTRACT)
return
else if(istype(AM, /obj/item/projectile))
var/obj/item/projectile/P = AM
if(P.original != parent)
return
if(istype(AM, /obj/effect/dummy/phased_mob)) //don't squeek if they're in a phased/jaunting container.
return
var/atom/current_parent = parent
if(isturf(current_parent.loc))
play_squeak()
/datum/component/squeak/proc/use_squeak()
if(last_use + use_delay < world.time)
last_use = world.time
play_squeak()
/datum/component/squeak/proc/on_equip(datum/source, mob/equipper, slot)
RegisterSignal(equipper, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react, TRUE)
/datum/component/squeak/proc/on_drop(datum/source, mob/user)
UnregisterSignal(user, COMSIG_MOVABLE_DISPOSING)
// Disposal pipes related shit
/datum/component/squeak/proc/disposing_react(datum/source, obj/structure/disposalholder/holder, obj/machinery/disposal/source)
//We don't need to worry about unregistering this signal as it will happen for us automaticaly when the holder is qdeleted
RegisterSignal(holder, COMSIG_ATOM_DIR_CHANGE, .proc/holder_dir_change)
/datum/component/squeak/proc/holder_dir_change(datum/source, old_dir, new_dir)
//If the dir changes it means we're going through a bend in the pipes, let's pretend we bumped the wall
if(old_dir != new_dir)
play_squeak()