ROM Hack Game botting with ntr ?

hacksn5s4

Banned!
OP
Banned
Joined
Aug 12, 2015
Messages
4,332
Trophies
0
XP
1,292
Country
h
So here the code I thought about based on ctrulib's HID implementation:
Code:
#define BIT(x) (1 << x)


/* hidSharedMem can be 0x10000000, 0x10001000, 0x10002000 (maybe even 0x10003000 but didn't see the case until now)
** the address can be different between games
** I don't know for now how to retrieve it automatically so you must define the good one manually
*/
vu32    *hidSharedMem = (u32 *)0x10002000;
u32      kDown = 0;

enum
{
    KEY_A       = BIT(0),       ///< A
    KEY_B       = BIT(1),       ///< B
    KEY_SELECT  = BIT(2),       ///< Select
    KEY_START   = BIT(3),       ///< Start
    KEY_DRIGHT  = BIT(4),       ///< D-Pad Right
    KEY_DLEFT   = BIT(5),       ///< D-Pad Left
    KEY_DUP     = BIT(6),       ///< D-Pad Up
    KEY_DDOWN   = BIT(7),       ///< D-Pad Down
    KEY_R       = BIT(8),       ///< R
    KEY_L       = BIT(9),       ///< L
    KEY_X       = BIT(10),      ///< X
    KEY_Y       = BIT(11),      ///< Y
    KEY_CPAD_RIGHT = BIT(28),   ///< Circle Pad Right
    KEY_CPAD_LEFT  = BIT(29),   ///< Circle Pad Left
    KEY_CPAD_UP    = BIT(30),   ///< Circle Pad Up
    KEY_CPAD_DOWN  = BIT(31),   ///< Circle Pad Down

};

u32 hidCheckSectionUpdateTime(vu32 *sharedmem_section, u32 id)
{
    s64 tick0 = 0;
    s64 tick1 = 0;

    if (id==0)
    {
        tick0 = *((u64 *)&sharedmem_section[0]);
        tick1 = *((u64 *)&sharedmem_section[2]);
        if (tick0 == tick1 || tick0 < 0 || tick1 < 0)
            return 1;
    }
    return 0;
}

void scanHID(void)
{
    u32 id = 0;
    kDown = 0;
    id = hidSharedMem[4];

    if (id > 7)
        id = 7;
    if (hidCheckSectionUpdateTime(hidSharedMem, id) == 0)
        kDown = hidSharedMem[10 + id * 4];
}

void    editMemoryRights(void)
{
    int i;

    for (i = 0; i < 8; i++)
        rtCheckRemoteMemoryRegionSafeForWrite(getCurrentProcessHandle(), (u32)hidSharedMem + (10 + i * 4),  4);
}

void    setHID(u32 keys)
{
      u32 id;

      id = hidSharedMem[4];
      if(id > 7)
        id = 7;
    hidSharedMem[10 + id * 4] |= keys;
}

u32    hidKeysDown()
{
    return(kDown);
}


Code:
void    send_key(u32 keys)
{
    setHID(keys);
}

void    my_super_bot(void)
{
    editMemoryRights();
    //Press L + A +B to exit the loop
    while (hidKeysDown() != (KEY_A | KEY_B | KEY_L))
    {
         //send A
        send_key(KEY_A);
        //wait 1s
        svcSleep(1000000000);
        //send B
        send_key(KEY_B);
        //wait 1s
        svcSleep(1000000000);
        //send A
        send_key(KEY_A);
        //wait 10s
        svcSleep(10000000000);
        scanHID();
    }
}
ow do i use this code though i just want to messaround with it first
 

Zan'

2F88744FEED717856386400A44BBA4B9CA62E76A32C715D4F
Member
Joined
Oct 8, 2015
Messages
387
Trophies
0
Age
31
XP
261
Country
This is def doable through the NTR client but would be a nightmare to write.
well doing this is better then wasting money on aundios and servo motors etc
It will be a pain to write though.
But creating a mechanical bot will not be less pain either.
Doing the running part of it won't be the problem. You can just write a left / right key input.
The problem will be to find the mem Region of the state (battle/overworld). (Maybe a bool)
The problem is there will probably not be an easy way of checking shiny or not. (This can possibly be taken from the graphical memory if you check the texture. They have to be somewhat similar. Possibly all shiny texture include "s" in the end of the string.)

Basic layout would be
While L/R not pressed
While state==overworld
Input left
Check state
Input right
Check state
endwhile
//inbattle
determine pokemon
If shiny
While state battle
Inputs for ballthrow
Check state
Endwhile
Else
While state battle
Inputs for run
Check state
Endwhile
Endif
Endwhile
 
