• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Moving to Random Region trigger

Status
Not open for further replies.
Level 5
Joined
Jun 13, 2012
Messages
113
So the trigger below is for a computer ai.
Basically I made variable player3 that acts as a switch, in order to detect if the computer enter that region. Basically when the computer enters the region it plus 1 to the variable and will retrigger this variable to move the hero again to another region, until it = 4.

The entire trigger works as intended but with, one glaring issue that i cant seem to find a solution to. When the computer enters lets say Barrack region it gets the issue order, but once it gets the order to move to barrack region, the computer just stands on the same region, because its already there.

So is there some sort of condition that will allow the cpu to issue its move order and ignore the region its already in. It can go back to that region later but it shouldnt be able to go back to it if its already in the region.


  • Move to new region Player 3
    • Events
      • Game - Player3 becomes Less than or equal to 4.00
    • Conditions
      • (Player 3 (Teal) controller) Equal to Computer
      • (Player 3 (Teal) Food used) Less than or equal to (Player 3 (Teal) Food cap)
      • (Player 3 (Teal) Current gold) Greater than or equal to 150
    • Actions
      • Game - Display to (All players) the text: (String((Player 3 (Teal) Current gold)))
      • Game - Display to (All players) the text: (String((Player 3 (Teal) Food used)))
      • Game - Display to (All players) the text: (String(Player3))
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 3 (Teal)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet Temp_Point_Copy = RandomPoint[(Random integer number between 8 and RegionNumberForAi)]
              • Unit - Order (Picked unit) to Move To Temp_Point_Copy
              • Custom script: call RemoveLocation (udg_Temp_Point_Copy)
            • Else - Actions
 
Level 13
Joined
Feb 5, 2018
Messages
545
If your variable is region variable just add a check after
Unit is in region Temp_Point_Copy equal to false
-Add actions
else
-Add actions

EDIT:

If your variable is point variable you can do a range check
Unit is within 100 AoE of Temp_Point_Copy
 
Level 5
Joined
Jun 13, 2012
Messages
113
If your variable is region variable just add a check after
Unit is in region Temp_Point_Copy equal to false
-Add actions
else
-Add actions

EDIT:

If your variable is point variable you can do a range check
Unit is within 100 AoE of Temp_Point_Copy


Units in region trigger doesn't work with point variables as i have to select a region that is already created in the map.

Also it wont work, due to the random trigger still having that region as an option, even if i had those conditions the hero will sit there at times still do to the random trigger bring back up the same region.

I dont know if im making sense but my point is that its not working
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,239
If your variable is region variable just add a check after
Unit is in region Temp_Point_Copy equal to false
-Add actions
else
-Add actions
This is not reliable because the "unit entering region" event from GUI generates a region which is only an approximation of the rect used to create it. As such there could exist some area of map which triggers the event but is not inside the rect.

o is there some sort of condition that will allow the cpu to issue its move order and ignore the region its already in. It can go back to that region later but it shouldnt be able to go back to it if its already in the region.
There are multiple issues here.

First you are removing a constant location. This means that the same location cannot be visited twice because it no longer exists after the trigger orders a unit to it. Setting a location variable to the value of another location variable sets it to the reference of the location and does not make a copy of the location. As such the RemoveLocation call is not required as the locations in RandomPoint will be reused (not leak).

As for your main problem the solution is to keep track of the last point the unit was ordered to using a variable. Then when it arrives you can build a new array list (another array) of all the points except for the one the unit was last sent to. Comparing the location objects will work for this filter since they are constant. Then you select a random index from this new array list as the next point and since the array list cannot have the last ordered point in it, it cannot be selected as an option.
 
Status
Not open for further replies.
Top