Multiple inventories for one character/player? [SOLVED]

Started by Stranga, Wed 09/03/2022 23:42:14

Previous topic - Next topic

Stranga

Hello everyone,

This is more of a trial and error sorta thing as I haven't yet added anything like this to a game, but what I'm intrigued about is if it is possible to make multiple separate inventories for the one character/player?
My idea was to have the player's normal inventory, then another for say like a particular group of items, sorta similar to the old pokemon games how they separated their inventories into categories if that makes sense.

Like normal items then key items...and so on, but I'm not sure IF you can do this in AGS using the inbuilt systems(which would be nice!)

Any help would be greatly appreciated :)


Khris

It's possible, kind of.
Each character has their own inventory, so just create a bunch of dummy characters to get a bunch of inventories.

A GUI InvWindow has a .CharacterToUse property, so you can do something like
Code: ags
  invMain.CharacterToUse = cKeyItems; // key item dummy character

to switch the displayed inventory when a button is clicked.

The only thing you need to watch out for is that interacting with other character's inventory items is not that simple. You can't make them the ActiveInventory without giving at least one item to the player for instance. But as long as you keep track of what's happening, it should work out fine.

Stranga

Thanks for the reply, Khris. I had the same thought, just didn't know about being able to view either character's inventory.

QuoteThe only thing you need to watch out for is that interacting with other characters' inventory items is not that simple. You can't make them the ActiveInventory without giving at least one item to the player for instance.
Just a thought, what if I were to change the playable character when opening different inventories? Would that work as well as I'm thinking or could cause issues down the track?


Khris

Yeah, that will work fine. You just need to make sure to also change all the dummy characters' rooms during every room change, or changing the player character will move the game to some other room.
Not a big issue though, you can do something like
Code: ags
function on_event(EventType event, int data) {
  if (event == eEventEntersRoomBeforeFadein) {
    cDummy.ChangeRoom(player.Room);
    // ... etc
  }
}

SMF spam blocked by CleanTalk