• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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.

Pokeruby add new item

  • 15
    Posts
    3
    Years
    • Seen Apr 9, 2025
    Hi, I'm using the pokeruby disassembler.
    I was wondering if it is possible to add new objects and if so which files I need to edit.
    I hope someone can help me.
    Thanks in advance.
     
    Hi, I'm using the pokeruby disassembler.
    I was wondering if it is possible to add new objects and if so which files I need to edit.
    I hope someone can help me.
    Thanks in advance.
    Yes, of course it's possible.
    You define a new item in include/constants/items.h.
    Add its basic data to the table at src/data/items_en.h
    Add a text string for its description at src/data/item_descriptions_en.h.
    And that's essentially it.

    For its effect you'll have to modify a number of other files depending on what type of effect you want to give it.
    For example, on top of the aforementioned files you'd modify include/item_use.h, src/item_use.c and potentially a 3rd file if you wanted an item that can be used from the overworld, whereas if you wanted to code in an item with a battle effect, you'd edit include/constants/hold_effects.h and a relevant battle file such as src/calculate_base_damage.c, src/battle_main.c or whatever else instead.
     
    Yes, of course it's possible.
    You define a new item in include/constants/items.h.
    Add its basic data to the table at src/data/items_en.h
    Add a text string for its description at src/data/item_descriptions_en.h.
    And that's essentially it.

    For its effect you'll have to modify a number of other files depending on what type of effect you want to give it.
    For example, on top of the aforementioned files you'd modify include/item_use.h, src/item_use.c and potentially a 3rd file if you wanted an item that can be used from the overworld, whereas if you wanted to code in an item with a battle effect, you'd edit include/constants/hold_effects.h and a relevant battle file such as src/calculate_base_damage.c, src/battle_main.c or whatever else instead.
    Thanks, I'd like to add a new key item that allows me to access the Pokemon Center PC.
    Where can I find the files relating to the Pokemon Center PC?
    Thanks again
     
    Last edited:
    Thanks, I'd like to add a new key item that allows me to access the Pokemon Center PC.
    Where can I find the files relating to the Pokemon Center PC?
    Thanks again
    src/pokemon_storage_system.c and the numbered files after it.
    You're better off writing an ItemUseOutOfBattle function and its subsequent task function at src/item_use.c, that make use of the main overworld script that the game uses to boot up the PC Storage System though, which is EventScript_PC. Once you get that set up, you link it to your item's main data at src/data/items_en.h in your item's ".fieldUseFunc" field.
    If you need examples to set up an ItemUseOutOfBattle function that can activate an overworld script, Ctrl+F "ScriptContext1_SetupScript" at src/item_use.c.
     
    src/pokemon_storage_system.c and the numbered files after it.
    You're better off writing an ItemUseOutOfBattle function and its subsequent task function at src/item_use.c, that make use of the main overworld script that the game uses to boot up the PC Storage System though, which is EventScript_PC. Once you get that set up, you link it to your item's main data at src/data/items_en.h in your item's ".fieldUseFunc" field.
    If you need examples to set up an ItemUseOutOfBattle function that can activate an overworld script, Ctrl+F "ScriptContext1_SetupScript" at src/item_use.c.
    I wrote the functions in the src/item_use.c file
    Can I ask you if the code is correct?
    I would like to avoid errors when compiling the rom.

    [PokeCommunity.com] Pokeruby add new item

    Thanks so much for your help.
     
    Last edited:
    I wrote the functions in the src/item_use.c file
    Can I ask you if the code is correct?
    I would like to avoid errors when compiling the rom.

    View attachment 168175

    Thanks so much for your help.
    No, that's not correct. Not even one bit.
    You can't just plop overworld scripts into .c files and expect things to work. You misunderstood my instructions.
    Read my post again.
     
    No, that's not correct. Not even one bit.
    You can't just plop overworld scripts into .c files and expect things to work. You misunderstood my instructions.
    Read my post again.
    Sorry, I'm sorry.
    I modified the code of the "src/item_use.c" file.

    [PokeCommunity.com] Pokeruby add new item

    [PokeCommunity.com] Pokeruby add new item

    Am I on the right track or am I still wrong?
    Thanks always for your help.
     
    Sorry, I'm sorry.
    I modified the code of the "src/item_use.c" file.

    View attachment 168571

    View attachment 168572

    Am I on the right track or am I still wrong?
    Thanks always for your help.
    Still wrong, yeah.
    Void functions such as your first ItemUseOutOfBattle_Notebook can't ever return a function, and you can't have 2 functions with the exact same label either.
    The 2nd one does have a better shape, but if you check the existingItemUseOutOfBattle functions you'll notice that they delegate their effect to a CallBack function.
    You have to do that as well due to how the codebase is written iirc.
    Also, there's no need to call ScriptContext2_Enable. Since the script you're trying to activate with your item is EventScript_PCMainMenu though, you might as well take the chance and replace it with a call to the LockPlayerFieldControls function instead. You wouldn't want the Player to move around while they browse the PC.
     
    Back
    Top