Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Gloves of Silence #7913

Merged
merged 14 commits into from Sep 11, 2021
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Expand Up @@ -299,3 +299,8 @@
#define COMSIG_SHOW_RADIUS "show_radius"
/// send this signal to remove /datum/component/vis_radius to a mobs: ()
#define COMSIG_HIDE_RADIUS "hide_radius"

// send this signal to stop suppressing in /datum/component/silence: ()
#define COMSIG_START_SUPPRESSING "start_suppressing"
// send this signal to stop suppressing in /datum/component/silence: ()
#define COMSIG_STOP_SUPPRESSING "stop_suppressing"
68 changes: 68 additions & 0 deletions code/datums/components/silence.dm
@@ -0,0 +1,68 @@
// A component you put on things you want to generate silence of sound suppresion around things.
/datum/component/silence
var/obj/effect/overlay/radius_obj
var/coeff = 0.0
var/vis_radius
var/list/old_locs = list()
var/enabled = FALSE

/datum/component/silence/Initialize(_dist, _coeff)
var/atom/movable/AM = parent
if (isnull(AM.loc))
return COMPONENT_NOT_ATTACHED
var/bound_width = AM.bound_width + world.icon_size * 2 * _dist
var/bound_height = AM.bound_height + world.icon_size * 2 * _dist
Comment on lines +13 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему world.icon_size * 2 * _dist тут умножение на 2 по дефолту? Если указать радиус > 1, то у тебя в итоге будет криво значение.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут радиус - это именно размер увеличения границы, а не сам радиус
вот кукла у нас 1х1, радиус 1 = 3х3
есть абстрактный объект 2х1, радиус тишины вокруг 1 = 4х3

var/bound_x = AM.bound_x + world.icon_size * -1 * _dist
var/bound_y = AM.bound_y + world.icon_size * -1 * _dist
coeff = _coeff

radius_obj = new(get_turf(AM))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думаю, эту фичу с радиусом можно в еще одну компоненту вынести. Правда, я так и непонял че быстрее, чистый рендж бьонда или /datum/component/bounded который таскает за собой этот радиус.

radius_obj.appearance_flags &= ~TILE_BOUND
radius_obj.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
radius_obj.bound_x = bound_x
radius_obj.bound_y = bound_y
radius_obj.bound_width = bound_width
radius_obj.bound_height = bound_height
radius_obj.AddComponent(/datum/component/bounded, AM, 0, 0, null, FALSE, FALSE)
AM.AddComponent(/datum/component/vis_radius, _dist, "radius", COLOR_BLACK)

RegisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_MOVABLE_LOC_MOVED), .proc/update_sound_suppression)
RegisterSignal(parent, list(COMSIG_START_SUPPRESSING), .proc/enable_suppresion)
RegisterSignal(parent, list(COMSIG_STOP_SUPPRESSING), .proc/disable_suppression)

/datum/component/silence/Destroy()
. = ..()
if (isnull(parent))
return
disable_suppression()
qdel(radius_obj.GetComponent(/datum/component/vis_radius))
QDEL_NULL(radius_obj)

/datum/component/silence/proc/enable_suppresion()
SIGNAL_HANDLER
if (!enabled)
enabled = TRUE
update_sound_suppression()

/datum/component/silence/proc/disable_suppression()
SIGNAL_HANDLER
if (enabled)
enabled = FALSE
for (var/turf/T in old_locs)
T.sound_coefficient += coeff
old_locs = list()

/datum/component/silence/proc/update_sound_suppression()
SIGNAL_HANDLER
if (!enabled)
return
var/list/entered_locs = radius_obj.locs - old_locs
var/list/left_locs = old_locs - radius_obj.locs
Comment on lines +59 to +60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

смущает, что взаимодействия физических локаций у нас считаются как-то от чисто визуального /obj/effect/overlay

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ибо у нас невозможно сделать нормально так, что сами перчатки 1х1, но у них есть "аура", что больше их самих. Данный вариант предложил Киборг и оно работает.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вроде как, на дистанции рейндж бьонда будет намного медленнее, чем таскание абстрактного радиуса и обычный фор по его элементам.

Я даже пытался это высчитать, но на скриншоте не учтена компонента баунда, которая таскает радиус за собой. Да и код я уже потерял, но там было что-то типо range(9) и такой же большой радиус-предмет.
dreamseeker_M28STjyxB9

Но я щас на этой ветке просто перчатки за собой потаскали не почти ничего не нагрузил.
image


for (var/turf/T in left_locs)
T.sound_coefficient += coeff

for (var/turf/T in entered_locs)
T.sound_coefficient -= coeff

old_locs = radius_obj.locs
6 changes: 6 additions & 0 deletions code/datums/uplinks_items.dm
Expand Up @@ -505,6 +505,12 @@
item = /obj/item/clothing/gloves/black/strip
cost = 3

