Suggestions on a loot system?

Started by Fritos, Thu 04/08/2005 10:12:35

Previous topic - Next topic

Fritos

What I'm looking for are any ideas for a way to make a loot system for creatures/characters that are killed that the main character could loot off them.

So, basically I would have 10 or so items that could possibily be gotten from the database of dead corpse. But have it randomized, so only 1-2 could be shown at a given time when the mob is killed.

Hope this makes since. Any suggestions?

BTW, this is centered around an RPG theme. For those who have played them.

GarageGothic

#1
I would probably use structs, but you might even use an inventories for the dead monster and add random items to it. Each character in the game can have it's own inventory, so you could have 5 or 10 dead monsters on the screen, each with their own posessions. This would allow you to select which items to loot from an inventory window.

Or, if you wantÃ,  a less complicated solution, just use Random() to select which items are added to the player's inventory when clicking on the monster, and write a small display-script to tell him which items have been added.

Try putting something like this to your click-on-corpse interaction:

Code: ags

int item1 = Random(10); //assuming you want to use the 10 first inventory items, else + the (starting item num - 1) (and change zero to that later on)
if (item1 == 0) {
 Display("You didn't find anything of use on the corpse");
 return; //stops running the script
 }
player.AddInventory(InventoryItem[item1]);
int item2 = Random(10);
while (item2 == item1) item2 = Random(10); //to ensure that you get two different items
if (item2 != 0) player.AddInventory(InventoryItem[item2]);
string displaypickup;
StrCopy(displaypickup, "You looted ");
string item1name;
InventoryItem[item1].GetName(item1name);
StrCat(displaypickup, item1name);
if (item2 != 0) {
Ã,  StrCat(displaypickup, " and ");
Ã,  string item2name;
Ã,  InventoryItem[item2].GetName(item2name);
Ã,  StrCat(displaypickup, item2name);
}
StrCat(displaypickup, " from the corpse.");
Display(displaypickup);


I'm not sure if the add inventory item code is right, because I haven't done any work with them since they were changed to pointers. But try messing around with it.

Edit: Your inventory item names would need to be "an apple", "a sword", "12 copper coins" or similar for the grammar to make sense. Of course you could always refine this and also have a radomized int for amount, so you could add a random number of coins, foodstuff etc.

TerranRich

Also, remember that NPCs can have inventories too. If that helps.
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk