Skip to content

Commit 8f8639a

Browse files
ID Flashing (thanks to Goonstation for sprites) (#38230)
* ID Flashing * Alters pixel offsets * Refactor code to be cleaner for flashing * Final updates
1 parent e296261 commit 8f8639a

File tree

7 files changed

+141
-3
lines changed

7 files changed

+141
-3
lines changed

code/datums/flash_animations.dm

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#define FLASH_ID_ANIM "flash_id_anim"
2+
#define FLASH_BADGE_ANIM "flash_badge_anim"
3+
#define FLASH_BADGE_CORD_ANIM "flash_badge_cord_anim"
4+
5+
6+
var/flash_pixel_offsets = list(
7+
"base"=list(
8+
FLASH_ID_ANIM=list(
9+
"hand_shape" = "id",
10+
"left" = list("x"= 4, "y" = -3),
11+
"right" = list("x"= -5, "y" = 0)
12+
),
13+
FLASH_BADGE_ANIM=list(
14+
"hand_shape" = "badge",
15+
"left" = list("x"= 7, "y" = -1),
16+
"right" = list("x"= -7, "y" = -2)
17+
),
18+
FLASH_BADGE_CORD_ANIM=list(
19+
"hand_shape" = "badge",
20+
"left" = list("x"= 7, "y" = -1),
21+
"right" = list("x"= -7, "y" = -2)
22+
)
23+
),
24+
"vox"=list(
25+
FLASH_ID_ANIM=list(
26+
"hand_shape" = "id",
27+
"left" = list("x"= 5, "y" = -3),
28+
"right" = list("x"= -5, "y" = -1)
29+
),
30+
FLASH_BADGE_ANIM=list(
31+
"hand_shape" = "badge",
32+
"left" = list("x"= 8, "y" = -2),
33+
"right" = list("x"= -7, "y" = -2)
34+
),
35+
FLASH_BADGE_CORD_ANIM=list(
36+
"hand_shape" = "badge",
37+
"left" = list("x"= 8, "y" = -4),
38+
"right" = list("x"= -7, "y" = -6)
39+
)
40+
)
41+
)
42+
43+
/proc/flash_object_animation(var/mob/user, var/obj/item/target, var/animation_type=FLASH_ID_ANIM)
44+
// Credit to pgmzeta of Goonstation for the base hand flash sprite under CC-BY-NC-SA. Modifications made so that
45+
// the pixels align better with /vg/'s diagonal card as well as to fit other item shapes and other species.
46+
var/hand_flash_icon_state
47+
var/pixel_x_offset
48+
var/pixel_y_offset
49+
50+
var/species_tag = "base"
51+
if(isvox(user))
52+
species_tag = "vox"
53+
var/hand_shape = flash_pixel_offsets[species_tag][animation_type]["hand_shape"]
54+
55+
if(user.active_hand == 1)
56+
hand_flash_icon_state = "hold_[hand_shape]_[species_tag]_right"
57+
pixel_x_offset = flash_pixel_offsets[species_tag][animation_type]["right"]["x"]
58+
pixel_y_offset = flash_pixel_offsets[species_tag][animation_type]["right"]["y"]
59+
else
60+
hand_flash_icon_state = "hold_[hand_shape]_[species_tag]_left"
61+
pixel_x_offset = flash_pixel_offsets[species_tag][animation_type]["left"]["x"]
62+
pixel_y_offset = flash_pixel_offsets[species_tag][animation_type]["left"]["y"]
63+
64+
var/hand_color = rgb(255, 202, 149)
65+
if(ishuman(user))
66+
var/mob/living/carbon/human/h = user
67+
68+
var/obj/item/equipped_external_suit = h.wear_suit
69+
if(istype(equipped_external_suit) && equipped_external_suit.body_parts_covered & HANDS)
70+
71+
hand_color = AverageColor(getFlatIcon(equipped_external_suit))
72+
else
73+
var/obj/item/equipped_gloves = h.gloves
74+
if(istype(equipped_gloves) && equipped_gloves.body_parts_covered & HANDS)
75+
hand_color = AverageColor(getFlatIcon(equipped_gloves))
76+
else
77+
hand_color = h.get_skin_color()
78+
79+
var/image/hand_image = image("icon"='icons/effects/effects.dmi', "icon_state"=hand_flash_icon_state, "layer"=MOB_LAYER+1)
80+
hand_image.color = hand_color
81+
hand_image.pixel_x += pixel_x_offset
82+
hand_image.pixel_y += pixel_y_offset
83+
user.dir = SOUTH
84+
85+
var/cached_vis_flags = target.vis_flags
86+
target.vis_flags |= (VIS_INHERIT_ID | VIS_INHERIT_PLANE | VIS_INHERIT_LAYER)
87+
target.pixel_x += pixel_x_offset
88+
target.pixel_y += pixel_y_offset
89+
90+
user.vis_contents += target
91+
user.overlays += hand_image
92+
93+
user.delayNextMove(0.5 SECONDS)
94+
playsound(user, 'sound/weapons/whip_crack.ogg', 40, 1)
95+
96+
spawn(5)
97+
if(user != null)
98+
user.overlays -= hand_image
99+
100+
if(target != null)
101+
if(user != null)
102+
user.vis_contents -= target
103+
target.vis_flags = cached_vis_flags
104+
target.pixel_x -= pixel_x_offset
105+
target.pixel_y -= pixel_y_offset

code/game/objects/items/weapons/cards_ids.dm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ var/list/global/id_cards = list()
248248
/obj/item/weapon/card/id/attack_self(var/mob/user)
249249
if(user.attack_delayer.blocked())
250250
return
251-
user.visible_message("[user] shows you: [bicon(src)] [name]: assignment: [assignment]",\
252-
"You flash your ID card: [bicon(src)] [name]: assignment: [assignment]")
253-
user.delayNextAttack(1 SECONDS)
251+
user.visible_message("[user] shows you: [bicon(src)] [name]. Assignment: [assignment]",\
252+
"You flash your ID card: [bicon(src)] [name]. Assignment: [assignment]")
253+
user.delayNextAttack(0.5 SECONDS)
254254
add_fingerprint(user)
255+
flash_object_animation(user, src, FLASH_ID_ANIM)
255256

256257
/obj/item/weapon/card/id/GetAccess()
257258
if(arcanetampered)

code/libs/IconProcs/IconProcs.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@
479479

480480
return rgb(r, g, b)
481481

482+
/proc/SubRGB(rgb1, rgb2, amount)
483+
var/list/RGB1 = rgb2num(rgb1)
484+
var/list/RGB2 = rgb2num(rgb2)
485+
486+
return rgb(clamp(RGB1[1] - RGB2[1], 0, 255), clamp(RGB1[2] - RGB2[2], 0, 255), clamp(RGB1[3] - RGB2[3], 0, 255))
487+
482488
/proc/BlendRGBasHSV(rgb1, rgb2, amount)
483489
return HSVtoRGB(RGBtoHSV(rgb1), RGBtoHSV(rgb2), amount)
484490

code/modules/clothing/accessories/accessory.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,23 @@
306306
slot_flags = SLOT_BELT
307307

308308
var/stored_name = null
309+
var/flash_animation = FLASH_BADGE_ANIM
309310

310311
/obj/item/clothing/accessory/holobadge/cord
311312
icon_state = "holobadge-cord"
312313
_color = "holobadge-cord"
313314
slot_flags = SLOT_MASK
315+
flash_animation = FLASH_BADGE_CORD_ANIM
314316

315317
/obj/item/clothing/accessory/holobadge/attack_self(mob/user as mob)
316318
if(!stored_name)
317319
to_chat(user, "Waving around a badge before swiping an ID would be pretty pointless.")
318320
return
319321
if(isliving(user))
322+
user.delayNextAttack(0.5 SECONDS)
323+
add_fingerprint(user)
320324
user.visible_message("<span class='warning'>[user] displays their Nanotrasen Internal Security Legal Authorization Badge.\nIt reads: [stored_name], NT Security.</span>","<span class='warning'>You display your Nanotrasen Internal Security Legal Authorization Badge.\nIt reads: [stored_name], NT Security.</span>")
325+
flash_object_animation(user, src, flash_animation)
321326

322327
/obj/item/clothing/accessory/holobadge/attackby(var/obj/item/O as obj, var/mob/user as mob)
323328

code/modules/mob/living/carbon/human/update_icons.dm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,26 @@ var/global/list/damage_icon_parts = list()
294294
if(update_icons)
295295
update_icons()
296296

297+
/mob/living/carbon/human/proc/get_skin_color()
298+
var/husk = (M_HUSK in mutations)
299+
var/hulk = (M_HULK in mutations) && !ishorrorform(src) && mind.special_role != HIGHLANDER // Part of the species.
300+
var/skeleton = (M_SKELETON in mutations)
301+
302+
var/base_rgb = species.flesh_color
303+
if(base_rgb == null)
304+
base_rgb = rgb(255, 202, 149)
305+
if(!skeleton && !husk && !hulk)
306+
if(species.anatomy_flags & MULTICOLOR)
307+
return AddRGB(base_rgb, rgb(multicolor_skin_r, multicolor_skin_g, multicolor_skin_b))
308+
else if(species.anatomy_flags & RGBSKINTONE)
309+
return AddRGB(base_rgb, rgb(my_appearance.r_hair, my_appearance.g_hair, my_appearance.b_hair))
310+
else if(species.anatomy_flags & HAS_SKIN_TONE)
311+
if(my_appearance.s_tone >= 0)
312+
return AddRGB(base_rgb, rgb(my_appearance.s_tone, my_appearance.s_tone, my_appearance.s_tone))
313+
else
314+
return SubRGB(base_rgb, rgb(-my_appearance.s_tone, -my_appearance.s_tone, -my_appearance.s_tone))
315+
return base_rgb
316+
297317
//HAIR OVERLAY
298318
/mob/living/carbon/human/update_hair(update_icons = TRUE)
299319
if(monkeyizing)

icons/effects/effects.dmi

1.16 KB
Binary file not shown.

vgstation13.dme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
#include "code\datums\disease.dm"
261261
#include "code\datums\emotes.dm"
262262
#include "code\datums\feedback.dm"
263+
#include "code\datums\flash_animations.dm"
263264
#include "code\datums\fuzzy_rules.dm"
264265
#include "code\datums\gas_giant.dm"
265266
#include "code\datums\laser_tag_game.dm"

0 commit comments

Comments
 (0)