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

Instant Tower Block Detection with out lag?

Status
Not open for further replies.
Level 2
Joined
Apr 1, 2019
Messages
156
I've seen this asked before and it seems not possible to detect a block through triggers in a large mazing area without a lag spike. But it has been asked soo long ago, I don't know if anyone had any breakthroughs?

I mean Warcraft 3 itself has to run A* code everytime a movement order is issued and that doesn't lag.

I've been trying to get it to work myself using Hashtables representing a grid of stored integers X and Y. I save 1 as unwalkable squares and 2 as waypoints. 0 is walkable. Below is my triggers, Idk if anyone knows a way to optimize it?

Initialization Grid Defaults

  • Events
    • Map initialization
  • Conditions
  • Actions
    • -------- Resets all values to defaults and 0's --------
    • Set BlockGrid_Int_OpenClosed1 = 0
    • Set BlockGrid_Int_OpenClosed2 = 0
    • Set BlockGrid_Int_WaypointTotal = 0
    • Set BlockGrid_Boolean_Finish = False
    • Set BlockGrid_Unit_TempUnit = No unit
    • For each (Integer A) from 5 to 40, do (Actions)
      • Loop - Actions
        • Hashtable - Save 3 as (Integer A) of 72 in BlockGrid_Hashtable_Grid[1]
    • For each (Integer A) from 2 to 71, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 1 to 44, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (Integer B) of (Integer A) from BlockGrid_Hashtable_Grid[1]) Equal to 100
              • Then - Actions
                • Hashtable - Save 0 as (Integer B) of (Integer A) in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (Integer B) of (Integer A) from BlockGrid_Hashtable_Grid[1]) Equal to 102
              • Then - Actions
                • Hashtable - Save 2 as (Integer B) of (Integer A) in BlockGrid_Hashtable_Grid[1]
              • Else - Actions


Grid Player 1 Red Build

  • Events
    • Unit - A unit Begins construction
  • Conditions
    • (Unit-type of (Triggering unit)) Not equal to Blacksmith
    • (Unit-type of (Triggering unit)) Not equal to Arcane Vault
    • (Owner of (Triggering unit)) Equal to Player 1 (Red)
  • Actions
    • -------- Stores the 4 X and Y locations of each square the tower blocks, uses some math to store them as integers in a hashtable --------
    • Set BlockGrid_Unit_TempUnit = (Triggering unit)
    • Set TempPointSpell = (Position of (Triggering unit))
    • Set BockGrid_Int_TempX = (((X of TempPointSpell) - (X of PointRockGen[1])) / 64.00)
    • Set BockGrid_Int_TempY = (((Y of TempPointSpell) - (Y of PointRockGen[1])) / 64.00)
    • Hashtable - Save 1 as (Integer((BockGrid_Int_TempX + 1.00))) of (Integer((BockGrid_Int_TempY + 2.00))) in BlockGrid_Hashtable_Grid[1]
    • Hashtable - Save 1 as (Integer((BockGrid_Int_TempX + 2.00))) of (Integer((BockGrid_Int_TempY + 2.00))) in BlockGrid_Hashtable_Grid[1]
    • Hashtable - Save 1 as (Integer((BockGrid_Int_TempX + 1.00))) of (Integer((BockGrid_Int_TempY + 3.00))) in BlockGrid_Hashtable_Grid[1]
    • Hashtable - Save 1 as (Integer((BockGrid_Int_TempX + 2.00))) of (Integer((BockGrid_Int_TempY + 3.00))) in BlockGrid_Hashtable_Grid[1]
    • Game - Display to (All players) the text: ((String((BockGrid_Int_TempX + 1.00))) + (X + ((String((BockGrid_Int_TempY + 2.00))) + y)))
    • Game - Display to (All players) the text: ((String((BockGrid_Int_TempX + 2.00))) + (X + ((String((BockGrid_Int_TempY + 2.00))) + y)))
    • Game - Display to (All players) the text: ((String((BockGrid_Int_TempX + 1.00))) + (X + ((String((BockGrid_Int_TempY + 3.00))) + y)))
    • Game - Display to (All players) the text: ((String((BockGrid_Int_TempX + 2.00))) + (X + ((String((BockGrid_Int_TempY + 3.00))) + y)))
    • Custom script: call RemoveLocation(udg_TempPointSpell)
    • Trigger - Run Test <gen> (checking conditions)


