For Gelatino:
I spent a bit working on the script. A few changes I've made:
1. I used 1 call function, through testing i learned you can only use one at a time AFAIK.
2. I changed the message boxes to have 0x6 at the end, instead of callstd. I did it to make it a bit neater, so change it back if need be.
3. This script will continue until the player has two Pokemon.
4. The script is ordered a bit different. I added dynamic offset for completion of script, remove that as necessary.
5. I have actually tested this and it works.
6. Again it'll look different, but I have left notes explaining what each thing does.
Problems:
None, Vendily posted the solution, and I have updated the script for you.
Thanks for reading, and good luck in your endeavors.
EDIT: By the way, after repeated testing, I've noticed that if you wanted to keep the person locked, you would have to enter a lockall after each message, and a faceplayer after the wildbattle. I've put the faceplayer after the battles for you.
Script:
Spoiler:
#org @begin
lockall
faceplayer
checkflag 0x860
if 0x1 goto @killscript2
msgbox @6 0x6 'Hello msg.
goto @caughtpokemonchecker
#org @killscript2
msgbox @10 0x6 'You already caught a pokemon so later.
releaseall
end
#org @caughtpokemonchecker 'here we check if we've caught a pokemon. If we have caught one, the script will complete.
countpokemon
compare 0x800D 0x2
if 0x1 goto @killscript 'If we have two, great, we'll leave the script.
goto @restart 'If we don't, we go back to the battle section.
#org @killscript 'we run this once the player HAS caught a pokemon. Just a message, and then we release the player.
msgbox @8 0x6 ' good luck, see ya journey.
setflag 0x860 'set the flag so that when we talk to them, they will not bother us with a wild battle again.
releaseall
end
#org @battles 'we actually need GOTO in this area. As far as I'm aware, you can only use a call one at a time, which is fine here, because after our wild battle, we'll return to @restart
random 0xA
compare 0x800D 0x0
if 0x1 goto @plakomask
compare 0x800D 0x1
if 0x1 goto @plakomask
compare 0x800D 0x2
if 0x1 goto @plakomask
compare 0x800D 0x3
if 0x1 goto @litturch
compare 0x800D 0x4
if 0x1 goto @litturch
compare 0x800D 0x5
if 0x1 goto @goldeen
compare 0x800D 0x6
if 0x1 goto @goldeen
compare 0x800D 0x7
if 0x1 goto @remoraid
compare 0x800D 0x8
if 0x1 goto @remoraid
compare 0x800D 0x9
if 0x1 goto @corphish
goto @corphish ' I added this to allow for NO errors. I could have put end, but that's not appropriate.
#org @restart 'I revised this. We are checking if the player has no balls left. If they don't, give them 5 more. Thanks to Vendily, this part has been fixed, tested and is working.
checkitem 0x4 0x5 'check pokeballs
compare 0x800D 0x1 'check that we do have 5.
if 0x0 call @balls 'suppose to read "If the player has less then or equal to 5 balls, give him 5 balls."
msgbox @7 0x6 'Ok prepare for battle msg
call @battles 'call for a random pokemon battle.
faceplayer
goto @caughtpokemonchecker 'after the battle, we now loop back to the beginning and check if we have two pokemon. If we don't then prepare for the ride.
#org @balls ' give the player balls.
msgbox @9 0x6 'here are more balls
giveitem 0x4 0x5 0x0
return
#org @plakomask
wildbattle 0x11B 0x12 0x0 'wildbattle, not startwildbattle, works fine here.
return
#org @litturch
wildbattle 0x5A 0x11 0x0
return
#org @goldeen
wildbattle 0x76 0x12 0x0
return
#org @remoraid
wildbattle 0xDF 0x12 0x0
return
#org @corphish
wildbattle 0x146 0x13 0x0
return
Side note:
I actually thought it was quite funny you posted this, because a few days ago I made a wild shiny Pokemon script that gives the Pokemon in the area a chance to be shiny. It works fairly well, and can only be detected by ROM hackers.
I just want to add that your compare is off.
Code:checkitem 0x4 0x5 'check pokeballs compare 0x800D 0x1 'check that we do have 5. if 0x3 call @balls 'suppose to read "If the player has less then or equal to 5 balls, give him 5 balls."
The checkitem command returns 0x1 if the player has enough, and 0x0 if the player has less than the quantity.
So your if/call isn't "If the player has less then or equal to 5 balls, give him 5 balls.", it's now checking if var 0x800D is less than or equal to 0x1, which it always will be. Try, if 0x0 call @balls, which reads "if var 0x800D is less than 0x1, give 5 balls."
Okay so, In battles, I want the Opponent's Pokemon able to be caught by the Master Ball. How do I do that exactly?
Thanks for your help, both of you. Sorry I took a few days to get back to you
Unfortunately, I'm having trouble testing the script because the wildbattle is still giving me an error, even though I can't see a problem:
Spoiler:![]()
I forgot to mention that I'm hacking Emerald, and you might have been using firered, so that might explain why it's working for you but not for me?
So this is what I have so far:Spoiler:
#dynamic 0x800554
#org @start
lock
faceplayer
checkflag 0x1200
if 0x1 goto @done
msgbox @question 0x5
compare LASTRESULT 0x1
if 0x1 goto @givepokemon
msgbox @no 0x6
release
end
#org @done
msgbox @checkup 0x6
release
end
#org @givepokemon
msgbox @yes 0x6
givepokemon 0x19 0xA 0x0 0x0 0x0 0x0
fanfare 0x13E
msgbox @recieved 0x6
waitfanfare
setflag 0x1200
msgbox @thanks2 0x6
release
end
#org @question
= Will you take the pidgey?
#org @no
= You refused.
#org @yes
= You recieved Pidgey.
#org @recieved
= \v\h01 recieved a Pidgey!
I think it should be fine, except for a "Error 13 Type mismatch line 9"
![]()
Probably because there's no #org @checkup in your script.
Can anyone tell me how to make a script tile? And how to replace Prof. Oak's Intro sprite? I've been trying to replace it with NSE and NSE Classic but it just won't import the sprite and palette.
Applymovement
What's new here? Applymovement, waitmovement, pause, playsong and fadesong. I guess I'll explain them all in that order.Code:#dynamic 0x800000 #org @start checkflag 0x828 if 0x1 goto @done msgbox @1 0x6 applymovement 0x04 @move waitmovement 0x0 applymovement 0xFF @move2 pause 0x30 msgbox @2 0x6 playsong 0x13E 0x0 applymovement 0x04 @move3 applymovement 0xFF @move3 waitmovement 0x0 fadesong 0x12C release end #org @done release end #org @move #raw 0x62 #raw 0x12 #raw 0x12 #raw 0x12 #raw 0x12 #raw 0xFE #org @move2 #raw 0x03 #raw 0xFE #org @move3 #raw 0x13 #raw 0x13 #raw 0x13 #raw 0x13 #raw 0xFE #org @1 = Waaaiiiitttt!!! #org @2 = You can't go out there\nwithout your own Pokemon.\pWild Pokemon will hurt you.
Applymovement is a very useful command that allows to show an overworld walking or running depending on what we want.
When we use applymovement, it has to be followed by a People Number, which is found here:
![]()
It also needs a pointer to where our movements are. An overworld with a people number of "4" seems normal, doesn't it? But what about one with 0xFF (255). There's almost never 255 overworlds on one map. 0xFF is the "hero's" people number.
Now, let's look at this movements list: (credit to HackMew for finding them and including them in XSE)
Ruby/Sapphire/Emerald
Spoiler:#raw 0x00 = Face Down
#raw 0x01 = Face Up
#raw 0x02 = Face Left
#raw 0x03 = Face Right
#raw 0x04 = Step Down (Slow)
#raw 0x05 = Step Up (Slow)
#raw 0x06 = Step Left (Slow)
#raw 0x07 = Step Right (Slow)
#raw 0x08 = Step Down (Normal)
#raw 0x09 = Step Up (Normal)
#raw 0x0A = Step Left (Normal)
#raw 0x0B = Step Right (Normal)
#raw 0x0C = Jump2 Down
#raw 0x0D = Jump2 Up
#raw 0x0E = Jump2 Left
#raw 0x0F = Jump2 Right
#raw 0x10 = Delay1
#raw 0x11 = Delay2
#raw 0x12 = Delay3
#raw 0x13 = Delay4
#raw 0x14 = Delay5
#raw 0x15 = Step Down (Fast)
#raw 0x16 = Step Up (Fast)
#raw 0x17 = Step Left (Fast)
#raw 0x18 = Step Right (Fast)
#raw 0x19 = Step on the Spot Down (Slow)
#raw 0x1A = Step on the Spot Up (Slow)
#raw 0x1B = Step on the Spot Left (Slow)
#raw 0x1C = Step on the Spot Right (Slow)
#raw 0x1D = Step on the Spot Down (Normal)
#raw 0x1E = Step on the Spot Up (Normal)
#raw 0x1F = Step on the Spot Left (Normal)
#raw 0x20 = Step on the Spot Right (Normal)
#raw 0x21 = Step on the Spot Down (Faster)
#raw 0x22 = Step on the Spot Up (Faster)
#raw 0x23 = Step on the Spot Left (Faster)
#raw 0x24 = Step on the Spot Right (Faster)
#raw 0x25 = Step on the Spot Down (Fastest)
#raw 0x26 = Step on the Spot Up (Fastest)
#raw 0x27 = Step on the Spot Left (Fastest)
#raw 0x28 = Step on the Spot Right (Fastest)
#raw 0x29 = Slide Down
#raw 0x2A = Slide Up
#raw 0x2B = Slide Left
#raw 0x2C = Slide Right
#raw 0x2D = Slide Down
#raw 0x2E = Slide Up
#raw 0x2F = Slide Left
#raw 0x30 = Slide Right
#raw 0x31 = Slide Down
#raw 0x32 = Slide Up
#raw 0x33 = Slide Left
#raw 0x34 = Slide Right
#raw 0x35 = Slide Running Down
#raw 0x36 = Slide Running Up
#raw 0x37 = Slide Running Left
#raw 0x38 = Slide Running Right
#raw 0x3A = Jump Facing Left (Down)
#raw 0x3B = Jump Facing Down (Up)
#raw 0x3C = Jump Facing Up (Left)
#raw 0x3D = Jump Facing Left (Right)
#raw 0x3E = Face Player
#raw 0x3F = Face Against Player
#raw 0x40 = Lock Sprite Facing
#raw 0x41 = Release Sprite Facing
#raw 0x42 = Jump Down
#raw 0x43 = Jump Up
#raw 0x44 = Jump Left
#raw 0x45 = Jump Right
#raw 0x46 = Jump in Place (Facing Down)
#raw 0x47 = Jump in Place (Facing Up)
#raw 0x48 = Jump in Place (Facing Left)
#raw 0x49 = Jump in Place (Facing Right)
#raw 0x4A = Jump in Place (Facing Down/Up)
#raw 0x4B = Jump in Place (Facing Up/Down)
#raw 0x4C = Jump in Place (Facing Left/Right)
#raw 0x4D = Jump in Place (Facing Right/Left)
#raw 0x4E = Face Left
#raw 0x54 = Hide Sprite
#raw 0x55 = Show Sprite
#raw 0x56 = Exclamation Mark (!)
#raw 0x57 = Question Mark (?)
#raw 0x58 = Love (<3)
#raw 0x62 = Walk Down
#raw 0x63 = Walk Down
#raw 0x64 = Face Down (Delayed)
#raw 0x65 = Face Up (Delayed)
#raw 0x66 = Face Left (Delayed)
#raw 0x67 = Face Right (Delayed)
#raw 0x70 = Jump in Place (Facing Down)
#raw 0x71 = Jump in Place (Facing Up)
#raw 0x72 = Jump in Place (Facing Left)
#raw 0x73 = Jump in Place (Facing Right)
#raw 0x74 = Jump Down Running
#raw 0x75 = Jump Up Running
#raw 0x76 = Jump Left Running
#raw 0x77 = Jump Right Running
#raw 0x78 = Jump2 Down Running
#raw 0x79 = Jump2 Up Running
#raw 0x7A = Jump2 Left Running
#raw 0x7B = Jump2 Right Running
#raw 0x7C = Walk on the Spot (Down)
#raw 0x7D = Walk on the Spot (Up)
#raw 0x7E = Walk on the Spot (Left)
#raw 0x7F = Walk on the Spot (Right)
#raw 0x80 = Slide Down Running
#raw 0x81 = Slide Up Running
#raw 0x82 = Slide Left Running
#raw 0x83 = Slide Right Running
#raw 0x84 = Slide Down
#raw 0x85 = Slide Up
#raw 0x86 = Slide Left
#raw 0x87 = Slide Right
#raw 0x88 = Slide Down on Left Foot
#raw 0x89 = Slide Up on Left Foot
#raw 0x8A = Slide Left on Left Foot
#raw 0x8B = Slide Right on Left Foot
#raw 0x8C = Slide Left diagonally (Facing Up)
#raw 0x8D = Slide Right diagonally (Facing Up)
#raw 0x8E = Slide Left diagonally (Facing Down)
#raw 0x8F = Slide Right diagonally (Facing Down)
#raw 0x90 = Slide2 Left diagonally (Facing Up)
#raw 0x91 = Slide2 Right diagonally (Facing Up)
#raw 0x92 = Slide2 Left diagonally (Facing Down)
#raw 0x93 = Slide2 Right diagonally (Facing Down)
#raw 0x96 = Walk Left
#raw 0x97 = Walk Right
#raw 0x98 = Levitate
#raw 0x99 = Stop Levitating
#raw 0x9C = Fly Up Vertically
#raw 0x9D = Land
#raw 0xFE = End of Movements
Fire Red/Leaf Green
Spoiler:#raw 0x0 = Face Down
#raw 0x1 = Face Up
#raw 0x2 = Face Left
#raw 0x3 = Face Right
#raw 0x4 = Face Down (Faster)
#raw 0x5 = Face Up (Faster)
#raw 0x6 = Face Left (Faster)
#raw 0x7 = Face Right (Faster)
#raw 0x8 = Step Down (Very Slow)
#raw 0x9 = Step Up (Very Slow)
#raw 0xA = Step Left (Very Slow)
#raw 0xB = Step Right (Very Slow)
#raw 0xC = Step Down (Slow)
#raw 0xD = Step Up (Slow)
#raw 0xE = Step Left (Slow)
#raw 0xF = Step Right (Slow)
#raw 0x10 = Step Down (Normal)
#raw 0x11 = Step Up (Normal)
#raw 0x12 = Step Left (Normal)
#raw 0x13 = Step Right (Normal)
#raw 0x14 = Jump2 Down
#raw 0x15 = Jump2 Up
#raw 0x16 = Jump2 Left
#raw 0x17 = Jump2 Right
#raw 0x18 = Delay1
#raw 0x19 = Delay2
#raw 0x1A = Delay3
#raw 0x1B = Delay4
#raw 0x1C = Delay5
#raw 0x1D = Step Down (Fast)
#raw 0x1E = Step Up (Fast)
#raw 0x1F = Step Left (Fast)
#raw 0x20 = Step Right (Fast)
#raw 0x21 = Step on the Spot Down (Normal)
#raw 0x22 = Step on the Spot Up (Normal)
#raw 0x23 = Step on the Spot Left (Normal)
#raw 0x24 = Step on the Spot Right (Normal)
#raw 0x25 = Step on the Spot Down (Faster)
#raw 0x26 = Step on the Spot Up (Faster)
#raw 0x27 = Step on the Spot Left (Faster)
#raw 0x28 = Step on the Spot Right (Faster)
#raw 0x29 = Step on the Spot Down (Fastest)
#raw 0x2A = Step on the Spot Up (Fastest)
#raw 0x2B = Step on the Spot Left (Fastest)
#raw 0x2C = Step on the Spot Right (Fastest)
#raw 0x2D = Face Down (Delayed)
#raw 0x2E = Face Up (Delayed)
#raw 0x2F = Face Left (Delayed)
#raw 0x30 = Face Right (Delayed)
#raw 0x31 = Slide Down (Slow)
#raw 0x32 = Slide Up (Slow)
#raw 0x33 = Slide Left (Slow)
#raw 0x34 = Slide Right (Slow)
#raw 0x35 = Slide Down (Normal)
#raw 0x36 = Slide Up (Normal)
#raw 0x37 = Slide Left (Normal)
#raw 0x38 = Slide Right (Normal)
#raw 0x39 = Slide Down (Fast)
#raw 0x3A = Slide Up (Fast)
#raw 0x3B = Slide Left (Fast)
#raw 0x3C = Slide Right (Fast)
#raw 0x3D = Slide Running on Right Foot (Down)
#raw 0x3E = Slide Running on Right Foot (Up)
#raw 0x3F = Slide Running on Right Foot (Left)
#raw 0x40 = Slide Running on Right Foot (Right)
#raw 0x41 = Slide Running on Left Foot (Down)
#raw 0x42 = Slide Running on Left Foot (Up)
#raw 0x43 = Slide Running on Left Foot (Left)
#raw 0x44 = Slide Running on Left Foot (Right)
#raw 0x46 = Jump Facing Left (Down)
#raw 0x47 = Jump Facing Down (Up)
#raw 0x48 = Jump Facing Up (Left)
#raw 0x49 = Jump Facing Left (Right)
#raw 0x4A = Face Player
#raw 0x4B = Face Against Player
#raw 0x4C = Lock Sprite Facing
#raw 0x4D = Release Sprite Facing
#raw 0x4E = Jump Down
#raw 0x4F = Jump Up
#raw 0x50 = Jump Left
#raw 0x51 = Jump Right
#raw 0x52 = Jump in Place (Facing Down)
#raw 0x53 = Jump in Place (Facing Up)
#raw 0x54 = Jump in Place (Facing Left)
#raw 0x55 = Jump in Place (Facing Right)
#raw 0x56 = Jump in Place (Facing Down/Up)
#raw 0x57 = Jump in Place (Facing Up/Down)
#raw 0x58 = Jump in Place (Facing Left/Right)
#raw 0x59 = Jump in Place (Facing Right/Left)
#raw 0x60 = Hide Sprite
#raw 0x61 = Show Sprite
#raw 0x62 = Exclamation Mark (!)
#raw 0x63 = Question Mark (?)
#raw 0x64 = Cross (X)
#raw 0x65 = Double Exclamation Mark (!!)
#raw 0x66 = Happy ()![]()
#raw 0xFE = End of Movements
Before we look at the movements in a different view, I should explain the layout of the movements at the pointer. It's set out in a similar way to a message. We have #org @pointer first and what's being written to the ROM below that. You put #raw, then the movement that you want. You have to put #raw 0xFE at the end of the movements, or else the movements won't work.
Now, we're going to look at waitmovement and pause.
waitmovement is one of the best commands that you will ever find. It's the "perfect pause"! When used as waitmovement 0x0, it will wait for the exact amount of time that it takes for the movements to move the sprite. Really helpful, isn't it?
Now, we have pause. pause will wait for a set amount of time. You have to add the amount that it will wait for. If you want to calculate pause time vs. seconds, here's a (not very good) conversion thingy:
0x20 Pause time = approx. 1 sec. real time
I don't use this very often. I prefer to use waitmovement almost all of the time.
Okay now, no more sidetracking. Let's look at the movements. Let's look at the script without anything but the applymovements, pause and waitmovements. This leaves us with this:
The first two applymovements are in a completely normal setup.Code:#dynamic 0x800000 #org @start applymovement 0x04 @move waitmovement 0x0 applymovement 0xFF @move2 pause 0x30 applymovement 0x04 @move3 applymovement 0xFF @move3 waitmovement 0x0 release end #org @move #raw 0x62 #raw 0x12 #raw 0x12 #raw 0x12 #raw 0x12 #raw 0xFE #org @move2 #raw 0x03 #raw 0xFE #org @move3 #raw 0x13 #raw 0x13 #raw 0x13 #raw 0x13 #raw 0xFE
ie. applymovement 0xXX @YYYYYY
waitmovement/pause
But let's look at the next set of movements. It's set up differently. We have two applymovements before we have some sort of pause. What would happen if I did that? They would both move at the same time. This is sometimes referred to as "follow-me." With a "follow-me", we can use as many applymovements before the pause as we want. This can be useful if we wanted a "group" to walk together. We can have three, four, five, six, or however many you want in a "group". I think that's all there is to the applymovement command.
Now we can move onto that playsong.
When we script playsong, we need a few bytes to get it to work. Here's a short summary of what we need:
playsong [song #] 0x0
That 0x0 is a buffer. We need it in order for the command to work.
Whatever game you're hacking, you can find the song numbers in A-Map.
Now we have fadesong. What's that do? It's set up similar to playsong and will fade into the sound displayed. If you want more detail on how it works, just refer back to playsong. The only thing different is that it does not need that extra buffer.
I thought I might point out something about the checkflag in this script. We actually have no setflag in this script. So why do I have a checkflag? In one script, we can check if a flag was set in a different script. In this section, we check if the Pokemon menu has been activated before the script will end (@done).
Okay. Compile the script, assign it to a script tile (green with an S) and not a person.
Now test it in the ROM. Then look at this spoiler.
Spoiler:Didn't work, did it? Froze on the spot. You're going to need to change this...
![]()
to this....
![]()
Try it now. Worked perfectly, didn't it?
Player char is looking up instead of right.
Running shoes flag isnt being set
Variable isnt being set
No walking animation when the mother walks, it looks like she's sliding.
This has been boggling my mind for quite some time now, but can someone explain the checktrainerflag command for me?
Currently my script is set up so it checks the trainer's flag, if the trainer hasn't been battled it sets a var, and then warps to a level script to battle the trainer. I know when it's working because the var that is being set is what activates the level script so if the level script doesn't activate, then something went awry.
Spoiler:
lock
msgbox @1 MSG_YESNO '"Small rays of light filter from\nu..."
compare LASTRESULT 0x1
if 0x1 goto @yes
release
end
#org @yes
checktrainerflag 0x1AD
compare LASTRESULT 0x0
if 0x1 call @setvar
warp 0x1 0x59 0x0 0x0 0x0
end
'---------------
#org @setvar
setvar 0x4015 0x6
nop
nop
nop
nop
nop
return
Basically I've tried everything with the checktrainerflag command and still don't know how it works. I know the important part is the "compare 0x800D 0x[whatever]" and the "if 0x[whatever] call @setvar" but I've changed the ox[whatever]'s and nothing happens. The only one that seems to work is when they're both 0x1 which should mean that the trainer has already been battled, but when I warp the level script works (Also I should note that if I go back after the battle and activate this same script again, it will warp me and set the var back so the level script will be reactivated). Everything else just doesn't set the variable so I can't even get the level script working.
I know the trainerflag commands are backwards when scripting, but I'm not sure if it applies to the checktrainerflag command or not. Is it because I have a bunch of nop's in it? I had them in because I was originally going to set 2 variables but I decided I only needed 1 and replaced the other setvar command with nop's which should do nothing.
If anyone has any ideas, please let me know. Thanks.
https://sphericalice.com/romhacking/documents/script/index.html#c-60
Add 0x500 to trainer id.
Replacing "checktrainerflag 0x1AD" with "checktrainerflag 0x6AD" still produces the same results. Only when both the "compare" and the "if" are 0x1 will it set the variable, but it'll do it every time even after the trainer has been defeated. The rest combinations (0x0 & 0x0, 0x1 & 0x0, 0x0 & 0x1) do nothing.
Im trying to make it so that i can play different music during battles. is there anyway to implement different music via script using the Trainerbattle 0x1 script? because i want 2 battle themes to play at two different battles.
Well, I'm less sure of this, but I think that the LASTRESULT is also causing the problem because the command doesn't need it.
Try taking it out as well.