add sborka

This commit is contained in:
2026-03-31 10:27:04 +03:00
commit f5e5f56c84
2345 changed files with 382127 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
include("shared.lua")
include("sh_turret.lua")
include("entities/lvs_tank_wheeldrive/modules/cl_tankview.lua")
include("cl_optics.lua")
function ENT:TankViewOverride( ply, pos, angles, fov, pod )
if ply == self:GetDriver() then
if pod:GetThirdPersonMode() then
pos = self:LocalToWorld( Vector(35,0,40) )
else
local vieworigin, found = self:GetTurretViewOrigin()
if found then pos = vieworigin end
end
end
return pos, angles, fov
end
function ENT:UpdatePoseParameters( steer, speed_kmh, engine_rpm, throttle, brake, handbrake, clutch, gear, temperature, fuel, oil, ammeter )
local Prongs = self:GetProngs()
local T = CurTime()
if Prongs then self._ProngTime = T + 1 end
local ProngsActive = (self._ProngTime or 0) > T
self:SetPoseParameter( "prong", self:QuickLerp( "prong", (ProngsActive and 1 or 0), 10 ) )
end

View File

@@ -0,0 +1,133 @@
ENT.OpticsFov = 30
ENT.OpticsEnable = true
ENT.OpticsZoomOnly = true
ENT.OpticsFirstPerson = true
ENT.OpticsThirdPerson = false
ENT.OpticsPodIndex = {
[1] = true,
}
ENT.OpticsProjectileSize = 7.5
local RotationOffset = 0
local circle = Material( "lvs/circle_hollow.png" )
local tri1 = Material( "lvs/triangle1.png" )
local tri2 = Material( "lvs/triangle2.png" )
local pointer = Material( "gui/point.png" )
local scope = Material( "lvs/scope_viewblocked.png" )
function ENT:PaintOpticsCrosshair( Pos2D )
surface.SetDrawColor( 255, 255, 255, 5 )
surface.SetMaterial( tri1 )
surface.DrawTexturedRect( Pos2D.x - 17, Pos2D.y - 1, 32, 32 )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawTexturedRect( Pos2D.x - 16, Pos2D.y, 32, 32 )
for i = -3, 3, 1 do
if i == 0 then continue end
surface.SetMaterial( tri2 )
surface.SetDrawColor( 255, 255, 255, 5 )
surface.DrawTexturedRect( Pos2D.x - 11 + i * 32, Pos2D.y - 1, 20, 20 )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawTexturedRect( Pos2D.x - 10 + i * 32, Pos2D.y, 20, 20 )
end
local ScrH = ScrH()
local Y = Pos2D.y + 64
local height = ScrH - Y
surface.SetDrawColor( 0, 0, 0, 100 )
surface.DrawRect( Pos2D.x - 2, Y, 4, height )
end
ENT.OpticsCrosshairMaterial = Material( "lvs/circle_filled.png" )
ENT.OpticsCrosshairColor = Color(0,0,0,150)
ENT.OpticsCrosshairSize = 4
function ENT:PaintOptics( Pos2D, Col, PodIndex, Type )
if Type == 1 then
self:DrawRotatedText( "MG", Pos2D.x + 30, Pos2D.y + 30, "LVS_FONT_PANEL", Color(0,0,0,220), 0)
else
self:DrawRotatedText( Type == 3 and "HE" or "AP", Pos2D.x + 30, Pos2D.y + 30, "LVS_FONT_PANEL", Color(0,0,0,220), 0)
end
local size = self.OpticsCrosshairSize
surface.SetMaterial( self.OpticsCrosshairMaterial )
surface.SetDrawColor( self.OpticsCrosshairColor )
surface.DrawTexturedRect( Pos2D.x - size * 0.5, Pos2D.y - size * 0.5, size, size )
local ScrW = ScrW()
local ScrH = ScrH()
surface.SetDrawColor( 0, 0, 0, 200 )
local TargetOffset = 0
if OldTargetOffset ~= TargetOffset then
OldTargetOffset = TargetOffset
surface.PlaySound( "lvs/optics.wav" )
end
RotationOffset = RotationOffset + (TargetOffset + math.max( self:GetTurretCompensation() / 15, -130 ) - RotationOffset) * RealFrameTime() * 8
local R = ScrH * 0.5 - 64
local R0 = R + 30
local R1 = R - 8
local R2 = R - 23
local R3 = R - 30
local R4 = R - 18
for i = 0, 40 do
local ang = -90 + (180 / 40) * i + RotationOffset
local x = math.cos( math.rad( ang ) )
local y = math.sin( math.rad( ang ) )
if i == 2 then
self:DrawRotatedText( self.OpticsProjectileSize, Pos2D.x + x * R0, Pos2D.y + y * R0, "LVS_FONT", Color(0,0,0,200), 90 + ang)
end
if i == 3 then
self:DrawRotatedText( "cm", Pos2D.x + x * R0, Pos2D.y + y * R0, "LVS_FONT", Color(0,0,0,200), 90 + ang)
end
if i == 5 then
self:DrawRotatedText( "Pzgr", Pos2D.x + x * R0, Pos2D.y + y * R0, "LVS_FONT", Color(0,0,0,200), 90 + ang)
end
surface.SetMaterial( circle )
surface.DrawTexturedRectRotated( Pos2D.x + x * R, Pos2D.y + y * R, 16, 16, 0 )
surface.DrawLine( Pos2D.x + x * R1, Pos2D.y + y * R1, Pos2D.x + x * R2, Pos2D.y + y * R2 )
self:DrawRotatedText( i, Pos2D.x + x * R3, Pos2D.y + y * R3, "LVS_FONT_PANEL", Color(0,0,0,255), ang + 90)
if i == 40 then continue end
local ang = - 90 + (180 / 40) * (i + 0.5) + RotationOffset
local x = math.cos( math.rad( ang ) )
local y = math.sin( math.rad( ang ) )
surface.DrawLine( Pos2D.x + x * R1, Pos2D.y + y * R1, Pos2D.x + x * R4, Pos2D.y + y * R4 )
end
surface.SetDrawColor( 0, 0, 0, 100 )
surface.SetMaterial( pointer )
surface.DrawTexturedRect( Pos2D.x - 16, 0, 32, 64 )
local diameter = ScrH + 64
local radius = diameter * 0.5
surface.SetMaterial( scope )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawTexturedRect( Pos2D.x - radius, Pos2D.y - radius, diameter, diameter )
-- black bar left + right
surface.DrawRect( 0, 0, Pos2D.x - radius, ScrH )
surface.DrawRect( Pos2D.x + radius, 0, Pos2D.x - radius, ScrH )
end

