mirror of
https://github.com/HaodongMo/ARC-9.git
synced 2025-03-04 03:02:58 -05:00
IR lasers & flashlights in mw, arctic, jmod nvgs
This commit is contained in:
parent
58a71fbf84
commit
541c9cf66e
@ -2,12 +2,38 @@ local defaulttracemat = Material("arc9/laser2")
|
|||||||
local defaultflaremat = Material("sprites/light_glow02_add", "mips smooth")
|
local defaultflaremat = Material("sprites/light_glow02_add", "mips smooth")
|
||||||
local lasercolorred = Color(255, 0, 0)
|
local lasercolorred = Color(255, 0, 0)
|
||||||
local lasercolor200 = Color(200, 200, 200)
|
local lasercolor200 = Color(200, 200, 200)
|
||||||
|
local irlasercolor = Color(106, 255, 218)
|
||||||
|
|
||||||
|
local function checknvg(wpn)
|
||||||
|
local lp = LocalPlayer()
|
||||||
|
if lp.quadnodsonlight or lp:GetNWBool("nvg_on", false) then return true end -- arctic nvgs and mw nvgs
|
||||||
|
if lp.EZarmor and lp.EZarmor.effects and lp.EZarmor.effects.nightVision then return true end -- jmod
|
||||||
|
local sight = wpn:GetSight()
|
||||||
|
if sight and wpn:GetSightAmount() > 0.8 and !wpn.Peeking and sight.atttbl and sight.atttbl.RTScopeNightVision then return true end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function SWEP:DrawLaser(pos, dir, atttbl, behav)
|
function SWEP:DrawLaser(pos, dir, atttbl, behav)
|
||||||
behav = behav or false
|
behav = behav or false
|
||||||
local strength = atttbl.LaserStrength or 1
|
local strength = atttbl.LaserStrength or 1
|
||||||
local flaremat = atttbl.LaserFlareMat or defaultflaremat
|
local flaremat = atttbl.LaserFlareMat or defaultflaremat
|
||||||
local lasermat = atttbl.LaserTraceMat or defaulttracemat
|
local lasermat = atttbl.LaserTraceMat or defaulttracemat
|
||||||
|
|
||||||
|
local width = math.Rand(0.1, 0.5) * strength
|
||||||
|
|
||||||
|
local nvgon
|
||||||
|
if atttbl.LaserIR then
|
||||||
|
nvgon = checknvg(self)
|
||||||
|
if nvgon then
|
||||||
|
width = width + 0.25
|
||||||
|
strength = strength + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if strength == 0 then return end
|
||||||
|
|
||||||
local owner = self:GetOwner()
|
local owner = self:GetOwner()
|
||||||
|
|
||||||
local dist = 5000
|
local dist = 5000
|
||||||
@ -21,8 +47,6 @@ function SWEP:DrawLaser(pos, dir, atttbl, behav)
|
|||||||
|
|
||||||
if tr.StartSolid then return end
|
if tr.StartSolid then return end
|
||||||
|
|
||||||
local width = math.Rand(0.1, 0.5) * strength
|
|
||||||
|
|
||||||
local hit = tr.Hit
|
local hit = tr.Hit
|
||||||
local hitpos = tr.HitPos
|
local hitpos = tr.HitPos
|
||||||
|
|
||||||
@ -75,6 +99,10 @@ function SWEP:DrawLaser(pos, dir, atttbl, behav)
|
|||||||
|
|
||||||
if (atttbl.LaserColorPlayer or atttbl.LaserPlayerColor) then color = colorplayer or color end
|
if (atttbl.LaserColorPlayer or atttbl.LaserPlayerColor) then color = colorplayer or color end
|
||||||
|
|
||||||
|
if nvgon and atttbl.LaserIR then
|
||||||
|
color = irlasercolor
|
||||||
|
end
|
||||||
|
|
||||||
if !behav then
|
if !behav then
|
||||||
render.SetMaterial(lasermat)
|
render.SetMaterial(lasermat)
|
||||||
render.DrawBeam(pos, laspos, width * 0.2, 0, fraction, lasercolor200)
|
render.DrawBeam(pos, laspos, width * 0.2, 0, fraction, lasercolor200)
|
||||||
@ -122,6 +150,7 @@ function SWEP:DrawLasers(wm, behav)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local wmnotdrawn = wm and self.LastWMDrawn != UnPredictedCurTime() and owner != lp
|
local wmnotdrawn = wm and self.LastWMDrawn != UnPredictedCurTime() and owner != lp
|
||||||
|
local nvgon = checknvg(self)
|
||||||
|
|
||||||
for _, model in ipairs(mdl) do
|
for _, model in ipairs(mdl) do
|
||||||
local slottbl = model.slottbl
|
local slottbl = model.slottbl
|
||||||
@ -135,8 +164,14 @@ function SWEP:DrawLasers(wm, behav)
|
|||||||
model:SetAngles(ang)
|
model:SetAngles(ang)
|
||||||
|
|
||||||
local a
|
local a
|
||||||
|
if wmnotdrawn then
|
||||||
if atttbl.LaserAttachment then
|
a = {
|
||||||
|
Pos = pos,
|
||||||
|
Ang = ang
|
||||||
|
}
|
||||||
|
|
||||||
|
a.Ang:RotateAroundAxis(a.Ang:Up(), -90)
|
||||||
|
elseif atttbl.LaserAttachment then
|
||||||
a = model:GetAttachment(atttbl.LaserAttachment)
|
a = model:GetAttachment(atttbl.LaserAttachment)
|
||||||
else
|
else
|
||||||
a = {
|
a = {
|
||||||
@ -148,7 +183,6 @@ function SWEP:DrawLasers(wm, behav)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !a then return end
|
if !a then return end
|
||||||
if wmnotdrawn then a.Pos, a.Ang = pos, ang end
|
|
||||||
|
|
||||||
local lasercorrectionangle = model.LaserCorrectionAngle
|
local lasercorrectionangle = model.LaserCorrectionAngle
|
||||||
local lasang = a.Ang
|
local lasang = a.Ang
|
||||||
@ -165,8 +199,14 @@ function SWEP:DrawLasers(wm, behav)
|
|||||||
local colorplayer = !owner:IsNPC() and owner:GetWeaponColor():ToColor()
|
local colorplayer = !owner:IsNPC() and owner:GetWeaponColor():ToColor()
|
||||||
|
|
||||||
if (atttbl.LaserColorPlayer or atttbl.LaserPlayerColor) then color = colorplayer or color end
|
if (atttbl.LaserColorPlayer or atttbl.LaserPlayerColor) then color = colorplayer or color end
|
||||||
|
|
||||||
|
local flaresize = 0.075
|
||||||
|
if atttbl.LaserIR then
|
||||||
|
flaresize = 0
|
||||||
|
if nvgon then flaresize = 0.2 color = irlasercolor end
|
||||||
|
end
|
||||||
|
|
||||||
self:DrawLightFlare(a.Pos, lasang, color, 0.075, !wm, false, -lasang:Right())
|
self:DrawLightFlare(a.Pos, lasang, color, flaresize, !wm, false, -lasang:Right())
|
||||||
|
|
||||||
if !wm or owner == lp or wm and owner:IsNPC() then
|
if !wm or owner == lp or wm and owner:IsNPC() then
|
||||||
if behav then
|
if behav then
|
||||||
@ -175,7 +215,7 @@ function SWEP:DrawLasers(wm, behav)
|
|||||||
self:DrawLaser(a.Pos, -lasang:Right(), atttbl, behav)
|
self:DrawLaser(a.Pos, -lasang:Right(), atttbl, behav)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:DrawLaser(a.Pos, self:GetShootDir():Forward(), atttbl, behav)
|
self:DrawLaser(a.Pos, -lasang:Right(), atttbl, behav)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,14 +11,29 @@ function SWEP:GetHasFlashlights()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local nvgon = false
|
||||||
|
local function checknvg(wpn) -- this func a bit different than what in cl_laser
|
||||||
|
local lp = LocalPlayer()
|
||||||
|
if lp.quadnodsonlight or lp:GetNWBool("nvg_on", false) then return true end -- arctic nvgs and mw nvgs
|
||||||
|
if lp.EZarmor and lp.EZarmor.effects and lp.EZarmor.effects.nightVision then return true end -- jmod
|
||||||
|
local sight = wpn:GetSight()
|
||||||
|
if sight and wpn:GetSightAmount() > 0.8 and !wpn.Peeking and sight.atttbl and sight.atttbl.RTScopeNightVision and ARC9.RTScopeRender then return true end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local arc9_allflash = GetConVar("arc9_allflash")
|
local arc9_allflash = GetConVar("arc9_allflash")
|
||||||
|
|
||||||
|
local irflashcolor = Color(106, 255, 218)
|
||||||
|
|
||||||
function SWEP:CreateFlashlights()
|
function SWEP:CreateFlashlights()
|
||||||
self:KillFlashlights()
|
self:KillFlashlights()
|
||||||
self.Flashlights = {}
|
self.Flashlights = {}
|
||||||
|
|
||||||
local total_lights = 0
|
local total_lights = 0
|
||||||
|
local lp = LocalPlayer()
|
||||||
|
nvgon = checknvg(self)
|
||||||
|
|
||||||
for _, k in ipairs(self:GetSubSlotList()) do
|
for _, k in ipairs(self:GetSubSlotList()) do
|
||||||
if !k.Installed then continue end
|
if !k.Installed then continue end
|
||||||
local atttbl = self:GetFinalAttTable(k)
|
local atttbl = self:GetFinalAttTable(k)
|
||||||
@ -33,6 +48,11 @@ function SWEP:CreateFlashlights()
|
|||||||
nodotter = atttbl.Flashlight360
|
nodotter = atttbl.Flashlight360
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nvgon and atttbl.FlashlightIR then
|
||||||
|
newlight.col = irflashcolor
|
||||||
|
newlight.br = 1
|
||||||
|
end
|
||||||
|
|
||||||
total_lights = total_lights + 1
|
total_lights = total_lights + 1
|
||||||
|
|
||||||
local l = newlight.light
|
local l = newlight.light
|
||||||
@ -52,6 +72,16 @@ function SWEP:CreateFlashlights()
|
|||||||
l:SetColor(atttbl.FlashlightColor or color_white)
|
l:SetColor(atttbl.FlashlightColor or color_white)
|
||||||
l:SetTexture(atttbl.FlashlightMaterial or "effects/flashlight001")
|
l:SetTexture(atttbl.FlashlightMaterial or "effects/flashlight001")
|
||||||
l:SetBrightness(atttbl.FlashlightBrightness or 3)
|
l:SetBrightness(atttbl.FlashlightBrightness or 3)
|
||||||
|
|
||||||
|
|
||||||
|
if nvgon and atttbl.FlashlightIR then
|
||||||
|
l:SetFOV((atttbl.FlashlightFOV or 50) * 1.5)
|
||||||
|
l:SetFarZ(2048)
|
||||||
|
l:SetColor(irflashcolor)
|
||||||
|
-- l:SetTexture(atttbl.FlashlightMaterial or "effects/flashlight001")
|
||||||
|
l:SetBrightness(1)
|
||||||
|
end
|
||||||
|
|
||||||
l:SetEnableShadows(true)
|
l:SetEnableShadows(true)
|
||||||
l:Update()
|
l:Update()
|
||||||
|
|
||||||
@ -64,7 +94,7 @@ function SWEP:CreateFlashlights()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if total_lights > 1 or (arc9_allflash:GetBool() and self:GetOwner() != LocalPlayer()) then -- you are a madman
|
if total_lights > 1 or (arc9_allflash:GetBool() and self:GetOwner() != lp) then -- you are a madman
|
||||||
for i, k in ipairs(self.Flashlights) do
|
for i, k in ipairs(self.Flashlights) do
|
||||||
if k.light:IsValid() then k.light:SetEnableShadows(false) end
|
if k.light:IsValid() then k.light:SetEnableShadows(false) end
|
||||||
end
|
end
|
||||||
@ -101,10 +131,13 @@ function SWEP:DrawFlashlightsWM()
|
|||||||
if isotherplayer and lp:EyePos():DistToSqr(owner:EyePos()) > 2048^2 then self:KillFlashlights() return end
|
if isotherplayer and lp:EyePos():DistToSqr(owner:EyePos()) > 2048^2 then self:KillFlashlights() return end
|
||||||
local wmnotdrawn = self.LastWMDrawn != UnPredictedCurTime() and isotherplayer
|
local wmnotdrawn = self.LastWMDrawn != UnPredictedCurTime() and isotherplayer
|
||||||
|
|
||||||
|
local anydrawn = false
|
||||||
for i, k in ipairs(self.Flashlights) do
|
for i, k in ipairs(self.Flashlights) do
|
||||||
local model = (k.slottbl or {}).WModel
|
local model = (k.slottbl or {}).WModel
|
||||||
|
|
||||||
-- if !IsValid(model) then continue end
|
-- if !IsValid(model) then continue end
|
||||||
|
anydrawn = true
|
||||||
|
if k.br == 0 then continue end
|
||||||
|
|
||||||
local pos, ang
|
local pos, ang
|
||||||
|
|
||||||
@ -148,6 +181,10 @@ function SWEP:DrawFlashlightsWM()
|
|||||||
k.light:SetAngles(ang)
|
k.light:SetAngles(ang)
|
||||||
k.light:Update()
|
k.light:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if anydrawn and nvgon != checknvg(self) then
|
||||||
|
self:CreateFlashlights()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:DrawFlashlightsVM()
|
function SWEP:DrawFlashlightsVM()
|
||||||
@ -159,10 +196,13 @@ function SWEP:DrawFlashlightsVM()
|
|||||||
local lp = LocalPlayer()
|
local lp = LocalPlayer()
|
||||||
local eyepos = owner:EyePos()
|
local eyepos = owner:EyePos()
|
||||||
|
|
||||||
|
local anydrawn = false
|
||||||
for i, k in ipairs(self.Flashlights) do
|
for i, k in ipairs(self.Flashlights) do
|
||||||
local model = (k.slottbl or {}).VModel
|
local model = (k.slottbl or {}).VModel
|
||||||
|
|
||||||
if !IsValid(model) then continue end
|
if !IsValid(model) then continue end
|
||||||
|
anydrawn = true
|
||||||
|
if k.br == 0 then continue end
|
||||||
|
|
||||||
local pos, ang
|
local pos, ang
|
||||||
|
|
||||||
@ -210,6 +250,10 @@ function SWEP:DrawFlashlightsVM()
|
|||||||
k.light:SetAngles(ang)
|
k.light:SetAngles(ang)
|
||||||
k.light:Update()
|
k.light:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if anydrawn and nvgon != checknvg(self) then
|
||||||
|
self:CreateFlashlights()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local flaremat = Material("effects/arc9_lensflare", "mips smooth")
|
local flaremat = Material("effects/arc9_lensflare", "mips smooth")
|
||||||
|
Loading…
Reference in New Issue
Block a user