• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Inventory (Hero) Level Bug

Status
Not open for further replies.
Level 9
Joined
May 21, 2014
Messages
580
I have an Inventory (Hero) skill that can be leveled up via upgrades. I want this to work properly.

There is a weird bug that is going on in this ability.

The upgrade goes like this:
Ability - Level Up Base: 0
Ability - Level Up Increment: 1

Currently, the ability is not enabled until first researched. When the 1st research is done, 1 inventory slot will be available to the unit. (Level 1)

When the 2nd research is done, the unit will have 2 inventory slots, which is working fine. But then, there is this weird bug: When the unit has an item within those two slots, sometimes IT WILL PICK UP THE ITEM BEING PICKED UP AND AT THE SAME TIME DROP THE OTHER ITEM THAT HE CURRENTLY HAD.
This happens when the ITEM HE CURRENTLY HAS is in slot 2, and when he picks up an item.

When the 3rd research is done, the unit will have 3 inventory slots, which is working fine, then there is this weird bug again: When the unit has an item within those three slots, sometimes IT WILL PICK UP THE ITEM BEING PICKED UP AND AT THE SAME TIME DROP THE OTHER RANDOM ITEM THAT HE CURRENTLY HAD, OR BOTH.
This sometimes happens when the ITEM HE CURRENTLY HAS is in slot 3, or the items are in slot 2 and 3, and when he picks up an item.

The bug is quite reliant on CURRENT LEVEL of the ability.

Quick Edit: Work-Arounds are welcome.
 
That is quite the interesting bug, what I suggest is to make 3 versions of the inventory ability and remove/add them instead because this is the only work-around for this method. I didn't know you can't level inventory properly, very interesting indeed.

Not that much of a problem, easy enough to add/remove and pick up items again.

Edit: There might be another solution out there from another person, but this is currently what I have to offer. =)
 
Level 9
Joined
May 21, 2014
Messages
580
This is going to be hard since the ability can be acquired using an upgrade; all other units trained with the ability must have the proper ability. Also, I have a unit upgrade that causes the unit to be replaced with another improved unit, in which I have to check this.

It can be done, but it needs a lot of checking with the current gameplay I have in the map.
 
Level 9
Joined
May 21, 2014
Messages
580
Well you can have multiple inventories on every unit and have them unlocked by upgrades... Your not limited to one inventory per unit, just have to make sure each one is restricted by upgrade and a dummy unit so the previous ones get locked.

I have tried this solution. Apparently and it only sometimes happen; that the unit has 2 inventory; one being accessible through the UI Warcraft III has, the other inaccessible; but the unit has the item's effects if is is passive.
I have tried using Techtree Requirements and Requirement Level. It seems that it also does not work properly at some cases. The weird thing is that it happens sometimes.
 
It actually should always happen if done in-correctly. The item is still there, just active items can't be clicked. Either way you'll have to track your units which is really easy to do. Just add/remove new/old ability and order a pickup of all dropped items for the researching player for the units with the research.

No matter what, it seems increasing/adding/removing/enabling/disabling inventory abilities always force items to drop. However you can try a dummy inventory method.

Edit: You'll only really need to show active items and when they get dropped just remove them and check if that unit still has a copy and give it into the units new inventory while blocking up the hidden inventory with extra dummy items unless it already has 6/max of how many inventories.
 
Level 9
Joined
May 21, 2014
Messages
580
It's working fine with the method you just posted. I had to redo some triggers to detect the errors I did. Another stupid event came up. My units that have inventory are just normal units. I set the ability to have "Drop Items on Death" to False, so that these units will lose the items when they die, and the items are gone forever that the player needs to rebuy them. The funny thing is that THOSE ITEMS WHO DIED WITH THE UNIT reappear on the map after some time. This is getting weirder and weirder!


EDIT:
I tested this again several times, and found out that AFTER THE UNIT DECAYS, ALL THOSE ITEMS HE HAD WHEN HE DIED ARE FORCED TO BE DROPPED. THEY ARE NOT COMPLETELY REMOVED.

Triggers are the answer to this.

@Dat-C3
I am quite in a problem with the method you posted. Since there are many units that are being handled with the trigger, it's quite lagging. It reminded me of something that I can try though. Be right back!


EDIT (2nd):
I got it working somehow.
I used the same tactic I have in my first post, but the data Upgrade is changed, and the Inventory (Hero) ability is also changed;

Upgrade:
Data - Ability Level up - Increment: -1
Data - Ability Level Up - Base: 2

Ability:
Data - Level 1 - Inventory Slots: 3
Data - Level 2 - Inventory Slots: 2
Data - Level 3 - Inventory Slots: 1

The bug doesn't seem to appear. I have retested multiple times and it is working properly. I kind of abused about the idea that the bug has something to do with the Levels. 1st Research enables 1 slot; 2nd enables 2 slots; 3rd enables 3 slots as expected without bugs. No small lag issues as well.

+Rep though, because if there were bugs that I have detected (AGAIN), I will reuse the triggers I made with the your method.
If that happens, I will post the triggers here and probably you can make it "less laggier."
I need to do an extensive testing about this...
 
Last edited:
Level 9
Joined
May 21, 2014
Messages
580
do it via triggers. whenever a unit receives an item, loop through his inventory and check how much items the unit carries. if the cap is already reached, drop the item

The cap is already determined with the Data fields the Inventory (Hero) ability. The problem is:
The Inventory Cap is 3.
Unit picks up an Item with 1 Item in Inventory.
[Sometimes] The unit picks up an item and quickly drops the item that he had, and successfully picks up the item being picked up.

Yes, as Dat-C3 had suggested, I must do it with triggers mostly and I will keep his advice, but for now there is a "rather successful alternative.", which is already posted by me.

I got it working somehow.
I used the same tactic I have in my first post, but the data Upgrade is changed, and the Inventory (Hero) ability is also changed;

Upgrade:
Data - Ability Level up - Increment: -1
Data - Ability Level Up - Base: 2

Ability:
Data - Level 1 - Inventory Slots: 3
Data - Level 2 - Inventory Slots: 2
Data - Level 3 - Inventory Slots: 1

The bug doesn't seem to appear. I have retested multiple times and it is working properly. I kind of abused about the idea that the bug has something to do with the Levels. 1st Research enables 1 slot; 2nd enables 2 slots; 3rd enables 3 slots as expected without bugs. No small lag issues as well.
 
Whenever a unit dies with items on it, they will appear 10 seconds later no matter what you tell it to do. Yeah backwards levels might work, but it might fail later on. However it should work since you identify it for its max number of slots at level 1. Good luck, let me know if you need/want help.

Edit: The lag is easily fixed, don't do it all at once. It will lag at 50+ units.
 
Status
Not open for further replies.
Top