add sborka
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Draw()
|
||||
if CurTime() > self:GetNWFloat("HideTime", CurTime() + 1) then
|
||||
self:DrawModel()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:IsTranslucent()
|
||||
return true
|
||||
end
|
||||
@@ -0,0 +1,146 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
local LVS = LVS
|
||||
ENT.Damage = 0
|
||||
ENT.Prime = 0.03
|
||||
ENT.Delay = 30
|
||||
ENT.HideDelay = 0.0
|
||||
|
||||
|
||||
function ENT:Initialize()
|
||||
local mdl = self:GetModel()
|
||||
|
||||
if not mdl or mdl == "" or mdl == "models/error.mdl" then
|
||||
self:SetModel("models/Weapons/w_panzerfaust3_sandstorm_projectile.mdl")
|
||||
end
|
||||
self.burnout = CurTime() + 2
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
--self:PhysicsInitSphere((self:OBBMaxs() - self:OBBMins()):Length() / 4, "metal")
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
||||
if (phys:IsValid()) then
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self:SetFriction(self.Delay)
|
||||
self.killtime = CurTime() + self.Delay
|
||||
self:DrawShadow(true)
|
||||
self.StartTime = CurTime()
|
||||
self:EmitSound( "TFA_INS2_RPG7.Loop" )
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self.HasIdle = true
|
||||
timer.Simple(0.1, function()
|
||||
if IsValid(self) then
|
||||
self:SetOwner()
|
||||
end
|
||||
end)
|
||||
self:SetNWFloat("HideTime",CurTime() + self.HideDelay )
|
||||
self.HP = math.random(30, 60)
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
if self.killtime < CurTime() then
|
||||
return false
|
||||
end
|
||||
local phys = self:GetPhysicsObject()
|
||||
local force = phys:GetMass() * Vector( 0, 0, -9.80665 ) * 7-- This gives us the force in kg*source_unit/s^2
|
||||
local dt = engine.TickInterval() -- The time interval over which the force acts on the object (in seconds)
|
||||
phys:ApplyForceCenter( force * dt ) -- Multiplying the two gives us the impulse in kg*source_unit/s
|
||||
self:NextThink(CurTime())
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local effectdata, shake
|
||||
|
||||
function ENT:Explode()
|
||||
if not IsValid(self.Owner) then
|
||||
self:Remove()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin(self:GetPos())
|
||||
effectdata:SetScale(10)
|
||||
effectdata:SetMagnitude(5)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.BlastDamage(self, self.Owner, self:GetPos(), 100, 10)
|
||||
shake = ents.Create("env_shake")
|
||||
shake:SetOwner(self.Owner)
|
||||
shake:SetPos(self:GetPos())
|
||||
shake:SetKeyValue("amplitude", tostring(20)) -- Power of the shake
|
||||
shake:SetKeyValue("radius", tostring( 768 ) ) -- Radius of the shake
|
||||
shake:SetKeyValue("duration", tostring( self.Damage / 800 )) -- Time of shake
|
||||
shake:SetKeyValue("frequency", "255") -- How har should the screenshake be
|
||||
shake:SetKeyValue("spawnflags", "4") -- Spawnflags(In Air)
|
||||
shake:Spawn()
|
||||
shake:Activate()
|
||||
shake:Fire("StartShake", "", 0)
|
||||
self:EmitSound("TFA_INS2_RPG7.2")
|
||||
local heat = {}
|
||||
heat.Src = self:GetPos()
|
||||
heat.Dir = self:GetAngles():Forward()
|
||||
heat.Spread = Vector(0,0,0)
|
||||
heat.Force = 20000
|
||||
heat.HullSize = 0
|
||||
heat.Damage = 8000
|
||||
heat.Velocity = 2000
|
||||
heat.Attacker = self.Owner
|
||||
LVS:FireBullet( heat )
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:PhysicsCollide(data, phys)
|
||||
if data.Speed > 60 and CurTime() > self.StartTime + self.Prime then
|
||||
timer.Simple(0,function()
|
||||
if IsValid(self) then
|
||||
self:Explode()
|
||||
end
|
||||
end)
|
||||
else
|
||||
self.Prime = math.huge
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
self:SetNWFloat("HideTime", -1 )
|
||||
end
|
||||
end
|
||||
--[[elseif self:GetOwner() ~= self then
|
||||
self.Prime = math.huge
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self:SetOwner(self)
|
||||
end
|
||||
]]--
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator, caller)
|
||||
if activator:IsPlayer() and self.WeaponClass and activator:GetWeapon(self.WeaponClass) then
|
||||
activator:GiveAmmo(1, activator:GetWeapon(self.WeaponClass):GetPrimaryAmmoType(), false)
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage( dmg )
|
||||
if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
|
||||
if self.Exploded then return end
|
||||
if self.HP > 0 and self.HP - dmg:GetDamage() <= 0 then
|
||||
self.Exploded = true
|
||||
self:Explode()
|
||||
end
|
||||
self.HP = self.HP - dmg:GetDamage()
|
||||
dmg:SetAttacker(self)
|
||||
dmg:SetInflictor(self)
|
||||
self:TakePhysicsDamage( dmg )
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "Contact Explosive"
|
||||
ENT.Author = ""
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
ENT.DoNotDuplicate = true
|
||||
ENT.DisableDuplicator = true
|
||||
@@ -0,0 +1,11 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Draw()
|
||||
if CurTime() > self:GetNWFloat("HideTime", 0) then
|
||||
self:DrawModel()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:IsTranslucent()
|
||||
return true
|
||||
end
|
||||
229
garrysmod/addons/tfa_antitank/lua/entities/rpg26_rocket/init.lua
Normal file
229
garrysmod/addons/tfa_antitank/lua/entities/rpg26_rocket/init.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
|
||||
local LVS = LVS
|
||||
|
||||
ENT.Damage = 0
|
||||
ENT.Prime = 0.03
|
||||
ENT.Delay = 30
|
||||
ENT.HideDelay = 0.0
|
||||
|
||||
function ENT:Initialize()
|
||||
if not self:GetModel() or self:GetModel() == "" or self:GetModel() == "models/error.mdl" then
|
||||
self:SetModel("models/weapons/fas2/world/explosives/rpg26/rocket.mdl")
|
||||
end
|
||||
|
||||
if not self.Owner:IsPlayer() then
|
||||
self.Owner = NULL
|
||||
end
|
||||
|
||||
self.burnout = CurTime() + 2
|
||||
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) then
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self:SetFriction(self.Delay)
|
||||
self.killtime = CurTime() + self.Delay
|
||||
self.StartTime = CurTime()
|
||||
|
||||
self:EmitSound("TFA_INS2_RPG7.Loop")
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
|
||||
self.HasIdle = true
|
||||
self.HP = math.random(30, 60)
|
||||
|
||||
timer.Simple(0.1, function()
|
||||
if IsValid(self) then
|
||||
self:SetOwner(self:GetOwner() or NULL)
|
||||
end
|
||||
end)
|
||||
|
||||
self:SetNWFloat("HideTime", CurTime() + self.HideDelay)
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
local ct = CurTime()
|
||||
if self.killtime < ct then return false end
|
||||
|
||||
local phys = self:GetPhysicsObject()
|
||||
if not IsValid(phys) then return end
|
||||
if phys:IsValid() then
|
||||
phys:ApplyForceCenter(Vector(0, 0, -9.80665 * 7) * phys:GetMass() * engine.TickInterval())
|
||||
end
|
||||
|
||||
self:NextThink(ct)
|
||||
return true
|
||||
end
|
||||
|
||||
function ENT:Explode()
|
||||
if self._Exploding then return end
|
||||
self._Exploding = true
|
||||
|
||||
if not IsValid(self.Owner) then
|
||||
self:Remove()
|
||||
return
|
||||
end
|
||||
|
||||
local tr = util.TraceLine({
|
||||
start = pos,
|
||||
endpos = pos + self:GetAngles():Forward() * 200,
|
||||
filter = self
|
||||
})
|
||||
|
||||
local hit = tr.Entity
|
||||
|
||||
if IsValid(hit) and hit.LVS then
|
||||
local dmg = DamageInfo()
|
||||
dmg:SetDamage(250)
|
||||
dmg:SetDamageType(DMG_BLAST)
|
||||
dmg:SetAttacker(self.Owner or self)
|
||||
dmg:SetInflictor(self)
|
||||
hit:TakeDamageInfo(dmg)
|
||||
|
||||
if hit.GetSubSystem then
|
||||
local subsys = hit:GetSubSystem(tr.HitPos)
|
||||
if subsys then
|
||||
subsys:TakeDamage(300)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local pos = self:GetPos()
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin(pos)
|
||||
effectdata:SetScale(5)
|
||||
effectdata:SetMagnitude(5)
|
||||
|
||||
util.Effect("HelicopterMegaBomb", effectdata)
|
||||
util.Effect("Explosion", effectdata)
|
||||
|
||||
util.BlastDamage(self, self.Owner, pos, 100, 10)
|
||||
|
||||
local shake = ents.Create("env_shake")
|
||||
shake:SetOwner(self.Owner)
|
||||
shake:SetPos(pos)
|
||||
shake:SetKeyValue("amplitude", "20")
|
||||
shake:SetKeyValue("radius", "768")
|
||||
shake:SetKeyValue("duration", tostring(self.Damage / 800))
|
||||
shake:SetKeyValue("frequency", "255")
|
||||
shake:SetKeyValue("spawnflags", "4")
|
||||
shake:Spawn()
|
||||
shake:Activate()
|
||||
shake:Fire("StartShake", "", 0)
|
||||
|
||||
self:EmitSound("TFA_INS2_RPG7.2")
|
||||
|
||||
LVS:FireBullet({
|
||||
Src = pos,
|
||||
Dir = self:GetAngles():Forward(),
|
||||
Spread = vector_origin,
|
||||
Force = 42000,
|
||||
HullSize = 0,
|
||||
Damage = 12000,
|
||||
Velocity = 16000,
|
||||
Attacker = self.Owner
|
||||
})
|
||||
|
||||
local tr = util.TraceHull({
|
||||
start = pos,
|
||||
endpos = pos,
|
||||
mins = Vector(-80, -80, -80),
|
||||
maxs = Vector(80, 80, 80),
|
||||
filter = self
|
||||
})
|
||||
|
||||
local hit = tr.Entity
|
||||
|
||||
if IsValid(hit) and hit.LVS then
|
||||
local dmg = DamageInfo()
|
||||
dmg:SetDamage(200)
|
||||
dmg:SetDamageType(DMG_BLAST)
|
||||
dmg:SetAttacker(self.Owner or self)
|
||||
dmg:SetInflictor(self)
|
||||
hit:TakeDamageInfo(dmg)
|
||||
|
||||
if hit.GetSubSystem then
|
||||
local subsys = hit:GetSubSystem(pos)
|
||||
|
||||
if subsys then
|
||||
local name = subsys.Name:lower()
|
||||
|
||||
if name:find("engine") then
|
||||
subsys:SetHP(0)
|
||||
|
||||
elseif name:find("ammo") then
|
||||
subsys:SetHP(0)
|
||||
|
||||
elseif name:find("fuel") then
|
||||
subsys:SetHP(0)
|
||||
|
||||
else
|
||||
subsys:TakeDamage(250)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:PhysicsCollide(data, phys)
|
||||
if self._LastCollide and self._LastCollide > CurTime() - 0.05 then return end
|
||||
self._LastCollide = CurTime()
|
||||
local ct = CurTime()
|
||||
|
||||
if data.Speed > 60 and ct > self.StartTime + self.Prime then
|
||||
timer.Simple(0, function()
|
||||
if IsValid(self) then self:Explode() end
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
self.Prime = math.huge
|
||||
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
self:SetNWFloat("HideTime", -1)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator)
|
||||
if activator:IsPlayer() and self.WeaponClass then
|
||||
local wep = activator:GetWeapon(self.WeaponClass)
|
||||
if IsValid(wep) then
|
||||
activator:GiveAmmo(1, wep:GetPrimaryAmmoType(), false)
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(dmg)
|
||||
if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
|
||||
if self.Exploded then return end
|
||||
|
||||
local damage = dmg:GetDamage()
|
||||
self.HP = self.HP - damage
|
||||
|
||||
if self.HP <= 0 then
|
||||
self.Exploded = true
|
||||
self:Explode()
|
||||
return
|
||||
end
|
||||
|
||||
self:TakePhysicsDamage(dmg)
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "Contact Explosive"
|
||||
ENT.Author = ""
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
ENT.DoNotDuplicate = true
|
||||
ENT.DisableDuplicator = true
|
||||
@@ -0,0 +1,11 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Draw()
|
||||
if CurTime() > self:GetNWFloat("HideTime", CurTime() + 1) then
|
||||
self:DrawModel()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:IsTranslucent()
|
||||
return true
|
||||
end
|
||||
@@ -0,0 +1,219 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
local LVS = LVS
|
||||
ENT.Damage = 0
|
||||
ENT.Prime = 0.03
|
||||
ENT.Delay = 30
|
||||
ENT.HideDelay = 5
|
||||
ENT.FireRadius = 600 -- Общий радиус распространения пожара
|
||||
ENT.FireDuration = 10 -- Длительность пожара в секундах
|
||||
ENT.FireCount = 20 -- Количество отдельных источников огня
|
||||
ENT.MaxFireDistance = 200 -- Максимальное расстояние от центра взрыва для источников огня
|
||||
|
||||
|
||||
function ENT:Initialize()
|
||||
local mdl = self:GetModel()
|
||||
|
||||
if not mdl or mdl == "" or mdl == "models/error.mdl" then
|
||||
self:SetModel("models/weapons/fas2/world/explosives/rpg26/rocket.mdl")
|
||||
end
|
||||
self.burnout = CurTime() + 2
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
--self:PhysicsInitSphere((self:OBBMaxs() - self:OBBMins()):Length() / 4, "metal")
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
||||
if (phys:IsValid()) then
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self:SetFriction(self.Delay)
|
||||
self.killtime = CurTime() + self.Delay
|
||||
self:DrawShadow(true)
|
||||
self.StartTime = CurTime()
|
||||
self:EmitSound( "TFA_INS2_RPG7.Loop" )
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self.HasIdle = true
|
||||
timer.Simple(0.1, function()
|
||||
if IsValid(self) then
|
||||
self:SetOwner()
|
||||
end
|
||||
end)
|
||||
self:SetNWFloat("HideTime",CurTime() + self.HideDelay )
|
||||
self.HP = math.random(30, 60)
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
if self.killtime < CurTime() then
|
||||
return false
|
||||
end
|
||||
local phys = self:GetPhysicsObject()
|
||||
local force = phys:GetMass() * Vector( 0, 0, -9.80665 ) * 7-- This gives us the force in kg*source_unit/s^2
|
||||
local dt = engine.TickInterval() -- The time interval over which the force acts on the object (in seconds)
|
||||
phys:ApplyForceCenter( force * dt ) -- Multiplying the two gives us the impulse in kg*source_unit/s
|
||||
self:NextThink(CurTime())
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local effectdata, shake
|
||||
|
||||
function ENT:CreateFire()
|
||||
-- Создаем несколько источников огня в случайных позициях внутри радиуса
|
||||
for i = 1, self.FireCount do
|
||||
-- Вычисляем случайную позицию в радиусе взрыва
|
||||
local angle = math.random(0, 360)
|
||||
local distance = math.random(0, self.MaxFireDistance)
|
||||
local rad = math.rad(angle)
|
||||
|
||||
local offset = Vector(
|
||||
math.cos(rad) * distance,
|
||||
math.sin(rad) * distance,
|
||||
0
|
||||
)
|
||||
|
||||
local firePos = self:GetPos() + offset
|
||||
|
||||
-- Проверяем, что позиция не находится внутри объекта
|
||||
local trace = util.TraceLine({
|
||||
start = self:GetPos(),
|
||||
endpos = firePos,
|
||||
mask = MASK_SOLID_BRUSHONLY
|
||||
})
|
||||
|
||||
|
||||
-- Создаем отдельный источник огня
|
||||
local fire = ents.Create("env_fire")
|
||||
if IsValid(fire) then
|
||||
fire:SetPos(firePos)
|
||||
|
||||
-- Размер каждого отдельного огня (меньше общего радиуса)
|
||||
local individualFireSize = math.random(10, 40)
|
||||
|
||||
fire:SetKeyValue("health", self.FireDuration + math.random(-5, 5)) -- Случайная длительность
|
||||
fire:SetKeyValue("firesize", individualFireSize)
|
||||
fire:SetKeyValue("fireattack", "5")
|
||||
fire:SetKeyValue("damagescale", "20")
|
||||
fire:SetKeyValue("spawnflags", "130") -- Бесконечный огонь + дым + старт сразу
|
||||
fire:Spawn()
|
||||
fire:Fire("StartFire", "", 0)
|
||||
|
||||
-- Автоматическое удаление огня после заданного времени
|
||||
timer.Simple(self.FireDuration + math.random(-2, 2), function()
|
||||
if IsValid(fire) then
|
||||
fire:Remove()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local centerFire = ents.Create("env_fire")
|
||||
if IsValid(centerFire) then
|
||||
centerFire:SetPos(self:GetPos())
|
||||
centerFire:SetKeyValue("health", self.FireDuration)
|
||||
centerFire:SetKeyValue("firesize", 150)
|
||||
centerFire:SetKeyValue("fireattack", "10")
|
||||
centerFire:SetKeyValue("damagescale", "20")
|
||||
centerFire:SetKeyValue("spawnflags", "130")
|
||||
centerFire:Spawn()
|
||||
centerFire:Fire("StartFire", "", 0)
|
||||
|
||||
timer.Simple(self.FireDuration, function()
|
||||
if IsValid(centerFire) then
|
||||
centerFire:Remove()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Explode()
|
||||
if not IsValid(self.Owner) then
|
||||
self:Remove()
|
||||
return
|
||||
end
|
||||
|
||||
effectdata = EffectData()
|
||||
effectdata:SetOrigin(self:GetPos())
|
||||
effectdata:SetScale(5)
|
||||
effectdata:SetMagnitude(5)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.BlastDamage(self, self.Owner, self:GetPos(), 100, 10)
|
||||
shake = ents.Create("env_shake")
|
||||
shake:SetOwner(self.Owner)
|
||||
shake:SetPos(self:GetPos())
|
||||
shake:SetKeyValue("amplitude", tostring(20)) -- Power of the shake
|
||||
shake:SetKeyValue("radius", tostring( 768 ) ) -- Radius of the shake
|
||||
shake:SetKeyValue("duration", tostring( self.Damage / 800 )) -- Time of shake
|
||||
shake:SetKeyValue("frequency", "255") -- How har should the screenshake be
|
||||
shake:SetKeyValue("spawnflags", "4") -- Spawnflags(In Air)
|
||||
shake:Spawn()
|
||||
shake:Activate()
|
||||
shake:Fire("StartShake", "", 0)
|
||||
self:EmitSound("TFA_INS2_RPG7.2")
|
||||
local he = {}
|
||||
he.Src = self:GetPos()
|
||||
he.Dir = self:GetAngles():Forward()
|
||||
he.Spread = Vector(0,0,0)
|
||||
he.Force = 100
|
||||
he.HullSize = 0
|
||||
he.Damage = 700
|
||||
he.SplashDamage = 200
|
||||
he.SplashDamageRadius = 250
|
||||
he.Velocity = 300
|
||||
he.TracerName = "lvs_tracer_autocannon" -- Изменено на нужный трассер
|
||||
he.Attacker = self.Owner
|
||||
LVS:FireBullet( heat )
|
||||
|
||||
-- Создаем пожар после взрыва
|
||||
self:CreateFire()
|
||||
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:PhysicsCollide(data, phys)
|
||||
if data.Speed > 60 and CurTime() > self.StartTime + self.Prime then
|
||||
timer.Simple(0,function()
|
||||
if IsValid(self) then
|
||||
self:Explode()
|
||||
end
|
||||
end)
|
||||
else
|
||||
self.Prime = math.huge
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
self:SetNWFloat("HideTime", -1 )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator, caller)
|
||||
if activator:IsPlayer() and self.WeaponClass and activator:GetWeapon(self.WeaponClass) then
|
||||
activator:GiveAmmo(1, activator:GetWeapon(self.WeaponClass):GetPrimaryAmmoType(), false)
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage( dmg )
|
||||
if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
|
||||
if self.Exploded then return end
|
||||
if self.HP > 0 and self.HP - dmg:GetDamage() <= 0 then
|
||||
self.Exploded = true
|
||||
self:Explode()
|
||||
end
|
||||
self.HP = self.HP - dmg:GetDamage()
|
||||
dmg:SetAttacker(self)
|
||||
dmg:SetInflictor(self)
|
||||
self:TakePhysicsDamage( dmg )
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "Contact Explosive"
|
||||
ENT.Author = ""
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
ENT.DoNotDuplicate = true
|
||||
ENT.DisableDuplicator = true
|
||||
@@ -0,0 +1,11 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Draw()
|
||||
if CurTime() > self:GetNWFloat("HideTime", CurTime() + 1) then
|
||||
self:DrawModel()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:IsTranslucent()
|
||||
return true
|
||||
end
|
||||
146
garrysmod/addons/tfa_antitank/lua/entities/rpg28_rocket/init.lua
Normal file
146
garrysmod/addons/tfa_antitank/lua/entities/rpg28_rocket/init.lua
Normal file
@@ -0,0 +1,146 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
local LVS = LVS
|
||||
ENT.Damage = 0
|
||||
ENT.Prime = 0.03
|
||||
ENT.Delay = 30
|
||||
ENT.HideDelay = 0.0
|
||||
|
||||
|
||||
function ENT:Initialize()
|
||||
local mdl = self:GetModel()
|
||||
|
||||
if not mdl or mdl == "" or mdl == "models/error.mdl" then
|
||||
self:SetModel("models/weapons/rpg28_rocket.mdl")
|
||||
end
|
||||
self.burnout = CurTime() + 2
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
--self:PhysicsInitSphere((self:OBBMaxs() - self:OBBMins()):Length() / 4, "metal")
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
||||
if (phys:IsValid()) then
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self:SetFriction(self.Delay)
|
||||
self.killtime = CurTime() + self.Delay
|
||||
self:DrawShadow(true)
|
||||
self.StartTime = CurTime()
|
||||
self:EmitSound( "TFA_INS2_RPG7.Loop" )
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self.HasIdle = true
|
||||
timer.Simple(0.1, function()
|
||||
if IsValid(self) then
|
||||
self:SetOwner()
|
||||
end
|
||||
end)
|
||||
self:SetNWFloat("HideTime",CurTime() + self.HideDelay )
|
||||
self.HP = math.random(30, 60)
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
if self.killtime < CurTime() then
|
||||
return false
|
||||
end
|
||||
local phys = self:GetPhysicsObject()
|
||||
local force = phys:GetMass() * Vector( 0, 0, -9.80665 ) * 7-- This gives us the force in kg*source_unit/s^2
|
||||
local dt = engine.TickInterval() -- The time interval over which the force acts on the object (in seconds)
|
||||
phys:ApplyForceCenter( force * dt ) -- Multiplying the two gives us the impulse in kg*source_unit/s
|
||||
self:NextThink(CurTime())
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local effectdata, shake
|
||||
|
||||
function ENT:Explode()
|
||||
if not IsValid(self.Owner) then
|
||||
self:Remove()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin(self:GetPos())
|
||||
effectdata:SetScale(10)
|
||||
effectdata:SetMagnitude(5)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.Effect("lvs_explosion_small", effectdata)
|
||||
util.BlastDamage(self, self.Owner, self:GetPos(), 100, 10)
|
||||
shake = ents.Create("env_shake")
|
||||
shake:SetOwner(self.Owner)
|
||||
shake:SetPos(self:GetPos())
|
||||
shake:SetKeyValue("amplitude", tostring(20)) -- Power of the shake
|
||||
shake:SetKeyValue("radius", tostring( 768 ) ) -- Radius of the shake
|
||||
shake:SetKeyValue("duration", tostring( self.Damage / 800 )) -- Time of shake
|
||||
shake:SetKeyValue("frequency", "255") -- How har should the screenshake be
|
||||
shake:SetKeyValue("spawnflags", "4") -- Spawnflags(In Air)
|
||||
shake:Spawn()
|
||||
shake:Activate()
|
||||
shake:Fire("StartShake", "", 0)
|
||||
self:EmitSound("TFA_INS2_RPG7.2")
|
||||
local heat = {}
|
||||
heat.Src = self:GetPos()
|
||||
heat.Dir = self:GetAngles():Right()
|
||||
heat.Spread = Vector(0,0,0)
|
||||
heat.Force = 18000
|
||||
heat.HullSize = 0
|
||||
heat.Damage = 8000
|
||||
heat.Velocity = 16000
|
||||
heat.Attacker = self.Owner
|
||||
LVS:FireBullet( heat )
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
function ENT:PhysicsCollide(data, phys)
|
||||
if data.Speed > 60 and CurTime() > self.StartTime + self.Prime then
|
||||
timer.Simple(0,function()
|
||||
if IsValid(self) then
|
||||
self:Explode()
|
||||
end
|
||||
end)
|
||||
else
|
||||
self.Prime = math.huge
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
self:SetNWFloat("HideTime", -1 )
|
||||
end
|
||||
end
|
||||
--[[elseif self:GetOwner() ~= self then
|
||||
self.Prime = math.huge
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self:SetOwner(self)
|
||||
end
|
||||
]]--
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if self.HasIdle then
|
||||
self:StopSound("TFA_INS2_RPG7.Loop")
|
||||
self.HasIdle = false
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator, caller)
|
||||
if activator:IsPlayer() and self.WeaponClass and activator:GetWeapon(self.WeaponClass) then
|
||||
activator:GiveAmmo(1, activator:GetWeapon(self.WeaponClass):GetPrimaryAmmoType(), false)
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage( dmg )
|
||||
if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
|
||||
if self.Exploded then return end
|
||||
if self.HP > 0 and self.HP - dmg:GetDamage() <= 0 then
|
||||
self.Exploded = true
|
||||
self:Explode()
|
||||
end
|
||||
self.HP = self.HP - dmg:GetDamage()
|
||||
dmg:SetAttacker(self)
|
||||
dmg:SetInflictor(self)
|
||||
self:TakePhysicsDamage( dmg )
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "Contact Explosive"
|
||||
ENT.Author = ""
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
ENT.DoNotDuplicate = true
|
||||
ENT.DisableDuplicator = true
|
||||
Reference in New Issue
Block a user