Thread: Development: Set Disobedience
View Single Post
  #1    
Old August 5th, 2010 (7:02 AM). Edited August 10th, 2011 by metapod23.
metapod23's Avatar
metapod23 metapod23 is offline
Hardened Trainer
     
    Join Date: Mar 2009
    Gender: Male
    Nature: Timid
    Posts: 673
    For a while I was hoping to figure out a way to make a Pokemon disobedient, a sort of reverse of the setobedience command. I tried experimenting with Mew to see if there was anything in his code that would make him disobedient, but couldn't find anything, and I'm looking for more of the trade disobedience (occasionally sleeping, using other attacks, etc.).

    Can anyone tell me if there was a way to create a custom ASM routine to set a specific Pokemon in your party as disobedient? Could you find the setobedience command and just change a few things, and create your own routine for setting a Pokemon to disobedient no matter what its level and what badges you've obtained? Any insight would be appreciated. I know I don't understand much about ASM, but I'm willing to do whatever possible to get this in, and I'm hoping it won't be too difficult, considering there's a command already in the game that does almost the same thing, but the opposite.

    And now a solution to this problem. This code was made by colcolstyles, all credit goes to him:

    Quote:
    Originally Posted by colcolstyles View Post
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global hijack
    
    	@ put at 0x0801D404
    	@ also put 0x0000 at 0x081D402
    
    main:
    	ldr r1, .ADDRESS
    	bx r1
    
    .align 2
    .ADDRESS:
    	.word	0x08720001
    That branches off to the new routine at '0x720000' (that address can be changed) which is:

    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global obedience
    
    main:
    	cmp r0, #0x97		@ if current attacker == Mew
    	beq disobey
    	cmp r0, #0x07		@ if current attacker == Squirtle
    	beq disobey
    	
    	mov r0, #0x01
    	ldr r1, .RESUME
    	bx r1
    	
    disobey:
    	ldr r1, .DISOBEY
    	bx r1
    	
    branchlink:
    	bx r3
    
    .align 2
    .RESUME:
    	.word	0x0801D42B
    .DISOBEY:
    	.word	0x0801D415	@ goes on to check obedient byte
    ^ Of course, you need to remove anything that says @ and whatever follows that - that's just explanation. With this you can make and Pokemon you want to be disobedient. It's really quite nifty.


    Here's another code you can apply. This one was designed by JPAN, all credit to him. This is a code causes certain Pokemon to be disobedient, but instead of being completely disobedient, they are also occasionally obedient. It actually gives you some incentive to train a disobedient Pokemon, which can add to the depth of the game.

    Code:
    .align 2
    .thumb
    /*to use this code, place 00 49 08 47 at 0x0801d3f4, and the reversed pointer to  where
    you put this code at 0x0801d3f8*/
        cmp r0, #0x5
        beq disobey_or_not
        cmp r0, #0x6 
        beq disobey_or_not    /*add more checks here for other pokemon*/
        ldr r1, mew_check
        bx r1
    mew_check:   .word 0x0801D403
    disobey_or_not: ldr r1, random_addr 
        ldrb r1, [r1]
        mov r0, #0xb4 /*change here the "perform attack" chance. percentage  is r0 divided by 256 times 100 */
        cmp r1, r0 /*aprox 70% chance of not performing an attack*/
        bgt is_obedient
        ldr r0, disobedient_ret_addr
        bx r0
    is_obedient:   mov r0, #0x1
        pop {r4-r7,pc}
    .hword 0x0000    
    random_addr: .word 0x03005000
    disobedient_ret_addr: .word 0x0801d415
    And now here's a code that allows you to choose when a Pokemon is and isn't obedient. With this code, you can set a Pokemon's obedience to a variable, and have it only obey when that variable is set. Pretty cool, right?

    All credit to this one goest to Jambo51:

    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global obedience
     
    main:
        cmp r0, #0x97
        beq disobey
        cmp r0, #0x05
        beq disobey
        cmp r0, #0x06
        beq disobey
     
        mov r0, #0x01
        ldr r1, .RESUME
        bx r1
     
    disobey:
        ldr r0, =0x00006200 @the variable you want to use
        push {lr}
        bl vardecrypt
        pop {r1}
        mov lr, r1
        ldrh r0, [r0]
        cmp r0, #0x00
        beq disobey2
     
        mov r0, #0x01
        ldr r1, .RESUME
        bx r1
     
    disobey2:
        ldr r1, .DISOBEY
        bx r1
     
    resume:
        ldr r1, .RESUME
        bx r1
     
    vardecrypt:
        ldr r1, .VARDEC
        bx r1
     
    .align 2
    .RESUME:
        .word    0x0801D42B
    .DISOBEY:
        .word    0x0801D415
    .VARDEC:
        .word    0x0806E455
    Lastly, a code to make a Pokemon only sometimes disobey unless a certain variable is set:

    Special thanks to thank colcolstyles, Jambo51, and JPAN for working on this for me! Thanks!

    So here's the routine:

    First place 00 49 08 47 at 0x0801D3F4, and the reversed pointer to the code below at 0x0801D3F8 (per JPAN's routine).

    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global obedience
     
    main:
        cmp r0, #0x97    @Mew's number, if you want it to disobey still
        beq disobey
        cmp r0, #0x05    @Pokemon you want to disobey only sometimes 
        beq disobey        (Charmeleon)
        cmp r0, #0x06    @Pokemon you want to disobey only sometimes         
        beq disobey        (Charizard)
        ldr r1, mew_check
        bx r1
    
    mew_check:
       .word 0x0801D403
     
    disobey:
        ldr r0, =0x00006199    @Variable you want to use
        push {lr}
        bl vardecrypt
        pop {r1}
        mov lr, r1
        ldrh r0, [r0]
        cmp r0, #0x00    @the value of the variable you want to cause the
        beq disobey2       Pokemon to sometimes disobey
         mov r0, #0x01
        ldr r1, .RESUME
        bx r1
    
    disobey2:
        ldr r1, random_addr 
        ldrb r1, [r1]
        mov r0, #0xcd    the number, divided by 256, that will be the
        cmp r1, r0          percentage of how often the Pokemon disobeys
        bgt is_obedient    (in this case, cd (205)/256 = 80% disobey)
        ldr r0, disobedient_ret_addr
        bx r0
     
    resume:
        ldr r1, .RESUME
        bx r1
     
    vardecrypt:
        ldr r1, .VARDEC
        bx r1
    
    is_obedient:   mov r0, #0x1
        pop {r4-r7,pc}
    .hword 0x0000
    
    .align 2
    .RESUME:
        .word    0x0801D42B
    .DISOBEY:
        .word    0x0801D415
    .VARDEC:
        .word    0x0806E455
    random_addr:
    	.word 0x03005000
    
    disobedient_ret_addr:
    	.word 0x0801d415
    __________________
    Reply With Quote