1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

KM013 coeffs correction and km013 pecular properties randomization

This commit is contained in:
Moon Horse
2024-12-22 22:41:44 +03:00
parent 4e58096885
commit 677f007e73
6 changed files with 22 additions and 13 deletions

View File

@@ -246,6 +246,7 @@ function ENT:TrainSpawnerUpdate()
local offs = math.random(1,3) local offs = math.random(1,3)
if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end
self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1)) self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1))
self.Pneumatic:TriggerInput("KM013Over",math.random()>0.92)
self.Pneumatic:TriggerInput("VZ1Offset",0.8) self.Pneumatic:TriggerInput("VZ1Offset",0.8)
self.Pneumatic:TriggerInput("VZ2Offset",2.4) self.Pneumatic:TriggerInput("VZ2Offset",2.4)
self.CompressorEfficiency = math.random()*0.05 + 0.02 self.CompressorEfficiency = math.random()*0.05 + 0.02

View File

@@ -250,6 +250,7 @@ function ENT:TrainSpawnerUpdate()
local offs = math.random(1,3) local offs = math.random(1,3)
if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end
self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1)) self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1))
self.Pneumatic:TriggerInput("KM013Over",math.random()>0.92)
self.Pneumatic:TriggerInput("VZ1Offset",0.8) self.Pneumatic:TriggerInput("VZ1Offset",0.8)
self.Pneumatic:TriggerInput("VZ2Offset",2.4) self.Pneumatic:TriggerInput("VZ2Offset",2.4)
self.CompressorEfficiency = math.random()*0.05 + 0.02 self.CompressorEfficiency = math.random()*0.05 + 0.02

View File

@@ -366,6 +366,7 @@ function ENT:TrainSpawnerUpdate()
local offs = math.random(1,3) local offs = math.random(1,3)
if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end
self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1)) self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1))
self.Pneumatic:TriggerInput("KM013Over",math.random()>0.92)
self.Pneumatic:TriggerInput("VZ1Offset",0.9) self.Pneumatic:TriggerInput("VZ1Offset",0.9)
self.Pneumatic:TriggerInput("VZ2Offset",2.5) self.Pneumatic:TriggerInput("VZ2Offset",2.5)
self.CompressorEfficiency = math.random()*0.05 + 0.02 self.CompressorEfficiency = math.random()*0.05 + 0.02

View File

@@ -398,6 +398,7 @@ function ENT:TrainSpawnerUpdate()
local offs = math.random(1,3) local offs = math.random(1,3)
if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end if self:GetNW2Int("RetainerLoad",1) == 5 then self:SetNW2Int("RetainerLoad",math.random(1,4)) end
self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1)) self.Pneumatic:TriggerInput("KM013offset",5.0 + 0.1*(offs-1))
self.Pneumatic:TriggerInput("KM013Over",math.random()>0.92)
self.Pneumatic:TriggerInput("VZ1Offset",0.9) self.Pneumatic:TriggerInput("VZ1Offset",0.9)
self.Pneumatic:TriggerInput("VZ2Offset",2.5) self.Pneumatic:TriggerInput("VZ2Offset",2.5)
self.CompressorEfficiency = math.random()*0.05 + 0.02 self.CompressorEfficiency = math.random()*0.05 + 0.02

View File

