• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Help Thread: Script Help Thread

Status
Not open for further replies.
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:


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."

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?
 
Okay so, In battles, I want the Opponent's Pokemon able to be caught by the Master Ball. How do I do that exactly?

You might find these two posts useful, the first post explains how you can make other Trainers' Pokémon be able to be caught with a Master Ball (or a different Ball), and the second one is to fix bugs that come by doing that.

https://www.pokecommunity.com/posts/8519915/
https://www.pokecommunity.com/posts/8536920/

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?

This might not be the case, but sometimes XSE's text adjuster can mess the script/text up. So if you write the script all over again, there will be no errors when trying to compile it.
 
So this is what I have so far:
Spoiler:

I think it should be fine, except for a "Error 13 Type mismatch line 9"
 
So this is what I have so far:
Spoiler:

I think it should be fine, except for a "Error 13 Type mismatch line 9"

[PokeCommunity.com] Script Help Thread

Probably because there's no #org @checkup in your script.
 
[PokeCommunity.com] Script Help Thread

Probably because there's no #org @checkup in your script.

That seemed to work, but now if I say yes or no, it plays the no script.
Script:
Spoiler:
 
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.

I think I changed mine using UNLZ-GBA and there's also a tutorial here that tells and shows how to replace oak's intro sprite. There is also a tutorial here on how to make a script tile

Applymovement


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.
What's new here? Applymovement, waitmovement, pause, playsong and fadesong. I guess I'll explain them all in that order.
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:

[PokeCommunity.com] Script Help Thread


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:



Fire Red/Leaf Green
Spoiler:



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:
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
The first two applymovements are in a completely normal setup.
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:

That script tile.
 
Hey guys, im trying to make a simple script in firered where the player's mother gives the running shoes, and I cant get this script tile to work properly

Spoiler:


I'm getting the following problems:

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.
im using firered 1.0 (U) 1636
with xse
 
Player char is looking up instead of right.

You lack one waitmovement command.

Running shoes flag isnt being set

Add the missing waitmovement command and see if it works.

Variable isnt being set

You're setting the variable as a decimal instead of a hex value.

No walking animation when the mother walks, it looks like she's sliding.

The 'mother' doesn't have a walking animation because she doesn't have one. Use an OW editor and seek out a OW editing tutorial if you want to add a walking animation.
 
Okay, I have a question message script. What I want is if the player says yes, the npc would say something back like "Oh, great!" and warp. If it says no, something like "Damn, okay then." then warp.

My script is :
Spoiler:
 
I have answered this question in the other thread as you know, but I'll post the script for the community at large.

Script
Spoiler:
 
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:


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.
 
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:


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.
 
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.
 
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.

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.
 
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.

Jambo has a thread about class based music so you can have different songs played if the two battles you're talking about two different classes of trainers you're fighting out.
https://www.pokecommunity.com/threads/293704


There's also this pretty old thread that talks about having a special song played during one trainer encounter (has to be 0x1). I'm not sure of this one, but searching through the thread does give good tidbits of info.

https://www.pokecommunity.com/threads/306281



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.

I think it worked! The LASTRESULT thing must've been comparing it to my original YESNO question I had, not the actual trainerflag checking. Thank you, you are a saint!

And just something I figured out, the trainerflag doesn't have to have 0x500 added to it. It worked perfectly fine with 0x1AD but still goofed up with 0x6AD. Thanks. :)
 
Last edited:
When trying to implement a trainer battle into Pokemon Fire Red just for practice and to learn how it works, this error comes up every time:

Error 6 "overflow" Line 3
Wrong Parameter Type

(I apparently can't post links yet. ) The "line 3" bit changes depending on what line the "trainerbattle 0x0 0x23ABC8 0x0 @intro @defeat" is on, so that's where the problem is.

Spoiler:
.

I'm using A-trainer (Advance Trainer) and XSE. The error pops up whenever I debug it or try and compile it and I can't find a solution anywhere. As far as I can tell the script is fine apart from this...
 
Status
Not open for further replies.
Back
Top