• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

PKSV scripting Tutorial/Script Thread

2
Posts
12
Years
  • Seen Jan 9, 2013
I am trying to set up a trainer script.

I have the trainer ID set to which trainer i want in PET.

I use the script generator and it asks me to type in the trainer i want (i type in 0x002) it loads the script.

I then change the text it says to what i want. I save, compile, copy the offset, exit, and save my file in advance map. I load up the ROM but the trainer does nothing.

I also tried copying my one working trainer script (dont know how i did it) into my new one. The trainer loads now but it has the ??? pokemon. I also cannot change what he says, it always loads back up to the other trainer, even after i change the text, save, and compile again.

I am bad at this...

In AdvanceMap, after you copy the offset to the person in the 'Script Offset' box, look up three more boxes and you should see a 'Trainer' box. You need to change that box to $01. This tells AdvanceMap that the event is a trainer.

Next, look for a box called 'View Radius', and set that number to however many blocks away you want the trainer to catch you for a battle. So if you put 4 blocks in his radius, the trainer's line of sight will only be four blocks long.

Hope this helps.

-----------------------------------------------------------------------------------------------------------------------------------------------------

Okay, so I'm almost completely new to scripting itself, much less PKSV. Although I do have one high school semester's worth of web design and javascript, so that's helped me through some of the way, and really I'm just messing around so far.