@@ -57,6 +57,7 @@ function TRAIN_SYSTEM:Initialize(parameters)
self.PN2 = 0 self.PN2 = 0
self.cranPres = 0 self.cranPres = 0
self.KM013offset = 5.2 self.KM013offset = 5.2
self.km013_overcharge = false
--DKPT --DKPT
self.Train:LoadSystem("DKPT","Relay","R-52B") -- self.Train:LoadSystem("DKPT","Relay","R-52B") --
@@ -201,6 +202,8 @@ function TRAIN_SYSTEM:TriggerInput(name,value)
self.ValveType = math.floor(value) self.ValveType = math.floor(value)
elseif name == "KM013offset" then elseif name == "KM013offset" then
self.KM013offset = value self.KM013offset = value
elseif name == "KM013Over" then
self.km013_overcharge = value
elseif name:match("VZ%dOffset") then elseif name:match("VZ%dOffset") then
local idx = name:match("VZ(%d)Offset") local idx = name:match("VZ(%d)Offset")
self["GN"..idx.."Offset"] = math.random(2,10)*0.02 + value self["GN"..idx.."Offset"] = math.random(2,10)*0.02 + value
@@ -510,7 +513,7 @@ function TRAIN_SYSTEM:Think(dT)
if self.Leak or self.BrakeLineOpen then pz_speed = pr_speed*0.25 else pz_speed = pr_speed*1.3 end--*frc end if self.Leak or self.BrakeLineOpen then pz_speed = pr_speed*0.25 else pz_speed = pr_speed*1.3 end--*frc end
self.BLDisconnect = Train.DriverValveBLDisconnect.Value > 0 self.BLDisconnect = Train.DriverValveBLDisconnect.Value > 0
self.TLDisconnect = Train.DriverValveTLDisconnect.Value > 0 self.TLDisconnect = Train.DriverValveTLDisconnect.Value > 0
if self.RealDriverValvePosition > 4 and not self.km13_error2 then self.km13_error2 = 0.7 end if self.km013_overcharge and self.RealDriverValvePosition > 4 and not self.km13_error2 then self.km13_error2 = math.random()*0.3+0.4 end
-- 013: 1 Overcharge -- 013: 1 Overcharge
if (self.RealDriverValvePosition == 1) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > self.TrainLinePressure) then if (self.RealDriverValvePosition == 1) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > self.TrainLinePressure) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(6.4,self.TrainLinePressure), pr_speed, pz_speed, nil, 1.0) self:equalizePressure(dT,"BrakeLinePressure", math.min(6.4,self.TrainLinePressure), pr_speed, pz_speed, nil, 1.0)
@@ -527,22 +530,22 @@ function TRAIN_SYSTEM:Think(dT)
-- 013: 3 4.3 Atm -- 013: 3 4.3 Atm
if (self.RealDriverValvePosition == 3) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.3,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 3) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.3,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 4 4.0 Atm -- 013: 4 4.0 Atm
if (self.RealDriverValvePosition == 4) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.0,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 4) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.0,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 5 3.7 Atm -- 013: 5 3.7 Atm
if (self.RealDriverValvePosition == 5) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.7,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 5) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.7,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 6 3.0 Atm -- 013: 6 3.0 Atm
if (self.RealDriverValvePosition == 6) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.0,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 6) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.0,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 7 0.0 Atm -- 013: 7 0.0 Atm

View File

