Advertiser Content
Non-binary
USA-PST
Seen 2 Days Ago
Posted August 6th, 2019
9 posts
135 Days
I'm specifically looking for the implementation file for \asm\macros\event.inc.

here is an example of one of those macros:

@ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, variable 0x800D (LASTRESULT) is set to the (zero-indexed) slot number of the first Pokemon that knows the move. If not, LASTRESULT is set to 0x0006. Variable 0x8004 is also set to this Pokemon's species.
.macro checkpartymove index:req
.byte 0x7c
.2byte \index
.endm

it doesn't say anything about the variables listed in the comment in the chunk beneath it but it does interact with a pointer and it's parameters, which is making me think that this is just a set of declarations to allow compile-time functions to use run-time code. I'm thinking that it calls the function starting at the byte 0x7c with a parameter 2 bytes large that has been given the arbitrary name index so it can be passed through. but I can't confirm that as I can't trace down the function with that pointer.

the reason I want to find the implementation is to see if I can't put together a similar macro to the one above, only checking for a specific held item rather than a specific move (can't find one that exists already). I would do this at run-time, but as far as I can see the field-move triggers from when you press the a button on water or a cut-tree trace to \data\event_scripts.s and \data\scripts\field_move_scripts.inc respectively. there is a badge check and a move check in each these scripts. I want to allow the user to use field moves if they have a pokemon with the move, or they have a pokemon holding a specified item. I got the items working from the party menu (you can use flash, cut grass, heal with soft boiled, and others) but this is blocking my way when it comes to the field triggers.

DizzyEgg

Age 22
Male
Poland
Seen 2 Days Ago
Posted 1 Week Ago
785 posts
5.7 Years
it doesn't say anything about the variables listed in the comment in the chunk beneath it but it does interact with a pointer and it's parameters, which is making me think that this is just a set of declarations to allow compile-time functions to use run-time code.
You're 100% right, that's how all the script systems work in the game.

The actual code is here: https://github.com/pret/pokeemerald/blob/master/src/scrcmd.c#L1705
The table is here: https://github.com/pret/pokeemerald/blob/master/data/script_cmd_table.inc

Sidrk

Professional Lurker

Age 24
Male
India
Seen 5 Days Ago
Posted July 26th, 2019
145 posts
10.6 Years
the reason I want to find the implementation is to see if I can't put together a similar macro to the one above, only checking for a specific held item rather than a specific move (can't find one that exists already). I would do this at run-time, but as far as I can see the field-move triggers from when you press the a button on water or a cut-tree trace to \data\event_scripts.s and \data\scripts\field_move_scripts.inc respectively. there is a badge check and a move check in each these scripts. I want to allow the user to use field moves if they have a pokemon with the move, or they have a pokemon holding a specified item. I got the items working from the party menu (you can use flash, cut grass, heal with soft boiled, and others) but this is blocking my way when it comes to the field triggers.
This doesn't exactly answer your question, but you might want to look into the source of Pokémon Emerald Enhanced, it has the feature where you can just hit A when you're facing a cut tree and a popup asks you if you want to cut it (you don't need a Pokémon.)

Non-binary
USA-PST
Seen 2 Days Ago
Posted August 6th, 2019
9 posts
135 Days
I just finished the implementation of this feature and was cleaning up my mess from 3 days of banging my head against a wall as a way of getting to better know the wall. then I remembered that I posted for help here. I ended up using a special rather than a script command in the end. I got it streamlined enough that aside from the items themselves, the feature only adds one variable and one special. also, I wonder about the practical difference between specials and script commands. it seems from a cursory glance that script commands only use functions defined in the scope of themselves and need to be declared in asm, while specials can use the whole codebase and need to be declared in a container. I assume that script commands are faster, but how much strain does it put on the system to call code that can't be condensed at compile time in code that is condensed before run time?

I can post a guide on how I turned the hms into items if people are interested. I'd rather not more people burn away 3 days looking at the same 200 lines of code. I think it turned out well; I'm certainly happy with it being my first feature made toying with pokemon code.

Sidrk

Professional Lurker

Age 24
Male
India
Seen 5 Days Ago
Posted July 26th, 2019
145 posts
10.6 Years
I can post a guide on how I turned the hms into items if people are interested. I'd rather not more people burn away 3 days looking at the same 200 lines of code. I think it turned out well; I'm certainly happy with it being my first feature made toying with pokemon code.
Go ahead! I know that at least I'm going to be implementing this at some point. I'd also appreciate a link to the repo!
Advertiser Content