mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-04 00:52:33 +00:00
release branch init
This commit is contained in:
@@ -11,7 +11,7 @@ ENT.SyncTable = {
|
||||
"RRIEnable","RRIAmplifier",
|
||||
"DriverValveBLDisconnect","DriverValveTLDisconnect","EmergencyBrakeValve",
|
||||
"GV",
|
||||
"R_Program1","R_Program2","UAVA","UAVAC",
|
||||
"R_Program1","R_Program2","UAVA"
|
||||
}
|
||||
ENT.SyncFunctions = {
|
||||
""
|
||||
@@ -63,7 +63,6 @@ function ENT:Initialize()
|
||||
self.RearBogey:SetNWInt("MotorSoundType",0)
|
||||
self.FrontBogey.PneumaticPow = 1.5
|
||||
self.RearBogey.PneumaticPow = 1.5
|
||||
self.FrontCouple.EKKDisconnected = true
|
||||
|
||||
-- Initialize key mapping
|
||||
self.KeyMap = {
|
||||
@@ -112,7 +111,7 @@ function ENT:Initialize()
|
||||
[KEY_L] = "DriverValveDisconnect",
|
||||
|
||||
[KEY_7] = "KVWrenchNone",
|
||||
[KEY_9] = "KVWrenchKV9",
|
||||
[KEY_9] = "KVWrenchKV",
|
||||
[KEY_0] = "KVWrenchKV",
|
||||
[KEY_6] = "KVSetT1A",
|
||||
|
||||
@@ -183,6 +182,22 @@ function ENT:Initialize()
|
||||
},
|
||||
}
|
||||
|
||||
self.Lights = {
|
||||
-- Emergency lit
|
||||
[9] = { "dynamiclight", Vector(200, 0, -5), Angle(0,0,0), Color(255, 176, 59), brightness = 3, distance = 200},
|
||||
[10] = { "dynamiclight", Vector(-150, 0, -5), Angle(0,0,0), Color(255, 176, 59), brightness = 3, distance = 200},
|
||||
[11] = { "dynamiclight", Vector( 200, 0, -5), Angle(0,0,0), Color(255, 176, 59), brightness = 4, distance = 260},
|
||||
[12] = { "dynamiclight", Vector( 0, 0, -5), Angle(0,0,0), Color(255, 176, 59), brightness = 4, distance = 260},
|
||||
[13] = { "dynamiclight", Vector(-260, 0, -5), Angle(0,0,0), Color(255, 176, 59), brightness = 4, distance = 260},
|
||||
-- Cabin
|
||||
[23] = { "dynamiclight", Vector(425,0,40), Angle(0,0,0), Color(252, 157, 77), brightness = 0.0007, distance = 600},
|
||||
|
||||
[5] = { "light", Vector(465+5,-32, 48), Angle(0,0,0), Color(255,50,50), brightness = 0.2, scale = 1.5, texture = "sprites/light_glow02.vmt" },
|
||||
[6] = { "light", Vector(465+5, 32, 48), Angle(0,0,0), Color(255,50,50), brightness = 0.2, scale = 1.5, texture = "sprites/light_glow02.vmt" },
|
||||
[30] = { "light", Vector(465+5 , -45, -37), Angle(0,0,0), Color(255,220,180), brightness = 0.2, scale = 1.5, texture = "sprites/light_glow02.vmt" },
|
||||
[31] = { "light", Vector(465+5 , 45, -37), Angle(0,0,0), Color(255,220,180), brightness = 0.2, scale = 1.5, texture = "sprites/light_glow02.vmt" },
|
||||
[32] = { "light", Vector(465+5 , 0, 48), Angle(0,0,0), Color(255,220,180), brightness = 0.2, scale = 2.5, texture = "sprites/light_glow02.vmt" },
|
||||
}
|
||||
|
||||
-- Cross connections in train wires
|
||||
self.TrainWireInverts = {
|
||||
@@ -194,6 +209,14 @@ function ENT:Initialize()
|
||||
[31] = 32, -- Doors L<->R
|
||||
}
|
||||
|
||||
-- Setup door positions
|
||||
self.LeftDoorPositions = {}
|
||||
self.RightDoorPositions = {}
|
||||
for i=0,3 do
|
||||
table.insert(self.LeftDoorPositions,Vector(353.0 - 35*0.5 - 231*i,65,-1.8))
|
||||
table.insert(self.RightDoorPositions,Vector(353.0 - 35*0.5 - 231*i,-65,-1.8))
|
||||
end
|
||||
|
||||
-- KV wrench mode
|
||||
self:OnButtonPress("KVWrenchNone")
|
||||
|
||||
@@ -208,60 +231,70 @@ function ENT:Initialize()
|
||||
end
|
||||
|
||||
function ENT:TrainSpawnerUpdate()
|
||||
self.Pneumatic.VDLoud = math.random()<0.06 and 0.9+math.random()*0.2
|
||||
if self.Pneumatic.VDLoud then self.Pneumatic.VDLoudID = math.random(1,5) end
|
||||
self.Pneumatic.VDOLLoud = math.random()<0.25 and 0.9+math.random()*0.2
|
||||
self.Pneumatic.VDORLoud = math.random()<0.25 and 0.9+math.random()*0.2
|
||||
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 redlights = self.Panel.RedLights>0
|
||||
self:SetPackedBool("RedLight",redlights)
|
||||
self:SetLightPower(5,redlights)
|
||||
self:SetLightPower(6,redlights)
|
||||
|
||||
local lightsActive2 = math.min(1,Panel.MainLights2)
|
||||
local lightsActive1 = math.min(1,Panel.MainLights1)^2
|
||||
self:SetPackedBool("Lamps_emer1",Panel.EmergencyLights1 > 0 and lightsActive1 == 0)
|
||||
self:SetPackedBool("Lamps_cab",Panel.EmergencyLights1 > 0)
|
||||
self:SetPackedBool("Lamps_emer2",Panel.EmergencyLights2 > 0)
|
||||
local lightsActive2 = math.min(1,self.Panel.MainLights2)^2
|
||||
local lightsActive1 = math.min(1,self.Panel.MainLights1)^2
|
||||
local emerActive1 = self.Panel.EmergencyLights1
|
||||
local emerActive2 = self.Panel.EmergencyLights2
|
||||
self:SetPackedBool("Lamps_emer1",emerActive1 > 0 and lightsActive1 == 0)
|
||||
self:SetPackedBool("Lamps_cab",emerActive1 > 0)
|
||||
--self:SetLightPower(9, false)
|
||||
self:SetLightPower(23, emerActive1 > 0)
|
||||
self:SetPackedBool("Lamps_emer2",emerActive2 > 0)
|
||||
self:SetPackedBool("Lamps_half1",lightsActive1 > 0)
|
||||
if lightsActive1 == 0 then
|
||||
self:SetLightPower(9,emerActive1 > 0,emerActive1*0.3+emerActive2*0.7)
|
||||
self:SetLightPower(10,emerActive2 > 0)
|
||||
self:SetLightPower(11, false)
|
||||
self:SetLightPower(12, false)
|
||||
self:SetLightPower(13, false)
|
||||
else
|
||||
self:SetLightPower(9,false)
|
||||
self:SetLightPower(10,false)
|
||||
self:SetLightPower(11, lightsActive1 > 0, lightsActive1*0.1+lightsActive2*0.9)
|
||||
self:SetLightPower(12, lightsActive1 > 0, lightsActive1*0.4+lightsActive2*0.6)
|
||||
self:SetLightPower(13, lightsActive1 > 0, lightsActive1*0.9+lightsActive2*0.1)
|
||||
end
|
||||
self:SetPackedBool("Lamps_half2",lightsActive2 > 0)
|
||||
self:SetPackedRatio("LampsStrength",lightsActive1)--math.Round((self.Electric.I24-150)/1000.0,1.5))
|
||||
|
||||
-- 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.Pneumatic.LeftDoorState[1] > 0.5) or
|
||||
(self.Pneumatic.LeftDoorState[2] > 0.5) or
|
||||
(self.Pneumatic.LeftDoorState[3] > 0.5) or
|
||||
(self.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)
|
||||
(self.Pneumatic.RightDoorState[1] > 0.5) or
|
||||
(self.Pneumatic.RightDoorState[2] > 0.5) or
|
||||
(self.Pneumatic.RightDoorState[3] > 0.5) or
|
||||
(self.Pneumatic.RightDoorState[4] > 0.5)
|
||||
|
||||
-- Red RP
|
||||
local TW18 = 0
|
||||
if Panel.RRP > 0 then
|
||||
if self.Panel.RRP > 0 then
|
||||
local wags = #self.WagonList
|
||||
for _,v in ipairs(self.WagonList) do
|
||||
TW18 = TW18+(v.Panel.TW18 or 0)/wags
|
||||
end
|
||||
end
|
||||
self:SetPackedRatio("RRP",math.Clamp(TW18^0.7,0,1))
|
||||
self:SetPackedBool("GRP",Panel.GRP > 0)
|
||||
self:SetPackedBool("SD",Panel.SD > 0)
|
||||
self:SetPackedBool("PP1",Panel.PP1 > 0)
|
||||
self:SetPackedBool("PP6",Panel.PP6 > 0)
|
||||
self:SetPackedBool("SDW",Panel.SDW > 0)
|
||||
|
||||
|
||||
|
||||
self:SetPackedBool("GRP",self.Panel.GRP > 0)
|
||||
self:SetPackedBool("SD",self.Panel.SD > 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
|
||||
@@ -269,10 +302,10 @@ function ENT:Think()
|
||||
self:SetPackedRatio("ManualBrake",self.TrueBrakeAngle)
|
||||
|
||||
self:SetPackedRatio("LampsCount",math.Clamp(1-self.Electric.Cosume,0.3,1))
|
||||
self:SetPackedBool("VPR",Panel.VPR > 0)
|
||||
self:SetPackedBool("Compressor",Pneumatic.Compressor == 1.0)
|
||||
self:SetPackedBool("VPR",self.Panel.VPR > 0)
|
||||
self:SetPackedBool("Compressor",self.Pneumatic.Compressor == 1.0)
|
||||
self:SetPackedBool("RK",(self.RheostatController.Velocity ~= 0.0))
|
||||
self:SetPackedBool("Ring",Panel.Ring > 0.5)
|
||||
self:SetPackedBool("Ring",self.Panel.Ring > 0.5)
|
||||
|
||||
self:SetPackedBool("RearDoor",self.RearDoor)
|
||||
self:SetPackedBool("FrontDoor",self.FrontDoor)
|
||||
@@ -281,20 +314,20 @@ function ENT:Think()
|
||||
|
||||
self:SetPackedBool("RRIOn",self.RRI_VV.Power>0)
|
||||
self:SetPackedRatio("RRIRewind",self.RRIRewind.Value/2)
|
||||
self:SetPackedBool("AnnPlay",Panel.AnnouncerPlaying > 0)
|
||||
self:SetPackedBool("AnnPlay",self.Panel.AnnouncerPlaying > 0)
|
||||
--KRR
|
||||
--self:SetPackedBool("KRR",self.KRR.Value > 0.5)
|
||||
--print(self.LK1.Value,self.LK2.Value,self.LK3.Value,self.LK4.Value,self.RheostatController.Position,self.PositionSwitch.Position,self.KSH1.Value,self.KSH2.Value)
|
||||
--print(self.PositionSwitch.SelectedPosition,self.RheostatController.SelectedPosition)--self.Engines.E13/2,self.Engines.RotationRate)
|
||||
-- Feed packed floats
|
||||
self:SetNW2Int("WrenchMode",self.KVWrenchMode)
|
||||
self:SetPackedRatio("CranePosition", 1-Pneumatic.DriverValvePosition/7)
|
||||
self:SetPackedRatio("CranePosition", 1-self.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", math.min(2.7,Pneumatic.BrakeCylinderPressure)/6.0)
|
||||
self:SetPackedRatio("BLPressure", self.Pneumatic.ReservoirPressure/16.0)
|
||||
self:SetPackedRatio("TLPressure", self.Pneumatic.TrainLinePressure/16.0)
|
||||
self:SetPackedRatio("BCPressure", math.min(2.7,self.Pneumatic.BrakeCylinderPressure)/6.0)
|
||||
self:SetPackedRatio("EnginesVoltage", self.Engines.E24/2000.0)
|
||||
self:SetPackedRatio("EnginesCurrent", 0.5 + 0.5*(self.Electric.I24/500.0))
|
||||
self:SetPackedRatio("BatteryVoltage",self.Panel["V1"]*self.Battery.Voltage/82.0)
|
||||
@@ -327,12 +360,12 @@ function ENT:Think()
|
||||
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.BrakeCylinderPressure = self.Pneumatic.BrakeCylinderPressure*add
|
||||
self.FrontBogey.BrakeCylinderPressure_dPdT = -self.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
|
||||
self.RearBogey.BrakeCylinderPressure = self.Pneumatic.BrakeCylinderPressure*add
|
||||
self.RearBogey.BrakeCylinderPressure_dPdT = -self.Pneumatic.BrakeCylinderPressure_dPdT
|
||||
end
|
||||
|
||||
self:GenerateJerks()
|
||||
@@ -402,19 +435,18 @@ function ENT:OnButtonPress(button,ply)
|
||||
end
|
||||
end
|
||||
|
||||
if button == "KVWrenchKV" or button == "KVWrenchKV9" then
|
||||
if button == "KVWrenchKV" 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)
|
||||
self.KVWrenchMode = 1
|
||||
end
|
||||
end
|
||||
if button == "KVWrenchNone" then
|
||||
if self.KVWrenchMode == 0 then
|
||||
self:PlayOnce("rcu_in","cabin",0.7)
|
||||
self.KVWrenchMode = 3
|
||||
self.DriversWrenchMissing = false
|
||||
elseif self.KVWrenchMode ~= 0 and self.KV.ReverserPosition == 0 then
|
||||
if self.KVWrenchMode == 3 then
|
||||
self:PlayOnce("rcu_out","cabin",0.7)
|
||||
@@ -422,6 +454,7 @@ function ENT:OnButtonPress(button,ply)
|
||||
self:PlayOnce("revers_out","cabin",0.7)
|
||||
end
|
||||
self.KVWrenchMode = 0
|
||||
self.DriversWrenchMissing = true
|
||||
self.KV:TriggerInput("Enabled",0)
|
||||
end
|
||||
end
|
||||
@@ -496,3 +529,16 @@ function ENT:OnCouple(train,isfront)
|
||||
end
|
||||
self.BaseClass.OnCouple(self,train,isfront)
|
||||
end
|
||||
|
||||
function ENT:TriggerTurbostroiInput(sys,name,val)
|
||||
self.BaseClass.TriggerTurbostroiInput(self,sys,name,val)
|
||||
if sys == "Panel" then
|
||||
if name == "Headlights1" or name == "Headlights2" then
|
||||
self:SetPackedBool("Headlights1",self.Panel["Headlights1"] > 0)
|
||||
self:SetPackedBool("Headlights2",self.Panel["Headlights2"] > 0)
|
||||
self:SetLightPower(30,self.Panel["Headlights1"] > 0.5)
|
||||
self:SetLightPower(31,self.Panel["Headlights1"] > 0.5)
|
||||
self:SetLightPower(32,self.Panel["Headlights2"] > 0.5)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user