Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Dynamic Arrays(?) and creating a random item system


DeathKnight
 Share

Recommended Posts

To start off, I want to create add onto the item drops so that an NPC drops a random item from an array, i.e. we have array that stores 8 items, instead of creating a multiitem system that supports that many items, I just select this array on the NPC editor and there is a chance to drop any of the items from that array.

My question would be what would the best method to do this be?

The only ways I've thought of doing this have been:

1:Add in the random generator 1-max used items and loop it until it hits one of the items in the array (seems inefficient).

2:Create a Multi-Dimensional array and save it to a file that is loaded on item use. With this though, when an item is deleted, I would have to loop it to move all the value's up and redim it

3:Multi-dimensional array, same as above, but instead of looping and rediming the array, set the value in that spot to -1, then when I'm saving a new item to the array, I can search for -1 and change that to the current item number. I could also have it redim if it's the last item in the array that is -1, so I'm not ending up with uselessly long arrays if I'm adding and removing items from them.

What are everyones thoughts on doing this?
Link to comment
Share on other sites

I dont think I am understanding what you want to do.

You want the NPC to have 8 items in it's drop inventory. Every time you kill the NPC you want it to drop one of the items at random but you don't want to duplicate drops until all items have been dropped.

Is this right?
Link to comment
Share on other sites

No, it isn't that I want them to not duplicate.

The current loot system is that you have your NPC Editor which you have to select the item, and amount of items, per drop.

Instead of having like 8 items to select in the NPC editor, I want there just to have a drop down box where I select the item table that it drops from.

I want to add a variable to the item adding it to, say, a set of items. So I can have monster 1 drop items from set 1\. I just select the set when I'm saving the Item.
Link to comment
Share on other sites

Best way to do this? Create a new item type of "LootBag". you can even cheat and use all the str/int/ stats as item numbers. then let the players open the bag and go to the on use section of the items cpde server side, take the oot bag item, give random item from its list. Easy breezy.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...