local MAP_NAME = game.GetMap() if MAP_NAME ~= "fh_rockford" then return end util.PrecacheSound("ambient_mp3/grinder/grinderhuman_01.mp3") util.PrecacheSound("ambient_mp3/grinder/grinderhuman_02.mp3") sound.Add({ name = "TeamFortress.grinder_human", channel = CHAN_STATIC, volume = 1.0, level = 80, sound = { "ambient_mp3/grinder/grinderhuman_01.mp3", "ambient_mp3/grinder/grinderhuman_02.mp3" } }) local crunchedEnts = {} local function idToPrefix(id) return "T" .. id .. "_" end function SwitchTrainMode(id, mode) local prefix = idToPrefix(id) local trainRoot = ents.FindByName(prefix .. "tracktrain_root")[1] local trainProps = ents.FindByName(prefix .. "prop_*") local ambientMoving = ents.FindByName(prefix .. "ambient_trainmove_*") local spotlights = ents.FindByName(prefix .. "spotlight") local ambientHorn = ents.FindByName(prefix .. "ambient_horn")[1] if mode == 0 then -- -- Safe -- for _, ambient in ipairs(ambientMoving) do if IsValid(ambient) then ambient:Fire("stopsound") end end for _, light in ipairs(spotlights) do if IsValid(light) then light:Fire("lightoff") end end if IsValid(trainRoot) then trainRoot:Fire("stop") end for _, prop in ipairs(trainProps) do --if IsValid(prop) then prop:Fire("turnoff", "", 0.1) end end elseif mode == 1 then -- -- Warning -- if IsValid(ambientHorn) then ambientHorn:Fire("playsound") end for _, light in ipairs(spotlights) do if IsValid(light) then light:Fire("lighton") end end for _, prop in ipairs(trainProps) do if IsValid(prop) then prop:Fire("turnon", "", 0.1) end end elseif mode == 2 then -- -- Danger -- for _, ambient in ipairs(ambientMoving) do if IsValid(ambient) then ambient:Fire("playsound") end end if IsValid(trainRoot) then trainRoot:Fire("setspeed", "1024") trainRoot:Fire("startforward") end table.Empty(crunchedEnts) end end function SwitchLightsMode(id, mode) local prefix = idToPrefix(id) local redTimers = {} local yellowTimers = {} local allFlashingTimers = ents.FindByName(prefix .. "timer_flashing_*") for _, timer in ipairs(allFlashingTimers) do if IsValid(timer) then local name = timer:GetName() if string.find(name, "red") then table.insert(redTimers, timer) elseif string.find(name, "yellow") then table.insert(yellowTimers, timer) end timer:Fire("disable") end end local allBeams = ents.FindByName(prefix .. "beam_*") for _, beam in ipairs(allBeams) do if IsValid(beam) then local targetname = beam:GetName() if mode == 0 and string.find(targetname, "green") then beam:Fire("lighton") elseif string.find(targetname, "middle") then beam:Fire("lightoff") local color = "0 255 0" if mode == 1 then color = "255 255 0" elseif mode == 2 then color = "255 0 0" end beam:Fire("color", color, 0.25) beam:Fire("lighton", "", 0.5) else beam:Fire("lightoff") end end end if mode == 1 then for _, yellowTimer in ipairs(yellowTimers) do if IsValid(yellowTimer) then yellowTimer:Fire("enable") end end elseif mode == 2 then for _, redTimer in ipairs(redTimers) do if IsValid(redTimer) then redTimer:Fire("enable") end end end end function CreateCrunch() local activator = ACTIVATOR local trigger = CALLER if not IsValid(activator) then return end if activator:IsPlayer() and activator:Alive() then if activator:GetMoveType() == MOVETYPE_NOCLIP or activator:Team() == TEAM_SPECTATOR then return end activator:SetVelocity(trigger:GetVelocity() * 2) if activator:IsPlayer() and activator.IsSurvivor and not activator:IsSurvivor() then Teleport(activator) return end if table.HasValue(crunchedEnts, activator) then return end table.insert(crunchedEnts, activator) activator:EmitSound("TeamFortress.grinder_human") local edata = EffectData() edata:SetOrigin(activator:EyePos()) edata:SetEntity(activator) util.Effect("BloodImpact", edata, true, true) else activator:EmitSound("Breakable.MatFlesh") end end -- телепорт некстботиков таких как плюштрап / берлинги function Teleport(ply) local activator = ACTIVATOR if ply then activator = ply end local caller = CALLER if not IsValid(activator) then return end local isBot = activator:IsNextBot() or ply if isBot then local targets = ents.FindByName("botprotection_target") local nearestTarget = nil local minDist = 1024 local actPos = activator:GetPos() for _, target in ipairs(targets) do if IsValid(target) then local dist = actPos:Distance(target:GetPos()) if dist < minDist then minDist = dist nearestTarget = target end end end if IsValid(nearestTarget) then activator:SetPos(nearestTarget:GetPos()) end end end function WallTeleport() local activator = ACTIVATOR if not IsValid(activator) then return end if activator:IsPlayer() and activator:GetMoveType() == MOVETYPE_NOCLIP or activator:Team() == TEAM_SPECTATOR then return end if activator:IsPlayer() and activator.IsSurvivor and activator:IsSurvivor() then activator:Kill() end local targets = ents.FindByName("wallteleport_target") local nearestTarget = nil local minDist = 1024 local actPos = activator:GetPos() for _, target in ipairs(targets) do if IsValid(target) then local dist = actPos:Distance(target:GetPos()) if dist < minDist then minDist = dist nearestTarget = target end end end if IsValid(nearestTarget) then activator:SetPos(nearestTarget:GetPos()) if activator:IsPlayer() then activator:SetVelocity(Vector(0, 0, 0)) if activator.NoPlayerCollide then activator:NoPlayerCollide(0.25) end end end end hook.Add("InitPostEntity", "DeathTrains_Init", function() print("-- fh_rockford - Death Trains Script (GLua Port) Loaded --") end)