Código: Selecionar tudo
script_name("Downforce MOD V2")
script_author("plasma")
script_version("2.0")
local imgui = require "imgui"
local m = require "memory"
local mad = require "MoonAdditions"
local ini = require 'inicfg'
------É pra ser compativel com carros adicionados, apenas adicione uma linha a mais da tabela de carros, com o id do seu carro sendo o indice (o numero entre colchetes)-----
---***ATENÇÃO, SE FOR RECARREGAR O SCRIPT IN GAME, CERTIFIQUE-SE DE ESTAR COM O VEICULO TOTALMENTE PARADO OU FORA DE UM VEICULO***----
local airDensity = 1.225 -- kg/m^3 densidade do ar, quanto maior, mais downforce o carro ira ter (ou mais sustentação positiva dependendo do carro), realisticamente o veiculo iria ter mais drag também (resistencia do ar), mas esse script não se mete nessa parte. Alterações nesse valor só terão efeito se deixar a opção logo abaixo em false.
local calculateAirDensity = true --- ative para calcular automaticamente a densidade do ar para uma determinada altura.
local loadSensitivityMultiplier = 1.0 -- deixe em 1.0 para ativar a sensibilidade a carga, 0 para desativar.
local dwMult = 1.0 -- irá multiplicar os efeitos aerodinâmicos, 2.0 para dobra-los, 0 para desativa-los. (ao dobrar, estara dobrando efeitos negativos caso o carro tenha "downforce negativa")
local mode = 3 ---- 1 = aumenta apenas o tractionMultiplier; 2 = aumenta apenas o tractionLoss; 3 = distribui o aumento entre ambos
local improveBrakes = false --- deixe em true caso queira que a desaceleração dos freios aumente. *Esse efeito não é exatamente realista, pois a força dos freios não é afetada pela downforce do veiculo*
local downforce_editor_cheat = "wdit"
local drawInfos = true --- coloque false se não quiser mostrar nenhuma das informações abaixo.
local drawName = true --- coloque false se não quiser o nome do carro.
local xName = 70 --- posição horizontal do nome do carro
local yName = 485 --- posição vertical do nome do carro
local drawArea = true -- coloque false se não quiser o indicador de area efetiva.
local xArea = 70 -- posição horizontal do indicador de area efetiva.
local yArea = 500 -- posição vertical do indicador de area efetiva.
local drawDownforce = true --- coloque false se não quiser o indicador de downforce do carro.
local xDownforce = 70 -- posição horizontal do indicador de downforce.
local yDownforce = 515 -- posição vertical do indicador de downforce.
local drawGrip = true --- coloque false se não quiser o indicador de grip relativo do carro.
local xGrip = 70 -- posição horizontal do indicador de grip relativo.
local yGrip = 530 -- posição vertical do indicador de grip relativo.
local drawTractionMult = false --- coloque true se quiser o indicador do multiplo de tração.
local xTractionM = 70 -- posição horizontal do indicador do multiplo de tração.
local yTractionM = 545 -- posição vertical do indicador de do multiplo de tração.
local drawTractionLoss = false --- coloque true se quiser o indicador do tractionLoss.
local xTractionL = 70 -- posição horizontal do indicador do tractionLoss.
local yTractionL = 560 -- posição vertical do indicador de do tractionLoss.
local bonusPerWing = 0.20 -- area efetiva extra a cada parte do veiculo com um nome que contenha uma das palavras abaixo.
local namesToSearchFor = {"spoiler"} -- nomes das partes do veiculo a serem procuradas, ao instalar um aerofolio em um veiculo no tuning mod, de uma olhada na aba gerenciar os nomes dos nodes, caso não tenha uma dessas palavras no spoiler instalado, basta renomear a peça.
--[[atributos dos veiculos do jogo, deixe o index da tabela sempre com o id do veiculo em questão
name = nome do veiculos, apenas por praticidade
effectiveArea = area efetiva que irá gerar downforce, caso seja negativa irá gerar o contrário, ou seja o veiculo irá perder aderencia em altas velocidades.
effectiveArea = coeficiente de downforce * area frontal do veiculos.
*a downforce também pode ser chamada de sustentação negativa, veiculos mais pesados são menos sensiveis ao aumento ou diminuição de downforce*
loadSensitivity = sensibilidade dos pneus ao aumento de downforce no veiculo, a medida em que o peso nos pneus aumenta, o grip base dele diminui;
saiba mais aqui : https://en.wikipedia.org/wiki/Tire_load_sensitivity
e aqui: http://theracingline.net/2018/race-car-tech/race-tech-explained/tyres-load-sensitivity/
*Não deixe um valor muito alto, é extremamente sensivel, deixe entre 0 e 0.1.
***A sensibilidade a carga dos pneus não é calculada de maneira muito realista, apenas uma aproximação.
**Vale lembrar que esse script apenas multiplica valores da handling do carro, portanto o efeito final irá depender também do arquivo handling.cfg do seu jogo**
]]--
local cars = {}
cars[400] = {name = "LANDSTALKER", effectiveArea = -0.78, loadSensitivity = 0.019}
cars[401] = {name = "BRAVURA", effectiveArea = -0.31, loadSensitivity = 0.022}
cars[402] = {name = "BUFFALO", effectiveArea = 0.10, loadSensitivity = 0.025}
cars[403] = {name = "LINERUNNER", effectiveArea = -0.35, loadSensitivity = 0.012}
cars[404] = {name = "PERENNIAL", effectiveArea = -0.29, loadSensitivity = 0.02}
cars[405] = {name = "SENTINEL", effectiveArea = -0.11, loadSensitivity = 0.015}
cars[406] = {name = "DUMPER", effectiveArea = -1.55, loadSensitivity = 0.008}
cars[407] = {name = "FIRETRUCK", effectiveArea = -0.71, loadSensitivity = 0.012}
cars[408] = {name = "TRASHMASTER", effectiveArea = -0.52, loadSensitivity = 0.009}
cars[409] = {name = "STRETCH", effectiveArea = -0.18, loadSensitivity = 0.017}
cars[410] = {name = "MANANA", effectiveArea = -0.15, loadSensitivity = 0.027}
cars[411] = {name = "INFERNUS", effectiveArea = 0.35, loadSensitivity = 0.021}
cars[412] = {name = "VOODOO", effectiveArea = -0.37, loadSensitivity = 0.024}
cars[413] = {name = "PONY", effectiveArea = -0.592, loadSensitivity = 0.018}
cars[414] = {name = "MULE", effectiveArea = -0.86, loadSensitivity = 0.015}
cars[415] = {name = "CHEETAH", effectiveArea = 0.20, loadSensitivity = 0.019}
cars[416] = {name = "AMBULANCE", effectiveArea = -0.78, loadSensitivity = 0.014}
cars[418] = {name = "MOONBEAM", effectiveArea = -0.65, loadSensitivity = 0.017}
cars[419] = {name = "ESPERANTO", effectiveArea = -0.19, loadSensitivity = 0.022}
cars[420] = {name = "TAXI", effectiveArea = -0.21, loadSensitivity = 0.025}
cars[421] = {name = "WASHINGTON", effectiveArea = -0.37, loadSensitivity = 0.027}
cars[422] = {name = "BOBCAT", effectiveArea = -0.65, loadSensitivity = 0.019}
cars[423] = {name = "MR WHOOPEE", effectiveArea = -0.47, loadSensitivity = 0.022}
cars[424] = {name = "BF INJECTION", effectiveArea = -0.24, loadSensitivity = 0.032}
cars[426] = {name = "PREMIER", effectiveArea = -0.19, loadSensitivity = 0.025}
cars[427] = {name = "ENFORCER", effectiveArea = -0.75, loadSensitivity = 0.014}
cars[428] = {name = "SECURICAR", effectiveArea = -0.77, loadSensitivity = 0.018}
cars[429] = {name = "BANSHEE", effectiveArea = -0.08, loadSensitivity = 0.021}
cars[431] = {name = "BUS", effectiveArea = -0.99, loadSensitivity = 0.011}
cars[432] = {name = "RHINO", effectiveArea = -0.59, loadSensitivity = 0.005}
cars[433] = {name = "BARRACKS", effectiveArea = -0.68, loadSensitivity = 0.011}
cars[434] = {name = "HOTKNIFE", effectiveArea = -0.25, loadSensitivity = 0.023}
cars[436] = {name = "PREVION", effectiveArea = -0.20, loadSensitivity = 0.025}
cars[437] = {name = "COACH", effectiveArea = -1.10, loadSensitivity = 0.015}
cars[438] = {name = "CABBIE", effectiveArea = -0.35, loadSensitivity = 0.026}
cars[439] = {name = "STALLION", effectiveArea = -0.20, loadSensitivity = 0.025}
cars[440] = {name = "RUMPO", effectiveArea = -0.49, loadSensitivity = 0.016}
cars[441] = {name = "RC BANDIT", effectiveArea = 0.09, loadSensitivity = 0.04}
cars[442] = {name = "ROMERO", effectiveArea = -0.39, loadSensitivity = 0.022}
cars[443] = {name = "PACKER", effectiveArea = -0.89, loadSensitivity = 0.011}
cars[444] = {name = "MONSTER", effectiveArea = -0.95, loadSensitivity = 0.012}
cars[445] = {name = "ADMIRAL", effectiveArea = -0.25, loadSensitivity = 0.023}
cars[451] = {name = "TURISMO", effectiveArea = 0.45, loadSensitivity = 0.02}
cars[455] = {name = "FLATBED", effectiveArea = -0.68, loadSensitivity = 0.01}
cars[456] = {name = "YANKEE", effectiveArea = -0.72, loadSensitivity = 0.013}
cars[457] = {name = "CADDY", effectiveArea = -0.15, loadSensitivity = 0.031}
cars[458] = {name = "SOLAIR", effectiveArea = -0.35, loadSensitivity = 0.02}
cars[459] = {name = "TOP FUN", effectiveArea = -0.49, loadSensitivity = 0.019}
cars[466] = {name = "GLENDALE", effectiveArea = -0.35, loadSensitivity = 0.024}
cars[467] = {name = "OCEANIC", effectiveArea = -0.38, loadSensitivity = 0.023}
cars[470] = {name = "PATRIOT", effectiveArea = -0.37, loadSensitivity = 0.013}
cars[471] = {name = "QUAD", effectiveArea = -0.11, loadSensitivity = 0.028}
cars[474] = {name = "HERMES", effectiveArea = -0.37, loadSensitivity = 0.025}
cars[475] = {name = "SABRE", effectiveArea = -0.24, loadSensitivity = 0.024}
cars[477] = {name = "ZR-350", effectiveArea = 0.30, loadSensitivity = 0.021}
cars[478] = {name = "WALTON", effectiveArea = -0.52, loadSensitivity = 0.02}
cars[479] = {name = "REGINA", effectiveArea = -0.37, loadSensitivity = 0.02}
cars[480] = {name = "COMET", effectiveArea = -0.09, loadSensitivity = 0.024}
cars[482] = {name = "BURRITO", effectiveArea = -0.54, loadSensitivity = 0.016}
cars[483] = {name = "CAMPER", effectiveArea = -0.74, loadSensitivity = 0.02}
cars[485] = {name = "BAGGAGE", effectiveArea = -0.24, loadSensitivity = 0.022}
cars[486] = {name = "DOZER", effectiveArea = -0.59, loadSensitivity = 0.016}
cars[489] = {name = "RANCHER", effectiveArea = -0.55, loadSensitivity = 0.019}
cars[490] = {name = "FBI RANCHER", effectiveArea = -0.57, loadSensitivity = 0.016}
cars[491] = {name = "VIRGO", effectiveArea = -0.27, loadSensitivity = 0.025}
cars[492] = {name = "GREENWOOD", effectiveArea = -0.43, loadSensitivity = 0.024}
cars[494] = {name = "HOTRING", effectiveArea = 1.3, loadSensitivity = 0.016}
cars[496] = {name = "BLISTAC", effectiveArea = 0.02, loadSensitivity = 0.019}
cars[498] = {name = "BOXVILLIE", effectiveArea = -0.67, loadSensitivity = 0.015}
cars[499] = {name = "BENSON", effectiveArea = -0.62, loadSensitivity = 0.017}
cars[500] = {name = "MESA", effectiveArea = -0.29, loadSensitivity = 0.018}
cars[502] = {name = "HOTRING A", effectiveArea = 1.35, loadSensitivity = 0.019}
cars[503] = {name = "HOTRING B", effectiveArea = 1.05, loadSensitivity = 0.015}
cars[504] = {name = "BLOODRING BANGER", effectiveArea = -0.14, loadSensitivity = 0.02}
cars[505] = {name = "RANCHER LURE", effectiveArea = -0.44, loadSensitivity = 0.014}
cars[506] = {name = "SUPER GT", effectiveArea = 0.45, loadSensitivity = 0.02}
cars[507] = {name = "ELEGANT", effectiveArea = -0.15, loadSensitivity = 0.018}
cars[508] = {name = "JOURNEY", effectiveArea = -0.60, loadSensitivity = 0.015}
cars[514] = {name = "PETROL", effectiveArea = -0.56, loadSensitivity = 0.016}
cars[515] = {name = "ROADTRAIN", effectiveArea = -0.59, loadSensitivity = 0.015}
cars[516] = {name = "NEBULA", effectiveArea = -0.20, loadSensitivity = 0.022}
cars[517] = {name = "MAJESTIC", effectiveArea = -0.18, loadSensitivity = 0.024}
cars[518] = {name = "BUCCANEER", effectiveArea = -0.36, loadSensitivity = 0.022}
cars[524] = {name = "CEMENT TRUCK", effectiveArea = -0.78, loadSensitivity = 0.014}
cars[525] = {name = "TOW TRUCK", effectiveArea = -0.62, loadSensitivity = 0.017}
cars[526] = {name = "FORTUNE", effectiveArea = -0.15, loadSensitivity = 0.025}
cars[527] = {name = "CADRONA", effectiveArea = -0.17, loadSensitivity = 0.024}
cars[528] = {name = "FBI TRUCK", effectiveArea = -0.56, loadSensitivity = 0.016}
cars[529] = {name = "WILLIARD", effectiveArea = -0.26, loadSensitivity = 0.026}
cars[530] = {name = "FORKLIFT", effectiveArea = -0.31, loadSensitivity = 0.029}
cars[531] = {name = "TRACTOR", effectiveArea = -0.61, loadSensitivity = 0.02}
cars[532] = {name = "COMBINE", effectiveArea = -1.15, loadSensitivity = 0.015}
cars[533] = {name = "FELTZER", effectiveArea = -0.39, loadSensitivity = 0.024}
cars[534] = {name = "REMINGTON", effectiveArea = -0.35, loadSensitivity = 0.024}
cars[535] = {name = "SLAMVAN", effectiveArea = -0.59, loadSensitivity = 0.021}
cars[536] = {name = "BLADE", effectiveArea = -0.45, loadSensitivity = 0.023}
cars[540] = {name = "VINCENT", effectiveArea = -0.28, loadSensitivity = 0.027}
cars[541] = {name = "BULLET", effectiveArea = 0.25, loadSensitivity = 0.02}
cars[542] = {name = "CLOVER", effectiveArea = -0.38, loadSensitivity = 0.023}
cars[543] = {name = "SADLER", effectiveArea = -0.58, loadSensitivity = 0.02}
cars[544] = {name = "FIRETRUCK LS", effectiveArea = -0.78, loadSensitivity = 0.016}
cars[545] = {name = "HUSTLER", effectiveArea = -0.21, loadSensitivity = 0.025}
cars[546] = {name = "INTRUDER", effectiveArea = -0.24, loadSensitivity = 0.023}
cars[547] = {name = "PRIMO", effectiveArea = -0.17, loadSensitivity = 0.021}
cars[549] = {name = "TAMPA", effectiveArea = -0.21, loadSensitivity = 0.023}
cars[550] = {name = "SUNRISE", effectiveArea = -0.11, loadSensitivity = 0.023}
cars[551] = {name = "MERIT", effectiveArea = -0.18, loadSensitivity = 0.022}
cars[552] = {name = "UTILITY VAN", effectiveArea = -0.53, loadSensitivity = 0.019}
cars[554] = {name = "YOSEMITE", effectiveArea = -0.46, loadSensitivity = 0.018}
cars[555] = {name = "WINDSOR", effectiveArea = -0.15, loadSensitivity = 0.026}
cars[556] = {name = "MONSTER A", effectiveArea = -0.82, loadSensitivity = 0.016}
cars[557] = {name = "MONSTER B", effectiveArea = -0.80, loadSensitivity = 0.016}
cars[558] = {name = "URANUS", effectiveArea = -0.06, loadSensitivity = 0.025}
cars[559] = {name = "JESTER", effectiveArea = -0.11, loadSensitivity = 0.025}
cars[560] = {name = "SULTAN", effectiveArea = -0.08, loadSensitivity = 0.024}
cars[561] = {name = "STRATUM", effectiveArea = -0.20, loadSensitivity = 0.02}
cars[562] = {name = "ELEGY", effectiveArea = 0.12, loadSensitivity = 0.022}
cars[565] = {name = "FLASH", effectiveArea = -0.03, loadSensitivity = 0.025}
cars[566] = {name = "TAHOMA", effectiveArea = -0.18, loadSensitivity = 0.022}
cars[567] = {name = "SAVANNA", effectiveArea = -0.47, loadSensitivity = 0.021}
cars[568] = {name = "BANDITO", effectiveArea = -0.15, loadSensitivity = 0.028}
cars[571] = {name = "KART", effectiveArea = 0.03, loadSensitivity = 0.035}
cars[572] = {name = "MOWER", effectiveArea = -0.11, loadSensitivity = 0.032}
cars[573] = {name = "DUNERIDE", effectiveArea = -0.38, loadSensitivity = 0.018}
cars[574] = {name = "SWEEPER", effectiveArea = -0.14, loadSensitivity = 0.032}
cars[575] = {name = "BROADWAY", effectiveArea = -0.39, loadSensitivity = 0.026}
cars[576] = {name = "TORNADO", effectiveArea = -0.34, loadSensitivity = 0.022}
cars[578] = {name = "DFT-30", effectiveArea = -0.51, loadSensitivity = 0.015}
cars[579] = {name = "HUNTLEY", effectiveArea = -0.48, loadSensitivity = 0.018}
cars[580] = {name = "STAFFORD", effectiveArea = -0.48, loadSensitivity = 0.018}
cars[587] = {name = "EUROS", effectiveArea = -0.09, loadSensitivity = 0.022}
cars[589] = {name = "CLUB", effectiveArea = -0.14, loadSensitivity = 0.024}
cars[596] = {name = "COP CAR LS", effectiveArea = -0.25, loadSensitivity = 0.025}
cars[597] = {name = "COP CAR SF", effectiveArea = -0.25, loadSensitivity = 0.024}
cars[598] = {name = "COP CAR LV", effectiveArea = -0.29, loadSensitivity = 0.023}
cars[599] = {name = "RANGER", effectiveArea = -0.48, loadSensitivity = 0.019}
cars[602] = {name = "ALPHA", effectiveArea = 0.09, loadSensitivity = 0.023}
cars[603] = {name = "PHOENIX", effectiveArea = -0.05, loadSensitivity = 0.024}
--[[caso queira aplicar a um carro adicionado, copie e cole a linha abaixo depois do ultimo carro acima(LEMBRE DE CHECAR O ID DO VEICULO):
cars[12500] = {name = "ADICIONADO", effectiveArea = 0.25, loadSensitivity = 0.03}
]]--
--------fim----------
local game_started = false
local carMass = 0.0
local CCar
local actualCar
local generic = 0
local totalDownforce = 0.0
local totalIncrease = 0.0
local totalLoss = 0.0
local saved = false
local originalTractionMult = 0.0
local originalTractionLoss = 0.0
local originalBrakeDeceleration = 0.0
local totalAreaBonus = 0.0
local function getCarAttribute(offset, memType)
CCar = getCarPointer(actualCar)
carAttribute = CCar + offset
if memType == "float" then
carAttribute = m.getfloat(carAttribute, false)
elseif memType == "uint8" then
carAttribute = m.getuint8(carAttribute, false)
elseif memType == "uint16" then
carAttribute = m.getuint16(carAttribute, false)
elseif memType == "uint32" then
carAttribute = m.getuint32(carAttribute, false)
elseif memType == "uint64" then
carAttribute = m.getuint64(carAttribute, false)
end
return carAttribute
end
local function setCarAttribute(offset, memType, value)
CCar = getCarPointer(actualCar)
carAttribute = CCar + offset
if memType == "float" then
m.setfloat(carAttribute, value, false)
elseif memType == "uint8" then
m.setuint8(carAttribute, value, false)
elseif memType == "uint16" then
m.setuint16(carAttribute, value, false)
elseif memType == "uint32" then
m.setuint32(carAttribute, value, false)
elseif memType == "uint64" then
m.setuint64(carAttribute, value, false)
end
end
local function getTractionMultiplier()
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0x28
generic = m.getfloat(generic, false)
return generic
end
local function getTractionLoss() -- por mais que o loss indique "perda", aparentemente aumentar esse valor melhora o comportamento do carro
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0xA4
generic = m.getfloat(generic, false)
return generic
end
local function getBrakeDeceleration()
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0x94
generic = m.getfloat(generic, false)
return generic
end
local function getMass()
generic = getCarAttribute(140, "float")
return generic
end
local function getCarTopSpeed()
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0x84
generic = m.getfloat(generic, false)
return generic / 0.02000001564
end
local function setTractionMultiplier(value)
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0x28
m.setfloat(generic, value)
end
local function setTractionLoss(value)
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0xA4
m.setfloat(generic, value)
end
local function setBrakeDeceleration(value)
CCar = getCarPointer(actualCar)
CHandling = CCar + 0x384
CHandling = readMemory(CHandling, 4, false)
generic = CHandling + 0x94
m.setfloat(generic, value)
end
local function setNewGrip(index)
carMass = getMass()
if calculateAirDensity then
updateAirDensity()
end
totalDownforce = math.pow(getCarSpeed(actualCar), 2) * airDensity * (cars[index].effectiveArea + totalAreaBonus) * dwMult / 2
totalDownforce = totalDownforce / 9.81 -- convertendo de Newtons para Kg
totalLoss = totalDownforce * cars[index].loadSensitivity * loadSensitivityMultiplier / 100 --- transforma em porcentagem
totalLoss = totalLoss >= 1 and 0.99 or totalLoss --- dá ruim se esse valor for igual ou maior que 1
totalIncrease = (1-totalLoss) * ((carMass + totalDownforce) / carMass)
if mode == 1 then
setTractionMultiplier(originalTractionMult * totalIncrease)
elseif mode == 2 then
setTractionLoss(originalTractionLoss *totalIncrease)
else
halfIncrease = (totalIncrease - 1) / 2 + 1 --- feito para distribuir o aumento entre o tractionMult e Loss
setTractionMultiplier(originalTractionMult * halfIncrease)
setTractionLoss(originalTractionLoss * halfIncrease)
end
if improveBrakes then
setBrakeDeceleration(originalBrakeDeceleration * totalIncrease)
end
end
local function howManyWings()
local vehicleComp = mad.get_all_vehicle_components(car)
if vehicleComp ~= nil then
local wings = 0
for i=1, table.getn(vehicleComp) do
local compName = vehicleComp[i].name
for j=1, table.getn(namesToSearchFor) do
if string.find(compName, namesToSearchFor[j]) then
wings = wings + 1
end
end
end
return wings
end
end
local function drawInformations()
if drawName then
draw_text(cars[index].name, xName, yName, 255, 255, 255)
end
if drawArea then
draw_text("Effective Area(m2): " .. string.format("%.2f",cars[index].effectiveArea + totalAreaBonus), xArea, yArea, 255, 255, 255)
end
if drawDownforce then
draw_text("Downforce (Kg): " .. string.format("%.2f", totalDownforce), xDownforce, yDownforce, 255, 255, 255)
end
if drawGrip then
draw_text("Relative Grip: " .. string.format("%.3f", totalIncrease), xGrip, yGrip, 255, 255, 255)
end
if drawTractionMult then
draw_text("Traction Mult: " .. string.format("%.3f", getTractionMultiplier()), xTractionM, yTractionM, 255, 255, 255)
end
if drawTractionLoss then
draw_text("Traction Loss: " .. string.format("%.3f", getTractionLoss()), xTractionL, yTractionL, 255, 255, 255)
end
end
function updateAirDensity()
----- https://www.grc.nasa.gov/www/k-12/airplane/atmosmet.html ----
local kelvin = 273.15
local t = 0.0
local pressure = 0.0 --- kpa
local tempX, tempY, tempZ = getCharCoordinates(PLAYER_PED)
if tempZ < 11000 then
t = 15.04 - 0.00649 * tempZ
pressure = 101.29 * math.pow((t + kelvin)/288.08, 5.256)
elseif tempZ >= 11000 and tempZ < 25000 then
t = -56.46
pressure = 22.65 * math.exp(1.73 - 0.000157 * tempZ)
else
t = -131.25 + 0.00299 * tempZ
pressure = 2.488 * math.pow((t + kelvin)/216.6, -11.388)
end
airDensity = pressure / (0.2869 * (t + kelvin))
end
function draw_text(str, x, y, r, g, b)
mad.draw_text(str, x, y, mad.font_style.MENU, 0.3, 0.6, mad.font_align.LEFT, 2000, true, false, r, g, b, 255, 1, 0, 30, 30, 30, 120)
end
function main()
game_started = true
while true do
wait(0)
if isCharInAnyCar(PLAYER_PED) then
wait(0)
while isCharInAnyCar(PLAYER_PED) do
actualCar = getCarCharIsUsing(PLAYER_PED)
index = getCarModel(actualCar)
if cars[index] ~= nil then
if saved then
setNewGrip(index)
else
originalTractionMult = getTractionMultiplier()
originalTractionLoss = getTractionLoss()
originalBrakeDeceleration = getBrakeDeceleration()
totalAreaBonus = howManyWings() * bonusPerWing
--printString("Numero de asas atualizado: " .. howManyWings(), 800)
saved = true
end
if drawInfos then
drawInformations()
end
end
if testCheat(downforce_editor_cheat) then
imgui.Process = not imgui.Process
end
wait(0)
end
if saved then
saved = false
end
else
if testCheat(downforce_editor_cheat) then
imgui.Process = not imgui.Process
end
end
end
end
----event----
function onScriptTerminate(script, quitGame)
if thisScript() == script and game_started then
if not quitGame then
if not isCharOnFoot(PLAYER_PED) then
if cars[index] ~= nil then
setTractionMultiplier(originalTractionMult)
setTractionLoss(originalTractionLoss)
setBrakeDeceleration(originalBrakeDeceleration)
end
end
end
end
end
-- ## Um_Geek
local edit_mode = false
local ImModel = imgui.ImInt(400)
local ImEffectiveArea = imgui.ImFloat(0.0)
local ImLoadSensitivity = imgui.ImFloat(0.0)
local ImFind = imgui.ImBuffer(12)
local ImSaveToFile = imgui.ImBool(false)
local EditActiveModel = -1
local defaults = {}
local save_data = "downforce.ini"
for model ,sets in pairs(cars) do
defaults[model] = sets
end
local data = ini.load(nil,save_data)
if data then
for model,sets in pairs(data) do
cars[model] = sets
end
end
function save_configs()
local iniout = {}
for model,sets in pairs(cars) do
iniout[model] = {
name = sets.name,
effectiveArea = sets.effectiveArea,
loadSensitivity = sets.loadSensitivity,
}
end
ini.save(iniout,save_data)
end
local function checkModel(model)
return (
isThisModelABoat(model)
or isThisModelACar(model)
or isThisModelAHeli(model)
or isThisModelAPlane(model)
)
end
function imgui.OnDrawFrame()
local sx,sy = getScreenResolution()
local sw,sh = 380,sy/2
local posx = (sx/2) - (sw/2)
local posy = (sy/2) - (sh/2)
imgui.SetNextWindowPos(imgui.ImVec2(posx,posy),imgui.Cond.FirstUseEver);
imgui.SetNextWindowSize(imgui.ImVec2(sw,sh),imgui.Cond.FirstUseEver);
imgui.Begin("Downforce Editor",nil,2+4+32+128+2048)
if cars[EditActiveModel] then
local i = ImModel.v
if isModelAvailable(ImModel.v) and ((ImModel.v >= 400 and ImModel.v <= 611) or checkModel(ImModel.v)) then
imgui.Text(getNameOfVehicleModel(ImModel.v))
if cars[i] then
imgui.NewLine()
else
imgui.Text("No Available!")
end
imgui.Spacing()
if imgui.InputInt('model',ImModel,1,100,0) then
end
imgui.Spacing()
if imgui.InputFloat('effectiveArea',ImEffectiveArea,0.0,0.0,-1,0) then
end
imgui.Spacing()
if imgui.InputFloat('loadSensitivity',ImLoadSensitivity,0.0,0.0,-1,0) then
end
else
if imgui.InputInt('model',ImModel,400,999,0) then
end
end
imgui.Spacing()
imgui.Separator()
imgui.NewLine()
if imgui.Button("save",imgui.ImVec2(80.0,22)) then
if isModelAvailable(ImModel.v) then
if checkModel(ImModel.v) then
if cars[i] then
cars[i].name = getNameOfVehicleModel(ImModel.v)
cars[i].model = ImModel.v
cars[i].effectiveArea = tonumber(string.format("%3.3f",ImEffectiveArea.v))
cars[i].loadSensitivity = tonumber(string.format("%3.3f",ImLoadSensitivity.v))
if ImSaveToFile.v then save_configs() end
printHelpString("~g~SAVE SUCESS!")
else
cars[i] = {
name = getNameOfVehicleModel(ImModel.v),
model = ImModel.v,
effectiveArea = tonumber(string.format("%3.3f",ImEffectiveArea.v)),
loadSensitivity = tonumber(string.format("%3.3f",ImLoadSensitivity.v)),
}
if ImSaveToFile.v then save_configs() end
printHelpString("~p~ADD SUCESS!")
end
end
end
EditActiveModel = -1
edit_mode = false
end
imgui.SameLine()
if imgui.Button("reset",imgui.ImVec2(80.0,22)) then
local sets = defaults[ImModel.v]
if sets then
ImEffectiveArea.v = sets.effectiveArea
ImLoadSensitivity.v = sets.loadSensitivity
end
end
imgui.SameLine()
if imgui.Button("cancel",imgui.ImVec2(80.0,22)) then
EditActiveModel = -1
edit_mode = false
end
imgui.NewLine()
imgui.Checkbox("save to file",ImSaveToFile)
else
imgui.Spacing()
if imgui.InputText("find name",ImFind,12,0) then
end
imgui.Spacing()
imgui.Separator()
imgui.Spacing()
local index = 0
for model, sets in pairs(cars) do
if #ImFind.v <= 0 or string.find(sets.name..'_'..model,ImFind.v) then
local info = string.format("%s: %4.4f, %4.4f",sets.name,sets.effectiveArea,sets.loadSensitivity)
index = index + 1
imgui.Bullet()
if imgui.MenuItem(info,tostring(model)) then
ImModel.v = model
ImEffectiveArea.v = sets.effectiveArea
ImLoadSensitivity.v = sets.loadSensitivity
EditActiveModel = model
edit_mode = true
end
imgui.Separator()
end
end
end
imgui.End()
if isKeyDown(0x20) then
imgui.Process = not imgui.Process
end
end