Skip to content

Commit

Permalink
Merge pull request #2016 from SierraBay/upstream-pr-34539
Browse files Browse the repository at this point in the history
[MIRROR] ballistic goggles
  • Loading branch information
UEDCommander authored May 22, 2024
2 parents e6c9ac9 + 65e7940 commit 6eaa93d
Show file tree
Hide file tree
Showing 35 changed files with 672 additions and 202 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@
#include "code\modules\clothing\under\accessories\fire_overpants.dm"
#include "code\modules\clothing\under\accessories\flannel_shirt.dm"
#include "code\modules\clothing\under\accessories\ftu_pin.dm"
#include "code\modules\clothing\under\accessories\goggle_mods.dm"
#include "code\modules\clothing\under\accessories\hawaii.dm"
#include "code\modules\clothing\under\accessories\helmcover.dm"
#include "code\modules\clothing\under\accessories\helmet_decor.dm"
Expand Down
4 changes: 3 additions & 1 deletion code/__defines/items_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#define ACCESSORY_SLOT_ARMOR_M "Misc armor"
#define ACCESSORY_SLOT_HELM_C "Helmet cover"
#define ACCESSORY_SLOT_HELM_D "Helmet decor"

#define ACCESSORY_SLOT_VISOR "Helmet visor"
#define ACCESSORY_SLOT_VISION "Vision modification"
#define ACCESSORY_SLOT_HUD "HUD modification"

#define ACCESSORY_REMOVABLE FLAG(0)
#define ACCESSORY_HIDDEN FLAG(1)
Expand Down
3 changes: 0 additions & 3 deletions code/_helpers/cmp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
/proc/cmp_ruincost_priority(datum/map_template/ruin/A, datum/map_template/ruin/B)
return initial(A.spawn_cost) - initial(B.spawn_cost)

/proc/cmp_clientcolor_priority(datum/client_color/A, datum/client_color/B)
return B.priority - A.priority

/proc/cmp_power_component_priority(obj/item/stock_parts/power/A, obj/item/stock_parts/power/B)
return B.priority - A.priority

Expand Down
14 changes: 14 additions & 0 deletions code/datums/uplink/devices and tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@
path = /obj/item/clothing/glasses/thermal/syndi/aviators
antag_roles = list(MODE_TRAITOR)

/datum/uplink_item/item/tools/thermal_goggles
name = "Helmet-Attached Thermal Sights"
desc = "A set of thermal sights that can attach to combat or voidsuit helmets. Range is limited, along with the color palette, and it will be obvious what you are wearing."
item_cost = 12
path = /obj/item/clothing/head/helmet/nvgmount/thermal
antag_roles = list(MODE_TRAITOR)

/datum/uplink_item/item/tools/night_goggles
name = "Helmet-Attached Light-Enhancing Sights"
desc = "A set of light-enhancing sights for seeing in the dark. They can attach to combat or voidsuit helmets. Range is slightly limited, along with your perceptible range of colors. It will be obvious what you are wearing."
item_cost = 12
path = /obj/item/clothing/head/helmet/nvgmount/nvg
antag_roles = list(MODE_MERCENARY, MODE_TRAITOR) //don't give mercs extra thermals but NVGs are okay

/datum/uplink_item/item/tools/flashdark
name = "Flashdark"
desc = "A device similar to a flash light that absorbs the surrounding light, casting a shadowy, black mass."
Expand Down
2 changes: 2 additions & 0 deletions code/game/antagonist/outsider/raider.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ GLOBAL_DATUM_INIT(raiders, /datum/antagonist/raider, new)
/obj/item/clothing/head/pirate,
/obj/item/clothing/mask/bandana/red,
/obj/item/clothing/head/hgpiratecap,
/obj/item/clothing/head/helmet/nvgmount/nvg,
/obj/item/clothing/head/helmet/nvgmount/thermal // raiders can have a little nvg, as a treat
)