Last edited by Zan',
  • Like
Reactions: Wolfvak

Azel

Well-Known Member
Member
Joined
Dec 16, 2014
Messages
632
Trophies
0
Age
40
XP
646
Country
France
So here the code I thought about based on ctrulib's HID implementation:
Code:
#define BIT(x) (1 << x)


/* hidSharedMem can be 0x10000000, 0x10001000, 0x10002000 (maybe even 0x10003000 but didn't see the case until now)
** the address can be different between games
** I don't know for now how to retrieve it automatically so you must define the good one manually
*/
vu32    *hidSharedMem = (u32 *)0x10002000;
u32      kDown = 0;

enum
{
    KEY_A       = BIT(0),       ///< A
    KEY_B       = BIT(1),       ///< B
    KEY_SELECT  = BIT(2),       ///< Select
    KEY_START   = BIT(3),       ///< Start
    KEY_DRIGHT  = BIT(4),       ///< D-Pad Right
    KEY_DLEFT   = BIT(5),       ///< D-Pad Left
    KEY_DUP     = BIT(6),       ///< D-Pad Up
    KEY_DDOWN   = BIT(7),       ///< D-Pad Down
    KEY_R       = BIT(8),       ///< R
    KEY_L       = BIT(9),       ///< L
    KEY_X       = BIT(10),      ///< X
    KEY_Y       = BIT(11),      ///< Y
    KEY_CPAD_RIGHT = BIT(28),   ///< Circle Pad Right
    KEY_CPAD_LEFT  = BIT(29),   ///< Circle Pad Left
    KEY_CPAD_UP    = BIT(30),   ///< Circle Pad Up
    KEY_CPAD_DOWN  = BIT(31),   ///< Circle Pad Down

};

u32 hidCheckSectionUpdateTime(vu32 *sharedmem_section, u32 id)
{
    s64 tick0 = 0;
    s64 tick1 = 0;

    if (id==0)
    {
        tick0 = *((u64 *)&sharedmem_section[0]);
        tick1 = *((u64 *)&sharedmem_section[2]);
        if (tick0 == tick1 || tick0 < 0 || tick1 < 0)
            return 1;
    }
    return 0;
}

void scanHID(void)
{
    u32 id = 0;
    kDown = 0;
    id = hidSharedMem[4];

    if (id > 7)
        id = 7;
    if (hidCheckSectionUpdateTime(hidSharedMem, id) == 0)
        kDown = hidSharedMem[10 + id * 4];
}

void    editMemoryRights(void)
{
    int i;

    for (i = 0; i < 8; i++)
        rtCheckRemoteMemoryRegionSafeForWrite(getCurrentProcessHandle(), (u32)hidSharedMem + (10 + i * 4),  4);
}

void    setHID(u32 keys)
{
      u32 id;

      id = hidSharedMem[4];
      if(id > 7)
        id = 7;
    hidSharedMem[10 + id * 4] |= keys;
}

u32    hidKeysDown()
{
    return(kDown);
}


Code:
void    send_key(u32 keys)
{
    setHID(keys);
}

void    my_super_bot(void)
{
    editMemoryRights();
    //Press L + A +B to exit the loop
    while (hidKeysDown() != (KEY_A | KEY_B | KEY_L))
    {
         //send A
        send_key(KEY_A);
        //wait 1s
        svcSleep(1000000000);
        //send B
        send_key(KEY_B);
        //wait 1s
        svcSleep(1000000000);
        //send A
        send_key(KEY_A);
        //wait 10s
        svcSleep(10000000000);
        scanHID();
    }
}
Wait. that means we can remap stuff to C-Stick un Kid Icarus Uprising now then?!
 

hacksn5s4

Banned!
OP
Banned
Joined
Aug 12, 2015
Messages
4,332
Trophies
0
XP
1,292
Country
It will be a pain to write though.
But creating a mechanical bot will not be less pain either.
Doing the running part of it won't be the problem. You can just write a left / right key input.
The problem will be to find the mem Region of the state (battle/overworld). (Maybe a bool)
The problem is there will probably not be an easy way of checking shiny or not. (This can possibly be taken from the graphical memory if you check the texture. They have to be somewhat similar. Possibly all shiny texture include "s" in the end of the string.)

Basic layout would be
While L/R not pressed
While state==overworld
Input left
Check state
Input right
Check state
endwhile
//inbattle
determine pokemon
If shiny
While state battle
Inputs for ballthrow
Check state
Endwhile
Else
While state battle
Inputs for run
Check state
Endwhile
Endif
Endwhile
idk if you could have it detect the light thats on the bottom screen cause when theres a shiny its black longer the machine bots use light sensors to do that you could have code that makes it detect the light of the bottom screen or detect which model is loaded or detect if the shiny value of the mon matches it of your save file
 
