Game botting with ntr ?

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by hacksn5s4, May 7, 2016.

  1. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    So I've seen these Pokemon shiny hunting bots on YouTube they use motors to press the buttons but could you use ntr to put inputs from the bot into the game from a pc and have it read ram to see if moms shiny or not I just want this for fun
     
  2. kbmarinha

    kbmarinha GBAtemp Advanced Fan

    Member
    664
    195
    May 21, 2009
    Brazil
    Last edited by kbmarinha, May 7, 2016
    gamesquest1 likes this.
  3. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    some thing like this but instead of using a machine that presses the buttons on the 3ds send inputs to the 3ds
     
  4. Zan'

    Zan' 2F88744FEED717856386400A44BBA4B9CA62E76A32C715D4F

    Member
    386
    159
    Oct 8, 2015
    Depends on how the inputs are handled.
    But the console has to get the mechanical inputs into a code acceptable. So somewhere the oressed key has to be stored. By writing to that part you could effectively emulate a button press.
    Then you just do this like a macro in a while loop with chained presses. In between it can even read out data and check foe specific requirements.
     
  5. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    Last edited by hacksn5s4, May 7, 2016
  6. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of France :)
    Yes it's possible to inject inputs through a plugin.

    I've posted a working code in the thread for the NTR Debugger with Gateshark support.

    You just have to program your bot and use the previously mentioned code for injecting the inputs.
     
    cearp likes this.
  7. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    Thing is though I need away for it to read the ram so the bot knows what it's doing it needs to know when it encounters a mon needs to know if it's shiny or not
     
    Last edited by hacksn5s4, May 7, 2016
  8. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of France :)
    Read the ram is easy, but you need to know where to read and what is the value you're waiting for...
     
  9. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    Thing is what does it need to be coded in
     
  10. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of France :)
    If your speaking about the programming language, then you need to program the plugin in C (or C++).
     
  11. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    Are you planning to make some thing like this as well
     
  12. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of France :)
    I don't understand your question...

    If you're asking me about making a bot for a shiny hunting then no I won't.

    I don't mind helping with the mechanics of the bot, but there's no way I'm taking time to find where are the information we need in the ram.
    I don't need that, and I'm not even playing this game...
     
  13. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    I ment like for imputing into the 3ds
     
  14. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of France :)
    I already gave the functions needed for that in an other thread, but I'll paste them in it. ;)
     
  15. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    I wish more people knew about this think of all the boys that could be made
     
  16. Hking0036

    Hking0036 GBAtemp Fan

    Member
    400
    194
    Sep 15, 2015
    United States
    if you want to bot to get shiny pokemon why not just use pkhex and make one that passes a legality check? That way you're not killing your battery and you still get what you want, if you're willing to spend this much effort to get random ones you can expend significantly less and have whatever you want, still able to battle online.
     
  17. Nanquitas

    Nanquitas GBAtemp Addict

    Member
    2,151
    1,816
    Sep 29, 2015
    France
    South of 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();
        }
    }
    
     
    Azel and cearp like this.
  18. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    Because it would not be legit and it's fun to watch
     
  19. Hking0036

    Hking0036 GBAtemp Fan

    Member
    400
    194
    Sep 15, 2015
    United States
    it would be legit though, if it passes a legitimacy test then it is legit, regardless of if it's obtained in game or not in game. It just seems like an extra length to go for not much payoff.
     
  20. hacksn5s4
    OP

    hacksn5s4 Banned

    Banned
    4,332
    450
    Aug 12, 2015
    I
    its just fun to watch and cool