@@ -60,6 +60,7 @@ function TRAIN_SYSTEM:Initialize(parameters)
self.PN2 = 0 self.PN2 = 0
self.cranPres = 0 self.cranPres = 0
self.KM013offset = 5.2 self.KM013offset = 5.2
self.km013_overcharge = false
--DKPT --DKPT
self.Train:LoadSystem("DKPT","Relay","R-52B") -- self.Train:LoadSystem("DKPT","Relay","R-52B") --
@@ -232,6 +233,8 @@ function TRAIN_SYSTEM:TriggerInput(name,value)
--PrintMessage(HUD_PRINTTALK, Format("Вагон %u; ВЗ-1: %.1f; ВЗ-2: %.1f",self.Train:GetWagonNumber(),self.GN1Offset or 0,self.GN2Offset or 0)) --PrintMessage(HUD_PRINTTALK, Format("Вагон %u; ВЗ-1: %.1f; ВЗ-2: %.1f",self.Train:GetWagonNumber(),self.GN1Offset or 0,self.GN2Offset or 0))
elseif name == "KM013offset" then elseif name == "KM013offset" then
self.KM013offset = value self.KM013offset = value
elseif name == "KM013Over" then
self.km013_overcharge = value
elseif name == "Autostop" then elseif name == "Autostop" then
local HaveUAVA = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoUAVA local HaveUAVA = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoUAVA
if HaveUAVA and self.Train.UAVA.Value == 0 then if HaveUAVA and self.Train.UAVA.Value == 0 then
@@ -537,7 +540,7 @@ function TRAIN_SYSTEM:Think(dT)
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.BrakeLinePressure_dPdT) trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.BrakeLinePressure_dPdT)
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.ReservoirPressure_dPdT)*0.05 trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.ReservoirPressure_dPdT)*0.05
else else
pr_speed = 2.8--1.25*wagc --2 pr_speed = 2.8
local pz_speed local pz_speed
-- wagc | pr_speed -- wagc | pr_speed
------------------ ------------------
@@ -563,12 +566,11 @@ function TRAIN_SYSTEM:Think(dT)
end end
end end
---------------debug---------------------]] ---------------debug---------------------]]
--local frc = 0.4--0.35 --local frc = 0.4--0.35 = 2.1 = 3.64
--if Train.EPK.Value > 0 or self.EmergencyValve or self.BrakeLineOpen then pz_speed = pr_speed*0.75 else pz_speed = pr_speed*1.3 end
if self.Leak or self.BrakeLineOpen then pz_speed = pr_speed*0.75 else pz_speed = pr_speed*1.3 end if self.Leak or self.BrakeLineOpen then pz_speed = pr_speed*0.75 else pz_speed = pr_speed*1.3 end
self.BLDisconnect = self.DisconnectType and Train.DriverValveBLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0 self.BLDisconnect = self.DisconnectType and Train.DriverValveBLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0
self.TLDisconnect = self.DisconnectType and Train.DriverValveTLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0 self.TLDisconnect = self.DisconnectType and Train.DriverValveTLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0
if self.RealDriverValvePosition > 4 and not self.km13_error2 then self.km13_error2 = 0.7 end if self.km013_overcharge and self.RealDriverValvePosition > 4 and not self.km13_error2 then self.km13_error2 = math.random()*0.3+0.4 end
-- 013: 1 Overcharge -- 013: 1 Overcharge
if (self.RealDriverValvePosition == 1) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > self.TrainLinePressure) then if (self.RealDriverValvePosition == 1) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > self.TrainLinePressure) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(6.4,self.TrainLinePressure), pr_speed, pz_speed, nil, 1.0) self:equalizePressure(dT,"BrakeLinePressure", math.min(6.4,self.TrainLinePressure), pr_speed, pz_speed, nil, 1.0)
@@ -585,22 +587,22 @@ function TRAIN_SYSTEM:Think(dT)
-- 013: 3 4.3 Atm -- 013: 3 4.3 Atm
if (self.RealDriverValvePosition == 3) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.3,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 3) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.3,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 4 4.0 Atm -- 013: 4 4.0 Atm
if (self.RealDriverValvePosition == 4) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.0,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 4) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(4.0,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 5 3.7 Atm -- 013: 5 3.7 Atm
if (self.RealDriverValvePosition == 5) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.7,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 5) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.7,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 6 3.0 Atm -- 013: 6 3.0 Atm
if (self.RealDriverValvePosition == 6) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.0,self.TrainToBrakeReducedPressure)) then if (self.RealDriverValvePosition == 6) and self.BLDisconnect and (self.TLDisconnect or self.BrakeLinePressure > math.min(3.0,self.TrainToBrakeReducedPressure)) then
self:equalizePressure(dT,"BrakeLinePressure", math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed,pz_speed, nil, 2.5) self:equalizePressure(dT,"BrakeLinePressure", math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed*1.5,pz_speed, nil, 2.5)
end end
-- 013: 7 0.0 Atm -- 013: 7 0.0 Atm