Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Isegrim on Mon 22/09/2003 20:35:18

Title: Multiple Characters-one inventory
Post by: Isegrim on Mon 22/09/2003 20:35:18
Hi!

Is there an EASY way of having multiple characters sharing one inventory?
Title: Re:Multiple Characters-one inventory
Post by: Pumaman on Mon 22/09/2003 21:22:08
Each character has their own inventory. Perhaps if you explain what you're trying to do, we can think of an easier solution.
Title: Re:Multiple Characters-one inventory
Post by: Scummbuddy on Mon 22/09/2003 22:20:18
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
Title: Re:Multiple Characters-one inventory
Post by: JD on Fri 26/09/2003 12:36:45
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.
Title: Re:Multiple Characters-one inventory
Post by: Pumaman on Sat 27/09/2003 13:12:50
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.
Title: Re:Multiple Characters-one inventory
Post by: Kennedy on Sat 27/09/2003 22:00:36
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).





Title: Re:Multiple Characters-one inventory
Post by: Ishmael on Sun 28/09/2003 12:42:17
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...
Title: Re:Multiple Characters-one inventory
Post by: Pumaman on Sun 28/09/2003 17:40:04
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.
Title: Re:Multiple Characters-one inventory
Post by: Ishmael on Sun 28/09/2003 18:40:27
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;
}
Title: Re:Multiple Characters-one inventory
Post by: Pumaman on Sun 28/09/2003 20:48:06
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();
}
Title: Re:Multiple Characters-one inventory
Post by: Ishmael on Mon 29/09/2003 07:22:42
Whoops.... ;D