var/list/raider_suits = list(
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/ecigs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "electronic cigarette"
desc = "Device with modern approach to smoking."
icon = 'icons/obj/ecig.dmi'
var/active = 0
active = 0
var/obj/item/cell/cigcell
var/cartridge_type = /obj/item/reagent_containers/ecig_cartridge/med_nicotine
var/obj/item/reagent_containers/ecig_cartridge/ec_cartridge
Expand Down
34 changes: 22 additions & 12 deletions code/game/objects/random/random.dm
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,12 @@
/obj/item/clothing/glasses/hud/security/prot = 2,
/obj/item/clothing/glasses/hud/security/prot/sunglasses = 3,
/obj/item/clothing/glasses/hud/security/prot/aviators = 1,
/obj/item/clothing/glasses/tacgoggles = 1)
/obj/item/clothing/glasses/tacgoggles = 1,
/obj/item/clothing/glasses/ballistic/security = 1,
/obj/item/clothing/glasses/ballistic = 2,
/obj/item/clothing/glasses/ballistic/prescription = 1,
/obj/item/clothing/glasses/ballistic/fake = 3
)

/obj/random/hat
name = "random headgear"
Expand All @@ -851,16 +856,19 @@
icon_state = "tophat"

/obj/random/hat/spawn_choices()
return list(/obj/item/clothing/head/helmet = 2,
/obj/item/clothing/head/helmet/tactical = 1,
/obj/item/clothing/head/helmet/space/emergency = 1,
/obj/item/clothing/head/bio_hood/general = 1,
/obj/item/clothing/head/hardhat = 4,
/obj/item/clothing/head/hardhat/orange = 4,
/obj/item/clothing/head/hardhat/red = 4,
/obj/item/clothing/head/hardhat/blue = 4,
/obj/item/clothing/head/ushanka = 3,
/obj/item/clothing/head/welding = 2)
return list(/obj/item/clothing/head/helmet = 4,
/obj/item/clothing/head/helmet/tactical = 2,
/obj/item/clothing/head/helmet/old_commonwealth = 1,
/obj/item/clothing/head/helmet/old_confederation = 1,
/obj/item/clothing/head/helmet/space/emergency = 2,
/obj/item/clothing/head/bio_hood/general = 2,
/obj/item/clothing/head/hardhat = 8,
/obj/item/clothing/head/hardhat/orange = 8,
/obj/item/clothing/head/hardhat/red = 8,
/obj/item/clothing/head/hardhat/blue = 8,
/obj/item/clothing/head/ushanka = 8,
/obj/item/clothing/head/welding = 8
)

/obj/random/suit
name = "random suit"
Expand Down Expand Up @@ -923,7 +931,9 @@
/obj/item/clothing/accessory/storage/holster/waist = 1,
/obj/item/clothing/accessory/storage/holster/armpit = 1,
/obj/item/clothing/accessory/kneepads = 3,
/obj/item/clothing/accessory/stethoscope = 2)
/obj/item/clothing/accessory/stethoscope = 2,
/obj/item/clothing/accessory/glassesmod/nvg = 1
)

GLOBAL_LIST_INIT(random_backpacks, list(
/obj/item/storage/backpack/cultpack,
Expand Down
225 changes: 146 additions & 79 deletions code/modules/client/client_color.dm
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
11 changes: 11 additions & 0 deletions code/modules/client/preference_setup/loadout/lists/eyegear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,14 @@
display_name = "Blindfold"
path = /obj/item/clothing/glasses/blindfold
flags = GEAR_HAS_COLOR_SELECTION

/datum/gear/eyes/ballistics
display_name = "Replica Ballistic Goggles"
path = /obj/item/clothing/glasses/ballistic/fake

/datum/gear/eyes/ballistics/New()
..()
var/list/options = list()
options["Replica Ballistic Goggles"] = /obj/item/clothing/glasses/ballistic/fake
options["Replica Ballistic Goggles, corrective"] = /obj/item/clothing/glasses/ballistic/fake/prescription
gear_tweaks += new /datum/gear_tweak/path (options)
Loading

0 comments on commit 6eaa93d

Please sign in to comment.