Golden Sun Hacking Community
December 16, 2017, 08:44:59 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 10363 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: 2394

« 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...
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 #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: 2394

« 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...
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 #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: 2394

« 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...
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 #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
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.055 seconds with 22 queries.