Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steam & Epic Autosave Update #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
94 changes: 94 additions & 0 deletions 2fmAutoSave.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
local GameVersion = 0
local canExecute = false
local prevBlack = 0
local prevContinue = 0
local blacklist = {"es01", "bb05", "eh20", "eh22", "eh23", "eh24", "eh25", "eh26", "eh27", "eh28", "eh29"}
local blacklisted = false

function _OnInit()
GameVersion = 0
end

function GetVersion() --Define anchor addresses
if GAME_ID == 0x431219CC and ENGINE_TYPE == 'BACKEND' then --PC
if ReadString(0x09A92F0,4) == 'KH2J' then --EGS
GameVersion = 2
print('[2fmAutoSave] - Epic Version Detected')
continue = 0x29FAFC0
save1 = 0x9A92F0
saveselect = 0x2616D60
sveAddr = 0x9BA370
inputAddr = 0x29FAD30
LoadingIndicator = 0x8EBFF0
loadmenu = 0x743350
writeLogic = 0x713438
canExecute = true
elseif ReadString(0x09A9830,4) == 'KH2J' then --Steam Global
GameVersion = 3
print('[2fmAutoSave] - Steam Global Version Detected')
continue = 0x29FB500
save1 = 0x9A9830
saveselect = 0x2617460
sveAddr = 0x9BA8B0
inputAddr = 0xBF3120
LoadingIndicator = 0x8EC540
loadmenu = 0x7435D0
writeLogic = 0x7134A0
canExecute = true
elseif ReadString(0x09A8830,4) == 'KH2J' then --Steam JP
GameVersion = 4
print('[2fmAutoSave] - Steam JP Version Detected')
continue = 0x29FA500
save1 = 0x9A8830
saveselect = 0x2616460
sveAddr = 0x9B98B0
inputAddr = 0xBF2120
LoadingIndicator = 0x8EB540
loadmenu = 0x7425D0
writeLogic = 0x7124A0
canExecute = true
end
end
end

function _OnFrame()
if GameVersion == 0 then --Get anchor addresses
GetVersion()
return
end

SVE = ReadString(sveAddr, 4)
for i = 1, 11 do
if SVE ~= blacklist[i] then
blacklisted = false
end
end
for i = 1, 11 do
if SVE == blacklist[i] then
blacklisted = true
end
end
if canExecute then
local input = ReadInt(inputAddr)
if input & 8192 == 8192 and ReadByte(loadmenu) == 0x03 then
WriteFloat(LoadingIndicator, 90)
end
if (input & 8192 == 8192 and ReadInt(saveselect) == 0 and ReadInt(save1+0xC) ~= prevSave) then
local f = io.open("KH2autosave.dat", "rb")
if f ~= nil then
WriteString(save1, f:read("*a"))
f:close()
print("Loaded autosave")
end
end
if ReadInt(continue+0xC) ~= prevContinue and ReadByte(writeLogic) == 0 and blacklisted == false then
local f = io.open("KH2autosave.dat", "wb")
f:write(ReadString(continue, 0x10FC0))
f:close()
print("Wrote autosave")
end
prevInput = input
prevSave = ReadInt(save1+0xC)
prevContinue = ReadInt(continue+0xC)
end
end
18 changes: 0 additions & 18 deletions 2fmSoftReset_v1.0.0.8.lua

This file was deleted.

8 changes: 4 additions & 4 deletions mod.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: Soft Reset (1.0.1)
title: Soft Reset Steam/Epic 1.0.0.9
originalAuthor: Denhonator
description: OpenKH port of Denhonator's KH2 soft reset script.
description: OpenKH port of Denhonator's KH2 soft reset script. Supports Steam and Epic 1.0.0.9
assets:
- name: scripts/2fmSoftReset_v1.0.0.8.lua
- name: scripts/2fmSoftReset.lua
method: copy
source:
- name: 2fmSoftReset_v1.0.0.8.lua
- name: 2fmSoftReset.lua