• 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.

How much freedom do I have when changing things in the code?

  • 23
    Posts
    1
    Years
    • Seen Jan 30, 2024
    Exactly how easy is it to break the game and make it unable to build when editing the code of the game? Like if I wanted to add the Fairy typing or new attacks and abilities, could I just add them to the arrays or are the a ton of interconnected parts that I have to change as well? Also what about changing the number values of things? If I edit the value of something, how much is that going to affect things?
     

    Lunos

    Random Uruguayan User
  • 3,116
    Posts
    15
    Years
    How easy is it to break the game and make it unable to build when editing the code of the game?
    Very easy or very hard depending on whether you're capable of reading and understanding the project's code, and the changes you make to it.
    Like if I wanted to add the Fairy typing or new attacks and abilities, could I just add them to the arrays or are the a ton of interconnected parts that I have to change as well?
    Well, there aren't just arrays involved in the process, but yeah, the majority of the work involves extending existing arrays/data tables.

    I'll give you an example; the quick notes I tend to re-post whenever someone asks how to add new moves to Pokeemerald:
    Lunos said:
    Define your move in include/constants/moves.h.
    Add its stats in src/data/battle_moves.h.
    Add the name and description it'll have In Game in src/data/text/move_names.h and src/data/text/move_descriptions.h.

    If you want to add a custom effect, then:
    Define it in include/constants/battle_move_effects.h.
    Define a Battle Script for it in the list at data/battle_scripts_1.s, and then proceed to write a battlescript down below following the lead of the other Battle Scripts in that file.
    Adjust the stats of your move in src/data/battle_moves.h appropriately afterward.

    Animations go in data/battle_anim_scripts.s.
    There's a table of moves where you have to put your move following the order in include/constants/moves.h, and then you write the animation script somewhere below.
    It's preferable to put things on the same spot for both, the table and the list of animation scripts, in order to keep things clean, so if your move comes after Psycho Boost, you'd add an entry for it in the table and also its animation script right below Psycho Boost's.
    Also what about changing the number values of things? If I edit the value of something, how much is that going to affect things?
    It depends completely on what value you're talking about specifically, but it will only affect the parts of the codebase that use it.

    The project has many constant labels defined. These are labels assigned to specific numerical values that serve to make the code more readable, and at times, easier to modify without inducing too many headaches.
    To put an example, there's a constant that represents the value of the level that a Pokémon Egg from the Daycare hatches at.
    This constant is called EGG_HATCH_LEVEL, it's located in include/constants/daycare.h and has a default value of 5.
    As far as the compiler is concerned, when you ask it to build a ROM for you, it will replace all instances of EGG_HATCH_LEVEL with "5".
    If you were to change that constant's value to 10, the code would then start to put 10s instead of 5s, and due to the parts of the code in which that constant (or rather its value as far as the machine goes) is used, that means you would start to see Pokémon Eggs hatching at Lv10 inside of the game.

    This is like, a thorough but extremely simple explanation.
    So yeah, "how much is changing a value going to affect things" depends completely on the parts of the code that use this value and how they make use of it.
     
  • 23
    Posts
    1
    Years
    • Seen Jan 30, 2024
    How does someone learn all the ins and outs of these decomps? Is it just time spent studying the code base and playing around?
     

    Lunos

    Random Uruguayan User
  • 3,116
    Posts
    15
    Years
    How does someone learn all the ins and outs of these decomps? Is it just time spent studying the code base and playing around?
    Yes, basically.
    You just decide to do something, then jump in and figure out how to accomplish that something.
    One thing leads to another and eventually you know where most of the stuff is located.
    For the things that you don't know about there's always git grep or equivalents which allow you to search specific words in the entire codebase.
     
    Back
    Top