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: 256
  • GUI Equipment System.w3x
    19.1 KB · Views: 280
  • Equipment System The_Flood(Flood) V 1.3.w3x
    76.4 KB · Views: 264
  • Tuto inventaire 12 slots MapExemple.w3x
    23.1 KB · Views: 267
  • EZ Extra Inventory V 2.0.w3x
    47.7 KB · Views: 252

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: 313

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 The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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