add sborka
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
if CLIENT then
|
||||
SWEP.WepSelectIcon = surface.GetTextureID("vgui/hud/weapon_doietoolus")
|
||||
SWEP.DrawWeaponInfoBox = false
|
||||
SWEP.BounceWeaponIcon = false
|
||||
killicon.Add( "weapon_doietoolus", "vgui/hud/weapon_doietoolus", Color( 0, 0, 0, 255 ) )
|
||||
end
|
||||
|
||||
SWEP.PrintName = "Entrenching Tool"
|
||||
|
||||
SWEP.Category = "Engiener Tools"
|
||||
|
||||
SWEP.Spawnable= true
|
||||
SWEP.AdminSpawnable= true
|
||||
SWEP.AdminOnly = false
|
||||
|
||||
SWEP.ViewModelFOV = 60
|
||||
SWEP.ViewModel = "models/weapons/doi/v_etool_us.mdl"
|
||||
SWEP.WorldModel = "models/weapons/doi/w_etool_us.mdl"
|
||||
SWEP.ViewModelFlip = false
|
||||
|
||||
SWEP.AutoSwitchTo = false
|
||||
SWEP.AutoSwitchFrom = false
|
||||
|
||||
SWEP.Slot = 0
|
||||
SWEP.SlotPos = 0
|
||||
|
||||
SWEP.UseHands = true
|
||||
|
||||
SWEP.HoldType = "melee2"
|
||||
|
||||
SWEP.FiresUnderwater = false
|
||||
|
||||
SWEP.DrawCrosshair = false
|
||||
|
||||
SWEP.DrawAmmo = true
|
||||
|
||||
SWEP.Base = "weapon_base"
|
||||
|
||||
SWEP.CSMuzzleFlashes = true
|
||||
|
||||
SWEP.Sprint = 0
|
||||
|
||||
SWEP.Primary.ClipSize = 0
|
||||
SWEP.Primary.DefaultClip = 0
|
||||
SWEP.Primary.Automatic = false
|
||||
SWEP.Primary.Ammo = "none"
|
||||
|
||||
SWEP.Secondary.ClipSize = 0
|
||||
SWEP.Secondary.DefaultClip = 0
|
||||
SWEP.Secondary.Automatic = false
|
||||
SWEP.Secondary.Ammo = "none"
|
||||
|
||||
SWEP.Structures = {
|
||||
{
|
||||
name = "Мешки с песком",
|
||||
icon = "entities/closebutton.png",
|
||||
cat = 1,
|
||||
hp = 10000,
|
||||
model = "models/props_fortifications/sandbags_corner1.mdl",
|
||||
count = 3,
|
||||
corrangle = Angle(0,0,0)
|
||||
},
|
||||
{
|
||||
name = "Большие мешки с песком",
|
||||
icon = "entities/closebutton.png",
|
||||
cat = 1,
|
||||
hp = 20000,
|
||||
model = "models/props_fortifications/sandbags_corner1_tall.mdl",
|
||||
count = 2,
|
||||
corrangle = Angle(0,0,0)
|
||||
},
|
||||
{
|
||||
name = "Противотанковые ёжи",
|
||||
icon = "entities/closebutton.png",
|
||||
cat = 1,
|
||||
hp = 50000,
|
||||
model = "models/test_sborka_props/barricades/ezi_antitank_2.mdl",
|
||||
count = 2,
|
||||
corrangle = Angle(0,-90,0)
|
||||
},
|
||||
{
|
||||
name = "Танковый окоп",
|
||||
icon = "entities/closebutton.png",
|
||||
cat = 2,
|
||||
hp = 100000,
|
||||
model = "models/trenches/prop/tank_cover/tank_cover.mdl",
|
||||
count = 3,
|
||||
corrangle = Angle(0,0,0)
|
||||
},
|
||||
}
|
||||
|
||||
function SWEP:Initialize()
|
||||
self:SetWeaponHoldType( self.HoldType )
|
||||
self:GetOwner().buildtime = 0
|
||||
end
|
||||
|
||||
function SWEP:Deploy()
|
||||
self:SetNextPrimaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
|
||||
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
|
||||
Sprint = 0
|
||||
end
|
||||
|
||||
function SWEP:Holster()
|
||||
self.NextSecondaryAttack = 0
|
||||
Sprint = 0
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:PrimaryAttack()
|
||||
if !(self.Weapon:GetNextPrimaryFire() < CurTime()) || not(Sprint == 0) then return end
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
|
||||
self.Owner:SetAnimation( PLAYER_ATTACK1 )
|
||||
self:SetNextPrimaryFire( CurTime() + 1)
|
||||
self:SetNextSecondaryFire( CurTime() + 1)
|
||||
|
||||
if SERVER then
|
||||
net.Start("openmenu")
|
||||
net.WriteTable(self.Structures)
|
||||
net.Send(self:GetOwner())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SWEP:SecondaryAttack()
|
||||
end
|
||||
|
||||
function SWEP:Reload()
|
||||
if SERVER then
|
||||
local item = self:GetOwner():GetEyeTrace().Entity
|
||||
if item:IsValid() then
|
||||
if item.id != nil then
|
||||
if item.Owner == self:GetOwner() then
|
||||
if (item:GetClass() == self.Structures[item.id].entity) or (item:GetModel() == self.Structures[item.id].model) then
|
||||
item:Remove()
|
||||
self.Structures[item.id].count = self.Structures[item.id].count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function SWEP:DrawHUDBackground()
|
||||
if self:GetOwner().buildtime > 0 then
|
||||
draw.RoundedBox( 20, ScrW()/2-150, ScrH()/2-30, 0+300-self:GetOwner().buildtime*15, 60, Color( 50, 50, 50 , 180) )
|
||||
draw.RoundedBox( 20, ScrW()/2-145, ScrH()/2-25, 0+290-self:GetOwner().buildtime*14.5, 50, Color( 0, 255, 0 ,125) )
|
||||
draw.DrawText( tostring(100 - self:GetOwner().buildtime*5) .. '%', "Font3", ScrW()/2-20, ScrH()/2-15, Color( 255, 255, 255 ,255), 0 )
|
||||
end
|
||||
end
|
||||
|
||||
local delay = 0.5
|
||||
local nextOccurance = 0
|
||||
local flag1 = true
|
||||
if CLIENT then
|
||||
function SWEP:RenderScreen()
|
||||
if self.Owner.buildtime < 0 or Sprint == 2 then
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
|
||||
end
|
||||
|
||||
|
||||
if input.IsKeyDown(KEY_F) and flag1 then
|
||||
net.Start("buildstop12")
|
||||
net.SendToServer()
|
||||
self.Owner.building = false
|
||||
self.Owner.buildtime = -3
|
||||
flag1 = false
|
||||
timer.Simple(1, function() flag1 = true end)
|
||||
end
|
||||
|
||||
local timeLeft = nextOccurance - CurTime()
|
||||
if timeLeft < 0 and self:GetOwner().buildtime >= 0 then
|
||||
self:GetOwner().buildtime = self:GetOwner().buildtime - 0.5
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
|
||||
self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
|
||||
self:SetNextPrimaryFire( CurTime() + delay)
|
||||
nextOccurance = CurTime() + delay
|
||||
end
|
||||
net.Receive("buildanim", function(len, ply)
|
||||
self:GetOwner().buildtime = 20
|
||||
end)
|
||||
end
|
||||
end
|
||||
if SERVER then
|
||||
function SWEP:Think()
|
||||
|
||||
|
||||
net.Receive("buildstop12", function(len, ply)
|
||||
ply:Freeze(false)
|
||||
if self.LastEnt:IsValid() then
|
||||
self.Structures[self.LastEnt.id].count = self.Structures[self.LastEnt.id].count + 1
|
||||
self.LastEnt:Remove()
|
||||
end
|
||||
end)
|
||||
net.Receive("buildtrench", function(len, ply)
|
||||
if ply:GetActiveWeapon():GetClass() != "engineertool" then return end
|
||||
local id = net.ReadInt(13)
|
||||
if (ply:GetEyeTrace().HitPos - ply:GetEyeTrace().StartPos):Length() <= 300 then
|
||||
if self.Structures[id].count > 0 then
|
||||
net.Start("buildanim")
|
||||
net.WriteEntity(item)
|
||||
net.Send(self:GetOwner())
|
||||
local item = ents.Create("util_structure")
|
||||
item:SetPos(ply:GetEyeTrace().HitPos)
|
||||
item:SetAngles(ply:GetEyeTrace().HitNormal:Angle() + Angle(90,ply:EyeAngles().y,0))
|
||||
item:SetModel(self.Structures[id].model)
|
||||
item.hp = self.Structures[id].hp
|
||||
item.id = id
|
||||
item.poscoef = -100
|
||||
item.building = true
|
||||
item.Owner = self:GetOwner()
|
||||
item:Spawn()
|
||||
self.LastEnt = item
|
||||
self.Structures[id].count = self.Structures[id].count - 1
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
net.Receive("setentity", function(len, ply)
|
||||
if ply:GetActiveWeapon():GetClass() != "engineertool" then return end
|
||||
local id = net.ReadInt(13)
|
||||
if (ply:GetEyeTrace().HitPos - ply:GetEyeTrace().StartPos):Length() <= 300 then
|
||||
if self.Structures[id].count > 0 then
|
||||
local item = ents.Create(self.Structures[id].entity)
|
||||
item:SetPos(ply:GetEyeTrace().HitPos + ply:GetEyeTrace().HitNormal * 40)
|
||||
item:SetAngles(ply:GetEyeTrace().HitNormal:Angle() + self.Structures[id].corrangle)
|
||||
item.id = id
|
||||
item.Owner = self:GetOwner()
|
||||
item:Spawn()
|
||||
self.LastEnt = item
|
||||
self.Structures[id].count = self.Structures[id].count - 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
if (Sprint == 0) then
|
||||
|
||||
if self.Owner:KeyDown(IN_SPEED) and (self.Owner:KeyDown(IN_FORWARD) || self.Owner:KeyDown(IN_BACK) || self.Owner:KeyDown(IN_MOVELEFT) || self.Owner:KeyDown(IN_MOVERIGHT)) then
|
||||
Sprint = 1
|
||||
end
|
||||
end
|
||||
if (Sprint == 1) then
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_SPRINT_IDLE)
|
||||
Sprint = 2
|
||||
end
|
||||
if (Sprint == 2) then
|
||||
if self.Owner:KeyReleased(IN_SPEED) then
|
||||
self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
|
||||
Sprint = 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user