/datum/uplink_item/stealthy_weapons/silence_gloves
name = "Silence gloves"
desc = "A pair of black gloves which silences all sounds around you."
item = /obj/item/clothing/gloves/black/silence
cost = 12

/datum/uplink_item/stealthy_weapons/soap
name = "Syndicate Soap"
desc = "A sinister-looking surfactant used to clean blood stains to hide murders and prevent DNA analysis. You can also drop it underfoot to slip people."
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/random/random_cloth.dm
Expand Up @@ -103,7 +103,7 @@
icon = 'icons/obj/clothing/gloves.dmi'
icon_state = "orange"
/obj/random/cloth/gloves/item_to_spawn()
return pick(subtypesof(/obj/item/clothing/gloves) - list(/obj/item/clothing/gloves/golem, /obj/item/clothing/gloves/shadowling, /obj/item/clothing/gloves/fluff))
return pick(subtypesof(/obj/item/clothing/gloves) - list(/obj/item/clothing/gloves/golem, /obj/item/clothing/gloves/shadowling, /obj/item/clothing/gloves/fluff, /obj/item/clothing/gloves/black/silence/furioso))

/obj/random/cloth/glasses
name = "random glasses"
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/random/random_syndie.dm
Expand Up @@ -57,6 +57,7 @@
prob(33);/obj/item/ammo_box/a357,\
prob(33);/obj/item/device/encryptionkey/binary,\
prob(33);/obj/item/clothing/mask/gas/voice,\
prob(33);/obj/item/clothing/gloves/black/silence,\
prob(33);/obj/item/clothing/gloves/black/strip,\
prob(50);/obj/item/device/encryptionkey/syndicate,\
prob(50);/obj/item/device/multitool/ai_detect,\
Expand Down
5 changes: 5 additions & 0 deletions code/game/sound.dm
Expand Up @@ -13,6 +13,9 @@ voluminosity = if FALSE, removes the difference between left and right ear.

=======================================================================================================================================*/

/turf
var/sound_coefficient = 1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

надо будет либо запретить умножать на ноль, либо какой-то способ отслеживания того что кто-то сейчас умножает на ноль.

(Чтобы не вышло так что две перчатки там умножающие на ноль делают что турф навсегда молчит)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Возможно не актуально с тем что перчатки сейчас не умножают этот коэффициент, а прибавляют-убавляют)


/proc/playsound(atom/source, soundin, volume_channel = NONE, vol = 100, vary = TRUE, frequency = null, extrarange = 0, falloff, channel, wait, ignore_environment = FALSE, voluminosity = TRUE)
if(isarea(source))
CRASH("[source] is an area and is trying to make the sound: [soundin]")
Expand Down Expand Up @@ -88,6 +91,8 @@ voluminosity = if FALSE, removes the difference between left and right ear.
pressure_factor = max(pressure_factor, 0.15) //hearing through contact

S.volume *= pressure_factor
S.volume *= turf_source.sound_coefficient
S.volume *= max(T.sound_coefficient, 0.0)

if (S.volume <= 0)
return //no volume means no sound
Expand Down
1 change: 0 additions & 1 deletion code/modules/clothing/gloves/color.dm
Expand Up @@ -35,7 +35,6 @@
/obj/item/clothing/gloves/black/strip // gloves for stripping items
siemens_coefficient = 0.2


/obj/item/clothing/gloves/black/hos
name = "head of security's gloves"
item_color = "hosred" //Exists for washing machines.
Expand Down
90 changes: 90 additions & 0 deletions code/modules/clothing/gloves/silence.dm
@@ -0,0 +1,90 @@
// SILENCE GLOVES
// Traitor's item to nearly mute everything in one tile
/obj/item/clothing/gloves/black/silence
siemens_coefficient = 0.2
var/distance = 1
var/sound_coefficient = 0.9
var/hide_radius_timer

/obj/item/clothing/gloves/black/silence/atom_init()
. = ..()
AddComponent(/datum/component/silence, distance, sound_coefficient)

/obj/item/clothing/gloves/black/silence/equipped(mob/user, slot)
. = ..()
if (slot == SLOT_GLOVES)
to_chat(user, "<span class='red'>You can hear strange humming, hiding all other sounds away.</span>")
SEND_SIGNAL(src, COMSIG_START_SUPPRESSING)
SEND_SIGNAL(src, COMSIG_SHOW_RADIUS, user)
hide_radius_timer = addtimer(CALLBACK(src, .proc/hide_radius), 2 SECOND, TIMER_STOPPABLE)

/obj/item/clothing/gloves/black/silence/proc/hide_radius()
SEND_SIGNAL(src, COMSIG_HIDE_RADIUS)

/obj/item/clothing/gloves/black/silence/dropped(mob/user)
. = ..()
to_chat(user, "<span class='notice'>Humming goes away and you can hear now.</span>")
SEND_SIGNAL(src, COMSIG_STOP_SUPPRESSING)
SEND_SIGNAL(src, COMSIG_HIDE_RADIUS)
deltimer(hide_radius_timer)

