I'd like to create a scene, where the player's character loses all items it carries. After leaving the scene, the items, it was carrying before, should go back into the inventory.
I can easily make a loop, that loses everything, like
i=0;
while (i<NoOfItems) {
LoseInventory(i);
}
Also, I can use character[CHARID].inv
- to find out, whether the character is carrying an item or not, but do I really have to "reserve" as many globalInts, as the maximum possible no. of items is or is there a possibility to create a data field in AGS scripting?
You could create a 'dummy' character (or use an NPC if you'd rather), copy EGO's inventory to them before clearing the inventory, then restore from it when you want. Something like your loop could be used:
// to backup inv
i=0;
while (i<NoOfItems) {
if (character[EGO].inv[i] == 1) { // if EGO has that item
AddInventoryToCharacter (DUMMY, i); // Copy it over
LoseInventory(i); // Then lose it
}
i ++; // Move on to next item
}
//to restore
i=0;
while (i<NoOfItems) {
if (character[DUMMY].inv[i] == 1) { // if DUMMY has that item
LoseInventoryFromCharacter (DUMMY, i); // Copy it back
AddInventory(i); // Then lose it
}
i ++; // Move on to next item
}
Quote from: Ashen on Sat 02/04/2005 20:23:12
You could create a 'dummy' character (or use an NPC if you'd rather), copy EGO's inventory to them before clearing the inventory, then restore from it when you want.
Haha! Sure!! Thank you... as always, there is an easy solution - I like this enginge!