Skip to content

Commit 3590757

Browse files
authored
v1.5.5
2 parents 90d612f + d994e79 commit 3590757

File tree

9 files changed

+201
-68
lines changed

9 files changed

+201
-68
lines changed

Advanced Gamepad Assist/apps/lua/Advanced Gamepad Assist Config/Advanced Gamepad Assist Config.lua

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local lib = require "../../../extension/lua/joypad-assist/Advanced Gamepad Assist/AGALib"
22
local _json = require "json"
3+
local updater = require "updater"
34

45
local uiData = ac.connect{
56
ac.StructItem.key("AGAData"),
@@ -53,7 +54,7 @@ local presetKeys = {
5354
"maxDynamicLimitReduction",
5455
}
5556

56-
local _factoryPresetsStr = '{"Loose":{"dampingStrength":0.3,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.3,"maxSelfSteerAngle":4,"targetSlip":1,"countersteerResponse":0.3,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":4.5,"steeringRate":0.5},"Default":{"dampingStrength":0.37,"filterSetting":0.5,"useFilter":true,"selfSteerResponse":0.37,"maxSelfSteerAngle":14,"targetSlip":0.95,"countersteerResponse":0.2,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":5,"steeringRate":0.5},"Stable":{"dampingStrength":0.75,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.65,"maxSelfSteerAngle":90,"targetSlip":0.93,"countersteerResponse":0.15,"rateIncreaseWithSpeed":0.0,"maxDynamicLimitReduction":6,"steeringRate":0.35},"Drift":{"dampingStrength":0.5,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.35,"maxSelfSteerAngle":90,"targetSlip":1,"countersteerResponse":0.5,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":4,"steeringRate":0.4},"Author\'s preference":{"dampingStrength":0.4,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.35,"maxSelfSteerAngle":90,"targetSlip":0.95,"countersteerResponse":0.2,"rateIncreaseWithSpeed":0,"maxDynamicLimitReduction":5,"steeringRate":0.5}}'
57+
local _factoryPresetsStr = '{"Loose":{"dampingStrength":0.3,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.3,"maxSelfSteerAngle":4,"targetSlip":1,"countersteerResponse":0.3,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":4.5,"steeringRate":0.5},"Default":{"dampingStrength":0.37,"filterSetting":0.5,"useFilter":true,"selfSteerResponse":0.37,"maxSelfSteerAngle":14,"targetSlip":0.95,"countersteerResponse":0.2,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":5,"steeringRate":0.5},"Stable":{"dampingStrength":0.75,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.65,"maxSelfSteerAngle":90,"targetSlip":0.93,"countersteerResponse":0.15,"rateIncreaseWithSpeed":0.0,"maxDynamicLimitReduction":6,"steeringRate":0.35},"Drift":{"dampingStrength":0.5,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.35,"maxSelfSteerAngle":90,"targetSlip":1,"countersteerResponse":0.5,"rateIncreaseWithSpeed":0.1,"maxDynamicLimitReduction":4,"steeringRate":0.4},"Author\'s preference":{"dampingStrength":0.4,"filterSetting":0.5,"useFilter":false,"selfSteerResponse":0.35,"maxSelfSteerAngle":90,"targetSlip":0.95,"countersteerResponse":0.2,"rateIncreaseWithSpeed":-0.25,"maxDynamicLimitReduction":5,"steeringRate":0.5}}'
5758
local factoryPresets = _json.decode(_factoryPresetsStr)
5859

5960
local savedPresets = ac.storage({presets = "{}"}, "AGA_PRESETS_")
@@ -79,7 +80,7 @@ local tooltips = {
7980
autoClutch = "Automatically controls the clutch if the engine would otherwise stall, or when setting off from a standstill.\n\nThis setting doesn't affect gear changes, that part is controlled by the 'Shifting mode' setting.",
8081
autoShiftingMode = "Default = AC's own gear shifting, no change.\n\nManual = custom rev-matching and clutch logic (if the car allows it), but manual shifting only.\n\nAutomatic = custom rev-matching and clutch logic (if the car allows it), as well as automatic gear shifting. You can still shift manually to override a gear for a short time though.\n\nThe 'Automatic' mode uses a custom algorithm which also takes the engine's power curve into account for optimal shifting points.\n\nIMPORTANT: Options other than 'Default' only work properly if 'Automatic shifting' is DISABLED in AC's assist settings!",
8182
autoShiftingCruise = "Allows the automatic shifting to go between cruise mode and performance mode depending on your throttle input.\n\nUseful if you want to do both performance driving and casual cruising, but you can disable it for racing (especially for rolling starts).",
82-
autoShiftingDownBias = "Higher = more aggressive downshifting when using automatic mode.\n\nFor example at the maximum setting the car will downshift almost immediately when you brake for a turn, however, this might leave you very close to the top of a gear when going back on the throttle again.",
83+
autoShiftingDownBias = "Higher = more aggressive downshifting when using automatic mode.\n\nFor example at the maximum setting the car will downshift almost immediately when you brake for a turn, however, this might leave you very close to the top of a gear when going back on the throttle again.\n\nIn most cases I recommend leaving this at maximum.",
8384
triggerFeedbackL = "Vibration feedback on the left trigger when braking.\n\nA lighter vibration means you're approaching the grip limit, and a heavy vibration means you're locking up the wheels.\n\nOnly works with compatible Xbox controllers!",
8485
triggerFeedbackR = "Vibration feedback on the right trigger when accelerating.\n\nA lighter vibration means you're approaching the grip limit, and a heavy vibration means you're getting wheelspin.\n\nOnly works with compatible Xbox controllers!",
8586
triggerFeedbackAlwaysOn = "Allows trigger vibrations even when TCS or ABS are enabled.",
@@ -100,6 +101,22 @@ local tooltips = {
100101
_gameRumble = "Controls AC's own 'Rumble effects' setting."
101102
}
102103

104+
-- Checking if a new version is available
105+
106+
local newVersionAvailable = false
107+
-- local newVersionURL = ""
108+
109+
updater.getLatestVersion(function (versionString, releaseNotes, downloadURL)
110+
local currentVersion = updater.versionStringToNumber(updater.getCurrentVersionString())
111+
local latestVersion = updater.versionStringToNumber(versionString)
112+
113+
if currentVersion ~= 0 and latestVersion ~= 0 and latestVersion > currentVersion and releaseNotes ~= "" and downloadURL ~= "" then
114+
newVersionAvailable = true
115+
tooltips["releaseNotes"] = "Release notes for version " .. versionString .. ":\n\n" .. releaseNotes
116+
-- newVersionURL = downloadURL
117+
end
118+
end)
119+
103120
local sectionPadding = 10
104121

105122
local black = rgbm(0.0, 0.0, 0.0, 1.0)
@@ -669,9 +686,16 @@ function script.windowMain(dt)
669686
showConfigSlider("maxSelfSteerAngle", "Max angle", "%.1f°", 0.0, 90.0, 1.0, uiData.useFilter)
670687
showConfigSlider("dampingStrength", "Damping", "%.f%%", 0.0, 100.0, 100.0, uiData.useFilter)
671688

672-
showDummyLine(0.25)
673-
ui.alignTextToFramePadding()
674-
ui.textWrapped("Tip: Hold SHIFT to fine-tune sliders, or CTRL-click them to edit the values!")
689+
showDummyLine(0.5)
690+
691+
if newVersionAvailable then
692+
if showButton("📲 Update available! Click to download!", "releaseNotes", nil, 0, rgbm(1.0, 0.9, 0.0, 1.0)) then
693+
os.execute("start https://www.overtake.gg/downloads/advanced-gamepad-assist.62485/")
694+
end
695+
else
696+
ui.alignTextToFramePadding()
697+
ui.textWrapped("Tip: Hold SHIFT to fine-tune sliders, or CTRL-click them to edit the values!")
698+
end
675699

676700
-- ui.pushFont(ui.Font.Tiny)
677701
-- showDummyLine(0.5)

Advanced Gamepad Assist/apps/lua/Advanced Gamepad Assist Config/manifest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[ABOUT]
22
NAME = Advanced Gamepad Assist Config
33
AUTHOR = adam10603
4-
VERSION = 1.5.4
4+
VERSION = 1.5.5
55
DESCRIPTION = Settings for the Advanced Gamepad Assist mod.
66

77
[CORE]
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local _json = require "json"
2+
3+
local M = {}
4+
5+
local versionRequestURL = "https://api.github.com/repos/adam10603/AC-Advanced-Gamepad-Assist/releases?per_page=1"
6+
local versionRequestHeaders = {
7+
["Accept"] = "application/vnd.github+json",
8+
["X-GitHub-Api-Version"] = "2022-11-28"
9+
}
10+
11+
M.versionStringToNumber = function(str)
12+
local mult = 100
13+
local versionNumber = 0
14+
for c in str:gmatch("%d") do
15+
versionNumber = versionNumber + mult * tonumber(c)
16+
mult = mult / 10
17+
end
18+
return versionNumber
19+
end
20+
21+
M.getCurrentVersionString = function()
22+
local manifest = ac.INIConfig.load("manifest.ini", ac.INIFormat.Extended)
23+
24+
local versionString = manifest:get("ABOUT", "VERSION", "")
25+
26+
if versionString == nil or versionString == "" then return "" end
27+
28+
return versionString
29+
end
30+
31+
---@param callback fun(versionString: string, releaseNotes: string, downloadURL: string)
32+
M.getLatestVersion = function(callback)
33+
34+
-- callback("1.5.6", " - Testing\r\n - Patch notes")
35+
36+
web.get(versionRequestURL, versionRequestHeaders, function (err, response)
37+
if (err ~= nil and err ~= "") or response.status ~= 200 then
38+
ac.error("Failed to retrieve the latest version string.")
39+
return
40+
end
41+
42+
local parsed = _json.decode(response.body)
43+
44+
if parsed[1] and type(parsed[1]["tag_name"]) == "string" and type(parsed[1]["body"]) == "string" and type(parsed[1]["assets"]) == "table" and type(parsed[1]["assets"][1]) == "table" and type(parsed[1]["assets"][1]["browser_download_url"]) == "string" then
45+
local tag = parsed[1]["tag_name"]
46+
if string.startsWith(tag, "v") then tag = tag:sub(2) end
47+
callback(tag, parsed[1]["body"], parsed[1]["assets"][1]["browser_download_url"])
48+
return
49+
end
50+
51+
ac.error("Invalid response when retrieving the latest version string")
52+
end)
53+
end
54+
55+
-- M.performUpdate = function(downloadURL)
56+
-- web.loadRemoteAssets(downloadURL, function (err, folder)
57+
-- ac.log(err)
58+
-- ac.log(folder)
59+
-- end)
60+
-- end
61+
62+
return M

Advanced Gamepad Assist/extension/lua/joypad-assist/Advanced Gamepad Assist/AGALib.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function M.SmoothTowards:reset()
365365
end
366366

367367
-- SmoothTowards2 class
368-
-- would be a better version of SmoothTowards, but im lazy to migrate the whole project to use this
368+
-- would be a better version of SmoothTowards, but im lazy to migrate the whole project to use this, the rates would all need to be adjusted slightly
369369

370370
-- M.SmoothTowards2 = {}
371371

@@ -384,9 +384,11 @@ end
384384
-- function M.SmoothTowards2:get(val, dt)
385385
-- local x1 = self.linearity - 0.5
386386
-- local rateCorrection = x1 * x1 * 0.2 + 0.95
387-
-- local change = dt * self.range * self.rate * rateCorrection
388-
-- local v0 = self.state + (val - self.state) * (change * 2.0)
389-
-- local v1 = (math.abs(val - self.state) <= change) and val or (self.state + math.sign(val - self.state) * change)
387+
-- local normalizedRate = self.rate * self.range * rateCorrection
388+
-- local maxChange = normalizedRate * dt
389+
-- local factor = 1.0 - math.exp(-2.0 * maxChange / math.max(self.range, 1e-13))
390+
-- local v0 = self.state + (val - self.state) * factor
391+
-- local v1 = (math.abs(val - self.state) <= maxChange) and val or (self.state + math.sign(val - self.state) * maxChange)
390392
-- self.state = v0 + (v1 - v0) * self.linearity
391393

392394
-- return self.state
@@ -413,7 +415,7 @@ end
413415
-- self.state = self.startingValue
414416
-- end
415417

416-
--
418+
417419

418420
local _valueHistory = {}
419421
function M.measureUpdateRate(key, value, dt)

Advanced Gamepad Assist/extension/lua/joypad-assist/Advanced Gamepad Assist/CarPerformanceData.lua

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function M:getMaxTQ(rpm, gear)
150150
local totalBoost = 0.0 -- Total boost from all turbos
151151

152152
for _, turbo in ipairs(self.turboData) do
153-
local tBoost = 0.0 -- Boost from this turbo
153+
local currentTurboBoost = (rpm / turbo.referenceRPM) ^ turbo.gamma -- 0 -- Boost from this turbo
154154

155155
if table.nkeys(turbo.controllers) > 0 then
156156
for _, controller in ipairs(turbo.controllers) do
@@ -160,22 +160,19 @@ function M:getMaxTQ(rpm, gear)
160160
controller.LUT.useCubicInterpolation = true
161161
controllerValue = controller.LUT:get(rpm)
162162
elseif turbo.controllerInput == "GEAR" then
163-
turbo.controllerLUT.useCubicInterpolation = false
164-
controllerValue = turbo.controllerLUT:get(gear)
163+
controller.LUT.useCubicInterpolation = false
164+
controllerValue = controller.LUT:get(gear)
165165
end
166166

167167
if controller.combinator == "ADD" then
168-
tBoost = tBoost + controllerValue
168+
currentTurboBoost = currentTurboBoost + controllerValue
169169
elseif controller.combinator == "MULT" then
170-
tBoost = tBoost * controllerValue
170+
currentTurboBoost = currentTurboBoost * controllerValue
171171
end
172172
end
173-
else
174-
-- No special controllers, standard boost math
175-
tBoost = tBoost + (rpm / turbo.referenceRPM) ^ turbo.gamma
176173
end
177174

178-
totalBoost = totalBoost + math.min(tBoost, turbo.boostLimit)
175+
totalBoost = totalBoost + math.min(currentTurboBoost, turbo.boostLimit)
179176
end
180177

181178
return baseTorque * (1.0 + totalBoost)
@@ -210,14 +207,14 @@ function M:calcShiftingTable(minNormRPM, maxNormRPM)
210207

211208
local minRPM = self:getAbsoluteRPM(minNormRPM)
212209
local maxShiftRPM = self:getAbsoluteRPM(maxNormRPM)
213-
local defaultFallback = self.defaultShiftUpRPM * 1.03
210+
local defaultFallback = self.defaultShiftUpRPM
214211

215212
for gear = 1, self.vehicle.gearCount - 1, 1 do
216213
local bestUpshiftRPM = defaultFallback
217214

218215
if self.vehicle.mgukDeliveryCount == 0 then
219216
local bestArea = 0
220-
local areaSkew = math.lerp(1.0, 1.2, (gear - 1) / (self.vehicle.gearCount - 2)) -- shifts the bias of the power integral higher as the gear number increases
217+
local areaSkew = math.lerp(1.0, 1.25, (gear - 1) / (self.vehicle.gearCount - 2)) -- shifts the bias of the power integral higher as the gear number increases
221218
local nextOverCurrentRatio = self:getGearRatio(gear + 1) / self:getGearRatio(gear)
222219
for i = 0, 300, 1 do
223220
local upshiftRPM = self:getAbsoluteRPM(i / 300.0)
@@ -226,7 +223,7 @@ function M:calcShiftingTable(minNormRPM, maxNormRPM)
226223
local area = 0
227224
for j = 0, 100, 1 do
228225
local simRPM = math.lerp(nextGearRPM, upshiftRPM, j / 100.0)
229-
area = area + self:getMaxHP(simRPM, gear) / 100.0 * math.lerp(1.0, areaSkew, (j / 100.0))
226+
area = area + self:getMaxHP(simRPM, gear + 1) / 100.0 * math.lerp(1.0, areaSkew, (j / 100.0))
230227
end
231228
if area > bestArea then
232229
bestArea = area

0 commit comments

Comments
 (0)