• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Personal Loot System help

Level 3
Joined
Nov 26, 2021
Messages
25
Is there a way in Jass or GUI to make a trigger that only triggers once on start of the map, that checks every item and location on the map, allowing each play to loot each item once only?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
that checks every item and location on the map
What do you mean by "checks every location"? As I understand you want it so that if 3 Crown of Kings are present on the map, Player 1 can only pick up one of those at a time even when using different units. If the Player 1 unit that is holding the CoK drops it then any of Player 1's units could pick up any of the 3 Crowns?
 
Level 3
Joined
Nov 26, 2021
Messages
25
By that I have pre set locations on items always in same spot on start of map, want then to be lootable in exactly same location with nice per player, so not 3 items one each, the exact same item that other looted

So items are already placed on map
Want it to allow every player to loot same item once each

So player 1 loots item at X Y player 2 can loot that same item, but player one no longer can as already looted before

Items are activate on use items so they are like Experience books

So never go into players inventory
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Do players have more than 1 controllable unit that could interact with the items? Could there ever be more than one set of such items available for pickup at once? Since there aren't itemgroups (outside of using a
( table hiveworkshop - Поиск в Google ) object) you could try using some (fake) multidimensional arrays to store groups of items and check orders against them. A little easier if there is only ever one set of powerups available at once since you don't have to keep track of old rewards being clicked.

  • -------- in an init trigger --------
  • Set RewardCount = 0
  • Set RewardCount = (RewardCount + 1)
  • Set RewardPlayers[RewardCount] = Player 2 (Blue)
  • Set RewardCount = (RewardCount + 1)
  • Set RewardPlayers[RewardCount] = Player 5 (Yellow)
  • Set RewardCount = (RewardCount + 1)
  • Set RewardPlayers[RewardCount] = Player 1 (Red)
  • -------- to spawn items --------
  • For each (Integer A) from 1 to RewardCount do (Actions)
    • Loop - Actions
      • Item - Remove Rewards[(Integer A)]
      • Item - Create a ... at ...
      • Set Rewards[(Integer A)] = (Last created item)
  • Events
    • Unit - A unit is issued an order targeting an item
  • Conditions
  • Actions
    • Set U = (Triggering Unit)
    • Set P = (Triggering Player)
    • Set Itm = (Target item of issued order) //I think there's a response something like this
    • For each (Integer A) from 1 to RewardCount do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • Itm equal to Rewards[(Integer A)]
            • P equal to RewardPlayers[(Integer A)]
          • Then - Actions
            • Trigger - Skip remaining actions
          • Else - Actions
    • Unit - Pause U //I think you still have to do this to countermand an order properly
    • Unit - Order U to stop
    • Unit - Unpause U
 
Level 3
Joined
Nov 26, 2021
Messages
25
On start they do not but can get new unit that can pick up items

There is the only one set of items on start

Now items do spawn randomly as game goes on, but the start items only once
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
I'd probably use an Item Indexer and give each Item X stacks, where X is the number of Users in the game.

Setup your items:
  • Events
    • Time - Elapsed game time is 0.01 seconds
  • Conditions
  • Actions
    • Set Variable Player_Count = (Number of players in Users_Playing)
    • Item - Pick every item in (Playable map area) and do (Actions)
      • Loop - Actions
        • Set Variable Item_CV = (Custom value of (Picked item))
        • Set Variable Item_Stacks[Item_CV] = Player_Count
        • Set Variable Item_Owner[Item_CV] = 0
        • Set Variable Item_Point[Item_CV] = (Position of (Picked item))
Users_Playing is a Player Group variable tracking all of your active Users -> Is playing, Is User.

Create a new item when it's acquired:
  • Events
    • Unit - A unit Acquires an Item
  • Conditions
    • Item_Stacks(Custom value of (Item being manipulated)) Greater than 0
    • Item_Owner(Custom value of (Item being manipulated)) Equal to 0
  • Actions
    • Set Variable Item_CV = (Custom value of (Item being manipulated))
    • Set Variable Item_Owner[Item_CV] = (Player number of (Owner of (Triggering unit)))
    • Set Variable Item_Stacks[Item_CV] = (Item_Stacks[Item_CV] - 1)
    • If all conditions are true then do (Actions)
      • If - Conditions
        • Item_Stacks[Item_CV] Greater than 0
      • Then - Actions
        • Item - Create 1 (Item-type of (Item being manipulated)) at Item_Point[Item_CV]
        • Custom script: call IndexItem( GetLastCreatedItem() )
        • Set Variable Item_CV_2 = (Custom value of (Last created item))
        • Set Variable Item_Owner[Item_CV_2] = 0
        • Set Variable Item_Stacks[Item_CV_2] = Item_Stacks[Item_CV]
        • Set Variable Item_Point[Item_CV_2] = Item_Point[Item_CV]
      • Else - Actions
        • Custom script: call RemoveLocation( udg_Item_Point[Item_CV] )
