add sborka
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
include("shared.lua")
|
||||
local posX = {
|
||||
0.29,
|
||||
0.5,
|
||||
0.71,
|
||||
0.71,
|
||||
0.71,
|
||||
0.5,
|
||||
0.29,
|
||||
0.29,
|
||||
}
|
||||
local posY = {
|
||||
0.29,
|
||||
0.29,
|
||||
0.29,
|
||||
0.5,
|
||||
0.71,
|
||||
0.71,
|
||||
0.71,
|
||||
0.5,
|
||||
}
|
||||
local COLOR_GREEN = Color(0,255,0,255)
|
||||
local COLOR_BLACK = Color(0,0,0,255)
|
||||
local COLOR_WHITE = Color(255,255,255,255)
|
||||
local COLOR_WHITE_HOVERED = Color(200,200,200,150)
|
||||
local HOOK_ADDED = false
|
||||
local LANGUAGE
|
||||
local ints = {
|
||||
[8] = 1,
|
||||
[2] = 2,
|
||||
[4] = 3,
|
||||
}
|
||||
local function DrawCircle( X, Y, radius )
|
||||
local segmentdist = 360 / ( 2 * math.pi * radius / 2 )
|
||||
for a = 0, 360, segmentdist do
|
||||
surface.DrawLine( X + math.cos( math.rad( a ) ) * radius, Y - math.sin( math.rad( a ) ) * radius, X + math.cos( math.rad( a + segmentdist ) ) * radius, Y - math.sin( math.rad( a + segmentdist ) ) * radius )
|
||||
end
|
||||
end
|
||||
function SWEP:DrawHUD()
|
||||
local X = ScrW()
|
||||
local Y = ScrH()
|
||||
if self.Zoom.Val == 0 then
|
||||
local tr = self.Owner:GetEyeTrace()
|
||||
if IsValid(tr.Entity) and tr.StartPos:DistToSqr(tr.HitPos) < self.MaxPairDistance then
|
||||
if (tr.Entity.LVS or tr.Entity.LFS or (tr.Entity.SWBombV3 and tr.Entity.HaveGuidance)) and tr.Entity:GetNWBool("HaveDesignator") == false then
|
||||
if !IsValid(self:GetNWEntity("PairedObj")) then
|
||||
draw.DrawText("Click to pair designator","Trebuchet24",X*0.5,Y*0.25,color_white,TEXT_ALIGN_CENTER)
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if IsValid(self:GetNWEntity("Projectile")) then
|
||||
local Pos = self:GetNWVector("TarPos"):ToScreen()
|
||||
surface.SetDrawColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
DrawCircle( Pos.x, Pos.y, 10 )
|
||||
local Pos2 = self:GetNWEntity("Projectile"):GetPos():ToScreen()
|
||||
surface.SetDrawColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
surface.SetMaterial(Material("icons/mis.png"))
|
||||
surface.DrawTexturedRect(Pos2.x,Pos2.y,25,25)
|
||||
end
|
||||
if IsValid(self:GetNWEntity("PairedObj")) and self:GetNWEntity("PairedObj").SWBombV3 then
|
||||
local Pos = self:GetNWVector("TarPos"):ToScreen()
|
||||
surface.SetDrawColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
DrawCircle( Pos.x, Pos.y, 10 )
|
||||
local Pos2 = self:GetNWEntity("PairedObj"):GetPos():ToScreen()
|
||||
surface.SetDrawColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
surface.SetMaterial(Material("icons/mis.png"))
|
||||
surface.DrawTexturedRect(Pos2.x,Pos2.y,25,25)
|
||||
end
|
||||
if IsValid(self:GetNWEntity("PairedObj")) and not self:GetNWEntity("PairedObj").SWBombV3 then
|
||||
local Pos = self:GetNWEntity("PairedObj"):GetPos():ToScreen()
|
||||
surface.SetDrawColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
surface.SetMaterial(Material("icons/plane.png"))
|
||||
surface.DrawTexturedRect(Pos.x,Pos.y,25,25)
|
||||
end
|
||||
surface.SetDrawColor(0,0,0,self.Zoom.Val*255)
|
||||
surface.SetTexture(surface.GetTextureID("models/sw/shared/sights/binoculars"))
|
||||
surface.DrawTexturedRect(0,-(X-Y)/2,X,X)
|
||||
local tr = self.Owner:GetEyeTrace()
|
||||
local range = (math.ceil(100*(tr.StartPos:Distance(tr.HitPos)*0.024))/100)
|
||||
if tr.HitSky then
|
||||
range = "-"
|
||||
else
|
||||
range = range.."m"
|
||||
end
|
||||
surface.SetTextColor( 255, 255, 255, self.Zoom.Val*255 )
|
||||
surface.SetTextPos( (X*0.165), (Y/2) )
|
||||
surface.DrawText( "Range: "..range )
|
||||
surface.SetTextPos( (X*0.165), (Y/2) + 16)
|
||||
surface.DrawText( "X: "..(math.ceil(100*tr.HitPos.x))/100)
|
||||
surface.SetTextPos( (X*0.165), (Y/2) + 32)
|
||||
surface.DrawText( "Y: "..(math.ceil(100*tr.HitPos.y)/100) )
|
||||
surface.SetTextPos( (X*0.165), (Y/2) + 48)
|
||||
surface.DrawText( "Z: "..(math.ceil(100*tr.HitPos.z)/100) )
|
||||
|
||||
if self:GetNWBool("NVG") == true then
|
||||
surface.SetTextPos( (X*0.165), (Y/2) + 64)
|
||||
surface.DrawText( "NVG: ON" )
|
||||
local dlight = DynamicLight(self:EntIndex())
|
||||
dlight.r = self.Zoom.Val*255
|
||||
dlight.g = self.Zoom.Val*255
|
||||
dlight.b = self.Zoom.Val*255
|
||||
dlight.minlight = 0
|
||||
dlight.style = 0
|
||||
dlight.Brightness = self.Zoom.Val*0.1
|
||||
dlight.Pos = EyePos()
|
||||
dlight.Size = self.Zoom.Val*2048
|
||||
dlight.Decay = self.Zoom.Val*10000
|
||||
dlight.DieTime = CurTime() + 0.1
|
||||
local mat_color = Material( "pp/colour" )
|
||||
render.UpdateScreenEffectTexture()
|
||||
mat_color:SetTexture( "$fbtexture", render.GetScreenEffectTexture() )
|
||||
mat_color:SetFloat( "$pp_colour_addr", -self.Zoom.Val*255 )
|
||||
mat_color:SetFloat( "$pp_colour_addg", 0 )
|
||||
mat_color:SetFloat( "$pp_colour_addb", 0)
|
||||
mat_color:SetFloat( "$pp_colour_mulr", 0 )
|
||||
mat_color:SetFloat( "$pp_colour_mulg", 0 )
|
||||
mat_color:SetFloat( "$pp_colour_mulb", 0 )
|
||||
mat_color:SetFloat( "$pp_colour_brightness", self.Zoom.Val*0.01 )
|
||||
mat_color:SetFloat( "$pp_colour_contrast", 1+self.Zoom.Val*5 )
|
||||
mat_color:SetFloat( "$pp_colour_colour", 1 )
|
||||
render.SetMaterial( mat_color )
|
||||
render.DrawScreenQuad()
|
||||
DrawBloom(self.Zoom.Val*0.5,self.Zoom.Val*1,self.Zoom.Val*10,self.Zoom.Val*10,self.Zoom.Val*2,self.Zoom.Val*1,self.Zoom.Val*1,self.Zoom.Val*1,self.Zoom.Val*1)
|
||||
else
|
||||
surface.SetTextPos( (X*0.165), (Y/2) + 64)
|
||||
surface.DrawText( "NVG: OFF" )
|
||||
end
|
||||
end
|
||||
function SWEP:CalcView(ply,pos,ang,fov)
|
||||
return pos,ang,fov - (self.Zoom.Val * self.Zoom.FOV)
|
||||
end
|
||||
function SWEP:AdjustMouseSensitivity()
|
||||
return self.Owner:KeyDown(IN_ATTACK2) and 0.1 or 1
|
||||
end
|
||||
function SWEP:CalcViewModelView(ViewModel,OldEyePos)
|
||||
if self.Zoom.Val > 0.8 then
|
||||
return Vector(0,0,0)
|
||||
else
|
||||
return OldEyePos - Vector(0,0,1.3)
|
||||
end
|
||||
end
|
||||
function SWEP:Think()
|
||||
local keydown = self.Owner:KeyDown(IN_ATTACK2)
|
||||
self.Zoom.Val = math.Clamp(self.Zoom.Val + (keydown and self.Zoom.Rate or -self.Zoom.Rate),0,1)
|
||||
if keydown and not self.IsZooming then
|
||||
self.IsZooming = true
|
||||
self.IsUnZooming = false
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
|
||||
elseif !keydown and not self.IsUnZooming and self.IsZooming then
|
||||
self.IsZooming = false
|
||||
self.IsUnZooming = true
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
|
||||
end
|
||||
if keydown then
|
||||
local Zoom = self.Zoom.FOV
|
||||
local ZoomSwitch = self.Owner:KeyDown(IN_SPEED)
|
||||
if self.OldZoomSwitch ~= ZoomSwitch then
|
||||
if ZoomSwitch and Zoom == 70 then
|
||||
self.Zoom.FOV = 40
|
||||
elseif ZoomSwitch and Zoom == 40 then
|
||||
self.Zoom.FOV = 70
|
||||
end
|
||||
self.OldZoomSwitch = ZoomSwitch
|
||||
end
|
||||
local NVGSwitch = self.Owner:KeyDown(IN_ZOOM)
|
||||
if self.OldNVGSwitch ~= NVGSwitch then
|
||||
if NVGSwitch and self:GetNWBool("NVG") == true then
|
||||
self:SetNWBool("NVG",false)
|
||||
self:EmitSound("sw/misc/nv_off.wav")
|
||||
elseif NVGSwitch and self:GetNWBool("NVG") == false then
|
||||
self:SetNWBool("NVG",true)
|
||||
self:EmitSound("sw/misc/nv_on.wav")
|
||||
end
|
||||
self.OldNVGSwitch = NVGSwitch
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,64 @@
|
||||
include("shared.lua")
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
|
||||
function SWEP:PrimaryAttack()
|
||||
if self.Owner:KeyDown(IN_ATTACK2) then
|
||||
if IsValid(self:GetNWEntity("PairedObj")) then
|
||||
if self:GetNWEntity("PairedObj").SWBombV3 and self:GetNWEntity("PairedObj").HaveGuidance then
|
||||
local tr = self.Owner:GetEyeTrace()
|
||||
self:GetNWEntity("PairedObj").GuidanceActive = true
|
||||
self:GetNWEntity("PairedObj").target = tr.Entity
|
||||
self:GetNWEntity("PairedObj").targetOffset = tr.Entity:WorldToLocal(tr.HitPos)
|
||||
self:SetNWVector("TarPos", tr.HitPos )
|
||||
self:EmitSound("sw/misc/point.wav")
|
||||
print(tr.HitPos)
|
||||
end
|
||||
if IsValid(self:GetNWEntity("PairedObj"):GetNWEntity("Missile")) then
|
||||
if self:GetNWEntity("PairedObj"):GetNWEntity("Missile").SWBombV3 and self:GetNWEntity("PairedObj"):GetNWEntity("Missile").HaveGuidance then
|
||||
local tr = self.Owner:GetEyeTrace()
|
||||
self:SetNWEntity("Projectile",self:GetNWEntity("PairedObj"):GetNWEntity("Missile"))
|
||||
self:GetNWEntity("PairedObj"):GetNWEntity("Missile").GuidanceActive = true
|
||||
self:GetNWEntity("PairedObj"):GetNWEntity("Missile").LaserGuided = false
|
||||
self:GetNWEntity("PairedObj"):GetNWEntity("Missile").target = tr.Entity
|
||||
self:GetNWEntity("PairedObj"):GetNWEntity("Missile").targetOffset = tr.Entity:WorldToLocal(tr.HitPos)
|
||||
self:SetNWVector("TarPos", tr.HitPos )
|
||||
self:EmitSound("sw/misc/point.wav")
|
||||
print(tr.HitPos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.Owner:KeyDown(IN_ATTACK2) then return end
|
||||
local tr = self.Owner:GetEyeTrace()
|
||||
if IsValid(tr.Entity) and tr.StartPos:DistToSqr(tr.HitPos) < self.MaxPairDistance then
|
||||
if ((tr.Entity.LVS or tr.Entity.LFS) and tr.Entity.Pairable ) or (tr.Entity.SWBombV3 and tr.Entity.HaveGuidance) then
|
||||
if !IsValid(self:GetNWEntity("PairedObj")) then
|
||||
tr.Entity:SetNWBool("HaveDesignator",true)
|
||||
self:SetNWEntity("PairedObj",tr.Entity)
|
||||
self:SetNWBool("Paired",true)
|
||||
self.Owner:PrintMessage(HUD_PRINTCENTER,"You have paired target designator with:"..self:GetNWEntity("PairedObj").PrintName)
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function SWEP:SecondaryAttack()
|
||||
end
|
||||
function SWEP:CanReload(ct)
|
||||
return self.NextReload <= ct
|
||||
end
|
||||
function SWEP:Reload()
|
||||
local ct = CurTime()
|
||||
if not self:CanReload(ct) then return end
|
||||
self.NextReload = ct + 0.3
|
||||
end
|
||||
function SWEP:OnRemove()
|
||||
if IsValid(self) and IsValid(self:GetNWEntity("PairedObj")) then
|
||||
self:GetNWEntity("PairedObj"):SetNWBool("HaveDesignator",false)
|
||||
self:SetNWEntity("PairedObj",nil)
|
||||
self:SetNWBool("Paired",false)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,98 @@
|
||||
AddCSLuaFile()
|
||||
SWEP.Base = "weapon_base"
|
||||
SWEP.Spawnable = true
|
||||
SWEP.AdminSpawnable = false
|
||||
SWEP.MaxPairDistance = 500^2
|
||||
SWEP.Category = "SW Weapons Factory"
|
||||
SWEP.Author = "Shermann Wolf"
|
||||
SWEP.Contact = "shermannwolf@gmail.com"
|
||||
SWEP.Purpose = ""
|
||||
SWEP.Instructions = "Right click on bomb/missile/aircraft to pair it with your laser pointer,and left click to point target for it"
|
||||
SWEP.PrintName = "Laser target designator"
|
||||
SWEP.WorldModel = "models/sw/shared/weapons/w_binoculars.mdl"
|
||||
SWEP.ViewModel = "models/sw/shared/weapons/v_binoculars.mdl"
|
||||
SWEP.TarPos = nil
|
||||
SWEP.Primary = {
|
||||
Ammo = "None",
|
||||
ClipSize = -1,
|
||||
DefaultClip = -1,
|
||||
Automatic = false,
|
||||
NextShot = 0,
|
||||
FireRate = 0.00001
|
||||
}
|
||||
SWEP.Secondary = SWEP.Primary
|
||||
SWEP.NextReload = 0
|
||||
SWEP.DrawAmmo = false
|
||||
SWEP.Zoom = {}
|
||||
SWEP.Zoom.FOV = 70
|
||||
SWEP.Zoom.Rate = 0.035
|
||||
SWEP.Zoom.Val = 0
|
||||
SWEP.UseHands = true
|
||||
local pairs = pairs
|
||||
local IsValid = IsValid
|
||||
local CLIENT = CLIENT
|
||||
local SERVER = SERVER
|
||||
local SINGLEPLAYER = game.SinglePlayer()
|
||||
function SWEP:Deploy()
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
|
||||
return true
|
||||
end
|
||||
function SWEP:Initialize()
|
||||
self:SetNWEntity("PairedObj",nil)
|
||||
self:SetNWEntity("Projectile",nil)
|
||||
self:SetNWBool("Paired",false)
|
||||
self:SetHoldType("camera")
|
||||
end
|
||||
function SWEP:Holster(wep)
|
||||
return true
|
||||
end
|
||||
function SWEP:DrawHUD()
|
||||
surface.SetDrawColor(0,0,0,self.Zoom.Val*255)
|
||||
surface.SetTexture(surface.GetTextureID("models/sw/shared/sights/binoculars"))
|
||||
local X = ScrW()
|
||||
local Y = ScrH()
|
||||
surface.DrawTexturedRect(0,-(X-Y)/2,X,X)
|
||||
end
|
||||
function SWEP:CalcViewModelView(ViewModel,OldEyePos)
|
||||
if self.Zoom.Val > 0.8 then
|
||||
return Vector(0,0,0)
|
||||
else
|
||||
return OldEyePos - Vector(0,0,1.3)
|
||||
end
|
||||
end
|
||||
function SWEP:Think()
|
||||
local keydown = self.Owner:KeyDown(IN_ATTACK2)
|
||||
self.Zoom.Val = math.Clamp(self.Zoom.Val + (keydown and 0.1 or -0.1),0,1)
|
||||
if keydown and not self.IsZooming then
|
||||
self.IsZooming = true
|
||||
self.IsUnZooming = false
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
|
||||
elseif !keydown and not self.IsUnZooming and self.IsZooming then
|
||||
self.IsZooming = false
|
||||
self.IsUnZooming = true
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
|
||||
end
|
||||
end
|
||||
function SWEP:CalcView(ply,pos,ang,fov)
|
||||
fov = fov - (self.Zoom.Val*self.Zoom.FOV)
|
||||
return pos,ang,fov
|
||||
end
|
||||
function SWEP:AdjustMouseSensitivity()
|
||||
return self.Owner:KeyDown(IN_ATTACK2) and 0.1 or 1
|
||||
end
|
||||
function SWEP:CanPrimaryAttack(ct)
|
||||
return self.Primary.NextShot <= ct
|
||||
end
|
||||
function SWEP:PrimaryAttack()
|
||||
local ct = CurTime()
|
||||
if not self:CanPrimaryAttack(ct) then return end
|
||||
self.Primary.NextShot = ct + self.Primary.FireRate
|
||||
end
|
||||
function SWEP:CanSecondaryAttack(ct)
|
||||
end
|
||||
function SWEP:SecondaryAttack()
|
||||
end
|
||||
function SWEP:CanReload(ct)
|
||||
end
|
||||
function SWEP:Reload()
|
||||
end
|
||||
Reference in New Issue
Block a user