(The second half is 'give item'.)
(This shows more uses of flags.)
Okay, so you got down the talking scripts? Feel free to do some exercises if you did not, but I suggest you don't start on this lesson until you get the first 2 down, because the elements of the first two lessons will be used over and over again, and if you don't understand something, you will not be able to understand the harder scripts.
Now, today we will work on 'giving items'. This script is very easy (you actually don't use a lot of the things you've already learned). However, call this lesson a 'filler', a 'break', after we are done, we're going to do something much more difficult. But, I'll talk about that in the next lesson.
Now, as you know, in Pokemon, you can receive items from pokeballs found on the map, you can buy items from the shop, and you can get items from people. While 'give item' scripts are very easy, incorporating them into the methods mentioned above can prove to be much more of a challenge.
Finding an Item (normally the sprite is a pokeball):
Okay, so you got down the talking scripts? Feel free to do some exercises if you did not, but I suggest you don't start on this lesson until you get the first 2 down, because the elements of the first two lessons will be used over and over again, and if you don't understand something, you will not be able to understand the harder scripts.
Now, today we will work on 'giving items'. This script is very easy (you actually don't use a lot of the things you've already learned). However, call this lesson a 'filler', a 'break', after we are done, we're going to do something much more difficult. But, I'll talk about that in the next lesson.
Now, as you know, in Pokemon, you can receive items from pokeballs found on the map, you can buy items from the shop, and you can get items from people. While 'give item' scripts are very easy, incorporating them into the methods mentioned above can prove to be much more of a challenge.
Finding an Item (normally the sprite is a pokeball):
give_item_pokeball.pks | |
File Size: | 0 kb |
File Type: | pks |
Shopping at the Market:
pokemart.pks | |
File Size: | 0 kb |
File Type: | pks |
Getting an item from a person:
give_item_person.pks | |
File Size: | 0 kb |
File Type: | pks |
Oh look, it's that 'Yes/No Question' script again. I hope you can make those scripts now, because I will not be explaining those scripts again. Lets start with the first script, finding an item. Open the script file I have (or look below).
#dyn 0x740000
#org @start
copyvarifnotzero 0x8000 SEAINCENSE
copyvarifnotzero 0x8001 1
callstd MSG_FIND
setflag 0xAAA
end
Wow, other than the first two lines, and the last line, we have a whole new script! Nothing looks familiar! Well, let me make the script familiar for you, and carve it into your memory.
copyvarifnotzero 0x8000 SEAINCENSE
copyvarifnotzero 0x8001 1
The game will check if the 'item var' is 'zero'. If it is not, it will add the item 'SEAINCENSE'. The same is for the bottom, but the '1' determines the quantity of the item.
callstd MSG_FIND
Another 'callstd' value. This one will display the "'Player' found a 'item name'. 'Player' put the 'item name' into the 'pouch name'.".
setflag 0xAAA
This is the perfect time to explain 'flags'. 'Flags' are special variables used within the game to help 'store' events. Whenever you put a 'setflag' command, followed by a number (or hex), the game will record that flag as 'set'. A set flag can be checked with 'checkflag', or removed with 'clearflag'. Using flags allows you to help record certain actions which can determine future possibilities. For example, when Oak lets you choose one of the starters, say you picked Bulbasaur (I don't know why people hate this pokemon, he's awesome). After you pick Bulb, the script will set a flag (we'll say the flag is ABCDE for now). So, somewhere further in the script, the game will see if flag ABCDE is set. If it is, it will jump to the offset of the script where your rival picks Charmander. However, if you picked Charmander, the game will set flag 12345 instead. Further down the script, it will first check if flag ABCDE is set. If it is not, it will check if flag 12345 is set. If 12345 is set, the script will jump to the offset where the rival picks Squirtle. The use of flags can allow different paths to occur, and using flags can trigger special events. In this case, when we set flag AAA, we want the item containing the item (normally a pokeball) to stay removed from the game. If we don't use this flag, the pokeball will reappear after you walk a step, or reenter the map, and we don't want that.
(Note: In advance-map, it is recommended that you make your NPC's person ID the flag you set.)
#dyn 0x740000
#org @start
copyvarifnotzero 0x8000 SEAINCENSE
copyvarifnotzero 0x8001 1
callstd MSG_FIND
setflag 0xAAA
end
Wow, other than the first two lines, and the last line, we have a whole new script! Nothing looks familiar! Well, let me make the script familiar for you, and carve it into your memory.
copyvarifnotzero 0x8000 SEAINCENSE
copyvarifnotzero 0x8001 1
The game will check if the 'item var' is 'zero'. If it is not, it will add the item 'SEAINCENSE'. The same is for the bottom, but the '1' determines the quantity of the item.
callstd MSG_FIND
Another 'callstd' value. This one will display the "'Player' found a 'item name'. 'Player' put the 'item name' into the 'pouch name'.".
setflag 0xAAA
This is the perfect time to explain 'flags'. 'Flags' are special variables used within the game to help 'store' events. Whenever you put a 'setflag' command, followed by a number (or hex), the game will record that flag as 'set'. A set flag can be checked with 'checkflag', or removed with 'clearflag'. Using flags allows you to help record certain actions which can determine future possibilities. For example, when Oak lets you choose one of the starters, say you picked Bulbasaur (I don't know why people hate this pokemon, he's awesome). After you pick Bulb, the script will set a flag (we'll say the flag is ABCDE for now). So, somewhere further in the script, the game will see if flag ABCDE is set. If it is, it will jump to the offset of the script where your rival picks Charmander. However, if you picked Charmander, the game will set flag 12345 instead. Further down the script, it will first check if flag ABCDE is set. If it is not, it will check if flag 12345 is set. If 12345 is set, the script will jump to the offset where the rival picks Squirtle. The use of flags can allow different paths to occur, and using flags can trigger special events. In this case, when we set flag AAA, we want the item containing the item (normally a pokeball) to stay removed from the game. If we don't use this flag, the pokeball will reappear after you walk a step, or reenter the map, and we don't want that.
(Note: In advance-map, it is recommended that you make your NPC's person ID the flag you set.)
Note: There are special flags within the game, which you guys can use to trigger special events in the game (for example, getting your running shoes, or badges. You can also make the SS Anne cut scene, or get the national dex). To find the special flags, go to the 'tools' tab in PKSV-UI, and click on 'Flag List'.
If you don't really want to remember this concept (I didn't), feel free to use the generator. Click on 'Find Item', and you will automatically get the script. I will not go into more detail, since this script is very straightforward, and I don't believe anyone will need too much help. However, just to make sure, I will make one scenario for you guys to do.
Scenario:
Find a 'Potion' when you talk to an 'NPC'.
If you don't really want to remember this concept (I didn't), feel free to use the generator. Click on 'Find Item', and you will automatically get the script. I will not go into more detail, since this script is very straightforward, and I don't believe anyone will need too much help. However, just to make sure, I will make one scenario for you guys to do.
Scenario:
Find a 'Potion' when you talk to an 'NPC'.
give_item_pokeball_answer.pks | |
File Size: | 0 kb |
File Type: | pks |
Okay, lets look at the pokemart script.
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
showmsg
pokemart @store
message @thank
callstd MSG_NORMAL
release
end
#org @talk
= What do you want?
#org @thank
= Thanks for shopping.
#org @store
item POKEBALL
item POTION
item ANTIDOTE
item REPEL
endmart
Well, at least this script has some familiar stuff to it. You probably noticed that after 'message', there was no 'callstd'. This is because when we are asked the 'Buy, Sell, See ya!' option, we do not want to close the script if we press a button. So, to prevent that, we use a 'showmsg' line for the 'message' to show up, and make our button pressing options be at the 'Buy, Sell, See ya!' location.
'Pokemart' will activate the 'shop' menu, where you buy the stuff. I made my pokemart offset '@store'. If you scroll to the bottom, where my '@store' offset is defined, you can see all of my shop items.
(Note: If you want to change the prices of the items, you will need an external program. The item values are built into the game, so scripting will not (or it might, but you have to find it) be able to change the prices.
That is all for pokemarts. Now, let us try out a scenario.
Scenario
When you talk to a clerk, make him sell pokeballs, super potions, super repels, revives, and moo moo milk.
Good luck. Check your answer with my script, or test it out in game.
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
showmsg
pokemart @store
message @thank
callstd MSG_NORMAL
release
end
#org @talk
= What do you want?
#org @thank
= Thanks for shopping.
#org @store
item POKEBALL
item POTION
item ANTIDOTE
item REPEL
endmart
Well, at least this script has some familiar stuff to it. You probably noticed that after 'message', there was no 'callstd'. This is because when we are asked the 'Buy, Sell, See ya!' option, we do not want to close the script if we press a button. So, to prevent that, we use a 'showmsg' line for the 'message' to show up, and make our button pressing options be at the 'Buy, Sell, See ya!' location.
'Pokemart' will activate the 'shop' menu, where you buy the stuff. I made my pokemart offset '@store'. If you scroll to the bottom, where my '@store' offset is defined, you can see all of my shop items.
(Note: If you want to change the prices of the items, you will need an external program. The item values are built into the game, so scripting will not (or it might, but you have to find it) be able to change the prices.
That is all for pokemarts. Now, let us try out a scenario.
Scenario
When you talk to a clerk, make him sell pokeballs, super potions, super repels, revives, and moo moo milk.
Good luck. Check your answer with my script, or test it out in game.
pokemart_script_answer.pks | |
File Size: | 0 kb |
File Type: | pks |
Now here comes the main attraction: giving items. This is the lesson you came for, right? If you open up the script I wrote for this part of the lesson, you might recognize some older stuff, and some new stuff.
#dyn 0x740000
#org @main
lock
faceplayer
checkflag 0x73B
if == jump @alreadygave
message @talk
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
message @give
callstd MSG_NORMAL
additem POKEBALL 1
setflag 0x73B
release
end
#org @no
message @keep
callstd MSG_NORMAL
release
end
#org @alreadygave
message @goaway
callstd MSG_NORMAL
release
end
#org @talk
= Want a Pokeball?
#org @goaway
= I already gave you one.
#org @give
= Okay.
#org @keep
= Fine, don't take it.
Wow, look at that! Lets start!
checkflag 0x73B
Boy, 'flags' again. This line will 'check' if 'flag' 0x73B has been set or not. If it has not, it script will continue. If the flag has been set, we will jump to '@alreadygave'. I will now jump straight to the #org @yes, because everything else should be straightforward (they are part of the 'yes/no' scripts). As you can see, we have
additem POKEBALL 1
setflag 0x73B
The 'additem' just adds the item into your inventory without displaying the message. Put the item you want to add, then the quantity of the item.
We have a 'setflag' again. We will set the flag number 0x73B after we receive the item. If you look back to the top of the script, we have a 'checkflag', which will jump to another part of the script (give no more items basically) if the flag is set. Adding a flag will prevent the NPC from giving you items over and over again.
All right, lets work on a Scenario. This last part may be a bit tricky, since flags may seem a bit confusing, but I know you can do it!
Scenario: Make the person give you a PICHU (any level, and holding any item) if you want one. However, make sure the person only gives you ONE pichu.
(Use 'addpokemon (pokemon's name in caps) (the pokemon's level) (the item the pokemon is holding, use '00' if the pokemon is holding no item) and 3 '0' to add a pokemon)
Ex. 'addpokemon PIKACHU 30 POTION 0 0 0' will give the player a level 30 pikachu with a potion.
'addpokemon PIKACHU 25 00 0 0 0' will give the player a level 25 pikachu with no items.
#dyn 0x740000
#org @main
lock
faceplayer
checkflag 0x73B
if == jump @alreadygave
message @talk
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
message @give
callstd MSG_NORMAL
additem POKEBALL 1
setflag 0x73B
release
end
#org @no
message @keep
callstd MSG_NORMAL
release
end
#org @alreadygave
message @goaway
callstd MSG_NORMAL
release
end
#org @talk
= Want a Pokeball?
#org @goaway
= I already gave you one.
#org @give
= Okay.
#org @keep
= Fine, don't take it.
Wow, look at that! Lets start!
checkflag 0x73B
Boy, 'flags' again. This line will 'check' if 'flag' 0x73B has been set or not. If it has not, it script will continue. If the flag has been set, we will jump to '@alreadygave'. I will now jump straight to the #org @yes, because everything else should be straightforward (they are part of the 'yes/no' scripts). As you can see, we have
additem POKEBALL 1
setflag 0x73B
The 'additem' just adds the item into your inventory without displaying the message. Put the item you want to add, then the quantity of the item.
We have a 'setflag' again. We will set the flag number 0x73B after we receive the item. If you look back to the top of the script, we have a 'checkflag', which will jump to another part of the script (give no more items basically) if the flag is set. Adding a flag will prevent the NPC from giving you items over and over again.
All right, lets work on a Scenario. This last part may be a bit tricky, since flags may seem a bit confusing, but I know you can do it!
Scenario: Make the person give you a PICHU (any level, and holding any item) if you want one. However, make sure the person only gives you ONE pichu.
(Use 'addpokemon (pokemon's name in caps) (the pokemon's level) (the item the pokemon is holding, use '00' if the pokemon is holding no item) and 3 '0' to add a pokemon)
Ex. 'addpokemon PIKACHU 30 POTION 0 0 0' will give the player a level 30 pikachu with a potion.
'addpokemon PIKACHU 25 00 0 0 0' will give the player a level 25 pikachu with no items.
give_pichu_answer.pks | |
File Size: | 0 kb |
File Type: | pks |
What we discussed today:
Giving Items (main)
Flags
Giving Items (main)
Flags
Flags will be used again, so do not think that they are only in the 'give item' section. If you don't understand flags, reread my explanation, or ask me to clarify (I know the description wasn't that good). However, if you got this all down, and feel you can make these scripts with no sweat, we're going to try something much more difficult: MOVEMENT!
P.S You will need flags for the next lesson.
P.S You will need flags for the next lesson.