Test

  • Events
  • Conditions
  • Actions
    • -------- Checks start of mazing area for 0s and 2s and changes them to 100 and 102 --------
    • -------- Adds the Coordinance of the 100 and 102 to a integer array to be looped through in next trigger --------
    • For each (Integer A) from 5 to 40, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Load (Integer A) of 2 from BlockGrid_Hashtable_Grid[1]) Equal to 0
          • Then - Actions
            • Hashtable - Save 100 as (Integer A) of 2 in BlockGrid_Hashtable_Grid[1]
            • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
            • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (Integer A)
            • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = 2
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Load (Integer A) of 2 from BlockGrid_Hashtable_Grid[1]) Equal to 2
          • Then - Actions
            • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
            • Hashtable - Save 102 as (Integer A) of 2 in BlockGrid_Hashtable_Grid[1]
            • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
            • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (Integer A)
            • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = 2
          • Else - Actions
    • Trigger - Run Test Loop <gen> (checking conditions)


Test Loop

  • Events
  • Conditions
  • Actions
    • -------- Loops through each saved 100 and 102 finding all nearby 0's and 2's then adding them to a new integer array --------
    • -------- Every 2 thats hit increases waypoint total integer --------
    • -------- 3s are at the end of the maze, they tick the Block_Grid_Finish Boolean --------
    • -------- This trigger reruns until all reachable 0s and 2s have been changed to 100s and 102s OR if waypoint total and boolean condition is met --------
    • For each (Integer A) from 1 to BlockGrid_Int_OpenClosed1, do (Actions)
      • Loop - Actions
        • -------- Up --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1) Less than or equal to 72
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX1[(Integer A)] of (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedX1[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX1[(Integer A)] of (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedX1[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1)
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX1[(Integer A)] of (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Boolean_Finish = True
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedX1[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedY1[(Integer A)] + 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Down --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedY1[(Integer A)] - 1) Greater than or equal to 1
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX1[(Integer A)] of (BlockGrid_Int_OpenClosedY1[(Integer A)] - 1) from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedX1[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedY1[(Integer A)] - 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX1[(Integer A)] of (BlockGrid_Int_OpenClosedY1[(Integer A)] - 1) from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedX1[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedY1[(Integer A)] - 1)
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Left --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1) Greater than or equal to 1
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Right --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1) Less than or equal to 44
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY1[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed2 = (BlockGrid_Int_OpenClosed2 + 1)
                • Set BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] = (BlockGrid_Int_OpenClosedX1[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] = BlockGrid_Int_OpenClosedY1[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX2[BlockGrid_Int_OpenClosed2] of BlockGrid_Int_OpenClosedY2[BlockGrid_Int_OpenClosed2] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
    • Set BlockGrid_Int_OpenClosed1 = 0
    • -------- Contains a second loop to alternate between integers and integer arrays --------
    • For each (Integer A) from 1 to BlockGrid_Int_OpenClosed2, do (Actions)
      • Loop - Actions
        • -------- Up --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1) Less than or equal to 72
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX2[(Integer A)] of (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedX2[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX2[(Integer A)] of (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedX2[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1)
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX2[(Integer A)] of (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1) from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Boolean_Finish = True
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedX2[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedY2[(Integer A)] + 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Down --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedY2[(Integer A)] - 1) Greater than or equal to 1
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX2[(Integer A)] of (BlockGrid_Int_OpenClosedY2[(Integer A)] - 1) from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedX2[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedY2[(Integer A)] - 1)
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load BlockGrid_Int_OpenClosedX2[(Integer A)] of BlockGrid_Int_OpenClosedY2[((Integer A) - 1)] from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedX2[(Integer A)]
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedY2[(Integer A)] - 1)
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Left --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1) Greater than or equal to 1
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] - 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
        • -------- Right --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1) Less than or equal to 44
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 0
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 2
              • Then - Actions
                • Set BlockGrid_Int_WaypointTotal = (BlockGrid_Int_WaypointTotal + 1)
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 102 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Load (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1) of BlockGrid_Int_OpenClosedY2[(Integer A)] from BlockGrid_Hashtable_Grid[1]) Equal to 3
              • Then - Actions
                • Set BlockGrid_Int_OpenClosed1 = (BlockGrid_Int_OpenClosed1 + 1)
                • Set BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] = (BlockGrid_Int_OpenClosedX2[(Integer A)] + 1)
                • Set BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] = BlockGrid_Int_OpenClosedY2[(Integer A)]
                • Hashtable - Save 100 as BlockGrid_Int_OpenClosedX1[BlockGrid_Int_OpenClosed1] of BlockGrid_Int_OpenClosedY1[BlockGrid_Int_OpenClosed1] in BlockGrid_Hashtable_Grid[1]
              • Else - Actions
          • Else - Actions
    • Set BlockGrid_Int_OpenClosed2 = 0
    • Game - Display to (All players) the text: yes
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • BlockGrid_Int_WaypointTotal Greater than or equal to (WaypointRockGenNumber + PortelGenInt)
        • BlockGrid_Boolean_Finish Equal to True
      • Then - Actions
        • Game - Display to (All players) the text: (Block Grid + (String(BlockGrid_Int_WaypointTotal)))
        • Game - Display to (All players) the text: (Waypoints + (String(WaypointRockGenNumber)))
        • Game - Display to (All players) the text: (Portals + (String(PortelGenInt)))
        • Trigger - Run Initialization Grid Defaults <gen> (checking conditions)
        • Skip remaining actions
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • BlockGrid_Int_OpenClosed1 Equal to 0
      • Then - Actions
        • Game - Display to (All players) the text: (Block Grid + (String(BlockGrid_Int_WaypointTotal)))
        • Game - Display to (All players) the text: (Waypoints + (String(WaypointRockGenNumber)))
        • Game - Display to (All players) the text: (Portals + (String(PortelGenInt)))
        • Set TempPointSpell = (Position of BlockGrid_Unit_TempUnit)
        • Set TempPlayerGroup = (Player group((Owner of BlockGrid_Unit_TempUnit)))
        • Game - Display to TempPlayerGroup the text: (Blocking Tower Destroyed, + ((|cFFFFCC00 + (String((Point-value of BlockGrid_Unit_TempUnit)))) + |r gold refunded.))
        • Unit - Remove BlockGrid_Unit_TempUnit from the game
        • Special Effect - Create a special effect at TempPointSpell using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
        • Special Effect - Set Scale of (Last created special effect) to 1.50
        • Special Effect - Set Time Scale of (Last created special effect) to 0.70
        • Special Effect - Destroy (Last created special effect)
        • Sound - Play Error <gen> at 100.00% volume, located at TempPointSpell with Z offset 0.00
        • Player - Add (Point-value of BlockGrid_Unit_TempUnit) to (Owner of BlockGrid_Unit_TempUnit) Current gold
        • Hashtable - Save 0 as (Integer((BockGrid_Int_TempX + 1.00))) of (Integer((BockGrid_Int_TempY + 2.00))) in BlockGrid_Hashtable_Grid[1]
        • Hashtable - Save 0 as (Integer((BockGrid_Int_TempX + 2.00))) of (Integer((BockGrid_Int_TempY + 2.00))) in BlockGrid_Hashtable_Grid[1]
        • Hashtable - Save 0 as (Integer((BockGrid_Int_TempX + 1.00))) of (Integer((BockGrid_Int_TempY + 3.00))) in BlockGrid_Hashtable_Grid[1]
        • Hashtable - Save 0 as (Integer((BockGrid_Int_TempX + 2.00))) of (Integer((BockGrid_Int_TempY + 3.00))) in BlockGrid_Hashtable_Grid[1]
        • Custom script: call DestroyForce(udg_TempPlayerGroup)
        • Custom script: call RemoveLocation(udg_TempPointSpell)
        • Trigger - Run Initialization Grid Defaults <gen> (checking conditions)
        • Skip remaining actions
        • Game - Display to (All players) the text: (Block Grid + (String(BlockGrid_Int_WaypointTotal)))
        • Game - Display to (All players) the text: (Waypoints + (String(WaypointRockGenNumber)))
        • Game - Display to (All players) the text: (Portals + (String(PortelGenInt)))
        • Trigger - Run Initialization Grid Defaults <gen> (checking conditions)
      • Else - Actions
        • Trigger - Run (This trigger) (checking conditions)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
