forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2016 from SierraBay/upstream-pr-34539
[MIRROR] ballistic goggles
- Loading branch information
Showing
35 changed files
with
672 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,179 @@ | ||
/datum/client_color | ||
var/client_color = "" //Any client.color-valid value | ||
var/priority = 1 //Since only one client.color can be rendered on screen, we take the one with the highest priority value: | ||
//eg: "Bloody screen" > "goggles color" as the former is much more important | ||
var/override = FALSE //If set to override we will stop multiplying the moment we get here. NOTE: Priority remains, if your override is on position 4, the other 3 will still have a say. | ||
/// Any value valid for client.color | ||
var/client_color | ||
|
||
/// The order in which client colors are applied. Higher numbers are applied later. | ||
var/order | ||
|
||
/mob | ||
var/list/client_colors = list() | ||
/// If set, stops applying client colors once this one is reached. Order still applies. | ||
var/override | ||
|
||
/// Whether this client color should affect the color of blood. | ||
var/ignore_blood | ||
|
||
|
||
/* | ||
Adds an instance of color_type to the mob's client_colors list | ||
color_type - a typepath (subtyped from /datum/client_color) | ||
*/ | ||
/mob/proc/has_client_color(color_type) | ||
if(!ispath(/datum/client_color) || !LAZYLEN(client_colors)) | ||
/// The set of /datum/client_color currently applied to the mob, if any. | ||
/mob/var/list/client_colors | ||
|
||
|
||
/// Checks whether the mob has an instance of color_type in its client_colors list. | ||
/mob/proc/has_client_color(datum/client_color/color_type) | ||
if (!length(client_colors)) | ||
return FALSE | ||
for(var/thing in client_colors) | ||
var/datum/client_color/col = thing | ||
if(col.type == color_type) | ||
if (!ispath(color_type, /datum/client_color)) | ||
return FALSE | ||
for (var/datum/client_color/entry as anything in client_colors) | ||
if (entry.type == color_type) | ||
return TRUE | ||
return FALSE | ||
|
||
/mob/proc/add_client_color(color_type) | ||
if(!has_client_color(color_type)) | ||
var/datum/client_color/CC = new color_type() | ||
client_colors |= CC | ||
sortTim(client_colors, GLOBAL_PROC_REF(cmp_clientcolor_priority)) | ||
update_client_color() | ||
|
||
|
||
/* | ||
Removes an instance of color_type from the mob's client_colors list | ||
color_type - a typepath (subtyped from /datum/client_color) | ||
returns true if instance was found, false otherwise | ||
*/ | ||
/mob/proc/remove_client_color(color_type) | ||
if(!ispath(/datum/client_color)) | ||
return FALSE | ||
/// Adds an instance of color_type to the mob's client_colors list if one doesn't already exist. | ||
/mob/proc/add_client_color(datum/client_color/color_type) | ||
if (has_client_color(color_type)) | ||
return | ||
if (!length(client_colors)) | ||
client_colors = list() | ||
client_colors |= new color_type | ||
sortTim(client_colors, GLOBAL_PROC_REF(cmp_clientcolor_order)) | ||
update_client_color() | ||
|
||
|
||
/// The comparison function for sorting client_colors by order. | ||
/proc/cmp_clientcolor_order(datum/client_color/a, datum/client_color/b) | ||
return a.order - b.order | ||
|
||
var/result = FALSE | ||
for(var/cc in client_colors) | ||
var/datum/client_color/CC = cc | ||
if(CC.type == color_type) | ||
result = TRUE | ||
client_colors -= CC | ||
qdel(CC) | ||
|
||
/// Removes an instance of color_type from the mob's client_colors list, returning TRUE if one existed. | ||
/mob/proc/remove_client_color(datum/client_color/color_type) | ||
if (!length(client_colors)) | ||
return | ||
for (var/datum/client_color/entry as anything in client_colors) | ||
if (entry.type == color_type) | ||
client_colors -= entry | ||
qdel(entry) | ||
update_client_color() | ||
if (!length(client_colors)) | ||
client_colors = null | ||
break | ||
|
||
|
||
/// Clears the mobs client_colors list. | ||
/mob/proc/clear_client_colors() | ||
if (!length(client_colors)) | ||
return | ||
client_colors = null | ||
update_client_color() | ||
return result | ||
|
||
|
||
/* | ||
Resets the mob's client.color to null, and then sets it to the highest priority | ||
client_color datum, if one exists | ||
*/ | ||
/// Resets the mob's client.color to null and then applies the client_colors list. | ||
/mob/proc/update_client_color() | ||
if(!client) | ||
if (!client) | ||
return | ||
client.color = null | ||
if(!length(client_colors)) | ||
var/list/color = list( | ||
1, 0, 0, | ||
0, 1, 0, | ||
0, 0, 1 | ||
) | ||
if (!length(client_colors)) | ||
animate(renderers[10], color = initial(color)) | ||
animate(client, color = initial(color)) | ||
return | ||
var/list/c = list(1,0,0, 0,1,0, 0,0,1) //Star at normal | ||
for(var/datum/client_color/CC in client_colors) | ||
//Matrix multiplication newcolor * current | ||
var/list/current = c.Copy() | ||
var/datum/client_color/top_color | ||
for (var/datum/client_color/entry as anything in client_colors) | ||
top_color = entry | ||
var/list/copy = color.Copy() | ||
for (var/m = 1 to 3) | ||
for (var/i = 1 to 3) | ||
var/value = 0 | ||
for (var/j = 1 to 3) | ||
value += copy[(j - 1) * 3 + i] * entry.client_color[(m - 1) * 3 + j] | ||
color[(m - 1) * 3 + i] = value | ||
if (entry.override) | ||
break | ||
if (!top_color.ignore_blood) | ||
animate(renderers[10], color = color) | ||
animate(client, color = list( | ||
1, 0, 0, | ||
0, 1, 0, | ||
0, 0, 1 | ||
)) | ||
else | ||
animate(client, color = color) | ||
animate(renderers[10], color = list( | ||
1, 0, 0, | ||
0, 1, 0, | ||
0, 0, 1 | ||
)) | ||
|
||
|
||
for(var/m = 1; m <= 3; m += 1) //For each row | ||
for(var/i = 1; i <= 3; i += 1) //go over each column of the second matrix | ||
var/sum = 0 | ||
for(var/j = 1; j <= 3; j += 1) //multiply each pair | ||
sum += CC.client_color[(m-1)*3 + j] * current[(j-1)*3 + i] | ||
/datum/client_color/deuteranopia | ||
client_color = list( | ||
0.47, 0.38, 0.15, | ||
0.54, 0.31, 0.15, | ||
0, 0.3, 0.7 | ||
) | ||
order = 100 | ||
|
||
c[(m-1)*3 + i] = sum | ||
|
||
if(CC.override) | ||
break | ||
/datum/client_color/protanopia | ||
client_color = list( | ||
0.51, 0.4, 0.12, | ||
0.49, 0.41, 0.12, | ||
0, 0.2, 0.76 | ||
) | ||
order = 100 | ||
|
||
|
||
/datum/client_color/tritanopia | ||
client_color = list( | ||
0.95, 0.07, 0, | ||
0, 0.44, 0.52, | ||
0.05, 0.49, 0.48 | ||
) | ||
order = 100 | ||
|
||
animate(client, color = c) | ||
|
||
/datum/client_color/monochrome | ||
client_color = list(0.33,0.33,0.33, 0.33,0.33,0.33, 0.33,0.33,0.33) | ||
priority = 100 | ||
client_color = list( | ||
0.33, 0.33, 0.33, | ||
0.33, 0.33, 0.33, | ||
0.33, 0.33, 0.33 | ||
) | ||
order = 199 | ||
|
||
//Similar to monochrome but shouldn't look as flat, same priority | ||
/datum/client_color/noir | ||
client_color = list(0.299,0.299,0.299, 0.587,0.587,0.587, 0.114,0.114,0.114) | ||
priority = 200 | ||
|
||
/datum/client_color/thirdeye | ||
client_color = list(0.1, 0.1, 0.1, 0.3, 0.3, 0.3, 0.3, 0.3, 0.7) | ||
priority = 300 | ||
/datum/client_color/nvg | ||
client_color = list( | ||
0.2, 0.2, 0.2, | ||
0.2, 0.5, 0.5, | ||
0.2, 0.3, 0.5 | ||
) | ||
order = 199 | ||
|
||
//Disabilities, could be hooked to brain damage or chargen if so desired. | ||
/datum/client_color/deuteranopia | ||
client_color = list(0.47,0.38,0.15, 0.54,0.31,0.15, 0,0.3,0.7) | ||
priority = 100 | ||
|
||
/datum/client_color/protanopia | ||
client_color = list(0.51,0.4,0.12, 0.49,0.41,0.12, 0,0.2,0.76) | ||
priority = 100 | ||
/datum/client_color/noir | ||
client_color = list( | ||
0.299, 0.299, 0.299, | ||
0.587, 0.587, 0.587, | ||
0.114, 0.114, 0.114 | ||
) | ||
order = 200 | ||
ignore_blood = TRUE | ||
|
||
|
||
/datum/client_color/thirdeye | ||
client_color = list( | ||
0.1, 0.1, 0.1, | ||
0.3, 0.3, 0.3, | ||
0.3, 0.3, 0.7 | ||
) | ||
order = 300 | ||
ignore_blood = TRUE | ||
|
||
/datum/client_color/tritanopia | ||
client_color = list(0.95,0.07,0, 0,0.44,0.52, 0.05,0.49,0.48) | ||
priority = 100 | ||
|
||
/datum/client_color/berserk | ||
client_color = "#af111c" | ||
priority = INFINITY //This effect sort of exists on its own you /have/ to be seeing RED | ||
override = TRUE //Because multiplying this will inevitably fail | ||
order = INFINITY | ||
override = TRUE | ||
ignore_blood = TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.