• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Script] Script help and maybe more

JordanB500

Former Pokemon League Champion
104
Posts
16
Years
  • Hello, i want to remove restrictions on legendary pokemon in the battle frontier.

    Edit: i altered the cut bush script to use a random number generator to determine if the cut bush is a dudowoodo still cant figure out how to make the wild pokemon have reduced hp.

    also if possible i want to have male/female only evolutions, and not related to scripting(at liest i dont think so) i want to add new tms in the empty ??? item slots excluding the one before the master ball

    if any of these are possible let me know
     
    Last edited:

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • Hello, i want to remove restrictions on legendary pokemon in the battle frontier.

    Check out this post.

    Edit: i altered the cut bush script to use a random number generator to determine if the cut bush is a dudowoodo still cant figure out how to make the wild pokemon have reduced hp.

    Spoiler:


    In order to change the starting HP of a wild Pokemon you need to generate the Pokemon, edit the HP in the RAM and then initiate the battle. Thankfully this is pretty easy to do with just a few script commands:

    Code:
    ...
    setwildbattle 0xB9 0xA 0x0 // Generates a level 10 Sudowoodo
    writebytetooffset 0x1 0x0202479A // Overwrites the Sudowoodo's current HP with 1
    dowildbattle // Begins the battle
    waitstate
    ...

    Here's a link to how the data structure of Pokemon is arranged and here's some info on where your party/ enemy's party is in the RAM. Since you're using Emerald, in order to find the correct spot in the RAM to edit, you just need to find the start point of the first opposing Pokemon (0x02024744) and then add 0x56 (86 in decimal) to reach the current HP. If the player is going up against higher level Sudowoodo with a possible total HP over 255 you will also need to change 0x0202479B in the RAM to 0x0 as it will need to use that extra byte to properly store the HP.

    If you don't want the Sudowoodo to have static HP (i.e its always at 1 HP) and instead want dynamic HP (e.g you want it to have half health or you want remove 5 HP after cutting it) you can make the HP dynamic by doing some variable maths.

    Here's how you can remove a set number from the Sudowoodo's current HP:

    Code:
    ...
    setwildbattle 0xB9 0xA 0x0 // Generates a level 10 Sudowoodo
    copybyte 0x020375D8 0x0202479A
    copybyte 0x020375D9 0x0202479B // Moving the enemy's current HP to variable 0x8000 in the RAM
    subvar 0x8000 0x5 // Removing 0x5 from variable 0x8000's value. Change this to alter how much HP is removed
    copybyte 0x0202479A 0x020375D8
    copybyte 0x0202479B 0x020375D9 // Moving variable 0x8000 to the enemy's current HP in the RAM
    dowildbattle // Begins the battle
    waitstate
    ...

    Here's how you can make the HP a fraction of its total just with scripting alone. It would probably be better to use ASM for something like this, but I felt like writing it out in script form~

    Code:
    ...
    setwildbattle 0xB9 0xA 0x0 // Generates a level 10 Sudowoodo
    copybyte 0x020375D8 0x0202479A
    copybyte 0x020375D9 0x0202479B // Moving the current HP to variable 0x8000 in the RAM
    setvar 0x8001 0x1 // This is your numerator
    setvar 0x8002 0x2 // This is your denominator
    setvar 0x8003 0x0 // Counter number 1: Helps keep track of where we are in relation to our chosen fraction. Just leave as 0x0.
    copyvar 0x8004 0x8000 // Counter number 2: Lets us know how many times we will repeat @loop
    goto @loop
    
    #org @loop
    comparevars 0x8003 0x8001 // Compares variables 0x8003 and 0x8001
    if 0x4 call @removehp // If our numerator is greater than or equal to counter 1, go to @removehp
    subvar 0x8004 0x1 // Removes 1 from counter 2
    compare 0x8004 0x0 // Check if counter 2 has finished
    if 0x1 goto @next // If this is true, exit the loop
    addvar 0x8003 0x1 // Add 1 to counter 1
    comparevars 0x8003 0x8002 // Compares counter 1 and the denominator
    if 0x5 goto @loop // If they are not equal to each other, continue the loop immediately
    setvar 0x8003 0x0 // If they are equal, reset counter 1
    goto @loop
    
    #org @removehp
    subvar 0x8000 0x1 // This will remove one HP from the generated Sudowoodo
    return
    
    #org @next
    copybyte 0x0202479A 0x020375D8
    copybyte 0x0202479B 0x020375D9 // Moving variable 0x8000 to the enemy's current HP in the RAM
    dowildbattle // Begins the battle
    waitstate
    ...

    Hopefully one of those is what you're looking for.
     

    JordanB500

    Former Pokemon League Champion
    104
    Posts
    16
    Years
  • yes it seems i did make a typo and ty however most of these things are above my level of scripting using vars and such

    this is a part of the modified script for cuttable trees/bushes


    msgbox 0x8290771 MSG_KEEPOPEN '"[buffer1] used [buffer2]!"
    closeonkeypress
    doanimation 0x2
    waitstate
    random 0x1 0x2
    compare LASTRESULT 0x0
    if 0x1 goto 0x8290710
    waitstate
    cry 0xb9 0x0
    waitcry
    wildbattle 0xb9 0xf 0x0
    compare LASTRESULT 0x0
    if 0x1 goto 0x29072b
    goto 0x8290710


    also im curious can i replace the "0x1 0x0202479A"
    with something like 0x5 or 0xA or any number? also where do you get 0x0202479a? it couldnt be an offset could it i dont think there exists an offset in emerald at that address afaik atliest in hex
     
    Last edited:

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • also im curious can i replace the "0x1 0x0202479A" with something like 0x5 or 0xA or any number?

    Yep, test it out and play around with some values to see the effect. All three of the script fragments I posted can have their effects changed just by changing one or two numbers that I've labeled in my post.

    also where do you get 0x0202479a? it couldnt be an offset could it i dont think there exists an offset in emerald at that address afaik atliest in hex

    That is the location of the enemy Pokemon's HP in Emerald's RAM, which is different to the ROM which you edit in hex editors, advance map and other tools. You can see the RAM in action by opening the memory viewer in VBA when you play your game.
     
    Last edited:
    Back
    Top