Skip to content

Commit 0d10066

Browse files
committed
Update Version 0.9.1.4
Changelog Version 0.9.1.4: - added Russian translation to pallet - fixed problem with the mod "Repair and paint settings (Configure Maintenance)" where the vehicle got FS22-normal-damage from working on a field -> too many RDS-damages - fixed problem where implements didn't get any FS22-normal-damage from working on a field - fixed problem where the engine sound disappeared when starting the engine with over 8 damages -> repairing -> opening an item in the shop - fixed multiplayer sync problem - fixed dedicated server problem where the FS22-normal-damage was not changed with a new damage / repair - fixed mutliplayer problem with console command "rdsRemoveDamages" - added mod version to debug - fixed problem where the vehicle died immediately after receiving 9 damages - created a new shop icon for the pallet -fixed problem where the pallet moved when a helper drove close to it
1 parent 460bf48 commit 0d10066

File tree

6 files changed

+127
-94
lines changed

6 files changed

+127
-94
lines changed

RealisticDamageSystem.lua

+62-34
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ RealisticDamageSystem.TimeUntilInspectionCommand = 0; --set the time until the n
3636
RealisticDamageSystem.UsersHadTutorialDialog = {} --users who had the chance to start the tutorial
3737
RealisticDamageSystem.MaintenancePallets = {}; --create table where every maintenance pallet is stored
3838

39+
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
40+
--load moddesc version
41+
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
42+
local modDesc = loadXMLFile("modDesc", g_currentModDirectory .. "modDesc.xml")
43+
RealisticDamageSystem.modVersion = getXMLString(modDesc, "modDesc.version")
44+
3945
function RealisticDamageSystem.prerequisitesPresent(specializations)
4046
return true;
4147
end;
@@ -137,6 +143,7 @@ function RealisticDamageSystem:onLoad(savegame)
137143

138144
spec.dirtyFlag = self:getNextDirtyFlag() --multiplayer sync
139145
spec.MultiplayerCosts = 0;
146+
spec.MultiplayerAddDamage = 0;
140147

141148
-- maintenance menu
142149

