Jump to content

B2W2 General ROM Info


Recommended Posts

021D7540 Type-effectiveness chart(0- no effect, 2- .5x dmg, 4- 1x dmg, 8- 2x dmg) Bond697

021BD1A0 Determine type effectiveness for the current attack Bond697

it is in overlay 167 and it is 17x17.

ovl167 starts at 2199900, so do some subtraction.

21d7540 - 2199900 = 3DC40 into the overlay. subtract 0x40 for black 2.

e: the values to use for each type:

typedef enum

{

TYPE_NORMAL = 0x0,

TYPE_FIGHT = 0x1,

TYPE_FLY = 0x2,

TYPE_POIS = 0x3,

TYPE_GROUND = 0x4,

TYPE_ROCK = 0x5,

TYPE_BUG = 0x6,

TYPE_GHOST = 0x7,

TYPE_STEEL = 0x8,

TYPE_FIRE = 0x9,

TYPE_WATER = 0xA,

TYPE_GRASS = 0xB,

TYPE_ELEC = 0xC,

TYPE_PSY = 0xD,

TYPE_ICE = 0xE,

TYPE_DRAGON = 0xF,

TYPE_DARK = 0x10,

} PokeType;

e2: quick example of how to edit.

say i'm using a normal type attack on a rock type. refer to the chart and see that normal is 0x0 and rock is 0x5. even though the array is 17x17 (u8 type_chart[17][17]), they will be 1 long line in the assembled code. so you do this to get the right value to go to:

attacking_type * 17 + defending type + 1 = value to seek to

*the +1 is because the array starts from index 0, not 1. and it's *17 because there's 17 types. so 17*attacking type skips to that type's "row".

so since i have normal attacking and rock defending, i would do 0*17 + 5 + 1 which means to count to the 6th element in the array. so i would count from the top:

OVL_167:021D7540 04 unk_21D7540 DCB 4 -1

OVL_167:021D7541 04 DCB 4 -2

OVL_167:021D7542 04 DCB 4 -3

OVL_167:021D7543 04 DCB 4 -4

OVL_167:021D7544 04 DCB 4 -5

OVL_167:021D7545 02 DCB 2 -6** normal is .5 dmg against rock

OVL_167:021D7546 04 DCB 4

OVL_167:021D7547 00 DCB 0

let's do one more. i have electric attacking bug, so 12*17 + 6 + 1 is 211. so would start at 21D7540 and count to 211 byte by byte. or start @ 3DC40 and add the result to skip to the right value in your hex editor.

** the type chart in white 1 is @ 21F049C. 3A37C in overlay 93 in white 1.

Edited by Bond697
Link to comment
Share on other sites

let's do one more. i have electric attacking bug, so 12*17 + 6 + 1 is 211. so would start at 21D7540 and count to 211 byte by byte.

to find offset every type (start from 0) : 3DC40 + (attacking_type * 17 + 0) ....

is more efficient than dppt, ... i will try test it later xD

Link to comment
Share on other sites

YESSSSS. Thanks, Mr. Bond. Type effectiveness really was my biggest "want" in Gen 5. Now to go to work...

EDIT: I'm having real trouble trying to retrace your steps in altering the types. I think if you gave an example of the actual hexadecimal in that overlay area, I'd have a better idea of what I'm looking for. I've gone to the sector of the rom that you specified, but the bytes I see are way off from I expected to see. This isn't a binary edit, it it, like with move tutors? I feel like I'm stupidly missing something, here.

Link to comment
Share on other sites

YESSSSS. Thanks, Mr. Bond. Type effectiveness really was my biggest "want" in Gen 5. Now to go to work...

EDIT: I'm having real trouble trying to retrace your steps in altering the types. I think if you gave an example of the actual hexadecimal in that overlay area, I'd have a better idea of what I'm looking for. I've gone to the sector of the rom that you specified, but the bytes I see are way off from I expected to see. This isn't a binary edit, it it, like with move tutors? I feel like I'm stupidly missing something, here.

You just missing something ... , idk i just find that quickly and is easy to edit xD. OVA 167 offset is 3DC40.

3DC40 + (attacking_type * 17 + deffending_from_type) .... is for finding that

like :

settype_effectiveness(normal,dark,0); <-- it will edit normal defending attack from dark type to immune (0);

a201302032318000.jpg

Link to comment
Share on other sites

  • 2 weeks later...

opposing trainer and pokemon editing:

(my notes):

type1 8 bytes

