Golden Sun Hacking Community
October 17, 2017, 01:28:10 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 9570 times)
0 Members and 2 Guests 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: 2376

« 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...
*Cross my fingers and hope we have Big Brother All-Stars next year... with Paulie & Cody Califorie(sp?)... and Vanessa & Tiffany Rousso.... Would be fun? :P Especially if one of the boys got evicted early since there's usually some all-guy alliance in there, right?
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: 2376

« 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...
*Cross my fingers and hope we have Big Brother All-Stars next year... with Paulie & Cody Califorie(sp?)... and Vanessa & Tiffany Rousso.... Would be fun? :P Especially if one of the boys got evicted early since there's usually some all-guy alliance in there, right?
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: 2376

« 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...
*Cross my fingers and hope we have Big Brother All-Stars next year... with Paulie & Cody Califorie(sp?)... and Vanessa & Tiffany Rousso.... Would be fun? :P Especially if one of the boys got evicted early since there's usually some all-guy alliance in there, right?
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:57:26 AM
AZVRE: Im pretty okay, what about you?
Yesterday at 01:17:14 AM
Fox: I think the nine is doing a cirno on me, though... Anyway, how is everyone doing today?
Yesterday at 01:12:20 AM
Fox: onesixtwo*
Yesterday at 01:12:00 AM
Fox: Okay... Meanwhile... ah... 162 being a number that has made itself known to me.... I look at the relationships of the numbers.... 162  1+6+2 = 9 ; onesizetwo = alphabetical order = 9 characters ; Distance apart analysis: os = 4 = 1[6][2] , st = 1 = [1]6[2] , ot = 5 = [1][6]2 ; ost = original sound track?
October 15, 2017, 06:31:17 PM
AZVRE: ah okay :D i thought i caused some trouble
October 14, 2017, 07:49:16 AM
Fox: Oh i know... You were messing with yours, and the description says mine. It's kind of a funny bug. :P
October 13, 2017, 08:18:31 PM
AZVRE: I did not edit your profile tho. Just to erase that confusion ^^"
October 12, 2017, 04:49:56 AM
Fox: e.g. this art = http://forum.goldensunhacking.net/Themes/Jupiter/images/catbg.gif (etc.)
October 12, 2017, 04:48:58 AM
Fox: I have a question: Where did the art for the headers come from? (Like the backgrounds to each of these things... "Affiliates", etc... Asking just incase it inspires me to do something... but if Charon made it, then that's cool too.
October 11, 2017, 04:23:02 AM
FoxWas thinking about having something for the editor anniversary, but I believe I had to change my mind....
October 10, 2017, 12:58:36 PM
Fox: That's alright. ;       @AZVRE's profile: "Current Activity:  Editing the profile of Fox." ...Eh... That looks weird.
October 07, 2017, 11:45:16 PM
Atrius: Sorry about that, the auto bot detection is still working, but it also requires an admin to visit the site regularly.
October 04, 2017, 04:17:40 AM
Fox: Yeah, it does bring a small amount of activity. Not good quality activity, but it's still activity, nonetheless.  Now if we can get them to randomly post pictures and vdeios!
October 04, 2017, 02:10:48 AM
Majora: If nothing else, I like how they're copying the content of real posts at random. Interesting to see how they adapt to seem more authentic
October 03, 2017, 08:29:38 PM
Fox: medico6601 = Most likely another bot. :(
September 26, 2017, 03:32:24 PM
Fox: by ten* Excuse me.
September 26, 2017, 03:32:12 PM
Fox: Oh yes... Also multiply all levels by two. (So actually, an adept will have levels of 54, 3, 2, and 1, rather than 5, 0, 0, 0.... if going by those.)
September 26, 2017, 03:29:07 PM
Fox: ...I mean the theory also saves space on the Status Screen.
September 26, 2017, 03:26:11 PM
Fox: Random/fun concept theory: What if we got rid of ePow/eRest, and just made eLevel do everything. :P (A process of cleaning stuff up... Though, could make things less versatile. - Like, if a Djinni add 1 eLevel = Okay, that's understood... by why specifically +5 on the ePow/eRes (Rhetorical))
September 23, 2017, 04:42:08 AM
Fox: Oh nevermind, it does... but I swear I saw that a minute ago.

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