add sborka
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
-----------------------------------------
|
||||
-- FT CONTUSION (MILITARY RP)
|
||||
-- Собственность Олега Закона и Scripty
|
||||
-----------------------------------------
|
||||
local concussionActive = false
|
||||
local lastConcussionSound = 0
|
||||
local function ApplyShake(endTime)
|
||||
local ply = LocalPlayer()
|
||||
if not ply or not ply:IsValid() then return end
|
||||
if not ply:Alive() then return end
|
||||
|
||||
local remainingTime = endTime - CurTime()
|
||||
local intensity = math.Clamp(remainingTime / 11, 0, 1)
|
||||
|
||||
local randAng =
|
||||
Angle(math.Rand(-1, 1), math.Rand(-1, 1), math.Rand(-1, 1)) * intensity
|
||||
end
|
||||
|
||||
net.Receive("StartConcussionEffect", function()
|
||||
local effectDuration = 15
|
||||
local endTime = CurTime() + effectDuration
|
||||
|
||||
if concussionActive then
|
||||
hook.Remove("HUDPaint", "DarkenScreenEffect")
|
||||
hook.Remove("RenderScreenspaceEffects", "BlurScreenEffect")
|
||||
hook.Remove("CalcView", "ConcussionCameraShake")
|
||||
timer.Remove("ShakeEffectTimer")
|
||||
timer.Remove("ConcussionEnd")
|
||||
end
|
||||
|
||||
concussionActive = true
|
||||
|
||||
if CurTime() - lastConcussionSound > 10 then
|
||||
surface.PlaySound("explosion_contusion.mp3")
|
||||
lastConcussionSound = CurTime()
|
||||
end
|
||||
|
||||
hook.Add("HUDPaint", "DarkenScreenEffect", function()
|
||||
local ply = LocalPlayer()
|
||||
if not IsValid(ply) or not ply:Alive() then return end
|
||||
local alpha = math.Clamp((endTime - CurTime()) / effectDuration * 225, 0, 225)
|
||||
draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(0, 0, 0, alpha))
|
||||
end)
|
||||
|
||||
hook.Add("RenderScreenspaceEffects", "BlurScreenEffect", function()
|
||||
local ply = LocalPlayer()
|
||||
if not IsValid(ply) or not ply:Alive() then return end
|
||||
local blur = (math.sin(CurTime() * 3) * 5 + 5) * 5 *
|
||||
math.Clamp((endTime - CurTime()) / effectDuration, 0, 1)
|
||||
DrawMotionBlur(0.1, blur, 0.05)
|
||||
end)
|
||||
|
||||
timer.Create("ShakeEffectTimer", 0.05, effectDuration * 20, function()
|
||||
ApplyShake(endTime)
|
||||
end)
|
||||
|
||||
timer.Create("ConcussionEnd", effectDuration, 1, function()
|
||||
concussionActive = false
|
||||
|
||||
hook.Remove("HUDPaint", "DarkenScreenEffect")
|
||||
hook.Remove("RenderScreenspaceEffects", "BlurScreenEffect")
|
||||
hook.Remove("CalcView", "ConcussionCameraShake")
|
||||
timer.Remove("ShakeEffectTimer")
|
||||
|
||||
if not IsValid(LocalPlayer()) then return end
|
||||
|
||||
local gasps = {
|
||||
"gasp/focus_gasp_01.wav",
|
||||
"gasp/focus_gasp_02.wav",
|
||||
"gasp/focus_gasp_03.wav",
|
||||
"gasp/focus_gasp_04.wav",
|
||||
"gasp/focus_gasp_05.wav",
|
||||
"gasp/focus_gasp_06.wav"
|
||||
}
|
||||
|
||||
surface.PlaySound(table.Random(gasps))
|
||||
end)
|
||||
end)
|
||||
|
||||
local originalWalk, originalRun = nil, nil
|
||||
local slowEnd = 0
|
||||
|
||||
net.Receive("ConcussionSlowdown", function()
|
||||
local mult = net.ReadFloat()
|
||||
local duration = net.ReadFloat()
|
||||
local ply = LocalPlayer()
|
||||
|
||||
if not IsValid(ply) then return end
|
||||
|
||||
if not originalWalk then
|
||||
originalWalk = ply:GetWalkSpeed()
|
||||
originalRun = ply:GetRunSpeed()
|
||||
end
|
||||
|
||||
ply:SetWalkSpeed(originalWalk * mult)
|
||||
ply:SetRunSpeed(originalRun * mult)
|
||||
|
||||
slowEnd = CurTime() + duration
|
||||
|
||||
timer.Create("ConcussionRestoreSpeed", duration, 1, function()
|
||||
if IsValid(ply) then
|
||||
ply:SetWalkSpeed(originalWalk)
|
||||
ply:SetRunSpeed(originalRun)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
hook.Add("PlayerSpawn", "Concussion_ResetOnRespawn", function(ply)
|
||||
if ply ~= LocalPlayer() then return end
|
||||
|
||||
concussionActive = false
|
||||
|
||||
hook.Remove("HUDPaint", "DarkenScreenEffect")
|
||||
hook.Remove("RenderScreenspaceEffects", "BlurScreenEffect")
|
||||
hook.Remove("CalcView", "ConcussionCameraShake")
|
||||
|
||||
timer.Remove("ShakeEffectTimer")
|
||||
timer.Remove("ConcussionEnd")
|
||||
|
||||
if originalWalk and originalRun then
|
||||
ply:SetWalkSpeed(originalWalk)
|
||||
ply:SetRunSpeed(originalRun)
|
||||
end
|
||||
end)
|
||||
|
||||
-----------------------------------------
|
||||
-- FT CONTUSION (MILITARY RP)
|
||||
-- Собственность Олега Закона и Scripty
|
||||
-----------------------------------------
|
||||
@@ -0,0 +1,153 @@
|
||||
-----------------------------------------
|
||||
-- FT CONTUSION (MILITARY RP)
|
||||
-- Собственность Олега Закона и Scripty
|
||||
-----------------------------------------
|
||||
util.AddNetworkString("StartConcussionEffect")
|
||||
util.AddNetworkString("ConcussionSlowdown")
|
||||
|
||||
local EFFECT_DURATION = 10
|
||||
local SLOW_MULT = 0.45
|
||||
|
||||
local RADIUS_HL2 = 550
|
||||
local RADIUS_LVS = 550
|
||||
local RADIUS_SWBOMB = 900
|
||||
|
||||
local function ApplyConcussion(ply)
|
||||
if not IsValid(ply) or not ply:Alive() then return end
|
||||
|
||||
-- Не применяем контузию, если игрок в обычном транспорте или в технике LVS
|
||||
if ply:InVehicle() then return end
|
||||
if ply.lvsGetVehicle and IsValid(ply:lvsGetVehicle()) then return end
|
||||
|
||||
net.Start("StartConcussionEffect")
|
||||
net.Send(ply)
|
||||
|
||||
net.Start("ConcussionSlowdown")
|
||||
net.WriteFloat(SLOW_MULT)
|
||||
net.WriteFloat(EFFECT_DURATION)
|
||||
net.Send(ply)
|
||||
end
|
||||
|
||||
local function IsTFABombProjectileClass(cls)
|
||||
if not cls or cls == "" then return false end
|
||||
return string.StartWith(cls, "tfa_bomb")
|
||||
end
|
||||
|
||||
hook.Add("EntityTakeDamage", "Concussion_TFA_Damage", function(target, dmginfo)
|
||||
if not target:IsPlayer() then return end
|
||||
|
||||
local attacker = dmginfo:GetAttacker()
|
||||
local inflictor = dmginfo:GetInflictor()
|
||||
|
||||
local aclass = IsValid(attacker) and attacker:GetClass() or ""
|
||||
local iclass = IsValid(inflictor) and inflictor:GetClass() or ""
|
||||
|
||||
if IsTFABombProjectileClass(aclass) or IsTFABombProjectileClass(iclass) then
|
||||
ApplyConcussion(target)
|
||||
return
|
||||
end
|
||||
|
||||
if IsValid(attacker) and attacker:IsPlayer() then
|
||||
local wep = attacker:GetActiveWeapon()
|
||||
if IsValid(wep) and wep.IsTFADOINade then
|
||||
ApplyConcussion(target)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityRemoved", "Concussion_TFA_Radius", function(ent)
|
||||
if not IsValid(ent) then return end
|
||||
|
||||
local cls = ent:GetClass()
|
||||
if not IsTFABombProjectileClass(cls) then return end
|
||||
|
||||
local pos = ent:GetPos()
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply:GetPos():Distance(pos) <= RADIUS_HL2 then
|
||||
ApplyConcussion(ply)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityTakeDamage", "Concussion_HL2", function(target, dmginfo)
|
||||
if not target:IsPlayer() then return end
|
||||
if not dmginfo:IsExplosionDamage() then return end
|
||||
|
||||
ApplyConcussion(target)
|
||||
end)
|
||||
|
||||
hook.Add("EntityTakeDamage", "Concussion_LVS_Damage", function(target, dmginfo)
|
||||
if not target:IsPlayer() then return end
|
||||
|
||||
local attacker = dmginfo:GetAttacker()
|
||||
if not IsValid(attacker) then return end
|
||||
|
||||
local class = attacker:GetClass()
|
||||
if class == "lvs_item_explosive" or string.find(class, "lvs_item_explosive") then
|
||||
attacker._DidExplode = true
|
||||
ApplyConcussion(target)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityRemoved", "Concussion_LVS_Radius", function(ent)
|
||||
if not IsValid(ent) then return end
|
||||
|
||||
local class = ent:GetClass()
|
||||
if class ~= "lvs_item_explosive" and not string.find(class, "lvs_item_explosive") then return end
|
||||
if not ent._DidExplode then return end
|
||||
|
||||
local pos = ent:GetPos()
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply:GetPos():Distance(pos) <= RADIUS_LVS then
|
||||
ApplyConcussion(ply)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("OnEntityCreated", "SWBombV3_ExplosionDetector", function(ent)
|
||||
if not IsValid(ent) then return end
|
||||
|
||||
if ent:GetClass() == "swbomb_explosion" then
|
||||
local pos = ent:GetPos()
|
||||
|
||||
for _, bomb in ipairs(ents.FindInSphere(pos, 200)) do
|
||||
if bomb.SWBombV3 then
|
||||
bomb._DidExplode = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityTakeDamage", "Concussion_SWBomb_Damage", function(target, dmginfo)
|
||||
if not target:IsPlayer() then return end
|
||||
|
||||
local attacker = dmginfo:GetAttacker()
|
||||
if not IsValid(attacker) then return end
|
||||
|
||||
if attacker.SWBombV3 then
|
||||
attacker._DidExplode = true
|
||||
ApplyConcussion(target)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityRemoved", "Concussion_SWBomb_Radius", function(ent)
|
||||
if not IsValid(ent) then return end
|
||||
if not ent.SWBombV3 then return end
|
||||
if not ent.Exploded then return end
|
||||
|
||||
local pos = ent:GetPos()
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply:GetPos():Distance(pos) <= RADIUS_SWBOMB then
|
||||
ApplyConcussion(ply)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-----------------------------------------
|
||||
-- FT CONTUSION (MILITARY RP)
|
||||
-- Собственность Олега Закона и Scripty
|
||||
-----------------------------------------
|
||||
Reference in New Issue
Block a user