mirror of
https://github.com/JonnyBro/beatrun.git
synced 2024-12-28 12:53:02 +05:00
serverside cleanup
This commit is contained in:
parent
7d937f7507
commit
7e58a2936e
12 changed files with 146 additions and 99 deletions
|
@ -2,25 +2,31 @@ util.AddNetworkString("DisarmStart")
|
||||||
local cvardisarm = CreateConVar("Beatrun_Disarm", 1, FCVAR_ARCHIVE, "Whether 'using' NPCs triggers a disarm", 0, 1)
|
local cvardisarm = CreateConVar("Beatrun_Disarm", 1, FCVAR_ARCHIVE, "Whether 'using' NPCs triggers a disarm", 0, 1)
|
||||||
|
|
||||||
local function Disarm_Init(ply, victim)
|
local function Disarm_Init(ply, victim)
|
||||||
victim:NextThink(CurTime()+100)
|
victim:NextThink(CurTime() + 100)
|
||||||
victim.InDisarm = true
|
victim.InDisarm = true
|
||||||
victim:DropWeapon()
|
victim:DropWeapon()
|
||||||
|
|
||||||
net.Start("DisarmStart")
|
net.Start("DisarmStart")
|
||||||
net.WriteEntity(victim)
|
net.WriteEntity(victim)
|
||||||
net.Send(ply)
|
net.Send(ply)
|
||||||
|
|
||||||
timer.Simple(1.35, function() if IsValid(victim) then victim:TakeDamage(victim:Health()) end end)
|
timer.Simple(1.35, function()
|
||||||
|
if IsValid(victim) then
|
||||||
|
victim:TakeDamage(victim:Health())
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Disarm(ply, ent)
|
local function Disarm(ply, ent)
|
||||||
if !cvardisarm:GetBool() then return end
|
if not cvardisarm:GetBool() then return end
|
||||||
if ent:IsNPC() and !ent.InDisarm then
|
|
||||||
|
if ent:IsNPC() and not ent.InDisarm then
|
||||||
if ply:KeyPressed(IN_USE) then
|
if ply:KeyPressed(IN_USE) then
|
||||||
Disarm_Init(ply, ent)
|
Disarm_Init(ply, ent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
hook.Add("PlayerUse", "Disarm", Disarm)
|
hook.Add("PlayerUse", "Disarm", Disarm)
|
||||||
|
|
||||||
hook.Add("CreateEntityRagdoll", "Disarm_Ragdoll", function(ent, rag)
|
hook.Add("CreateEntityRagdoll", "Disarm_Ragdoll", function(ent, rag)
|
||||||
|
|
|
@ -1,35 +1,41 @@
|
||||||
local doors =
|
local doors = {
|
||||||
{
|
["func_door_rotating"] = true,
|
||||||
["func_door_rotating"] = true,
|
["prop_door_rotating"] = true
|
||||||
["prop_door_rotating"] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
util.AddNetworkString("DoorBashAnim")
|
util.AddNetworkString("DoorBashAnim")
|
||||||
|
|
||||||
hook.Add("PlayerUse", "DoorBash", function(ply, ent)
|
hook.Add("PlayerUse", "DoorBash", function(ply, ent)
|
||||||
if doors[ent:GetClass()] then
|
if doors[ent:GetClass()] then
|
||||||
if ply:GetVelocity():Length() < 100 or ply:Crouching() then return end
|
if ply:GetVelocity():Length() < 100 or ply:Crouching() then return end
|
||||||
if ent.bashdelay and ent.bashdelay > CurTime() then return end
|
if ent.bashdelay and ent.bashdelay > CurTime() then return end
|
||||||
if ent:GetInternalVariable("m_bLocked") then return end
|
if ent:GetInternalVariable("m_bLocked") then return end
|
||||||
|
|
||||||
local speed = ent:GetInternalVariable("speed")
|
local speed = ent:GetInternalVariable("speed")
|
||||||
if !ent.oldspeed then
|
|
||||||
|
if not ent.oldspeed then
|
||||||
ent.oldspeed = speed
|
ent.oldspeed = speed
|
||||||
ent.bashdelay = 0
|
ent.bashdelay = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
net.Start("DoorBashAnim")
|
net.Start("DoorBashAnim")
|
||||||
net.Send(ply)
|
net.Send(ply)
|
||||||
|
|
||||||
ent:SetSaveValue("speed", ent.oldspeed*4)
|
ent:SetSaveValue("speed", ent.oldspeed * 4)
|
||||||
ent:Use(ply)
|
ent:Use(ply)
|
||||||
ent.bashdelay = CurTime()+1
|
ent.bashdelay = CurTime() + 1
|
||||||
ent:SetCycle(1)
|
ent:SetCycle(1)
|
||||||
ent:Fire("Lock")
|
ent:Fire("Lock")
|
||||||
|
|
||||||
timer.Simple(1, function()
|
timer.Simple(1, function()
|
||||||
if IsValid(ent) then
|
if IsValid(ent) then
|
||||||
ent:SetSaveValue("speed", ent.oldspeed)
|
ent:SetSaveValue("speed", ent.oldspeed)
|
||||||
ent:Fire("Unlock")
|
ent:Fire("Unlock")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ent:EmitSound("Door.Barge")
|
ent:EmitSound("Door.Barge")
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
|
@ -4,29 +4,32 @@ if game.SinglePlayer() then return end
|
||||||
|
|
||||||
local maxmsgcount = 100
|
local maxmsgcount = 100
|
||||||
local netIncoming_old = net.Receive
|
local netIncoming_old = net.Receive
|
||||||
|
|
||||||
local netIncoming_detour = function(length, ply)
|
local netIncoming_detour = function(length, ply)
|
||||||
local tickcount = engine.TickCount()
|
local tickcount = engine.TickCount()
|
||||||
|
|
||||||
if tickcount > (ply.NetDelay or 0) then
|
if tickcount > (ply.NetDelay or 0) then
|
||||||
ply.NetDelayCount = 0
|
ply.NetDelayCount = 0
|
||||||
ply.NetDelay = tickcount+ 10
|
ply.NetDelay = tickcount + 10
|
||||||
end
|
end
|
||||||
|
|
||||||
ply.NetDelayCount = ply.NetDelayCount + 1
|
ply.NetDelayCount = ply.NetDelayCount + 1
|
||||||
|
|
||||||
if ply.NetDelayCount > maxmsgcount then
|
if ply.NetDelayCount > maxmsgcount then
|
||||||
ply:Kick("Client sent too much data")
|
ply:Kick("Client sent too much data")
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local i = net.ReadHeader()
|
local i = net.ReadHeader()
|
||||||
local strName = util.NetworkIDToString( i )
|
local strName = util.NetworkIDToString(i)
|
||||||
|
if not strName then return end
|
||||||
if ( !strName ) then return end
|
|
||||||
|
local func = net.Receivers[strName:lower()]
|
||||||
local func = net.Receivers[ strName:lower() ]
|
if not func then return end
|
||||||
if ( !func ) then return end
|
|
||||||
|
|
||||||
length = length - 16
|
length = length - 16
|
||||||
func( length, ply )
|
func(length, ply)
|
||||||
end
|
end
|
||||||
|
|
||||||
net.Incoming = netIncoming_detour
|
net.Incoming = netIncoming_detour
|
|
@ -4,13 +4,14 @@ function BRProtectedEntity(class, pos, ang)
|
||||||
a:SetAngles(ang)
|
a:SetAngles(ang)
|
||||||
a:Spawn()
|
a:Spawn()
|
||||||
a:SetNW2Bool("BRProtected", true)
|
a:SetNW2Bool("BRProtected", true)
|
||||||
|
|
||||||
return a
|
return a
|
||||||
end
|
end
|
||||||
|
|
||||||
if file.Exists("beatrun/gamemode/Maps/"..game.GetMap().."_cl.lua", "LUA") then
|
if file.Exists("beatrun/gamemode/Maps/" .. game.GetMap() .. "_cl.lua", "LUA") then
|
||||||
AddCSLuaFile("beatrun/gamemode/Maps/"..game.GetMap().."_cl.lua")
|
AddCSLuaFile("beatrun/gamemode/Maps/" .. game.GetMap() .. "_cl.lua")
|
||||||
end
|
end
|
||||||
if file.Exists("beatrun/gamemode/Maps/"..game.GetMap()..".lua", "LUA") then
|
|
||||||
include("beatrun/gamemode/Maps/"..game.GetMap()..".lua")
|
if file.Exists("beatrun/gamemode/Maps/" .. game.GetMap() .. ".lua", "LUA") then
|
||||||
|
include("beatrun/gamemode/Maps/" .. game.GetMap() .. ".lua")
|
||||||
end
|
end
|
|
@ -1,8 +1,10 @@
|
||||||
Beatrun_NPCs = Beatrun_NPCs or {}
|
Beatrun_NPCs = Beatrun_NPCs or {}
|
||||||
local npctbl = Beatrun_NPCs
|
local npctbl = Beatrun_NPCs
|
||||||
|
|
||||||
hook.Add("OnEntityCreated", "NPCTracker", function(ent)
|
hook.Add("OnEntityCreated", "NPCTracker", function(ent)
|
||||||
if IsValid(ent) and ent:IsNPC() then
|
if IsValid(ent) and ent:IsNPC() then
|
||||||
table.insert(Beatrun_NPCs, ent)
|
table.insert(Beatrun_NPCs, ent)
|
||||||
|
|
||||||
ent.OldProficiency = ent:GetCurrentWeaponProficiency()
|
ent.OldProficiency = ent:GetCurrentWeaponProficiency()
|
||||||
ent.NextProficiency = 0
|
ent.NextProficiency = 0
|
||||||
end
|
end
|
||||||
|
@ -10,7 +12,7 @@ end)
|
||||||
|
|
||||||
hook.Add("EntityRemoved", "NPCTracker", function(ent)
|
hook.Add("EntityRemoved", "NPCTracker", function(ent)
|
||||||
for k, npc in ipairs(npctbl) do
|
for k, npc in ipairs(npctbl) do
|
||||||
if !IsValid(npc) then
|
if not IsValid(npc) then
|
||||||
table.remove(npctbl, k)
|
table.remove(npctbl, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,24 +20,25 @@ end)
|
||||||
|
|
||||||
local updaterate = 0.2
|
local updaterate = 0.2
|
||||||
local updatetime = 0
|
local updatetime = 0
|
||||||
|
|
||||||
hook.Add("Tick", "NPCBehavior", function()
|
hook.Add("Tick", "NPCBehavior", function()
|
||||||
local CT = CurTime()
|
local CT = CurTime()
|
||||||
if updatetime > CT then return end
|
if updatetime > CT then return end
|
||||||
|
|
||||||
for k, npc in ipairs(npctbl) do
|
for k, npc in ipairs(npctbl) do
|
||||||
if !IsValid(npc) then
|
if not IsValid(npc) then continue end
|
||||||
continue
|
|
||||||
end
|
|
||||||
local enemy = npc:GetEnemy()
|
local enemy = npc:GetEnemy()
|
||||||
if !IsValid(enemy) or !enemy:IsPlayer() then
|
|
||||||
continue
|
if not IsValid(enemy) or not enemy:IsPlayer() then continue end
|
||||||
end
|
|
||||||
|
|
||||||
if enemy:GetJumpTurn() or enemy:GetSliding() or enemy:GetWallrun() > 0 or enemy:GetVelocity():Length() > 300 then
|
if enemy:GetJumpTurn() or enemy:GetSliding() or enemy:GetWallrun() > 0 or enemy:GetVelocity():Length() > 300 then
|
||||||
npc:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_POOR )
|
npc:SetCurrentWeaponProficiency(WEAPON_PROFICIENCY_POOR)
|
||||||
npc.NextProficiency = CT + 1
|
npc.NextProficiency = CT + 1
|
||||||
elseif CT > npc.NextProficiency then
|
elseif CT > npc.NextProficiency then
|
||||||
npc:SetCurrentWeaponProficiency( npc.OldProficiency or WEAPON_PROFICIENCY_GOOD )
|
npc:SetCurrentWeaponProficiency(npc.OldProficiency or WEAPON_PROFICIENCY_GOOD)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
updatetime = CT + updaterate
|
updatetime = CT + updaterate
|
||||||
end)
|
end)
|
|
@ -1,7 +1,9 @@
|
||||||
local updatetime = 0
|
local updatetime = 0
|
||||||
|
|
||||||
hook.Add("PlayerPostThink", "PacketLossNet", function(ply)
|
hook.Add("PlayerPostThink", "PacketLossNet", function(ply)
|
||||||
if CurTime() > updatetime then
|
if CurTime() > updatetime then
|
||||||
ply:SetNW2Int("PLoss",ply:PacketLoss())
|
ply:SetNW2Int("PLoss", ply:PacketLoss())
|
||||||
updatetime = CurTime()+4
|
|
||||||
|
updatetime = CurTime() + 4
|
||||||
end
|
end
|
||||||
end)
|
end)
|
|
@ -1,33 +1,42 @@
|
||||||
util.AddNetworkString("ReplayRequest")
|
util.AddNetworkString("ReplayRequest")
|
||||||
util.AddNetworkString("ReplayTutorialPos")
|
util.AddNetworkString("ReplayTutorialPos")
|
||||||
|
|
||||||
net.Receive("ReplayRequest", function(len,ply)
|
net.Receive("ReplayRequest", function(len, ply)
|
||||||
local stopped = net.ReadBool()
|
local stopped = net.ReadBool()
|
||||||
if !stopped and !ply.InReplay and ((Course_Name != "") or TUTORIALMODE) then
|
|
||||||
|
if not stopped and not ply.InReplay and ((Course_Name ~= "") or TUTORIALMODE) then
|
||||||
ply.InReplay = true
|
ply.InReplay = true
|
||||||
|
|
||||||
ply:ResetParkourState()
|
ply:ResetParkourState()
|
||||||
ply:Spawn()
|
ply:Spawn()
|
||||||
ply:SetNW2Int("CPNum", -1)
|
ply:SetNW2Int("CPNum", -1)
|
||||||
ply:SetLocalVelocity(vector_origin)
|
ply:SetLocalVelocity(vector_origin)
|
||||||
ply:SetLaggedMovementValue( 0 )
|
ply:SetLaggedMovementValue(0)
|
||||||
timer.Simple(0.1, function() ply:SetLaggedMovementValue( 1 ) end)
|
|
||||||
if !TUTORIALMODE then
|
timer.Simple(0.1, function()
|
||||||
|
ply:SetLaggedMovementValue(1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not TUTORIALMODE then
|
||||||
ply:SetPos(Course_StartPos)
|
ply:SetPos(Course_StartPos)
|
||||||
else
|
else
|
||||||
ply:SetPos(net.ReadVector())
|
ply:SetPos(net.ReadVector())
|
||||||
end
|
end
|
||||||
|
|
||||||
net.Start("ReplayRequest")
|
net.Start("ReplayRequest")
|
||||||
net.Send(ply)
|
net.Send(ply)
|
||||||
elseif stopped then
|
elseif stopped then
|
||||||
ply.InReplay = false
|
ply.InReplay = false
|
||||||
end
|
end
|
||||||
|
|
||||||
hook.Run("PostReplayRequest", ply, stopped)
|
hook.Run("PostReplayRequest", ply, stopped)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
net.Receive("ReplayTutorialPos", function(len, ply)
|
net.Receive("ReplayTutorialPos", function(len, ply)
|
||||||
if !TUTORIALMODE then return end
|
if not TUTORIALMODE then return end
|
||||||
|
|
||||||
local pos = net.ReadVector()
|
local pos = net.ReadVector()
|
||||||
|
|
||||||
ply:SetPos(pos or ply:GetPos())
|
ply:SetPos(pos or ply:GetPos())
|
||||||
ply:SetLocalVelocity(vector_origin)
|
ply:SetLocalVelocity(vector_origin)
|
||||||
end)
|
end)
|
|
@ -1,22 +1,15 @@
|
||||||
util.AddNetworkString("ToggleWhitescale")
|
util.AddNetworkString("ToggleWhitescale")
|
||||||
local skypaint
|
local skypaint
|
||||||
local skypaintdata = {
|
|
||||||
Vector(0, 0.34, 0.93),
|
local skypaintdata = {Vector(0, 0.34, 0.93), Vector(0.36, 0.76, 1), Vector(0.25, 0.1, 0), Vector(1, 1, 1), 0.44, 0.66, 0.79, 0.5, 7.44}
|
||||||
Vector(0.36, 0.76, 1),
|
|
||||||
Vector(0.25, 0.1, 0),
|
|
||||||
Vector(1, 1, 1),
|
|
||||||
0.44,
|
|
||||||
0.66,
|
|
||||||
0.79,
|
|
||||||
0.5,
|
|
||||||
7.44
|
|
||||||
}
|
|
||||||
function WhitescaleOn()
|
function WhitescaleOn()
|
||||||
if BlockWhitescaleSkypaint then return end
|
if BlockWhitescaleSkypaint then return end
|
||||||
if !IsValid(skypaint) then
|
|
||||||
|
if not IsValid(skypaint) then
|
||||||
skypaint = ents.FindByClass("env_skypaint")[1]
|
skypaint = ents.FindByClass("env_skypaint")[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsValid(skypaint) then
|
if IsValid(skypaint) then
|
||||||
skypaint:SetTopColor(skypaintdata[1])
|
skypaint:SetTopColor(skypaintdata[1])
|
||||||
skypaint:SetBottomColor(skypaintdata[2])
|
skypaint:SetBottomColor(skypaintdata[2])
|
||||||
|
@ -33,9 +26,8 @@ end
|
||||||
|
|
||||||
net.Receive("ToggleWhitescale", function(len, ply)
|
net.Receive("ToggleWhitescale", function(len, ply)
|
||||||
local toggle = net.ReadBool()
|
local toggle = net.ReadBool()
|
||||||
|
|
||||||
if toggle then
|
if toggle then
|
||||||
WhitescaleOn()
|
WhitescaleOn()
|
||||||
else
|
else return end
|
||||||
|
|
||||||
end
|
|
||||||
end)
|
end)
|
|
@ -6,44 +6,55 @@ local function Echo()
|
||||||
end
|
end
|
||||||
|
|
||||||
blinded = false
|
blinded = false
|
||||||
|
|
||||||
concommand.Add("toggleblindness", function(ply)
|
concommand.Add("toggleblindness", function(ply)
|
||||||
if IsValid(ply) and !ply:IsSuperAdmin() then return end
|
if IsValid(ply) and not ply:IsSuperAdmin() then return end
|
||||||
blinded = !blinded
|
|
||||||
|
blinded = not blinded
|
||||||
|
|
||||||
net.Start("BlindPlayers")
|
net.Start("BlindPlayers")
|
||||||
net.WriteBool(blinded)
|
net.WriteBool(blinded)
|
||||||
net.Broadcast()
|
net.Broadcast()
|
||||||
|
|
||||||
if blinded then
|
if blinded then
|
||||||
for k,v in pairs(ents.FindByClass("env_soundscape")) do
|
for k, v in pairs(ents.FindByClass("env_soundscape")) do
|
||||||
v:Remove()
|
v:Remove()
|
||||||
end
|
end
|
||||||
hook.Add("EntityEmitSound","Echo",Echo)
|
|
||||||
|
hook.Add("EntityEmitSound", "Echo", Echo)
|
||||||
else
|
else
|
||||||
hook.Remove("EntityEmitSound","Echo")
|
hook.Remove("EntityEmitSound", "Echo")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local red = Color(255,90,90)
|
local red = Color(255, 90, 90)
|
||||||
local green = Color(90,255,90)
|
local green = Color(90, 255, 90)
|
||||||
|
|
||||||
concommand.Add("blindplayer", function(ply, cmd, args)
|
concommand.Add("blindplayer", function(ply, cmd, args)
|
||||||
if IsValid(ply) and !ply:IsSuperAdmin() then return end
|
if IsValid(ply) and not ply:IsSuperAdmin() then return end
|
||||||
|
|
||||||
local blinded = tobool(args[2])
|
local blinded = tobool(args[2])
|
||||||
local blindedstr = (blinded and "is now blind.\n") or "is no longer blind.\n"
|
local blindedstr = (blinded and "is now blind.\n") or "is no longer blind.\n"
|
||||||
local blindedcol = (blinded and red) or green
|
local blindedcol = (blinded and red) or green
|
||||||
local plysearch = args[1]
|
local plysearch = args[1]
|
||||||
if !plysearch then
|
|
||||||
|
if not plysearch then
|
||||||
MsgC(red, "syntax: blindplayer (player name) (0/1)\n")
|
MsgC(red, "syntax: blindplayer (player name) (0/1)\n")
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local mply = nil
|
local mply = nil
|
||||||
local mname = ""
|
local mname = ""
|
||||||
local mcount = 0
|
local mcount = 0
|
||||||
for k,v in ipairs(player.GetAll()) do
|
|
||||||
|
for k, v in ipairs(player.GetAll()) do
|
||||||
local name = v:Nick()
|
local name = v:Nick()
|
||||||
local smatch = string.match(name, plysearch)
|
local smatch = string.match(name, plysearch)
|
||||||
|
|
||||||
if smatch then
|
if smatch then
|
||||||
local slen = smatch:len()
|
local slen = smatch:len()
|
||||||
|
|
||||||
if slen > mcount then
|
if slen > mcount then
|
||||||
mply = v
|
mply = v
|
||||||
mname = name
|
mname = name
|
||||||
|
@ -51,19 +62,21 @@ concommand.Add("blindplayer", function(ply, cmd, args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsValid(mply) then
|
if IsValid(mply) then
|
||||||
MsgC(blindedcol, mname, " ", blindedstr)
|
MsgC(blindedcol, mname, " ", blindedstr)
|
||||||
else
|
else
|
||||||
MsgC(red, "Player not found: ",plysearch)
|
MsgC(red, "Player not found: ", plysearch)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
net.Start("BlindPlayers")
|
net.Start("BlindPlayers")
|
||||||
net.WriteBool(blinded)
|
net.WriteBool(blinded)
|
||||||
net.Send(mply)
|
net.Send(mply)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
hook.Add("OnNPCKilled", "BlindNPCKilled", function(npc,attacker,inflictor)
|
hook.Add("OnNPCKilled", "BlindNPCKilled", function(npc, attacker, inflictor)
|
||||||
if blinded and attacker:IsPlayer() then
|
if blinded and attacker:IsPlayer() then
|
||||||
net.Start("BlindNPCKilled")
|
net.Start("BlindNPCKilled")
|
||||||
net.Send(attacker)
|
net.Send(attacker)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
DEFINE_BASECLASS( "gamemode_base" )
|
DEFINE_BASECLASS("gamemode_base")
|
||||||
|
|
||||||
function GM:PlayerSpawn(ply, transition)
|
function GM:PlayerSpawn(ply, transition)
|
||||||
player_manager.SetPlayerClass( ply, "player_beatrun" )
|
player_manager.SetPlayerClass(ply, "player_beatrun")
|
||||||
|
|
||||||
BaseClass.PlayerSpawn( self, ply, transition )
|
BaseClass.PlayerSpawn(self, ply, transition)
|
||||||
end
|
end
|
|
@ -1,16 +1,24 @@
|
||||||
util.AddNetworkString("DeathStopSound")
|
util.AddNetworkString("DeathStopSound")
|
||||||
|
|
||||||
hook.Add("EntityTakeDamage", "MEHitSounds", function( ply, dmginfo )
|
hook.Add("EntityTakeDamage", "MEHitSounds", function(ply, dmginfo)
|
||||||
if !ply:IsPlayer() then return end
|
if not ply:IsPlayer() then return end
|
||||||
if ( dmginfo:IsBulletDamage() ) then
|
|
||||||
--[[Block damage if they're going very fast]]
|
if dmginfo:IsBulletDamage() then
|
||||||
if ply:GetVelocity():Length() > 400 then return true end
|
--[[Block damage if they're going very fast]]
|
||||||
ply:EmitSound("mirrorsedge/Flesh_0"..tostring(math.random(1,9))..".wav")
|
if ply:GetVelocity():Length() > 400 then return true end
|
||||||
ply:ViewPunch(Angle(math.Rand(-10,-5),0,math.Rand(0,5)))
|
|
||||||
elseif ( dmginfo:IsFallDamage() and ply:Health()-dmginfo:GetDamage()<=0 ) and !ply:HasGodMode() and !blinded then
|
ply:EmitSound("mirrorsedge/Flesh_0" .. tostring(math.random(1, 9)) .. ".wav")
|
||||||
|
ply:ViewPunch(Angle(math.Rand(-10, -5), 0, math.Rand(0, 5)))
|
||||||
|
elseif (dmginfo:IsFallDamage() and ply:Health() - dmginfo:GetDamage() <= 0) and not ply:HasGodMode() and not blinded then
|
||||||
net.Start("DeathStopSound")
|
net.Start("DeathStopSound")
|
||||||
net.Send(ply)
|
net.Send(ply)
|
||||||
timer.Simple(0.01,function() if IsValid(ply) then ply:EmitSound("mirrorsedge/DeathFall"..tostring(math.random(1,4))..".wav") end end)
|
|
||||||
ply:ScreenFade( SCREENFADE.OUT, Color( 0, 0, 0, 255 ), 0.05, 10 )
|
timer.Simple(0.01, function()
|
||||||
|
if IsValid(ply) then
|
||||||
|
ply:EmitSound("mirrorsedge/DeathFall" .. tostring(math.random(1, 4)) .. ".wav")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
ply:ScreenFade(SCREENFADE.OUT, Color(0, 0, 0, 255), 0.05, 10)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
|
@ -1,9 +1,12 @@
|
||||||
function LadderSpawnDebug()
|
function LadderSpawnDebug()
|
||||||
local p=Entity(1):GetEyeTrace()
|
local p = Entity(1):GetEyeTrace()
|
||||||
a=ents.Create('br_ladder')
|
a = ents.Create("br_ladder")
|
||||||
|
|
||||||
a:SetAngles(p.HitNormal:Angle())
|
a:SetAngles(p.HitNormal:Angle())
|
||||||
a:SetPos(p.HitPos+p.HitNormal*10)
|
a:SetPos(p.HitPos + p.HitNormal * 10)
|
||||||
a:Spawn()
|
a:Spawn()
|
||||||
sk=util.QuickTrace(p.HitPos,Vector(0,0,100000)).HitPos-p.HitNormal*10
|
|
||||||
a:LadderHeightExact(util.QuickTrace(sk, Vector(0,0,-100000)).HitPos:Distance(a:GetPos())-62)
|
sk = util.QuickTrace(p.HitPos, Vector(0, 0, 100000)).HitPos - p.HitNormal * 10
|
||||||
|
|
||||||
|
a:LadderHeightExact(util.QuickTrace(sk, Vector(0, 0, -100000)).HitPos:Distance(a:GetPos()) - 62)
|
||||||
end
|
end
|
Loading…
Reference in a new issue