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

add: Light frame coloring #6381

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ stddef.dm
#Ignore cached sound files.
/sound/tts_cache/**/*
/sound/tts_scrambled/**/*
.vscode/launch.json
.gitignore
29 changes: 29 additions & 0 deletions code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,35 @@
explode()
return ATTACK_CHAIN_BLOCKED_ALL

if(istype(I, /obj/item/toy/crayon/spraycan))
add_fingerprint(user)
var/obj/item/toy/crayon/spraycan/spraycan = I
if(spraycan.colour == light_color)
return ATTACK_CHAIN_BLOCKED_ALL
/* Реализация проверки цвета, который был выбран в распылителе
Если цвет слишком тёмный, то return */
var/r = hex2num(copytext(spraycan.colour, 2, 4))
var/g = hex2num(copytext(spraycan.colour, 4, 6))
var/b = hex2num(copytext(spraycan.colour, 6, 8))

var/brightness = (0.299 * r + 0.587 * g + 0.114 * b) // Формула для определения яркости цвета(Да, магические числа)
if(brightness < 100) // Порог яркости
to_chat(user, span_warning("Выбранный цвет слишком тёмный для того чтоб он мог пропускать свет!"))
return ATTACK_CHAIN_BLOCKED_ALL
var/min_rgb = min(r, g, b)
var/max_rgb = max(r, g, b)
var/saturation = (max_rgb - min_rgb) / max_rgb
if(saturation > 0.8) // Максимально допустимая насыщенность
to_chat(user, span_warning("Цвет слишком насыщенный для освещения!"))
return ATTACK_CHAIN_BLOCKED_ALL
/* Конец проверки цвета */
to_chat(user, span_warning("Вы покрасили [src] при помощи [spraycan.name]!"))
spraycan.uses--
color = spraycan.colour
light_color = spraycan.colour
playsound(src, 'sound/effects/spray.ogg', 50, TRUE)
update()
return ATTACK_CHAIN_BLOCKED_ALL
return ..()


Expand Down