The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script Script help and maybe more

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old October 9th, 2018 (7:51 AM). Edited October 9th, 2018 by JordanB500.
JordanB500's Avatar
JordanB500 JordanB500 is offline
Former Pokemon League Champion
 
Join Date: Jan 2008
Location: Independence MO
Age: 36
Gender: Male
Nature: Gentle
Posts: 100
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
__________________




Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old October 12th, 2018 (4:51 AM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
Quote:
Originally Posted by JordanB500 View Post
Hello, i want to remove restrictions on legendary pokemon in the battle frontier.
Check out this post.

Quote:
Originally Posted by JordanB500 View 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:
Dudowoodo? Has science gone too far?


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.
__________________
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old October 17th, 2018 (5:29 AM). Edited October 17th, 2018 by JordanB500.
JordanB500's Avatar
JordanB500 JordanB500 is offline
Former Pokemon League Champion
 
Join Date: Jan 2008
Location: Independence MO
Age: 36
Gender: Male
Nature: Gentle
Posts: 100
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
__________________




Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old October 17th, 2018 (6:16 AM). Edited October 17th, 2018 by DrFuji.
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
Quote:
Originally Posted by JordanB500 View Post
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.

Quote:
Originally Posted by JordanB500 View 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.
__________________
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old October 17th, 2018 (3:21 PM).
JordanB500's Avatar
JordanB500 JordanB500 is offline
Former Pokemon League Champion
 
Join Date: Jan 2008
Location: Independence MO
Age: 36
Gender: Male
Nature: Gentle
Posts: 100
i see now all i need is a way to implement a male/female only evolution method
__________________




Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:17 AM.