View File

@@ -0,0 +1,171 @@
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "sh_turret.lua" )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "cl_optics.lua" )
include("shared.lua")
include("sh_turret.lua")
ENT.AISearchCone = 30
function ENT:OnSpawn( PObj )
self:AddDriverSeat( Vector(0,15,-5), Angle(0,-90,0) )
local ID = self:LookupAttachment( "muzzle" )
local Muzzle = self:GetAttachment( ID )
self.SNDTurret = self:AddSoundEmitter( self:WorldToLocal( Muzzle.Pos ), "lvs/vehicles/pak40/cannon_fire.wav", "lvs/vehicles/pak40/cannon_fire.wav" )
self.SNDTurret:SetSoundLevel( 95 )
self.SNDTurret:SetParent( self, ID )
local WheelModel = "models/blu/pak40_wheel.mdl"
local FrontAxle = self:DefineAxle( {
Axle = {
ForwardAngle = Angle(0,0,0),
SteerType = LVS.WHEEL_STEER_NONE,
SteerAngle = 0,
BrakeFactor = 1,
UseHandbrake = true,
},
Wheels = {
self:AddWheel( {
pos = Vector(47.2,31,19),
mdl = WheelModel,
mdl_ang = Angle(0,90,0),
} ),
self:AddWheel( {
pos = Vector(47.2,-31,19),
mdl = WheelModel,
mdl_ang = Angle(0,-90,0),
} ),
},
Suspension = {
Height = 0,
MaxTravel = 0,
ControlArmLength = 0,
},
} )
self:AddTrailerHitch( Vector(-98,0,2), LVS.HITCHTYPE_FEMALE )
end
function ENT:OnTick()
self:AimTurret()
end
function ENT:OnCollision( data, physobj )
if self:WorldToLocal( data.HitPos ).z < 19 then return true end -- dont detect collision when the lower part of the model touches the ground
return false
end
function ENT:OnCoupled( targetVehicle, targetHitch )
self:SetProngs( true )
timer.Simple( 0.2, function()
if not IsValid( self ) then return end
self:RebuildCrosshairFilterEnts()
end )
end
function ENT:OnDecoupled( targetVehicle, targetHitch )
self:SetProngs( false )
timer.Simple( 0.2, function()
if not IsValid( self ) then return end
self:RebuildCrosshairFilterEnts()
end )
end
function ENT:OnStartDrag( caller, activator )
self:SetProngs( true )
end
function ENT:OnStopDrag( caller, activator )
self:SetProngs( false )
end
function ENT:SpawnShell()
local ID = self:LookupAttachment( "muzzle" )
local Muzzle = self:GetAttachment( ID )
if not Muzzle then return end
local Shell = ents.Create( "lvs_item_shell" )
if not IsValid( Shell ) then return end
Shell.MDL = "models/props_debris/shellcasing_08.mdl"
Shell.CollisionSounds = {
"lvs/vehicles/pak40/shell_impact1.wav",
"lvs/vehicles/pak40/shell_impact2.wav"
}
Shell:SetPos( Muzzle.Pos - Muzzle.Ang:Forward() * 140 )
Shell:SetAngles( Muzzle.Ang + Angle(90,0,0) )
Shell:Spawn()
Shell:Activate()
Shell:SetOwner( self )
local PhysObj = Shell:GetPhysicsObject()
if not IsValid( PhysObj ) then return end
PhysObj:SetVelocityInstantaneous( Shell:GetRight() * 250 - Shell:GetUp() * 20 )
PhysObj:SetAngleVelocityInstantaneous( Vector(0,0,180) )
end
function ENT:DoReloadSequence( delay )
if self._ReloadActive then return end
self._ReloadActive = true
self:SetBodygroup(1, 1)
timer.Simple(delay, function()
if not IsValid( self ) then return end
self:PlayAnimation("breach")
self:EmitSound("lvs/vehicles/pak40/cannon_unload.wav", 75, 100, 0.5, CHAN_WEAPON )
timer.Simple(0.3, function()
if not IsValid( self ) then return end
self:SpawnShell()
end)
end)
timer.Simple(2, function()
if not IsValid( self ) then return end
self:PlayAnimation("reload")
self:EmitSound("lvs/vehicles/pak40/cannon_reload.wav", 75, 100, 1, CHAN_WEAPON )
timer.Simple(0.1, function()
if not IsValid( self ) then return end
self:SetBodygroup(1, 0)
self._ReloadActive = nil
end )
end )
end
function ENT:DoAttackSequence()
if not IsValid( self.SNDTurret ) then return end
self.SNDTurret:PlayOnce( 100 + math.cos( CurTime() + self:EntIndex() * 1337 ) * 5 + math.Rand(-1,1), 1 )
self:PlayAnimation("fire")
self:DoReloadSequence( 1 )
end
function ENT:OnDriverEnterVehicle( ply )
ply:SetCollisionGroup(COLLISION_GROUP_PLAYER)
end
function ENT:OnDriverExitVehicle( ply )
end