u8 strength(iv set- ((strength * 31) / 255)

u8 abil: >>4 if 1 abil1, if 2 abil2, gender:0 skip get rate, else get gender rate for set gender

u8 level

u8 pad

u16 species

u16 form

type2 16 bytes, 4

u8 strength(iv set- ((strength * 31) / 255)

u8 abil: >>4 if 1 abil1, if 2 abil2, gender:0 skip get rate, else get gender rate for set gender

u8 level

u8 pad

u16 species

u16 form

u16 move1

u16 move2

u16 move3

u16 move4

type3 10 bytes, 796

u8 strength(iv set- ((strength * 31) / 255)

u8 abil: >>4 if 1 abil1, if 2 abil2, gender:0 skip get rate, else get gender rate for set gender

u8 level

u8 pad

u16 species

u16 form

u16 item

type4 18 bytes, 813

u8 strength(iv set- ((strength * 31) / 255) the result is used for all 6 ivs

u8 abil/gender: >>4 if 1 abil1, if 2 abil2, gender:0 skip get rate, else get gender rate for set gender

u8 level

u8 pad

u16 species

u16 form

u16 item

u16 move1

u16 move2

u16 move3

u16 move4

nature comes from pid: pid % 25

pkm byte 1, gender/abil byte: abil1 = 10, abil2 = 20, abilDW = 30

they check if the poke has frustration as a move. if not, happiness is 255. if so, set it to 0.

trainer

u8 template

u8 class

u8 battle type

u8 poke count

u16 item1

u16 item2

u16 item3

u16 item4

u32 trainer AI

u8 & 1 healer

u8 cash

u16 item, post battle

template is 0-3, affects pkm type- up above

the rest of healer is not used

post battle item is given out once

trainer AI is a char-sized bitfield. it's read as a u32 though, likely for the sake of future expansion. trainer AI is made up of many parts though(i've spent some time poking at it), so it's not just using the 8 bits as parts to pick through. your best bet for now is to look trainers up and use them as templates. i.e. 1 for normal trainer battles, 7 for event battles, 81 for double battles, 87 for 2v2, etc etc. eventually we'll know what it all does and be able to edit it. it's very complex and very large.

Link to comment
Share on other sites

Pokemon Abilities. Abilities have never been touched since Gen 3 hacks, I think. Not sure what would be entailed in doing that, but custom abilities would allow for a HUGE jump in Pokemon diversity. We can rename existing ones, but that's kind of cheesy and does not allow for effects like, say... "0.5x damage from [insert type]-type attacks" that we don't already have (Heatproof; Fire).

Link to comment
Share on other sites

Continuation of last tutorial, where we now add in a custom script.

[video=youtube;_5QY2mA3GUE]

Script that was inserted

2E 00 
74 00 
A6 00 47 05 

3D 00 00 04 0D 00 00 00 00 00 
47 00 10 80 

09 00 10 80 
08 00 00 00 
11 00 01 00 
1F 00 FF 47 00 00 00

3D 00 00 04 0E 00 00 00 00 00 
32 00 
3F 00 

85 00 9B 00 00 00 00 00 

8D 00 10 80 

09 00 10 80 
08 00 01 00 
11 00 01 00 
1F 00 FF 08 00 00 00 

8E 00 
1E 00 02 00 00 00 

8C 00 

3D 00 00 04 0F 00 00 00 00 00 
1E 00 0A 00 00 00 

3D 00 00 04 10 00 00 00 00 00 

32 00 
3F 00 
2F 00 
02 00

Link to comment
Share on other sites

Safe Flags for added scripts:

Flag Usage

Drayano was re-using flags that were in use by the game already, which caused his added content to be deactivated/activated at times where it wasn't intended. So I just ripped a bunch of sav's Flag Regions (Save: 2025E-203DD) and popped out a list of flags that were set/unset.

Here's what appears to be safe flags that can be used for content:

500-599 
1051-1099
1876-1879
2351-2399
3033-3063

>300 flags should be good for most if not all tweak-hacks.

Send me save files and I can check to see if there's any more flags that are used (28 isn't conclusive!) via PM and I'll update.

Trainer Flags 0-813 occupy region:

1520-2333

Technically it just does setflag (parameter+1520 dec)

Edited by Kaphotics
thanks bond (0-99 clearing)
Link to comment
Share on other sites

Yeah I tried that, there's a few problems with that:

There's a lot of sub-script calling (set variables = flag number, CallSTD #) where the "Flag" logic is a variable. Example script file is the Hidden Item script (furniture overworlds) @ script_1241

scriptfile_1241: PPMax on Route 2

=== Script 131 === 

Offset: 4782 LockAll 
Offset: 4784 SetVar2A 0x8000 53 - PP Max
Offset: 4790 SetVar2A 0x8001 1 - Quantity
Offset: 4796 SetVar2A 0x8002 2951 - Flag to Set
Offset: 4802 CallStd 2811 - Item giving script @ scriptfile_1238, givehiddenitem+sets flag, deactivates OWtile
Offset: 4806 WaitMoment 
Offset: 4808 UnlockAll 
Offset: 4810 End 

NPRE's "dump" isn't functional so I have to scan all 1288~ scripts one at a time in NPRE. On top of that I have to account for the variable flag calling :\

The save files give me a general idea on what blocks of flags are used; large swathes of undetected usage with all save files indicate an unused set of flags. For a not-totally redone game, a few hundred flags should be sufficient for added content.

Link to comment
Share on other sites

Move Animations

[video=youtube;wh_S1I7xwXU]

/a/0/6/5 is the narc that contains all the animations. There's 559 moves + 0_file, additionally there's 41 (560-600) that are unused leftover animations (dummies). I swapped around a few animations for the video and altered the animation for Swords Dance (last move shown) by just changing things randomly.

http://dl.dropbox.com/u/12206225/pporg/musichex.txt

^ list of music hexes by their internal name; if you use VGMTrans you can usually find the sounds that are called by the movescript.

Link to comment
Share on other sites

BW

a/0/0/6

a/0/6/6

BW2

a/0/0/6 <-- spa files is for animation sprite

a/0/6/5 <-- animation frame command (attack)

a/0/6/6 <-- another one was used same format as a/0/6/5 (item animation on battle)

start with :

01000000
3C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C0000003C000000

02000000
7400000074000000740000007400000074000000740000007400000074000000740000007400000074000000740000007400000074000000
AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000AA020000

And other value.

after that, is likely a count to animation object :

04000000

Format : this file used 4 byte.

^i was already mark these file as animation related, and these file was have a structure.

Edited by Andibad
Link to comment
Share on other sites

i didn't realize this was being discussed. i spent a few minutes looking into it awhile back. probably in november, i think.

it's another scripting environment essentially equivalent to the one used for the main script system, just cut down in size. instead of a 256-word stack, it's 16. instead of 64 global variables, there are 8. there are quite a few less commands, though the commands themselves are even more complex than in the main system and some use a LOT of arguments(i count more than a dozen command arguments in one of the commands). the secondary narc is loaded as part of one of the commands and some math is done to jump into a decided-upon file in that narc. afterward, the environment jumps back to where it was.

there's a lot of fixed point math and vector-specific math, so it looks like the commands operate more directly and are more hardcoded than the main environment.

quite a few of the commands have their own subsystems, their own memory blocks/filename allocations, and most of them are built on 10 or more script arguments. while the commands in the main script system are used together and strewn into long, complex scripts, these are used sparingly and are long and extremely complex on their own.

fyi: the first value is actually the number of scripts in the file. after that, the header is really pretty obvious.

Link to comment
Share on other sites

if you want something really interesting to play around with, some of the move script stuff seems to play with some code that's actually situated in vram. gamefreak actually has code hidden in vram starting at 0x6898020.

Link to comment
Share on other sites

Besides abilities, something that I often wonder about editing would be some of the more obscure, innate type attributes, such as:

Fire type's immunity to Burn

Poison & Steel type's immunity to Poison

Are these coded into the status conditions themselves? If I wanted to make some types immune to certain status effects, what would it take?

Some of the others would be tied to certain moves, I think, like Grass type's immunity to Leech Seed, and the Rock type's Special Defense boost in Sandstorm.

On that subject... If we had a greater understanding of move effects, we could easily construct new types of attacks, or, in the case of Sandstorm's effects, perhaps make changes to certain weather effects... For instance, the relationship between weather and certain moves (Rain and Thunder/Hurricane, Sun and Solar Beam, Hail and Blizzard). What if we wanted to add new relationships, like, say, Sandstorm and Sand Tomb, or Sun and Heat Wave... are we limited to changes in accuracy? Are changes in power limited to Solar Beam-style effects? What if Hail or Sun effected stats of certain types? Would understanding the effects of Gravity or Trick Room and others like them help in understanding moves like Rain Dance, or are they totally unrelated? etc.

Link to comment
Share on other sites

all of those check for types as part of the move.

as for the move effects, pretty much all of that stuff is possible. we would need a serious understanding of all the commands and all their arguments to pull it off though. the problem is what i was saying above. the commands are extremely complex- some have their own large subsystems, some commands actually start new script environments that run new commands, and they all have tons of arguments that are really hard to figure out/follow through the code.

Link to comment
Share on other sites

Are these coded into the status conditions themselves? If I wanted to make some types immune to certain status effects, what would it take?

it will complex commands is checking all condition is need to apply these effect. is need expert on hex editing, understand of all command/arguments the game, as bond said is hard part. we need searching, researching all of them first before to start edit them.

to try edit something is related into system / engine, it will extreme complex.

Link to comment
Share on other sites

just to illustrate what i'm talking about, this an average script command from the main script system:

http://pastebin.com/xTCkfREx

now this is an average command from the move command script system:

http://pastebin.com/ghirndHT

that makes the problem pretty obvious. all of those "scriptRead32" calls are for arguments. and that number of arguments is pretty average.

Link to comment
Share on other sites

Figured out how to make an NPC follow you, persistently (even if you save or change maps).

[video=youtube;5VAs68XQKUg]

I'll post more about it once I figure out a little bit more. It's pretty simple when it comes to scripting...

Might as well explain how (now that I have a better understanding)

Relevant portion Hugh's script @ 854:

Offset: 5868 StoreVar 0x8000 
Offset: 5872 StoreVar 0x8001 
Offset: 5876 StoreVar 0x8002 
Offset: 5880 StoreVar 0x8003 
Offset: 5884 StoreVar 0x8004 
Offset: 5888 SetVar2A 0x8000 0 
Offset: 5894 SetVar2A 0x8001 2 
Offset: 5900 SetVar2A 0x8002 1 
Offset: 5906 SetVar2A 0x8003 0 
Offset: 5912 SetVar2A 0x8004 10539 
Offset: 5918 CallStd 10535 
Offset: 5922 ClearVar 0x8004 
Offset: 5926 ClearVar 0x8003 
Offset: 5930 ClearVar 0x8002 
Offset: 5934 ClearVar 0x8001 
Offset: 5938 ClearVar 0x8000 

Note: Bianca does it too in reversal mountain @ 1078, and the Humilau Meinfoo @ 940. Bianca can detach at 1072_#176d. Hugh also can do it for the Sewers, but I didn't bother checking.

Script that is called with the CallStd-> 1275:

Offset: 349 StoreFlag 2406 
Offset: 353 CompareTo 1 
Offset: 357 Condition EQUAL
Offset: 361 If FALSE Function 5 (370 )
Offset: 368 ReturnStd 
Offset: 370 0x250 
Offset: 372 8000 
Offset: 374 8001 
Offset: 376 8002 
Offset: 378 8003 
Offset: 380 8004 
Offset: 382 22E 254
Offset: 386 ReturnStd
Offset: 388 End

Detachment Script:

Offset: 390 StoreFlag 2406 
Offset: 394 CompareTo 0 
Offset: 398 Condition EQUAL
Offset: 402 If FALSE Function 6 (411 )
Offset: 409 ReturnStd 
Offset: 411 0x251 0x8000 0x8001 
Offset: 417 ReturnStd 
Offset: 419 End 

So for the parameters of the CallStd (the 0x250 routine):

50 02 - command 0x0250
01 00 - param1 - NPC that gets attached
02 00 - param2 - ????
01 00 - param3 - persistency (00 not, 01 yes)
01 00 - param4 - NPC to do a double battle with
2C 29 - param5 - script to call when interacted with
2E 02 - command 0x022E
FE 00 - param1 - NPC to attach as

Haven't bothered looking at the detachment. Couldn't get the game to not double battle everything wild, so it's stuck requiring a trainer# to battle with. The whole command would have to be edited/tinkered with to prevent doing so for a HGSS style follow me (such that param4=FFFF -> don't force).

Example script:

50 02   Command
01 00   overworld NPC to attach
02 00   ???
01 00   Persistent Flag (yes)
01 00   Trainer to enter a double battle with
2C 29   Script to call when interacted with

2E 02 FE 00	Pretty sure this sets the NPC Overworld ID to 254
	whenever the map is changed (does the adding?)

Non-commented:
50 02 01 00 02 00 01 00 01 00 2C 29 2E 02 FE 00

Edited by Bond697
Link to comment
Share on other sites

  • 3 weeks later...

I'd to greatly thank those who came up with the Hex editor and Andibad for his PWT/Subway viewer. I've finally finished coming up with the list of possible EV spreads for the enemy Pokemon in the Battle Subway/PWT

Here's an example:

A000 7F00 F200 1801 0800 0A03 0A01

The 2 digits in red on this line is the EV spread. This is the Feraligatr I modified... giving it the exact moves my Feraligatr have. Anyway...

Those 2 digits "0A" mean that Feraligatr has 255 EVs for Attack & Speed.

Here's the link for the complete list of EV spread via Hex to view:

http://www.mediafire.com/view/?t812v8mdih5dwe2

This might make you come up with your own version of the Battle Subway/PWT.

Now if only someone can come up with a Battle Subway editor to add more Pokemon and enlist them in a trainer's roster... I would've done it myself... but I don't know anything about compiling stuff together to make an editor.

Edited by PKMNTrainerNick144
Link to comment
Share on other sites

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...