// FURIOSO GLOVES
// Gloves with silence and storage capabilities
/obj/item/weapon/storage/internal/furioso
var/list/storaged_types = list()
atik1n marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/weapon/storage/internal/furioso/attackby(obj/item/I, mob/user, params)
if (I.type in storaged_types)
to_chat(user, "<span class='red'>There is already one [I] in storage!</span>")
return FALSE
. = ..()
if(.)
storaged_types += I.type

/obj/item/weapon/storage/internal/furioso/remove_from_storage(obj/item/W, atom/new_location, NoUpdate = FALSE)
. = ..()
if (.)
storaged_types -= W.type

/obj/item/weapon/storage/internal/furioso/MouseDrop(obj/over_object, src_location, turf/over_location)
if(over_object == usr && Adjacent(usr))
return
. = ..()

/obj/item/clothing/gloves/black/silence/furioso //gloves for badminery purposes
name = "the Black Silence gloves"
desc = "Gloves that suppresses all sound around it's wearer and can hold up to seven different types of weaponry."

distance = 3
siemens_coefficient = 0.0
sound_coefficient = 1.0

var/obj/item/weapon/storage/internal/pockets // oh yeah

/obj/item/clothing/gloves/black/silence/furioso/atom_init()
. = ..()
pockets = new /obj/item/weapon/storage/internal/furioso(src)
pockets.set_slots(slots = 7, slot_size = SIZE_LARGE)
pockets.can_hold = list(/obj/item/weapon/melee, /obj/item/weapon/gun)

/obj/item/clothing/gloves/black/silence/furioso/Destroy()
. = ..()
QDEL_NULL(pockets)

/obj/item/clothing/gloves/black/silence/furioso/attack_hand(mob/user)
if (pockets && pockets.handle_attack_hand(user))
..(user)

/obj/item/clothing/gloves/black/silence/furioso/MouseDrop(obj/over_object as obj)
if (pockets && pockets.handle_mousedrop(usr, over_object))
..(over_object)

/obj/item/clothing/gloves/black/silence/furioso/attackby(obj/item/I, mob/user, params)
if(pockets && user.a_intent != INTENT_HARM && pockets.attackby(I, user, params))
return
return ..()

/obj/item/clothing/gloves/black/silence/furioso/emp_act(severity)
if(pockets)
pockets.emplode(severity)
..()
2 changes: 1 addition & 1 deletion code/modules/clothing/under/chameleon.dm
Expand Up @@ -302,7 +302,7 @@

/obj/item/clothing/gloves/chameleon/atom_init()
. = ..()
var/blocked = list(/obj/item/clothing/gloves/chameleon)//Prevent infinite loops and bad hats.
var/blocked = list(/obj/item/clothing/gloves/chameleon, /obj/item/clothing/gloves/black/strip, /obj/item/clothing/gloves/black/silence)//Prevent infinite loops and bad hats.
for(var/U in typesof(/obj/item/clothing/gloves)-blocked)
var/obj/item/clothing/gloves/V = new U
clothing_choices[V.name] = U
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/say.dm
Expand Up @@ -145,6 +145,9 @@ var/global/list/department_radio_keys = list(

if (speech_sound)
sound_vol *= 0.5 //muffle the sound a bit, so it's like we're actually talking through contact

//make sure we actually can hear there
message = Gibberish(message, (1.0 - max(0.0, T.sound_coefficient)) * 100 + 20)

var/list/listening = list()
var/list/listening_obj = list()
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mob/mob.dm
Expand Up @@ -163,7 +163,11 @@
to_chat(M, self_message)
continue

M.show_message(message, SHOWMSG_AUDIO, deaf_message, SHOWMSG_VISUAL)
var/turf/T = get_turf(M)
if (T.sound_coefficient == 0.0)
M.show_message(deaf_message, SHOWMSG_VISUAL)
else
M.show_message(message, SHOWMSG_AUDIO, deaf_message, SHOWMSG_VISUAL)

// Show a message to all mobs in earshot of this atom
// Use for objects performing audible actions
Expand Down
2 changes: 2 additions & 0 deletions taucetistation.dme
Expand Up @@ -257,6 +257,7 @@
#include "code\datums\components\mechanic_description.dm"
#include "code\datums\components\mood.dm"
#include "code\datums\components\multi_carry.dm"
#include "code\datums\components\silence.dm"
#include "code\datums\components\slippery.dm"
#include "code\datums\components\swiping.dm"
#include "code\datums\components\tactical.dm"
Expand Down Expand Up @@ -1346,6 +1347,7 @@
#include "code\modules\clothing\gloves\color.dm"
#include "code\modules\clothing\gloves\miscellaneous.dm"
#include "code\modules\clothing\gloves\ninja.dm"
#include "code\modules\clothing\gloves\silence.dm"
#include "code\modules\clothing\gloves\stungloves.dm"
#include "code\modules\clothing\head\beret.dm"
#include "code\modules\clothing\head\collectable.dm"
Expand Down