Last active
November 16, 2022 04:09
-
-
Save MottaTheHutt/5a92cc88dd0d60f2f5ab to your computer and use it in GitHub Desktop.
Gau Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Work in Progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local battle = {} | |
battle.main = function () | |
while (memory.readbyte(0x7E3A8F)==0x00) do | |
while (memory.readbyte(0x7E3219)==0x00 or memory.readbyte(0x7E321B)==0x00 or | |
memory.readbyte(0x7E321D)==0x00 or memory.readbyte(0x7E321F)==0x00) do | |
joypad.set(1,{A=true}) | |
snes9x.frameadvance() | |
end | |
snes9x.frameadvance() | |
end | |
end | |
return battle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local characters = { | |
terra = { | |
name = "Terra", | |
currentWorldHP = function() return memory.readword(0x7E1609) end, | |
maxHP = memory.readword(0x7E160B), | |
partyStatus = memory.readbyte(0x7E1850), | |
}, | |
locke = { | |
name = "Locke", | |
currentWorldHP = function() return memory.readword(0x7E162E) end, | |
maxHP = memory.readword(0x7E1630), | |
partyStatus = memory.readbyte(0x7E1851), | |
}, | |
cyan = { | |
name = "Cyan", | |
currentWorldHP = function() return memory.readword(0x7E1653) end, | |
maxHP = memory.readword(0x7E1655), | |
partyStatus = memory.readbyte(0x7E1852), | |
}, | |
edgar = { | |
name = "Edgar", | |
currentWorldHP = function() return memory.readword(0x7E169D) end, | |
maxHP = memory.readword(0x7E169F), | |
partyStatus = memory.readbyte(0x7E1854), | |
}, | |
sabin = { | |
name = "Sabin", | |
currentWorldHP = function() return memory.readword(0x7E16C2) end, | |
maxHP = memory.readword(0x7E16C4), | |
partyStatus = memory.readbyte(0x7E1855), | |
}, | |
setzer = { | |
name = "Setzer", | |
currentWorldHP = function() return memory.readword(0x7E1756) end, | |
maxHP = memory.readword(0x7E1758), | |
partyStatus = memory.readbyte(0x7E1859), | |
}, | |
gau = { | |
name = "Gau, Gau!", | |
currentWorldHP = function() return memory.readword(0x7E17A0)end, | |
maxHP = memory.readword(0x7E17A2), | |
partyStatus = memory.readbyte(0x7E185B), | |
}, | |
empty = { | |
name = "Empty", | |
currentWorldHP = function() return 1 end, | |
maxHP = 1, | |
partyStatus = 2, -- EXPERIMENTAL PLACEHOLDER | |
}, | |
} | |
return characters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- *************************************************************************************** | |
-- gau_bot.lua | |
-- a rage-acquiring bot | |
-- WiP | |
-- | |
-- Green beret obscures max_hp value | |
-- Use back guard. Non-standard formations interfere with heal targetting | |
-- intangir = probable wipe | |
-- | |
-- ************************************************************************** | |
NAVIGATION = require "navigation" | |
PARTY = require "party" | |
BATTLE = require "battle" | |
while (true) do | |
if (memory.readbyte(0x7E3A8F)==0x00) then | |
BATTLE.main() | |
end | |
if (PARTY[1].currentWorldHP()/PARTY[1].maxHP<=0.33 or PARTY[2].currentWorldHP()/PARTY[2].maxHP<=0.33 or | |
PARTY[3].currentWorldHP()/PARTY[3].maxHP<=0.33 or PARTY[4].currentWorldHP()/PARTY[4].maxHP<=0.33) then | |
NAVIGATION.visitMobliz() | |
else | |
NAVIGATION.patrol() | |
end | |
for a=1,25 do | |
--gui.text(25,25, PARTY[2].currentWorldHP()) -- PRINT A SPECIFIC ADDRESS | |
snes9x.frameadvance() | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local party = {} | |
local CHARACTERS = require "characters" | |
local function findCharacters () | |
i = 1; | |
party = {} | |
for k,character in pairs(CHARACTERS) do | |
if character.partyStatus%2 == 1 then | |
party[i] = character | |
i = i+1 | |
end | |
end | |
return party | |
end | |
local function sortCharacters(unsorted) | |
sorted = {CHARACTERS.empty,CHARACTERS.empty,CHARACTERS.empty,CHARACTERS.empty} | |
for k,character in pairs(unsorted) do | |
partyPosition = bit.rshift(bit.band(character.partyStatus,0x18),3) + 1 | |
character.partyPosition = partyPosition | |
sorted[partyPosition] = character | |
end | |
return sorted; | |
end | |
local function fillEmptySlots(sorted) | |
filled = {CHARACTERS.empty,CHARACTERS.empty,CHARACTERS.empty,CHARACTERS.empty} | |
for i=1, 4 do | |
if sorted[i].name == "Empty" then | |
filled[i] = CHARACTERS.empty | |
else | |
filled[i] = sorted[i] | |
end | |
end | |
return filled | |
end | |
function party.createParty() | |
unsortedParty = findCharacters() | |
sortedParty = sortCharacters(unsortedParty) | |
filledParty = fillEmptySlots(sortedParty) | |
return filledParty | |
end | |
-- PRINT TEST Warning: Will crash main.lua, must run party.lua directly ---- | |
-- while (true) do | |
-- local testString | |
-- testString1 = findCharacters() | |
-- testString2 = sortCharacters(testString1) | |
-- testString3 = fillEmptySlots(testString2) | |
-- j = 0 | |
-- for i=1,4 do | |
-- gui.text(17,25+10*j,testString3[i].name) | |
-- j = j+1 | |
-- end | |
-- snes9x.frameadvance() | |
-- end | |
---------------------------------------------------------------------- | |
return party.createParty() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment