I like to hack saved game files. It’s just something I’ve done for many years now. I got into that kind of stuff back when I first started getting into computers.

I’ve hacked a lot of different games now. For a lot of different systems too. I’ve hacked many NES, SNES, Sega Genesis, N64, and PC games. One of the fun things about hacking a save file is learning how that game went about storing/writing the data of the game. A lot of games seem to go about it different ways. I think overall I’ve seen a pretty popular way of doing it, and some extremely random unoptimized way of doing it (or perhaps I never understood the reasoning behind their storage methods).

Item IDs
Any game that has Items uses Item IDs, some way of identifying which item the item is. Is this item a sword, a potion, or a key?

NES, SNES and Sega Genesis games are usually straight forward about how to do this. They usually only use 1 byte for the Item ID, and they use the full range. And almost always, 00 is used as the “Empty” spot in the Inventory. I’ve also seen 255 used as “Empty”. Like in Final Fantasy 3 (My favorite game, btw), there’s only 1 byte used for the Item ID, so there are only 255 items in the game. Imagine my surprise (and anger) when I learned that there was no Paladin Ring! I spent months trying to farm that ring. But the internet wasn’t around back then and the rumors insisted that the item was real and that it existed… Yea. It didn’t exist as I found out years later, from hacking all the items into the game. And for all those jerks out there insisting that the Paladin Ring is real… YOU’RE A JERK!

*Deep breath*

Anyways.

When it comes to PC Items, the ID always seems to be 4 bytes (signed or unsigned, who knows) values. In some games, it seems randomly generated. Just take a look at some of the Item IDs of Summoner:



Now I understand that I’m not seeing the full picture of the Item IDs, not having access to the code of such a great game, but still… why are the Item IDs so seemingly random? Why not just go 0 through number of items in the game and save time?

In other PC games, the Item ID starts at some value, then each item after that is a certain value more than the last item’s value. Take Recettear for example.

Worn Sword ID = 64
Rusty Dagger = 6464
Focus Staff = 12864
Wooden Bow = 19264

See the pattern? Now I have no idea what the next category of items is… but I bet I know it’s value: 25664.

Inventory Layout
Usually the layout I see with inventories in save files is this

[ItemA ID][ItemB ID][ItemC ID]… (after whole inventory listed) [ItemA Quantity][ItemB Quantity][ItemC Quantity]… (for every item)

That works really well. ESPECIALLY if you have a fixed inventory size (like a lot of old console games did back then). Usually console games like to have a set size for their save files (Because they have a specific layout of the save file).

Some games don’t have a quantity at all, but rather, just repeat the item ID over and over in the inventory for the quantity that you have. Super Mario RPG is an example of a game like that.

One of the more interesting ones I saw is how Lufia 2 does it’s inventory.. Each item is 2 bytes long, but there are less than 512 items in the game.. so although the lower byte is completely used, the 2nd byte is only ever 00 or 01… but this isn’t what makes Lufia 2′s inventory system neat. Lufia 2 also uses the higher byte to store the quantity of the item. It takes the quantity, doubles it, and adds it to the higher byte. So if you have an item who’s ID is 0×0100, (1 in hex, with little endian ordering), if you want 99 of that item, you take 99, double it to 198, convert 198 to hex (C6), and add that to the higher byte: 01C6. So that gives you 99 of 0100.

It can get confusing when your Item IDs aren’t clean looking to begin with.

Why… On… Earth…?
The last game I made a hack program for… had such a weird system for their items. You can have up to 15,000 items in your inventory. Instead of writing out Item ID, and then Item quantity… it just writes out the Item ID over and over and over until for as many of that item as you have. This makes the save file for that game HUGE. 17.8 MB. I don’t see too many save files that are in MB’s like this.

I honestly think out of all the systems, the most efficient is something that writes out the Item ID, and then a Quantity somewhere as well. That way your inventory only has to be big enough to hold as many items in the game that exist. So if you have 256 items (including “Empty” slots) in your game, and you can only hold 99 of each item at the most ever… You could store your whole inventory as 512 bytes. Efficient.

Recettear,… the game with the 17.8 MB save file, only has 538 items in it’s game. Being generous, you could use 8 bytes per item, a 4 byte ID, and a 4 byte quantity, and be able to hold farrrrrrrrrrrr more items with farrrrrrrrrrr less space. Instead it uses 4 byte ID, and no quantity, and pastes the ID over and over, capping at 15K items. That means at most you could have 27-ish of each item in the game (I did int division, so no remainder (15000/538 = 27)). That’s pathetic. Whereas with 8 bytes per item, 538 items… That’s 4,304 bytes, and it allows you to have BILLIONS of EACH item. Efficient. Okay. Rant over.
Well,

Time flies! Apparently I blinked at some point as it is no longer December, but rather January, and the month is almost over! Our game is looking so beautiful. Our final final turn-in is on Thursday. I’ve been polishing and bug-fixing all month. It’s crazy how much easier it is to bug-fix and polish than it is to create a core part of the game’s system.

I always seem to work on features of the game that are invisible – collisions, frustum culling and AI, things of that sort. Well everyone on our team has been given a title… and I had no idea what mine should be called. At first, we settled on “Data Lead”, but it sounded silly. Honestly if it didn’t sound so bad, I’d call myself “Invisible Lead”, because all the tech I work on works quietly in the background. Eventually we settled on Collision Lead. And I guess that’ll have to do.

Anyways, the game is beautiful. I think tomorrow we’re suppose to make a Fraps video so we can make another awesome advertisement for our game’s presentation (Which is February 3rd, by the way). I honestly can’t wait to post the game as a download on my site. It really is a good game. It supports multiplayer as well, up to 4 players (using XBox 360 controllers).

Well. I’ll not spoil the surprise… if you want to learn more about the game – Mini-Mech: Exterminator… you’ll have to come to our presentation! It’s on February 3rd at Full Sail Live, 1PM. Be there! =)

Other than the game, I’ve been working on the mythical “About Me” section of the site… It’s not finished yet, so that’s why it’s not accessible on the navigation (as of January 23rd), but when it is finished… well, this site will be a little more personal. It’s going to include some of the side projects (Not programming related) that I’ve done.

Well I think I’ve rambled enough. Have a nice day, everyone. =)

~Bruce
Hi everyone,

One of the fun things about being a programmer is some of the funny variable names you can run into while coding stuff.

My friend was working on making minidump files, which are files that can be used to determine the cause of a crash in a program, when he came across the minidump file types.

1st of all… we’re college students, 2nd of all, we’re in Game Development, so we can’t help but laugh just by saying “lol We’re making minidumps”. And then my friend Tovar found the enums for Minidump_types and they are hilaaaaaaarious. Apparently there’s many ways to take a dump!



Awesome stuff. My personal favorite? Minidump with full memory. You’ll never forget that dump. LOL.

~Bruce
Hello everyone,

Here’s how to find the planes of your camera frustum and how to test if an object is inside all of the the frustums. Please note that the update listed below makes your plane normals point INWARD. If you want your normals to point outward, then multiply them by -1.0f and leave me be.

Here’s a picture of what the normals will look like:

 
  //Declare needed variables and enums for this demonstration here...
  D3DXMATRIX ViewProjection, CameraViewMatrix, CameraProjectionMatrix;
  D3DXPLANE m_d3dPlanes[6];
  D3DXVECTOR3 vTestPoint(0.0f, 0.0f, 50.0f);
  enum { P_LEFT, P_RIGHT, P_TOP, P_BOTTOM, P_NEAR, P_FAR };
 
  //Get the Camera's View Matrix
  CameraViewMatrix = CCamera.GetViewMatrix();
  
  //Get the Projection Matrix
  CameraProjectionMatrix = CCamera.GetProjectionMatrix();
  
  //Multiply them together
  D3DXMatrixMultiply( &ViewProjection, &CameraViewMatrix, &CameraProjectionMatrix );
 
  //Calculate each plane
  //.a,.b,.c = Plane Normal
  //.d = Plane Distance
  
  // Left plane 
  m_d3dPlanes[P_LEFT].a = ViewProjection._14 + ViewProjection._11; 
  m_d3dPlanes[P_LEFT].b = ViewProjection._24 + ViewProjection._21; 
  m_d3dPlanes[P_LEFT].c = ViewProjection._34 + ViewProjection._31; 
  m_d3dPlanes[P_LEFT].d = ViewProjection._44 + ViewProjection._41;
  
  // Right plane 
  m_d3dPlanes[P_RIGHT].a = ViewProjection._14 - ViewProjection._11; 
  m_d3dPlanes[P_RIGHT].b = ViewProjection._24 - ViewProjection._21; 
  m_d3dPlanes[P_RIGHT].c = ViewProjection._34 - ViewProjection._31; 
  m_d3dPlanes[P_RIGHT].d = ViewProjection._44 - ViewProjection._41;
 
  // Top plane 
  m_d3dPlanes[P_TOP].a = ViewProjection._14 - ViewProjection._12; 
  m_d3dPlanes[P_TOP].b = ViewProjection._24 - ViewProjection._22; 
  m_d3dPlanes[P_TOP].c = ViewProjection._34 - ViewProjection._32; 
  m_d3dPlanes[P_TOP].d = ViewProjection._44 - ViewProjection._42;
 
  // Bottom plane 
  m_d3dPlanes[P_BOTTOM].a = ViewProjection._14 + ViewProjection._12; 
  m_d3dPlanes[P_BOTTOM].b = ViewProjection._24 + ViewProjection._22; 
  m_d3dPlanes[P_BOTTOM].c = ViewProjection._34 + ViewProjection._32; 
  m_d3dPlanes[P_BOTTOM].d = ViewProjection._44 + ViewProjection._42;
 
  // Near plane 
  m_d3dPlanes[P_NEAR].a = ViewProjection._13; 
  m_d3dPlanes[P_NEAR].b = ViewProjection._23; 
  m_d3dPlanes[P_NEAR].c = ViewProjection._33; 
  m_d3dPlanes[P_NEAR].d = ViewProjection._43;
 
  // Far plane 
  m_d3dPlanes[P_FAR].a = ViewProjection._14 - ViewProjection._13; 
  m_d3dPlanes[P_FAR].b = ViewProjection._24 - ViewProjection._23; 
  m_d3dPlanes[P_FAR].c = ViewProjection._34 - ViewProjection._33; 
  m_d3dPlanes[P_FAR].d = ViewProjection._44 - ViewProjection._43;
 
  // Normalize the normal of the plane, thus making the plane useful. =P
  for (unsigned int i = 0; i < 6; i++) 
  {
    D3DXPlaneNormalize( &m_d3dPlanes[i], &m_d3dPlanes[i] );
  }
  
  //Now anytime you want to test to see if something is within the frustum
  //Call D3DXPlaneDotCoord() function with the point (or object position)
  //on all planes, and if the results are all positive, the point (object)
  //is in the frustum.
  //Example:
  if(D3DXPlaneDotCoord(&m_d3dPlanes[P_LEFT], &vTestPoint) > 0.0f
     && D3DXPlaneDotCoord(&m_d3dPlanes[P_RIGHT], &vTestPoint) > 0.0f
	 && D3DXPlaneDotCoord(&m_d3dPlanes[P_TOP], &vTestPoint) > 0.0f
	 && D3DXPlaneDotCoord(&m_d3dPlanes[P_BOTTOM], &vTestPoint) > 0.0f
	 && D3DXPlaneDotCoord(&m_d3dPlanes[P_NEAR], &vTestPoint) > 0.0f
	 && D3DXPlaneDotCoord(&m_d3dPlanes[P_FAR], &vTestPoint) > 0.0f)
  {
    //Test point is inside the frustum.
	//Render() or something awesome;
  }


Grid Partitioning

Our game’s partitioning system ran into a problem today, and due to working with that problem, it has been changed.

Our game is partitioned using a 2D grid system that overlooks the world from a top-down view.

Here’s an example world shown from the top-down view.


Here’s the world broken into the grid system.


Our world’s triangles use to be split up using 2 checks. The first split is determined by seeing if any of the triangle’s vertices are within the grid.


However, this will not cover all situations,…


… So we had another check after that to see if any of the grid’s corners were within the triangle.


And for awhile, this system worked great in our game. However, recently we discovered a special situation that slips through the partition system…


