Multiple Characters-one inventory

Started by Isegrim, Mon 22/09/2003 20:35:18

Previous topic - Next topic

Isegrim

Hi!

Is there an EASY way of having multiple characters sharing one inventory?
This post was generated automatically and therefore bears no signature.

Pumaman

Each character has their own inventory. Perhaps if you explain what you're trying to do, we can think of an easier solution.

Scummbuddy

make global ints that will remember what inventory items are currently in your players position, and when you change characters, you can do a check on all inventory items. small if statements asking if the global int X is 0 or 1,and then add inventory if 1
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

JD

He means that he has like 3 characters, and when he opens the inventory it doesn't matter which character you're playing with they all have the same inventory items.

Pumaman

Hmm, I guess the best way would be always to add and remove items from one specific character's inventory, and show that to the player as the inventory window. Interesting point.

Kennedy

Maybe you could implement some way of bringing up a specified characters inventory rather then only having access to the inventory of the current player?
So if they want to access the inventory of the character ROGER then they could type InventoryScreen (ROGER),
but if they wanted to access the inventory of the character EGO then they could type InventoryScreen (EGO).






Ishmael

That's a good idea... Allthough you can probably do it by scripting already:

int CurrentCharID, invcharx, invchary, invcharroom;

function CharacterInventory(int InvCharID) {

// Get current player character
 CurrentCharID = GetPlayerCharacter();

// Get inventory character's location
 invcharx = character[InvCharID].x;
 invchary = character[InvCharID].y;

// Move inventory character ot same location as player to prevent unwanted screen moving
 character[InvCharID].x = character[CurrentCharID].x;
 character[InvCharID].y = character[CurrentCharID].y;

// Get inventory character's current room, and make sure they are not visible in the screen
 invcharroom = character[InvCharID].room;
 character[InvCharID].room = -1;

// Open the inventory of the other character
 SetPlayerCharacter(InvCharID);
 InventoryScreen(); // or custom inv code here
 SetPlayerCharacter(CurrenrCharID);

// Put inventory character back where they belongs to
 character[InvCharID].x = invcharx;
 character[InvCharID].y = invchary;
 character[InvCharID].room = invcharroom;
}

I have not tested, but this should work...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Pumaman

Along with a couple of custom AddInventory and LoseInventory functions to add them to the correct player, that sort of thing should do the trick.

It's not easy though, I appreciate.

Ishmael

int CurrentCharID;

fucntion AddCharInv(int InvCharID, int invitem) {

// Get current player character
CurrentCharID = GetPlayerCharacter();

// Get inventory character's location
invcharx = character[InvCharID].x;
invchary = character[InvCharID].y;

// Move inventory character ot same location as player to prevent unwanted screen moving
character[InvCharID].x = character[CurrentCharID].x;
character[InvCharID].y = character[CurrentCharID].y;

// Get inventory character's current room, and make sure they are not visible in the screen
invcharroom = character[InvCharID].room;
character[InvCharID].room = -1;

// Add the inventory item
SetPlayerCharacter(InvCharID);
AddInventory(invitem);
SetPlayerCharacter(CurrentCharID);

// Put inventory character back where they belongs to
character[InvCharID].x = invcharx;
character[InvCharID].y = invchary;
character[InvCharID].room = invcharroom;
}

And:

fucntion LoseCharInv(int InvCharID, int invitem) {

// Get current player character
CurrentCharID = GetPlayerCharacter();

// Get inventory character's location
invcharx = character[InvCharID].x;
invchary = character[InvCharID].y;

// Move inventory character ot same location as player to prevent unwanted screen moving
character[InvCharID].x = character[CurrentCharID].x;
character[InvCharID].y = character[CurrentCharID].y;

// Get inventory character's current room, and make sure they are not visible in the screen
invcharroom = character[InvCharID].room;
character[InvCharID].room = -1;

// Add the inventory item
SetPlayerCharacter(InvCharID);
LoseInventory(invitem);
SetPlayerCharacter(CurrentCharID);

// Put inventory character back where they belongs to
character[InvCharID].x = invcharx;
character[InvCharID].y = invchary;
character[InvCharID].room = invcharroom;
}
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Pumaman

Actually, this code:


character[InvCharID].room = -1;
// Add the inventory item
SetPlayerCharacter(InvCharID);


will crash the game, since the SetPlayerCharacter call will attempt to change to room -1 (and fail, obviously). You need to bring the InvCharID character into the same room as the player.

Also, AddCharInv is simpler than that:

function AddCharInv(int InvCharID, int invitem) {
 character[InvCharID].inv[invitem]++;
 UpdateInventory();
}

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk