News:

The forum has been updated to SMF (2.1.3)!
Please be patient as we work to polish up the place and update features as we can.

Main Menu

Creating useful Lua Scripts

Started by Plexa, 08, August, 2015, 02:21:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Plexa

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
Quote0811CE94 = 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]
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
[/spoiler]

Daddy Poi's Oily Gorillas

#1
@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
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#2
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:
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. =/

Daddy Poi's Oily Gorillas

#3
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...
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#4
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

Daddy Poi's Oily Gorillas

#5
QuoteUPDATE 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.

QuoteShould 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 documentation08002054 = 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...
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

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.

Daddy Poi's Oily Gorillas

#7
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?)
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#8
Success!! Lua gets confused when the numbers are larger than 2^53, as your calculations verified. I split the RNG calculation up into
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.

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
QuoteVulnerability 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!
Quote from: Fox on 09, October, 2012, 11:52:55 AM
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?

Daddy Poi's Oily Gorillas

#9
QuoteMia 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.)

QuoteWhere 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.
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#10
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!)

Daddy Poi's Oily Gorillas

#11
QuoteSeems 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.)
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

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 :)

Daddy Poi's Oily Gorillas

#13
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.
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#14
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 :)

Plexa

#15
Just wrote the vulnerability stuff into the code so thanks for that! The current iteration of the GS Utility script can be found here for anyone who is curious: http://pastebin.com/mQQtTNH9

Daddy Poi's Oily Gorillas

#16
GS1 and GS2 use the same equation...

GS1's only effect to generate 3 random numbers was effect 67 - Inflicts seal. -- I haven't checked anything before this equation part...

Quoteele = memory.readbyte(0x02309a0)
You messed up the address... All looks nice, except plenty of duplicated code will likely make it look more messy. AKA: Sort of think that the ablade/wwand/mist functions could all be combined... sort of. And things like moving the
Quoteg = S
        g = RNB(g)*100
        g = bit.rshift(g,16)
down to where it is actually checked... aka:"        if kill >= g then"
Quoteif kill >= bit.rshift(RNB(S)*100,16) then
Might also help for readability.


Quotemath.floor(elu/2))
The real equation as it is in the game is (elu >> 1) or bit.rshift(elu,1) in the case of LUA... I put "floor" at the time because I thought more people would understand it over bitshifts.




*After posting, now sees that you edited your post... I guess there are no more issues?
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#17
Ah I actually found that error (which is why it was isolated to the ablade part) so I wonder how that crept back in :P probably a bad copy paste. Thanks for pointing that out! (I've fixed it on pastebin)

Porting this over to GS2 is just a matter of changing the addresses (and populating the enemy table :P) but seeing as Zetonegi (the guy doing most of the routing for that atm) doesn't need a script to work his magic, I'll probably improve this more before doing that.

You're right that the code is messy :) I'm no programmer, so my only objective was functionality. The script is tailored to helping with the speedrun route, so there's some funny if/then statements to account for that (they're basically dirty hacks because I couldn't work out an efficient way to check to see if Isaac was holding the assassin blade, or garet for that matter). You're right that the ablade/wwand etc stuff could be combined into a single function with a second argument to which is the probability of success.

Thank you for the advice though :)

Daddy Poi's Oily Gorillas

#18
Quote(I've fixed it on pastebin)
Where? (Looks the same to me.)

By the way, I am working on the refactoring at the moment... (With GS1 addresses)
    function enemy (S) -- Enemy Elemental Data Table
            elemInd = memory.readbyte(0x08080EC8 + ((S - 8) * 0x54) + 0x34)
            evele = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 4)
            emele = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 5)
            emale = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 6)
            ejule = memory.readbyte(0x08088E38 + (elemInd * 0x18) + 7)
            return evele, emele, emale, ejule
    end


Anyway... GS2's addresses are:
080B9E7C = Enemy Stats, 0x4C bytes/entry ; Elemental Index should be at +0x2A.
080C6684 = Enemy Elemental data, 0x18 bytes/entry

QuoteThank you for the advice though :)
You are welcome. Refactoring can be quite fun sometimes.


The rest of the refactoring may come later, if I decide to.
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...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

I combined the different proc functions into a single function as you suggested. The pastebin should be updated.