• 🏆 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!

Way to detect when an inventory is full?

Status
Not open for further replies.
Level 6
Joined
Dec 9, 2014
Messages
176
Is there a way to detect when an inventory is full when picking up items and instead have a different unit with an inventory pick it up? I have a rough backpack system right now and I'd like items to automatically go to a different unit when the primary inventory is full. Thanks for any help!
 
Level 6
Joined
Dec 9, 2014
Messages
176
Damn, I thought this would work but I guess "Acquire" is looking for something different than a simple command to pickup and item lol.

  • Auto Item Placement
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Sorceress Not equal to No unit
          • (Level of Open Backpack (New) for (Triggering unit)) Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot 1) Not equal to No item
              • (Item carried by (Triggering unit) in slot 2) Not equal to No item
              • (Item carried by (Triggering unit) in slot 3) Not equal to No item
              • (Item carried by (Triggering unit) in slot 4) Not equal to No item
              • (Item carried by (Triggering unit) in slot 5) Not equal to No item
              • (Item carried by (Triggering unit) in slot 6) Not equal to No item
            • Then - Actions
              • Item - Remove (Item being manipulated)
              • Hero - Create (Item-type of (Item being manipulated)) and give it to Bag 1 0150 <gen>
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Sorceress Not equal to No unit
          • (Level of Open Backpack (New) for (Triggering unit)) Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot 1) Not equal to No item
              • (Item carried by (Triggering unit) in slot 2) Not equal to No item
              • (Item carried by (Triggering unit) in slot 3) Not equal to No item
              • (Item carried by (Triggering unit) in slot 4) Not equal to No item
              • (Item carried by (Triggering unit) in slot 5) Not equal to No item
              • (Item carried by (Triggering unit) in slot 6) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 1) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 2) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 3) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 4) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 5) Not equal to No item
              • (Item carried by Bag 1 0150 <gen> in slot 6) Not equal to No item
            • Then - Actions
              • Item - Remove (Item being manipulated)
              • Hero - Create (Item-type of (Item being manipulated)) and give it to Bag 2 0151 <gen>
            • Else - Actions
        • Else - Actions
Might just end up having to deal with opening the backpack every time you wanna store extra stuff. That's ok, thanks for the help!
 
Level 6
Joined
Dec 9, 2014
Messages
176
That's messy, what's wrong with the new method I found? Also looks like your doing it a bit incorrectly as well.

Well, setting every individual item to a power up and then setting a trigger for how each item acts when picked up just seems like a grip of work and triggers all to make picking up items slightly more convenient lol

Yeah, it's messy, but it's the best I can do with my current knowledge of triggers.

As it is currently, all I have to do is summon the back pack and put stuff into it. My current system doesn't get real trigger and variable heavy which allows it to work with the stacking system and the equipment systems in place.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
acquire is when a unit picks up an item. if you want ordered to pick up an item, you have to use unit is issued an order targeting an item (exists? maybe)
 
Well, setting every individual item to a power up and then setting a trigger for how each item acts when picked up just seems like a grip of work and triggers all to make picking up items slightly more convenient lol

Yeah, it's messy, but it's the best I can do with my current knowledge of triggers.

I don't understand, how do you deal with this system when one of the slots are filled? It won't work anymore. Also what happens when that unit has all 6 items, you kind of get an error message popping up on you and it also stops your unit/hero from receiving the item therefore the trigger won't fire because there was no event since no item was "Acquired".

Edit: Howk you too fast... stop stealing! He's mine =(
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Edit: Howk you too fast... stop stealing! He's mine =(

i have nothing to do for 6 hours you're fked. also considering i have exp in this (my per-player item drop syste which i forgot to throw on the lab)
 
Level 6
Joined
Dec 9, 2014
Messages
176
I don't understand, how do you deal with this system when one of the slots are filled? It won't work anymore. Also what happens when that unit has all 6 items, you kind of get an error message popping up on you and it also stops your unit/hero from receiving the item therefore the trigger won't fire because there was no event since no item was "Acquired".

Edit: Howk you too fast... stop stealing! He's mine =(

As far as I can tell the conditions require all slots to be full, not just one. Yeah, like I said, I was hoping the Acquire event was simply looking for pickup command. It's all good, I don't mind the way the item system is, currently. Now I just need help with returning the bags to their holding area lol. I posted that question in Triggers & Scripts.
 
i have nothing to do for 6 hours you're fked. also considering i have exp in this (my per-player item drop syste which i forgot to throw on the lab)

Uh huh..... WELL GUESS WHAT! I has win. :xxd:

A few minutes > your 6 hours...

For the win/(GUI) :grin:

I spent a while figuring out creative names for the heroes, lots of work and thinking and effort went into this system. Hope you enjoy it aussj5link. Let me know if you encounter any problems and/or issues. Don't give up, work together with variables to becoming closer to being one of the best.

