From 34346cf3086119b375bc4e9285c8655ce3e8ade6 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Thu, 11 Sep 2014 12:42:12 +0200 Subject: [PATCH] Ninja-night vision now works. A ninja now uses proper glasses instead of using its own hack. Fixed a bug that would override the old ninja-night vision unless one also wore additional glasses in the glasses-inventory slot. Adds overlays to thermals and mesons as well. Slightly reduces the intensity of the night vision overlay. --- code/_onclick/hud/hud.dm | 18 +++- code/game/gamemodes/events/ninja_equipment.dm | 95 +++++++++++------- code/modules/clothing/glasses/glasses.dm | 15 ++- code/modules/mob/living/carbon/human/life.dm | 76 ++++++-------- icons/obj/hud_full.dmi | Bin 0 -> 5899 bytes icons/obj/nvg_hud_full.dmi | Bin 2075 -> 0 bytes 6 files changed, 119 insertions(+), 85 deletions(-) create mode 100644 icons/obj/hud_full.dmi delete mode 100644 icons/obj/nvg_hud_full.dmi diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 5e005c5f0e..221eef2a1d 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -15,6 +15,8 @@ var/datum/global_hud/global_hud = new() var/list/vimpaired var/list/darkMask var/obj/screen/nvg + var/obj/screen/thermal + var/obj/screen/meson /datum/global_hud/New() //420erryday psychedellic colours screen overlay for when you are high @@ -33,11 +35,25 @@ var/datum/global_hud/global_hud = new() nvg = new /obj/screen() nvg.screen_loc = "1,1" - nvg.icon = 'icons/obj/nvg_hud_full.dmi' + nvg.icon = 'icons/obj/hud_full.dmi' nvg.icon_state = "nvg_hud" nvg.layer = 17 nvg.mouse_opacity = 0 + thermal = new /obj/screen() + thermal.screen_loc = "1,1" + thermal.icon = 'icons/obj/hud_full.dmi' + thermal.icon_state = "thermal_hud" + thermal.layer = 17 + thermal.mouse_opacity = 0 + + meson = new /obj/screen() + meson.screen_loc = "1,1" + meson.icon = 'icons/obj/hud_full.dmi' + meson.icon_state = "meson_hud" + meson.layer = 17 + meson.mouse_opacity = 0 + var/obj/screen/O var/i //that nasty looking dither you get when you're short-sighted diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index 787f2cf93e..19db9772ff 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -1173,16 +1173,25 @@ ________________________________________________________________________________ /* =================================================================================== -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> =================================================================================== */ -/obj/item/clothing/mask/gas/voice/space_ninja/New() - verbs += /obj/item/clothing/mask/gas/voice/space_ninja/proc/togglev - verbs += /obj/item/clothing/mask/gas/voice/space_ninja/proc/switchm +/obj/item/clothing/glasses/hud/ninja + name = "Ninja Scanner HUD" + desc = "Assesses targets" + body_parts_covered = 0 -//This proc is linked to human life.dm. It determines what hud icons to display based on mind special role for most mobs. -/obj/item/clothing/mask/gas/voice/space_ninja/proc/assess_targets(list/target_list, mob/living/carbon/U) +/obj/item/clothing/glasses/hud/ninja/process_hud(var/mob/M) + var/target_list[] = list() + for(var/mob/living/target in oview(M)) + if(target.mind && (target.mind.special_role || issilicon(target))) //They need to have a mind. + target_list += target + if(target_list.len) + assess_targets(target_list, M) + if(!M.druggy) M.see_invisible = SEE_INVISIBLE_LIVING + +/obj/item/clothing/glasses/hud/ninja/proc/assess_targets(list/target_list, mob/living/carbon/U) var/icon/tempHud = 'icons/mob/hud.dmi' for(var/mob/living/target in target_list) if(iscarbon(target)) @@ -1216,6 +1225,42 @@ ________________________________________________________________________________ U.client.images += image(tempHud,silicon_target,"hudmalai") return 1 +/* +=================================================================================== +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +=================================================================================== +*/ + +/datum/ninja_vision + var/mode + var/obj/item/clothing/glasses/glasses + +/datum/ninja_vision/scouter + mode = "Scouter" + glasses = new/obj/item/clothing/glasses/hud/ninja + +/datum/ninja_vision/nvg + mode = "Night Vision" + glasses = new/obj/item/clothing/glasses/night + +/datum/ninja_vision/thermal + mode = "Thermal Scanner" + glasses = new/obj/item/clothing/glasses/thermal + +/datum/ninja_vision/meson + mode = "Meson Scanner" + glasses = new/obj/item/clothing/glasses/meson + +/obj/item/clothing/mask/gas/voice/space_ninja + var/datum/ninja_vision/ninja_vision + var/list/datum/ninja_vision/ninja_visions + +/obj/item/clothing/mask/gas/voice/space_ninja/New() + ninja_visions = list(new/datum/ninja_vision/scouter, new/datum/ninja_vision/nvg, new/datum/ninja_vision/thermal, new/datum/ninja_vision/meson) + ninja_vision = ninja_visions[1] + verbs += /obj/item/clothing/mask/gas/voice/space_ninja/proc/togglev + verbs += /obj/item/clothing/mask/gas/voice/space_ninja/proc/switchm + /obj/item/clothing/mask/gas/voice/space_ninja/proc/togglev() set name = "Toggle Voice" set desc = "Toggles the voice synthesizer on or off." @@ -1248,42 +1293,20 @@ ________________________________________________________________________________ set name = "Switch Mode" set desc = "Switches between Night Vision, Meson, or Thermal vision modes." set category = "Ninja Equip" - //Have to reset these manually since life.dm is retarded like that. Go figure. - //This will only work for humans because only they have the appropriate code for the mask. + + var/index = ninja_visions.Find(ninja_vision) + 1 + if(index > ninja_visions.len) + index = 1 + ninja_vision = ninja_visions[index] + var/mob/U = loc - switch(mode) - if(0) - mode=1 - U << "Switching mode to Night Vision." - if(1) - mode=2 - U.see_in_dark = 2 - U << "Switching mode to Thermal Scanner." - if(2) - mode=3 - U.see_invisible = SEE_INVISIBLE_LIVING - U.sight &= ~SEE_MOBS - U << "Switching mode to Meson Scanner." - if(3) - mode=0 - U.sight &= ~SEE_TURFS - U << "Switching mode to Scouter." + U << "Switching mode to [ninja_vision.mode]." /obj/item/clothing/mask/gas/voice/space_ninja/examine() set src in view() ..() - var/mode - switch(mode) - if(0) - mode = "Scouter" - if(1) - mode = "Night Vision" - if(2) - mode = "Thermal Scanner" - if(3) - mode = "Meson Scanner" - usr << "[mode] is active."//Leaving usr here since it may be on the floor or on a person. + usr << "[ninja_vision.mode] is active."//Leaving usr here since it may be on the floor or on a person. usr << "Voice mimicking algorithm is set [!vchange?"inactive":"active"]." /* diff --git a/code/modules/clothing/glasses/glasses.dm b/code/modules/clothing/glasses/glasses.dm index 2bb3eba3ff..737f82f6ac 100644 --- a/code/modules/clothing/glasses/glasses.dm +++ b/code/modules/clothing/glasses/glasses.dm @@ -11,6 +11,7 @@ var/prescription = 0 var/toggleable = 0 var/active = 1 + var/obj/screen/overlay = null body_parts_covered = EYES /obj/item/clothing/glasses/attack_self(mob/user) @@ -18,13 +19,11 @@ if(active) active = 0 icon_state = "degoggles" - vision_flags = 0 user.update_inv_glasses() usr << "You deactivate the optical matrix on the [src]." else active = 1 icon_state = initial(icon_state) - vision_flags = initial(vision_flags) user.update_inv_glasses() usr << "You activate the optical matrix on the [src]." @@ -38,6 +37,10 @@ toggleable = 1 vision_flags = SEE_TURFS +/obj/item/clothing/glasses/meson/New() + ..() + overlay = global_hud.meson + /obj/item/clothing/glasses/meson/prescription name = "prescription mesons" desc = "Optical Meson Scanner with prescription lenses." @@ -57,6 +60,10 @@ origin_tech = "magnets=2" darkness_view = 7 +/obj/item/clothing/glasses/night/New() + ..() + overlay = global_hud.nvg + /obj/item/clothing/glasses/eyepatch name = "eyepatch" desc = "Yarr." @@ -212,6 +219,10 @@ M.disabilities &= ~NEARSIGHTED ..() +/obj/item/clothing/glasses/thermal/New() + ..() + overlay = global_hud.thermal + /obj/item/clothing/glasses/thermal/syndi //These are now a traitor item, concealed as mesons. -Pete name = "Optical Meson Scanner" desc = "Used for seeing walls, floors, and stuff through anything." diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 6ba271f425..1119225ec1 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1202,7 +1202,7 @@ if(copytext(hud.icon_state,1,4) == "hud") //ugly, but icon comparison is worse, I believe client.images.Remove(hud) - client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask, global_hud.nvg) + client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask, global_hud.nvg, global_hud.thermal, global_hud.meson) update_action_buttons() @@ -1314,57 +1314,18 @@ see_invisible = SEE_INVISIBLE_LIVING seer = 0 + var/tmp/glasses_processed = 0 if(istype(wear_mask, /obj/item/clothing/mask/gas/voice/space_ninja)) var/obj/item/clothing/mask/gas/voice/space_ninja/O = wear_mask - switch(O.mode) - if(0) - var/target_list[] = list() - for(var/mob/living/target in oview(src)) - if( target.mind&&(target.mind.special_role||issilicon(target)) )//They need to have a mind. - target_list += target - if(target_list.len)//Everything else is handled by the ninja mask proc. - O.assess_targets(target_list, src) - if(!druggy) see_invisible = SEE_INVISIBLE_LIVING - if(1) - see_in_dark = 5 - if(!druggy) see_invisible = SEE_INVISIBLE_LIVING - if(2) - sight |= SEE_MOBS - if(!druggy) see_invisible = SEE_INVISIBLE_LEVEL_TWO - if(3) - sight |= SEE_TURFS - if(!druggy) see_invisible = SEE_INVISIBLE_LIVING - + glasses_processed = 1 + process_glasses(O.ninja_vision.glasses) if(glasses) - var/obj/item/clothing/glasses/G = glasses - if(istype(G)) - see_in_dark += G.darkness_view - if(G.vision_flags) // MESONS - sight |= G.vision_flags - if(!druggy) - see_invisible = SEE_INVISIBLE_MINIMUM - if(istype(G,/obj/item/clothing/glasses/night)) - see_invisible = SEE_INVISIBLE_MINIMUM - client.screen += global_hud.nvg + glasses_processed = 1 + process_glasses(glasses) - /* HUD shit goes here, as long as it doesn't modify sight flags */ - // The purpose of this is to stop xray and w/e from preventing you from using huds -- Love, Doohl - - if(istype(glasses, /obj/item/clothing/glasses/sunglasses/sechud)) - var/obj/item/clothing/glasses/sunglasses/sechud/O = glasses - if(O.hud) O.hud.process_hud(src) - if(!druggy) see_invisible = SEE_INVISIBLE_LIVING - else if(istype(glasses, /obj/item/clothing/glasses/hud)) - var/obj/item/clothing/glasses/hud/O = glasses - O.process_hud(src) - if(!druggy) - see_invisible = SEE_INVISIBLE_LIVING - - else if(!seer) + if(!seer && !glasses_processed) see_invisible = SEE_INVISIBLE_LIVING - - if(healths) if (analgesic) healths.icon_state = "health_health_numb" @@ -1491,6 +1452,29 @@ reset_view(null) return 1 + proc/process_glasses(var/obj/item/clothing/glasses/G) + if(G && G.active) + see_in_dark += G.darkness_view + if(G.overlay) + client.screen |= G.overlay + if(G.vision_flags) + sight |= G.vision_flags + if(!druggy) + see_invisible = SEE_INVISIBLE_MINIMUM + if(istype(G,/obj/item/clothing/glasses/night)) + see_invisible = SEE_INVISIBLE_MINIMUM + /* HUD shit goes here, as long as it doesn't modify sight flags */ + // The purpose of this is to stop xray and w/e from preventing you from using huds -- Love, Doohl + if(istype(G, /obj/item/clothing/glasses/sunglasses/sechud)) + var/obj/item/clothing/glasses/sunglasses/sechud/O = G + if(O.hud) O.hud.process_hud(src) + if(!druggy) see_invisible = SEE_INVISIBLE_LIVING + else if(istype(G, /obj/item/clothing/glasses/hud)) + var/obj/item/clothing/glasses/hud/O = G + O.process_hud(src) + if(!druggy) + see_invisible = SEE_INVISIBLE_LIVING + proc/handle_random_events() // Puke if toxloss is too high if(!stat) diff --git a/icons/obj/hud_full.dmi b/icons/obj/hud_full.dmi new file mode 100644 index 0000000000000000000000000000000000000000..83a768d515e237eb1c7bba7ab4d26b7820b48ef3 GIT binary patch literal 5899 zcmeAS@N?(olHy`uVBq!ia0y~yU_JoC9Be?5U)Ka?1F6=kkcbkO)Z*l#%z~24{5%GR ziaEhy1x2ObzXTV2{Q5-8TUYDcne)LLLJck&KX{~b-beFf0FblM;K8Fa9%p^dYczi9 z@)q(A63r2v^6Av2$Hrd4Q+8Mc8+CU9MR;~vT<#Jo4pz+Bv1?M#l|^@s$Sk_@Y?;{e z=MRHdu6gk4`JxApUY}%T*vew^e$I-$F$@f1j-D=#Ar*7p-rOj7$U%VRV0D+0rIL!~ zPnQJ}DUM=Q$-9&z%CoM&Hh<5^kXO3avOJ%mVb<|?j6kmxuru;7FgP?Z0KKQ+$iU3N zFhQXKDB&Rh^fiMDM*@%(Vle=coJ%|BjR4!sfKTyV48`jxmomgAV{(`J*lV(Z0}VA{gxukCp_Zqavf#!DyRc fv`sJ~20ZJhSnzzwERUQE%<~MMu6{1-oD!M