Golden Sun Hacking Community
July 22, 2018, 08:46:59 AM *
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 12897 times)
0 Members and 1 Guest are viewing this topic.

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #15 on: August 13, 2015, 11:35:08 AM »

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
« Last Edit: August 13, 2015, 01:26:57 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: 2412

« Reply #16 on: August 13, 2015, 02:38:25 PM »

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

Quote
ele = 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
Quote
        g = S
        g = RNB(g)*100
        g = bit.rshift(g,16)
down to where it is actually checked... aka:"        if kill >= g then"
Quote
        if kill >= bit.rshift(RNB(S)*100,16) then
Might also help for readability.


Quote
math.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?
« Last Edit: August 13, 2015, 02:45:08 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...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #17 on: August 13, 2015, 02:53:24 PM »

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 :)
« Last Edit: August 13, 2015, 02:57:55 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: 2412

« Reply #18 on: August 13, 2015, 04:26:37 PM »

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

Quote
Thank 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.
« Last Edit: August 13, 2015, 06:27:37 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...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #19 on: August 14, 2015, 06:53:48 AM »

I combined the different proc functions into a single function as you suggested. The pastebin should be updated.
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: 2412

« Reply #20 on: August 14, 2015, 11:41:48 AM »

Awesome! It's looking even better now... I do see room for more optimization... maybe... Like have the effectproc data collected before the loop, and process the value along with the random number within the loop...
(However, it might not matter(?), because a max of 500 (100x5) loops isn't much. Then again, this is for each frame (GBA should be just short of 60 frames/sec.), so I don't know...)
If you do decide to go this route, I can see the unleash function having a second arg for chance, and that one being called twice per while loop. One to process unleash, and the other to process with the chance value retrieved from effectproc.
I recommend also having a small infinite loop (while true do) that the vba.frameadvance() would be in... and in that loop, to also have draw commands... and specific checks for when data should be collected (i.e. Have a counter every time it reaches... say 2-60, or when the RNG changes (As a second cond. since you will have it on display), set counter to 0 and collect. Although numbers like the RNG should probably be collected every frame.)... That way, we could have a small amount of operations per frame.
 Would also have been nice if LUA supported pre/post-increment (Like C++/C#/Java....), though, unfortunately it doesn't seem to. Oh well.

I do have two bug-related questions, though.

1. Is this part fully correct?
Quote
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
*Looks back at my documentation to see I put in "0811A188 = List living PCs (Arg=1), or enemies (Arg=2) ; I think?" (Function that is called from the Flee Check function.)
*Also looks at the function's assembly real quick to see that it retrieves the HP values to see if they're alive or not.

So... If you KO some enemies, this might turn out incorrect, since those should be removed from the list, I believe.  Same for the Party side as well.


2. Possible mismatch with Elm == U check?
0 = Venus, 1 = Mercury, 2= Mars, 3 = Jupiter,
0 = Isaac, 1 = Garet, 2 = Ivan, 3 = Mia
Quote
        if Elm == U then
                elmaff = 5
        else
                elmaff = 0
        end
Try something more like...
if memory.readbyte(0x080844EC + (U * 0xB4) + 0x92 + Elm) == 54 then elmaff = 5
(Or you could divide by 10 with flooring. -- That way it could also be compatible with hacks... as long as the table wasn't moved.)
« Last Edit: August 14, 2015, 03:42:04 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...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile

Regular Member
**

Coins: 2
Offline Offline

Posts: 135

« Reply #21 on: August 16, 2015, 12:10:39 AM »

Regarding average level; you're correct that if you kill something that things it might return incorrect results. On the other hand for our purposes we just don't flat out fight anything non-essential so that's never an issue.

I'll replace the elmaff code with yours, you're correct that it doesn't work :P

Placing the functions outside of the while true do loop makes the script stop working :(
« Last Edit: August 16, 2015, 12:15:20 AM by Plexa » Logged
View Profile
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Cbox
Yesterday at 09:19:06 PM
Salanewt: Time to upload that "EXP gain when KO'd" patch I made a month ago.
Yesterday at 09:18:48 PM
Salanewt: Oh hey, the site's back up!
July 18, 2018, 10:49:52 PM
roger: I can post but it goes to an error page when I submit.
July 18, 2018, 05:24:12 PM
zman9000: Site is back WOO!
May 09, 2018, 12:35:37 AM
KyleRunner: The "Start In" field is not editable... I'll try making new shortcuts
May 08, 2018, 09:51:08 PM
Fox: If all else fails, you canmake new Shortcuts to do the same thing.
May 08, 2018, 09:49:53 PM
Fox: Export Properties > Shortcut (Tab) > Target / Start In ; Target (for Export) should be: (filename) 0 , and for Import: (filename) 1
May 08, 2018, 08:52:00 PM
KyleRunner: I can't change the path in properties menu...
May 08, 2018, 01:27:19 AM
Fox: You may need to edit something in properties, though... so it uses the exe file in the same directory.
May 08, 2018, 01:24:59 AM
Fox: It is suppose to be a shortcut, yes.
May 03, 2018, 11:48:05 PM
KyleRunner: Fox, the "export" function in your text editor is just a shortcut... Could you please fix it?
May 02, 2018, 09:53:45 PM
KyleRunner: I come here everyday. I'm working on a Portuguese translation, and the people here help me a lot.
May 02, 2018, 08:56:07 AM
Drake baku: My feel as well, I posted a little as well since my return, but silence was all that followed... At least the forum is a great source for data when hacking GS/ GS2, currently looking for something I have read a long time ago cause my PP recovery psy is not working
May 01, 2018, 09:58:04 AM
Fox: I am thinking a lot of this might be because of Discord?
May 01, 2018, 09:56:08 AM
Fox: Yeah, this forum is more dead than ever before.  February and April have 0 new topics. (All other months prior have more.) And March has lowest number of new posts. (It'd be dumb to count the very first month this site was created.)
April 25, 2018, 09:02:13 PM
Fox: Yes. The best tool is a hex editor. Well.... VBA, VBA-SDL-H, no$gba Debugger, GBATEK, and my documentation.... to use these to learn how the code/data works. Best method because it maximizes your editing ability... and then there is my program gsmagic that I was working on. Still in its early stages, though. (Even after year(s).)
April 25, 2018, 04:21:58 PM
Xendrox D: *exept tla editor.
April 25, 2018, 04:21:29 PM
Xendrox D: is there any other tool for hacking gs?
April 23, 2018, 09:26:27 PM
Atrius: Rarely, but not never.
April 23, 2018, 08:01:48 AM
Drake baku: Can it be, the god who created the editor, atrius. I heard you never came back online here anymore

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.048 seconds with 22 queries.