My problem today is that I am trying to make an event where you walk up to a man, he talks back to you, and at the end of the message he gives you an item (in my case it's a nugget). After this is completed, you can't receive another nugget from him. Instead, he just gives you another, yet different, message.

Seems like this can be easily solved with flags, right? You would think, and I don't think the flag is the problem here. My problem is that I can't get the 'ITEM OBTAINED!' text to show up properly. Instead of saying, "Obtained the NUGGET!" it says, "Obtained the ?????????". It's probably because I don't know the ID for nugget in PKSV, but it does give me a nugget so I don't know.

If anybody could help with this, that would be great.

Oh and if it helps;

This is my script before I compile/paste offsets:

Spoiler:


And this is my script after I compile/paste offset:

Spoiler:
 
Last edited:
15
Posts
11
Years
  • Seen Mar 19, 2016
Great tutorials! But i have a request, you learned us how to GIVE a pokemon but not how to TAKE a pokemon. exmaple: 'do you want to trade your ____ for my _____'
I would appreciate that a lot!
 
9
Posts
11
Years
  • Seen Dec 30, 2022
I have a question.
I want to edit a game but how can am I edit the first map in emerald/ruby/sapphire ( the van , how I write new start? )
 
4
Posts
12
Years
  • Seen Jan 25, 2014
Really good tutorial, but I'm having problems with the "money" command in the PKSVUI script editor. Whenever I type it in and compile it, all that comes out of it is junk (a lot of "raw").
 

bctincher15

blue eye + brown eye =awesome
261
Posts
12
Years
  • Age 33
  • Seen Feb 18, 2013
How do I make an over world Pokemon disappear permanently after beating/catching it. I would beat/catch it and after I take a step, It will show up again. Can someone help, Please.
 
1
Posts
11
Years
  • Seen Sep 15, 2012
Hi everyone, I'm new to scripting and was hoping someone could help me. I've got most of the scripts figured out except the pokemon battles one (i'm hacking ruby, if that helps). I'm trying to insert new legendary battles.

So, for instance, I'm trying to put a battle with Articuno in. So i insert the sprite in advance map as a person event, no problem, and open up the script at offset $00740000. At that point, the script looks like this:

#org 0x8740000
'-----------------------------------
#raw 0xFF
#raw 0xFF
#raw 0xFF
#raw 0xFF
...and so on.

Then I insert the battle script from the generator, and it looks like this:
#dyn 0x740000
#org @start
special 0x187
compare LASTRESULT 2
if == jump 0x81A7AE0
special 0x188
lock
faceplayer
checksound
cry ARTICUNO 2
waitcry
pause 0x14
playsound 0x156 0x0
battle ARTICUNO 15 NONE
setflag 0x807
special 0x138
waitspecial
clearflag 0x807
special2 0x800D 0xB4
compare LASTRESULT 1
if == jump 0x8162558
compare LASTRESULT 4
if == jump 0x8162561
compare LASTRESULT 5
if == jump 0x8162561
setflag 0x201
release
end

...which I believe is correct, since i got it from the generator.
I press compile, and copy the offset, which is at $00740001, into advance map. i change the person ID to $0201 as well. but then when i open the script again, it looks like this:


#org 0x8740001
'-----------------------------------
special INIT_STEPCOUNT
compare LASTRESULT 0x2
if == jump 0x81A7AE0 ' Equal To
special GET_STEPCOUNT
lock
faceplayer
cry 0x30 0x290
nop0 ' #raw 0x0
waitcry
pause 0x14
playsound 0x156
battle ARTICUNO 15 NONE
setflag RS_BADGE_1
special BATTLE_PIXELLATE
waitspecial
clearflag RS_BADGE_1
special2 LASTRESULT 0xB4
compare LASTRESULT 0x1
if == jump 0x8162558 ' Equal To
compare LASTRESULT 0x4
if == jump 0x8162561 ' Equal To
compare LASTRESULT 0x5
if == jump 0x8162561 ' Equal To
setflag 0x201
release
end

#org 0x81A7AE0
'-----------------------------------
#raw 0xC9
#raw 0xDC
#raw 0xB8
nop0 ' #raw 0x0
CMD_C3 0x0
#raw 0xE7
#raw 0xD9
#raw 0xD9
setdoorclosed 0xADAD 0xCDFB
#raw 0xE8
#raw 0xDD
#raw 0xE0
#raw 0xE0
#raw 0xB8
nop0 ' #raw 0x0
#raw 0xD6
#raw 0xD9
#raw 0xDD
#raw 0xE2
#raw 0xDB
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xDC
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xE7
#raw 0xDD
#raw 0xE0
#raw 0xD9
#raw 0xE2
#raw 0xE8
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xED
#raw 0xE4
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xDD
#raw 0xE7
nop0 ' #raw 0x0
#raw 0xD5
#raw 0xE0
#raw 0xE7
#raw 0xE3
nop0 ' #raw 0x0
#raw 0xD7
#raw 0xE3
#raw 0xE3
#raw 0xE0
#raw 0xB8
CMD_FE 0xDD
#raw 0xE7
#raw 0xE2
givetocoincase 232 ' Bear in mind, it's not in hex
#raw 0xDD
#raw 0xE8
setdooropened 0xC3FB 0xDC00
#raw 0xE3
#raw 0xE4
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xED
#raw 0xE3
#raw 0xE9
givetocoincase 57568 ' Bear in mind, it's not in hex
nop0 ' #raw 0x0
#raw 0xDB
#raw 0xDD
#raw 0xEA
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xE1
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xDC
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xE3
#raw 0xE4
#raw 0xE4
#raw 0xE3
#raw 0xE6
#raw 0xE8
#raw 0xE9
#raw 0xE2
#raw 0xDD
#raw 0xE8
#raw 0xED
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xE3
CMD_FE 0xE7
#raw 0xDC
#raw 0xD5
#raw 0xE6
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xED
#raw 0xE3
#raw 0xE9
#raw 0xE6
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xDC
#raw 0xE3
#raw 0xE9
#raw 0xDB
#raw 0xDC
#raw 0xE8
#raw 0xE7
nop0 ' #raw 0x0
#raw 0xD5
#raw 0xDB
#raw 0xD5
#raw 0xDD
#raw 0xE2
tempspriteface 0xFF 0xC3
givetocoincase 57568 ' Bear in mind, it's not in hex
nop0 ' #raw 0x0
#raw 0xD6
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xE0
#raw 0xE3
#raw 0xE3
#raw 0xDF
#raw 0xDD
#raw 0xE2
#raw 0xDB
nop0 ' #raw 0x0
#raw 0xDA
#raw 0xE3
#raw 0xE6
#raw 0xEB
#raw 0xD5
#raw 0xE6
#raw 0xD8
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xE3
nop0 ' #raw 0x0
#raw 0xED
#raw 0xE3
#raw 0xE9
#raw 0xE6
nop0 ' #raw 0x0
#raw 0xE2
#raw 0xD9
#raw 0xEC
#raw 0xE8
CMD_FE 0xD6
#raw 0xD5
#raw 0xE8
#raw 0xE8
#raw 0xE0
#raw 0xD9
tempspriteface 0xFF 0xD3
#raw 0xD9
#raw 0xD5
#raw 0xDC
tempspriteface 0xFE 0xC3
#raw 0xE8
givetocoincase 231 ' Bear in mind, it's not in hex
#raw 0xBC
comparehiddenvar 0xBB 0xC9D0
nop0 ' #raw 0x0
checkobedience 0xBBCC
CMD_C3 0xC8
#raw 0xBF
comparehiddenvar 0x0 0xDDE8
#raw 0xE1
#raw 0xD9
tempspriteface 0xFB 0xCE
#raw 0xE3
#raw 0xD8
#raw 0xD5
#raw 0xED
#raw 0xB8
nop0 ' #raw 0x0
#raw 0xEB
#raw 0xD9
givetocoincase 55782 ' Bear in mind, it's not in hex
nop0 ' #raw 0x0
#raw 0xDB
#raw 0xE3
#raw 0xDD
#raw 0xE2
#raw 0xDB
nop0 ' #raw 0x0
#raw 0xE8
#raw 0xE3
nop0 ' #raw 0x0
#raw 0xE4
#raw 0xE6
#raw 0xE3
#raw 0xDA
#raw 0xDD
#raw 0xE0
#raw 0xD9
nop0 ' #raw 0x0
#raw 0xFD
end

#org 0x8162558
'-----------------------------------
nop0 ' #raw 0x0
setmaptile 0x6 0x11 0x252 0x0
setmaptile 0x9 0x4 0x24A 0x1
setmaptile 0x9 0x5 0x252 0x0
setmaptile 0x9 0x7 0x24A 0x1
setmaptile 0x9 0x8 0x252 0x0
setmaptile 0xC 0xD 0x24A 0x1
setmaptile 0xC 0xE 0x252 0x0
setmaptile 0xC 0x10 0x24A 0x1
setmaptile 0xC 0x11 0x252 0x0
return

#org 0x8162561
'-----------------------------------
nop0 ' #raw 0x0
setmaptile 0x9 0x4 0x24A 0x1
setmaptile 0x9 0x5 0x252 0x0
setmaptile 0x9 0x7 0x24A 0x1
setmaptile 0x9 0x8 0x252 0x0
setmaptile 0xC 0xD 0x24A 0x1
setmaptile 0xC 0xE 0x252 0x0
setmaptile 0xC 0x10 0x24A 0x1
setmaptile 0xC 0x11 0x252 0x0
return

.... and then, in the game, the battle obviously freezes up. I feel like i'm missing something really simple here, can anyone help? thank you so much.
 
5
Posts
11
Years
  • Seen Jul 18, 2012
Im a newb, to scripting, and i finally have gotten pksv to work, only one thing im suggesting or well asking. Can you explain flags better. I understand what they are but not how to use them. And i also dont no how to use the jump command and such, really to a newbie scripter all youve done under the flags part was give a example and then define the flags, not how to use them
 

Pinta77

Guest
0
Posts
@Zidca
As far as I know, it is pretty much impossible. I've never seen a tutorial for removing pokemon, and any time i tried to do it from scratch, it didn't work.

@Samuraiskyshot
A flag makes it so something can no longer happen. Use this script as an example:
Spoiler:


When you first talk to the person, the flag (0x1001 in this case) has not been set yet. So according to this script, the person will say "The flag hasn't been set yet." However in this script, flag 0x1001 is set after you talk to the person. the command "checkflag 0x1001" checks to see if the flag has been set yet. So if you talk to them again, the person will say "Now it has." If you remove the "setflag 0x1001" part, then you can talk to this person over and over again and they will continue to say "The flag hasn't been set yet."

You could make a completely separate script for a different person and include "setflag 0x1001". Then if you go back to the first person, they will say "Now it has."

Every time you use a flag, you have to use a different number. If you use the same number for two different scripts, then once the flag is set, it will be set for both scripts. So you have to be careful. Use a different flag number every time UNLESS you want it to work out that way.

I hope that helps out. If it does, great :) if not, sorry. Try youtube. Normally there are lots of tutorials on flags.

I have a question though. (And I'll be honest, I haven't looked through all of the posts yet, my computer is really slow.)

Is there a way to script movement for ruby/sapphire in PKSV? The movements provided on the first post only seem to work on fire red. On ruby they either move the person the wrong way or freeze the game.


I figured out and mastered movement for ruby/sapphire. I need help with the green box script events. I CANNOT figure it out. I need the player to step on the script event and for a message to be displayed. That's it. Can anyone help?
 
Last edited:
22
Posts
11
Years
  • Seen Jan 18, 2015
I'm sorry if anyone has asked this before, but can anyone tell me how to make a custom trade happen in a FireRed Hack? I know the game uses a couple of pre-sets to define the trades, but is there a way to, say, check for a pokemon, remove it if desired, and then give a new pokemon? Or something along those lines? Any and all help would be greatly appreciated.
 
2
Posts
11
Years
  • Seen Aug 9, 2012
Need help.

Hello! I am new with coding so i have some questions:)

