Skip to content
Open

#590 #593

Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
422 changes: 400 additions & 22 deletions lua/entities/gmod_subway_81-714_lvz/cl_init.lua

Large diffs are not rendered by default.

62 changes: 58 additions & 4 deletions lua/entities/gmod_subway_81-714_lvz/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ENT.BogeyDistance = 650 -- Needed for gm trainspawner
ENT.SyncTable = {
"A53","A56","A54","A24","A39","A23","A14","A13","A31","A32","A16","A12","A49","A15","A27","A50","A8","A52","A19","A10","A22","A30","A1","A2","A3","A4","A5","A6","A72","A38","A20","A25","A37","A55","A45","A66","A51","A65","A28",
"A70","A81","A80","A18",
"VB","GV",
"DriverValveBLDisconnect","DriverValveTLDisconnect","ParkingBrake",
"VB","GV","IDLK1","IDLK2","IDLK3","IDLK4","IDLK5","IDLK6","IDLK7","IDLK8",
"DriverValveBLDisconnect","DriverValveTLDisconnect","ParkingBrake","DVRDisconnect","DoorReleaseLeft","DoorReleaseRight",
"A84","BPSNon","ConverterProtection","L_1","Start","VozvratRP","EmergencyBrakeValve"
}

Expand Down Expand Up @@ -145,6 +145,22 @@ function ENT:Initialize()
self:SetNW2Int("BPSNType",self.BPSNType)
self.OldTexture = 0

self.OldPedestrianCount = 0

self.d_slow_speeds = {
{0.4, 0.8},
--{0.3, 0.4},
--{0.2, 0.3},
--{0.3, 0.4},
--{0.2, 0.3},
}
self.d_fast_speeds = {
{1.2, 1.8},
--{1.7, 1.8},
--{1.8, 1.9},
--{1.7, 1.8},
--{2.1, 2.2},
}
self.Lamps = {
broken = {},
}
Expand Down Expand Up @@ -226,6 +242,22 @@ end
function ENT:TrainSpawnerUpdate()
local typ = self:GetNW2Int("Type")
local num = self.WagonNumber

local offs = math.random(1,3)
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("KM013Over",math.random()>0.92)
self.Pneumatic:TriggerInput("VZ1Offset",0.8)
self.Pneumatic:TriggerInput("VZ2Offset",2.4)
self.CompressorEfficiency = math.random()*0.05 + 0.02
self.AirConsumeRatio = math.random()*0.04 + 0.06
self.AirLeakRatio = math.random()*0.002 + 0.001
self.DVRLag = math.random()*0.5
self.DVRHiss = math.random(2,5)
self.d_speeds = nil
self.DoorSpeedsDone = false
self.StuckSet = nil

math.randomseed(num+817171)
local kvr=false
local passtex = "Def_717SPBWhite"
Expand Down Expand Up @@ -355,7 +387,29 @@ function ENT:Think()
(Pneumatic.RightDoorState[3] > 0.5) or
(Pneumatic.RightDoorState[4] > 0.5)

--self:SetPackedRatio("Crane", Pneumatic.RealDriverValvePosition)
if self.Speed > 1 and not self.LeftDoorsOpen and not self.RightDoorsOpen and not self.PedChecked then
self.OldPedestrianCount = self:GetNW2Float("PassengerCount")
self.PedChecked = true
self.left_side = nil
self.StuckSet = false
end
if not self.StuckSet then
local passenger_count = self:GetNW2Float("PassengerCount")
if self.Speed < 1 and math.abs(self.OldPedestrianCount - passenger_count) >= 1 and self.left_side == nil then
self.OldPedestrianCount = self:GetNW2Float("PassengerCount")
self.left_side = self.Pneumatic.DoorLeft or false
self.PedChecked = false
end
if self.left_side ~= nil then
if not (self.Pneumatic.DoorLeft or self.Pneumatic.DoorRight) then
local luava = math.random()
self["CanStuckPassenger"..(self.left_side and "Left" or "Right")] = (1-passenger_count/200) < luava and luava < 1 and 1--0.912 < luava and luava < 0.987
self.StuckSet = true
if self.CanStuckPassengerLeft or self.CanStuckPassengerRight then print(self,"passenger to be caught! :D") end
end
end
end
--self:SetPackedRatio("Crane", Pneumatic.RealDriverValvePosition)
--self:SetPackedRatio("Controller", (self.KV.ControllerPosition+3)/7)
if Pneumatic.ValveType == 1 then
self:SetPackedRatio("BLPressure", Pneumatic.ReservoirPressure/16.0)
Expand Down Expand Up @@ -448,7 +502,7 @@ function ENT:OnButtonPress(button,ply)
if self.CouchCap and self.Pneumatic.DriverValvePosition>2 then return end
self.CouchCap = not self.CouchCap
end
if not self.CouchCap and (not button:find("VB") and not button:find("GV") and not button:find("Isolation") and not button:find("Parking") and not button:find("Air")) then return true end
--if not self.CouchCap and (not button:find("VB") and not button:find("GV") and not button:find("Isolation") and not button:find("Parking") and not button:find("Air")) then return true end

if button == "DriverValveDisconnect" then
if self.DriverValveBLDisconnect.Value == 0 or self.DriverValveTLDisconnect.Value == 0 then
Expand Down
12 changes: 11 additions & 1 deletion lua/entities/gmod_subway_81-714_lvz/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ function ENT:InitializeSounds()
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["releasedl"] = {loop=true,"subway_trains/717/door_cyl/vdo_on.mp3"}
self.SoundPositions["releasedl"] = {150,20,Vector(282,62,12.5),1.5}
self.SoundNames["releasedr"] = {loop=true,"subway_trains/717/door_cyl/vdo2_on.mp3"}
self.SoundPositions["releasedr"] = {150,20,Vector(281,-62,12.8),1.5}

self.SoundNames["dcyl_op_exh"] = "subway_trains/common/pneumatic/parking_brake_stop2.mp3"
self.SoundNames["dcyl_cl_exh"] = self.SoundNames["dcyl_op_exh"]
self.SoundPositions["dcyl_op_exh"] = {480,1e9,Vector(-420,45,-30),0.4}
self.SoundPositions["dcyl_cl_exh"] = {480,1e9,Vector(-420,45,-30),1.2}

self.SoundNames["parking_brake"] = {loop=true,"subway_trains/common/pneumatic/parking_brake.wav"}
self.SoundNames["parking_brake_en"] = "subway_trains/common/pneumatic/parking_brake_stop.mp3"
self.SoundNames["parking_brake_rel"] = "subway_trains/common/pneumatic/parking_brake_stop2.mp3"
Expand Down Expand Up @@ -343,7 +353,7 @@ function ENT:InitializeSystems()
-- Панель управления 81-710
self:LoadSystem("Panel","81_714_Panel")
-- Пневмосистема 81-710
self:LoadSystem("Pneumatic","81_717_Pneumatic",{br013_1 = true})
self:LoadSystem("Pneumatic","81_714_NewPneumatic",{br013_1 = true})
-- Everything else
self:LoadSystem("Battery")
self:LoadSystem("PowerSupply","BPSN")
Expand Down
Loading