HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item System Help

03-17-2007, 08:19 PM#1
FatalError
Alright, so I'm currently working on an Item System. What it is is basically a recipe/combination system. The way it works is instead of buying items, you are actually (literally) buying a dummy unit. Each dummy unit has an item that it matches with. When a dummy unit is bought, the matching item is looked up, and the unit is replaced with the item. If the item belongs to any recipes/combinations, the recipe item is created.

The problem I have is the bold line above. I need a way to store the matches and item combinations. I am currently using GameCache (ew) because I can't think of a better way to store both the unit/item matches AND recipes.

For example, I need some sort of table that matches dummy units with items.
Ex: 'e000' => 'rat6' (Claws of Attack +6)
Also, I need a table has combinations/recipes (whatever you want to call them).
Ex: 'rat6' + 'rat6' = 'ratc' (2 of Claws of Attack +6 = Claws of Attack +12)
The problem I have with recipes and GameCache is that recipes can have 3-4 items, and it makes GC really hard to use (and even slower <_<).

Anyone have any ideas? Sorry if this doesn't make sense, I overslept today. XD I can elaborate further if needed.

EDIT: Eh, I didn't make this clear...when you buy the dummy unit, the unit is removed from the game, and then the item checks are run. If the item is part of any recipes, and you have all the items needed for that recipe, then the recipe is created. If not, then the item is simply given to the hero.


PS: DO NOT tell me to use Structs (or in fact any pre-made system). I want this to be my own creation, independant of other systems.
03-17-2007, 11:40 PM#2
botanic
Just use arrays for example

Unit_Item = Unit bought
Item_Replace = Replaced item
temppoint = point og unit

Event
Unit is created
Cond
Effect
for intiger a 1 to Total_Items so
If last created unit = Unit_Item[intiger a]
then
set temppoint = position of last created unit
create Item_Replace[Intiger a] at temppoint
remove last created unit
call udg_RemoveLocation (udg_temppoint )

for the recipe just make another trigger

Event
unit aquires an item
cond
effect
if item carried by triggering unit = Item_Replace[1] and item carried by unit and Item_Replace[2] and item carried by triggering unit = Item_Replace[3] then
remove Item_Replace[1]
remove Item_Replace[2]
remove Item_Replace[3]
set temppoint = position of triggering unit
Create Item_Replace[4] at temppoint


PS: why dont you just make it buy the item?

Sorry bout not using the code boxed I dont really get how to use them ^.^
03-18-2007, 12:46 AM#3
FatalError
Well I was going to do it that way but I'm afraid that with a lot of items it would be even slower than GameCache, which isn't the aim here.

The point of using dummy units is get rid of the annoying "Inventory Is Full" error. I'm assuming you've played DotA, right? Isn't it annoying when your inventory is full, but all you wanna buy is a recipe? You have to drop one item (or possibly more), and then buy it.

If you are buying a dummy unit, then you're not actually buying an item, so it won't give that error. I don't know whether to make a custom error or to just drop the item at the hero's feet. Either way though, it's a lot better than having to drop items just to buy a recipe that WILL eventually fit in your inventory.
03-18-2007, 02:03 AM#4
botanic
The array wont be slower just load it at game initialization. I have done it before worked great. Ne ways don't make it drop at the units feet (ever had an sa steal an item? so gay...) just remove the items from the game and create the item at the location of there hero then have the hero pick it up automatically. Add the line

Unit - Order (Triggering unit) to Right-Click (Last created item)

to the trigger I have above.

If you are truly worried about the speed I did this with 133 variables 3 times over and it wasn't even a small bit of lag. So unless you have some 100000 items you should be ok ^.^ The main thing is to make sure that the variables are loaded on the game initialization and not later or it can cause some lag.

PS: The DOTA item system lags a bit ^.^
03-18-2007, 07:32 AM#5
FatalError
Quote:
Originally Posted by botanic
If you are truly worried about the speed I did this with 133 variables 3 times over and it wasn't even a small bit of lag. So unless you have some 100000 items you should be ok ^.^ The main thing is to make sure that the variables are loaded on the game initialization and not later or it can cause some lag.

PS: The DOTA item system lags a bit ^.^
Really? Hmm, I guess I'll just do that. Yeah now that I think about it, I guess it should be faster, because I would have to do the same amount of GameCache calls, which would be 32128324 times slower.

And yeah, I'm not using DotA's code as an example...IceFrog may be a decent coder, but speed isn't his strongest side, which is what I'm aiming for.

Thanks for the help! This is going to help me a ton. Major Rep+ =]
03-18-2007, 10:02 AM#6
WNxCryptic
Lets not talk about DOTA and IceFrog...my head might explode.