Залив
This commit is contained in:
279
gamemodes/cod_custom/gamemode/server/sv_abilities.lua
Normal file
279
gamemodes/cod_custom/gamemode/server/sv_abilities.lua
Normal file
@@ -0,0 +1,279 @@
|
||||
local meta = FindMetaTable("Player")
|
||||
|
||||
function COD:IsAllowedSelfRevive()
|
||||
return COD.DataTable["Gamemode"] != 3
|
||||
end
|
||||
|
||||
function meta:StopSlide()
|
||||
return self.Takedowning or self:GetNWBool('Downed') or self:GetNWString('SVAnim') != "" or self:WaterLevel() > 1 or !self:Alive() or !self:OnGround()
|
||||
end
|
||||
|
||||
function meta:Sliding(bool)
|
||||
if bool then
|
||||
if isvector(self.SlidingVelocity) then return end
|
||||
|
||||
local ang = self:GetAngles()
|
||||
ang.x = 0
|
||||
ang.z = 0
|
||||
local vec = ang:Forward()*32
|
||||
self.SlidingDuration = CurTime()+1
|
||||
self.SlidingVelocity = vec
|
||||
self:SetNWBool('Sliding', true)
|
||||
self:EmitSound("tdmg/ply/slide"..math.random(1,3)..".wav")
|
||||
self:ViewPunch(Angle(-5,0,0))
|
||||
else
|
||||
self.SlidingVelocity = nil
|
||||
self:SetNWBool('Sliding', false)
|
||||
end
|
||||
end
|
||||
|
||||
function meta:IsDowned()
|
||||
return self:GetNWBool('Downed')
|
||||
end
|
||||
|
||||
function meta:MovingDirection(threshold) --This function was made by OpenAI ChatGPT
|
||||
threshold = threshold or 0.1
|
||||
local vel = self:GetVelocity()
|
||||
local forward = self:GetForward()
|
||||
local right = self:GetRight()
|
||||
local forwardDot = vel:Dot(forward)
|
||||
local rightDot = vel:Dot(right)
|
||||
|
||||
if forwardDot > threshold then
|
||||
return "forward"
|
||||
elseif forwardDot < -threshold then
|
||||
return "backward"
|
||||
end
|
||||
|
||||
if rightDot > threshold then
|
||||
return "right"
|
||||
elseif rightDot < -threshold then
|
||||
return "left"
|
||||
end
|
||||
|
||||
return "stand"
|
||||
end
|
||||
|
||||
function meta:Down()
|
||||
if COD:IsAllowedSelfRevive() then
|
||||
self:SetNWFloat('DownedTime', CurTime()+15)
|
||||
else
|
||||
self:SetNWFloat('DownedTime', CurTime()+30)
|
||||
end
|
||||
self:SetNWBool('Downed', true)
|
||||
self:SetViewOffset( Vector(0,0,24) )
|
||||
self:SetViewOffsetDucked( Vector(0,0,24) )
|
||||
self:SetHealth(50)
|
||||
self:SetJumpPower(0)
|
||||
self.AlreadyWasDowned = true
|
||||
self.ReviveNumber = 0
|
||||
self:SetSVAnimation("laststand_down", true)
|
||||
self:GodEnable()
|
||||
self:SetActiveWeapon(nil)
|
||||
timer.Simple(0.5, function()
|
||||
if !IsValid(self) then return end
|
||||
self:GodDisable()
|
||||
end)
|
||||
end
|
||||
|
||||
function meta:Revive(died)
|
||||
self:SetViewOffset( Vector(0,0,64) )
|
||||
self:SetViewOffsetDucked( Vector(0,0,32) )
|
||||
self:SetJumpPower(128)
|
||||
self:SetHealth(25)
|
||||
if died then
|
||||
self:Kill()
|
||||
else
|
||||
self:SetSVAnimation("laststand_standup", true)
|
||||
end
|
||||
self:SetNWBool('Downed', false)
|
||||
self.RevivingSelf = false
|
||||
end
|
||||
|
||||
hook.Add("SetupMove", "TDMSetupMove1", function(ply, mv, cmd)
|
||||
if ply:IsDowned() then
|
||||
if ply:KeyDown(IN_USE) or IsValid(ply:GetNWEntity('Reviver')) then
|
||||
mv:SetForwardSpeed(1)
|
||||
mv:SetSideSpeed(1)
|
||||
else
|
||||
mv:SetMaxSpeed(25)
|
||||
mv:SetMaxClientSpeed(25)
|
||||
end
|
||||
end
|
||||
if isvector(ply.SlidingVelocity) then
|
||||
mv:SetMaxSpeed(1)
|
||||
mv:SetMaxClientSpeed(1)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDMSliding", function()
|
||||
for _, ent in ipairs(player.GetAll()) do
|
||||
if isvector(ent.SlidingVelocity) then
|
||||
ent:SetVelocity(ent.SlidingVelocity)
|
||||
end
|
||||
if ent:KeyDown(IN_SPEED) and ent:KeyDown(IN_DUCK) and not ent:Crouching() and !ent:StopSlide() then
|
||||
ent:Sliding(true)
|
||||
end
|
||||
if !ent:KeyDown(IN_DUCK) and isvector(ent.SlidingVelocity) or ent.SlidingDuration and ent.SlidingDuration < CurTime() or ent:StopSlide() then
|
||||
ent:Sliding(false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("PlayerDeath", "TDMRevive", function(ply)
|
||||
if ply:IsDowned() then
|
||||
ply:Revive()
|
||||
end
|
||||
ply.AlreadyWasDowned = false
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDMAnimsRevive", function()
|
||||
local plys2 = player.GetAll()
|
||||
for i=1,#plys2 do
|
||||
local ply = plys2[i]
|
||||
if ply:IsDowned() and ply:GetNWFloat('DownedTime') < CurTime() and (not ply:KeyDown(IN_USE) or !COD:IsAllowedSelfRevive()) and !IsValid(ply:GetNWEntity('Reviver')) and not ply.Takedowning then
|
||||
ply:Revive(true)
|
||||
end
|
||||
if ply:Alive() and not ply:IsDowned() and ply:KeyDown(IN_USE) then
|
||||
local tr = ply:GetEyeTrace()
|
||||
local ent = tr.Entity
|
||||
local dist = ply:EyePos():DistToSqr(tr.HitPos) < 5000
|
||||
if ent:IsPlayer() and dist and ent:IsDowned() and ply:Team() == ent:Team() then
|
||||
ent:SetNWEntity('Reviver', ply)
|
||||
ply.RevivingThatEntity = ent
|
||||
end
|
||||
if !IsValid(ply.RevivingThatEntity) or !ply.RevivingThatEntity:Alive() or not ply.RevivingThatEntity:IsDowned() then
|
||||
ply.RevivingThatEntity = nil
|
||||
if ply:GetNWString('SVAnim') == "laststand_startrevive" and not ply.Takedowning then
|
||||
ply:SetSVAnimation("")
|
||||
end
|
||||
end
|
||||
end
|
||||
if ply:IsDowned() then
|
||||
local rev = ply:GetNWEntity('Reviver')
|
||||
ply:SetActiveWeapon(nil)
|
||||
if !IsValid(rev) and ply:KeyDown(IN_USE) and not ply.Takedowning and COD:IsAllowedSelfRevive() then
|
||||
ply.ReviveNumber = ply.ReviveNumber + FrameTime()/5.5
|
||||
if not ply.RevivingSelf then
|
||||
ply:SetSVAnimation("laststand_selfrevive", true)
|
||||
ply.RevivingSelf = true
|
||||
end
|
||||
elseif !IsValid(rev) and not ply:KeyDown(IN_USE) and not ply.Takedowning then
|
||||
ply.ReviveNumber = 0
|
||||
if ply.RevivingSelf then
|
||||
ply:SetSVAnimation("")
|
||||
ply.RevivingSelf = false
|
||||
end
|
||||
end
|
||||
if IsValid(rev) then
|
||||
if rev:KeyDown(IN_USE) and rev:GetEyeTrace().Entity == ply and not ply.Takedowning then
|
||||
ply.ReviveNumber = ply.ReviveNumber + FrameTime()/3
|
||||
rev:SetActiveWeapon(nil)
|
||||
if not rev.RevivingTarget then
|
||||
rev:SetSVAnimation("laststand_startrevive")
|
||||
rev.RevivingTarget = true
|
||||
end
|
||||
else
|
||||
if rev.RevivingTarget then
|
||||
rev:SetSVAnimation("")
|
||||
rev:SelectWeapon(rev:GetNWString('MainWep'))
|
||||
rev.RevivingTarget = false
|
||||
end
|
||||
ply:SetNWEntity('Reviver', NULL)
|
||||
end
|
||||
end
|
||||
if ply.ReviveNumber >= 1 then
|
||||
ply.ReviveNumber = 0
|
||||
ply:SetSVAnimation("")
|
||||
if IsValid(rev) then
|
||||
rev:ChangeScore(100)
|
||||
rev:SetSVAnimation("")
|
||||
rev:SelectWeapon(rev:GetNWString('MainWep'))
|
||||
rev.RevivingTarget = false
|
||||
COD:GiveMessageCenter({rev}, 5)
|
||||
end
|
||||
ply:Revive()
|
||||
ply:SelectWeapon(ply:GetNWString('MainWep'))
|
||||
end
|
||||
else
|
||||
ply:SetNWEntity('Reviver', NULL)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("CalcMainActivity", "TDMAnimsRevive", function(ply, vel)
|
||||
if ply:IsDowned() and ply:GetNWString('SVAnim') == "" then
|
||||
local anim1 = ply:LookupSequence("laststand_idle")
|
||||
local anim2 = ply:LookupSequence("laststand_crawl_forward")
|
||||
local anim3 = ply:LookupSequence("laststand_crawl_backward")
|
||||
local anim4 = ply:LookupSequence("laststand_crawl_left")
|
||||
local anim5 = ply:LookupSequence("laststand_crawl_right")
|
||||
local dir = ply:MovingDirection(8)
|
||||
local vel = ply:GetVelocity():Length2D() > 10
|
||||
if dir == "forward" and vel then
|
||||
return -1, anim2
|
||||
elseif dir == "backward" and vel then
|
||||
return -1, anim3
|
||||
elseif dir == "left" and vel then
|
||||
return -1, anim4
|
||||
elseif dir == "right" and vel then
|
||||
return -1, anim5
|
||||
else
|
||||
return -1, anim1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local delay = CurTime()+5
|
||||
hook.Add("Think", "TDMApplyCommands", function()
|
||||
if delay < CurTime() then
|
||||
delay = CurTime()+5
|
||||
for k, v in pairs(COD.ApplyCommands["Server"]) do
|
||||
RunConsoleCommand(k, v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
concommand.Add("cod_jointeam", function(ply, cmd, args)
|
||||
local float = tonumber(args[1])
|
||||
if ply:IsSuperAdmin() then
|
||||
ply:SetTeam(float)
|
||||
ply:Spawn()
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
function COD:InfilStart()
|
||||
if COD.DataTable["Gamemode"] == 4 then return end
|
||||
|
||||
local t1s, t2s = COD.DataTable["Team1_InfilSettings"], COD.DataTable["Team2_InfilSettings"]
|
||||
|
||||
for k1, v1 in pairs(t1s.positions) do
|
||||
timer.Simple(0.1*k1, function()
|
||||
local infil = ents.Create("tdm_player_infil")
|
||||
infil:SetPos(v1)
|
||||
infil:SetAngles(t1s.angles[k1])
|
||||
infil.Infil = t1s.type
|
||||
infil.TeamChoose = 1
|
||||
infil:Spawn()
|
||||
end)
|
||||
end
|
||||
|
||||
for k2, v2 in pairs(t2s.positions) do
|
||||
timer.Simple(0.1*k2, function()
|
||||
local infil = ents.Create("tdm_player_infil")
|
||||
infil:SetPos(v2)
|
||||
infil:SetAngles(t2s.angles[k2])
|
||||
infil.Infil = t2s.type
|
||||
infil.TeamChoose = 2
|
||||
infil:Spawn()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("COD.ChangeState", "TDM_Infil", function(start)
|
||||
if COD.DataTable["Enable_InfilAnimations"] and start then
|
||||
COD:InfilStart()
|
||||
end
|
||||
end)
|
||||
40
gamemodes/cod_custom/gamemode/server/sv_domination.lua
Normal file
40
gamemodes/cod_custom/gamemode/server/sv_domination.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
function COD:SpawnDominationFlags()
|
||||
local tab = COD.DataTable["flag_Spawns"]
|
||||
for i=1,3 do
|
||||
local flag = ents.Create("tdm_domination_flag")
|
||||
flag:SetPos(tab[i])
|
||||
flag:Spawn()
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------
|
||||
|
||||
hook.Add("PlayerDeath", "TDMPlayer_Domination", function(ply)
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 5 then
|
||||
if ply:Team() == 1 then
|
||||
COD:AddFragsToData(2, -1)
|
||||
elseif ply:Team() == 2 then
|
||||
COD:AddFragsToData(1, -1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("COD.ChangeState", "TDMPlayer_Domination", function(start)
|
||||
if start and COD.DataTable["Gamemode"] == 5 then
|
||||
COD:SpawnDominationFlags()
|
||||
end
|
||||
end)
|
||||
|
||||
local thinkdelay = 0
|
||||
hook.Add("Think", "TDMPlayer_Domination", function()
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 5 and thinkdelay < CurTime() then
|
||||
thinkdelay = CurTime()+3
|
||||
|
||||
for k, v in ipairs(ents.FindByClass("tdm_domination_flag")) do
|
||||
local team = v:GetNWFloat('Team')
|
||||
if team > 0 then
|
||||
COD:AddFragsToData(team, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
1220
gamemodes/cod_custom/gamemode/server/sv_functions.lua
Normal file
1220
gamemodes/cod_custom/gamemode/server/sv_functions.lua
Normal file
File diff suppressed because it is too large
Load Diff
172
gamemodes/cod_custom/gamemode/server/sv_infected.lua
Normal file
172
gamemodes/cod_custom/gamemode/server/sv_infected.lua
Normal file
@@ -0,0 +1,172 @@
|
||||
COD.DelayGamemodeNumber = 999999999
|
||||
|
||||
function COD:JoinAllToTeam()
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
ply:SetTeam(1)
|
||||
ply:KillSilent()
|
||||
ply:Spawn()
|
||||
end
|
||||
end
|
||||
|
||||
function COD:ShowTimer(num)
|
||||
net.Start("COD.TimerShow")
|
||||
net.WriteFloat(num)
|
||||
net.Broadcast()
|
||||
end
|
||||
|
||||
function COD:RandomInfection()
|
||||
local tabp = player.GetAll()
|
||||
local ply = table.Random(tabp)
|
||||
for _, plys in ipairs(tabp) do
|
||||
if plys != ply then
|
||||
COD:GiveMessageCenter(plys, 9)
|
||||
plys:ChangeScore(50)
|
||||
end
|
||||
end
|
||||
if IsValid(ply) then
|
||||
local pos = ply:GetPos()
|
||||
local ang = ply:EyeAngles()
|
||||
ply:SetTeam(2)
|
||||
ply:KillSilent()
|
||||
ply:Spawn()
|
||||
COD:GiveMessageCenter(ply, 7)
|
||||
timer.Simple(0.02, function()
|
||||
if !IsValid(ply) then return end
|
||||
|
||||
ply:SetPos(pos)
|
||||
ply:SetEyeAngles(ang)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("PlayerDeath", "TDMPlayer_Infection", function(ply, inf, att)
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 4 then
|
||||
COD.DataTable["Team1_Kills"] = 0
|
||||
COD.DataTable["Team2_Kills"] = 0
|
||||
if ply:Team() == 1 then
|
||||
COD.TimeBeforeEnd = COD.TimeBeforeEnd+30
|
||||
BroadcastLua([[
|
||||
COD.TimeMatch = ]]..COD.TimeBeforeEnd..[[
|
||||
]])
|
||||
for _, plys in ipairs(team.GetPlayers(1)) do
|
||||
COD:GiveMessageCenter(plys, 9)
|
||||
plys:ChangeScore(50)
|
||||
end
|
||||
end
|
||||
timer.Simple(0.1, function()
|
||||
if !IsValid(ply) or ply:Team() == 2 then return end
|
||||
|
||||
ply:SetTeam(2)
|
||||
if #team.GetPlayers(1) == 1 then
|
||||
COD:GiveMessageCenter(player.GetAll(), 8)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("PlayerSpawn", "TDMPlayer_Infection", function(ply)
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 4 then
|
||||
timer.Simple(0.01, function()
|
||||
if !IsValid(ply) then return end
|
||||
|
||||
ply:SetNWFloat('Perk1', 4)
|
||||
ply:SetNWFloat('Perk2', 0)
|
||||
ply:SetNWFloat('Perk1_Choose', 0)
|
||||
ply:SetNWFloat('Perk2_Choose', 0)
|
||||
ply:SetNWFloat('KillStreak1', 0)
|
||||
ply:SetNWFloat('KillStreak2', 0)
|
||||
ply:SetNWFloat('KillStreak3', 0)
|
||||
ply:SetPos(table.Random(COD.DataTable["simple_Spawns"]))
|
||||
if ply:Team() == 2 then
|
||||
ply:SetModel("models/humangrunt/cod4/captain_macmillan_pm.mdl")
|
||||
ply:SetupHands()
|
||||
ply:StripWeapons()
|
||||
ply:Give('tdm_infection_knife')
|
||||
ply:SetNWFloat('FragGrenades', 0)
|
||||
ply:SetNWFloat('FlashGrenades', 0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("COD.ChangeState", "TDMPlayer_Infection", function(start)
|
||||
if start and COD.DataTable["Gamemode"] == 4 then
|
||||
COD.TimeBefore1PerkUnlock = math.huge
|
||||
COD.TimeBefore2PerkUnlock = math.huge
|
||||
COD.DisableSpawn = false
|
||||
COD.DelayGamemodeNumber = CurTime()+COD.DataTable["Delay_Before_Start"]+21
|
||||
COD.DisableEndGameByNoTeam = true
|
||||
COD:JoinAllToTeam()
|
||||
timer.Simple(COD.DataTable["Delay_Before_Start"]+10, function()
|
||||
if COD.DataTable["Gamemode"] == 4 and COD.GameStarted then
|
||||
COD:ShowTimer(10)
|
||||
end
|
||||
end)
|
||||
timer.Simple(COD.DataTable["Delay_Before_Start"]+20, function()
|
||||
if COD.DataTable["Gamemode"] == 4 and COD.GameStarted then
|
||||
COD:RandomInfection()
|
||||
end
|
||||
end)
|
||||
else
|
||||
COD.DisableSpawn = false
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDMPlayer_Infection", function()
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 4 then
|
||||
local team1, team1alive = team.GetPlayers(1), false
|
||||
local team2alive = false
|
||||
local loseteam = 0
|
||||
|
||||
for k, p in ipairs(team1) do
|
||||
if p:Alive() then
|
||||
team1alive = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if #team.GetPlayers(2) != 0 then
|
||||
team2alive = true
|
||||
end
|
||||
|
||||
if team1alive and team2alive then
|
||||
COD.DelayGamemodeNumber = CurTime()+2
|
||||
loseteam = 0
|
||||
elseif team1alive and not team2alive then
|
||||
loseteam = 1
|
||||
elseif team2alive and not team1alive then
|
||||
loseteam = 2
|
||||
COD.TimeBeforeEnd = 0
|
||||
elseif not team1alive and not team2alive then
|
||||
loseteam = 3
|
||||
end
|
||||
|
||||
if COD.TimeBeforeStart < CurTime()+1 and team1alive then
|
||||
loseteam = 1
|
||||
COD.DelayGamemodeNumber = 0
|
||||
end
|
||||
|
||||
if loseteam == 1 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team1_Kills"] = 1
|
||||
COD.DataTable["Team2_Kills"] = 0
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
elseif loseteam == 2 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team2_Kills"] = 1
|
||||
COD.DataTable["Team1_Kills"] = 0
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
elseif loseteam == 3 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team1_Kills"] = 0
|
||||
COD.DataTable["Team2_Kills"] = 0
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
end
|
||||
end
|
||||
end)
|
||||
335
gamemodes/cod_custom/gamemode/server/sv_invasion.lua
Normal file
335
gamemodes/cod_custom/gamemode/server/sv_invasion.lua
Normal file
@@ -0,0 +1,335 @@
|
||||
COD_Invasion = COD_Invasion or {}
|
||||
COD_Invasion.current_ai_spawned_team1 = 0
|
||||
COD_Invasion.current_ai_spawned_team2 = 0
|
||||
COD_Invasion.current_ai_max_team = COD.DataTable["MaxAIInTeam"]
|
||||
COD_Invasion.HeavyUnitsDelay = 0
|
||||
COD_Invasion.HeavyUnits = false
|
||||
COD_Invasion.SupportPackagesDelay = 0
|
||||
COD_Invasion.SupportPackages = false
|
||||
|
||||
local delay_in_action = 0
|
||||
local spawn_team1_delay = 0
|
||||
local spawn_team2_delay = 0
|
||||
local heli_team1_delay = 0
|
||||
local heli_team2_delay = 0
|
||||
------------------------------------------------------------------------
|
||||
|
||||
hook.Add("OnNPCKilled", "TDM_Invasion", function(ent, att)
|
||||
if COD.DataTable["Gamemode"] == 2 then
|
||||
local class1 = "vj_tdm_invasion_soldier1"
|
||||
local class2 = "vj_tdm_invasion_soldier2"
|
||||
|
||||
if class1 == ent:GetClass() then
|
||||
COD:AddFragsToData(2, 1)
|
||||
COD_Invasion.current_ai_spawned_team1 = COD_Invasion.current_ai_spawned_team1 - 1
|
||||
elseif class2 == ent:GetClass() then
|
||||
COD:AddFragsToData(1, 1)
|
||||
COD_Invasion.current_ai_spawned_team2 = COD_Invasion.current_ai_spawned_team2 - 1
|
||||
end
|
||||
end
|
||||
if att:IsPlayer() then
|
||||
att:AddFrags(1)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("PlayerDeath", "TDM_Invasion", function(ply)
|
||||
if COD.DataTable["Gamemode"] == 2 then
|
||||
if ply:Team() == 1 then
|
||||
COD:AddFragsToData(2, 4)
|
||||
elseif ply:Team() == 2 then
|
||||
COD:AddFragsToData(1, 4)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("COD.ChangeState", "TDM_Invasion", function(start)
|
||||
if COD.DataTable["Gamemode"] == 2 then
|
||||
COD_Invasion:RemoveAllAI()
|
||||
if start then
|
||||
spawn_team1_delay = CurTime()+15
|
||||
spawn_team2_delay = CurTime()+15
|
||||
heli_team1_delay = CurTime()+30
|
||||
heli_team2_delay = CurTime()+30
|
||||
COD_Invasion:CreateStartAI()
|
||||
COD_Invasion.HeavyUnits = false
|
||||
COD_Invasion.SupportPackages = false
|
||||
COD_Invasion.HeavyUnitsDelay = CurTime()+COD.GamemodeSettings[2]["Time_Before_HeavyUnits"]
|
||||
COD_Invasion.SupportPackagesDelay = CurTime()+COD.GamemodeSettings[2]["Time_Before_SupportPackages"]
|
||||
else
|
||||
COD_Invasion.HeavyUnitsDelay = math.huge
|
||||
COD_Invasion.SupportPackagesDelay = math.huge
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("OnEntityCreated", "TDM_Invasion", function(ent)
|
||||
local class1 = "vj_tdm_invasion_soldier1"
|
||||
local class2 = "vj_tdm_invasion_soldier2"
|
||||
|
||||
if class1 == ent:GetClass() then
|
||||
COD_Invasion.current_ai_spawned_team1 = COD_Invasion.current_ai_spawned_team1 + 1
|
||||
elseif class2 == ent:GetClass() then
|
||||
COD_Invasion.current_ai_spawned_team2 = COD_Invasion.current_ai_spawned_team2 + 1
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDM_Invasion", function(start)
|
||||
if COD.TimeBeforeEnd < CurTime() and COD.GameStarted then
|
||||
COD_Invasion:RemoveAllAI()
|
||||
end
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 2 then
|
||||
if COD_Invasion.HeavyUnitsDelay < CurTime() and not COD_Invasion.HeavyUnits then
|
||||
COD_Invasion.HeavyUnits = true
|
||||
COD:ShowAnnouncment(2)
|
||||
end
|
||||
if COD_Invasion.SupportPackagesDelay < CurTime() and not COD_Invasion.SupportPackages then
|
||||
COD_Invasion.SupportPackages = true
|
||||
COD_Invasion:SupplyPackages()
|
||||
COD:ShowAnnouncment(1)
|
||||
end
|
||||
if delay_in_action < CurTime() then
|
||||
|
||||
delay_in_action = CurTime() + 1
|
||||
|
||||
local team1 = COD_Invasion:GetAICount(1)
|
||||
local team2 = COD_Invasion:GetAICount(2)
|
||||
local max = COD_Invasion.current_ai_max_team
|
||||
|
||||
if team1 < max and spawn_team1_delay < CurTime() then
|
||||
spawn_team1_delay = CurTime() + 2
|
||||
COD_Invasion:CreateSoldier(1)
|
||||
|
||||
if heli_team1_delay < CurTime() then
|
||||
heli_team1_delay = CurTime()+math.random(60,120)
|
||||
COD_Invasion:CreateHeli(1)
|
||||
end
|
||||
end
|
||||
|
||||
if team2 < max and spawn_team2_delay < CurTime() then
|
||||
spawn_team2_delay = CurTime() + 2
|
||||
COD_Invasion:CreateSoldier(2)
|
||||
|
||||
if heli_team2_delay < CurTime() then
|
||||
heli_team2_delay = CurTime()+math.random(60,120)
|
||||
COD_Invasion:CreateHeli(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
function COD_Invasion:SupplyPackages()
|
||||
heli_team1_delay = CurTime()+30
|
||||
heli_team2_delay = CurTime()+30
|
||||
|
||||
for i, pos in ipairs(COD.DataTable["backup_Spawns"]) do
|
||||
local tr2 = util.TraceLine( {
|
||||
start = pos,
|
||||
endpos = pos+Vector(0,0,99999),
|
||||
filter = function( ent ) return ( ent:GetClass() == "prop_static" ) end,
|
||||
} )
|
||||
|
||||
local height = math.Clamp(tr2.HitPos:Distance(pos), 100, 600)
|
||||
|
||||
local heli = ents.Create("prop_dynamic")
|
||||
heli:SetModel("models/tdmg/heli.mdl")
|
||||
heli:SetPos(pos+Vector(0,0,4))
|
||||
heli:SetAngles(Angle(0,math.random(0,360),0))
|
||||
heli:Spawn()
|
||||
heli:ResetSequence("spawn")
|
||||
heli:SetBodygroup(3, 1)
|
||||
|
||||
timer.Simple(1, function()
|
||||
for i=1,10 do
|
||||
local sproxy = ents.Create("tdm_infil_soundproxy")
|
||||
sproxy:SetOwner(heli:GetOwner())
|
||||
sproxy:SetPos(heli:GetPos())
|
||||
sproxy:SetAngles(heli:GetAngles())
|
||||
sproxy:SetParent(heli)
|
||||
sproxy.Sound = "tdmg/sas1_veh1_int_quad_front_stat.wav"
|
||||
sproxy.Bone = "tag_main_rotor_static"
|
||||
sproxy.Vol = 100
|
||||
sproxy:Spawn()
|
||||
end
|
||||
end)
|
||||
|
||||
timer.Simple(12, function()
|
||||
if !IsValid(heli) then return end
|
||||
local care = ents.Create("tdm_package")
|
||||
care:SetPos(pos+Vector(0,0,height-64))
|
||||
care:Spawn()
|
||||
care:SetAngles(heli:GetAngles())
|
||||
end)
|
||||
|
||||
timer.Simple(30, function()
|
||||
if IsValid(heli) then
|
||||
heli:Remove()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function COD_Invasion:CreateSoldier(team, custompos, freezetime)
|
||||
local sol = ents.Create("vj_tdm_invasion_soldier"..team)
|
||||
if custompos then
|
||||
sol:SetPos(custompos)
|
||||
else
|
||||
sol:SetPos(COD_Invasion:GetAIPosition(team))
|
||||
end
|
||||
sol.Team = team
|
||||
sol:Spawn()
|
||||
if freezetime then
|
||||
sol:AddEFlags(EFL_NO_THINK_FUNCTION)
|
||||
sol:SetSequence("idle_passive")
|
||||
timer.Simple(freezetime, function()
|
||||
if !IsValid(sol) then return end
|
||||
sol:RemoveEFlags(EFL_NO_THINK_FUNCTION)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function COD_Invasion:CreateHeli(team, custompos)
|
||||
local h = ents.Create("tdm_infil")
|
||||
if custompos then
|
||||
h:SetPos(custompos)
|
||||
else
|
||||
h:SetPos(COD_Invasion:GetHeliPosition(team))
|
||||
end
|
||||
h.Team2Team = team == 2
|
||||
h.Invasion = true
|
||||
h.KillstreakModel = true
|
||||
h.Team = team
|
||||
h:Spawn()
|
||||
h:SetNWFloat('Team', h.Team)
|
||||
end
|
||||
|
||||
function COD_Invasion:CreateStartAI()
|
||||
local spos_team1 = COD.DataTable["Team1_AISpawns"]
|
||||
local spos_team2 = COD.DataTable["Team2_AISpawns"]
|
||||
local hpos_team1 = COD.DataTable["Team1_HeliSpawns"]
|
||||
local hpos_team2 = COD.DataTable["Team2_HeliSpawns"]
|
||||
|
||||
for k, v in pairs(spos_team1) do
|
||||
COD_Invasion:CreateSoldier(1, v, COD.DataTable["Delay_Before_Start"]-2)
|
||||
end
|
||||
for k, v in pairs(spos_team2) do
|
||||
COD_Invasion:CreateSoldier(2, v, COD.DataTable["Delay_Before_Start"]-2)
|
||||
end
|
||||
|
||||
local delay = 0
|
||||
if COD.DataTable["Enable_InfilAnimations"] then
|
||||
delay = 20
|
||||
end
|
||||
|
||||
timer.Simple(delay, function()
|
||||
for k, v in pairs(hpos_team1) do
|
||||
COD_Invasion:CreateHeli(1, v, COD.DataTable["Delay_Before_Start"]-2)
|
||||
end
|
||||
for k, v in pairs(hpos_team2) do
|
||||
COD_Invasion:CreateHeli(2, v, COD.DataTable["Delay_Before_Start"]-2)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function COD_Invasion:RemoveAllAI()
|
||||
local soldiers = ents.FindByClass("vj_tdm_invasion_*")
|
||||
|
||||
COD_Invasion.current_ai_spawned_team1 = 0
|
||||
COD_Invasion.current_ai_spawned_team2 = 0
|
||||
for k, v in pairs(soldiers) do
|
||||
v:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function COD_Invasion:GetAICount(team)
|
||||
local soldiers = ents.FindByClass("vj_tdm_invasion_*")
|
||||
local count = 0
|
||||
|
||||
for k, v in pairs(soldiers) do
|
||||
if v.Team == team then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
function COD_Invasion:GetAIPosition(team)
|
||||
local enemy_players = player.GetAll()
|
||||
|
||||
local positions = {}
|
||||
for _, pos in ipairs(COD.DataTable["simple_Spawns"]) do
|
||||
local can = true
|
||||
local gdist = 0
|
||||
for _, en in ipairs(enemy_players) do
|
||||
if en:Alive() and en:Team() != team then
|
||||
local dist = en:GetPos():DistToSqr(pos)
|
||||
if en:IsLineOfSightClear(pos) or dist < 50000 then
|
||||
can = false
|
||||
end
|
||||
for v, n in ipairs(ents.FindInSphere(pos, 64)) do
|
||||
if n:IsNPC() or n:IsPlayer() then
|
||||
can = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if dist > gdist then
|
||||
gdist = dist
|
||||
end
|
||||
end
|
||||
end
|
||||
if can then
|
||||
table.insert(positions, {vec = pos, dist = gdist})
|
||||
end
|
||||
end
|
||||
if #positions > 0 then
|
||||
local position, dist = positions[1].vec, 0
|
||||
for _, p in ipairs(positions) do
|
||||
if p.dist > dist then
|
||||
dist = p.dist
|
||||
position = p.vec
|
||||
end
|
||||
end
|
||||
return position
|
||||
else
|
||||
return table.Random(COD.DataTable["simple_Spawns"])
|
||||
end
|
||||
end
|
||||
|
||||
function COD_Invasion:GetHeliPosition(team)
|
||||
local enemy_players = ents.GetAll()
|
||||
|
||||
local positions = {}
|
||||
for _, pos in ipairs(COD.DataTable["backup_Spawns"]) do
|
||||
local can = true
|
||||
local gdist = 0
|
||||
for _, en in ipairs(enemy_players) do
|
||||
if en:IsNPC() and en.Team != team or en:IsPlayer() and en:Team() != team then
|
||||
local dist = en:GetPos():DistToSqr(pos)
|
||||
if dist < 50000 then
|
||||
can = false
|
||||
end
|
||||
if dist > gdist then
|
||||
gdist = dist
|
||||
end
|
||||
end
|
||||
end
|
||||
if can then
|
||||
table.insert(positions, {vec = pos, dist = gdist})
|
||||
end
|
||||
end
|
||||
if #positions > 0 then
|
||||
local position, dist = positions[1].vec, 0
|
||||
for _, p in ipairs(positions) do
|
||||
if p.dist > dist then
|
||||
dist = p.dist
|
||||
position = p.vec
|
||||
end
|
||||
end
|
||||
return position
|
||||
else
|
||||
return table.Random(COD.DataTable["backup_Spawns"])
|
||||
end
|
||||
end
|
||||
168
gamemodes/cod_custom/gamemode/server/sv_killcam.lua
Normal file
168
gamemodes/cod_custom/gamemode/server/sv_killcam.lua
Normal file
@@ -0,0 +1,168 @@
|
||||
util.AddNetworkString("COD.KillcamSend")
|
||||
|
||||
COD.LastKillData = {
|
||||
length = 0,
|
||||
data = ""
|
||||
}
|
||||
|
||||
function COD:ShowLastKillCam(delay)
|
||||
if not COD.DataTable["Enable_KillCam"] then return end
|
||||
local len = COD.LastKillData.length
|
||||
local tab = COD.LastKillData.data
|
||||
timer.Simple(delay, function()
|
||||
net.Start("COD.KillcamSend")
|
||||
net.WriteUInt(len, 32)
|
||||
net.WriteData(tab, len)
|
||||
net.WriteBool(true)
|
||||
net.Broadcast()
|
||||
end)
|
||||
end
|
||||
|
||||
function COD:ShowKillCam(ply, att, delay)
|
||||
if not COD.DataTable["Enable_KillCam"] then return end
|
||||
|
||||
if !istable(ply) then
|
||||
ply = {ply}
|
||||
end
|
||||
if not delay then
|
||||
delay = 0
|
||||
end
|
||||
|
||||
if att.KillCamTable then
|
||||
local tab = att.KillCamTable
|
||||
local num2 = #att.KillCamTable-300
|
||||
|
||||
for i=1,num2 do
|
||||
table.remove(tab, 1)
|
||||
end
|
||||
|
||||
local tab3 = util.TableToJSON(tab)
|
||||
tab3 = util.Compress(tab3)
|
||||
local flt = #tab3
|
||||
|
||||
if flt < 4294967295 then
|
||||
for _, en in pairs(ply) do
|
||||
if IsValid(en) then
|
||||
net.Start("COD.KillcamSend")
|
||||
net.WriteUInt(flt, 32)
|
||||
net.WriteData(tab3, flt)
|
||||
net.WriteBool(false)
|
||||
net.Send(en)
|
||||
end
|
||||
end
|
||||
|
||||
COD.LastKillData = {
|
||||
length = flt,
|
||||
data = tab3
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("Tick", "RecordCamBot", function()
|
||||
if COD.DataTable["Enable_KillCam"] then
|
||||
local plyall = player.GetAll()
|
||||
for k=1,#plyall do
|
||||
local ply = plyall[k]
|
||||
|
||||
if !COD.DataTable["Enable_KillCam_WithBots"] and !ply:IsPlayer() then continue end
|
||||
|
||||
if not ply.KillCamTable then
|
||||
ply.KillCamTable = {}
|
||||
end
|
||||
|
||||
if #ply.KillCamTable > 500 then
|
||||
table.remove(ply.KillCamTable, 1)
|
||||
end
|
||||
|
||||
local plytab = {
|
||||
model = ply:GetModel(),
|
||||
ang = (ply:GetAimVector()):GetNormalized():Angle(),
|
||||
pos = ply:EyePos()-ply:GetAimVector()*32+ply:GetUp()*16,
|
||||
snd = "",
|
||||
blt = {},
|
||||
hit = 0
|
||||
}
|
||||
|
||||
if ply:GetNWString('SVAnim') != "" then
|
||||
plytab.ang = (ply:GetForward()*1-ply:GetRight()*2):GetNormalized():Angle()
|
||||
plytab.pos = ply:GetAttachment(ply:LookupAttachment('eyes')).Pos+ply:GetRight()*64-ply:GetForward()*16
|
||||
end
|
||||
|
||||
if ply.VMSND and istable(ply.VMSND) then
|
||||
plytab.snd = ply.VMSND
|
||||
ply.VMSND = nil
|
||||
end
|
||||
|
||||
if ply.VMBLT then
|
||||
plytab.blt = ply.VMBLT
|
||||
ply.VMBLT = nil
|
||||
end
|
||||
|
||||
if ply.VMHIT then
|
||||
plytab.hit = ply.VMHIT
|
||||
ply.VMHIT = nil
|
||||
end
|
||||
|
||||
local otab = {
|
||||
ent = {},
|
||||
model = {},
|
||||
pos = {},
|
||||
ang = {},
|
||||
cycle = {},
|
||||
seq = {},
|
||||
alive = {}
|
||||
}
|
||||
|
||||
for i=1,#plyall do
|
||||
local pl = plyall[i]
|
||||
if pl:IsLineOfSightClear(ply) then
|
||||
table.insert(otab.ent, pl:EntIndex())
|
||||
table.insert(otab.model, pl:GetModel())
|
||||
table.insert(otab.pos, pl:GetPos())
|
||||
table.insert(otab.ang, Angle(0,math.Round(pl:EyeAngles().y),0))
|
||||
table.insert(otab.cycle, pl:GetCycle())
|
||||
table.insert(otab.seq, pl:GetSequenceName(pl:GetSequence()))
|
||||
table.insert(otab.alive, pl:Alive())
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(ply.KillCamTable, {
|
||||
ply = plytab,
|
||||
other = otab,
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityEmitSound", "RecordCamBot", function(data)
|
||||
local ent = data.Entity
|
||||
|
||||
if ent:IsPlayer() or ent.IsBot and ent:IsBot() then
|
||||
if not istable(ent.VMSND) then
|
||||
ent.VMSND = {}
|
||||
end
|
||||
|
||||
table.insert(ent.VMSND, data.SoundName)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityTakeDamage", "RecordCamBot", function(ent, data)
|
||||
local att = data:GetAttacker()
|
||||
if (att:IsPlayer() or att.IsBot and att:IsBot()) and (ent:IsPlayer() or ent.IsBot and ent:IsBot()) then
|
||||
att.VMHIT = 1
|
||||
if data:GetDamage() >= ent:Health()+ent:Armor() then
|
||||
att.VMHIT = 2
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityFireBullets", "RecordCamBot", function(ent, data)
|
||||
if ent:IsPlayer() or ent.IsBot and ent:IsBot() then
|
||||
if not istable(ent.VMSND) then
|
||||
ent.VMSND = {}
|
||||
end
|
||||
|
||||
ent.VMBLT = data
|
||||
end
|
||||
end)
|
||||
1091
gamemodes/cod_custom/gamemode/server/sv_killstreaks.lua
Normal file
1091
gamemodes/cod_custom/gamemode/server/sv_killstreaks.lua
Normal file
File diff suppressed because it is too large
Load Diff
93
gamemodes/cod_custom/gamemode/server/sv_knockout.lua
Normal file
93
gamemodes/cod_custom/gamemode/server/sv_knockout.lua
Normal file
@@ -0,0 +1,93 @@
|
||||
COD.DelayGamemodeNumber = 999999999
|
||||
|
||||
hook.Add("PlayerDeath", "TDMPlayer_Knockout", function(ply)
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 3 then
|
||||
timer.Simple(0.1, function()
|
||||
if !IsValid(ply) then return end
|
||||
|
||||
ply.DeathTime = CurTime()+999999999
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("PlayerSpawn", "TDMPlayer_Knockout", function(ply)
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 3 then
|
||||
timer.Simple(0.1, function()
|
||||
if !IsValid(ply) then return end
|
||||
|
||||
ply:SetNWFloat('Perk1', 0)
|
||||
ply:SetNWFloat('Perk2', 2)
|
||||
ply:SetNWFloat('Perk1_Choose', 0)
|
||||
ply:SetNWFloat('Perk2_Choose', 0)
|
||||
ply:SetNWFloat('KillStreak1', 0)
|
||||
ply:SetNWFloat('KillStreak2', 0)
|
||||
ply:SetNWFloat('KillStreak3', 0)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("COD.ChangeState", "TDMGmodStartMatch_Knockout", function(start)
|
||||
if start and COD.DataTable["Gamemode"] == 3 then
|
||||
COD.TimeBefore1PerkUnlock = math.huge
|
||||
COD.TimeBefore2PerkUnlock = math.huge
|
||||
COD.DisableSpawn = true
|
||||
COD.DelayGamemodeNumber = CurTime()+5
|
||||
COD.DisableEndGameByNoTeam = false
|
||||
else
|
||||
COD.DisableSpawn = false
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDMGmodStartMatch_Knockout", function()
|
||||
if COD.GameStarted and COD.DataTable["Gamemode"] == 3 then
|
||||
local team1, team1alive = team.GetPlayers(1), false
|
||||
local team2, team2alive = team.GetPlayers(2), false
|
||||
local loseteam = 0
|
||||
|
||||
for k, p in ipairs(team1) do
|
||||
if p:Alive() then
|
||||
team1alive = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for k, p in ipairs(team2) do
|
||||
if p:Alive() then
|
||||
team2alive = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if team1alive and team2alive then
|
||||
COD.DelayGamemodeNumber = CurTime()+2
|
||||
loseteam = 0
|
||||
elseif team1alive and not team2alive then
|
||||
loseteam = 1
|
||||
elseif team2alive and not team1alive then
|
||||
loseteam = 2
|
||||
elseif not team1alive and not team2alive then
|
||||
loseteam = 3
|
||||
end
|
||||
|
||||
if loseteam == 1 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team1_Kills"] = COD.DataTable["MaxKills"]
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
elseif loseteam == 2 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team2_Kills"] = COD.DataTable["MaxKills"]
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
elseif loseteam == 3 and COD.DelayGamemodeNumber < CurTime() then
|
||||
COD.DataTable["Team1_Kills"] = 0
|
||||
COD.DataTable["Team2_Kills"] = 0
|
||||
BroadcastLua([[
|
||||
COD.DataTable["Team2_Kills"] = ]]..COD.DataTable["Team2_Kills"]..[[
|
||||
COD.DataTable["Team1_Kills"] = ]]..COD.DataTable["Team1_Kills"]..[[
|
||||
]])
|
||||
end
|
||||
end
|
||||
end)
|
||||
237
gamemodes/cod_custom/gamemode/server/sv_takedown.lua
Normal file
237
gamemodes/cod_custom/gamemode/server/sv_takedown.lua
Normal file
@@ -0,0 +1,237 @@
|
||||
function COD:ConnectWeapon(ply, model, lang, lpos, scale, attachment, usebonemerge, boneang)
|
||||
local wep = ents.Create('base_anim')
|
||||
local attach = ply:GetAttachment(ply:LookupAttachment(attachment))
|
||||
wep:SetPos(attach.Pos)
|
||||
wep:SetModel(model)
|
||||
wep:SetAngles(attach.Ang)
|
||||
wep:SetParent(ply, ply:LookupAttachment(attachment))
|
||||
if usebonemerge then
|
||||
wep:AddEffects(EF_BONEMERGE)
|
||||
end
|
||||
if boneang and ply:LookupBone(boneang) then
|
||||
wep:SetAngles(select(2, ply:GetBonePosition(ply:LookupBone(boneang))))
|
||||
end
|
||||
wep:Spawn()
|
||||
wep:SetLocalAngles(lang)
|
||||
wep:SetLocalPos(lpos)
|
||||
wep:SetModelScale(scale, 0)
|
||||
function wep:Think()
|
||||
if !IsValid(ply) or not ply.Takedowning then
|
||||
wep:Remove()
|
||||
end
|
||||
end
|
||||
return wep
|
||||
end
|
||||
|
||||
function COD:TakeThisIntoPhys(ent, removetime)
|
||||
local wep = ents.Create("prop_physics")
|
||||
wep:SetModel(ent:GetModel())
|
||||
wep:SetAngles(ent:GetAngles())
|
||||
wep:SetPos(ent:GetPos())
|
||||
wep:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
|
||||
wep:Spawn()
|
||||
wep:GetPhysicsObject():Wake()
|
||||
|
||||
timer.Simple(removetime, function()
|
||||
if !IsValid(wep) then return end
|
||||
wep:Remove()
|
||||
end)
|
||||
|
||||
ent:Remove()
|
||||
return wep, wep:GetPhysicsObject()
|
||||
end
|
||||
|
||||
local knife_model = "models/tdmg/wep/combat_knife.mdl"
|
||||
local pistol_model = "models/tdmg/wep/m18.mdl"
|
||||
local ar_model = "models/viper/mw/weapons/w_galima.mdl"
|
||||
local machete_model = "models/tdmg/wep/w_machete.mdl"
|
||||
local pkm_model = "models/tdmg/wep/w_mw_pkm.mdl"
|
||||
local shotgun_model = "models/tdmg/wep/w_rem870_p.mdl"
|
||||
local sniper_model = "models/tdmg/wep/m82.mdl"
|
||||
local sledgehammer_model = "models/tdmg/wep/w_sledgehammer.mdl"
|
||||
local pickaxe_model = "models/tdmg/wep/wpn_h1_melee_pick_axe_wm.mdl"
|
||||
local katana_model = "models/tdmg/wep/w_katana.mdl"
|
||||
local new_pickaxe_model = "models/tdmg/wep/new/hatchet.mdl"
|
||||
local new_katana_model = "models/tdmg/wep/new/katana.mdl"
|
||||
local new_stick_model = "models/tdmg/wep/new/kalistick.mdl"
|
||||
local modeltab = {knife_model, pistol_model, ar_model, machete_model, pkm_model, shotgun_model, sniper_model, sledgehammer_model, katana_model, new_stick_model, new_pickaxe_model, new_katana_model}
|
||||
for _, v in pairs(modeltab) do
|
||||
util.PrecacheModel(v)
|
||||
end
|
||||
|
||||
local pl = FindMetaTable("Player")
|
||||
util.AddNetworkString("COD.TakedownCam")
|
||||
|
||||
concommand.Add("cod_givetakedown", function(ply, cmd, args)
|
||||
if args[1] then
|
||||
local num = tostring(args[1])
|
||||
ply:SetNWString('TakedownAnim', num)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("PlayerButtonDown", "TakeDownTDM", function(ply, but)
|
||||
if ply:Alive() and but == KEY_E then
|
||||
ply:Takedown()
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("CalcMainActivity", "!TDMAnims", function(ply, vel)
|
||||
local str = ply:GetNWString('SVAnim')
|
||||
local num = ply:GetNWFloat('SVAnimDelay')
|
||||
local st = ply:GetNWFloat('SVAnimStartTime')
|
||||
if str != "" then
|
||||
ply:SetCycle((CurTime()-st)/num)
|
||||
return -1, ply:LookupSequence(str)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("Think", "TDMGmodTakedown", function()
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply.Takedowning and (not ply:Alive() or !ply.TakedownIsFinished and (!IsValid(ply.TakedowningTarget) or ply.TakedowningTarget:Health() <= 0)) then
|
||||
ply.Takedowning = false
|
||||
ply:SetSVAnimation("")
|
||||
ply:Freeze(false)
|
||||
net.Start("COD.TakedownCam")
|
||||
net.WriteBool(false)
|
||||
net.Send(ply)
|
||||
if ply.TakedowningGun then
|
||||
ply:SelectWeapon(ply.TakedowningGun)
|
||||
end
|
||||
elseif ply:IsBot() and ply.Takedowning and IsValid(ply.TakedowningTarget) then
|
||||
ply:SetPos(ply.TakedowningTarget:GetPos())
|
||||
ply:SetEyeAngles(ply.TakedowningTarget:EyeAngles())
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function pl:SetSVAnimation(anim, autostop)
|
||||
self:SetNWString('SVAnim', anim)
|
||||
self:SetNWFloat('SVAnimDelay', select(2, self:LookupSequence(anim)))
|
||||
self:SetNWFloat('SVAnimStartTime', CurTime())
|
||||
self:SetCycle(0)
|
||||
if autostop then
|
||||
local delay = select(2, self:LookupSequence(anim))
|
||||
timer.Simple(delay, function()
|
||||
if !IsValid(self) then return end
|
||||
|
||||
local anim2 = self:GetNWString('SVAnim')
|
||||
|
||||
if anim == anim2 then
|
||||
self:SetSVAnimation("")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function pl:IsAtBack(enemy) --This function was made by OpenAI ChatGPT
|
||||
if !IsValid(enemy) then return end
|
||||
local enemyForward = enemy:GetForward()
|
||||
local enemyToPlayer = self:GetPos() - enemy:GetPos()
|
||||
local angle = enemyForward:Angle():Forward():Dot(enemyToPlayer:GetNormalized())
|
||||
local degrees = math.deg(math.acos(angle))
|
||||
return degrees > 100
|
||||
end
|
||||
|
||||
function pl:Takedown(forceentity)
|
||||
local tr = self:GetEyeTrace()
|
||||
local ent = tr.Entity
|
||||
local dist = tr.StartPos:Distance(tr.HitPos) < 96
|
||||
if forceentity then
|
||||
dist = true
|
||||
ent = forceentity
|
||||
end
|
||||
|
||||
if !ent:IsPlayer() or ent:Team() == self:Team() or self:IsDowned() or ent.Takedowning or self.Takedowning or !ent:OnGround() or !self:OnGround() or !self:IsAtBack(ent) or not dist then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local float = self:GetNWString('TakedownAnim')
|
||||
if float == "00" then
|
||||
local _, rnd = table.Random(COD.Takedowns)
|
||||
float = rnd
|
||||
end
|
||||
if not COD.Takedowns[float] or float == "00" then return end
|
||||
|
||||
if not COD.Takedowns[float] then return end
|
||||
if !isnumber(float) then
|
||||
anim1, anim2 = "execution_"..float.."_attacker_stand", "execution_"..float.."_victim_stand"
|
||||
if ent:IsDowned() then
|
||||
anim1, anim2 = "execution_"..float.."_attacker_laststand", "execution_"..float.."_victim_laststand"
|
||||
end
|
||||
end
|
||||
|
||||
local delay1 = select(2, self:LookupSequence(anim1))
|
||||
local delay2 = COD.Takedowns[float].deathtime
|
||||
if ent:IsDowned() then
|
||||
delay2 = COD.Takedowns[float].deathtime_laststand
|
||||
end
|
||||
|
||||
local ang1 = ent:EyeAngles()
|
||||
self:Freeze(true)
|
||||
self:SetEyeAngles(Angle(ang1.x,ang1.y,0))
|
||||
self:SetPos(ent:GetPos())
|
||||
self:SetSVAnimation(anim1)
|
||||
local wep = self:GetActiveWeapon()
|
||||
if IsValid(wep) then
|
||||
self.TakedowningGun = wep:GetClass()
|
||||
else
|
||||
self.TakedowningGun = ""
|
||||
end
|
||||
local wep = ent:GetActiveWeapon()
|
||||
if IsValid(wep) then
|
||||
ent.TakedowningGun = wep:GetClass()
|
||||
else
|
||||
ent.TakedowningGun = ""
|
||||
end
|
||||
self.TakedowningTarget = ent
|
||||
self.Takedowning = true
|
||||
self.TakedownIsFinished = false
|
||||
self:SetActiveWeapon(nil)
|
||||
ent:SetActiveWeapon(nil)
|
||||
ent.TakedowningTarget = self
|
||||
ent.Takedowning = true
|
||||
ent.TakedownIsFinished = false
|
||||
ent:SetSVAnimation(anim2)
|
||||
ent:Freeze(true)
|
||||
ent:SetEyeAngles(Angle(ang1.x,ang1.y,0))
|
||||
|
||||
net.Start("COD.TakedownCam")
|
||||
net.WriteBool(true)
|
||||
net.WriteFloat(delay1)
|
||||
net.WriteBool(true)
|
||||
net.Send(self)
|
||||
|
||||
net.Start("COD.TakedownCam")
|
||||
net.WriteBool(true)
|
||||
net.WriteFloat(delay2)
|
||||
net.WriteBool(false)
|
||||
net.Send(ent)
|
||||
|
||||
if ent:IsDowned() then
|
||||
COD.Takedowns[float].effect_laststand(self, ent)
|
||||
else
|
||||
COD.Takedowns[float].effect(self, ent)
|
||||
end
|
||||
|
||||
timer.Simple(delay2, function()
|
||||
if IsValid(ent) and IsValid(self) and self.Takedowning then
|
||||
self.TakedownIsFinished = true
|
||||
ent:Freeze(false)
|
||||
ent:TakeDamage(ent:Health()+ent:Armor(), self)
|
||||
ent.Takedowning = false
|
||||
ent.TakedowningTarget = nil
|
||||
ent:SetSVAnimation("")
|
||||
end
|
||||
end)
|
||||
|
||||
timer.Simple(delay1, function()
|
||||
if IsValid(self) and self.Takedowning then
|
||||
self:Freeze(false)
|
||||
self:SetEyeAngles(Angle(ang1.x,ang1.y,0))
|
||||
self.Takedowning = false
|
||||
self:SetSVAnimation("")
|
||||
self:SelectWeapon(self.TakedowningGun)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user