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

Prevent Blocking in TD

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
So I know the most prominent way is that when a creep cannot complete its move order it is allowed to attack and destroy until it can reach its destination, other times people catch the attack order and have the creep "blink" to where it needs to be.


I would rather catch the block when the player tries to build so this never becomes an issue:

Currently, I have crafted something based upon an example I found, however it works only in the case that if an entire row or column of the plot is blocked.

I would like to add a way to detect blocking not only on the whole but also part to allow for creeps to move from each "checkpoint" within the plot without being blocked. (See picture to better visualize)


Not sure if this is relevant, I am working with the assumption that the grid I am working on is made up spots of size 128x128 (size of a regular scout tower) and there must be at least 64 units open for the route to be unblocked.

Code so far:

  • On Build
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPoint = (Position of TempUnit)
      • Set MinX = (X of TempPoint)
      • Set MaxX = (X of TempPoint)
      • Set MinY = (Y of TempPoint)
      • Set MaxY = (Y of TempPoint)
      • Unit Group - Add TempUnit to AB_Group
      • Custom script: loop
      • Set DidChain = False
      • Unit Group - Pick every unit in AB_Group and do (Actions)
        • Loop - Actions
          • Set TempUnit2 = (Picked unit)
          • Set TempPoint2 = (Position of TempUnit2)
          • Set AB_FilterGroup = (Units within 191.00 of TempPoint2)
          • Unit Group - Pick every unit in AB_FilterGroup and do (Actions)
            • Loop - Actions
              • Set TempUnit3 = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit3 is A structure) Equal to True
                  • (TempUnit3 is in AB_Group) Equal to False
                • Then - Actions
                  • Unit Group - Add TempUnit3 to AB_Group
                  • Set TempPoint3 = (Position of TempUnit3)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (X of TempPoint3) Less than MinX
                    • Then - Actions
                      • Set MinX = (X of TempPoint3)
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (X of TempPoint3) Greater than MaxX
                    • Then - Actions
                      • Set MaxX = (X of TempPoint3)
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Y of TempPoint3) Less than MinY
                    • Then - Actions
                      • Set MinY = (Y of TempPoint3)
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Y of TempPoint3) Greater than MaxY
                    • Then - Actions
                      • Set MaxY = (Y of TempPoint3)
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_TempPoint3)
                  • Set DidChain = True
                • Else - Actions
          • Custom script: call DestroyGroup(udg_AB_FilterGroup)
          • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: exitwhen udg_DidChain == false
      • Custom script: endloop
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (MaxX - MinX) Greater than or equal to 896.00
              • (MaxY - MinY) Greater than or equal to 896.00
        • Then - Actions
          • Special Effect - Create a special effect at TempPoint using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit - Remove TempUnit from the game
          • Game - Display to (All players) for 5.00 seconds the text: (Blocked. X Length: + ((String((MaxX - MinX))) + (Y Length: + (String((MaxY - MinY))))))
        • Else - Actions
          • Game - Display to (All players) for 5.00 seconds the text: (Not Blocked. X Length: + ((String((MaxX - MinX))) + ( Y Length: + (String((MaxY - MinY))))))
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Unit Group - Remove all units from AB_Group


AntiBlock Pic.png
(Pardon that my code is set up for a square and my picture is rectangles.)
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
I have been doing such a system, but it does not work with too big regions (because warcraft stops the trigger after too many recursions). My system could detect, when a tower is built on a location which would block the path. You could then remove the tower, return resources and dsiplay an error message.
If you are interested I can share it with you.
 

Deleted member 219079

D

Deleted member 219079

I think such system would make a nice addition to spells section.
 
Level 15
Joined
Mar 25, 2016
Messages
1,327
I would be very interested in taking a look. I have no desire to reinvent the wheel.
Will take some time though. It's not finished yet. I was able to make it work with all sizes of regions, but I still need to get it to work with multiple regions at the same time.
(I had to split the calculation, because warcraft automatically stops the trigger after too many actions it seems. So if the calculation could not be finished it will contunue in the next 0.01 seconds. So the calulation is not instant, which means that I need to store variables similar to making a spell MUI)
I think such system would make a nice addition to spells section.
I don't think this system matches the requirements for approval. To be honest splitting the calculation and running the calculation every 0.01 seconds until it's finished is a very ugly solution.
 

Deleted member 219079

D

Deleted member 219079

I didn't refer to your system in particular.
 
Status
Not open for further replies.
Top