I am trying to get the Player to "auto-walk" and talk when you walk on a special point of the ground.
This is my code

Code:
#dyn 0x740000
#org @start
lock
applymovement PLAYER @a
release
end

#org @a
m walk_up end
I have set the script with advance map and set it on the right coords.
But the game freezes when i walk on that spot. WHAT is the problem?
Do i have to set the var number?
Do i have to change the script?
Please ansver...
 
Last edited:
2
Posts
10
Years
  • Seen Jun 8, 2013
hey maybe you can help me out. I been working of editing the script when Pro Oak stops you in fire red and i used pksv and i got the script i think but when i copy and past the offset into a-maps i get this message "No script editor defined. do you know what this means and/or how to fix it
 

AtecainCorp.

Rejishan awake...
1,377
Posts
15
Years
I have and question for you. How can I change FLAGS in Pokemon Ruby Rom? When I open Pokemon Ruby. And click in PKSV FLAGS editor it show me list for FRLG. And I need change flags for Pokemon Ruby. Becouse I want add JOHTO BADGES headers to my rom.
 

Sceptylos

Saint
11
Posts
10
Years
I've been on this for about 2 days and I'm starting to lose hope, what I'm trying to do is make a Team Rocket Grunt escort the player to a little corner in Viridian Forest then battle him but all I can do right now is make him talk, the movement script doesn't work (pretty sure I'm doing it wrong even though I copy/pasted and edited) and I haven't inserted the trainer battle yet.

Code:
#dynamic 0x74000
#org @start
lockall
checkflag 0x1227
if true jump :end
message @a3
callstd MSG_NORMAL
applymovement 0x13 @a1
applymovement 0x13 @a2
pauseevent 0x0
disappear 0x13
setflag 0x1227
:end
releaseall
end

#org @a3
= Hello young one, allow me to escort \nyou through this dangerous forest!

#org @a1
M look_up say_! end

#org @a2
M walk_left walk_left walk_left walk_left walk_left end
 
8
Posts
10
Years
  • Age 53
  • Seen Aug 30, 2017
what is wrong with this script?
when ever I run no matter how much money I have it will take all my money away or,
it will just not work at all.

#dyn 0x740000
#org @Main
lock
faceplayer
showmoney 0x0 0x0
message @First
callstd MSG_Normal
paymoney 1000 0
pause 0xF
updatemoney 0 0 0
message @Second
callstd MSG_Normal
hidemoney 0 0
release
end

#org @First
= You lost money.

#org @Second
= Hahaha.
 

bitelaserkhalif

Falcon Punch!!
69
Posts
10
Years
Errm..Thanks for tutorial, most of them is working fine.

WAIT!
I have another question.
First, how to trigger script like in Rocket Hideout in Mahogany Town?(This meant stepping on scripted title will trigger wild pokemon battle.)
I had tried using script generator, and the game frozen even i had inserted release all, why?

Second, How to creating Interact to battle?(wild battle like articuno on FRLG, and it's on pokemon emerald; I dont know where is an unused flag ones in pokemon emerald).
 
Last edited:

Proteun

Unofficial PokéMusic Composer
266
Posts
10
Years
Hey, tutorials like this are really great and everything, but I just don't know how to put it into the game.
Say, I just want to change what Mom says the first time in FireRed. I know what to write, but how to save it into the ROM?
 
8
Posts
12
Years
  • Seen Apr 17, 2014
Hi guys!

Great tutorial!

Anyway,
I've found out how to change music for any battles I set
(example playsound 0x228 0x228),

But is there any way to change music for random wild battles.

(I intend to use to "load map" script).

I couldn't find it, even after using google. Thanks!
 
Back
Top