[Trigger] How can i optimize this trigger?

Level 9
Joined
Dec 1, 2010
Messages
346
I have the following trigger currently set up in my project.

Simply put this trigger shows you a different multiboard with resources based on which out of 15 regions you are hovering with your mouse.

It's very intuitive to play with in it's current form so i much prefer it over previous iterations of changing the multiboard. However i'm suspsecting this trigger is causing significnt lagg since it basically triggers every time you move your mouse.

I was wondering if there's any ways to increase performance and keep the same functionality. There are certain things i'm not sure about. like does hiding previous multiboards help or not. During testing I've noticed a significant performance increase when turning this trigger off. And since i have many resource intensive systems in my map that's a big issue.



  • MouseHoverRegion
    • Events
      • Player - Player 1 (Red) issues Mouse Move event
      • Player - Player 2 (Blue) issues Mouse Move event
      • Player - Player 3 (Teal) issues Mouse Move event
      • Player - Player 4 (Purple) issues Mouse Move event
      • Player - Player 5 (Yellow) issues Mouse Move event
      • Player - Player 6 (Orange) issues Mouse Move event
      • Player - Player 7 (Green) issues Mouse Move event
      • Player - Player 8 (Pink) issues Mouse Move event
      • Player - Player 9 (Gray) issues Mouse Move event
      • Player - Player 10 (Light Blue) issues Mouse Move event
      • Player - Player 11 (Dark Green) issues Mouse Move event
      • Player - Player 12 (Brown) issues Mouse Move event
    • Conditions
    • Actions
      • Set VariableSet Temp_Loc1 = (Mouse Position for Triggered Mouse Event)
      • -------- hover tradenode 1 --------
      • -------- 26 is the current most regions in a node (last node is 15) --------
      • For each (Integer A) from 1 to 27, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Node1Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
            • Then - Actions
              • Set VariableSet localplayer = (Triggering player)
              • Custom script: if udg_localplayer == GetLocalPlayer() then
              • Multiboard - Hide TradeNodeMultiboard[3]
              • Multiboard - Hide TradeNodeMultiboard[2]
              • Multiboard - Hide TradeNodeMultiboard[7]
              • Multiboard - Show TradeNodeMultiboard[1]
              • Custom script: endif
            • Else - Actions
              • -------- hover tradenode 2 --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Node2Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                • Then - Actions
                  • Set VariableSet localplayer = (Triggering player)
                  • Custom script: if udg_localplayer == GetLocalPlayer() then
                  • Multiboard - Hide TradeNodeMultiboard[1]
                  • Multiboard - Hide TradeNodeMultiboard[3]
                  • Multiboard - Hide TradeNodeMultiboard[4]
                  • Multiboard - Hide TradeNodeMultiboard[5]
                  • Multiboard - Show TradeNodeMultiboard[2]
                  • Multiboard - Hide TradeNodeMultiboard[7]
                  • Custom script: endif
                • Else - Actions
                  • -------- hover tradenode 3 --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Node3Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                    • Then - Actions
                      • Set VariableSet localplayer = (Triggering player)
                      • Custom script: if udg_localplayer == GetLocalPlayer() then
                      • Multiboard - Hide TradeNodeMultiboard[1]
                      • Multiboard - Hide TradeNodeMultiboard[2]
                      • Multiboard - Hide TradeNodeMultiboard[4]
                      • Multiboard - Hide TradeNodeMultiboard[5]
                      • Multiboard - Hide TradeNodeMultiboard[7]
                      • Multiboard - Show TradeNodeMultiboard[3]
                      • Custom script: endif
                    • Else - Actions
                      • -------- hover tradenode 4 --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Node4Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                        • Then - Actions
                          • Set VariableSet localplayer = (Triggering player)
                          • Custom script: if udg_localplayer == GetLocalPlayer() then
                          • Multiboard - Hide TradeNodeMultiboard[1]
                          • Multiboard - Hide TradeNodeMultiboard[2]
                          • Multiboard - Hide TradeNodeMultiboard[3]
                          • Multiboard - Hide TradeNodeMultiboard[7]
                          • Multiboard - Hide TradeNodeMultiboard[4]
                          • Multiboard - Hide TradeNodeMultiboard[5]
                          • Multiboard - Show TradeNodeMultiboard[4]
                          • Custom script: endif
                        • Else - Actions
                          • -------- hover tradenode 5 --------
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Node5Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                            • Then - Actions
                              • Set VariableSet localplayer = (Triggering player)
                              • Custom script: if udg_localplayer == GetLocalPlayer() then
                              • Multiboard - Hide TradeNodeMultiboard[1]
                              • Multiboard - Hide TradeNodeMultiboard[2]
                              • Multiboard - Hide TradeNodeMultiboard[3]
                              • Multiboard - Hide TradeNodeMultiboard[4]
                              • Multiboard - Hide TradeNodeMultiboard[7]
                              • Multiboard - Show TradeNodeMultiboard[5]
                              • Custom script: endif
                            • Else - Actions
                              • -------- hover tradenode 6 --------
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Node6Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                • Then - Actions
                                  • Set VariableSet localplayer = (Triggering player)
                                  • Custom script: if udg_localplayer == GetLocalPlayer() then
                                  • Multiboard - Hide TradeNodeMultiboard[1]
                                  • Multiboard - Hide TradeNodeMultiboard[2]
                                  • Multiboard - Hide TradeNodeMultiboard[3]
                                  • Multiboard - Hide TradeNodeMultiboard[4]
                                  • Multiboard - Hide TradeNodeMultiboard[5]
                                  • Multiboard - Hide TradeNodeMultiboard[7]
                                  • Multiboard - Show TradeNodeMultiboard[6]
                                  • Custom script: endif
                                • Else - Actions
                                  • -------- hover tradenode 7 --------
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Node7Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                    • Then - Actions
                                      • Set VariableSet localplayer = (Triggering player)
                                      • Custom script: if udg_localplayer == GetLocalPlayer() then
                                      • Multiboard - Hide TradeNodeMultiboard[1]
                                      • Multiboard - Hide TradeNodeMultiboard[2]
                                      • Multiboard - Hide TradeNodeMultiboard[3]
                                      • Multiboard - Hide TradeNodeMultiboard[4]
                                      • Multiboard - Hide TradeNodeMultiboard[5]
                                      • Multiboard - Hide TradeNodeMultiboard[6]
                                      • Multiboard - Show TradeNodeMultiboard[7]
                                      • Custom script: endif
                                    • Else - Actions
                                      • -------- hover tradenode 8 --------
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Node8Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                        • Then - Actions
                                          • Set VariableSet localplayer = (Triggering player)
                                          • Custom script: if udg_localplayer == GetLocalPlayer() then
                                          • Multiboard - Show TradeNodeMultiboard[8]
                                          • Custom script: endif
                                        • Else - Actions
                                          • -------- hover tradenode 9 --------
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Node9Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                            • Then - Actions
                                              • Set VariableSet localplayer = (Triggering player)
                                              • Custom script: if udg_localplayer == GetLocalPlayer() then
                                              • Multiboard - Show TradeNodeMultiboard[9]
                                              • Custom script: endif
                                            • Else - Actions
                                              • -------- hover tradenode 10 --------
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Node10Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                • Then - Actions
                                                  • Set VariableSet localplayer = (Triggering player)
                                                  • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                  • Multiboard - Show TradeNodeMultiboard[10]
                                                  • Custom script: endif
                                                • Else - Actions
                                                  • -------- hover tradenode 11 --------
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Node11Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                    • Then - Actions
                                                      • Set VariableSet localplayer = (Triggering player)
                                                      • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                      • Multiboard - Show TradeNodeMultiboard[11]
                                                      • Custom script: endif
                                                    • Else - Actions
                                                      • -------- hover tradenode 12 --------
                                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                        • If - Conditions
                                                          • (Node12Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                        • Then - Actions
                                                          • Set VariableSet localplayer = (Triggering player)
                                                          • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                          • Multiboard - Show TradeNodeMultiboard[12]
                                                          • Custom script: endif
                                                        • Else - Actions
                                                          • -------- hover tradenode 13 --------
                                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                            • If - Conditions
                                                              • (Node13Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                            • Then - Actions
                                                              • Set VariableSet localplayer = (Triggering player)
                                                              • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                              • Multiboard - Show TradeNodeMultiboard[13]
                                                              • Custom script: endif
                                                            • Else - Actions
                                                              • -------- hover tradenode 14 --------
                                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                • If - Conditions
                                                                  • (Node14Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                                • Then - Actions
                                                                  • Set VariableSet localplayer = (Triggering player)
                                                                  • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                                  • Multiboard - Show TradeNodeMultiboard[14]
                                                                  • Custom script: endif
                                                                • Else - Actions
                                                                  • -------- hover tradenode 14 --------
                                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                                    • If - Conditions
                                                                      • (Node15Regions[(Integer A)] contains (Mouse Position for Triggered Mouse Event)) Equal to True
                                                                    • Then - Actions
                                                                      • Set VariableSet localplayer = (Triggering player)
                                                                      • Custom script: if udg_localplayer == GetLocalPlayer() then
                                                                      • Multiboard - Show TradeNodeMultiboard[15]
                                                                      • Custom script: endif
                                                                    • Else - Actions
                                                                      • -------- hover tradenode 16 --------
      • Custom script: call RemoveLocation(udg_Temp_Loc1)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Remove any redundancy, don't use (Integer A), use a Hashtable to save the Regions and how many there are, use a Hashtable to save which multiboards get hidden and which get shown, reference Temp_Loc1 instead of this memory leak -> (Mouse Position for Triggered Mouse Event)).

Then change the Event to a periodic interval and have it run for all ACTIVE Players. These players would be stored in a Player Group that adds them as the game starts and removes them after they leave the game. You could even offset the periodic intervals so it runs at different times for different players.

Here's an example:
  • Get Player MouseXY
    • Events
      • Player - Player 1 (Red) issues Mouse Move event
      • Player - Player 2 (Blue) issues Mouse Move event
      • Player - Player 3 (Teal) issues Mouse Move event
      • Player - Player 4 (Purple) issues Mouse Move event
      • Player - Player 5 (Yellow) issues Mouse Move event
      • Player - Player 6 (Orange) issues Mouse Move event
      • Player - Player 7 (Green) issues Mouse Move event
      • Player - Player 8 (Pink) issues Mouse Move event
      • Player - Player 9 (Gray) issues Mouse Move event
      • Player - Player 10 (Light Blue) issues Mouse Move event
      • Player - Player 11 (Dark Green) issues Mouse Move event
      • Player - Player 12 (Brown) issues Mouse Move event
    • Conditions
    • Actions
      • Set Variable PN = (Player number of (Triggering player))
      • Set Variable Mouse_Point = (Mouse Position for Triggered Mouse Event)
      • Set Variable Mouse_X[PN] = (X of Mouse_Point)
      • Set Variable Mouse_Y[PN] = (Y of Mouse_Point)
      • Custom script: call RemoveLocation( udg_Mouse_Point )
  • Events
    • Time - Every 0.20 seconds
  • Conditions
  • Actions
    • Player Group - Pick every player in Active_Users and do (Actions)
      • Loop - Actions
        • Set Variable PN = (Player number of (Picked player))
        • Set Variable Region_Checks[PN] = (Region_Checks[PN] + 1)
        • If all conditions are true then do actions
          • If - Conditions
            • Region_Checks[PN] Equal to Region_Checks_Needed[PN]
          • Then - Actions
            • Set Variable Region_Checks[PN] = 0
            • Set Variable Mouse_Point = Point(Mouse_X[PN], Mouse_Y[PN])
            • -------- Proceed to check all regions using For Loops + loaded Hashtable data --------
            • Custom script: call RemoveLocation( udg_Mouse_Point )
          • Else - Actions
So now I'm always storing the mouse x/y coordinates for all players.

Then I periodically track the elapsed time for each player, and every X seconds I run a mouse position + region check. This check would rely on the saved Hashtable data to see if Mouse_Point is inside any of the Regions. The logic would remain mostly the same as what you have now. The Hashtable data would have been setup beforehand, likely after you set all of the NodeRegion variables since it'll use them as a reference on what to Save.

That being said, it would probably be better to get the Player's current camera coordinates instead of their mouse coordinates. This could be done at the time that they're needed rather than ALL of the time. Then replace Mouse_Point with Camera_Point. The only issue here is I think you'll need to sync the camera data first, but I can show you how to do that.

Also, if your NodeXRegions are not overlapping then you could reduce the number of Region checks. But I imagine the reason you have so many Region Nodes is because they're scattered randomly across the map.

Note that you don't need to create a Region if you're just comparing X/Y coordinates and aren't going to use their Enter/Leave functionality. For example, if Mouse_X >= -5000 and Mouse_X <= 5000 and Mouse_Y >= -5000 and Mouse_Y <= 5000 then we know that their Mouse is within a 10,000x10,000 chunk of the map. You don't need to create a Region to figure that out, which could be useful if you want to reduce your Region usage or possibly find other coordinate related optimizations.
 
Last edited:
Level 9
Joined
Dec 1, 2010
Messages
346
Also, if your NodeXRegions are not overlapping then you could reduce the number of Region checks. But I imagine the reason you have so many Region Nodes is because they're scattered randomly across the map.

Note that you don't need to create a Region if you're just comparing X/Y coordinates and aren't going to use their Enter/Leave functionality. For example, if Mouse_X >= -5000 and Mouse_X <= 5000 and Mouse_Y >= -5000 and Mouse_Y <= 5000 then we know that their Mouse is within a 10,000x10,000 chunk of the map. You don't need to create a Region to figure that out, which could be useful if you want to reduce your Region usage or possibly find other coordinate related optimizations.
map5.PNG

My region situation is a bit complex..
i have about 180 of them since they need to follow natural region borders. I like having them though. it makes it easy for me to know what region i'm working in. as each of them will have access to a different combination of resources based on their geography and climate.
 

Attachments

  • map5.PNG
    map5.PNG
    1.3 MB · Views: 8
Level 9
Joined
Dec 1, 2010
Messages
346
That being said, it would probably be better to get the Player's current camera coordinates instead of their mouse coordinates. This could be done at the time that they're needed rather than ALL of the time. Then replace Mouse_Point with Camera_Point. The only issue here is I think you'll need to sync the camera data first, but I can show you how to do that.

That honestly sounds better yes. I currently still have the issue that it returns null when hovering the menu (fixable but annoying). But it seems a bit more intuitive to use the camera instead.

It depends though on what point specifically the camera takes., is it always the center of your screen? I don't want too get a situation where you're hovering a certain spot and it displays the wrong region's trade node, also. I will add commands that change the cameras zoom.


What is this syncing of camera data?

Btw, the setup you describe would look something like this? (the first trigger no longer being required)
  • CheckCamPos
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in PG_Active_Users and do (Actions)
        • Loop - Actions
          • Set VariableSet PlayerNumber = (Player number of (Picked player))
          • Set VariableSet Region_Checks[PlayerNumber] = (Region_Checks[PlayerNumber] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Region_Checks[PlayerNumber] Equal to 15
            • Then - Actions
              • Set VariableSet Region_Checks[PlayerNumber] = 0
              • Set VariableSet Camera_Point = (Target of current camera view)
              • -------- Proceed to check all regions using For Loops + loaded Hashtable data --------
              • Custom script: call RemoveLocation( udg_Camera_Point )
            • Else - Actions
I'm a bit unsure how you envision the hashtable to look.

I currently have arrays for every region that are manually set up already to contain every single region. eg:
  • Node7Regions[A]
and in my current set up I iterated over all those 27 times. (the biggest region is 26 regions combined) So the for loop went through each of these variables and checked if any of their 1 - 27 child regions contained the point. Would i still use these array variables? (with a counter +1 instead of Integer A)
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That honestly sounds better yes. I currently still have the issue that it returns null when hovering the menu (fixable but annoying). But it seems a bit more intuitive to use the camera instead.

It depends though on what point specifically the camera takes., is it always the center of your screen? I don't want too get a situation where you're hovering a certain spot and it displays the wrong region's trade node, also. I will add commands that change the cameras zoom.


What is this syncing of camera data?
The Target X/Y of the camera view would be the very center of the screen. I would choose this optimization over rare edge cases that hardly come up.

Anyway, you don't necessarily have to sync the camera data if you're careful with how you use it:
  • Custom script: if udg_localplayer == GetLocalPlayer() then
  • Set Variable X = (Target X of current camera view)
  • Set Variable Y = (Target Y of current camera view)
  • Custom script: endif
Note how "current camera view" doesn't specify a player, this basically needs to be used in a GetLocalPlayer() block to work properly. If you wanted to then use those X/Y coordinates in a way that won't desync (like creating a Unit at them) then you'd have to sync this information to every player first.

I attached an example map showcasing what I described before, it should have most if not all of the answers you need.
 

Attachments

  • Get Camera Region.w3m
    20.4 KB · Views: 4
Last edited:
Level 9
Joined
Dec 1, 2010
Messages
346
The Target X/Y of the camera view would be the very center of the screen. I would choose this optimization over rare edge cases that hardly come up.

Anyway, you don't necessarily have to sync the camera data if you're careful with how you use it:
  • Custom script: if udg_localplayer == GetLocalPlayer() then
  • Set Variable X = (Target X of current camera view)
  • Set Variable Y = (Target Y of current camera view)
  • Custom script: endif
Note how "current camera view" doesn't specify a player, this basically needs to be used in a GetLocalPlayer() block to work properly. If you wanted to then use those X/Y coordinates in a way that won't desync (like creating a Unit at them) then you'd have to sync this information to every player first.

I attached an example map showcasing what I described before, it should have most if not all of the answers you need.
Aha, well i'm not planning on doing anything but display the multiboard, which if i understand you correctly does not cause a desync.




I tried the test map and it seemed to work perfect in there, when trying to implement it into my own map i ran into some issues though.
Idk if it's clear in the video. but it's not correctly displaying it for all of the subregions. for reference. All of the red regions are part of regions2 yet it's only really triggering for specific areas. same for region1 (yellow) where the middle island does not show anything when hovered. video above also shows this in action.

I don't know if i might have done something wrong when implementing this into my map?

regions.PNG




  • Setup Camera Regions
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet Cam_Hashtable = (Last created hashtable)
      • -------- --------
      • -------- Save the total number of Region sets: --------
      • Hashtable - Save 2 as 0 of 0 in Cam_Hashtable.
      • -------- --------
      • -------- Save the first set of Regions: --------
      • Set VariableSet Cam_Regions[1] = Node1R1 <gen>
      • Set VariableSet Cam_Regions[2] = Node1R2 <gen>
      • Set VariableSet Cam_Regions[3] = Node1R3 <gen>
      • Hashtable - Save 2 as 0 of 1 in Cam_Hashtable.
      • For each (Integer Cam_Loop_A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle OfCam_Regions[Cam_Loop_A] as Cam_Loop_A of 1 in Cam_Hashtable.
      • -------- --------
      • -------- Save the second set of Regions: --------
      • Set VariableSet Cam_Regions[1] = Node2R1 <gen>
      • Set VariableSet Cam_Regions[2] = Node2R2 <gen>
      • Set VariableSet Cam_Regions[3] = Node2R3 <gen>
      • Set VariableSet Cam_Regions[4] = Node2R4 <gen>
      • Set VariableSet Cam_Regions[5] = Node2R5 <gen>
      • Set VariableSet Cam_Regions[6] = Node2R6 <gen>
      • Set VariableSet Cam_Regions[7] = Node2R7 <gen>
      • Hashtable - Save 1 as 0 of 2 in Cam_Hashtable.
      • For each (Integer Cam_Loop_A) from 1 to 7, do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle OfCam_Regions[Cam_Loop_A] as Cam_Loop_A of 2 in Cam_Hashtable.
  • Get Player Camera Region
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in Cam_Users and do (Actions)
        • Loop - Actions
          • Set VariableSet Cam_Player = (Picked player)
          • Set VariableSet Cam_PN = (Player number of Cam_Player)
          • Set VariableSet Cam_Counter[Cam_PN] = (Cam_Counter[Cam_PN] + 1)
          • -------- --------
          • Game - Display to Cam_Users for 1.00 seconds the text: (Cam Counter: + ((String(Cam_Counter[Cam_PN])) + (/ + (String(Cam_Counter_Needed[Cam_PN])))))
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Cam_Counter[Cam_PN] Equal to Cam_Counter_Needed[Cam_PN]
            • Then - Actions
              • Set VariableSet Cam_Counter[Cam_PN] = 0
              • -------- --------
              • Cinematic - Clear the screen of text messages for Cam_Users.
              • Game - Display to Cam_Users for 1.00 seconds the text: |cff00ff00Checking!...
              • -------- --------
              • Custom script: if GetLocalPlayer() == udg_Cam_Player then
              • Set VariableSet Cam_X = (Target X of current camera view)
              • Set VariableSet Cam_Y = (Target Y of current camera view)
              • For each (Integer Cam_Loop_A) from 1 to (Load 0 of 0 from Cam_Hashtable.), do (Actions)
                • Loop - Actions
                  • For each (Integer Cam_Loop_B) from 1 to (Load 0 of Cam_Loop_A from Cam_Hashtable.), do (Actions)
                    • Loop - Actions
                      • Set VariableSet Cam_Regions[0] = (Load Cam_Loop_B of Cam_Loop_A in Cam_Hashtable.)
                      • Custom script: if RectContainsCoords(udg_Cam_Regions[0], udg_Cam_X, udg_Cam_Y) then
                      • Game - Display to Cam_Users for 1.00 seconds the text: (Camera is in Region Set: + (String(Cam_Loop_A)))
                      • Multiboard - Show TradeNodeMultiboard[Cam_Loop_A]
                      • Custom script: return
                      • Custom script: endif
              • -------- --------
              • Custom script: endif
            • Else - Actions
 

Attachments

  • traderpgTradeWorking v35.w3m
    3.6 MB · Views: 5

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
The Hashtable needs to Save the following:
1) How many Regions exist per "Region Set" which is what I decided to call each grouping of Regions.
2) How many Sets there are in total.
3) The actual Regions in each Set, which are referred to as Rects in this case.

The number of Regions that exist in each Set is saved at Child Key 0, Parent Key X, where X is the current Set #:
  • Hashtable - Save 2 as 0 of 1 in Cam_Hashtable.
Note how you're saving 2 when you have 3 Regions in total. I had only used 2 Regions for this Set in my demo map which is why this value works there.

These values get referenced in the For Loops to determine the max ranges. Loop_A goes over each Set and Loop_B goes over each Region in that Set:
  • For each (Integer Cam_Loop_A) from 1 to (Load 0 of 0 from Cam_Hashtable.), do (Actions)
    • Loop - Actions
      • For each (Integer Cam_Loop_B) from 1 to (Load 0 of Cam_Loop_A from Cam_Hashtable.), do (Actions)
I know Hashtables are a little confusing to read but they're not as complicated as they seem. They're basically just bigger Arrays, so if you understand how to use an Array then you'll be able to understand how to use a Hashtable.
 
Last edited:
Level 9
Joined
Dec 1, 2010
Messages
346
The Hashtable needs to Save the following:
1) How many Regions exist per "Region Set" which is what I decided to call each grouping of Regions.
2) How many Sets there are in total.
3) The actual Regions in each Set, which are referred to as Rects in this case.

The number of Regions that exist in each Set is saved at Child Key 0, Parent Key X, where X is the current Set #:
  • Hashtable - Save 2 as 0 of 1 in Cam_Hashtable.
Note how you're saving 2 when you have 3 Regions in total. I had only used 2 Regions for this Set in my demo map which is why this value works there.

These values get referenced in the For Loops to determine the max ranges. Loop_A goes over each Set and Loop_B goes over each Region in that Set:
  • For each (Integer Cam_Loop_A) from 1 to (Load 0 of 0 from Cam_Hashtable.), do (Actions)
    • Loop - Actions
      • For each (Integer Cam_Loop_B) from 1 to (Load 0 of Cam_Loop_A from Cam_Hashtable.), do (Actions)
I know Hashtables are a little confusing to read but they're not as complicated as they seem. They're basically just bigger Arrays, so if you understand how to use an Array then you'll be able to understand how to use a Hashtable.
i Can't believe it was something that futile haha.

yeah, I'm getting more used to hashtables every day. used them heavily in my trading system.
In this case, i wasn't fully certain what the hashtable you prescribed actually stored. Now it's very clear though. the game runs as smooth as a baby's bottom haha
 
Top