Multiple inventory boxes for one character

Started by jamesreg, Wed 28/10/2009 13:53:27

Previous topic - Next topic

jamesreg

Quick question.

I had my game set up where you had three avatars for three different characters then you would click on an avatar and it would make that character the playable character and display that characters inventory items.

while beta testing this with a few friends I kept getting comments that the making each character playable wasn't really needed and was acctully causing some confusion on somethings.

this works out for me cause its easier to script if i don't have multiple playable characters and it doesn't total fit the plot anyway.

so anyway I changed the interface where I still have the three character portraits but instead of making the other characters playable when clicked on it will simply display their inventory items and allow you to select items as if the main character is giving an order for the other characters to do something. This works well for my game and better then the way I had it.

However one problem now that I did that and turned off the make the other characters playable.

I get an error message that says that character does not have that inventory item.

Which is because the main character does not have that item.

So my question is this is it possible for one character to have multiple inventorys?
or even an easier solution is it possible for me to do something like this

switch inventorys back and forth for example

if i have active players inventoy A  and i click the avatar for character B can I script it and tell it to switch active player A'S inventory with character B's inventory and so on

basicaly I will need to have be able to switch back and forth between three characters inventory boxes but have it accessable by the main playable character.

im thinking there should be an easy way to switch inventory guis between characters back and forth

AngelicCharon

If I understand correctly, there's only one playable character, but two other characters who for some reason also have their own inventories, and you want it such that the playable character can access/use the inventories of the other two?

One method would be to create 3 identical playable characters then, each with their own inventory, so that way when you switch, your playable character remains the same but now has the other inventory.

Another slightly more tedious solution, would be maybe coding something whereby you store what inventory items any particular character has, and then any time you want to switch, it removes all of the one set of inventory and gives the other set of inventory.

I'm sure there are other solutions, hopefully those make sense.

But there's no specific way that I'm aware of to 'simply' say 'swap Inv.A to Inv. B.'.

All depends how much work you want to do.

Honestly, having 3 playable characters sounds interesting as well, if you made them unique enough.  Otherwise, just having them as briefcases for items, not sure about how necessary that'd be...but, I don't know what you're doing.

Good luck! :)

monkey0506

As far as the idea of swapping complete inventories between two characters it could be accomplished like this:

Code: ags
// GlobalScript.ash
import function SwapInventory(this Character*, Character *otherCharacter);

// GlobalScript.asc
function SwapInventory(this Character*, Character *otherCharacter) {
  if (otherCharacter == null) return;
  int i = 0;
  while (i < Game.InventoryItemCount) {
    int j = this.InventoryQuantity[i];
    this.InventoryQuantity[i] = otherCharacter.InventoryQuantity[i];
    otherCharacter.InventoryQuantity[i] = j;
    i++;
  }
  UpdateInventory();
}

// wherever (inside a function)
player.SwapInventory(cTim); // swap the player's inventory with Tim's inventory
// ...
// do some stuff with Tim's inventory
// ...
player.SwapInventory(cTim); // switch back to the player's inventory

skuttleman

Are you really trying to swap inventory? It sounds like all you need to do is look up the CharacterToUse property for inventory windows in the manual.

monkey0506

The problem with that is that you then have to completely rethink the entire inventory system as well. If the player character doesn't have inventory item 'X' then you can't set player.ActiveInventory to that item. Generally when handling inventory item clicks one would check this property...

Now it could be as simple as just storing it in a global pointer or some such instead, but depending on how all/where all it's being used it could be rather tedious to have to remember not to use player.ActiveInventory.

skuttleman

You can always use InvWindow.CharacterToUse.ActiveInventory. It seems to me a lot messier of a work around to swap inventories, especially if you're going to have .AddInventory[] or .LoseInventory[] commands because an inventory item that would should go to the player might have to go to characterx instead, if their inventories are swapped.

Khris

Like monkey said, ActiveInventory must be in the player's inventory.
A workaround would be to use just the graphic and a custom cursor.

jamesreg

Thanks for all the great advice guys I am reviewing what you all said and I see several things I can do for this problem and some other ones down the road.

Let me pose another question here that might not be the same one but would solve my problems never the less.

Lets say I kept things where I had three characters each with their own inventorys and such.

But I still have a one character I want to be the main character.

I want to be able to click the other players or click thier avatar portrait on screen and select them i want to be able to have them  look at items , talk to people, and interact with items and use respective inventory items kind of like the main character is giving orders for them to do things.

Now I basicaly want them to do everything except be able to walk around I want to restrict walking around to the main character.

Now I already have half the game scripted where i have them using thier inventory items, and using the talk and look and interact actions and do not want to have to go back and remove all this

kinda beta tested with a few people and figured out that having them walk around was uneccesarry and even kinda confusing to some folks so it needs to be more like the main character can click on them and tell them to do stuff

but the way it is set up is if i click on them they become the active player and such to be able to access their inventory items and have access to the other interactions as I want to be able to have different viewpoints if a different character looks at a hotspot and such also

Hope i made clear what I want to try to do here.

Is there any easy way to make a character playable but turn off his walk ability function what would you guys do if you was already deep into this and did not want to undo alot of coding or redo alot?

tzachs

Hmm, one way of doing this would be to removing the walking area of the switched-to player, and restoring it when switching back.

Haven't tested it, but something like this:

Code: ags

function SwitchToNonWalkingPlayer(Character* toChar)
{
    RemoveWalkableArea(GetWalkableAreaAt(toChar.x, toChar.y));
}

function SwitchFromNonWalkingPlayer(Character* fromChar)
{
   RestoreWalkableArea(GetWalkableAreaAt(fromChar.x, fromChar.y));  
}

SMF spam blocked by CleanTalk