|
| 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 |
0 commit comments