1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
This commit is contained in:
g_brzhezinskiy
2021-01-02 12:51:45 +03:00
commit 1d05caf866
613 changed files with 337020 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,634 @@
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
ENT.BogeyDistance = 650 -- Needed for gm trainspawner
--"DURASelectMain","DURASelectAlternate","DURAToggleChannel","DURAPowerToggle",
ENT.SyncTable = {
"VB","VBA","AV","VU","VU1","VU2","VU3",
"VRD","VR",
"VRU","KAD","KAH","OVT","KSD","KPVU","VKF",
"KOS","VZP","KRZD","KDL","KDLK","KDPK","LOn","LOff","VozvratRP","KSN","KDP","VMK","Ring","VUS","VAK","Autodrive","VZD","PB","VUD","VAKK",
"RCAV3","RCAV4","RCAV5","RCARS","RCBPS",
"VDL","KDPH",
"ALS","ARS","Headlights","VSOSD","KB","DriverValveBLDisconnect","DriverValveTLDisconnect",
"GV",
"R_UPO",
"UAVA","UAVAC","EmergencyBrakeValve"
}
ENT.SyncFunctions = {
""
}
function ENT:Initialize()
self.Plombs = {
VRU=true,
KAH=true,
KAD=true,
OVT=true,
KPVU=true,
UAVA=true,
RCAV3=true,
RCAV4=true,
RCAV5=true,
RCARS=true,
RCBPS=true,
Init=true,
}
-- Set model and initialize
self:SetModel("models/metrostroi_train/81-502/81-502.mdl")
self.BaseClass.Initialize(self)
self:SetPos(self:GetPos() + Vector(0,0,140))
-- Create seat entities
self.DriverSeat = self:CreateSeat("driver",Vector(425+3,-39.4,-31.5),Angle(0,0,0))
self.InstructorsSeat = self:CreateSeat("instructor",Vector(430,40,-48+6+2.5),Angle(0,90,0),"models/vehicles/prisoner_pod_inner.mdl")
self.ExtraSeat1 = self:CreateSeat("instructor",Vector(443,0,-48+6+2.5),Angle(0,90,0),"models/vehicles/prisoner_pod_inner.mdl")
self.ExtraSeat2 = self:CreateSeat("instructor",Vector(420,-20,-48+6),Angle(0,90,0),"models/vehicles/prisoner_pod_inner.mdl")
-- Hide seats
self.DriverSeat:SetColor(Color(0,0,0,0))
self.DriverSeat:SetRenderMode(RENDERMODE_TRANSALPHA)
self.InstructorsSeat:SetColor(Color(0,0,0,0))
self.InstructorsSeat:SetRenderMode(RENDERMODE_TRANSALPHA)
self.ExtraSeat1:SetColor(Color(0,0,0,0))
self.ExtraSeat1:SetRenderMode(RENDERMODE_TRANSALPHA)
self.ExtraSeat2:SetColor(Color(0,0,0,0))
self.ExtraSeat2:SetRenderMode(RENDERMODE_TRANSALPHA)
-- Create bogeys
if Metrostroi.BogeyOldMap then
self.FrontBogey = self:CreateBogey(Vector( 317-5,0,-89),Angle(0,180,0),true,"717")
self.RearBogey = self:CreateBogey(Vector(-317+0,0,-89),Angle(0,0,0),false,"717")
self.FrontCouple = self:CreateCouple(Vector( 419.5+3.5,0,-75),Angle(0,0,0),true,"722")
self.RearCouple = self:CreateCouple(Vector(-421.5-3.5,0,-75),Angle(0,180,0),false,"702")
else
self.FrontBogey = self:CreateBogey(Vector( 317-11,1.0,-85),Angle(0,180,0),true,"717")
self.RearBogey = self:CreateBogey(Vector(-317+0,1.3,-85),Angle(0,0,0),false,"717")
self.FrontCouple = self:CreateCouple(Vector( 421-4-3.6+4.5,1.0,-72),Angle(0,0,0),true,"722")
self.RearCouple = self:CreateCouple(Vector(-421+2+3.6-4.5,1.3,-72),Angle(0,180,0),false,"702")
end
self.FrontBogey:SetNWInt("MotorSoundType",0)
self.RearBogey:SetNWInt("MotorSoundType",0)
self.FrontCouple.EKKDisconnected = true
self.LeftAutoCoil = self:AddAutodriveCoil(self.FrontBogey,false)
self.RightAutoCoil = self:AddAutodriveCoil(self.FrontBogey,true)
-- Initialize key mapping
self.KeyMap = {
[KEY_1] = "KVSetX1B",
[KEY_2] = "KVSetX2",
[KEY_3] = "KVSetX3",
[KEY_4] = "KVSet0",
[KEY_5] = "KVSetT1B",
[KEY_6] = "KVSetT1AB",
[KEY_7] = "KVSetT2",
[KEY_G] = "VozvratRPSet",
[KEY_0] = "KVReverserUp",
[KEY_9] = "KVReverserDown",
[KEY_PAD_PLUS] = "KVReverserUp",
[KEY_PAD_MINUS] = "KVReverserDown",
[KEY_W] = "KVUp",
[KEY_S] = "KVDown",
[KEY_F] = "PneumaticBrakeUp",
[KEY_R] = "PneumaticBrakeDown",
[KEY_A] = {"KDL",helper="VDLSet"},
[KEY_D] = "KDP",
[KEY_V] = "VUDToggle",
[KEY_L] = "HornEngage",
[KEY_PAD_1] = "PneumaticBrakeSet1",
[KEY_PAD_2] = "PneumaticBrakeSet2",
[KEY_PAD_3] = "PneumaticBrakeSet3",
[KEY_PAD_4] = "PneumaticBrakeSet4",
[KEY_PAD_5] = "PneumaticBrakeSet5",
[KEY_BACKSPACE] = {"EmergencyBrake",helper="EmergencyBrakeValveToggle"},
[KEY_SPACE] = "KB",
[KEY_PAD_DIVIDE] = "VAKSet",
[KEY_PAD_ENTER] = "KVWrenchKV",
[KEY_PAD_0] = "DriverValveDisconnect",
[KEY_LSHIFT] = {
[KEY_W] = "KVUp_Unlocked",
[KEY_1] = "LOnSet",
[KEY_2] = "LOffSet",
[KEY_4] = "KVSet0Fast",
[KEY_L] = "DriverValveDisconnect",
[KEY_7] = "KVWrenchNone",
[KEY_9] = "KVWrenchKV9",
[KEY_0] = "KVWrenchKV",
[KEY_6] = "KVSetT1A",
[KEY_SPACE] = "PB",
[KEY_PAD_ENTER] = "KVWrenchNone",
},
}
self.KeyMap[KEY_RALT] = self.KeyMap[KEY_LALT]
self.KeyMap[KEY_RSHIFT] = self.KeyMap[KEY_LSHIFT]
self.KeyMap[KEY_RCONTROL] = self.KeyMap[KEY_LCONTROL]
self.InteractionZones = {
{
ID = "FrontBrakeLineIsolationToggle",
Pos = Vector(469, -29, -62), Radius = 8,
},
{
ID = "FrontTrainLineIsolationToggle",
Pos = Vector(469, 29, -62), Radius = 8,
},
{
ID = "RearTrainLineIsolationToggle",
Pos = Vector(-474, -30, -62), Radius = 8,
},
{
ID = "RearBrakeLineIsolationToggle",
Pos = Vector(-474, 30, -62), Radius = 8,
},
{
ID = "FrontDoor",
Pos = Vector(469,32,-10), Radius = 12,
},
{
ID = "CabinDoor",
Pos = Vector(469,58,-10), Radius = 10,
},
{
ID = "CabinDoor",
Pos = Vector(469,58,-30), Radius = 10,
},
{
ID = "CabinDoor",
Pos = Vector(390,64,-10), Radius = 16,
},
{
ID = "PassengerDoor",
Pos = Vector(389,35,8), Radius = 16,
},
{
ID = "RearDoor",
Pos = Vector(-469,-35,-10), Radius = 20,
},
{
ID = "GVToggle",
Pos = Vector(155,63.7,-75), Radius = 10,
},
{
ID = "AirDistributorDisconnectToggle",
Pos = Vector(-224.5, 50, -66), Radius = 20,
},
}
-- Cross connections in train wires
self.TrainWireInverts = {
[15] = true,
}
self.TrainWireCrossConnections = {
[5] = 4, -- Reverser F<->B
[30] = 29, -- Reverser F<->B
[31] = 32, -- Doors L<->R
}
-- KV wrench mode
self:OnButtonPress("KVWrenchNone")
-- Parking brake ratio
self.ManualBrake = 0.0
self.RearDoor = false
self.FrontDoor = false
self.CabinDoor = false
self.PassengerDoor = false
-- self.A5:TriggerInput("Set",0)
self:SetNW2Float("UPONoiseVolume",math.Rand(0,0.3))
self:SetNW2Float("UPOVolume",math.Rand(0.8,1))
self.EMAType = self.EMAType or 1
self:TrainSpawnerUpdate()
end
function ENT:TrainSpawnerUpdate()
if IsValid(self.FrontBogey) then
self.FrontBogey:SetNW2Int("SquealType",math.floor(math.random()*7)+1)
end
if IsValid(self.RearBogey) then
self.RearBogey:SetNW2Int("SquealType",math.floor(math.random()*7)+1)
end
end
function ENT:NonSupportTrigger()
self.RCAV3:TriggerInput("Set",0)
self.RCAV4:TriggerInput("Set",0)
self.RCAV5:TriggerInput("Set",0)
self.RCARS:TriggerInput("Set",0)
self.OVT:TriggerInput("Set",0)
self.KAH:TriggerInput("Set",1)
self.VBA:TriggerInput("Set",0)
self.ARS:TriggerInput("Set",0)
self.Plombs.RCAV3 = nil
self.Plombs.RCAV4 = nil
self.Plombs.RCAV5 = nil
self.Plombs.RCARS = nil
self.Plombs.OVT = nil
self.Plombs.KAH = nil
end
--------------------------------------------------------------------------------
function ENT:Think()
local RetVal = self.BaseClass.Think(self)
local Panel = self.Panel
local Pneumatic = self.Pneumatic
self:SetPackedBool("PanelLights",self.PanelLamp.Value > 0.5)
self:SetPackedBool("RedLight",Panel.RedLights>0)
self:SetPackedBool("Headlights1",Panel.Headlights1 > 0)
self:SetPackedBool("Headlights2",Panel.Headlights2 > 0)
local lightsActive2 = math.min(1,Panel.MainLights2)
local lightsActive1 = math.min(1,Panel.MainLights1)^2
local emerActive1 = Panel.EmergencyLights1
local emerActive2 = Panel.EmergencyLights2
self:SetPackedBool("Lamps_emer1",emerActive1 > 0)
self:SetPackedBool("Lamps_emer2",emerActive2 > 0)
self:SetPackedBool("Lamps_half1",lightsActive1 > 0)
self:SetPackedBool("Lamps_half2",lightsActive2 > 0)
self:SetPackedRatio("LampsStrength",lightsActive1)
-- Signal if doors are open or no to platform simulation
self.LeftDoorsOpen =
(Pneumatic.LeftDoorState[1] > 0.5) or
(Pneumatic.LeftDoorState[2] > 0.5) or
(Pneumatic.LeftDoorState[3] > 0.5) or
(Pneumatic.LeftDoorState[4] > 0.5)
self.RightDoorsOpen =
(Pneumatic.RightDoorState[1] > 0.5) or
(Pneumatic.RightDoorState[2] > 0.5) or
(Pneumatic.RightDoorState[3] > 0.5) or
(Pneumatic.RightDoorState[4] > 0.5)
local TW18 = 0
if Panel.SSN > 0 then
local wags = #self.WagonList
for _,v in ipairs(self.WagonList) do
TW18 = TW18+(v.Panel.TW18 or 0)/wags
end
end
if self.EMAType == 1 then
self:SetPackedBool("CPS_AV",Panel.SSD > 0)
self:SetPackedBool("BPSon",self.BPS.PowerLamp > 0)
self:SetPackedBool("BPSErr",self.BPS.ErrorLamp > 0)
self:SetPackedBool("BPSFail",self.BPS.FailLamp > 0)
self:SetPackedBool("ARS_04",self.MARS.NoFreq > 0)
self:SetPackedBool("ARS_00",self.MARS.F5 > 0)
self:SetPackedBool("CPS_Pd",self.MARS.F6 > 0)
self:SetPackedBool("ARS_40",self.MARS.F4 > 0)
self:SetPackedBool("ARS_60",self.MARS.F3 > 0)
self:SetPackedBool("ARS_70",self.MARS.F2 > 0)
self:SetPackedBool("ARS_80",self.MARS.F1 > 0)
self:SetPackedBool("KSRing",false)
self:SetPackedBool("MRing",Panel.Ring > 0)
self:SetPackedBool("LKVD",self.MARS.KVD > 0)
self:SetPackedBool("NMLow",Panel.NMLow > 0)
self:SetPackedBool("UAVATriggered",Panel.UAVATriggered > 0 and CurTime()%0.4>0.2)
else
self:SetPackedBool("CPS_AV",false)
self:SetPackedBool("ARS_04",self.ALSCoil.NoFreq)
self:SetPackedBool("ARS_00",self.ALSCoil.F5)
self:SetPackedBool("CPS_Pd",self.ALSCoil.F6)
self:SetPackedBool("ARS_40",self.ALSCoil.F4)
self:SetPackedBool("ARS_60",self.ALSCoil.F3)
self:SetPackedBool("ARS_70",self.ALSCoil.F2)
self:SetPackedBool("ARS_80",self.ALSCoil.F1)
self:SetPackedBool("KSRing",Panel.Ring > 0)
self:SetPackedBool("MRing",false)
if self.PB.Value > 0 and not self:GetDriver() then self.PB:TriggerInput("Set",0) end
end
--print(self.Electric.Itotal,self.LK1.Value,self.LK5.Value,self.TSH.Value,self.PR.Value)
self:SetPackedBool("CPS_SN2",TW18 > 0.5)
--print(self.RRT.Value,self.RUT.Value)--self.Scheme["25A"],self["RRTpod"])
self:SetPackedRatio("CPS_SN1",math.Clamp(TW18^0.7,0,1))
self:SetPackedBool("CPS_KS",self.KSAUP.Power > 0)
self:SetPackedBool("CPS_4",Panel.S4 > 0)
self:SetPackedBool("CPS_5",Panel.S5 > 0)
self:SetPackedBool("CPS_20",Panel.S20 > 0)
self:SetPackedBool("CPS_6",Panel.S6 > 0)
self:SetPackedBool("CPS_1",Panel.S1 > 0)
self:SetPackedBool("CPS_1P",Panel.S1P > 0)
self:SetPackedBool("CPS_3",Panel.S3 > 0)
self:SetPackedBool("CPS_2",Panel.S2 > 0)
self:SetPackedBool("CPS_RP",Panel.GreenRP > 0)
self:SetPackedBool("CPS_SD",Panel.SSD > 0)
self:SetPackedBool("CPS_DT",Panel.SDT > 0)
--print(self.Electric.Cosume)
self:SetPackedRatio("LampsCount",math.Clamp(1-self.Electric.Cosume,0.3,1))
self:SetPackedBool("LMK",Panel.LMK > 0)
self:SetPackedBool("L16",Panel.L16 > 0)
self:SetPackedBool("LRU",Panel.LRU > 0)
self:SetPackedBool("LVRD",Panel.RD > 0)
self.SOSD = Panel.SOSD > 0
self:SetPackedBool("SOSD",self.SOSD)
self:SetPackedBool("DoorsW",Panel.DoorsW > 0)
self:SetPackedBool("GRP",Panel.GreenRP > 0)
self:SetPackedBool("BrY",Panel.BrY > 0)
self:SetPackedBool("DoorsWC",Panel.DoorsWC > 0)
self:SetPackedBool("CPS_4",Panel.S4 > 0)
self:SetPackedBool("CPS_4",Panel.S4 > 0)
self.TrueBrakeAngle = self.TrueBrakeAngle or 0
if self.ManualBrake < 0.001 and self.ManualBrake > self.TrueBrakeAngle then self.TrueBrakeAngle = self.ManualBrake end
if self.ManualBrake > 0.999 and self.ManualBrake < self.TrueBrakeAngle then self.TrueBrakeAngle = self.ManualBrake end
self.TrueBrakeAngle = self.TrueBrakeAngle + (self.ManualBrake - self.TrueBrakeAngle)*2.0*(self.DeltaTime or 0)
self:SetPackedRatio("ManualBrake",self.TrueBrakeAngle)
self.BD2:TriggerInput("Set",self.PassengerDoor and 1 or 0)
self:SetPackedBool("Compressor",Pneumatic.Compressor == 1.0)
self:SetPackedBool("RK",(self.RheostatController.Velocity ~= 0.0))
self:SetPackedBool("RearDoor",self.RearDoor)
self:SetPackedBool("FrontDoor",self.FrontDoor)
self:SetPackedBool("PassengerDoor",self.PassengerDoor)
self:SetPackedBool("CabinDoor",self.CabinDoor)
self:SetPackedBool("AnnPlay",Panel.AnnouncerPlaying > 0)
self:SetPackedBool("VPR",Panel.VPR > 0)
self:SetPackedBool("LUDS",Panel.V1 > 0)
self:SetNW2Int("WrenchMode",self.KVWrenchMode)
self:SetPackedRatio("CranePosition", Pneumatic.DriverValvePosition/7)
self:SetPackedRatio("ControllerPosition", (self.KV.ControllerPosition+3)/7)
self:SetPackedRatio("ReverserPosition", 1-(self.KV.ReverserPosition+1)/2)
self:SetPackedBool("RCUPosition", self.KV.RCU > 0)
self:SetPackedRatio("BLPressure", Pneumatic.ReservoirPressure/16.0)
self:SetPackedRatio("TLPressure", Pneumatic.TrainLinePressure/16.0)
self:SetPackedRatio("BCPressure", Pneumatic.BrakeCylinderPressure/6.0)
self:SetPackedRatio("BatteryVoltage",self.Panel["V1"]*self.Battery.Voltage/150.0)
self:SetPackedRatio("EnginesVoltage", self.Engines.E24/2000.0)
self:SetPackedRatio("EnginesCurrent", 0.5 + 0.5*(self.Electric.I24/500.0))
self:SetPackedRatio("Speed", self.ALSCoil.Speed/100)
self:SetPackedRatio("CPS_Speed", self.KSAUP.Speed/100)
self:SetNW2Bool("UPOPlaying",self:ReadTrainWire(47) > 0)
-- Exchange some parameters between engines, pneumatic system, and real world
self.Engines:TriggerInput("Speed",self.Speed)
if IsValid(self.FrontBogey) and IsValid(self.RearBogey) and not self.IgnoreEngine then
local A = 2*self.Engines.BogeyMoment
self.FrontBogey.MotorForce = 22050+3000*(A < 0 and 1 or 0)
self.FrontBogey.Reversed = (self.Reverser.NZ > 0.5)
self.RearBogey.MotorForce = 22050+3000*(A < 0 and 1 or 0)
self.RearBogey.Reversed = (self.Reverser.VP > 0.5)
-- These corrections are required to beat source engine friction at very low values of motor power
local P = math.max(0,0.04449 + 1.06879*math.abs(A) - 0.465729*A^2)
if math.abs(A) > 0.4 then P = math.abs(A) end
if math.abs(A) < 0.05 then P = 0 end
if self.Speed < 10 then P = P*(1.0 + 0.5*(10.0-self.Speed)/10.0) end
self.RearBogey.MotorPower = P*0.5*((A > 0) and 1 or -1)
self.FrontBogey.MotorPower = P*0.5*((A > 0) and 1 or -1)
-- Apply brakes
local add = 1
if math.abs(self:GetAngles().pitch) > 4 then
add = math.min((math.abs(self:GetAngles().pitch)-4)/2,1)*2
end
self.FrontBogey.PneumaticBrakeForce = 50000.0-2000
self.FrontBogey.BrakeCylinderPressure = Pneumatic.BrakeCylinderPressure*add
self.FrontBogey.BrakeCylinderPressure_dPdT = -Pneumatic.BrakeCylinderPressure_dPdT
self.FrontBogey.ParkingBrakePressure = self.ManualBrake
self.RearBogey.PneumaticBrakeForce = 50000.0-2000
self.RearBogey.BrakeCylinderPressure = Pneumatic.BrakeCylinderPressure*add
self.RearBogey.BrakeCylinderPressure_dPdT = -Pneumatic.BrakeCylinderPressure_dPdT
end
self:GenerateJerks()
return RetVal
end
--------------------------------------------------------------------------------
function ENT:OnButtonPress(button,ply)
if string.find(button,"PneumaticBrakeSet") then
self.Pneumatic:TriggerInput("BrakeSet",tonumber(button:sub(-1,-1)))
return
end
-- Parking brake
if button == "ParkingBrakeLeft" then
self.ManualBrake = math.max(0.0,(self.ManualBrake or 0) - 0.05)
if self.ManualBrake == 0.0 then return end
end
if button == "ParkingBrakeRight" then
self.ManualBrake = math.min(1.0,(self.ManualBrake or 0) + 0.05)
if self.ManualBrake == 1.0 then return end
end
if string.find(button,"PneumaticBrakeSet") then
self.Pneumatic:TriggerInput("BrakeSet",tonumber(button:sub(-1,-1)))
return
end
if button == "FrontDoor" then self.FrontDoor = not self.FrontDoor end
if button == "RearDoor" then self.RearDoor = not self.RearDoor end
if button == "PassengerDoor" then self.PassengerDoor = not self.PassengerDoor end
if button == "CabinDoor" then self.CabinDoor = not self.CabinDoor end
-- Parking brake
if button == "ManualBrakeLeft" then
self.ManualBrake = math.max(0.0,self.ManualBrake - 0.008)
if self.ManualBrake == 0.0 then return end
--print(self.ManualBrake)
end
if button == "ManualBrakeRight" then
self.ManualBrake = math.min(1.0,self.ManualBrake + 0.008)
if self.ManualBrake == 1.0 then return end
--print(self.ManualBrake)
end
if button == "KVUp" then
if self.KV.ControllerPosition ~= -1 then
self.KV:TriggerInput("ControllerUp",1.0)
end
end
if button == "KVUp_Unlocked" then self.KV:TriggerInput("ControllerUp",1.0) end
if button == "KVDown" then self.KV:TriggerInput("ControllerDown",1.0) end
if button == "KVSetT1B" then
if self.KV.ControllerPosition == -1 then
self.KV:TriggerInput("ControllerSet",-2)
else
self.KV:TriggerInput("ControllerSet",-1)
end
end
if button == "KVSetX1B" then
if self.KV.ControllerPosition == 1 then
self.KV:TriggerInput("ControllerSet",2)
else
self.KV:TriggerInput("ControllerSet",1)
end
end
if button == "KVSetT1AB" then
if self.KV.ControllerPosition == -2 then
self.KV:TriggerInput("ControllerSet",-1)
else
self.KV:TriggerInput("ControllerSet",-2)
end
end
if button == "KVWrenchKV" or button == "KVWrenchKV9" then
if self.KVWrenchMode == 0 then
self:PlayOnce("revers_in","cabin",0.7)
self.KVWrenchMode = 1
self.KV:TriggerInput("Enabled",1)
else
self:TriggerInput(button == "KVWrenchKV9" and "KVReverserDown" or "KVReverserUp",1)
end
end
if button == "KVWrenchNone" then
if self.KVWrenchMode == 0 then
self:PlayOnce("revers_in","cabin",0.7)
self.KVWrenchMode = 3
elseif self.KVWrenchMode ~= 0 and self.KV.ReverserPosition == 0 then
self:PlayOnce("revers_out","cabin",0.7)
self.KVWrenchMode = 0
self.KV:TriggerInput("Enabled",0)
end
end
if (self.KVWrenchMode == 3) and (button == "KVReverserUp") then
self.KV:TriggerInput("RCU",1)
end
if (self.KVWrenchMode == 3) and (button == "KVReverserDown") then
self.KV:TriggerInput("RCU",0)
end
if button == "KDL" then self.KDPK:TriggerInput("Open",1) end
if button == "KDP" then self.KDPK:TriggerInput("Close",1) end
if button == "KDL" and self.VUD.Value < 1 then self.KDL:TriggerInput("Close",1) end
if button == "KDP" and self.VUD.Value < 1 then self.KDP:TriggerInput("Close",1) end
if button == "EmergencyBrake" then
self.KV:TriggerInput("ControllerSet",-3)
self.Pneumatic:TriggerInput("BrakeSet",7)
self.DriverValveBLDisconnect:TriggerInput("Set",1)
return
end
if button == "DriverValveDisconnect" then
if self.DriverValveBLDisconnect.Value == 0 or self.DriverValveTLDisconnect.Value == 0 then
self.DriverValveBLDisconnect:TriggerInput("Set",1)
self.DriverValveTLDisconnect:TriggerInput("Set",1)
else
--self:PlayOnce("pneumo_disconnect1","cabin",0.9)
self.DriverValveBLDisconnect:TriggerInput("Set",0)
self.DriverValveTLDisconnect:TriggerInput("Set",0)
end
end
if button == "VUDToggle" then
self.VDL:TriggerInput("Open",1)
self.KDL:TriggerInput("Open",1)
self.KDP:TriggerInput("Open",1)
end
if button == "GVToggle" then
if self.GV.Value > 0.5 then
self:PlayOnce("revers_f",nil,0.7)
else
self:PlayOnce("revers_b",nil,0.7)
end
return
end
if button == "KB" then
if self.EMAType == 1 then
self.PB:TriggerInput("Set",1)
else
self.KOS:TriggerInput("Set",1)
end
end
if button == "PB" then
if self.EMAType == 1 then
self.KB:TriggerInput("Set",1)
else
self.PB:TriggerInput("Set",1-self.PB.Value)
end
end
--[[if (button == "UAVAToggle") then
if self.UAVA then
if self.UAVA.Value > 0.5 then
self:PlayOnce("uava_off","cabin")
else
self:PlayOnce("uava_off","cabin")
end
end
return
end]]
if button == "EPKToggle" and self.DriverValveBLDisconnect.Value == 1.0 then
if self.EPK.Value == 0.0 then
self:PlayOnce("epv_off","cabin",0.9)
else
self:PlayOnce("epv_on","cabin",0.9)
end
return
end
end
function ENT:OnButtonRelease(button)
if string.find(button,"PneumaticBrakeSet") then
if button == "PneumaticBrakeSet1" and (self.Pneumatic.DriverValvePosition == 1) then
self.Pneumatic:TriggerInput("BrakeSet",2)
end
return
end
if button == "KB" then
if self.EMAType == 1 then
self.PB:TriggerInput("Set",0)
else
self.KOS:TriggerInput("Set",0)
end
end
if button == "PB" then
self.KB:TriggerInput("Set",0)
end
--if button == "KVT2Set" then self.KVT:TriggerInput("Open",1) end
if button == "KDL" and self.VUD.Value < 1 then self.KDL:TriggerInput("Open",1) self:OnButtonRelease("KDLSet") end
if button == "KDP" and self.VUD.Value < 1 then self.KDP:TriggerInput("Open",1) self:OnButtonRelease("KDPSet") end
if button == "KVSetT1AB" then
if self.KV.ControllerPosition > -2 then
self.KV:TriggerInput("ControllerSet",-2)
end
end
if button == "KVSetX1B" then
if self.KV.ControllerPosition > 1 then
self.KV:TriggerInput("ControllerSet",1)
end
end
if button == "KVSetT1B" then
if self.KV.ControllerPosition < -1 then
self.KV:TriggerInput("ControllerSet",-1)
end
end
end
function ENT:OnCouple(train,isfront)
if isfront and self.FrontAutoCouple then
self.FrontBrakeLineIsolation:TriggerInput("Open",1.0)
self.FrontTrainLineIsolation:TriggerInput("Open",1.0)
self.FrontAutoCouple = false
elseif not isfront and self.RearAutoCouple then
self.RearBrakeLineIsolation:TriggerInput("Open",1.0)
self.RearTrainLineIsolation:TriggerInput("Open",1.0)
self.RearAutoCouple = false
end
self.BaseClass.OnCouple(self,train,isfront)
end

