I was mucking around this afternoon and created a night vision scope and display system for a project I'm doing. I was going to put it in the store but not particularly interested in some of the seller conditions so I'd rather give the script away minus the gfx.
It uses my modified Text Compass script I did earlier as well as some goodies to make night shooting a little more.... advanced. Designed for use with or without a sniper scope as you can see from the images.
EDIT: Note that the vertical elevation on the right hand side and the compass actually work, they're not just eye-candy.
Enjoy.
PS: If rolfy or anyone wants me to incorporate this into rolfy's existing NV system I'm more than happy for it to happen or I'll do it if time permits.
-- Night Shooters AID (Advanced Information Display)
-- Code by SisterMatic - commercial use allowed - credits please
-- USAGE
-- Place an entity such as rock, tree etc. on map. assign THIS script in AI System: Main
-- Set General:Static Mode to "No"
-- Set Physics:Always Active? to "Yes"
-- NOTICE
-- THIS system has been designed for 1920 x 1080 resolution. You are more than welcome to modify for lower resolutions
-- but note that nearly ALL display text will need to be repositioned and in some cases recalculated.
-- RECOMMENDED
-- Use night and a night skybox for best effect
-- EDITS
-- For Night Shooters AID to be OFF by default change nvbinos_active to 0 (zero) in nvbinos_init function (currentl ON)
-- Key mapping is currently "o" for ON and "O" (shift + o) for OFF
-- BONUS SCOPING
-- This script has also been designed for additional use with the M700 Sniper Rifle. Bearing, elevation etc. remain visible when scoped.
-- When HUD is off -uncomment HideHuds()- weapon zoom will work with crosshairs - excellent for night sniper attacks.
-- ISSUES: As at April 25 2015
-- Minor elevation lag during scoping, does not appear to effect fps so not sure why it feels "laggy"
-- The term "binos" has been used because this is adapted from a night vision scope I created for a project. gfx not included with this script.
-- ADDITIONAL NOTES
-- With minor vertical text adjustments this script should/could work nicely with rolfy's animated night vision script. See store.
-- If rolfy offers permission, I'd be more than happy to adapt this script to fit.
local compass= {}
-- **************************
function ns_aid_init(e)
-- **************************
-- EDIT THIS FOR ON/OFF
nvbinos_active = 1 -- THIS can be changed - set to zero and change if you want user to "find" a compass for example
--uncomment this for great night vision zoom with a M700 Sniper rifle. (or any zoom weapon for that matter)
-- HideHuds()
-- ShowHuds()
defn_nvbinos() -- a little tidier than filling init
nvb_on = 0
end
-- **************************
function ns_aid_main(e)
-- **************************
-- this keypress part is *optional*. I use it to turn nightvision on/off via o, shift O (No. We can't use "C")
if g_InKey=="o" and nvbinos_active == 0 then
nvbinos_active=1
elseif g_InKey=="O" and nvbinos_active == 1 then
nvbinos_active=0
end
if nvbinos_active == 1 then
show_nvbinos()
end
end --function
--***********************************
-- THE BELOW SECTION SHOULD NOT NEED EDITING.
--***********************************
-- **************************
function show_nvbinos ()
-- **************************
local start=0
local compass_str=""
local bearing=0
-- most efficient way I can find to return a 360 limited bearing from player rotation
bearing = math.floor(math.fmod(g_PlayerAngY, 360))
-- hack due to negative Y angle on rotation - why devs?
if bearing < 0 then bearing=bearing+360 end
-- make sure we have full dimension on 10 degrees either side of actual bearing
if bearing < 45 then
start = 315 + bearing
else
start=bearing-45
end
local arraypos=start
-- 91 is one quater of compass and 1 added for the array offset so we don't go out of bounds
for i=1,91, 1 do
if arraypos==360 or arraypos<=0 then
arraypos=1 -- we reached end of table, reset
else
arraypos=arraypos+1
end
compass_str=compass_str..compass[arraypos]
end -- for
TextCenterOnXColor(50,22,2,"|",255,10,10)
TextCenterOnXColor(50,24,2,compass_str,10,255,10)
TextCenterOnXColor(50,26,2,"|",255,10,10)
TextCenterOnXColor(50,48,2,"|",10,255,10)
tmpstr="----^----"
TextCenterOnXColor(50,50,2,tmpstr,10,255,10)
-- now the player pos -- convert to metric if current measure is inches??
local x= (g_PlayerPosX*2.54)/1000
local y= (g_PlayerPosY*2.54)/100 -- inches to cm to m
local z= (g_PlayerPosZ*2.54)/1000
local str1=string.format("%.2f",x)
local str2=string.format("%.2f",z)
local str3=string.format("%.2f",y)
TextColor(60,60,2,"GPSystems [Active]",10,255,10)
TextColor(60,62,2,"X ["..str1.."] Z ["..str2.."]",10,192,10)
TextColor(60,64,2,"Bearing ["..bearing.."]",10,192,10)
TextColor(60,66,2,"Elevation ["..str3.."m]",10,192,10)
TextColor(40,60,2,"Status",10,255,10)
TextColor(40,62,2,"Health ["..g_PlayerHealth.."]",10,192,10)
TextColor(40,64,2,"Lives ["..g_PlayerLives.."]",10,192,10)
-- do the vertical elev display
local deg=g_PlayerAngX*-1
TextCenterOnXColor(50,52,2,bearing,10,192,10)
TextColor(69,50,2,"<",255,10,10)
for i=35,65, 1 do
disp= math.ceil(deg)-i+50
if math.fmod(disp,5) == 0 then
TextColor(68,i,2,disp,10,192,10)
else
TextColor(68,i,2,"-",10,192,10)
end
end -- for
end -- show
-- **************************
function defn_nvbinos()
-- **************************
-- called once only at init()
-- note that we need to offset the array by 1 because we can't have 0 as an array ref.
for i=1, 360, 1 do
if i == 1 then compass[i] = "N"
elseif i == 46 then compass[i] = "NE"
elseif i == 91 then compass[i] = "E"
elseif i == 136 then compass[i] = "SE"
elseif i == 181 then compass[i] = "S"
elseif i == 226 then compass[i] = "SW"
elseif i == 271 then compass[i] = "W"
elseif i == 316 then compass[i] = "NW"
-- pad out the non cardinals - suit yourself but watch the panel display sizing - I use | for every 10 and . for in between
elseif math.fmod(i,10) == 1 then
compass[i] = "|"
else
compass[i] = " "
end
end -- for
end -- defn
E&OE - subject to edit
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD