[Fallout 2][C++] GetItemName function

Firehawk

First time out of the vault
Hello modders, and players of the Fallout series (I'm assuming Fallout 1 and 2)

I recently started up replaying Fallout 2, and I couldn't resist doing a little bit of hacking after finishing my playthrough.

Anyhow, I was poking around and found a function you guys might like.

Code:
char* GetItemName( DWORD id )
{
	static DWORD pGetItemName = 0x49EAFC;

	__asm{
		mov eax, id
		call pGetItemName
	}
}

http://www.nma-fallout.com/content.php?page=fo-modding-fo-list-itemlist

I was dissecting the Inventory Item data (and didn't get very far) when I found that webpage. It was going to be one hell of a problem to reference all of that in my code, so I instead decided to just seek out this function. It wasn't too hard to find, but this is quite a helpful function (For example, someone could code a Fallout 2 Item dumper.)

But yeah, consider this my welcome to the forums. I hope to post more snippets as I work with Fallout 2.

Cheers,
Firehawk.
 
Oh yeah?
Code:
InventorySlot* pItem = SearchContainer( WEAPON_PlantSpike );

		if ( pItem != NULL )
		{
			pItem->ItemData->ObjectID = WEAPON_TommyGun;
			pItem->ItemData->AmmoType = AMMO_MicroFusionCell;
			pItem->ItemData->Ammo = 10;
		}

Well, I can turn my Plant Spikes into Tommy Guns that shoot MicroFusion Cells. Can your editor do that?!?!?!?!

Lol, but jokes aside, I'm aware of the existence of the savegame editor. This is mostly to satify some need in me to hack whatever I can. I learn a lot about ASM every time. Plus, there's a lot of stuff you can do with the game's memory that you can't do by modifying savegame files.

Speaking of Inventory,

Code:
class CItemData
{
public:
char _0x0000[60];
	DWORD Ammo; //0x003C 
	DWORD AmmoType; //0x0040 
char _0x0044[32];
	DWORD ObjectID; //0x0064 
char _0x0068[28];

};//Size=0x0084

class InventorySlot
{
public:
	CItemData *ItemData;
	DWORD Amount;
};

class CPlayerInventory
{
public:
	InventorySlot Container[1];
};

Code:
DWORD InvPatch = 0x0046ECC6;
DWORD InvPatch_Exit = 0x0046ECCC;

void __declspec( naked ) InventoryPatch()
{
	__asm{
		pushad
		pushfd
		mov eax, [edx + 0x08] //Get inventory handle
		mov Inventory, eax //Store the handle
	}
	pInventory = (CPlayerInventory*)Inventory;
    __asm{		
		popfd
		popad
		mov dword ptr ds:[0x59E960],edx //Store the player handle.
		jmp InvPatch_Exit
    }
}

Some of the stuff I've dissected from the memory so far. I wish I could interpret more from CItemData, but I can't. Maybe someone else has had more luck than I have, who knows.

I wrote a mid-function hook to grab a handle to the Inventory. You can also grab a handle to the player (Which, is mystery I'll probably get into some other time). If you want to get the amount of items in the Inventory, or the allocated amount of space given to the container,

Code:
edx + 0x00 - Items in Inventory
edx + 0x04 - Allocated space for Inventory. This is automatically increased when you go over the amount (Realloc), which means the location of the inventory changes.

There is only a handle to the player or the inventory once you've opened your inventory at least once (which I don't quite fully understand yet).

Anyhow, I've said enough for now. Hope to see some people who are interested in his kind of hacking on here.
 
Back
Top