View Single Post
Old December 1st, 2011 (5:26 PM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
  • Crystal Tier
Join Date: Sep 2009
Location: Downia-upside
Age: 24
Gender: Male
Nature: Jolly
Posts: 1,328
Originally Posted by Epitaph93 View Post
Is there a way to disable running in a wildbattle via XSE?
I'm not sure if there is any way to prevent you from running away while randomly walking around in tall grass, but you can kind of do it in a scripted event. The script will recognise if you ran away and then send you back into the battle - The wild Pokemon's HP and PP won't be restored, making it as if you never left the battle. Here is an example of such a script:

#dynamic 0x800000

#org @start
wildbattle 0x1 0x5 0x0
goto @Continue

#org @Continue
special2 0x800D 0xB4
compare 0x800D 0x4
if 0x1 goto @RanAway
msgbox @Win 0x2

#org @RanAway
msgbox @Coward 0x2
goto @Continue

#org @Win
= You did it! Yay!

#org @Coward
= Why did you run away?\nFight it again!
The scripting that checks if you've run away starts with the line containing special2 which then branches off depending on what you did to end the battle. The 'dowildbattle' command then uses the data that was leftover in the RAM from the last battle you fought, making it so the Pokemon has the exact same status/ damage it had earlier. Here is an explanation of how the special2 command can be used:

Originally Posted by Quilava's Master
"special2 LASTRESULT 0xB4
compare LASTRESULT 0x[insert number here]
if 0x1 goto @pointer"
after the wildbattle command. The special 0xB4 checks for the result of the battle then sets a value to the variable.

comparing 0x1 checks if the pokemon fainted
comparing 0x4 checks if you ran away
comparing 0x7 checks if you caught the Pokemon.
The only unresolved issue is that if you switched during the battle, the Pokemon that you were using last won't come out, the first usable Pokemon in your party will. Other than that, I think it is a solid script.