I gave you the map itself with the triggers so you can copy it easily however I shall also post it here.

[trigger=]
setting dem backpacks
Events
Map initialization
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) controller) Equal to User
((Picked player) slot status) Equal to Is playing
Then - Actions
Unit - Create 1 Palabag for (Picked player) at ((Picked player) start location) facing Default building facing degrees
Set backpack1[(Player number of (Picked player))] = (Last created unit)
Unit - Create 1 Palabag for (Picked player) at ((Picked player) start location) facing Default building facing degrees
Set backpack2[(Player number of (Picked player))] = (Last created unit)
Else - Actions



[/trigger]

===============================================

[trigger=]
main system for you
Events
Unit - A unit Is issued an order targeting an object
Conditions
(Target item of issued order) Not equal to No item
(Unit-type of (Triggering unit)) Not equal to Palabag
Actions
Set pweettycounter = 0
For each (Integer pwettyloop) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by (Triggering unit) in slot pwettyloop) Not equal to No item
Then - Actions
Set pweettycounter = (pweettycounter + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
pweettycounter Equal to 6
Then - Actions
Set p = (Position of (Triggering unit))
Set p2 = (Position of (Target item of issued order))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between p and p2) Less than 250.00
Then - Actions
Set pweettycounter = 0
For each (Integer pwettyloop) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by backpack1[(Player number of (Owner of (Triggering unit)))] in slot pwettyloop) Not equal to No item
Then - Actions
Set pweettycounter = (pweettycounter + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
pweettycounter Equal to 6
Then - Actions
Set pweettycounter = 0
For each (Integer pwettyloop) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by backpack2[(Player number of (Owner of (Triggering unit)))] in slot pwettyloop) Not equal to No item
Then - Actions
Set pweettycounter = (pweettycounter + 1)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
pweettycounter Not equal to 6
Then - Actions
Hero - Give (Target item of issued order) to backpack2[(Player number of (Owner of (Triggering unit)))]
Else - Actions
Floating Text - Create floating text that reads (Sorry + ((Name of (Owner of (Triggering unit))) + , your backpacks are full.)) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 50.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 0.40 seconds
Else - Actions
Hero - Give (Target item of issued order) to backpack1[(Player number of (Owner of (Triggering unit)))]
Else - Actions
Custom script: call RemoveLocation(udg_p)
Custom script: call RemoveLocation(udg_p2)
Else - Actions

[/trigger]
 

Attachments

  • backpack system dat-c3.w3x
    23.1 KB · Views: 51
Level 19
Joined
Aug 8, 2007
Messages
2,765
i never said i would code something for him, as thats counter to what i believe in. he wont learn that way.
 
i never said i would code something for him, as thats counter to what i believe in. he wont learn that way.

Even if it counters whatever you believe in teaching/learning... It doesn't change the fact that this is a method of so. Showing,saying,listening,doing it yourself. I think that's it. I do showing best and I want to help people get to where they want to be faster and best possible way but still retain what they learnt.

Yeah true, though you did however sound like you might have been trying something.... Still thanks for participating in this thread howk. =)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Dat-C3, the first loop could be like this to avoid unnecessary loops.
  • For each (Integer pwettyloop) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item carried by (Triggering unit) in slot pwettyloop) Equal to No item
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
          • Set pweettycounter = (pweettycounter + 1)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I would imagine the process is pretty simple, something like this...

JASS:
function UnitInventoryIsFull takes unit u returns boolean
    return UnitItemInSlot(u, 0) != null and UnitItemInSlot(u, 1) != null and UnitItemInSlot(u, 2) != null and UnitItemInSlot(u, 3) != null and UnitItemInSlot(u, 4) != null and UnitItemInSlot(u, 5) != null
endfunction
This is probably the best way to do it for 6 slot units as any form of loop adds additional overhead due to a lack of optimizing compiler.

For a dynamic number of slots you could do this...
JASS:
function UnitInventoryIsFull takes unit u returns boolean
    local integer i = UnitInventorySize(u)
    loop
        exitwhen i <= 0
        set i = i - 1
        if UnitItemInSlot(u, i) == null then
            return false
        endif
    endloop
    return true
endfunction
In this case the loop overhead might be justified by avoiding having to test slots the unit does not have.
 
Dat-C3, the first loop could be like this to avoid unnecessary loops.
  • For each (Integer pwettyloop) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item carried by (Triggering unit) in slot pwettyloop) Equal to No item
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
          • Set pweettycounter = (pweettycounter + 1)

That wouldn't work though because what if item slot 1 had an item while others didn't? It'd just stop the entire trigger wouldn't it?

Good idea DSG, will see what I can do about applying that. I made this system as easy as possible for the one who wanted help with this. I will be improving it hoping he learns more about what he wants.
 
Status
Not open for further replies.
Top