As you can see in the above situation,… no vertex of the triangle is in the grid, and no corner of the grid is within the triangle… So our character was running through walls in our game!

So we revamped the partition system. Now there’s only 1 check, it’s much faster than any other the other checks, and it works for all situations. We flatten every triangle in the world by setting it’s Y to 0 (rather, just ignoring the Y completely), and then do a 2D Line to Box intersection. This covers all situations.


And finally, we kept in the collision check that checks Grid points to see if they are inside triangles. That should take care of all triangle situations.



Well,

I learned a tough lesson today. I lost a lot of time working on this. Today I was suppose to get the newest level exported and loaded up into our game so that I could test collisions against it and get the collision code up and running in our game… but every time we exported and loaded up the level… there was nothing there!

Eventually we figured out that the level was extremely massive. Massive beyond reasoning. So we had the artist import the character into the scene, and then the artist scaled the level down to the character’s size to make it look appropriate…

But after exporting the level again… it was still massive!!

Turns out that just because Maya will import another maya file into your scene… doesn’t mean it will tell you the truth.

The character’s units were in centimeters… whereas the level’s units were in meters.

My question and frustration is… Why doesn’t Maya do a conversion when you bring in a model on different units into your scene??? Why do they ‘fake’ it the way they do?? The fact that Maya didn’t bring in the character and have the character be a microscopic piece of dust in centimeters in a world that is meters long and wide… wasted so much of our time.

Instead Maya let us drag a model in centimeters up to a door in meters and made it look like they were in the same size.

That’s just wrong, Maya. Thanks.


I decided to go out and get a plugin for my WordPress that allows me to type code without needing to worry about the special characters of & and > and <. Hopefully this test will work!


//Testing the &...
int x = 0;
int* y = &x;
//Testing the < and >...
if(x > 0 || x < 0)
     return -1;
cin >> x;
cout << x;


Well. It seems to work. Good stuff! =)

~Bruce


Well,

It has been an interesting day today. Our group noticed that in our game ‘Til Dawn, our player would shoot slightly to the left of where he was aiming when the enemy got too close to the player.

It turned out that the Ray being used to test against the collision tree wasn’t hitting the leaf nodes, but rather stopping on some of the outer parent nodes and returning that collision point…

This would have bullets fly near the enemy, hit the outerspheres, but miss the inner spheres where real collision takes place, like the damaging of enemies.

So I basically rewrote the recursive part of the function. My logic was something along these lines

//////////////////////////////////////////////////////////////////////////////////////////

For every enemy, start at the root.
bool bAnswer = false;

–Start Recursion Point–

Does this node’s sphere collide with the Ray?
{
   If Yes, Does this node have children nodes?
   {
      If Yes, For every child, Test for collision (back to beginning of recursion)
   }
   else this node does NOT have children
   {
      This is a leaf, is this collision a shorter time record?
         If so, Save time and collision point, set bAnswer to True
   }
}
return bAnswer;

//////////////////////////////////////////////////////////////////////////////////////////

And when I recompiled… it worked. =) So I’m happy about that. Now I think I’m going to take the rest of the day off.

Have a nice day.

~Bruce


Well now I have a blog up and running on my site.

Hello everyone!

It’s 2AM in the morning… I should be sleeping. But like always, I seem to work best late at night. Installing WordPress wasn’t too hard. Now I just want to add all of my friends to the link section of the site. Also maybe later I can get my background as the background of this blog.

Today was a good day today. I worked on collisions in our game (‘Til Dawn). Now our crossbow bolts collide with animated enemies. The enemies use a collision tree class that I wrote. It’s beautiful. It takes a creature, makes a giant collision sphere around them, and then splits that sphere up by the models joints, and then recursively splits those spheres up. It’s beautiful, it really is. I love it.

At first it didn’t work, Tovar Shoaf had to help me fix a few bugs in it,… but now it works perfectly.

It’s neat because when the debug rendering is on, you see this blob of collision spheres moving with the rendered model.

I tested the collision tree by shooting bolts at the enemies, and it works. The enemies got hit and died. Our game is coming along smoothly.

If you want to see information about ‘Til Dawn, check out my Current Projects section, and click on Learn More in the ‘Til Dawn section.

… or just click here.