The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Script [Fire Red] Is there a way to continue an event script after a trainer battle? (https://www.pokecommunity.com/showthread.php?t=447808)

wcbvei234 April 4th, 2021 10:50 AM

[Fire Red] Is there a way to continue an event script after a trainer battle?
 
Hey all, glad you stopped by! Title is explanatory enough; I want to have an event script continue running after a trainer battle. I've tried everything I can think of to no avail. I then reverse-engineered a script from the base game where the player battles his rival. The only thing different I could see was that the script called the trainer battle and then returned to the main body. I tried that, and the script still ends. I also tried changing the trainer battle type from the usual 0x0 to the rival's 0x9 just to see what it would do, and nothing changed. Here's my code:

Spoiler:
#dynamic 0x800000

#org @start
lock
applymovement 0x3 @first
waitmovement 0x0
pause 0x060
msgbox @hello 0x6
applymovement 0x3 @gather
pause 0x010
hidesprite 0x1
hidesprite 0x2
waitmovement 0x3
call @battle
msgbox @incentive 0x6
getplayerpos 0x4014 0x4015
compare 0x4015 0x25
if 0x1 goto @top
goto @bottom

#org @top
applymovement 0x3 @topMove
waitmovement 0x3
fanfare 0x13E
giveitem 0x165 0x1 MSG_OBTAIN
waitfanfare
msgbox @goodbye 0x6
applymovement 0x3 @topMoveOut
waitmovement 0x3
sound 0x09
hidesprite 0x3
setflag 0x02F
setvar 0x408B 0x1
release
end

#org @bottom
applymovement 0x3 @bottomMove
waitmovement 0x3
fanfare 0x13E
giveitem 0x165 0x1 MSG_OBTAIN
waitfanfare
msgbox @goodbye 0x6
applymovement 0x3 @bottomMoveOut
waitmovement 0x3
sound 0x09
hidesprite 0x3
setflag 0x02F
setvar 0x408B 0x1
release
end

#org @battle
trainerbattle 0x0 0x01 0x0 @challenge @defeat
return

#org @first
#raw 0x62
#raw 0x03
#raw 0xFE

#org @hello
= [red_fr]A child? I would have thought my\nTRIED brethren had the strength to\lhalt any intruder.\pIt would appear I was incorrect.\pWhatever you want here--it is no\nmatter! These are for THE TRIED!

#org @gather
#raw 0x1F
#raw 0x1F
#raw 0x1E
#raw 0x20
#raw 0x1D
#raw 0x20
#raw 0xFE

#org @challenge
= [red_fr]Now to deal with you!

#org @defeat
= It would appear once more that I\nwas incorrect. You show promise.

#org @incentive
= [red_fr]That promise may prove fruitful.\pAs such, I'll allow you to walk\naway with one of these relics.\pPerhaps the more... "Religious"\none should mozy its way into your\lpockets.

#org @topMove
#raw 0x13
#raw 0xFE

#org @goodbye
= [red_fr]When you look at this relic of\nold, I hope you think of THE\lTRIED.\pIn due time, perhaps you'll join\nus as a higher-ranking member.\pFarewell, child.

#org @topMoveOut
#raw 0x12
#raw 0x12
#raw 0x11
#raw 0x11
#raw 0xFE

#org @bottomMove
#raw 0x10
#raw 0x13
#raw 0xFE

#org @bottomMoveOut
#raw 0x12
#raw 0x12
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0xFE


TL;DR of that code: an NPC is startled by the player, grabs some fossils (the hidesprite commands), battles the player, gives the player the Helix Fossil, and runs off.

Anyone have any past experience with this, or maybe some experimental ideas? I'm stumped. Thanks all for reading <3

Asith April 4th, 2021 11:21 AM

It's based on trainer battle types. There are two trainer battle types (iirc) that can continue the script after the player wins.
The first is trainer battle 0x1. You can use that like this:
trainerbattle 0x1 0x01 0x0 @Challenge @Defeat @Victory
With @Victory leading to the script that runs after you win. This is mostly used for gym leaders in the original game.

The second is trainer battle 0x3, which isn't something I've personally tested so I'd probably recommend you use the first one. From what I've been told, however, this command doesn't stop the current script.
trainerbattle 0x3 0x01 0x0 @Defeat
...

The ellipses can just be replaced with the rest of the script you're running after you win, so you never jump to a different pointer. Again, not sure if this one has any problems though. 0x1 should do the trick without a hitch.
EDIT: Actually, the 0x9 you're using should also have this second functionality now that I think about it...
Try using a goto @Victory right after your trainerbattle if you'd prefer to use 0x9


All times are GMT -8. The time now is 9:17 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.