Golden Sun Hacking Community
December 16, 2017, 08:33:54 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
  Home   Forum   DC Wiki Help Search Calendar Downloads Login Register  
Pages: [1] 2   Go Down
  Print  
Author Topic: Creating useful Lua Scripts  (Read 10361 times)
0 Members and 1 Guest are viewing this topic.

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« on: August 08, 2015, 06:21:38 AM »

Hey all.

To better optimise the GS1 speedrun I want to write a few lua scripts to do useful things for us. The ones I have at the moment cover things like:
- time to next encounter
- GRN/BRN display
- GRN/BRN advance counter (number of times RNG advances)
- enemy hp
- position of Isaac

The way to take scripting to the next level of usefulness is to develop a script which tells you:
- encounter step growth rate (i.e. how fast does the encounter counter rise) (im sure there is a memory value that can be read for this but I don't know where it is)
- number of GRN advances required to flee from battle
- number of BRN advances required to trigger an assassin blade instant kill

The biggest barrier to creating the second two scripts is that I don't know how the game modifies the GRN (general random number) and BRN (battle random number) to be used in the formulas in the master formula thread.

Hunting through the disassembly, I think to generate a random number between 0x0 and 0xFFFF it shifts the GRN value to the right by 2, then shifts to the left by 4 and returns the hex value of the inner four digits of the GRN value (in hex). I have no idea how the game modifies a random number to get a value less than 0x63.

Last time the subject was discussed, Fox said
Quote
0811CE94 = Calculate chance of fleeing.
5000 + (2000*fleeFails) + (Relative Level * 500) >= Random(0,9999) , Oddly uses the “General” RNG.
Relative Level = Get the average level of all the PCs and subtract the average level of the enemies.
If my previous guess is correct, I now have a number between 0 and 65535 and I don't know how to convert that to a number =< 9999 for use in the formula. I figure if I can work out how to get the flee predictor working, the assassin blade should follow in a similar manner.

I've spoilered a section of the code I am writing in case that is useful.
Spoiler for Hidden:
Code:
local GRN = 0x03001CB4 -- General RN

local function flee(GRN)

el1 = memory.readbyte(0x02030887)
el2 = memory.readbyte(0x020309d3)
el3 = memory.readbyte(0x02030B1F)
el4 = memory.readbyte(0x02030c6b)

if el4 ~= 0 then
ela = (el1+el2+el3+el4)/4
elseif el3 ~=0 then
ela = (el1+el2+el3)/3
elseif el2 ~=0 then
ela = (el1+el2)/2
else
ela = el1
end

party = memory.readbyte(0x02000040)
isl= memory.readbyte(0x0200050E)
gal= memory.readbyte(0x0200065a)
ivl= memory.readbyte(0x020007a6)
mil= memory.readbyte(0x020008F2)

if party == 15 then
ml = (isl+gal+ivl+mil)/4
elseif party == 7 then
ml = (isl+gal+ivl)/3
else
ml = (isl+gal)/2
end

LevelAve = ml-ela

fleeFail = memory.readbyte(0x02030092)

fl = 5000 + (2000*fleeFail) + (LevelAve * 500)

cgren = ??? [this would be the GRN value modified]

if fl >= cgrn then
return true
else
return false
end
end
Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #1 on: August 08, 2015, 06:56:11 AM »

@RNG = For what's stored in memory... Suppose x represents the random number in RAM.
x = (x * 0x41C64E6D) + 0x3039
The value returned from the function will only give you the two bytes in the middle.
Now to make it so you can only have random numbers below a certain values, the number (In a register, not in RAM), is further modified. (Usually multiplying by the range number, and shifting 16 bits right.)

Example:
@0811CF5C = This is the call to the GRN, returns 16-bit value from 0000-FFFF.
After this function call, that number is multiplied by 10000.... and then shifted right 16-bits (4 hex numbers)...

( 0x0000 * 10000 ) >> 16  = 0
( 0xFFFF * 10000 ) >> 16  = 9999
« Last Edit: August 08, 2015, 06:58:33 AM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #2 on: August 08, 2015, 07:10:42 AM »

Let me see if I understand you correctly.

Let x= GRN in RAM.

If I select "Flee" in battle the game does the calculation x = (x * 0x41C64E6D) + 0x3039 (where the two numbers are hex numbers not ram addresses). Write x into the GRN RAM and let y= 2 middle bytes of x (i.e.  y = x << 8, >> 16)
Calculate y*10000 and right shift 16 bits and let the result be y. If y <= flee formula, then flee is successful.

UPDATE: I went ahead and implemented the above as I understood it and the result is this:
Code:
local function flee(GRN)

-- Calculate enemy average level

el1 = memory.readbyte(0x02030887)
el2 = memory.readbyte(0x020309d3)
el3 = memory.readbyte(0x02030B1F)
el4 = memory.readbyte(0x02030c6b)

if el4 ~= 0 then
ela = (el1+el2+el3+el4)/4
elseif el3 ~=0 then
ela = (el1+el2+el3)/3
elseif el2 ~=0 then
ela = (el1+el2)/2
else
ela = el1
end

-- Calculate party average level

party = memory.readbyte(0x02000040)
isl= memory.readbyte(0x0200050F)
gal= memory.readbyte(0x0200065b)
ivl= memory.readbyte(0x020007a7)
mil= memory.readbyte(0x020008F3)

if party == 15 then
ml = (isl+gal+ivl+mil)/4
elseif party == 7 then
ml = (isl+gal+ivl)/3
else
ml = (isl+gal)/2
end

-- Relative Level
LevelAve = ml-ela

--Flee Value
fleeFail = memory.readbyte(0x02030092)
fl = 5000 + (2000*fleeFail) + (LevelAve * 500)

--Random number
evalgrn = memory.readdword(0x03001CB4)
c1 = 1103515245
c2 = 12345
g = (evalgrn * c1)+c2
g = bit.lshift(g,8)
g = bit.rshift(g,16)
g = g * 10000
cgrn = bit.rshift(g, 16)
print(cgrn)
print(fl)

--Flee successful?
if fl >= cgrn then
return true
else
return false
end
end
It doesn't look like the calculations are matching up with flee success at all. The random number is between 0-9999 but there doesn't seem to be any correlation between the Flee Value calculated above and the Random number. =/
« Last Edit: August 08, 2015, 09:59:04 AM by Plexa » Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #3 on: August 09, 2015, 12:48:56 PM »

Does it work for GS2? (With GS2 addresses)

Does dividing get rid of the remainder/decimal?
Are all variables 32-bit? (i.e. Read one 8-bit byte into a 32-bit variable?)


Haven't tested your code yet... I need some version of VBA I forgot about, I'm guessing? (First guess was VBA-M.) Found something Called VBA - ReRecording, maybe that will do?
While I can definitely understand your code, can't say I've dabbled much in LUA... Yet, unfortunately.


---
By the way... * 500 happens before the division:

((Sum of PC levels * 500) / number of PCs) - ((Sum of enemy levels * 500) / number of enemies)

May or may not be important to note due to rounding that division does... So it may have been a mistake for me to simplify that much earlier...
« Last Edit: August 09, 2015, 02:14:47 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #4 on: August 09, 2015, 11:55:57 PM »

Currently at uni so can't test anything but... I haven't tested it with GS2, but I can easily make some adaptions and test it tonight. Will let you know how that goes.

The division doesn't get rid of the decimal, this could be the source of the problem since if the number of enemies is 3 then you can get some ugly decimals. Should I round the division down or up?

Everything looks like a 32-bit variable.

I use VBA-RR to do this stuff (which is VBA ReRecording).


UPDATE: Tested in GS2, also got inconsistent results =/

UPDATE 2: Did some digging and I think the problem is in getting the correct random number. It's plausible that the g = memory.readdword(0x030011BC),   c1 = 1103515245,   c2 = 12345,   g = (g * c1)+c2 part of the code might not be operating correctly. Will think about it tonight.

UPDATE 3: Running things through VBA SDL-H it looks like the random number is accessed a lot of times when you go to flee. It seems as though it may not be a single RN advance which is used, but possibly a few.

UPDATE 4: Okay I'm pretty sure there's just something wrong with my "advance RNG calculation". So the multiplication returns a 48 bit number which can then be converted into a 32 bit number. The question is how does the GBA multiply two numbers together and stay within 32 bits? Is it done modulo x100000000? Is it done with bitwise AND with 0xFFFFFFFF? etc
« Last Edit: August 10, 2015, 09:23:44 AM by Plexa » Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #5 on: August 10, 2015, 06:20:32 PM »

Quote
UPDATE 4: Okay I'm pretty sure there's just something wrong with my "advance RNG calculation". So the multiplication returns a 48 bit number which can then be converted into a 32 bit number. The question is how does the GBA multiply two numbers together and stay within 32 bits? Is it done modulo x100000000? Is it done with bitwise AND with 0xFFFFFFFF? etc
Hmm... Good point... My guess is AND 0xFFFFFFFF... But I might have to check it out.

Quote
Should I round the division down or up?
Without verifying, I would round down. Since r1 would be the remainder number, I believe? (And r0 in the ones that actually do return it.)

Quote from: From my documentation
08002054 = Division(numerator,denominator) (Signed?)
0800205C = Division(numerator,denominator) (Unsigned?)
08002064 = Division(numerator,denominator) (Signed. return remainder?)
0800206C = Division(numerator,denominator) (Unsigned, return remainder?)

080028A8 = There's a table here (32-bits), for denominators of 0x0-0x3FFF.... basically... if you can do 64-bits, do... (read32bit[080028A8 + denominator*4] * numerator) >> 32
(ARM is able to do 64-bit by using two registers sort of...)


---
*Tested your LUA scripts somewhat...
« Last Edit: August 10, 2015, 08:52:15 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #6 on: August 10, 2015, 08:59:50 PM »

I tested both mod 0x100000000 and AND 0xFFFFFFFF and didn't get anywhere. Will have another go once I get home today :) Will also incorporate division rounding down. etc. Will keep you posted on developments.
Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #7 on: August 10, 2015, 09:05:50 PM »

Just want to say... this thing calculates weirdly... So yeah, something wrong is going on...

   evalgrn = memory.readdword(0x03001CB4) -- =0x51b585b1
   c1 = 1103515245
   c2 = 12345
   g = (evalgrn * c1)+c2
g = bit.band(g,0xffffffff)
print(g)

g would be 1601235978 (0x5F70EC0A, but is supposed to be... 0x14FE625F70EC0A96...when using Windows calculator in Programming mode. (Shifted 8-bits, how? Not sure I understand, unless something about a 56-bit limit? No idea?)
« Last Edit: August 10, 2015, 09:21:59 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #8 on: August 11, 2015, 03:07:59 AM »

Success!! Lua gets confused when the numbers are larger than 2^53, as your calculations verified. I split the RNG calculation up into
Code:
g = memory.readdword(0x03001CB4)
m1 = 0x4e6d
m2 = 0x41c6
g1 = g*m1
g2 = g*m2
g2 = bit.band(g2,0xFFFF)
g = g1 + g2*0x10000
c=0x3039
g = g+c
g = bit.band(g,0xFFFFFFFF)
and now the script accurately calculates the RNG and the formula seems to work!

Here is a working lua script to calculate the number of attack cancels you need to input before you can flee from battle and the number of BRNs needed to advance to get an assassin blade kill with Isaac.
Code:
local el1 = memory.readbyte(0x02030887)
local el2 = memory.readbyte(0x020309d3)
local el3 = memory.readbyte(0x02030B1F)
local el4 = memory.readbyte(0x02030c6b)
local party = memory.readbyte(0x02000040)
local isl= memory.readbyte(0x0200050F)
local gal= memory.readbyte(0x0200065b)
local ivl= memory.readbyte(0x020007a7)
local mil= memory.readbyte(0x020008F3)

while true do

if (memory.readword(0x020308B0)) >= 1 then

if el4 ~= 0 then
ela = (el1+el2+el3+el4)/4
elseif el3 ~=0 then
ela = (el1+el2+el3)/3
elseif el2 ~=0 then
ela = (el1+el2)/2
else
ela = el1
end

if party == 15 then
ml = (isl+gal+ivl+mil)/4
elseif party == 7 then
ml = (isl+gal+ivl)/3
else
ml = (isl+gal)/2
end

LevelAve = ml-ela

function RNA (R)

g = R
m1 = 0x4e6d
m2 = 0x41c6
g1 = g*m1
g2 = g*m2
g2 = bit.band(g2,0xFFFF)
g = g1 + g2*0x10000
g = bit.band(g,0xFFFFFFFF)
c=0x3039
g = g+c
g = bit.band(g,0xFFFFFFFF)
return g

end

function RNB (R)

g = R
m1 = 0x4e6d
m2 = 0x41c6
g1 = g*m1
g2 = g*m2
g2 = bit.band(g2,0xFFFF)
g = g1 + g2*0x10000
c=0x3039
g = g+c
g = bit.band(g,0xFFFFFFFF)
g = bit.lshift(g,8)
g = bit.rshift(g,16)
return g

end

fleeFail = memory.readbyte(0x02030092)

function flee(S)
g = S
g = RNB(g)*10000
fl = 5000 + (2000*fleeFail) + (LevelAve * 500)
g = bit.rshift(g, 16)
if fl >= g then
return true
else
return false
end
end

--gui.register(flee)

RN= memory.readdword(0x03001CB4)
count = 0

while flee(RN) == false do
count = count + 1
if count == 100 then break end
RN= RNA(RN)
end

gui.text(0,0,"ACs to Run: " .. count)

function ablade (S)
g = S
g = RNB(g)*100
g = bit.rshift(g,16)
iel = memory.readbyte(0x02000524)
eel = memory.readbyte(0x0203089E) -- venus res
elu = memory.readbyte(0x020308BA)
eme = memory.readbyte(0x020308A2)
ema = memory.readbyte(0x020308A6)
eju = memory.readbyte(0x020308A8)
if eel < eme and eel < ema and eel < eju then
v = 25
else
v = 0
end
v=25
kill = (((iel - eel)-math.floor(elu/2))*3+20+v*100)/100
if kill >= g then
return true
else
return false
end
end

function unleash (S)
g = S
g = RNB(g)*100
g = bit.rshift(g,16)
if 35 >= g then
return true
else
return false
end
end

BRN = memory.readdword(0x020023A8)
bcount=0

while ablade(RNA(BRN)) == false or unleash(BRN) == false do
bcount = bcount+1
if bcount == 100 then break end
BRN=RNA(BRN)
end

gui.text(0,10,bcount)
end

vba.frameadvance();

end

Phase 2; Assassin Blade instant kills. Note: I've implemented what I think is correct (and the data matches it thus far...). The question here is how does the game pick a number before 0x63? I assume its the 'shifted' RN *100 and then >> 16 ? (This seems to work)

So when you go to attack multiple BRNs are consumed. For what we're interested in, we need the assassin blade to unleash mortal danger (1 BRN) and then we need mortal danger to instant kill (1 BRN). From this it looks like we need to check to see if there will be an unleash on the current BRN seed and then an unleash on the second BRN seed. I assume the unleash calculation is just checking to see if the RN is bigger than 35.

Also in the master formula list the instant death effect uses the formula:
(((((((Attacker's elemental level - Defender's elemental level) - Floor(Defender's luck / 2)) * 3) + effect's base chance + (vulnerabity's 25)) * multi_arg) / 100)  >= rnd())

What on earth is (vulnerabity's 25)? I've assumed that it's an elemental weakness to Venus, if so then set vulnerability to 25, else set it to 0.

UPDATE: I think the vulnerability portion of the code is incorrect. Gonna need that explained because I can't work it out from brute force T_T

UPDATE: I found this from Lord Squirtle
Quote
Vulnerability 25: Each class has three values which correspond to ability effects; if there is a value above 0 in a class, then it will add +25% to the success rate of that effect. Enemies also have these three values that correspond to ability effects. If looking at them in the editor, they will be the numbers at the bottom of the class section and the ones above the elemental tables for enemies.
Where might I find these values in the RAM?

UPDATE: I think there's something wrong with the ailment success formula. (((Attacker's elemental level - Defender's elemental level) - Floor(Defender's luck / 2)) * 3) -- I think the *3 should be multiplied against the Luck/2 number not the whole thing.

UPDATE: Here's and example of things going wrong against a boss. I have an RN seed which lets Mia proc the witch's wand unleash and inflict stun on Killer ape.
Mia Jupiter power = 76
Killer Ape Jupiter Res = 127
Killer Ape Luck = 26
Stun chance = 40
Plug everything into the formula and I get -25, i.e. the stun should never proc. =/

UPDATE: More digging lead me to this post!
It looks like there's a part of the code where if defender's luck is 40+, about 8 of the effects are given a chance of 0%. (For example, x18 and x19 (May Inflict Poison/Venom)

Effect's can also have a base chance without a formula (When their numbers are negative ), but when the formula is used (x0-x64), I think it looks like this: Not sure if I made any mistakes.

success =
(((((((Attacker's elemental level - Defender's elemental level) - Floor(Defender's luck / 2)) * 3) + effect's base chance + (vulnerabity's 25)) * diminishing%) / 100)  >= rnd())

diminishing% = The direct target is 100, with this lowering for enemies further away.

Notes:
x52 = "82 - May force target out of battle" is always 0% when class is not NPC. (0% for player characters?)

These generate three random numbers... This would make, for example, a chance of 50% (one) to be 87.5% (three), I think.
x43 = "67 - Inflicts Seal"
x50 = "80 - Inflicts Death Curse"
x55 = "85 - May inflict Stun"

Hopefully I didn't get anything backwards or messed up. I've only looked at the stuff from 080B08C2 and down, but there may be some stuff above this address that may have conditions for when this formula is skipped.

Where attacker and defender labels are placed are just assumed, I didn't double check them, but it wouldn't make much sense otherwise.

« Last Edit: October 10, 2012, 01:32:55 PM by Teawater »
Now it looks like you suggest that the value compared against the random number should be the minimum of the calculation and the base effect chance?
« Last Edit: August 11, 2015, 12:50:02 PM by Plexa » Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #9 on: August 11, 2015, 02:51:15 PM »

Quote
Mia Jupiter power = 76
Killer Ape Jupiter Res = 127
Suppose to use elemental level - I believe pow and res only affect damage done? (Maybe Healing as well... but not sure if res counts for that? aka: I forget.)

Quote
Where might I find these values in the RAM?
Not stored in RAM... Just ROM, in the enemy data/class data.

For GS1, those banks are here:
08080EC8 = Enemy Stats
08084B1C = Classes

The vulnerabilities list is at +0x48 or +0x50... ... To get current PC's class, you can go to a PC's RAM data, and +0x129 should be it.
« Last Edit: August 11, 2015, 03:11:28 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #10 on: August 12, 2015, 12:52:17 AM »

Seems like it would be easier just to build a bank of useful data (since I can't see how the game looks up data within the ROM :) )
If you tell me what values vulnerability corresponds to in the editor I can populate the table myself. (I figure elemental levels are the values above elemental power)

One other question, if I use Mist (which can induce sleep) would that use the mercury elemental level (since mist is mercury) or jupiter elemental level (since sleep is a jupiter status). Editor seems to suggest mercury (which would make the most sense!)
« Last Edit: August 12, 2015, 01:00:25 AM by Plexa » Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #11 on: August 12, 2015, 09:45:54 AM »

Quote
Seems like it would be easier just to build a bank of useful data
Depending on the size of that data, I somewhat disagree...
Quote
(since I can't see how the game looks up data within the ROM :) )
The entire ROM is memory mapped to 0x08000000... unlike some systems that look them up in parts. (See old GB/SNES/DS/etc... And even so, in the case of DS at least, there's still a likely chance that you could still find the data you want from files loaded to RAM. Since that's what DS does before it can actually use the ROM data. I'm less experienced with the others, though.)

But anyway, here's something to get you started:

e1Ind = memory.readbyte(0x020309A0)
-- e1Class = memory.readbyte(0x020309A1) -- Always 0 (NPC class) for enemies.
vuln1 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x48)
vuln2 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x49)
vuln3 = memory.readbyte(0x08080EC8 + ((e1Ind - 8) * 0x54) + 0x4A)

-- pc0Index = memory.readbyte(0x02000628) --Always 0 for Isaac, 1-7 for the other PCs, respectively.
pc0Class = memory.readbyte(0x02000629)
pc0Vuln1 = memory.readbyte(0x08084B1C + (pc0Class * 0x54) + 0x50)
pc0Vuln2 = memory.readbyte(0x08084B1C + (pc0Class * 0x54) + 0x51)
pc0Vuln3 = memory.readbyte(0x08084B1C + (pc0Class * 0x54) + 0x52)

Hopefully I didn't make any mistakes anywhere? I would also suggest doing loop blocks, but since I'm a bit new to LUA at the moment, I skipped them.

(Note that in GS2, the indexes are displayed at the end of a PC/enemy 's RAM... probably because they switched those indexes from 8-bit to 16-bit.)
« Last Edit: August 12, 2015, 10:20:21 AM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #12 on: August 12, 2015, 12:08:47 PM »

The bank of data becomes manageable because of the limited number of fights we're interested in taking. For example, https://docs.google.com/spreadsheets/d/1IL1nYfjHz2A0pMrCdXkYf_f7yfKfLpBrg2Cq-r5xn-U/edit#gid=0 this is a complete list of every fight we take in the speedrun. On many of these we have nothing to proc (so their data doesn't need to be included), it's basically just bosses we want to stun/put to sleep. Beyond kraken we want to assassinate as many of those enemies as possible which is a small enough data bank :)

That said, I'll test out your code when I get a chance. And thanks for all your help :)
Logged
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2394

« Reply #13 on: August 12, 2015, 12:25:26 PM »

Sounds cool.  But there is still the question on how much time it would take to do one versus the other... Although, both could be close to the same amount of time, depending on what you have prepared. (But since I didn't have your list initially, this one would have been easier for me.)

And there's also the chance you may only need the vuln for the first enemy, if it's just bosses.
« Last Edit: August 12, 2015, 12:28:11 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...
Did you know? In English, you are suppose to capitalize the languages. (e.g. English is a proper noun.) Subjects like math, science, history can be left lower-cased unless they are a title. (Kind of like how you can say either "my mom" or "Mom" in "I went with (X) to the store.", except that I don't think languages are ever lower-cased in English.) In Spanish, both subjects and languages are left lower-cased. (I put this here because I've noticed people make this mistake quite often. And am curious if they know about this, and whether they use their way because they believe this grammar usage should have never been a thing?

Remember kids! In getting a job, it's not about what you know, it's about WHO you know! So start making friends with the people that work where you want to work. :) (Friend of a friend and volunteering count too, so keep that in mind.)[/si
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #14 on: August 12, 2015, 12:30:36 PM »

Theoretically we'd like to 1 shot the lizard king in Crossbone isle, but other than that yeah everything is just enemy 1. Since I might extend this to GS2 eventually (and GS2 demands different procs, in particular weaken/sour) your method would be shortest overall :)
« Last Edit: August 12, 2015, 12:32:10 PM by Plexa » Logged
View Profile
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Cbox
Today at 05:19:46 AM
Majora: Perfect. Thank you!
Today at 04:45:37 AM
Atrius: Also, you can put use [nobbc][/nobbc] to show bbcode without it being parsed.
Today at 04:22:03 AM
Atrius: The bbcode wasn't designed to handle "https://youtu.be/" links.  It should be fixed now.
Today at 01:06:01 AM
Majora: Read that sometimes SMF doesn't like YouTube's https links, seems to have the same issue with http as well
Today at 01:04:59 AM
Majora: Sorry lol, didn't realize it would embed the player into the chat. At least that works! tl;dr: embedded YouTube videos fail to appear in forum posts
Today at 01:04:07 AM
Majora: Just noticed this, not sure if it's already been mentioned but it looks like the forum is breaking embedded YouTube links in posts using BBCode [youtube][/youtube] tags
December 13, 2017, 09:19:38 PM
Fox: Okay, so that Summon Night games adds the fram number to the seed, before generating another seed via mul/add....  (GS1-GS3 never adds the fram number.) ... So um, that makes sense! ;  Summon Night:  ((seed + frame) * 0x343FD + 0x269E3C) >> 0x10 ; Which is also on the list here: https://en.wikipedia.org/wiki/Linear_congruential_generator
December 12, 2017, 11:10:45 PM
Fox: Yes, and there could be contests. Maybe ones where 1st/2nd/3rd place get a cash reward, but eh. Dunno.... Kind of thinking about making a topic about how people got their job, and what was their experience. (e.g. Did they use references of people already working in the job, and various other things.)
December 09, 2017, 04:24:14 AM
Majora: Import old forum posts for reference, perhaps take posts containing important info like documentation away from the old stickied forum post model and make them into their own pages on a site with an in-built search bar. Might help with SEO, too. If nothing else, perhaps whipping them into PDFs and hosting them via Scribd? The possibilities are boundless when it comes to restructuring a site
December 09, 2017, 04:20:02 AM
Majora: Just a nice idea to have even if it doesn't come to fruition. Updating, modernizing, always a good idea. Could probably do something pretty nifty using a good Wordpress theme
December 09, 2017, 04:15:45 AM
Majora: Would be kind of neat to do something like that for GSHC. Could change it up a bit to show all tweets/instagram posts/facebook posts/golden sun subreddit posts all in one sidebar. It would be cool in that it gives the site it's on (and the topic in general) appear more lively and active, which is a plus
December 09, 2017, 04:14:19 AM
Majora: That does sound interesting. One cool thing I've seen some sites use is a sort of unique take on a sidebar option that acts like a social media integration (like, "See GSHC's latest Tweets"). It displays activity from a variety of related sites, such as Reddit, Twitter, Instagram, etc.
December 09, 2017, 12:58:53 AM
Fox: And the way it'd work via code is not that all users would instantly get nicknames the minute you register... but rather, the moment you view a name if it doesn't have a nickname, it gets one. (My Thoughts.)
December 09, 2017, 12:53:55 AM
Fox: (I was thinking that it would be "Name (Nickname)" ... The nickname is what you first known the user as, and you can change that yourself... and the Name is what the user wants to be called... Something like that.
December 09, 2017, 12:47:56 AM
Fox: So like... for starters, one idea I had was to make it so anyone can name anyone... much like how it works on Skype, and you (the namer) would be the only one to see it, and such...
December 09, 2017, 12:45:02 AM
Fox: Would need to be carefully thought out and tested, though.
December 09, 2017, 12:43:02 AM
Fox: I'm thinking I could make it so that name changes can happen whenever... (Without any limit)... Since I believe there's a way to do it with minimum confusion. (I think.) Hmm....
December 09, 2017, 12:31:36 AM
Fox: (I mean an offline version... at least initially.)
December 09, 2017, 12:25:01 AM
Fox: Now that I have thought about it a bit more, would I be right to assume that GSHC would be one of the most interesting websites to administrate, or no? It's sad to see not much going on with it. == I almost want to make a concept website at some point. :D Anyway, how is everyone doing today?
December 06, 2017, 12:12:59 AM
Fox: Like... Start using Github or something... Do like how many of those other projects such as Citra (WIP 3DS Emulator) does. Etc.

Affiliates
Temple of Kraden Golden Sunrise
Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.074 seconds with 22 queries.