B2W2 Tutorial: Battle Scripting and more

welcome back last time we successfully added an overworld sprite to the game or we didn't assign her a new script today we'll be making and adding a battle script for her to use to start off we have to assign her the new script value before we make it open the overworld file that the NPC is on in our example it's file 125 then do the same method as the last video to figure out which hex we have to change you since we are no longer using the script that the young boy uses which is script one we will have to assign our script three script two is used by the lady so yeah that's why we're using script three as you can see we only made one change to the file which was just replacing one hex with another that means that we don't have to fiddle around with the header so everything is good to go go ahead and save the file and get rid of the window just like the last video we're going to have to reinsert the edited overworld file back into the open world mark using PP NFR we can do this so in this example we're reinserting file 125 and we pick file 125 now that we've defined our NPC to use script 3 we actually have to define what script 3 is going back to this movie we can see that our display tells us at the bottom right corner that the script file use on this map is 224 now where exactly is script 224 I'm going to have to extract more narks at this point with nitro Explorer to be since we want a customized message when we talk to the NPC we're going to have to edit the text this is in a 0 0 3 so pull that one out and it's Story text next we're going to want to pull out the script narc which is a 0 5 6 in black and white 2 want to name this script snark now that we have our script narc we have to extract all the scripts that are inside of it so with editor exe we're going to have to extract everything just like last time let's click the check box and extract all this will make the new folder with all the scripts inside now we're going to have to open up the script that the map uses which was in our example script 2 to 24 so we're going to find it open it up in our hex editor and whoa whoa hold on let's first go over the structure of a script file there's a header and then there's data and something that tells you when to stop reading the header is 1 3 FD 1 3 FD is basically a stopped reading so there's pointers at the beginning of a script file they are 4 bytes long and they point to a script that starts later in the script file so if you highlight right after the script this certain length that the pointer tells you to you will point directly to the start of the script here's an example script file which kind of illustrates how you point to a start of a script so 0 6 points to the 2 e and the 1 e points to another 2 e so 2 e is an instruction to block everything and start a script for our actual script file let's go ahead and show that 24 bytes after the pointer is the start of the second script since I kind of just showed you how to do the first one while I was talking about the other one so the ultimate question is after we pointed to the data what does the data mean so what is 2 e and all the data afterwards mean well it's basically a machine instruction on certain commands that it pulls off so we lock everything and then you do a script I've put a lot of work into implementing all these commands into NPR II so we're going to open up this program which I've included and it doesn't matter which ROM you open but let's open our hacked rom that we're hacking and let it load you we're going to navigate to a o56 right click it and then we're going to open it as a script narc we're going to navigate now to script 224 and we can see that this program parses all the script data and tells us what the script does you so let's kind of go over what the boys script does so first you lock everything and play a sound then you start to display a message after you face the player once we've progressed through the message we're going to wait for a button press and once we've pressed a button we're going to dismiss the message wait a moment unlock everything and end the script so it's a pretty simple script and battle scripts are a little bit more complex so it's going to be a little bit of a shock at first sight but I'll explain it you so now for practice let's go ahead and isolate the boys script so we can just see how it works ourselves rather than rely on the program so let's go ahead and isolate all the data open up a new notepad just so we can not use a hex editor paste it in and let's go ahead and separate it out into lines of instructions so we've got two we lock everything a six play a sound seven four which is face the player 3d for applying a message which is message zero three to four wait a moment meanwhile key press three e this miss message 3 0 4 wait a moment 3 F unlock everything and and go2 so that's pretty much paralleled to exactly what the program prints out it's kind of pretty simple 16-bit instructions that's how it works so let's go ahead and close out of the script window that mpre shows and now we're going to do our battle script for Scylla so now we're going to do I've already pre written the script but it just goes ahead and see what we're going to do for a battle so first we're going to block all face the player play a sound do a message pop it yes no so just ask to want to battle yeah no okay and depending on their response we're going to have to branch out in different directions so it's kind of like a choose your own adventure book since this is probably still confusing I've got a little figure well couple screenshots of what I plan the event to be so we're going to start off with a hey you want to battle yes/no and depending on our response we're going to have to branch out to different areas so if we say yes we're going to battle if not we're going to say oh okay and then the script after the battle if we said yes we're going to end the battle once the battle is over we'll thank them for the battle and end the script to elaborate further let's just go show the different paths that one can take with this script we've copied the image and let's go and show it in paint and let's go just let's just go over the paths that we can take so yes goes one way no bows another you so this just shows an ideal script but let's go show it in the actual written out script that I've already done so we go ahead and open up a new copy of paint and we can just start drawing the paths that we can take to this script you so as you can see there is two decision points as I'm now highlighting the first one is if you want to battle or not if you say yes you're going to go one way if you say no you're going to go the other and also the other one is at the battle so depending on if you win or lose the battle you can have one outcome and/or another outcome so that's pretty much how a script work so kind of have to think in some sort of logical progression going from A to B or A to C and follow your own path so it's pretty much exactly like those choose your own adventure books so you're probably wondering how on earth I came up with this script already well it's pretty easy so you kind of think on how the scripts going to progress you name your commands that you think you're going to use and then you look up the commands that you're going to use la call to e next you have face player and yeah that's pretty much it so I've already converted it to the hex form you you so I've already converted the entire script to hex form but it mean there's a little bit of a problem that we have to address all these go twos and those are going to have to be pointed to so they're essentially pointers where we're going to have to jump from one to the next so it right after the pointer you got to count up how many hex you're going to have to jump over for the first jump for our decision on if we're going to say yes or no we're actually decide or figure out how many we're gonna have to jump over so and we're going to select how far we're jumping and it's not for D it's actually 47 or X 47 so we're going to change that and that that should be our finished script now that our script is finished we can paste it in at the end of the original script file now we actually have to insert a new pointer now we want the toy I'll size to be divisible by four so since we have two so far just add in two zeros to make the file size divisible by four to point the third script to the script that we wrote problem is there's no pointer there we only have two pointers to begin with so we're going to press the insert key on our keyboard and insert in four new bytes of data now we're going to select how much we have to point to so we're pointing x-38 forward to our new script and hold on we forgot one two things the pointers have to be pointing to their script that we're using so the first script we added four bytes in between we have to actually fix it now so we should really just add four bytes and the next one we're gonna have to add four bytes again because we also shifted everything four bytes further down the line by adding the pointer so you can just go ahead and check to see that the two pointers point to their original locations and that is it for the script file at this point just minimize everything and close out of your emulator now since we're finished with the script file we actually have to insert the text lines we're going to open up PP txt to the text file that we had go ahead and open up the story text narc and navigate to the text file that we're using for the game oops I forgot we didn't note that one down so let's go ahead and go back into the emulator and see which text file that the game is actually using so at the bottom right corner we can see that the game uses a script file 131 so you can kind of see a preview on what I had I was testing it out last night I have a save state but just ignore what you see go ahead and navigate to file 131 or whichever file you're editing and you can see that the text is here this is the text that this map uses I'm going to go ahead and explain why I used lines d e f and ten for our script if we go ahead and count starting at zero so trading sweethearts that line is line zero go ahead and count each line you'll count 0 1 2 3 4 5 6 7 8 9 ABC count and hex so there's total of 13 lines that are used at C lines are used so we're going to have to add these four lines is a problem though pptx t can't add lines what we can do is insert a blank text file that I will provide and with that we can then insert our extra lines because the blank text file will have like 600 or so lines you can edit so we're going to make a copy of the current text put it in notepad and then we're going to insert a blank text file to overwrite 131 with PP NFR once we've done that go ahead reopen PP txt and then we're going to navigate back to 131 you see oh it's blank go ahead and paste back in the text that we've backed up and now we can add in our own text so I'm going to write in four lines according to how I planned out the event you now that I've done that we have successfully added text so I go ahead save the text save the NARC and I'm done editing my text what we didn't do was add our script file back into the script nark so go ahead and use PPT PP n FR to insert back in your script file you now that we're done with everything we have three files that we have to reinsert so we have to do is reinsert them back into their proper place first we insert the text file the story tax narc back into a zero zero three next comes the script file which we put back in a 0 5 6 then we put in the overworld narc into a 1 2 6 once we've reinserted all of them back into their proper place the ramen is done we can go ahead and go in game to see all of our changes after we've done all of that hard work we know that she's a signed script 3 which is a battle script so let's go ahead make a save state then talk to her and it's exactly how we planned it so if you say no she'll say oh ok if we say yes she'll say yeah and then we'll battle you after the battle is over she will say a parting message and that's it so congratulations you've added a customized script to your game on a inserted custom MPC so feel free to experiment with different scripts so use a NPR II to see how you do scripts and how other scripts work especially a battling wild Pokemon or just movement scripts and you'll become a much better descriptor that way I just feel free to try certain stuff and yeah that's the end of the tutorial go ahead and check NP re open up your arm and check out your script that you inserted you can kind of see how it all worked out you all right that's the end of the tutorial thanks for watching for these 22 minutes happy hacking you

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


Leave a Reply

Your email address will not be published. Required fields are marked *