Items and Inventories.

tommerbob

Minecraft. :D
Reaction score
110
1.

My goal: Heroes can carry only 1 of each item class/type. They can carry only 1 weapon, 1 armor, 1 helm, 1 ring....etc.

I've seen rpg maps where they've done this. I'm trying to achieve something like Ace's Item Restrictions, but I want a vJass system that is efficient and can handle lots of items without lots of code.

What's the best way to implement it? I looked through kingking's Advanced Item Indexing and Unit Inventory Data, but they look like they handle only individual items, not item classes, which is what I want.

My initial thought about the best way to do it: Make all weapons "artifacts", all armors "permanent", all rings "miscellaneous", etc. Then when the item is acquired, I check if the hero is already carrying an item of that same class. Is this the best way?

2.

I've seen maps that use backpack systems, such as Gaia's Retaliation. They use an extra hero as the "backpack". Are there any systems around for this type of thing? I assume its just creating a hero with no model, and using a high-frequency timer, periodically move the backback unit to the same position as the hero?
 

StEaLtHmAn

New Member
Reaction score
2
I have fiddled with inventories a lot in the past, check these out you will find what you need.
 

Attachments

  • BagSys.w3x
    13.7 KB · Views: 246
  • GUI Equipment System.w3x
    19.1 KB · Views: 268
  • Equipment System The_Flood(Flood) V 1.3.w3x
    76.4 KB · Views: 254
  • Tuto inventaire 12 slots MapExemple.w3x
    23.1 KB · Views: 256
  • EZ Extra Inventory V 2.0.w3x
    47.7 KB · Views: 241

tommerbob

Minecraft. :D
Reaction score
110
Thank you for the reply, but none of those systems are what I'm looking for, plus I won't use GUI.
 

StEaLtHmAn

New Member
Reaction score
2
They can be converted to jass. Well the best way would be to separate all the item types into the item classifications then when an item is picked up run through the items the unit owns and test each one.
 

tommerbob

Minecraft. :D
Reaction score
110
First, converted jass is not vJass. Secondly, none of your systems do what I need. The only exception is the GUI Equipment System, but its not in vJass.

I'm wondering if there is already a vJass system out there for what I need. If not, then obviously I have to do it myself.
 

luorax

Invasion in Duskwood
Reaction score
67
Well, I really loved this inventory system. Although it has a bug (forgot what it was exactly), but it can be easily fixed. There's a higher version on WC3C, but I was lazy to find it (got to go soon). It's also based on a custom item struct, which is the best way IMO (I'm not using any fancy inventory system in my map and I'm still using a custom struct)
 

Dirac

22710180
Reaction score
147
Check this out, don't mind the title.
 

Attachments

  • DamageDemo.w3x
    831.3 KB · Views: 306

tommerbob

Minecraft. :D
Reaction score
110
I dunno if you linked the wrong Map, cause there is nothing in there about items or inventories. ?
 

Dirac

22710180
Reaction score
147
i have two maps with almost the same name lol... edited the post. Check it now
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Hm... A thread about items and inventories and not a signle mention about:

Tc's BX-TRS II

In my opinion it's the system which almost all other full screen inventories have tried to fork/emulate, although I think the idea behind it was actually from another system called fsgui.

It really "raises the bar" really high and makes all other inventory system look unimpressive. Although the problem for me is that it's documentation is not that great, has a huge learning curve and thus I still don't have a clue how to use it =) ...
 

luorax

Invasion in Duskwood
Reaction score
67
I have its first version as well (I have a damn huge collection of WC3 systems on my HDD), but yep, I must agree it's quite hard to get used to it. That's mostly the reason I didn't mention it, plus, OP was not asking for such a complicated and complex system, he just needed a simple and cool way to separate item types.
 

tommerbob

Minecraft. :D
Reaction score
110
Thanks everyone for your help. I decided to write up some code myself. It only took about 10 minutes. :)
 

Dirac

22710180
Reaction score
147
I suggest you the following (in case you haven't tested the map i provided above)
Instead of looping through the unit's inventory constantly, create a boolean array for each item type and use the unit's custom value as its index.
JASS:
static boolean array hasWeapon
...
if not hasWeapon[GetUnitUserData(unit)] then
...
 

tommerbob

Minecraft. :D
Reaction score
110
What's the difference between

JASS:
private boolean array hasWeapon


and

JASS:
static boolean array hasWeapon


??

EDIT: If I used a boolean, I would need to create an additional function to set the boolean to false whenever a unit drops an item. In that case, I would either need to (1) loop through the inventory anyway, because whenever a unit drops an item due to already having one, it would incorrectly set the boolean to false. Or (2) I would need to destroy an item and create a new one whenever a unit picked it up and already had it. So it doesn't seem like it would be that much better than simply looping through the inventory in the first place like I'm already doing.
 

Dirac

22710180
Reaction score
147
When it drops an item check for the item's type, i saw that you assigned a custom type to each one so it would work applying the logic...

if (type of item dropped) == Artifact then
set hasWeapon[unit index] = false
endif

no need for loops, and again please check my map.

"private" and "static" are completely different things, private i assume you already know of, it's for encapsulation, means that you cant access that variable outside the current scope.
static is used for ONLY struct members (and static ifs, but not relevant) remember that structs are meant to handle arrays attached to instances. If a variable is static it means that it works like a common global

struct Test
static integer what
endstruct

is the same as

globals
integer test_wat
endglobals
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
If you didn't fix the slot with the type, like Slot 0-> Weapon, Slot 1-> Armor, then it will be all right, needless to bother with moving item in slots. :)
 

TheLegend

New Member
Reaction score
10
pk here is an old system that restricts units from using items that aren't their class or if they already have the item type.
To link unit classes and item classes i used the custom values and to restrict item types i used item levelsView attachment Item Controler.w3x
gimme some credit if u use this ;)
EDIT:
The classes are unlimited so are the types, so you can have as many as u want
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top