Skip to content

Commit

Permalink
Fixed issue #65
Browse files Browse the repository at this point in the history
CHANGED: The timer "night_check" is now set to 1 seconds
FIXED : "NV Goggles" and "IR Goggles" do not work properly at night
  • Loading branch information
Rémi Gaffet committed Jun 26, 2016
1 parent 9ce130d commit 6663358
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 51 deletions.
46 changes: 8 additions & 38 deletions DayZ/gui/gear/hud_gear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,15 @@ function playerActivateGoggles (key,keyState)
guiSetVisible(infravision,false)
showChat(true)
setCameraGoggleEffect("normal")
local hour, minutes = getTime()
if gameplayVariables["enablenight"] then
setClientNight (hour,minutes)
end
triggerEvent("onPlayerDisabledGoggles", getLocalPlayer())
else
nightvision = true
guiSetVisible(nightvisionimage,true)
guiSetVisible(infravision,false)
showChat(false)
setCameraGoggleEffect("nightvision")
setFarClipDistance(1000)
triggerEvent("onPlayerEnabledGoggles", getLocalPlayer())
end
end
elseif key == "i" then
Expand All @@ -298,49 +296,21 @@ function playerActivateGoggles (key,keyState)
guiSetVisible(nightvisionimage,false)
showChat(true)
setCameraGoggleEffect("normal")
if gameplayVariables["enablenight"] then
setClientNight (hour,minutes)
end
triggerEvent("onPlayerDisabledGoggles", getLocalPlayer())
else
infaredvision = true
guiSetVisible(infravision,true)
guiSetVisible(nightvisionimage,false)
showChat(false)
infaredvision = true
guiSetVisible(infravision,true)
guiSetVisible(nightvisionimage,false)
showChat(false)
setCameraGoggleEffect("thermalvision")
if gameplayVariables["enablenight"] then
setClientNight (hour,minutes)
end
triggerEvent("onPlayerEnabledGoggles", getLocalPlayer())
end
end
end
end
bindKey("n","down",playerActivateGoggles)
bindKey("i","up",playerActivateGoggles)

function setClientNight (hour,minutes)
if hour == 21 then
setSkyGradient(0, 100/minutes, 196/minutes, 136/minutes, 170/minutes, 212/minutes)
setFarClipDistance(120+(880-minutes*14.6))
setFogDistance(-150+(250-minutes*4.16))
elseif hour == 7 then
setSkyGradient( 0, 1.6*minutes, 196*3.26, 136*2.26, 170*2.83, 212*3.53 )
setFarClipDistance(120+(minutes*14.6))
setFogDistance(-150+(minutes*4.16))
elseif hour == 22 or hour == 23 then
setSkyGradient( 0, 0, 0, 0, 0, 0 )
setFarClipDistance(120)
setFogDistance(-150)
elseif hour >= 0 and hour <= 7 then
setSkyGradient( 0, 0, 0, 0, 0, 0 )
setFarClipDistance(120)
setFogDistance(-150)
else
setSkyGradient(0, 100, 196, 136, 170, 212)
setFarClipDistance(1000)
setFogDistance(100)
end
end

local sWidth,sHeight = guiGetScreenSize()
function WeaponHUD()
if getElementData(localPlayer,"logedin") then
Expand Down
41 changes: 29 additions & 12 deletions DayZ/handlers/world/client/night/c_night.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ local shaderList = {}
local fading = false
local clone

nightStatus = true

function onPlayerEnabledGoggles()
nightStatus = false
end
addEvent("onPlayerEnabledGoggles",true)
addEventHandler("onPlayerEnabledGoggles",root,onPlayerEnabledGoggles)


function onPlayerDisabledGoggles()
nightStatus = true
end
addEvent("onPlayerDisabledGoggles",true)
addEventHandler("onPlayerDisabledGoggles",root,onPlayerDisabledGoggles)

-- Feel free to add more removables.
local removables = {
'tx*',
Expand Down Expand Up @@ -61,21 +76,23 @@ function night_init()
end

addEventHandler('onClientHUDRender', root, night_render)
nightTimer = setTimer(night_check, 4000, 0)
nightTimer = setTimer(night_check, 1000, 0)
end

function night_check()
local hours, minutes = getTime()
if hours >= 5 and hours < 12 then
fading = false
elseif hours >= 12 and hours < 15 then
fading = false
elseif hours >= 15 and hours < 21 then
fading = false
elseif hours >= 21 and hours < 5 then
fading = false
else
fading = true
if nightStatus == true then
local hours, minutes = getTime()
if hours >= 5 and hours < 12 then
fading = false
elseif hours >= 12 and hours < 15 then
fading = false
elseif hours >= 15 and hours < 21 then
fading = false
elseif hours >= 21 and hours < 5 then
fading = false
else
fading = true
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This changelog lists all changes made to MTA DayZ. It adheres to the following f
### CHANGED: New animation binds (1 = Salute, 2 = Hands up, 3 = Sit, 5 = Journal)
### CHANGED: playerThirst and playerHunger calculation every 30 seconds instead of onClientRender
### CHANGED: The night is far less dark
### CHANGED: The timer "night_check" is now set to 4 seconds.
### CHANGED: The timer "night_check" is now set to 1 seconds
### DEPRECATED: For once-stable removed in upcoming releases
### REMOVED: For deprecated features removed in the release it's mentioned in
### FIXED: For all bugs
Expand All @@ -34,6 +34,7 @@ This changelog lists all changes made to MTA DayZ. It adheres to the following f
### FIXED: Patrol Pack bug
### FIXED: Black & White shader not loading
### FIXED : The player don't get damage if are submerged for along time
### FIXED : "NV Goggles" and "IR Goggles" do not work properly at night
### SECURITY: To invite users to upgrade in case of vulnerabilities
### LANGUAGE: Romanian is now available.

Expand Down

0 comments on commit 6663358

Please sign in to comment.