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?
 
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: 280
  • GUI Equipment System.w3x
    19.1 KB · Views: 1,540
  • Equipment System The_Flood(Flood) V 1.3.w3x
    76.4 KB · Views: 291
  • Tuto inventaire 12 slots MapExemple.w3x
    23.1 KB · Views: 1,603
  • EZ Extra Inventory V 2.0.w3x
    47.7 KB · Views: 1,571
Thank you for the reply, but none of those systems are what I'm looking for, plus I won't use GUI.
 
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.
 
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.
 
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)
 
Check this out, don't mind the title.
 

Attachments

  • DamageDemo.w3x
    831.3 KB · Views: 1,562
I dunno if you linked the wrong Map, cause there is nothing in there about items or inventories. ?
 
i have two maps with almost the same name lol... edited the post. Check it now
 
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 =) ...
 
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.
 
Thanks everyone for your help. I decided to write up some code myself. It only took about 10 minutes. :)
 
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
...
 
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.
 
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
 
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. :)
 
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.
  • jonas jonas:
    I don't think the Republicans will get rid of income tax, at most lower it a little, mostly for people with 6 figures+. But that's just my opinion
  • The Helper The Helper:
    one can dream
  • Ghan Ghan:
    FairTax would be nice.
  • Ghan Ghan:
    But the electorate would have to demand it and vote people in to do it.
  • Ghan Ghan:
    Government spending, foreign policy, and the southern border are all bigger issues than the income tax right now I'd say.
  • The Helper The Helper:
    For you those are the bigger issues. Cannabis legalization and get rid of Income tax are mine.
  • Ghan Ghan:
    We have so much cannabis up here in Oklahoma. Can't go a block without running into 3 dispensaries. xD
  • The Helper The Helper:
    if the demand is there
  • jonas jonas:
    I think the biggest issue in USA is how divided the country has become
  • Ghan Ghan:
    There's a big split happening in fundamental values that is very worrisome.
  • jonas jonas:
    I think there's always been a split in values. But now there's a split in what reality is. No matter whom you ask, they think a third of the country is insane and wants to destroy the country
  • The Helper The Helper:
    pretty big split
  • The Helper The Helper:
    Happy Saturday!
    +1
  • V-SNES V-SNES:
    Happy Saturday!
    +1
  • The Helper The Helper:
    Dont forget to check out the list of all the recipes on the site at the Recipe Index - I am about to take Ghan up on the offer of making that a site :) https://www.thehelper.net/threads/main-recipes-menu-recipes-index-version-2-0.189517/
  • The Helper The Helper:
    We should add that as part of site navigation
  • Varine Varine:
    I just don't think Trump actually understands how the government works. I'm not going to pretend like I can understand the entirety of government but in my industry he kind of caused massive fucking issues. Tarriffs and the international counters had a pretty significant impact on what I do, it was actually kind of interesting to see though. I live in Idaho so I'm not really concerned with it, it'll be R pretty much the entire way down. We do have ranked choice on our ballot this year though and I DO really care about that. But if we are going to have a federal government we kind of need income tax. They could abolish it and tax states I guess, but then states are just going to raise income taxes. It's not really viable without a very significant and holistic overhaul of how the federal government works, and that isn't something I would expect Trump to do.
  • Varine Varine:
    I don't expect Harris to do it either. I want to see wealth and church taxes, but those also aren't things I'm going to hold my breath for.
  • jonas jonas:
    I mean he definitely doesn't, which is why he had to retract most of his executive orders, didn't manage to get rid of obamacare etc.
  • jonas jonas:
    B
  • jonas jonas:
    Replacing income tax with a wealth tax would be amazing imho, but I can't even imagine that this would happend
  • Ghan Ghan:
    Wealth tax would be a disaster. Imagine having to liquidate retirement accounts because you have a tax bill just for unrealized gains. Or your house goes up in price and you have to sell it to pay the tax bill.
  • jonas jonas:
    I'm not talking about an income tax on wealth gain.
  • jonas jonas:
    we already have a wealth tax on our house, it's called a property tax. I'm talking about extending that to other income-generating assets like private equity, bonds and stocks.
  • jonas jonas:
    I agree that the effect of that would be to depress asset prices, but I think that's a good thing. Makes it easier for hard working young people to grow their retirement income
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top