Jump to content

Pokemon Black: Scripting Lessons(I try...)


Recommended Posts

Set a flag when you give the egg. At the start of the script, do a checkflag to see if the egg is already given.

Here's a Randomized Egg script that I wrote which gives a random baby egg, once.

http://pastebin.com/raw.php?i=7gvFDa66

Take the happiny egg script for example. It uses two flags; one for checking if the egg has been offered and another that checks to see if it has been given.

Happiny egg script is in file 54 for B2W2.

=== Script 4 === 

Offset: 118 LockAll 
Offset: 120 StoreFlag 437 
Offset: 124 CompareTo 0 
Offset: 128 Condition EQUAL
Offset: 132 If FALSE Function 0 (339 )
Offset: 139 PlaySound 1351 
Offset: 143 FacePlayer 
Offset: 145 StoreFlag 436 
Offset: 149 CompareTo 1 
Offset: 153 Condition EQUAL
Offset: 157 If FALSE Function 1 (180 )
Offset: 164 Message2 0 4 4 0 0 = ' This Pokémon Egg was\nfound at the Day Care.\c\nWould you raise it? '
Offset: 174 Jump  Function 2 (194 )

=== Function0=== 

Offset: 180 Message2 0 4 3 0 0 = ' Um... Excuse me...\nTrainer?\r\nThis Pokémon Egg was found at the\nDay Care. Would you raise it? '
Offset: 190 SetFlag 436 
Offset: 194 YesNoBox 0x8010 
Offset: 198 StoreVar 0x8010 
Offset: 202 CompareTo 0 
Offset: 206 Condition EQUAL
Offset: 210 If FALSE Function 3 (319 )
Offset: 217 GiveEgg (0x10F) 0x8010 440 0 
Offset: 225 StoreVar 0x8010 
Offset: 229 CompareTo 1 
Offset: 233 Condition EQUAL
Offset: 237 If FALSE Function 4 (299 )
Offset: 244 Message2 0 4 7 0 0 = ' Oh! OK!\r\nPlease take good care of this Egg!\r '
Offset: 254 CloseMessageKeyPress2 
Offset: 256 SetFlag 437 
Offset: 260 SetVarHero 0 
Offset: 263 PlayFanfare 1317 
Offset: 267 EventGreyMessage 9 0 = ' [VAR NAME: 1 0] received the Egg! '
Offset: 273 WaitFanfare 
Offset: 275 CloseAngryMessage 
Offset: 277 CloseMessageKeyPress2 
Offset: 279 Message2 0 4 8 0 0 = ' Apparently, putting Pokémon Eggs next\nto healthy Pokémon is a good thing.\r\nIn other words, walk with the Egg.\r\nYou know, the Day Care is on Route 3.\nThey might be able to tell you more. '
Offset: 289 WaitButton 
Offset: 291 CloseMessageKeyPress2 
Offset: 293 Jump  Function 5 (313 )

=== Function1=== 

Offset: 299 Message2 0 4 5 0 0 = ' Um...\r\nYour party is full.\nYou don't have room to hold the Egg. '
Offset: 309 WaitButton 
Offset: 311 CloseMessageKeyPress2 
Offset: 313 Jump  Function 6 (333 )

=== Function2=== 

Offset: 319 Message2 0 4 6 0 0 = ' Oh... OK.\nI understand.\r\nIf you change your mind,\nplease come talk to me again. '
Offset: 329 WaitButton 
Offset: 331 CloseMessageKeyPress2 
Offset: 333 Jump  Function 7 (359 )

=== Function3=== 

Offset: 339 PlaySound 1351 
Offset: 343 FacePlayer 
Offset: 345 Message2 0 4 8 0 0 = ' Apparently, putting Pokémon Eggs next\nto healthy Pokémon is a good thing.\r\nIn other words, walk with the Egg.\r\nYou know, the Day Care is on Route 3.\nThey might be able to tell you more. '
Offset: 355 WaitButton 
Offset: 357 CloseMessageKeyPress 
Offset: 359 WaitMoment 
Offset: 361 UnlockAll 
Offset: 363 End 

Edited by Kaphotics
fixed pointer on #checkup, thanks drayano!
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

Will there be any more continuation of the previous tutorial? I would love to learn more commands. I think this is the 2nd week since I started hacking gen 5 roms and I'm starting to grasp the concept a lot faster now that I've reviewed this tutorial. I think the main thing I need reinforced is actually plugging scripted hex into an overworld without causing the rom to crash lol. But if I'm assuming correctly, I just look for a 2E 00 to 02 00 hex string to replace with a newly written script correct?

Link to comment
Share on other sites

Will there be any more continuation of the previous tutorial? I would love to learn more commands. I think this is the 2nd week since I started hacking gen 5 roms and I'm starting to grasp the concept a lot faster now that I've reviewed this tutorial. I think the main thing I need reinforced is actually plugging scripted hex into an overworld without causing the rom to crash lol. But if I'm assuming correctly, I just look for a 2E 00 to 02 00 hex string to replace with a newly written script correct?

I've done a few tutorial videos on my channel; there's more information in the video descriptions and also in the B2W2 General ROM Info thread.

Link to comment
Share on other sites

