Merge pull request #13055 from Citadel-Station-13/silicons-patch-78
squeaking objects including air horns and clockwork boots now have a default 1 second cooldown. squeaking objects crossing each other will on average only allow 3 squeaks to occur, because if byond is literally running out of sound channels you know the fun has went too far
This commit is contained in:
@@ -11,6 +11,13 @@
|
||||
// This is to stop squeak spam from inhand usage
|
||||
var/last_use = 0
|
||||
var/use_delay = 20
|
||||
|
||||
// squeak cooldowns
|
||||
var/last_squeak = 0
|
||||
var/squeak_delay = 5
|
||||
|
||||
/// chance we'll be stopped from squeaking by cooldown when something crossing us squeaks
|
||||
var/cross_squeak_delay_chance = 33 // about 3 things can squeak at a time
|
||||
|
||||
/datum/component/squeak/Initialize(custom_sounds, volume_override, chance_override, step_delay_override, use_delay_override)
|
||||
if(!isatom(parent))
|
||||
@@ -19,6 +26,7 @@
|
||||
if(ismovable(parent))
|
||||
RegisterSignal(parent, list(COMSIG_MOVABLE_BUMP, COMSIG_MOVABLE_IMPACT), .proc/play_squeak)
|
||||
RegisterSignal(parent, list(COMSIG_MOVABLE_CROSSED, COMSIG_ITEM_WEARERCROSSED), .proc/play_squeak_crossed)
|
||||
RegisterSignal(parent, COMSIG_CROSS_SQUEAKED, .proc/delay_squeak)
|
||||
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)
|
||||
@@ -39,20 +47,28 @@
|
||||
use_delay = use_delay_override
|
||||
|
||||
/datum/component/squeak/proc/play_squeak()
|
||||
do_play_squeak()
|
||||
|
||||
/datum/component/squeak/proc/do_play_squeak(bypass_cooldown = FALSE)
|
||||
if(!bypass_cooldown && ((last_squeak + squeak_delay) >= world.time))
|
||||
return FALSE
|
||||
if(prob(squeak_chance))
|
||||
if(!override_squeak_sounds)
|
||||
playsound(parent, pickweight(default_squeak_sounds), volume, 1, -1)
|
||||
else
|
||||
playsound(parent, pickweight(override_squeak_sounds), volume, 1, -1)
|
||||
last_squeak = world.time
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/datum/component/squeak/proc/step_squeak()
|
||||
if(steps > step_delay)
|
||||
play_squeak()
|
||||
do_play_squeak(TRUE)
|
||||
steps = 0
|
||||
else
|
||||
steps++
|
||||
|
||||
/datum/component/squeak/proc/play_squeak_crossed(atom/movable/AM)
|
||||
/datum/component/squeak/proc/play_squeak_crossed(datum/source, atom/movable/AM)
|
||||
if(isitem(AM))
|
||||
var/obj/item/I = AM
|
||||
if(I.item_flags & ABSTRACT)
|
||||
@@ -63,13 +79,18 @@
|
||||
return
|
||||
var/atom/current_parent = parent
|
||||
if(isturf(current_parent.loc))
|
||||
play_squeak()
|
||||
if(do_play_squeak())
|
||||
SEND_SIGNAL(AM, COMSIG_CROSS_SQUEAKED)
|
||||
|
||||
/datum/component/squeak/proc/use_squeak()
|
||||
if(last_use + use_delay < world.time)
|
||||
last_use = world.time
|
||||
play_squeak()
|
||||
|
||||
/datum/component/squeak/proc/delay_squeak()
|
||||
if(prob(cross_squeak_delay_chance))
|
||||
last_squeak = world.time
|
||||
|
||||
/datum/component/squeak/proc/on_equip(datum/source, mob/equipper, slot)
|
||||
RegisterSignal(equipper, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react, TRUE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user