The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script FR - Counting how many gym badges the player currently has?

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 November 3rd, 2018 (7:01 AM).
frabulator's Avatar
frabulator frabulator is offline
 
Join Date: Feb 2018
Posts: 44
Is there a way to count how many gym badges the player currently has in Fire Red? I have looking into the script of the vicotry road guards and found the flags for (I assume) the badges. How would I generate a counter that counts if the player has, say, badge 1 and badge 5, and then does something because the user has 2 badges?

Code:
#org 0x1A796E
textcolor 0x0
applymovement 0x8009 0x81A75E7
waitmovement 0x0
copyvar 0x8000 0x4001
compare 0x8000 0x1
if 0x1 goto 0x81A79D8
compare 0x8000 0x2
if 0x1 goto 0x81A79E7a
compare 0x8000 0x3
if 0x1 goto 0x81A79F6
compare 0x8000 0x4
if 0x1 goto 0x81A7A05
compare 0x8000 0x5
if 0x1 goto 0x81A7A14
compare 0x8000 0x6
if 0x1 goto 0x81A7A23
compare 0x8000 0x7
if 0x1 goto 0x81A7A32
compare 0x8000 0x8
if 0x1 goto 0x81A7A41
end
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old November 3rd, 2018 (7:47 AM).
PITink PITink is offline
 
Join Date: Oct 2018
Posts: 7
I don't have many experience with variables in Pokémon Scripts, but in theory it should work if you add +1 to a variable after each gym battle. Then just check the variable's value with the new script and continue the script how you want it to be.
I can't tell you much about it, but I hope I could help though
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old November 3rd, 2018 (8:39 AM).
frabulator's Avatar
frabulator frabulator is offline
 
Join Date: Feb 2018
Posts: 44
Quote:
Originally Posted by PITink View Post
I don't have many experience with variables in Pokémon Scripts, but in theory it should work if you add +1 to a variable after each gym battle. Then just check the variable's value with the new script and continue the script how you want it to be.
I can't tell you much about it, but I hope I could help though
Thats what I was thinking as well, however I do not know how to create a variable in pokemon scripts. In VB its easy enough as 'dim vr as variable = 0" and then "vr = vr +1". But in Pokescripts, I'm lost.
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old November 3rd, 2018 (10:09 AM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by frabulator View Post
Thats what I was thinking as well, however I do not know how to create a variable in pokemon scripts. In VB its easy enough as 'dim vr as variable = 0" and then "vr = vr +1". But in Pokescripts, I'm lost.
Yeah, pokescripting isn't a programming language and you can only use the defined commands. You don't have to declare any variables. They're all global, and all of the non-temporary ones will retain their value through saves. In scripting, to do arithmetic and variable logic, you need to use the scripting commands. So to add or subtract there are specific commands like addvar and subvar that you need to use.


To setup a way to count:
Quote:
setvar 0x8000 0x0 ' set the value of the variable to 0, so we can start counting from 0

checkflag 0xbadge1
if true call @incrementvar
checkflag 0xbadge2
if true call @incrementvar
checkflag 0xbadge3
if true call @incrementvar
...
To check amount of badges earned after you've counted:
Quote:
compare 0x8000 0x1
if 0x1 goto @onebadge
...
Incrementing a variable
Quote:
#org @incrementvar
addvar 0x8000 0x1
return

I would recommend breaking it down into these 3 parts. Because later on, you could just do something like, "call 0xaddress_for_count_badges" and conserve ROM space.
__________________
...
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old November 3rd, 2018 (12:25 PM).
frabulator's Avatar
frabulator frabulator is offline
 
Join Date: Feb 2018
Posts: 44
Quote:
Originally Posted by FBI View Post
Yeah, pokescripting isn't a programming language and you can only use the defined commands. You don't have to declare any variables. They're all global, and all of the non-temporary ones will retain their value through saves. In scripting, to do arithmetic and variable logic, you need to use the scripting commands. So to add or subtract there are specific commands like addvar and subvar that you need to use.


To setup a way to count:


To check amount of badges earned after you've counted:


Incrementing a variable



I would recommend breaking it down into these 3 parts. Because later on, you could just do something like, "call 0xaddress_for_count_badges" and conserve ROM space.


This is perfect! You rock! Thank you very much!
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
Thread Tools

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:14 AM.