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
The Gloves of Silence #7913
Changes from all commits
c6bd0f9
680419a
00f88b3
43100bb
d48ecb0
37836c6
e89aa9e
f57541a
b0618a5
6401964
c63e3db
718532a
6d7a489
b11c476
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Я думаю, эту фичу с радиусом можно в еще одну компоненту вынести. Правда, я так и непонял че быстрее, чистый рендж бьонда или |
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. смущает, что взаимодействия физических локаций у нас считаются как-то от чисто визуального There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ибо у нас невозможно сделать нормально так, что сами перчатки 1х1, но у них есть "аура", что больше их самих. Данный вариант предложил Киборг и оно работает. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вроде как, на дистанции рейндж бьонда будет намного медленнее, чем таскание абстрактного радиуса и обычный фор по его элементам. Я даже пытался это высчитать, но на скриншоте не учтена компонента баунда, которая таскает радиус за собой. Да и код я уже потерял, но там было что-то типо range(9) и такой же большой радиус-предмет. Но я щас на этой ветке просто перчатки за собой потаскали не почти ничего не нагрузил. |
||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ voluminosity = if FALSE, removes the difference between left and right ear. | |
|
||
=======================================================================================================================================*/ | ||
|
||
/turf | ||
var/sound_coefficient = 1.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. надо будет либо запретить умножать на ноль, либо какой-то способ отслеживания того что кто-то сейчас умножает на ноль. (Чтобы не вышло так что две перчатки там умножающие на ноль делают что турф навсегда молчит) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]") | ||
|
@@ -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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
..() |
There was a problem hiding this comment.
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, то у тебя в итоге будет криво значение.There was a problem hiding this comment.
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