Multiple characters sharing an inventory

Started by JD, Wed 24/12/2003 22:09:42

Previous topic - Next topic

JD

Hi peeps,

While working on my game I encountered a problem. My game has
4 playable characters (you can switch between them) and I want them
to share an inventory. I thought of having an invisible character following
the current character who would act as the inventory; so when you open
the inventory you'd use a SetPlayerCharacter(INVENTORY); and then it would
display the inventory. Then when you'd close the inventory screen it would
switch back to the original player. But here's the problem: My inventory is
displayed on screen, in the gui, which is visible at all times. Does anyone have
any ideas?

Thanks in advance,

Def

JD

Hmm I might have found a solution myself. I could just, whenever
an inventory item is added/removed from the inventory, add/remove
it to/from every character.

Pumaman

Yep, I think that's the best way.

On the other hand, you could just use the inventory normally - but when they switch player character, you copy the inventory across.

That way you only have to update the main player's inventory during gameplay, and when they switch characters you sync the others with them.

You can copy inventory by doing something like this:

int a = 0;
while (a < 100) {
 character[CHAR1].inv[a] = character[CHAR2].inv[a];
 a++;
}

(replace 100 with however many inventor yitems there are in the game).

That script will make CHAR1's inventory the same as CHAR2.

JD

Thats a pretty good way of doing it, cheers!

SMF spam blocked by CleanTalk