@@ -385,6 +392,7 @@ function RealisticDamageSystem:onReadUpdateStream(streamId, timestamp, connectio
385392
spec.NextKnownDamageOperatingHour = streamReadFloat32(streamId)
386393
spec.NextUnknownDamageOperatingHour = streamReadFloat32(streamId)
387394
spec.DamagesMultiplier = streamReadFloat32(streamId)
395+
spec.MultiplayerAddDamage = streamReadFloat32(streamId)
388396

389397
spec.FirstLoadNumbersSet = streamReadBool(streamId)
390398
spec.MaintenanceActive = streamReadBool(streamId)
@@ -423,6 +431,7 @@ function RealisticDamageSystem:onWriteUpdateStream(streamId, connection, dirtyMa
423431
streamWriteFloat32(streamId, spec.NextKnownDamageOperatingHour)
424432
streamWriteFloat32(streamId, spec.NextUnknownDamageOperatingHour)
425433
streamWriteFloat32(streamId, spec.DamagesMultiplier)
434+
streamWriteFloat32(streamId, spec.MultiplayerAddDamage)
426435

427436
streamWriteBool(streamId, spec.FirstLoadNumbersSet)
428437
streamWriteBool(streamId, spec.MaintenanceActive)
@@ -434,6 +443,7 @@ function RealisticDamageSystem:onWriteUpdateStream(streamId, connection, dirtyMa
434443
streamWriteString(streamId, RealisticDamageSystem:MPTableToString(RealisticDamageSystem.UsersHadTutorialDialog))
435444

436445
spec.MultiplayerCosts = 0
446+
spec.MultiplayerAddDamage = 0
437447
end
438448
else
439449
streamWriteBool(streamId, false)
@@ -494,12 +504,13 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
494504
spec.NextKnownDamageOperatingHour = self:getFormattedOperatingTime() + RealisticDamageSystem:RoundValue((math.random (45, 75) / 10) / RealisticDamageSystem.DamagesMultiplier, 1); --next operating hour when a known damage occurs --float --need /10 to get a decimal number
495505
spec.NextUnknownDamageOperatingHour = self:getFormattedOperatingTime() + RealisticDamageSystem:RoundValue((math.random (105, 135) / 10) / RealisticDamageSystem.DamagesMultiplier, 1); --next operating hour when an unknown damage occurs --float --need /10 to get a decimal number
496506

497-
self:setDamageAmount(0, true) -- reset damage to set it later in the script to the proper amount
507+
spec.MultiplayerAddDamage = -1 -- reset damage to set it later in the script to the proper amount
498508

499509
spec.FirstLoadNumbersSet = true
500510

501511
changeFlag = true --multiplayer sync
502512
end;
513+
503514
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
504515
--ask player if he wants to start the tutorial
505516
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -607,23 +618,6 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
607618
else
608619
if spec.LoadTooHigh ~= true then
609620
self.spec_RealisticDamageSystemEngineDied.EngineDied = false --set EngineDied to false when vehicle is started again
610-
611-
if self:getIsMotorStarted() then
612-
--giants bug:
613-
--vehicle has been started with the multiple ignition sound effect + any item in the shop has been selected and "opened" -> leads to the motor sound being stopped
614-
--everything else works fine, but the motor and gearbox sound is stopped (every other sound is still active as well)
615-
local MotorSounds = self.spec_motorized.motorSamples
616-
local gearboxSounds = self.spec_motorized.gearboxSamples
617-
if not g_soundManager:getIsSamplePlaying(MotorSounds[1]) then
618-
g_soundManager:playSamples(MotorSounds)
619-
end
620-
if not g_soundManager:getIsSamplePlaying(gearboxSounds[1]) then
621-
g_soundManager:playSamples(gearboxSounds)
622-
end
623-
if not g_soundManager:getIsSamplePlaying(self.spec_motorized.samples.retarder) then
624-
g_soundManager:playSample(self.spec_motorized.samples.retarder)
625-
end
626-
end
627621
end
628622
end;
629623

@@ -659,6 +653,24 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
659653
spec.forDBL_EngineLight = true
660654
else
661655
spec.forDBL_EngineLight = false
656+
spec.DontStopMotor = true --set to true when damages < 9 to prevent the vehicle from dying immediately after receiving 9 damages
657+
end
658+
659+
if self:getIsMotorStarted() then
660+
--giants bug:
661+
--vehicle has been started with the multiple ignition sound effect + any item in the shop has been selected and "opened" -> leads to the motor sound being stopped
662+
--everything else works fine, but the motor and gearbox sound is stopped (every other sound is still active as well)
663+
local MotorSounds = self.spec_motorized.motorSamples
664+
local gearboxSounds = self.spec_motorized.gearboxSamples
665+
if not g_soundManager:getIsSamplePlaying(MotorSounds[1]) then
666+
g_soundManager:playSamples(MotorSounds)
667+
end
668+
if not g_soundManager:getIsSamplePlaying(gearboxSounds[1]) then
669+
g_soundManager:playSamples(gearboxSounds)
670+
end
671+
if not g_soundManager:getIsSamplePlaying(self.spec_motorized.samples.retarder) then
672+
g_soundManager:playSample(self.spec_motorized.samples.retarder)
673+
end
662674
end
663675

664676
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -745,19 +757,18 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
745757
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
746758
if not g_currentMission.shopMenu.isOpen then
747759
if spec.TotalNumberOfDamages ~= spec.DamagesThatAddedWear then
748-
self:addDamageAmount((spec.TotalNumberOfDamages - spec.DamagesThatAddedWear) * 0.083, true) --add vehicle damage when new damage was created
760+
spec.MultiplayerAddDamage = (spec.TotalNumberOfDamages - spec.DamagesThatAddedWear) * 0.083 --add vehicle damage when new damage was created
749761
spec.DamagesThatAddedWear = spec.TotalNumberOfDamages
750-
751762
changeFlag = true
752763
end
753764
end
754765

755-
if math.abs(self:getDamageAmount() - spec.TotalNumberOfDamages * 0.083) >= 0.083 then --if vehicle damage does not represent the rds damage amount -> add rds damages
766+
--[[if math.abs(self:getDamageAmount() - (spec.TotalNumberOfDamages * 0.083)) >= 0.083 then --if vehicle damage does not represent the rds damage amount -> add rds damages
756767
spec.forDBL_TotalNumberOfDamagesPlayerKnows = spec.forDBL_TotalNumberOfDamagesPlayerKnows + math.floor((self:getDamageAmount() - spec.TotalNumberOfDamages * 0.083) / 0.083)
757768
spec.DamagesThatAddedWear = spec.DamagesThatAddedWear + math.floor((self:getDamageAmount() - spec.TotalNumberOfDamages * 0.083) / 0.083)
758-
769+
759770
changeFlag = true
760-
end
771+
end--]]
761772

762773
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
763774
--everything that happens when maintenance is started
@@ -776,9 +787,9 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
776787
--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
777788
if RealisticDamageSystem.StopActiveRepairCommand or ((g_currentMission.environment.currentDay > spec.FinishDay) or ((g_currentMission.environment.currentDay == spec.FinishDay and g_currentMission.environment.currentHour > spec.FinishHour)) or (g_currentMission.environment.currentDay == spec.FinishDay and g_currentMission.environment.currentHour >= spec.FinishHour and g_currentMission.environment.currentMinute >= spec.FinishMinute)) then
778789
if spec.DialogSelectedOptionCallback ~= 0 then --need this because DialogSelectedOptionCallback was not saved in the xml in a previous version and therefore could be 0 when reloading the savegame during a maintenance
779-
self:addDamageAmount(- (self:getDamageAmount() / spec.TotalNumberOfDamages) * spec.DialogSelectedOptionCallback, true) --remove so much vehicle damage, so that when you repair all damages at once, there is 0% damage left
790+
spec.MultiplayerAddDamage = - (self:getDamageAmount() / spec.TotalNumberOfDamages) * spec.DialogSelectedOptionCallback --remove so much vehicle damage, so that when you repair all damages at once, there is 0% damage left
780791
else
781-
self:setDamageAmount(0, true) --set vehicle damage to 0
792+
spec.MultiplayerAddDamage = -1 --set vehicle damage to 0
782793
end
783794
spec.MaintenanceActive = false
784795
self.spec_RealisticDamageSystemEngineDied.EngineDied = false
@@ -876,12 +887,12 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
876887
changeFlag = true --multiplayer sync
877888
end
878889
if RealisticDamageSystem.RemoveDamagesCommand ~= 0 then
879-
spec.DamagesThatAddedWear = spec.TotalNumberOfDamages - RealisticDamageSystem.RemoveDamagesCommand
880-
spec.forDBL_TotalNumberOfDamagesPlayerKnows = spec.forDBL_TotalNumberOfDamagesPlayerKnows - RealisticDamageSystem.RemoveDamagesCommand
890+
spec.DamagesThatAddedWear = math.max(spec.TotalNumberOfDamages - RealisticDamageSystem.RemoveDamagesCommand, 0)
891+
spec.forDBL_TotalNumberOfDamagesPlayerKnows = math.max(spec.forDBL_TotalNumberOfDamagesPlayerKnows - RealisticDamageSystem.RemoveDamagesCommand, 0)
881892
if RealisticDamageSystem.RemoveDamagesCommand > 0 then
882-
self:addDamageAmount(- ((self:getDamageAmount() / spec.TotalNumberOfDamages) * RealisticDamageSystem.RemoveDamagesCommand), true)
893+
spec.MultiplayerAddDamage = - ((self:getDamageAmount() / spec.TotalNumberOfDamages) * RealisticDamageSystem.RemoveDamagesCommand)
883894
else
884-
self:addDamageAmount(-RealisticDamageSystem.RemoveDamagesCommand * 0.083, true)
895+
spec.MultiplayerAddDamage = -RealisticDamageSystem.RemoveDamagesCommand * 0.083
885896
end
886897

887898
RealisticDamageSystem.RemoveDamagesCommand = 0
@@ -907,6 +918,7 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
907918
RealisticDamageSystem.StopActiveRepairCommand = false
908919
end
909920
if RealisticDamageSystem.DebugCommand then
921+
print("Mod version: "..tostring(RealisticDamageSystem.modVersion))
910922
print("Vehicle name: "..tostring(self:getName()))
911923
print("Vehicle age: "..tostring(self.age))
912924
print("Vehicle operating time: "..tostring(self:getFormattedOperatingTime()))
@@ -931,6 +943,7 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
931943
DebugUtil.printTableRecursively(RealisticDamageSystem.UsersHadTutorialDialog, "-" , 0, 3)
932944
end
933945
if RealisticDamageSystem.DebugCommandOnce then
946+
print("Mod version: "..tostring(RealisticDamageSystem.modVersion))
934947
print("Vehicle name: "..tostring(self:getName()))
935948
print("Vehicle age: "..tostring(self.age))
936949
print("Vehicle operating time: "..tostring(self:getFormattedOperatingTime()))
@@ -954,7 +967,7 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
954967
print("Players who had tutorial question:")
955968
DebugUtil.printTableRecursively(RealisticDamageSystem.UsersHadTutorialDialog, "-" , 0, 3)
956969

957-
print("") --separate stop print
970+
print("") --separate the print
958971
print("RDS DebugCommandOnce stopped.")
959972
RealisticDamageSystem.DebugCommandOnce = false
960973
end
@@ -1007,9 +1020,19 @@ function RealisticDamageSystem:onUpdate(dt, isActiveForInput, isActiveForInputIg
10071020
changeFlag = true
10081021
end
10091022
end
1023+
if g_server ~= nil and spec.MultiplayerAddDamage ~= nil then
1024+
if spec.MultiplayerAddDamage ~= 0 then
1025+
self:addDamageAmount(spec.MultiplayerAddDamage, true)
1026+
1027+
spec.MultiplayerAddDamage = 0
1028+
1029+
changeFlag = true
1030+
end
1031+
end
10101032
if changeFlag then
10111033
self:raiseDirtyFlags(spec.dirtyFlag)
10121034

1035+
10131036
if g_server ~= nil then
10141037
g_server:broadcastEvent(SyncClientServerEvent.new(self, spec.NextInspectionAge, spec.DamagesThatAddedWear, spec.FinishDay, spec.FinishHour, spec.FinishMinute, spec.DialogSelectedOptionCallback, spec.NextKnownDamageAge, spec.NextUnknownDamageAge, spec.forDBL_TotalNumberOfDamagesPlayerKnows, spec.TotalNumberOfDamagesPlayerDoesntKnow, spec.NextKnownDamageOperatingHour, spec.NextUnknownDamageOperatingHour, spec.DamagesMultiplier, spec.FirstLoadNumbersSet, spec.MaintenanceActive, spec.InspectionActive, spec.CVTRepairActive, self.spec_RealisticDamageSystemEngineDied.EngineDied, RealisticDamageSystem:LengthTableToString(spec.LengthForDamages), RealisticDamageSystem:MPTableToString(RealisticDamageSystem.UsersHadTutorialDialog)), nil, nil, self)
10151038
else
@@ -1478,15 +1501,20 @@ function RealisticDamageSystem:run()
14781501
end
14791502
--overwrite the FS damage system to stop the damage amount and control it over my script
14801503
function RealisticDamageSystem.updateDamageAmount(wearable, superFunc, dt)
1481-
return 0
1504+
if wearable.spec_RealisticDamageSystem ~= nil then --if damage is controlled by RDS -> no FS-damage
1505+
return 0
1506+
else --if it is an implement -> FS-damage
1507+
return superFunc(wearable, dt)
1508+
end
14821509
end
1510+
--overwrite configure maintenance damage system
14831511
if FS22_Configure_Maintenance ~= nil and FS22_Configure_Maintenance.ReduceMaintenanceSettings ~= nil then
14841512
FS22_Configure_Maintenance.ChangeMaintenanceSettingsEvent.run = Utils.appendedFunction(FS22_Configure_Maintenance.ChangeMaintenanceSettingsEvent.run, RealisticDamageSystem.run);
14851513
FS22_Configure_Maintenance.ReduceMaintenance.updateDamageAmount = Utils.overwrittenFunction(FS22_Configure_Maintenance.ReduceMaintenance.updateDamageAmount, RealisticDamageSystem.updateDamageAmount);
1486-
else
1487-
--overwrite the FS damage system to stop the damage amount and control it over my script
1488-
Wearable.updateDamageAmount = Utils.overwrittenFunction(Wearable.updateDamageAmount, RealisticDamageSystem.updateDamageAmount)
14891514
end
1515+
--overwrite the FS damage system to stop the damage amount and control it over my script
1516+
Wearable.updateDamageAmount = Utils.overwrittenFunction(Wearable.updateDamageAmount, RealisticDamageSystem.updateDamageAmount)
1517+
14901518
if RealisticDamageSystem.DamagesMultiplier == nil then
14911519
RealisticDamageSystem.DamagesMultiplier = 1
14921520
end

0 commit comments

Comments
 (0)