Fandom

Plants vs. Zombies Wiki

Comments10

Inner workings

1Zulu July 4, 2015 User blog:1Zulu

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

This is a page with a collection of information about PvZ2 code, the OBBs, and more gained through reverse engin... I mean, code introspection.

This content is targeted towards programmers who may want to expand upon my work. I'll open-source OBB Patcher and related tools when I feel it's more ready.

OBB Format

The OBB file is composed of resources laid down in blocks with the following format:

<header> <data>

The header consists of the string "pgsr" and metadata about the data to follow. This includes the filename(s), and the expected uncompressed size of the data, which comes exactly 16 bytes after the end of the filename(s) and is stored as a little-endian 32-bit integer. The offset within the uncompressed chunk at which the file starts is stored 12 bytes after the end of the filename.

Data, when in compressed format, uses zlib with high compression settings (0x78da header). The Chinese version uses default compression (0x789c header).

Both the headers and the data are aligned to 4096 offsets to allow for fast random access.

Texture Formats

Textures are "Image" type resources named *.PTX. In addition to the uncompressed size, the header also contains the dimensions of the texture. These are stored exactly 32 bytes after the name, and are also 32-bit ints in little endian order.

As far as I can tell, PvZ2 uses three texture formats (all of them are header-less):

Uncompressed

These are simply uncompressed RGBA8888, ie: RGBA with 8-bit color depth.

The iOS version for some reason inverts the blue and red channels.

These textures require a size of width * height * 4 bytes.

ETC1

These are compressed textures used by the Android version.

It's composed of ETC1 data followed by the uncompressed alpha channel. For example, in a 512x512 texture the first 131072 bytes are the ETC1 data, and the next 262144 bytes is the alpha channel.

These textures require a size of (width * height) * 3/2 bytes.

PVRTC

These are compressed textures used in the iOS versions.

They are simply PVRTC 4 bits per pixel RGBA textures stripped of their headers. Some versions also include an uncompressed alpha channel, laid out the ETC1 + Alpha textures above.

These textures require a size of (width * height) / 2 bytes when it's pure PVR, or (width * height) * 3/2 bytes when it's PVR + Alpha.

Sound Assets

These "SoundBank" type assets stored in *.BNK files (Wwise SoundBank), which are thoroughly documented here:

http://wiki.xentax.com/index.php?title=Wwise_SoundBank_(*.bnk)

The sound files (*.wem) can be trivially extracted from the *.bnk files and converted to ogg vorbis using ww2ogg by hcs (use the --pcb packed_codebooks_aoTuV_603.bin switch). Some players won't play the .oggs correctly. In this case, you can use revorb to recompute the granule positions.

Some of *.wem files are streamed and can be found elsewhere in the OBB (look for STREAMINGWAVES\*.WEM files). You can refer to streamingWaves.rton for more information about the *.WEM files.

Other resources

"Image" and "SoundBank" are two of the main types stored in the OBB. It also other assets, like animations, text, and more.

  • .PAM: PopAnim type. Animations in a proprietary PopCap format; likely derived from Flash formats
  • .POPFX: RenderEffect type; another proprietary PopCap format (fairly uncommon)
  • .TTF: PrimeFont type. True-type fonts used by the game

Additionally, there are other types stored under the "File" type:

  • .RTON: RTON is a proprietary PopCap serialization format for binary data. Property sheets for game assets, plants, zombies, levels, and more are all stored in this format. See spec here: RTON Format
  • .TXT: Unicode text files, like lawnstrings.txt, which contains localization data
  • .WEM: Streaming waves for sound assets not present in SoundBanks.

Plant IDs

  • Missing: 43, 45, 46, 47, 48, 49, 56, 57, 75, 77, 80 (1-87)
  • Snow Pea, Power Lily, Jalapeno (not in any order): 21, 33, 38
  • Sunflower = 1
  • Peashooter = 2
  • Wall-nut = 3
  • Potato Mine = 13
  • Bloomerang = 27
  • Cabbage-pult = 6
  • Iceberg Lettuce = 11
  • Grave Buster = 10
  • Twin Sunflower = 35
  • Bonk Choy = 5
  • Repeater = 14
  • Snow Pea = ?
  • Kernel-pult = 19
  • Snapdragon = 15
  • Power Lily = ?
  • Spikeweed = 16
  • Coconut Cannon = 9
  • Cherry Bomb = 8
  • Spring Bean = 20
  • Spikerock = 37
  • Threepeater = 17
  • Squash = 39
  • Split Pea = 23
  • Chili Bean = 22
  • Torchwood = 18
  • Lightning Reed = 24
  • Tall-nut = 4
  • Jalapeno = ?
  • Pea Pod = 25
  • Melon-pult = 7
  • Winter Melon = 34
  • Imitater = 32
  • Laser Bean = 12
  • Blover = 30
  • Citron = 40
  • E.M.Peach = 29
  • Starfruit = 31
  • Infi-nut = 28
  • Magnifying Grass = 26
  • Tile Turnip = 41
  • Hypno-shroom = 52
  • Sun-shroom = 42
  • Puff-shroom = 44
  • Fume-shroom = 55
  • Sun Bean = 50
  • Pea-nut = 54
  • Magnet-shroom = 51
  • Chomper =
  • Lily Pad = 58
  • Tangle Kelp = 61
  • Bowling Bulb = 59
  • Homing Thistle = 62
  • Ghost Pepper = 65
  • Guacodile = 64
  • Banana Launcher = 60
  • Sweet Potato = 66
  • Sap-fling = 67
  • Hurrikale = 68
  • Hot Potato = 72
  • Pepper-pult = 71
  • Chard Guard = 70
  • Fire Peashooter = 53
  • Stunion = 74
  • Rotobaga = 69
  • Dandelion = 76
  • Lava Guava = 82
  • Red Stinger = 78
  • A.K.E.E. = 81
  • Endurian = 84
  • Toadstool = ?
  • Stallia = 85
  • Gold Leaf = 79
  • Strawburst = ?
  • Cactus = ?
  • Phat Beet = 88
  • Celery Stalker = 90
  • Thyme Warp = 89?
  • Electric Blueberry = ?
  • Garlic = 93
  • Spore-shroom = 92
  • Intensive Carrot = 94

Also on Fandom

Random Wiki