using inventory item thats is assigned to a non player character

Started by jamesreg, Wed 23/09/2009 02:28:51

Previous topic - Next topic

jamesreg

I have an issue I have multiple characters and who all have their own inventory items.
I only have one player set as the active character and do not want the other players
as the active character. However I have it set up that if you click on another character
you will get their inventory window and from there I wish to allow my main character to select
an item and use it on hotspot or object and then have the other character to do something
As if im ordering the other character to do something.

Example back to trek game spock has a tricorder but kirk does not I want kirk to click spocks tricorder and select an object on screen
for spock to go and scan

Now when i try to script this I get an error message saying cant select that as active inventory because the main character does not have this item.

how do I get around this and script this right

monkey0506

Is the player character's inventory going to be shown at the same time as the other character's inventory? Because the only way you're going to be able to set the player's ActiveInventory is if the player actually has that inventory item in their own inventory set.

Or you could just rewrite the entire inventory system yourself. ::)

jamesreg

I think I will just allow for the players to switch and allow for play by multiple characters my main concern is I did not want one character going off screen and have to script all the options out but what I think I will do is handle it like this if they go off screen the rest of the landing party will follow as a group that way I still can script out the same events to happen.

and it will make it more realistic if you can really walk around as say spock and scan stuff and do stuff.

monkey0506

Well another option might be to temporarily swap their inventories. Something such as:

Code: ags
void SwapInventory(this Character*, Character *otherCharacter) {
  if (otherCharacter == null) return;
  int i = 0;
  while (i < Game.InventoryItemCount) {
    int ii = this.InventoryQuantity[i];
    this.InventoryQuantity[i] = otherCharacter.InventoryQuantity[i];
    otherCharacter.InventoryQuantity[i] = ii;
    i++;
  }
  UpdateInventory();
}

// ...

player.SwapInventory(cSpock);


Something like that would switch their inventories around so that the player could use Spock's inventory, then when you're done you could just call the same line again to swap back. Just remember that if you swap them like this that if you want to change Spock's inventory you'll need to work with the player since they've swapped their entire inventorys and will be changing back. ;)

SMF spam blocked by CleanTalk