Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------ADHESNI MODEL---------
- rychlostMS = Call("GetSpeed")
- if SysCall("ScenarioManager:GetCurrentPrecipitationType") < 3 then --nesnezi
- if SysCall("ScenarioManager:GetPrecipitationDensity") > 0.3 then --prsi hodne
- if adhese_casdeste == -1 then
- adhese_casdeste = 0
- end
- if adhese_casdeste <= 370 then
- adhese_casdeste = adhese_casdeste + deltaTime
- end
- adhese_caspodesti = -1
- elseif SysCall("ScenarioManager:GetPrecipitationDensity") ~= 0 then --prsi trochenc
- if adhese_casdeste == -1 then
- adhese_casdeste = 0
- end
- adhese_caspodesti = -1
- else --neprsi vubec
- adhese_casdeste = -1
- if adhese_casdeste ~= -1 then
- adhese_caspodesti = adhese_casdeste*10
- end
- if adhese_caspodesti > 0 then
- adhese_caspodesti = adhese_caspodesti - deltaTime
- else
- adhese_caspodesti = -1
- end
- end
- --defaultne adhese za sucha
- wh01_adhese = ADHESE_SUCHO
- wh02_adhese = ADHESE_SUCHO
- wh03_adhese = ADHESE_SUCHO
- wh04_adhese = ADHESE_SUCHO
- if adhese_casdeste ~= -1 then --pokud prsi
- if adhese_casdeste < ADHESE_VLHKO_CAS_NABEH then --a prsi mene jak ADHESE_VLHKO_CAS_NABEH (70 vterin) - adhese se znizuje az na ADHESE_VLHKO_START (0.5)
- wh01_adhese = ADHESE_SUCHO - (ADHESE_SUCHO-ADHESE_VLHKO_START)*(adhese_casdeste/ADHESE_VLHKO_CAS_NABEH)
- wh02_adhese = ADHESE_SUCHO - (ADHESE_SUCHO-ADHESE_VLHKO_START)*(adhese_casdeste/ADHESE_VLHKO_CAS_NABEH)
- wh03_adhese = ADHESE_SUCHO - (ADHESE_SUCHO-ADHESE_VLHKO_START)*(adhese_casdeste/ADHESE_VLHKO_CAS_NABEH)
- wh04_adhese = ADHESE_SUCHO - (ADHESE_SUCHO-ADHESE_VLHKO_START)*(adhese_casdeste/ADHESE_VLHKO_CAS_NABEH)
- elseif adhese_casdeste < ADHESE_VLHKO_CAS_SNIZENI then --nebo prsi mene jak ADHESE_VLHKO_CAS_SNIZENI (370 vterin) - adhese se zvysuje na ADHESE_VLHKO (0.7)
- wh01_adhese = ADHESE_VLHKO_START - (ADHESE_VLHKO_START-ADHESE_VLHKO)*(adhese_casdeste/(ADHESE_VLHKO_CAS_NABEH+ADHESE_VLHKO_CAS_SNIZENI))
- wh02_adhese = ADHESE_VLHKO_START - (ADHESE_VLHKO_START-ADHESE_VLHKO)*(adhese_casdeste/(ADHESE_VLHKO_CAS_NABEH+ADHESE_VLHKO_CAS_SNIZENI))
- wh03_adhese = ADHESE_VLHKO_START - (ADHESE_VLHKO_START-ADHESE_VLHKO)*(adhese_casdeste/(ADHESE_VLHKO_CAS_NABEH+ADHESE_VLHKO_CAS_SNIZENI))
- wh04_adhese = ADHESE_VLHKO_START - (ADHESE_VLHKO_START-ADHESE_VLHKO)*(adhese_casdeste/(ADHESE_VLHKO_CAS_NABEH+ADHESE_VLHKO_CAS_SNIZENI))
- else --jinak uz je adhese stala ADHESE_VLHKO (0.7)
- wh01_adhese = ADHESE_VLHKO
- wh02_adhese = ADHESE_VLHKO
- wh03_adhese = ADHESE_VLHKO
- wh04_adhese = ADHESE_VLHKO
- end
- elseif adhese_caspodesti ~= -1 then --pokud prselo pred mene jak 10 minutami, adhese se zvysuje od aktualni k ADHESE_SUCHO (0.9)
- if wh01_vychozi_adhese_podesti == -1 then
- wh01_vychozi_adhese_podesti = wh01_adhese
- end
- if wh02_vychozi_adhese_podesti == -1 then
- wh02_vychozi_adhese_podesti = wh02_adhese
- end
- if wh03_vychozi_adhese_podesti == -1 then
- wh03_vychozi_adhese_podesti = wh03_adhese
- end
- if wh04_vychozi_adhese_podesti == -1 then
- wh04_vychozi_adhese_podesti = wh04_adhese
- end
- wh01_adhese = wh01_vychozi_adhese_podesti - (wh01_vychozi_adhese_podesti-ADHESE_SUCHO)*(adhese_caspodesti/ADHESE_VLHKO_PODESTI)
- wh02_adhese = wh02_vychozi_adhese_podesti - (wh02_vychozi_adhese_podesti-ADHESE_SUCHO)*(adhese_caspodesti/ADHESE_VLHKO_PODESTI)
- wh03_adhese = wh03_vychozi_adhese_podesti - (wh03_vychozi_adhese_podesti-ADHESE_SUCHO)*(adhese_caspodesti/ADHESE_VLHKO_PODESTI)
- wh04_adhese = wh04_vychozi_adhese_podesti - (wh04_vychozi_adhese_podesti-ADHESE_SUCHO)*(adhese_caspodesti/ADHESE_VLHKO_PODESTI)
- end
- else --snezi, tak nejsou casy deste
- adhese_casdeste = -1
- adhese_caspodesti = -1
- end
- if adhese_caspodesti == -1 then --pokud uz neprsi vice jak 10 minut vynuluj vychozi pocitadla
- wh01_vychozi_adhese_podesti = -1
- wh02_vychozi_adhese_podesti = -1
- wh03_vychozi_adhese_podesti = -1
- wh04_vychozi_adhese_podesti = -1
- end
- if SysCall("ScenarioManager:GetSeason") == 2 then --pokud je podzim, vsade jsou listy - klouze to 3x tolik
- wh01_adhese = wh01_adhese * ADHESE_KOEF_LISTI
- wh02_adhese = wh02_adhese * ADHESE_KOEF_LISTI
- wh03_adhese = wh03_adhese * ADHESE_KOEF_LISTI
- wh04_adhese = wh04_adhese * ADHESE_KOEF_LISTI
- elseif SysCall("ScenarioManager:GetSeason") == 2 then --pokud je zima, je snih - sankuje to 2x tolik jak obvykle
- wh01_adhese = ADHESE_SNIH
- wh02_adhese = ADHESE_SNIH
- wh03_adhese = ADHESE_SNIH
- wh04_adhese = ADHESE_SNIH
- end
- if Call("GetControlValue","Sander",0) == 1 then --pokud ale piskuju, zvednu adhesi o 20%
- wh01_adhese = wh01_adhese * ADHESE_KOEF_PISEK
- wh02_adhese = wh02_adhese * ADHESE_KOEF_PISEK
- wh03_adhese = wh03_adhese * ADHESE_KOEF_PISEK
- wh04_adhese = wh04_adhese * ADHESE_KOEF_PISEK
- end
- --spetka nahodnosti jeste nikoho nezabila, takze nechame adhesi trosenku hybat - o +/- 1%
- wh01_adhese = wh01_adhese * (math.random(9,11)/100)
- wh02_adhese = wh02_adhese * (math.random(9,11)/100)
- wh03_adhese = wh03_adhese * (math.random(9,11)/100)
- wh04_adhese = wh04_adhese * (math.random(9,11)/100)
- --prvni naprava
- if wh01_PT > 0 then
- if VratAdhesniKN(wh01_adhese, rychlostMS, 4) - VratTCh(wh01_PT, wh01_speed, 4) > 0 then
- wh01_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh01_adhese, rychlostMS, 4) - VratTCh(wh01_PT, wh01_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh01_adhese, VratAdhesniKN(wh01_adhese, rychlostMS, 1)*0.3))
- wh01_skutecnaFt = math.min(VratAdhesniKN(wh01_adhese, rychlostMS, 4), VratTCh(wh01_PT, wh01_speed, 4))
- else
- if VratTCh(wh01_PT, wh01_speed, 4) > VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3 then
- wh01_speed = wh01_speed + (VratTCh(wh01_PT, wh01_speed, 4) - VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3) * deltaTime * 2
- elseif VratTCh(wh01_PT, wh01_speed, 4) < VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3 then
- wh01_speed = wh01_speed - ((VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3) - VratTCh(wh01_PT, wh01_speed, 4)) * deltaTime * 2
- end
- wh01_skutecnaFt = math.min(VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3, VratTCh(wh01_PT, wh01_speed, 4))
- end
- elseif wh01_PT < 0 then
- if VratAdhesniKN(wh01_adhese, rychlostMS, 4) - VratTCh(-wh01_PT, wh01_speed, 4) > 0 then
- wh01_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh01_adhese, rychlostMS, 4) - VratTCh(-wh01_PT, wh01_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh01_adhese, VratAdhesniKN(wh01_adhese, rychlostMS, 1)*0.3))
- wh01_skutecnaFt = math.max(-VratAdhesniKN(wh01_adhese, rychlostMS, 4), VratTCh(wh01_PT, wh01_speed, 4))
- else
- if VratTCh(-wh01_PT, wh01_speed, 4) > VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3 then
- if wh01_speed > 0 then
- wh01_speed = wh01_speed - ((VratTCh(-wh01_PT, wh01_speed, 4) - VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3)) * deltaTime * 2
- else
- wh01_speed = 0
- end
- elseif VratTCh(-wh01_PT, wh01_speed, 4) < VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3 then
- wh01_speed = wh01_speed + ((VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3) - VratTCh(-wh01_PT, wh01_speed, 4)) * deltaTime * 2
- end
- wh01_skutecnaFt = math.max(-VratAdhesniKN(wh01_adhese, rychlostMS, 4)*0.3, VratTCh(wh01_PT, wh01_speed, 4))
- end
- end
- --druha naprava
- if wh02_PT > 0 then
- if VratAdhesniKN(wh02_adhese, rychlostMS, 4) - VratTCh(wh02_PT, wh02_speed, 4) > 0 then
- wh02_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh02_adhese, rychlostMS, 4) - VratTCh(wh02_PT, wh02_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh02_adhese, VratAdhesniKN(wh02_adhese, rychlostMS, 1)*0.3))
- wh02_skutecnaFt = math.min(VratAdhesniKN(wh02_adhese, rychlostMS, 4), VratTCh(wh02_PT, wh02_speed, 4))
- else
- if VratTCh(wh02_PT, wh02_speed, 4) > VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3 then
- wh02_speed = wh02_speed + (VratTCh(wh02_PT, wh02_speed, 4) - VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3) * deltaTime * 2
- elseif VratTCh(wh02_PT, wh02_speed, 4) < VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3 then
- wh02_speed = wh02_speed - ((VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3) - VratTCh(wh02_PT, wh02_speed, 4)) * deltaTime * 2
- end
- wh02_skutecnaFt = math.min(VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3, VratTCh(wh02_PT, wh02_speed, 4))
- end
- elseif wh02_PT < 0 then
- if VratAdhesniKN(wh02_adhese, rychlostMS, 4) - VratTCh(-wh02_PT, wh02_speed, 4) > 0 then
- wh02_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh02_adhese, rychlostMS, 4) - VratTCh(-wh02_PT, wh02_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh02_adhese, VratAdhesniKN(wh02_adhese, rychlostMS, 1)*0.3))
- wh02_skutecnaFt = math.max(-VratAdhesniKN(wh02_adhese, rychlostMS, 4), VratTCh(wh02_PT, wh02_speed, 4))
- else
- if VratTCh(-wh02_PT, wh02_speed, 4) > VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3 then
- if wh02_speed > 0 then
- wh02_speed = wh02_speed - ((VratTCh(-wh02_PT, wh02_speed, 4) - VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3)) * deltaTime * 2
- else
- wh02_speed = 0
- end
- elseif VratTCh(-wh02_PT, wh02_speed, 4) < VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3 then
- wh02_speed = wh02_speed + ((VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3) - VratTCh(-wh02_PT, wh02_speed, 4)) * deltaTime * 2
- end
- wh02_skutecnaFt = math.max(-VratAdhesniKN(wh02_adhese, rychlostMS, 4)*0.3, VratTCh(wh02_PT, wh02_speed, 4))
- end
- end
- --treti naprava
- if wh03_PT > 0 then
- if VratAdhesniKN(wh03_adhese, rychlostMS, 4) - VratTCh(wh03_PT, wh03_speed, 4) > 0 then
- wh03_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh03_adhese, rychlostMS, 4) - VratTCh(wh03_PT, wh03_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh03_adhese, VratAdhesniKN(wh03_adhese, rychlostMS, 1)*0.3))
- wh03_skutecnaFt = math.min(VratAdhesniKN(wh03_adhese, rychlostMS, 4), VratTCh(wh03_PT, wh03_speed, 4))
- else
- if VratTCh(wh03_PT, wh03_speed, 4) > VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3 then
- wh03_speed = wh03_speed + (VratTCh(wh03_PT, wh03_speed, 4) - VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3) * deltaTime * 2
- elseif VratTCh(wh03_PT, wh03_speed, 4) < VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3 then
- wh03_speed = wh03_speed - ((VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3) - VratTCh(wh03_PT, wh03_speed, 4)) * deltaTime * 2
- end
- wh03_skutecnaFt = math.min(VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3, VratTCh(wh03_PT, wh03_speed, 4))
- end
- elseif wh03_PT < 0 then
- if VratAdhesniKN(wh03_adhese, rychlostMS, 4) - VratTCh(-wh03_PT, wh03_speed, 4) > 0 then
- wh03_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh03_adhese, rychlostMS, 4) - VratTCh(-wh03_PT, wh03_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh03_adhese, VratAdhesniKN(wh03_adhese, rychlostMS, 1)*0.3))
- wh03_skutecnaFt = math.max(-VratAdhesniKN(wh03_adhese, rychlostMS, 4), VratTCh(wh03_PT, wh03_speed, 4))
- else
- if VratTCh(-wh03_PT, wh03_speed, 4) > VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3 then
- if wh03_speed > 0 then
- wh03_speed = wh03_speed - ((VratTCh(-wh03_PT, wh03_speed, 4) - VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3)) * deltaTime * 2
- else
- wh03_speed = 0
- end
- elseif VratTCh(-wh03_PT, wh03_speed, 4) < VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3 then
- wh03_speed = wh03_speed + ((VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3) - VratTCh(-wh03_PT, wh03_speed, 4)) * deltaTime * 2
- end
- wh03_skutecnaFt = math.max(-VratAdhesniKN(wh03_adhese, rychlostMS, 4)*0.3, VratTCh(wh03_PT, wh03_speed, 4))
- end
- end
- --ctvrta naprava
- if wh04_PT > 0 then
- if VratAdhesniKN(wh04_adhese, rychlostMS, 4) - VratTCh(wh04_PT, wh04_speed, 4) > 0 then
- wh04_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh04_adhese, rychlostMS, 4) - VratTCh(wh04_PT, wh04_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh04_adhese, VratAdhesniKN(wh04_adhese, rychlostMS, 1)*0.3))
- wh04_skutecnaFt = math.min(VratAdhesniKN(wh04_adhese, rychlostMS, 4), VratTCh(wh04_PT, wh04_speed, 4))
- else
- if VratTCh(wh04_PT, wh04_speed, 4) > VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3 then
- wh04_speed = wh04_speed + (VratTCh(wh04_PT, wh04_speed, 4) - VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3) * deltaTime * 2
- elseif VratTCh(wh04_PT, wh04_speed, 4) < VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3 then
- wh04_speed = wh04_speed - ((VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3) - VratTCh(wh04_PT, wh04_speed, 4)) * deltaTime * 2
- end
- wh04_skutecnaFt = math.min(VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3, VratTCh(wh04_PT, wh04_speed, 4))
- end
- elseif wh04_PT < 0 then
- if VratAdhesniKN(wh04_adhese, rychlostMS, 4) - VratTCh(-wh04_PT, wh04_speed, 4) > 0 then
- wh04_speed = math.min(rychlostMS*(1/(100*(VratAdhesniKN(wh04_adhese, rychlostMS, 4) - VratTCh(-wh04_PT, wh04_speed, 4))^3)+1), VratRychlostProAdhesniKN(wh04_adhese, VratAdhesniKN(wh04_adhese, rychlostMS, 1)*0.3))
- wh04_skutecnaFt = math.max(-VratAdhesniKN(wh04_adhese, rychlostMS, 4), VratTCh(wh04_PT, wh04_speed, 4))
- else
- if VratTCh(-wh04_PT, wh04_speed, 4) > VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3 then
- if wh04_speed > 0 then
- wh04_speed = wh04_speed - ((VratTCh(-wh04_PT, wh04_speed, 4) - VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3)) * deltaTime * 2
- else
- wh04_speed = 0
- end
- elseif VratTCh(-wh04_PT, wh04_speed, 4) < VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3 then
- wh04_speed = wh04_speed + ((VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3) - VratTCh(-wh04_PT, wh04_speed, 4)) * deltaTime * 2
- end
- wh04_skutecnaFt = math.max(-VratAdhesniKN(wh04_adhese, rychlostMS, 4)*0.3, VratTCh(wh04_PT, wh04_speed, 4))
- end
- end
- Call("SetControlValue", "ThrottleAndBrake", 0, wh01_skutecnaFt+wh02_skutecnaFt+wh03_skutecnaFt+wh04_skutecnaFt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement