Help With This Trigger!

comparami

New Member
Reaction score
4
is there such an event or a way to detect when a player moves an item from any of his inventory slots, to another inventory slot?

lets say, i have Gloves of Haste in inventory slot 1, and i decide to move it to inventory slot 2, is there a possible event in which it detects this action?

i'm currently trying to make a "-ii" command found in DotA in which the multiboard shows the inventory slots of your allies, and each item carried in each specified slot, i've done all of that using periodic events.. but it ends up lagging.. dropping the fps to 59 or 58.. every second..

here's the trigger:

Trigger:
  • Update Inventory List
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TempPlayerGroup = (All players)
      • -------- EVERY PLAYER'S MULTIBOARD --------
      • Player Group - Pick every player in TempPlayerGroup and do (Actions)
        • Loop - Actions
          • -------- EACH INVENTORY SLOT CHECK --------
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • -------- ITEM TYPE IN INVENTORY SLOT (INTEGER A) CHECK --------
              • For each (Integer B) from 1 to Item_TypeCount, do (Actions)
                • Loop - Actions
                  • -------- ASSIGN ITEM CARRIED IN INVENTORY SLOT (INTEGER A) --------
                  • Set Item_Carried = (Item-type of (Item carried by Player_Hero[(Player number of (Picked player))] in slot (Integer A)))
                  • -------- IF ITEM CARRIED = ITEM TYPE (INTEGER B) --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Item_Carried Equal to Item_Type[(Integer B)]
                    • Then - Actions
                      • -------- DISPLAYS ITEM ICON PATH --------
                      • Multiboard - Set the icon for MB[(Player number of (Picked player))] item in column ((Integer A) + 6), row ((Player number of (Picked player)) + 2) to Item_TypeIconPath[(Integer B)]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item carried by Player_Hero[(Player number of (Picked player))] in slot (Integer A)) Equal to No item
                        • Then - Actions
                          • -------- IF NO ITEM IN INVENTORY SLOT (INTEGER A).... DISPLAY DEFAULT ICON --------
                          • Multiboard - Set the icon for MB[(Player number of (Picked player))] item in column ((Integer A) + 6), row ((Player number of (Picked player)) + 2) to ReplaceableTextures\CommandButtonsDisabled\DISundead-inventory-slotfiller.blp
                        • Else - Actions


please anybody? is there a way around this? in which it doesnt lag? :confused:
 

tommerbob

Minecraft. :D
Reaction score
110
First of all, you probably don't need a periodic of one second if all you're doing is updating a multiboard to display items of players. A 5 second or even a 10 second periodic is probably plenty fast.

Also, it lags because player groups cause memory leaks. At the end of your trigger you want to put in this custom script:

Code:
custom script: call DestroyForce(udg_TempPlayerGroup)
 

vypur85

Hibernate
Reaction score
803
> is there a possible event in which it detects this action?

Yeah.

Code:
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_order = GetIssuedOrderId()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                order Equal to 852002
            Then - Actions
                -[I]This will be item in slot 1[/I]-
            Else - Actions

Code:
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_order = GetIssuedOrderId()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                order Equal to 852003
            Then - Actions
                -[I]This will be item in slot 2[/I]-
            Else - Actions

Etc (between order ID of 852002 to 852007)... Use this to get some inspiration.
 

comparami

New Member
Reaction score
4
First of all, you probably don't need a periodic of one second if all you're doing is updating a multiboard to display items of players. A 5 second or even a 10 second periodic is probably plenty fast.

Also, it lags because player groups cause memory leaks. At the end of your trigger you want to put in this custom script:

Code:
custom script: call DestroyForce(udg_TempPlayerGroup)

after adding the "custom script: call DestroyForce(udg_TempPlayerGroup)" below.. the icons will only display once.. its like the player group TempPlayerGroup will never work..


> is there a possible event in which it detects this action?

Yeah.

Code:
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_order = GetIssuedOrderId()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                order Equal to 852002
            Then - Actions
                -[I]This will be item in slot 1[/I]-
            Else - Actions

Code:
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_order = GetIssuedOrderId()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                order Equal to 852003
            Then - Actions
                -[I]This will be item in slot 2[/I]-
            Else - Actions

Etc (between order ID of 852002 to 852007)... Use this to get some inspiration.

okay.. i tried using it, the icons displayed.. no lag, but.. something's wrong.. lets say i have an item Gloves of Haste in inventory slot 1, after moving it to inventory slot 2, the multiboard still displays that it's in inventory slot 1, then after moving the gloves of haste to slot 3, the multiboard shows its in slot 2.. there is a delay in the display.. weird..
 

tommerbob

Minecraft. :D
Reaction score
110
after adding the "custom script: call DestroyForce(udg_TempPlayerGroup)" below.. the icons will only display once.. its like the player group TempPlayerGroup will never work..

Probably because you put it in the wrong place in your trigger, and TempPlayerGroup is still trying to be referenced.
 

tommerbob

Minecraft. :D
Reaction score
110
Post the trigger as you have it now. You can use
Trigger:
  • tags if you want, but personally I think its easier to read with
    • <div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code">
      • <div class="bbCodeBlock-title">
        • Code:
      • </div>
      • <div class="bbCodeBlock-content" dir="ltr">
        • <pre class="bbCodeCode" dir="ltr" data-xf-init="code-block" data-lang=""><code> tags.</code></pre>
      • </div>
    • </div>
 

comparami

New Member
Reaction score
4
Code:
Update Inventory List
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set TempPlayerGroup = (All players)
        -------- EVERY PLAYER'S MULTIBOARD --------
        Player Group - Pick every player in TempPlayerGroup and do (Actions)
            Loop - Actions
                -------- EACH INVENTORY SLOT CHECK --------
                For each (Integer A) from 1 to 6, do (Actions)
                    Loop - Actions
                        -------- ITEM TYPE IN INVENTORY SLOT (INTEGER A) CHECK --------
                        For each (Integer B) from 1 to Item_TypeCount, do (Actions)
                            Loop - Actions
                                -------- ASSIGN ITEM CARRIED IN INVENTORY SLOT (INTEGER A) --------
                                Set Item_Carried = (Item-type of (Item carried by Player_Hero[(Player number of (Picked player))] in slot (Integer A)))
                                -------- IF ITEM CARRIED = ITEM TYPE (INTEGER B) --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Item_Carried Equal to Item_Type[(Integer B)]
                                    Then - Actions
                                        -------- DISPLAYS ITEM ICON PATH --------
                                        Multiboard - Set the icon for MB[(Player number of (Picked player))] item in column ((Integer A) + 6), row ((Player number of (Picked player)) + 2) to Item_TypeIconPath[(Integer B)]
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                (Item carried by Player_Hero[(Player number of (Picked player))] in slot (Integer A)) Equal to No item
                                            Then - Actions
                                                -------- IF NO ITEM IN INVENTORY SLOT (INTEGER A).... DISPLAY DEFAULT ICON --------
                                                Multiboard - Set the icon for MB[(Player number of (Picked player))] item in column ((Integer A) + 6), row ((Player number of (Picked player)) + 2) to ReplaceableTextures\CommandButtonsDisabled\DISundead-inventory-slotfiller.blp
                                            Else - Actions
Custom script:   call DestroyForce(udg_TempPlayerGroup)
 

vypur85

Hibernate
Reaction score
803
=.= Seriously, if it lags because of 'leaks' in this trigger then nobody will ever play WC3 again.

It probably lags because there are 3 loops stacking together. I'm not too sure if the changing icon function lags the performance or not, though. Haven't tried before.

Edit: Oh and yeah, it depends on the value of 'Item_TypeCount'. Not such a good idea to have it a huge number, considering the number of loop stacks.

On a related note, All players do not leak. Do not attempt to destroy it, in any way possible.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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