The Item Indexer may not work immediately on brand new Items so I manually call IndexItem() to assign a new Custom Value to it.

Drop items that don't belong to you:
  • Events
    • Unit - A unit Acquires an Item
  • Conditions
    • Item_Owner(Custom value of (Item being manipulated)) Not Equal to 0
    • Item_Owner(Custom value of (Item being manipulated)) Not Equal to (Player number of (Owner of (Triggering unit)))
  • Actions
    • Item - Drop (Item being manipulated) from (Triggering unit)
Note that this is unfinished and doesn't account for everything. IE: Multiple Heroes per Player will need extra Conditions/Variables, a Hashtable comes to mind.
 
Last edited:
Level 3
Joined
Nov 26, 2021
Messages
25
TY for help, howqever as item is a active on use it doesnt take a inv slot so drop item being manipulated wont work as theres no item in inv to drop

in end i went manual way as i knew how to do it that way, and from testing seems to work perfectly fine.
  • PLSetUp
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set Items --------
      • Set VariableSet PLSet[1] = Item <gen>
      • Set VariableSet PLSet[2] = Item <gen>
      • Set VariableSet PLSet[3] = Item <gen>
      • Set VariableSet PLSet[4] = Item <gen>
      • Set VariableSet PLSet[5] = Item <gen>
      • Set VariableSet PLSet[6] = Item <gen>
      • Set VariableSet PLSet[7] = Item <gen>
      • Set VariableSet PLSet[8] = Item <gen>
      • Set VariableSet PLSet[9] = Item <gen>
      • Set VariableSet PLSet[10] = Item <gen>
      • Set VariableSet PLSet[11] = Item <gen>
      • Set VariableSet PLSet[12] = Item <gen>
      • Set VariableSet PLSet[13] = Item <gen>
      • Set VariableSet PLSet[14] = Item <gen>
      • Set VariableSet PLSet[15] = Item <gen>
      • Set VariableSet PLSet[16] = Item <gen>
      • Set VariableSet PLSet[17] = Item <gen>
      • Set VariableSet PLSet[18] = Item <gen>
      • Set VariableSet PLSet[19] = Item <gen>
      • Set VariableSet PLSet[20] = Item <gen>
      • Set VariableSet PLSet[21] = Item <gen>
      • Set VariableSet PLSet[22] = Item <gen>
      • Set VariableSet PLSet[23] = Item <gen>
      • Set VariableSet PLSet[24] = Item <gen>
      • Set VariableSet PLSet[25] = Item <gen>
      • Set VariableSet PLSet[26] = Item <gen>
      • Set VariableSet PLSet[27] = Item <gen>
      • Set VariableSet PLSet[28] = Item <gen>
      • Set VariableSet PLSet[29] = Item <gen>
      • Set VariableSet PLSet[30] = Item <gen>
      • Set VariableSet PLSet[31] = Item <gen>
      • Set VariableSet PLSet[32] = Item <gen>
      • Set VariableSet PLSet[33] = Item <gen>
      • Set VariableSet PLSet[34] = Item <gen>
      • Set VariableSet PLSet[35] = Item <gen>
      • Set VariableSet PLSet[36] = Item <gen>
      • Set VariableSet PLSet[37] = Item <gen>
      • Set VariableSet PLSet[38] = Item <gen>
      • Set VariableSet PLSet[39] = Item <gen>
      • Set VariableSet PLSet[40] = Item <gen>
      • Set VariableSet PLSet[41] = Item <gen>
      • Set VariableSet PLSet[42] = Item <gen>
      • Set VariableSet PLSet[43] = Item <gen>
      • Set VariableSet PLSet[44] = Item <gen>
      • Set VariableSet PLSet[45] = Item <gen>
      • Set VariableSet PLSet[46] = Item <gen>
      • Set VariableSet PLSet[47] = Item <gen>
      • Set VariableSet PLSet[48] = Item <gen>
      • Set VariableSet PLSet[49] = Item <gen>
      • Set VariableSet PLSet[50] = Item <gen>
      • Set VariableSet PLSet[51] = Item <gen>
      • Set VariableSet PLSet[52] = Item <gen>
      • Set VariableSet PLSet[53] = Item <gen>
      • Set VariableSet PLSet[54] = Item <gen>
      • Set VariableSet PLSet[55] = Item <gen>
      • -------- Set Item Type/Location --------
      • For each (Integer A) from 1 to 55, do (Actions)
        • Loop - Actions
          • Set VariableSet PLType[(Integer A)] = (Item-type of PLSet[(Integer A)])
          • Set VariableSet PLX[(Integer A)] = (X of (Position of PLSet[(Integer A)]))
          • Set VariableSet PLY[(Integer A)] = (Y of (Position of PLSet[(Integer A)]))
  • LootCheck
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • -------- Player 1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP1[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 2 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP2[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 3 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP3[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 4 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP4[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 5 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP5[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 6 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
        • Then - Actions
          • For each (Integer A) from 1 to 43, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP6[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • -------- Player 7 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 7 (Green)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Target item of issued order) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LootP7[(Integer A)] Equal to 1
                    • Then - Actions
                      • Unit - Pause (Triggering unit)
                      • Unit - Order (Triggering unit) to Stop.
                      • Unit - Unpause (Triggering unit)
                      • Game - Display to (Player group((Owner of (Triggering unit)))) for 2.00 seconds the text: [|cffff0000U|rD|cff...
                      • Skip remaining actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
  • LootAquire
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • -------- Player 1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP1[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 2 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP2[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 3 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP3[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 4 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP4[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 5 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP5[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 6 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP6[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- Player 7 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 7 (Green)
        • Then - Actions
          • For each (Integer A) from 1 to 55, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item being manipulated) Equal to PLSet[(Integer A)]
                • Then - Actions
                  • Set VariableSet LootP7[(Integer A)] = 1
                  • Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)]))
                  • Set VariableSet PLSet[(Integer A)] = (Last created item)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
  • This line leaks a point every time you create a new item: Item - Create PLType[(Integer A)] at (Point(PLX[(Integer A)], PLY[(Integer A)])). You can store the location directly instead of the XY coordinates, which will not 'leak' the points though they will still be a very small and insignificant memory allocation.

  • Once an item is picked from a location by a player (say location 4 for example), that player will not be able to pick another item from location 4 later in the game if that player's units reach location 4 again (I'm presuming this is something like a board game where you may visit the same square throughout the course of the game). That's because you're not resetting LootP1[] ... LootP7[] to 0. If players will not ever visit the same square then this is not an issue, just pointing it out.

    I realize that the reason you're not resetting in general is so that you only have to spawn 1 of each item at once, rather than 7, so that each player only has to try to click that one item instead of finding the one that's 'theirs' amongst the 7. That's pretty smart, better than what I showed! The way I would get around this is a player group array per position. When a player grabs item 4 successfully (the 'skip remaining actions' is run) add that player to the PlGroup[4] and then check the number of players in the group; if it's 7 (or whatever the number of currently playing players is) then clear the group of all players and set LootP1[4]...LootP7[4] = 0 to reset the cycle and allow new pickups on location 4 in the future. Maybe wait until all players have moved on from that location before resetting.

  • Generally speaking having a bunch of hardcoded arrays like LootP1 is detrimental to long-term flexibility in your development because you will have to change a bunch of stuff at once if you ever have to make modifications. While not difficult it is annoying and can easily lead to errors you didn't anticipate because you forgot to click to change the variable name or didn't paste the line in the right place or whatever else.

    The two ways around that here would be to fake a 2D array (which GUI doesn't have directly) or to make better use of the player group array I mentioned above and just reduce what you're storing down to a single item array, a single player group array, and a single location array.

    A 2D array would look (in JASS) like this: Loot[3][24]. That would indicate the status of player 3 interacting with location 24. The conversion is actually quite simple; all you have to 'know' is the highest value the second columm could take. In this case that's 55 and this will make indices 1..55 specific to player 1, indices 56..110 specific to player 2, indices 111..165 to player 3, etc:
    • Set LOC_NUM = 55
    • Set WhichPlayer = Player Number of (Player 3 (Teal))
    • Set Where = 24
    • TheValueToInteractWith = LootArray[((LOC_NUM) x (WhichPlayer - 1)) + Where]
    For the parallel arrays method it would be something like this:
    • ItemArray[(Integer A)] = (The item)
    • LocationArray[(Integer A)] = (Position of the item above)
    • PlayerGroupArray[(Intger A)] = (All players that have already interacted with this item) //this array will need to have the proper 'size' such that all the relevant indices are initialized to an empty unit group (adding players to a null group doesn't do anything)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
Here's a working system that's essentially what Pyro suggested in combination with my own suggestion.

It shows how you can handle this without the need to check up to 55 different Items whenever you Acquire ANY item. It also avoids a long chain of If Then Else statements that check each individual Player. The moment you need a unique Array for each Player you should probably be using a Hashtable instead, which is what I'm using.

Anyway, I got rid of the Item Indexer for now because that system I linked had weird side effects when it came to Powerups. I think it removes them from the game which seemed to break my own triggers.

I've left my system in a state where it's a few changes away from being able to use an Item Indexer, if ever need be. At the moment I just assign Custom Value to the items myself using a very lazy design but it gets the job done.
 

Attachments

  • Personal Powerup System 1.w3m
    21.3 KB · Views: 5
Last edited:
Top