I've seen your tutorials and understand that, however for someone new to gen 5 rom hacking, they are awesome to look at and inspiring, however most of them go completely over my head, as I'm sure with a few other people (because they are simple for you, but advance for us). The tutorial here actually explained what the scripting function of each hex string did, which was not present in the video. Where in a few videos we were given the actual script to place, most of us look at it like...what am i supposed to do with it. Yes I could have deciphered the script that you gave, however it would have taken a very long time to figure out how it functioned down to a science. Also I don't understand how to replace a script within the hex. I've tried doing so which led to the game freezing, reason I wanted to clarify instead of repeated trial and error until I found a breakthrough.

Link to comment
Share on other sites

When you replace a script, did you make sure that the header repoints to the new script? Also, does any interaction freeze the game, or is it specific?

To make things easier, you could copy out the entire script, hex edit it in notepad, paste it back and repoint the header to the correct script.

Link to comment
Share on other sites

I'm not sure exactly how to do that. And basically an area of the map crashed, so if i tried to enter say a part of chargestone cave it would freeze the game. How would i go about repointing the header? and also how do i know where said hex script began and ended. By the way i was modifying scripts in the overworld narc if that helps any

Link to comment
Share on other sites

there's a few things that are wrong with what you're saying, maleficusu.

Overworlds are entirely different from Event Scripts and Text. You can't mix files.

For NPC editing it's best to use Kazo's tool (although if you can do it in hex I'd do it that way, as NPCE deletes trigger data at the end). My lua script in my tutorial video can check to see if the data has been edited properly if you activate the checking mechanism ingame at the location.

Link to comment
Share on other sites

  • 3 months later...
  • 7 months later...
Set a flag when you give the egg. At the start of the script, do a checkflag to see if the egg is already given.

Here's a Randomized Egg script that I wrote which gives a random baby egg, once.

http://pastebin.com/raw.php?i=7gvFDa66

Take the happiny egg script for example. It uses two flags; one for checking if the egg has been offered and another that checks to see if it has been given.

Happiny egg script is in file 54 for B2W2.

=== Script 4 === 

Offset: 118 LockAll 
Offset: 120 StoreFlag 437 
Offset: 124 CompareTo 0 
Offset: 128 Condition EQUAL
Offset: 132 If FALSE Function 0 (339 )
Offset: 139 PlaySound 1351 
Offset: 143 FacePlayer 
Offset: 145 StoreFlag 436 
Offset: 149 CompareTo 1 
Offset: 153 Condition EQUAL
Offset: 157 If FALSE Function 1 (180 )
Offset: 164 Message2 0 4 4 0 0 = ' This Pokémon Egg was\nfound at the Day Care.\c\nWould you raise it? '
Offset: 174 Jump  Function 2 (194 )

=== Function0=== 

Offset: 180 Message2 0 4 3 0 0 = ' Um... Excuse me...\nTrainer?\r\nThis Pokémon Egg was found at the\nDay Care. Would you raise it? '
Offset: 190 SetFlag 436 
Offset: 194 YesNoBox 0x8010 
Offset: 198 StoreVar 0x8010 
Offset: 202 CompareTo 0 
Offset: 206 Condition EQUAL
Offset: 210 If FALSE Function 3 (319 )
Offset: 217 GiveEgg (0x10F) 0x8010 440 0 
Offset: 225 StoreVar 0x8010 
Offset: 229 CompareTo 1 
Offset: 233 Condition EQUAL
Offset: 237 If FALSE Function 4 (299 )
Offset: 244 Message2 0 4 7 0 0 = ' Oh! OK!\r\nPlease take good care of this Egg!\r '
Offset: 254 CloseMessageKeyPress2 
Offset: 256 SetFlag 437 
Offset: 260 SetVarHero 0 
Offset: 263 PlayFanfare 1317 
Offset: 267 EventGreyMessage 9 0 = ' [VAR NAME: 1 0] received the Egg! '
Offset: 273 WaitFanfare 
Offset: 275 CloseAngryMessage 
Offset: 277 CloseMessageKeyPress2 
Offset: 279 Message2 0 4 8 0 0 = ' Apparently, putting Pokémon Eggs next\nto healthy Pokémon is a good thing.\r\nIn other words, walk with the Egg.\r\nYou know, the Day Care is on Route 3.\nThey might be able to tell you more. '
Offset: 289 WaitButton 
Offset: 291 CloseMessageKeyPress2 
Offset: 293 Jump  Function 5 (313 )

=== Function1=== 

Offset: 299 Message2 0 4 5 0 0 = ' Um...\r\nYour party is full.\nYou don't have room to hold the Egg. '
Offset: 309 WaitButton 
Offset: 311 CloseMessageKeyPress2 
Offset: 313 Jump  Function 6 (333 )

=== Function2=== 

Offset: 319 Message2 0 4 6 0 0 = ' Oh... OK.\nI understand.\r\nIf you change your mind,\nplease come talk to me again. '
Offset: 329 WaitButton 
Offset: 331 CloseMessageKeyPress2 
Offset: 333 Jump  Function 7 (359 )

=== Function3=== 

Offset: 339 PlaySound 1351 
Offset: 343 FacePlayer 
Offset: 345 Message2 0 4 8 0 0 = ' Apparently, putting Pokémon Eggs next\nto healthy Pokémon is a good thing.\r\nIn other words, walk with the Egg.\r\nYou know, the Day Care is on Route 3.\nThey might be able to tell you more. '
Offset: 355 WaitButton 
Offset: 357 CloseMessageKeyPress 
Offset: 359 WaitMoment 
Offset: 361 UnlockAll 
Offset: 363 End 

What am I to do if I would like to change the ability/IVs/moves of the Pokemon upon hatching?

Thanks in advance!

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...