Search the Community
Showing results for tags 'kaphotics'.
-
Introduction: Scripting is what coordinates and executes in-game events to create a story for the player. Gen III hacks have been able to tell new stories with custom scripts written from scratch; future hacks in more current generations are key for good hacks. This thread is to provide information in regards to how to script, what script commands do, and some example scripts. I'll try to go more in depth than pichu2001 did in his basic tutorial thread; if you are just starting off scripting, you should definitely read his thread first. Starting Information: First you need to extract the Script .narc with NitroExplorer, and unpack it into the individual files with editor.exe (kiwi.ds). Program & Lua starter kit: download here The location of the scripts is /a/0/5/6 There is currently no XSE equivalent of symbolic scripting for B2W2. We're doing this with hex. So have a hex editor ready (HxD or Hex Workshop), and get PPNFR to replace the individual scripts you edit. How do you know what script is used where? You currently need to use a Lua script while emulating. The script depicted below is in the starter kit. At the bottom right corner of the touch-screen, it tells you which Script is being used. Correlate this with the file numbers you extracted from the narc. Script Structure: As previously described by pichu2001 , the script contains two parts. The pointers and the scripts that are pointed to. Pointers are 4 bytes long (32 bits); the first script in this example image points to 00 00 00 38, which is equivalent to 00000038 = 0x38. 0x38 bytes after this pointer is the start of script 1. Use this formula to find the script's location in the file: Current Read Offset + Pointer Value = Script Offset In this example image, 0x04+0x38 = 0x3C. The first script is located at 0x3C... unfortunately it starts off reading as "End", so the script ends there. Try finding the offset of Script 2; you should get 0x3E, which just so happens to start right after Script 1 ends. To tell the game to stop reading pointers, a 16 byte "STOP" = 13 FD is used (0xFD13). After the STOP, there are no more pointers and the raw script command data starts. Pointers are an important part of the file; if you insert anything between existing data, the pointers will point to improper locations. I'll cover this later. Hello World: Interpreting Existing Scripts Knowing how to script requires you to observe how commands are normally used by others. I'll show you an example script that has an NPC says a text line and ends the script when dismissed. Above is the example script file. As you can see, it contains one script, which starts at 0x06. [color="purple"]02 00 00 00[/color] [u][i]13 FD[/i][/u] [color="blue"]2E 00 A6 00 47 05 74 00 3D 00 00 04 0A 00 00 00 00 00 32 00 3F 00 30 00 2F 00 02 00 00 00[/color] First we must separate out our script data. Remove everything before the start of our script (everything before 0x06) [color="blue"]2E 00 A6 00[/color] [color="green"]47 05[/color] [color="blue"]74 00 3D 00[/color] [color="green"]00 04 0A 00 00 00 00 00[/color] [color="blue"]32 00 3F 00 30 00 2F 00 02 00[/color] 00 00 Looks decent, let's make this more easily to see: [color="blue"]2E 00[/color] -- [color="red"]LockAll[/color] [color="blue"]A6 00[/color] [color="green"]47 05[/color] -- [color="red"]PlaySound Clink[/color] [color="blue"]74 00[/color] -- [color="red"]FacePlayer[/color] [color="blue"]3D 00[/color] [color="green"]00 04 0A 00 00 00 00 00[/color] -- [color="red"]Message2, text line 0xA, default settings[/color] [color="blue"]32 00[/color] -- [color="red"]WaitKeypress[/color] [color="blue"]3F 00[/color] -- [color="red"]CloseMessage2[/color] [color="blue"]30 00[/color] -- [color="red"]WaitDelay[/color] [color="blue"]2F 00[/color] -- [color="red"]UnlockAll[/color] [color="blue"]02 00[/color] -- [color="red"]End[/color] 00 00 -- Padding to make the file's size divisible by 0x4 This is gibberish to the untrained eye, so I'll explain what each line does in 'English'. [color="red"]LockAll[/color] [color="blue"]0x002E[/color] -- Stop all movements of NPCs and Player. LOCK EVERYTHING. [color="red"]PlaySound Clink[/color] [color="blue"]0x00A6[/color] [color="green"]0x0547[/color] -- Play a sound, sound number 0x0547 - "clink" [color="red"]FacePlayer[/color] [color="blue"]0x0074[/color] -- Make the NPC that was interacted with face the player [color="red"]Message2[/color] [color="blue"]0x003D[/color] -- Pops up a speech bubble from the interacted with NPC [color="green"]0x0400[/color] -- Tells the game to use the current text file [color="green"]0x000A[/color] -- Tells the game to use text line 0xA [color="green"]0x0000[/color] -- Tells the game to place the bubble away from interaction [color="green"]0x0000[/color] -- Tells the game to use the default speech bubble [color="red"]WaitKeypress[/color] [color="blue"]0x0032[/color] -- Wait until a button is pressed before proceeding [color="red"]CloseMessage2[/color] [color="blue"]0x003F[/color] -- Close the popped up speech bubble [color="red"]WaitDelay[/color] [color="blue"]0x0030[/color] -- Waits a frame; cools down the game [color="red"]UnlockAll[/color] [color="blue"]0x002F[/color] -- Allow all NPCs and player to move [color="red"]End[/color] [color="blue"]0x0002[/color] -- Ends the script; read no further! Pretty easy to interpret when you know what each command is... Value Storage: Flags, Containers (const) and Variables The game likes to keep track of what has happened in game, and your choices that you have made. If you get an item from an NPC, the game sets a flag so that the NPC doesn't give it out again. The game also sets flags to prevent NPCs from spawning (so that progress based NPCs appear/disappear) [*]If you choose a certain starter, the game sets a Const container to know what Rival teams to face you against. Constants are stored in the save file along with flags. [*]Variables are temporary values that are used to contain values for a short time. Variables do the majority of the work in scripts. They are defined by some command, then later used as dynamic parameters. Essentially symbolic math. Variables are not saved in the save file; however if they are not cleared/set properly their values can persist into other custom scripts. When you are done with them, clear them! Conclusion: Part 1 This introduction to scripting is just touching the surface on what you can do with B2W2 scripting. With over 800 commands at your disposal (more than 3x that of Gen III), there's so much more you can do!
-
I have been lately in a strugle with the pokebank legitimacity, but I just wondering, can we create events such as the snorlax or the mew z cristal??? How??
-
Hi, people. I have a question about Pokémon Black & White script editing. I know that: a/1/2/5 contains the overworld data. a/0/5/7 contains the scripts. My question is: how is the overworld data calling up scripts from the script narc? I know that overworlds have hex data for ''script'' added, but I don't know how that corresponds with the data in the script narc (a/0/5/7). I know for example that the overworld data is grouped per map. So all data of Route 2 is together in one part of the narc. For example, the script hex data of the Lass on Route 2 is BA 0B. Which part of the script narc does that relate with? How is the script data arranged?