So, we want to create a basic attack that does damage. This is how it's structured (all numbers are in hex):
See why I put it in a spoiler? The thing is, if you search for this string in your BPRE ROM, you will find it already exists, so why do we need to know about it at all? Why not just directly call that existing script? The answer is because a lot of the new moves use combinations of existing effects. This is something we cannot achieve simply by using the existing scripts. However, what we CAN do, and I advise you should do, is branch back to this script at the earlist available opportunity, after executing your effects.
Now, the most important part of that script for our purposes is towards the end. The 0x15 byte is the byte which takes care of any added effects that the attack may have. It reads from 0x02023E85 to find what effect it should execute. So why did I bother showing you what's above, I hear you asking.
The stuff that is above isn't reliant on a branch back to this code! You can simply end the execution of the effect(s) by using the return command (0x3C or 0x3D).
It basically comes down to this: If your attack does damage - use this new way, if it doesn't, use the older way from above.
I'll try to explain this with an example: Let's say we want to have Flare Blitz. Flare Blitz does damage, causes recoil AND can cause a burn. This is a combination of 2 existing effects, but because it has to do damage as well, we can't simply use the stat changing method. What do we do?
Firstly, we take care of the damage part of the attack. This is the section of the huge script from above that is in italics. All that nonsense takes care of causing damage to the opponent. So we need that:
Current Code for Flare Blitz:
Code:
[I]00 01 5E 69 1D 08 00 00 02 03 04 05 06 07 09 0A 0E 5C 00 3A 0B 00 0C 00 0D 12 40 00 0F 12 40 00[/I]
Excellent. Our attack would now do damage, carry an animation and all that good stuff.
Now, what effect gets executed next for Flare Blitz? Well - The recoil effect, of course! So, how to we go about finding how to use this effect?
The recoil effect we want is already in the ROM, however, we cannot simply call that one, because the game wouldn't then go on to execute the burn effect. What we need to do is take the relevant part of the recoil effect and insert it into our script, then execute it.
So, knowing that the recoil effect we want is number 198 (the same recoil effect as Double-Edge for anyone wondering where I pulled that number from), we can find the corresponding script easily enough. The table of effects starts at 0x1D65A8 in BPRE. So, we find the 198th entry in that table, and go to the script's location. What we see is what byte is stored, and to where, to execute the recoil effect. So we copy the storebyte command (2E) and all it's parameters to gain the effect.
Current Code:
Code:
00 01 5E 69 1D 08 00 00 02 03 04 05 06 07 09 0A 0E 5C 00 3A 0B 00 0C 00 0D 12 40 00 0F 12 40 00 [I]2E 85 3E 02 02 E6[/I]
Now we must execute the effect. Well, that's easy. Command 0x15 executes effects, so we simply add a 15 to the script.
Current Code:
Code:
00 01 5E 69 1D 08 00 00 02 03 04 05 06 07 09 0A 0E 5C 00 3A 0B 00 0C 00 0D 12 40 00 0F 12 40 00 2E 85 3E 02 02 E6 [I]15[/I]
Excellent - but so far, we've only added 1 of the 2 effects, and it's taken a lot of work! Thankfully, from here on out, it gets easier, as for each effect, you simply repeat the cycle of store and execute until completion. So we want to add the burn effect now. The burn effect byte is 0x3, so we now stick a storebyte for that byte into the end of the script, as well as an execute effect command.
Current Code:
Code:
00 01 5E 69 1D 08 00 00 02 03 04 05 06 07 09 0A 0E 5C 00 3A 0B 00 0C 00 0D 12 40 00 0F 12 40 00 2E 85 3E 02 02 E6 15 [I]2E 85 3E 02 02 03 15[/I]
Now, that's all of the effects which can be added for this attack directly (the defrosting is handled passively elsewhere), so now what do we do?
Ah yes, as per what I said earlier, we should return to the original script as soon as possible. So now we simply put a Goto command onto the end of the script, returning back to normal execution.
Flare Blitz Code:
Code:
00 01 5E 69 1D 08 00 00 02 03 04 05 06 07 09 0A 0E 5C 00 3A 0B 00 0C 00 0D 12 40 00 0F 12 40 00 2E 85 3E 02 02 E6 15 2E 85 3E 02 02 03 15 [I]28 47 69 1D 08[/I]
There we have it! One functional Flare Blitz effect.The recoil will ALWAYS happen, so you don't need to worry about clashes between the recoil and the CHANCE of burning, but if you have 2 effects such as flinch and burning which both rely on chance, they both must share the same chance of happening. This is simply a limiation of the code's design. It is possible for BOTH effects to happen at the same time, so you can't have a chance for poison combined with a chance for paralysis (for example).