View File

@@ -0,0 +1,577 @@
ENT.Type = "anim"
ENT.Base = "gmod_subway_base"
ENT.PrintName = "Ema (81-502)"
ENT.Author = ""
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Category = "Metrostroi (trains)"
ENT.SkinsType = "81-502"
ENT.Model = "models/metrostroi_train/81-502/81-502.mdl"
ENT.Spawnable = true
ENT.AdminSpawnable = false
ENT.DontAccelerateSimulation = false
function ENT:PassengerCapacity()
return 300
end
function ENT:GetStandingArea()
return Vector(-450,-30,-55),Vector(380,30,-55)
end
local function GetDoorPosition(i,k)
return Vector(359.0 - 35/2 - 229.5*i,-65*(1-2*k),7.5)
end
-- Setup door positions
ENT.LeftDoorPositions = {}
ENT.RightDoorPositions = {}
for i=0,3 do
table.insert(ENT.LeftDoorPositions,GetDoorPosition(i,1))
table.insert(ENT.RightDoorPositions,GetDoorPosition(i,0))
end
ENT.AnnouncerPositions = {
{Vector(412,-49 ,61),80,0.6},
{Vector(-3,-60, 62),300,0.6},
{Vector(-3,60 ,62),300,0.6},
}
ENT.Cameras = {
{Vector(407.5+18,32,21),Angle(0,180,0),"Train.703.Breakers1"},
{Vector(407.5+18,50,24),Angle(5,180,0),"Train.703.Breakers2"},
{Vector(407.5+20,-40,25),Angle(0,180,0),"Train.502.AV"},
{Vector(407.5+10,-35,9),Angle(20,180,0),"Train.502.VBA","VBA"},
{Vector(407.5+10,-28,5),Angle(20,180,0),"Train.502.VRD","VRD"},
{Vector(407.5+13,-46,10),Angle(10,200,0),"Train.502.RCARS","RCARS"},
{Vector(407.5+13,-46,10),Angle(10,200,0),"Train.502.RCAV5","RCAV5"},
{Vector(407.5+3,-37,-20),Angle(-20,180+40,0),"Train.502.RCBPS","RCBPS"},
{Vector(407.5+3,-37,-20),Angle(-20,180+40,0),"Train.502.RCAV3","RCAV3"},
{Vector(407.5+3,-33,-20),Angle(-20,180-40,0),"Train.502.RCAV4","RCAV4"},
{Vector(407.5+34,48,16),Angle(0,37,0),"Train.Common.HelpersPanel"},
{Vector(407.5+30,40,5) ,Angle(30,10,0),"Train.703.Parking"},
{Vector(407.5+75,48,1),Angle(0,190,0),"Train.Common.RouteNumber"},
{Vector(450+13,0,26),Angle(60,0,0),"Train.Common.CouplerCamera"},
}
function ENT:InitializeSounds()
self.BaseClass.InitializeSounds(self)
self.SoundNames["rolling_5"] = {loop=true,"subway_trains/common/junk/junk_background3.wav"}
self.SoundNames["rolling_10"] = {loop=true,"subway_trains/717/rolling/10_rolling.wav"}
self.SoundNames["rolling_40"] = {loop=true,"subway_trains/717/rolling/40_rolling.wav"}
self.SoundNames["rolling_70"] = {loop=true,"subway_trains/717/rolling/70_rolling.wav"}
self.SoundNames["rolling_80"] = {loop=true,"subway_trains/717/rolling/80_rolling.wav"}
self.SoundPositions["rolling_5"] = {480,1e12,Vector(0,0,0),0.15}
self.SoundPositions["rolling_10"] = {480,1e12,Vector(0,0,0),0.20}
self.SoundPositions["rolling_40"] = {480,1e12,Vector(0,0,0),0.55}
self.SoundPositions["rolling_70"] = {480,1e12,Vector(0,0,0),0.60}
self.SoundPositions["rolling_80"] = {480,1e12,Vector(0,0,0),0.75}
self.SoundNames["rolling_motors"] = {loop=true,"subway_trains/ezh/rolling/rolling_motors.wav"}
self.SoundPositions["rolling_motors"] = {480,1e12,Vector(0,0,0),.4}
self.SoundNames["rolling_low"] = {loop=true,"subway_trains/717/rolling/rolling_outside_low.wav"}
self.SoundNames["rolling_medium1"] = {loop=true,"subway_trains/717/rolling/rolling_outside_medium1.wav"}
self.SoundNames["rolling_medium2"] = {loop=true,"subway_trains/717/rolling/rolling_outside_medium2.wav"}
self.SoundNames["rolling_high2"] = {loop=true,"subway_trains/717/rolling/rolling_outside_high2.wav"}
self.SoundPositions["rolling_low"] = {480,1e12,Vector(0,0,0),0.6}
self.SoundPositions["rolling_medium1"] = {480,1e12,Vector(0,0,0),0.90}
self.SoundPositions["rolling_medium2"] = {480,1e12,Vector(0,0,0),0.90}
self.SoundPositions["rolling_high2"] = {480,1e12,Vector(0,0,0),1.00}
self.SoundNames["pneumo_disconnect2"] = "subway_trains/common/pneumatic/pneumo_close.mp3"
self.SoundNames["pneumo_disconnect1"] = {
"subway_trains/common/pneumatic/pneumo_open.mp3",
"subway_trains/common/pneumatic/pneumo_open2.mp3",
}
self.SoundPositions["pneumo_disconnect2"] = {60,1e9,Vector(431.8,-50.1+1.5,-33.7),1}
self.SoundPositions["pneumo_disconnect1"] = {60,1e9,Vector(431.8,-50.1+1.5,-33.7),1}
-- Релюшки
self.SoundNames["rpb_off"] = "subway_trains/717/relays/lsd_2.mp3"
self.SoundNames["rpb_on"] = "subway_trains/717/relays/relay_on.mp3"
self.SoundPositions["rpb_on"] = {100,1e9,Vector(400,25,-35),1}
self.SoundPositions["rpb_off"] = {100,1e9,Vector(400,25,-35),1}
self.SoundNames["kd_off"] = "subway_trains/717/relays/lsd_2.mp3"
self.SoundNames["kd_on"] = "subway_trains/717/relays/new/kd_on.mp3"
self.SoundPositions["kd_on"] = {100,1e9,Vector(400,25,-35),1}
self.SoundPositions["kd_off"] = {100,1e9,Vector(400,25,-35),1}
self.SoundNames["avu_off"] = "subway_trains/common/pneumatic/ak11b_off.mp3"
self.SoundNames["avu_on"] = "subway_trains/common/pneumatic/ak11b_on.mp3"
self.SoundPositions["avu_on"] = {60,1e9, Vector(400,-40,-45),0.5}
self.SoundPositions["avu_off"] = {60,1e9, Vector(400,-40,-45),0.5}
--Подвагонка
self.SoundNames["lk2_on"] = "subway_trains/717/pneumo/lk1_on.mp3"
self.SoundNames["lk2_off"] = "subway_trains/717/pneumo/lk2_off.mp3"
self.SoundNames["lk5_on"] = "subway_trains/717/pneumo/lk2_on.mp3"
self.SoundNames["lk5_off"] = "subway_trains/717/pneumo/lk2_off.mp3"
self.SoundNames["lk4_on"] = "subway_trains/717/pneumo/lk3_on.mp3"
self.SoundNames["lk4_off"] = "subway_trains/717/pneumo/lk3_off.mp3"
self.SoundPositions["lk2_on"] = {440,1e9,Vector(-60,-40,-66),0.22}
self.SoundPositions["lk2_off"] = {440,1e9,Vector(-60,-40,-66),0.3}
self.SoundPositions["lk5_on"] = self.SoundPositions["lk2_on"]
self.SoundPositions["lk5_off"] = self.SoundPositions["lk2_off"]
self.SoundPositions["lk4_on"] = self.SoundPositions["lk2_on"]
self.SoundPositions["lk4_off"] = self.SoundPositions["lk2_off"]
self.SoundNames["compressor"] = {loop=1.79,"subway_trains/717/compressor/compressor_717_start2.wav","subway_trains/717/compressor/compressor_717_loop2.wav", "subway_trains/717/compressor/compressor_717_stop2.wav"}
self.SoundPositions["compressor"] = {485,1e9,Vector(-118,-40,-66),0.80}
self.SoundNames["compressor_reflection"] = {"subway_trains/common/junk/junk_background2.wav"}
self.SoundPositions["compressor_reflection"] = {150,1e9,Vector(300,0,0)}
self.SoundPositions["compressor_reflection"] = {150,1e9,Vector(-300,0,0)}
self.SoundNames["rk"] = {"subway_trains/ezh/rk/rk_start.wav","subway_trains/ezh/rk/rk_spin.wav","subway_trains/ezh/rk/rk_stop.wav"}
self.SoundPositions["rk"] = {50,1e9,Vector(110,-40,-75),0.22}
self.SoundNames["ezh3_revers_0-f"] = {"subway_trains/717/kv70/reverser_0-f_1.mp3","subway_trains/717/kv70/reverser_0-f_2.mp3"}
self.SoundNames["ezh3_revers_f-0"] = {"subway_trains/717/kv70/reverser_f-0_1.mp3","subway_trains/717/kv70/reverser_f-0_2.mp3"}
self.SoundNames["ezh3_revers_0-b"] = {"subway_trains/717/kv70/reverser_0-b_1.mp3","subway_trains/717/kv70/reverser_0-b_2.mp3"}
self.SoundNames["ezh3_revers_b-0"] = {"subway_trains/717/kv70/reverser_b-0_1.mp3","subway_trains/717/kv70/reverser_b-0_2.mp3"}
self.SoundNames["revers_in"] = {"subway_trains/ezh3/kv66/revers_in.mp3"}
self.SoundNames["revers_out"] = {"subway_trains/ezh3/kv66/revers_out.mp3"}
self.SoundNames["rcu_in"] = {"subway_trains/ezh3/kv66/revers_in.mp3"}
self.SoundNames["rcu_out"] = {"subway_trains/ezh3/kv66/revers_out.mp3"}
self.SoundNames["rcu_on"] = {"subway_trains/ezh3/kv66/rcu_on.mp3","subway_trains/ezh3/kv66/rcu_on2.mp3"}
self.SoundNames["rcu_off"] = "subway_trains/ezh3/kv66/rcu_off.mp3"
self.SoundPositions["ezh3_revers_0-f"] = {80,1e9,Vector(458.00,-23,-6.40)}
self.SoundPositions["ezh3_revers_f-0"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["ezh3_revers_0-b"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["ezh3_revers_b-0"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["revers_in"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["revers_out"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["rcu_on"] = self.SoundPositions["ezh3_revers_0-f"]
self.SoundPositions["rcu_off"] = self.SoundPositions["rcu_on"]
self.SoundPositions["rcu_in"] = self.SoundPositions["rcu_on"]
self.SoundPositions["rcu_out"] = self.SoundPositions["rcu_on"]
self.SoundNames["kr_left"] = "subway_trains/ezh3/controller/krishechka_left.mp3"
self.SoundNames["kr_right"] = "subway_trains/ezh3/controller/krishechka_right.mp3"
self.SoundNames["switch_off"] = {
"subway_trains/717/switches/tumbler_slim_off1.mp3",
"subway_trains/717/switches/tumbler_slim_off2.mp3",
"subway_trains/717/switches/tumbler_slim_off3.mp3",
"subway_trains/717/switches/tumbler_slim_off4.mp3",
}
self.SoundNames["switch_on"] = {
"subway_trains/717/switches/tumbler_slim_on1.mp3",
"subway_trains/717/switches/tumbler_slim_on2.mp3",
"subway_trains/717/switches/tumbler_slim_on3.mp3",
"subway_trains/717/switches/tumbler_slim_on4.mp3",
}
self.SoundNames["switchbl_off"] = {
"subway_trains/717/switches/tumbler_fatb_off1.mp3",
"subway_trains/717/switches/tumbler_fatb_off2.mp3",
"subway_trains/717/switches/tumbler_fatb_off3.mp3",
}
self.SoundNames["switchbl_on"] = {
"subway_trains/717/switches/tumbler_fatb_on1.mp3",
"subway_trains/717/switches/tumbler_fatb_on2.mp3",
"subway_trains/717/switches/tumbler_fatb_on3.mp3",
}
self.SoundNames["button1_off"] = {
"subway_trains/ezh3/switches/button_off1.mp3",
"subway_trains/ezh3/switches/button_off2.mp3",
}
self.SoundNames["button1_on"] = {
"subway_trains/ezh3/switches/button_on1.mp3",
"subway_trains/ezh3/switches/button_on2.mp3",
}
self.SoundNames["button2_off"] = {
"subway_trains/ezh3/switches/button_off3.mp3",
"subway_trains/ezh3/switches/button_off4.mp3",
}
self.SoundNames["button2_on"] = {
"subway_trains/ezh3/switches/button_on3.mp3",
"subway_trains/ezh3/switches/button_on4.mp3",
}
self.SoundNames["button3_off"] = {
"subway_trains/ezh3/switches/button_off6.mp3",
"subway_trains/ezh3/switches/button_off5.mp3",
}
self.SoundNames["button3_on"] = {
"subway_trains/ezh3/switches/button_on5.mp3",
"subway_trains/ezh3/switches/button_on6.mp3",
}
self.SoundNames["uava_reset"] = {
"subway_trains/common/uava/uava_reset1.mp3",
"subway_trains/common/uava/uava_reset2.mp3",
"subway_trains/common/uava/uava_reset4.mp3",
}
self.SoundPositions["uava_reset"] = {80,1e9,Vector(449+7.7,56.0,-10.24349),0.6}
self.SoundNames["gv_f"] = {"subway_trains/ezh3/kv66/rcu_on.mp3","subway_trains/ezh3/kv66/rcu_on2.mp3"}
self.SoundNames["gv_b"] = "subway_trains/ezh3/kv66/rcu_off.mp3"
self.SoundPositions["gv_f"] = {80,1e2,Vector(120,62.0+0.0,-60),0.5}
self.SoundPositions["gv_b"] = {80,1e2,Vector(120,62.0+0.0,-60),0.5}
self.SoundNames["disconnect_valve"] = "subway_trains/common/switches/pneumo_disconnect_switch.mp3"
self.SoundNames["kv70_fix_on"] = {"subway_trains/717/kv70/kv70_fix_on1.mp3","subway_trains/717/kv70/kv70_fix_on2.mp3"}
self.SoundNames["kv70_fix_off"] = {"subway_trains/717/kv70/kv70_fix_off1.mp3","subway_trains/717/kv70/kv70_fix_off2.mp3"}
self.SoundNames["kv40_0_t1"] = {"subway_trains/ezh/kv40_2/0_t1.mp3"}
self.SoundNames["kv40_t1_0"] = {"subway_trains/ezh/kv40_2/t1_0.mp3"}
self.SoundNames["kv40_t1_t1a"] = {"subway_trains/ezh/kv40_2/t1_t1a.mp3"}
self.SoundNames["kv40_t1a_t1"] = {"subway_trains/ezh/kv40_2/t1a_t1.mp3"}
self.SoundNames["kv40_t1a_t2"] = {"subway_trains/ezh/kv40_2/t1a_t2.mp3"}
self.SoundNames["kv40_t2_t1a"] = {"subway_trains/ezh/kv40_2/t2_t1a.mp3"}
self.SoundNames["kv40_0_x1"] = {"subway_trains/ezh/kv40_2/0_x1_2.mp3"}
self.SoundNames["kv40_x1_0"] = {"subway_trains/ezh/kv40_2/x1_0.mp3"}
self.SoundNames["kv40_x1_x2"] = {"subway_trains/ezh/kv40_2/x1_x2.mp3"}
self.SoundNames["kv40_x2_x1"] = {"subway_trains/ezh/kv40_2/x2_x1.mp3"}
self.SoundNames["kv40_x2_x3"] = {"subway_trains/ezh/kv40_2/x2_x3.mp3"}
self.SoundNames["kv40_x3_x2"] = {"subway_trains/ezh/kv40_2/x3_x2.mp3"}
self.SoundPositions["kv70_fix_on"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv70_fix_off"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_0_t1"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv70_t1_0_fix"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_t1_0"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_t1_t1a"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_t1a_t1"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_t1a_t2"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_t2_t1a"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_0_x1"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_x1_0"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_x1_x2"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_x2_x1"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_x2_x3"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundPositions["kv40_x3_x2"] = {100,1e9,Vector(458.00,-23,-6),1}
self.SoundNames["rcav_0-2"] = {"subway_trains/ezh3/rc_ars/0-2.mp3"}
self.SoundNames["rcav_2-0"] = {"subway_trains/ezh3/rc_ars/2-0.mp3"}
self.SoundNames["ring"] = {loop=0.05,"subway_trains/502/ring_ksaup.wav"}
self.SoundPositions["ring"] = {120,1e9,Vector(410,-40,35),0.35}
self.SoundNames["ring2"] = {"subway_trains/717/ring/ring_start.wav","subway_trains/717/ring/ring_loop.wav","subway_trains/717/ring/ring_end.wav"}
self.SoundPositions["ring2"] = self.SoundPositions["ring"]
self.SoundNames["vpr"] = {loop=0.8,"subway_trains/common/other/radio/vpr_start.wav","subway_trains/common/other/radio/vpr_loop.wav","subway_trains/common/other/radio/vpr_off.wav"}
self.SoundPositions["vpr"] = {60,1e9,Vector(412,-49 ,61),0.05}
self.SoundNames["cab_door_open"] = "subway_trains/common/door/cab/door_open.mp3"
self.SoundNames["cab_door_close"] = "subway_trains/common/door/cab/door_close.mp3"
self.SoundNames["parking_brake_rolling"] = {"subway_trains/ezh3/parking_brake_rolling1.mp3","subway_trains/ezh3/parking_brake_rolling2.mp3","subway_trains/ezh3/parking_brake_rolling3.mp3","subway_trains/ezh3/parking_brake_rolling4.mp3"}
self.SoundPositions["parking_brake_rolling"] = {65,1e9,Vector(449.118378+7.6,33.493385,-14.713276),0.1}
self.SoundNames["av8_on"] = {"subway_trains/common/switches/av8/av8_on.mp3","subway_trains/common/switches/av8/av8_on2.mp3"}
self.SoundNames["av8_off"] = {"subway_trains/common/switches/av8/av8_off.mp3","subway_trains/common/switches/av8/av8_off2.mp3"}
self.SoundPositions["av8_on"] = {100,1e9,Vector(405,40,30)}
self.SoundPositions["av8_off"] = {100,1e9,Vector(405,40,30)}
self.SoundNames["vu22_on"] = {"subway_trains/ezh3/vu/vu22_on1.mp3", "subway_trains/ezh3/vu/vu22_on2.mp3", "subway_trains/ezh3/vu/vu22_on3.mp3"}
self.SoundNames["vu22_off"] = {"subway_trains/ezh3/vu/vu22_off1.mp3", "subway_trains/ezh3/vu/vu22_off2.mp3", "subway_trains/ezh3/vu/vu22_off3.mp3"}
self.SoundNames["vu223_on"] = {"subway_trains/common/switches/vu22/vu22_3_on.mp3"}
self.SoundNames["vu223_off"] = {"subway_trains/common/switches/vu22/vu22_3_off.mp3"}
--Краны
--Краны
self.SoundNames["brake_f"] = {"subway_trains/common/pneumatic/vz_brake_on2.mp3","subway_trains/common/pneumatic/vz_brake_on3.mp3","subway_trains/common/pneumatic/vz_brake_on4.mp3"}
self.SoundPositions["brake_f"] = {50,1e9,Vector(317-8,0,-82),0.13}
self.SoundNames["brake_b"] = self.SoundNames["brake_f"]
self.SoundPositions["brake_b"] = {50,1e9,Vector(-317+0,0,-82),0.13}
self.SoundNames["release1"] = {loop=true,"subway_trains/common/pneumatic/release_0.wav"}
self.SoundPositions["release1"] = {350,1e9,Vector(-183,0,-70),1}
self.SoundNames["release2"] = {loop=true,"subway_trains/common/pneumatic/release_low.wav"}
self.SoundPositions["release2"] = {350,1e9,Vector(-183,0,-70),0.4}
self.SoundNames["front_isolation"] = {loop=true,"subway_trains/common/pneumatic/isolation_leak.wav"}
self.SoundPositions["front_isolation"] = {300,1e9,Vector(452, 0,-63),1}
self.SoundNames["rear_isolation"] = {loop=true,"subway_trains/common/pneumatic/isolation_leak.wav"}
self.SoundPositions["rear_isolation"] = {300,1e9,Vector(-456, 0,-63),1}
self.SoundNames["crane013_brake2"] = {loop=true,"subway_trains/common/pneumatic/013_brake2.wav"}
self.SoundPositions["crane013_brake2"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.86}
self.SoundNames["crane334_brake_high"] = {loop=true,"subway_trains/common/pneumatic/334_brake.wav"}
self.SoundPositions["crane334_brake_high"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.85}
self.SoundNames["crane334_brake_low"] = {loop=true,"subway_trains/common/pneumatic/334_brake_slow.wav"}
self.SoundPositions["crane334_brake_low"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.75}
self.SoundNames["crane334_brake_2"] = {loop=true,"subway_trains/common/pneumatic/334_brake_slow.wav"}
self.SoundPositions["crane334_brake_2"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.85}
self.SoundNames["crane334_brake_eq_high"] = {loop=true,"subway_trains/common/pneumatic/334_release_reservuar.wav"}
self.SoundPositions["crane334_brake_eq_high"] = {80,1e9,Vector(456.55,-52.55,-70),0.45}
self.SoundNames["crane334_brake_eq_low"] = {loop=true,"subway_trains/common/pneumatic/334_brake_slow2.wav"}
self.SoundPositions["crane334_brake_eq_low"] = {80,1e9,Vector(456.55,-52.55,-70),0.45}
self.SoundNames["crane334_release"] = {loop=true,"subway_trains/common/pneumatic/334_release3.wav"}
self.SoundPositions["crane334_release"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.2}
self.SoundNames["crane334_release_2"] = {loop=true,"subway_trains/common/pneumatic/334_release2.wav"}
self.SoundPositions["crane334_release_2"] = {80,1e9,Vector(456.55,-52.55,-4.5),0.2}
self.SoundNames["valve_brake"] = {loop=true,"subway_trains/common/pneumatic/epv_loop.wav"}
self.SoundPositions["valve_brake"] = {400,1e9,Vector(464.40,24.4,-50),1}
--self.SoundNames["emer_brake"] = {loop=0.8,"subway_trains/common/pneumatic/autostop_start.wav","subway_trains/common/pneumatic/autostop_loop.wav", "subway_trains/common/pneumatic/autostop_end.wav"}
self.SoundNames["emer_brake"] = {loop=true,"subway_trains/common/pneumatic/autostop_loop.wav"}
self.SoundNames["emer_brake2"] = {loop=true,"subway_trains/common/pneumatic/autostop_loop_2.wav"}
self.SoundPositions["emer_brake"] = {600,1e9,Vector(380,-65,-75)}
self.SoundPositions["emer_brake2"] = self.SoundPositions["emer_brake"]
self.SoundNames["pneumo_TL_open"] = {
"subway_trains/common/334/334_open.mp3",
}
self.SoundNames["pneumo_TL_open_background"] = {
"subway_trains/common/334/334_open_pipeinside.mp3",
}
self.SoundPositions["pneumo_TL_open_background"] = {180,1e9,Vector(456.55,-52.57,-55),0.2}
self.SoundNames["pneumo_TL_disconnect"] = {
"subway_trains/common/334/334_close.mp3",
}
self.SoundNames["pneumo_BL_disconnect"] = {
"subway_trains/common/334/334_close.mp3",
}
self.SoundNames["horn"] = {loop=0.8,"subway_trains/common/pneumatic/horn/horn3_start.wav","subway_trains/common/pneumatic/horn/horn3_loop.wav", "subway_trains/common/pneumatic/horn/horn3_end.wav"}
self.SoundPositions["horn"] = {1100,1e9,Vector(450,-20,-55)}
--DOORS
self.SoundNames["vdol_on"] = {
"subway_trains/common/pneumatic/door_valve/VDO_on.mp3",
"subway_trains/common/pneumatic/door_valve/VDO2_on.mp3",
}
self.SoundNames["vdol_off"] = {
"subway_trains/common/pneumatic/door_valve/VDO_off.mp3",
"subway_trains/common/pneumatic/door_valve/VDO2_off.mp3",
}
self.SoundPositions["vdol_on"] = {100,1e9,Vector(410,20,-45)}
self.SoundPositions["vdol_off"] = {100,1e9,Vector(410,20,-45)}
self.SoundNames["vdor_on"] = self.SoundNames["vdol_on"]
self.SoundNames["vdor_off"] = self.SoundNames["vdol_off"]
self.SoundPositions["vdor_on"] = self.SoundPositions["vdol_on"]
self.SoundPositions["vdor_off"] = self.SoundPositions["vdol_off"]
self.SoundNames["vdz_on"] = {
"subway_trains/common/pneumatic/door_valve/VDZ_on.mp3",
"subway_trains/common/pneumatic/door_valve/VDZ2_on.mp3",
"subway_trains/common/pneumatic/door_valve/VDZ3_on.mp3",
}
self.SoundNames["vdz_off"] = {
"subway_trains/common/pneumatic/door_valve/VDZ_off.mp3",
"subway_trains/common/pneumatic/door_valve/VDZ2_off.mp3",
"subway_trains/common/pneumatic/door_valve/VDZ3_off.mp3",
}
self.SoundPositions["vdz_on"] = {100,1e9,Vector(410,20,-45)}
self.SoundPositions["vdz_off"] = {100,1e9,Vector(410,20,-45)}
self.SoundNames["kk_off"] = "subway_trains/common/pneumatic/ak11b_off2.mp3"
self.SoundNames["kk_on"] = "subway_trains/common/pneumatic/ak11b_on2.mp3"
self.SoundPositions["kk_on"] = {100,1e9,Vector(407,-55,-5),0.3}
self.SoundPositions["kk_off"] = {100,1e9,Vector(407,-55,-5),0.3}
for i=0,3 do
for k=0,1 do
self.SoundNames["door"..i.."x"..k.."r"] = {"subway_trains/common/door/door_roll.wav",loop=true}
self.SoundPositions["door"..i.."x"..k.."r"] = {150,1e9,GetDoorPosition(i,k),0.11}
self.SoundNames["door"..i.."x"..k.."o"] = {"subway_trains/common/door/door_open_end5.mp3","subway_trains/common/door/door_open_end6.mp3","subway_trains/common/door/door_open_end7.mp3"}
self.SoundPositions["door"..i.."x"..k.."o"] = {350,1e9,GetDoorPosition(i,k),2}
self.SoundNames["door"..i.."x"..k.."c"] = {"subway_trains/common/door/door_close_end.mp3","subway_trains/common/door/door_close_end2.mp3","subway_trains/common/door/door_close_end3.mp3","subway_trains/common/door/door_close_end4.mp3","subway_trains/common/door/door_close_end5.mp3"}
self.SoundPositions["door"..i.."x"..k.."c"] = {400,1e9,GetDoorPosition(i,k),2}
end
end
for k,v in ipairs(self.AnnouncerPositions) do
self.SoundNames["announcer_noise1_"..k] = {loop=true,"subway_announcers/upo/noiseS1.wav"}
self.SoundPositions["announcer_noise1_"..k] = {v[2] or 300,1e9,v[1],v[3]*0.2}
self.SoundNames["announcer_noise2_"..k] = {loop=true,"subway_announcers/upo/noiseS2.wav"}
self.SoundPositions["announcer_noise2_"..k] = {v[2] or 300,1e9,v[1],v[3]*0.2}
self.SoundNames["announcer_noise3_"..k] = {loop=true,"subway_announcers/upo/noiseS3.wav"}
self.SoundPositions["announcer_noise3_"..k] = {v[2] or 300,1e9,v[1],v[3]*0.2}
self.SoundNames["announcer_noiseW"..k] = {loop=true,"subway_announcers/upo/noiseW.wav"}
self.SoundPositions["announcer_noiseW"..k] = {v[2] or 300,1e9,v[1],v[3]*0.2}
end
self.SoundNames["RKR"] = "subway_trains/common/pneumatic/rkr2.mp3"
self.SoundPositions["RKR"] = {330,1e9,Vector(-27,-40,-66),0.22}
self.SoundNames["PN2end"] = {"subway_trains/common/pneumatic/vz2_end.mp3","subway_trains/common/pneumatic/vz2_end_2.mp3","subway_trains/common/pneumatic/vz2_end_3.mp3","subway_trains/common/pneumatic/vz2_end_4.mp3"}
self.SoundPositions["PN2end"] = {350,1e9,Vector(-183,0,-70),0.3}
end
function ENT:InitializeSystems()
-- Электросистема Е (АРС)
self:LoadSystem("Electric","81_502_Electric")
self.Electric:TriggerInput("Type",self.Electric.NVL)
-- Токоприёмник
self:LoadSystem("TR","TR_3B")
-- Электротяговые двигатели
self:LoadSystem("Engines","DK_108D")
-- Резисторы для реостата/пусковых сопротивлений
self:LoadSystem("KF_47A","81_703_KF_47A")
-- Резисторы для ослабления возбуждения
self:LoadSystem("KF_50A")
-- Ящик с предохранителями
self:LoadSystem("YAP_57")
-- Резисторы для цепей управления
--self:LoadSystem("YAS_44V")
self:LoadSystem("Reverser","PR_722D")
-- Реостатный контроллер для управления пусковыми сопротивления
self:LoadSystem("RheostatController","EKG_17A")
-- Групповой переключатель положений
self:LoadSystem("PositionSwitch","EKG_18A")
-- Кулачковый контроллер
self:LoadSystem("KV","KV_55")
-- Панель резервного управления
self:LoadSystem("PRU_502")
-- Ящики с реле и контакторами
self:LoadSystem("LK_755A")
self:LoadSystem("YAR_13A")
--self:LoadSystem("YAR_27")
self:LoadSystem("YAK_36")
self:LoadSystem("YAK_31A")
self:LoadSystem("YAS_44V")
self:LoadSystem("YARD_2")
self:LoadSystem("PR_109A")
-- Пневмосистема 81-703
self:LoadSystem("Pneumatic","81_703_Pneumatic")
self:LoadSystem("BD2","Relay","")
-- Панель управления Е
self:LoadSystem("Panel","81_502_Panel")
-- Everything else
self:LoadSystem("Battery")
self:LoadSystem("Horn")
self:LoadSystem("Announcer","81_71_Announcer", "AnnouncementsUPO")
self:LoadSystem("UPO","81_71_UPO")
self:LoadSystem("ALSCoil")
self:LoadSystem("KSAUP","81_502_KSAUP")
self:LoadSystem("IPAV")
self:LoadSystem("MARS","81_502_ARS")
self:LoadSystem("BPS","81_502_BPS")
self:LoadSystem("RouteNumber","81_71_RouteNumber",3)
--self:LoadSystem("ALS_ARS","ARS_MP")
--self:LoadSystem("IGLA_CBKI","IGLA_CBKI2")
--self:LoadSystem("IGLA_PCBK")
end
function ENT:PostInitializeSystems()
self.Electric:TriggerInput("Type",self.Electric.NVL)
if SERVER and (not Metrostroi.MapHasFullSupport or not Metrostroi.MapHasFullSupport("auto")) then
self.KSAUP:TriggerInput("CommandDoorsLeft",1)
self.KSAUP:TriggerInput("CommandDoorsRight",1)
end
end
ENT.SubwayTrain = {
Type = "E",
Name = "Ema",
Manufacturer = "LVZ",
WagType = 0,
ALS = {
NoEPK = true,
HaveAutostop = true,
TwoToSix = false,
RSAs325Hz = false,
Aproove0As325Hz = true,
},
IPAV = {
Systems = {"KSAUP"}
},
EKKType = 703,
NoFrontEKK=true,
}
ENT.NumberRanges = {{6047,6353}}
---[[
ENT.Spawner = {
model = {
"models/metrostroi_train/81-502/81-502.mdl",
"models/metrostroi_train/81-502/ema_salon.mdl",
"models/metrostroi_train/81-502/mirrors_ema.mdl",
"models/metrostroi_train/81-502/ema502_cabine.mdl",
"models/metrostroi_train/81-502/sun_protectors.mdl",
"models/metrostroi_train/81-502/controller_a.mdl",
"models/metrostroi_train/81-502/panel_b.mdl",
{"models/metrostroi_train/81-508/81-508_underwagon.mdl",pos=Vector(0,1,-18)}
},
spawnfunc = function(i,tbls,tblt)
local WagNum = tbls.WagNum
if tbls.EWagons and i==1 then
tbls.EID = 2+math.floor(math.random()*(WagNum-2))
end
if 1<i and i<WagNum then
return (tbls.EWagons and tbls.EMAType>1 and (tbls.EID==i or math.random()>0.9)) and "gmod_subway_81-703_int" or "gmod_subway_81-501"
else
return "gmod_subway_81-502"
end
end,
interim = "gmod_subway_81-501",
func = function(ent,i,maxi)
if ent:GetClass() == "gmod_subway_81-502" then
ent.VU:TriggerInput("Set",1)
ent.UAVA:TriggerInput("Set",0)
ent.Plombs.VU = nil
ent.Plombs.UAVA = true
else
ent.VU:TriggerInput("Set",0)
ent.UAVA:TriggerInput("Set",1)
ent.Plombs.VU = true
ent.Plombs.UAVA = nil
end
end,
Metrostroi.Skins.GetTable("Texture","Texture",Texture,"train"),
Metrostroi.Skins.GetTable("PassTexture","PassTexture",PassTexture,"pass"),
Metrostroi.Skins.GetTable("CabTexture","CabTexture",CabTexture,"cab"),
{"EMAType","Spawner.502.EMAType","List",{"Spawner.502.EMAType.NVL","Spawner.502.EMAType.KVLOld","Spawner.502.EMAType.KVLNew"},nil,function(ent,val,rot)
if ent:GetClass():find("703") then
-- Cross connections in train wires
ent.TrainWireInverts = {
[15] = true,
}
ent:SetNW2String("Texture","Def_703SPB")
end
if val == 1 then ent.Electric:TriggerInput("Type",ent.Electric.NVL) end
if val > 1 then ent.Electric:TriggerInput("Type",ent.Electric.KVL) end
ent.EMAType = val
ent:SetNW2Int("EMAType",ent.EMAType)
end},
{"SpawnMode","Spawner.Common.SpawnMode","List",{"Spawner.Common.SpawnMode.Full","Spawner.Common.SpawnMode.Deadlock","Spawner.Common.SpawnMode.NightDeadlock","Spawner.Common.SpawnMode.Depot"}, nil,function(ent,val,rot,i,wagnum,rclk)
if rclk then return end
if ent._SpawnerStarted~=val then
ent.VB:TriggerInput("Set",val<=2 and 1 or 0)
ent.AV:TriggerInput("Set",val<=2 and 1 or 0)
if ent.KSAUP then
local first = i==1 or _LastSpawner~=CurTime()
ent.VU2:TriggerInput("Set",(val<=2 and first) and 1 or 0)
--ent.VR:TriggerInput("Set",val<=2 and 1 or 0)
ent.R_UPO:TriggerInput("Set",val<=2 and 1 or 0)
ent.VMK:TriggerInput("Set",(val==1 and first) and 1 or 0)
ent.ARS:TriggerInput("Set",(val==1 and ent.Plombs.RCARS) and 1 or 0)
ent.VBA:TriggerInput("Set",(val==1 and ent.Plombs.RCAV3) and 1 or 0)
ent.ALS:TriggerInput("Set",val==1 and 1 or 0)
ent.VKF:TriggerInput("Set",val==3 and 1 or 0)
ent.VSOSD:TriggerInput("Set",(val==1 and first) and 1 or 0)
ent.Headlights:TriggerInput("Set",val==1 and 1 or 0)
_LastSpawner=CurTime()
ent.CabinDoor = val==4 and first
ent.PassengerDoor = val==4
ent.RearDoor = val==4
else
ent.VU2:TriggerInput("Set",0)
ent.FrontDoor = val==4
ent.RearDoor = val==4
end
ent.GV:TriggerInput("Set",val<4 and 1 or 0)
ent._SpawnerStarted = val
end
if val==1 then ent.KO:TriggerInput("Close",1) else ent.KO:TriggerInput("Open",1) end
ent.Pneumatic.TrainLinePressure = val==3 and math.random()*4 or val==2 and 4.5+math.random()*3 or 7.6+math.random()*0.6
if val==4 then ent.Pneumatic.BrakeLinePressure = 5.2 end
end},
{"EWagons","Spawner.502.EWagons","Boolean"},
}
--]]