View File

@@ -0,0 +1,23 @@
include("entities/lvs_tank_wheeldrive/modules/sh_turret.lua")
include("entities/lvs_tank_wheeldrive/modules/sh_turret_ballistics.lua")
ENT.TurretBallisticsProjectileVelocity = ENT.ProjectileVelocityArmorPiercing
ENT.TurretBallisticsMuzzleAttachment = "muzzle"
ENT.TurretBallisticsViewAttachment = "sight"
ENT.TurretAimRate = 15
ENT.TurretRotationSound = "common/null.wav"
ENT.TurretPitchPoseParameterName = "cannon_pitch"
ENT.TurretPitchMin = -10
ENT.TurretPitchMax = 6
ENT.TurretPitchMul = -0.75
ENT.TurretPitchOffset = -2
ENT.TurretYawPoseParameterName = "cannon_yaw"
ENT.TurretYawMin = -10
ENT.TurretYawMax = 10
ENT.TurretYawMul = -1
ENT.TurretYawOffset = 0

View File

@@ -0,0 +1,172 @@
ENT.Base = "lvs_base_wheeldrive_trailer"
ENT.PrintName = "PaK 40"
ENT.Author = "Luna"
ENT.Information = "Luna's Vehicle Script"
ENT.Category = "[LVS]"
ENT.VehicleCategory = "Artillery"
ENT.Spawnable = true
ENT.AdminSpawnable = false
ENT.MDL = "models/blu/pak40.mdl"
ENT.AITEAM = 1
ENT.WheelPhysicsMass = 350
ENT.WheelPhysicsInertia = Vector(10,8,10)
ENT.WheelPhysicsTireHeight = 0 -- tire height 0 = doesnt use tires
ENT.CannonArmorPenetration = 14500
-- ballistics
ENT.ProjectileVelocityHighExplosive = 13000
ENT.ProjectileVelocityArmorPiercing = 16000
ENT.lvsShowInSpawner = false
ENT.MaxHealth = 800
ENT.DSArmorIgnoreForce = 1000
ENT.GibModels = {
"models/blu/pak_d1.mdl",
"models/blu/pak_d2.mdl",
"models/blu/pak_d3.mdl",
"models/blu/pak_d4.mdl",
"models/blu/pak_d5.mdl",
"models/blu/pak_d6.mdl",
"models/blu/pak40_wheel.mdl",
"models/blu/pak40_wheel.mdl",
"models/gibs/manhack_gib01.mdl",
"models/gibs/manhack_gib02.mdl",
"models/gibs/manhack_gib03.mdl",
"models/gibs/manhack_gib04.mdl",
}
function ENT:OnSetupDataTables()
self:AddDT( "Bool", "Prongs" )
self:AddDT( "Bool", "UseHighExplosive" )
end
function ENT:CalcMainActivity( ply )
if ply ~= self:GetDriver() then return self:CalcMainActivityPassenger( ply ) end
if ply.m_bWasNoclipping then
ply.m_bWasNoclipping = nil
ply:AnimResetGestureSlot( GESTURE_SLOT_CUSTOM )
if CLIENT then
ply:SetIK( true )
end
end
ply.CalcIdeal = ACT_CROUCHIDLE
ply.CalcSeqOverride = ply:LookupSequence( "cidle_knife" )
return ply.CalcIdeal, ply.CalcSeqOverride
end
function ENT:InitWeapons()
local COLOR_WHITE = Color(255,255,255,255)
local weapon = {}
weapon.Icon = true
weapon.Ammo = 100
weapon.Delay = 3
weapon.HeatRateUp = 1
weapon.HeatRateDown = 0.3
weapon.OnThink = function( ent )
local ply = ent:GetDriver()
if not IsValid( ply ) then return end
local SwitchType = ply:lvsKeyDown( "CAR_SWAP_AMMO" )
if ent._oldSwitchType ~= SwitchType then
ent._oldSwitchType = SwitchType
if SwitchType then
ent:SetUseHighExplosive( not ent:GetUseHighExplosive() )
ent:DoReloadSequence( 0 )
ent:SetHeat( 1 )
ent:SetOverheated( true )
if ent:GetUseHighExplosive() then
ent:TurretUpdateBallistics( ent.ProjectileVelocityHighExplosive )
else
ent:TurretUpdateBallistics( ent.ProjectileVelocityArmorPiercing )
end
end
end
end
weapon.Attack = function( ent )
local ID = ent:LookupAttachment( "muzzle" )
local Muzzle = ent:GetAttachment( ID )
if not Muzzle then return end
local bullet = {}
bullet.Src = Muzzle.Pos
bullet.Dir = Muzzle.Ang:Forward()
bullet.Spread = Vector(0,0,0)
bullet.EnableBallistics = true
if ent:GetUseHighExplosive() then
bullet.Force = 500
bullet.HullSize = 15
bullet.Damage = 250
bullet.SplashDamage = 750
bullet.SplashDamageRadius = 200
bullet.SplashDamageEffect = "lvs_bullet_impact_explosive"
bullet.SplashDamageType = DMG_BLAST
bullet.Velocity = ent.ProjectileVelocityHighExplosive
else
bullet.Force = ent.CannonArmorPenetration
bullet.HullSize = 0
bullet.Damage = 1000
bullet.Velocity = ent.ProjectileVelocityArmorPiercing
end
bullet.TracerName = "lvs_tracer_cannon"
bullet.Attacker = ent:GetDriver()
ent:LVSFireBullet( bullet )
local effectdata = EffectData()
effectdata:SetOrigin( bullet.Src )
effectdata:SetNormal( bullet.Dir )
effectdata:SetEntity( ent )
util.Effect( "lvs_muzzle", effectdata )
ent:TakeAmmo( 1 )
ent:DoAttackSequence()
end
weapon.HudPaint = function( ent, X, Y, ply )
local ID = ent:LookupAttachment( "muzzle" )
local Muzzle = ent:GetAttachment( ID )
if Muzzle then
local traceTurret = util.TraceLine( {
start = Muzzle.Pos,
endpos = Muzzle.Pos + Muzzle.Ang:Forward() * 50000,
filter = ent:GetCrosshairFilterEnts()
} )
local MuzzlePos2D = traceTurret.HitPos:ToScreen()
if ent:GetUseHighExplosive() then
ent:PaintCrosshairSquare( MuzzlePos2D, COLOR_WHITE )
else
ent:PaintCrosshairOuter( MuzzlePos2D, COLOR_WHITE )
end
ent:LVSPaintHitMarker( MuzzlePos2D )
end
end
self:AddWeapon( weapon )
end