Last edited by hacksn5s4,

Zan'

2F88744FEED717856386400A44BBA4B9CA62E76A32C715D4F
Member
Joined
Oct 8, 2015
Messages
387
Trophies
0
Age
31
XP
261
Country
idk if you could have it detect the light thats on the bottom screen cause when theres a shiny its black longer the machine bots use light sensors to do that you could have code that makes it detect the light of the bottom screen
But if you have a guaranteed readout frm the ram, why would you do it the stupid way of measuring and only having a chance to be correct? It's also a lot more resource heavy by measuring.
And that would mean you would have to pseudo render the gpu ram to determine this. Which would require a lot more work.
There are mutiple good ways of checking it. Either way you need to find the region.
You could even read out tid / sid to calculate tsv and readout the encounter pid to calc psv and check for a match.

Or check the GPU of currently loaded things (probably the easiest)

Also possible would be checking liaded sounds.

(And by that I mean if the sound is played it has to be loaded. You don't check the sound output with the bot [that would be over the top] but just if the shiny sparkles sound was loaded.)
 
Last edited by Zan',

hacksn5s4

Banned!
OP
Banned
Joined
Aug 12, 2015
Messages
4,332
Trophies
0
XP
1,292
Country
But if you have a guaranteed readout frm the ram, why would you do it the stupid way of measuring and only having a chance to be correct? It's also a lot more resource heavy by measuring.
And that would mean you would have to pseudo render the gpu ram to determine this. Which would require a lot more work.
There are mutiple good ways of checking it. Either way you need to find the region.
You could even read out tid / sid to calculate tsv and readout the encounter pid to calc psv and check for a match.

Or check the GPU of currently loaded things (probably the easiest)

Also possible would be checking liaded sounds.

(And by that I mean if the sound is played it has to be loaded. You don't check the sound output with the bot [that would be over the top] but just if the shiny sparkles sound was loaded.)
it would just read the ram to know if its shiny and if its in a battle or not
 

Metab

Well-Known Member
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
27
Location
Where dat ass is
XP
289
Country
I am probably miss informed but I thought you could just use save editors for shinys? or do they not accept those online/these are special somehow?
 

hacksn5s4

Banned!
OP
Banned
Joined
Aug 12, 2015
Messages
4,332
Trophies
0
XP
1,292
Country
I am probably miss informed but I thought you could just use save editors for shinys? or do they not accept those online/these are special somehow?
you can but its fun to watch a bot do it and its not legit if you make it with a program and you could also use it for other games and to use gamecube controllero n smash
 
Last edited by hacksn5s4,

jimmyleen

Well-Known Member
Member
Joined
Feb 28, 2016
Messages
1,171
Trophies
0
XP
684
Country
Wouldn't it be better to create a app for the 3ds that the user can use to create bots? By that I mean create a app that looks like the old fbi layout but for creating bots directly on the 3ds or on Windows os.
 
Last edited by jimmyleen,

Metab

Well-Known Member
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
27
Location
Where dat ass is
XP
289
Country
you can but its fun to watch a bot do it and its not legit if you make it with a program and you could also use it for other games and to use gamecube controllero n smash
Fair enough, but I believe it is very possible (and easy, from what ive seen) to make legit looking shinys that are indistinguishable. Just have to make sure the way it was caught or whatever could have naturally occured in the game
 

Metab

Well-Known Member
Member
Joined
Mar 23, 2013
Messages
155
Trophies
0
Age
27
Location
Where dat ass is
XP
289
Country
Shouldn't that be "if you don't know what you're doing"?
I believe hes saying its impossible to knwo if the shiny is legit or generated if you know what youre doing (aka set everything up so that it could have naturally occured, then there is no way to tell)
If you didn't know it would get fucked up because the game would know it was impossible to catch in the instance you said it was caught in the save editor
 

jimmyleen

Well-Known Member
Member
Joined
Feb 28, 2016
Messages
1,171
Trophies
0
XP
684
Country
I believe hes saying its impossible to knwo if the shiny is legit or generated if you know what youre doing (aka set everything up so that it could have naturally occured, then there is no way to tell)
If you didn't know it would get fucked up because the game would know it was impossible to catch in the instance you said it was caught in the save editor

Understood
 
General chit-chat
Help Users
    SylverReZ @ SylverReZ: Hope they made lots of spaget