forked from gaithern/KH-1FM-AP-LUA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1fmAPEXPMultiplier.lua
84 lines (73 loc) · 2.32 KB
/
1fmAPEXPMultiplier.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
-----------------------------------
------ Kingdom Hearts 1 FM AP -----
------ by Gicu -----
-----------------------------------
LUAGUI_NAME = "kh1fmAP"
LUAGUI_AUTH = "denhonator with edits from Gicu"
LUAGUI_DESC = "Kingdom Hearts 1FM AP Integration"
local offset = 0x3A0606
local btltbl = 0x2D1F3C0 - offset
local itemTable = btltbl+0x1A58
local soraStats = 0x2DE59D0 - offset
local experienceMult = 0x2D59180 - offset
local canExecute = false
frame_count = 0
xp_mult = 1.0
if os.getenv('LOCALAPPDATA') ~= nil then
client_communication_path = os.getenv('LOCALAPPDATA') .. "\\KH1FM\\"
else
client_communication_path = os.getenv('HOME') .. "/KH1FM/"
ok, err, code = os.rename(client_communication_path, client_communication_path)
if not ok and code ~= 13 then
os.execute("mkdir " .. path)
end
end
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function read_mult()
if file_exists(client_communication_path .. "xpmult.cfg") then
file = io.open(client_communication_path .. "xpmult.cfg", "r")
io.input(file)
xp_mult = tonumber(io.read())
io.close(file)
elseif file_exists(client_communication_path .. "EXP Multiplier.cfg") then
file = io.open(client_communication_path .. "EXP Multiplier.cfg", "r")
io.input(file)
xp_mult = tonumber(io.read())
io.close(file)
else
xp_mult = 1.0
end
end
function main()
read_mult()
for p=0,2 do
local accOff = (p*0x74) + 0x1D
for i=0,3 do
local eqID = ReadByte(soraStats + accOff+i)
local eqName = ReadByte(itemTable+((eqID-1)*20))
if eqName == 0x56 or eqName == 0x58 then
xp_mult = xp_mult + 0.2
elseif eqName == 0x59 or eqName == 0x5A then
xp_mult = xp_mult + 0.3
end
end
end
WriteFloat(experienceMult, xp_mult)
end
function _OnInit()
if GAME_ID == 0xAF71841E and ENGINE_TYPE == "BACKEND" then
canExecute = true
ConsolePrint("KH1 detected, running script")
else
ConsolePrint("KH1 not detected, not running script")
end
end
function _OnFrame()
if frame_count == 0 and canExecute then
main()
end
frame_count = (frame_count + 1) % 30
end