I can't really suggest anything specific regarding your code but I'm sure JASS/Lua would open up a lot more options for efficiency. Anyway, here's an idea that I had regarding the concept in general.

The idea I had was to create a Line of Sight Blocker inside of every single Tower built. Then make sure to have a computer player that has absolutely no vision of the map. Next you would create some unit(s) for that computer player at a starting point that would attempt to cast the "Blink" ability towards an end point. The Blink ability requires an area to be explored first to cast. So the only way that the ability would work is if the computer had vision, and the only way that the computer would have vision is if there was some gaps between the line of sight blockers (no complete wall-offs).

I'm not sure about all of the details or whether or not it will even work but it's something to think about I guess.
 
Level 2
Joined
Apr 1, 2019
Messages
156
Tried it, seems to clunky to get it to work properly, maybe if I was better with triggers lol.

But I figured some shtuffs out with my original triggers, hashtables use more ram than integer arrays. So I replaced the hashtable with an 3124 integer array. Runs a bit smoother now, I'd say playable.

Testing it if I can somehow reduce the number of math equations within the loop to a min it will be even more optimal.
https://www.epicwar.com/maps/download/296359/05f95b056fa9a2c327775b75409c9e7aeffc7c0da3a17ffa934e283abadefd3f5d55ff25/Tower Blocking System v1.3.w3x
 
Level 2
Joined
Apr 1, 2019
Messages
156
Alright so after some googles, are you talking about "structs"?
Most tutorials use "local" variables within the "structs" but I need to retrieve the same information throughout the game so I need "globals"
But then I'm just putting a "global integer array" inside a "struct" which seems no more ram efficient than GUI. Idk if your referring to something else?

A short example vjass trigger would be very helpful
 
Status
Not open for further replies.
Top