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

Mooving units in formation

Status
Not open for further replies.
Level 7
Joined
Jun 23, 2009
Messages
297
I want to make some units to move in formation, or at least to spawn in formation... I know its possible cuase in Blood Tournament its like that...
I found this:

  • MoveUnits
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Footman
    • Actions
      • Unit - Order (Last created unit) to Move To ((Center of (Playable map area)) offset by (0.00, 0.00))
But i cant understand whats an offset... and how does it werk..
Thnks for the help
 
Level 12
Joined
Aug 22, 2008
Messages
911
Moving in formation and spawning in formation are extremely different.
Moving in formation is automatically engaged if you enable it (by default it's enabled so you don't have to worry about that), and through triggers it can be applied by ordering units as a group:
  • Unit - Create 5 Warriors at point facing (Building facing) degrees
  • Set group = (Last Created Unit Group)
  • Unit - Create 3 Archers at point facing (Building facing) degrees
  • Set group2 = (Last Created Unit Group)
  • Unit Group - Add all units of group2 to group
  • Custom Script: call DestroyGroup(udg_group2)
  • Unit Group - Order group to (Move to) point2
  • Custom Script: call DestroyGroup(udg_group)
  • Custom Script: call RemoveLocation(udg_point)
  • Custom Script: call RemoveLocation(udg_point)
NOTE: Units are NOT spawned in formation.
Creating them in formation would require the specific placement of each unit, which would be really annoying followed by many possible leaks (yes, your friend's thing leaks.). I wouldn't recommend even trying to spawn them in formation.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This spawns units in a square formation:

  • Spawn
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set Temp_Loc_1 = (Center of Region 000 <gen>)
      • Set Temp_Integer_1 = 11
      • Set Temp_Real_1 = 128.00
      • Set Temp_Integer_2 = (Integer((Square root((Real(Temp_Integer_1))))))
      • For each (Integer A) from 0 to Temp_Integer_2, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to Temp_Integer_2, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Temp_Group) Less than Temp_Integer_1
                • Then - Actions
                  • Set Temp_Loc_2 = (Temp_Loc_1 offset by ((Temp_Real_1 x (Real((Integer A)))), (Temp_Real_1 x (Real((Integer B))))))
                  • Unit - Create 1 Footman for Player 1 (Red) at Temp_Loc_2 facing 0.00 degrees
                  • Unit Group - Add (Last created unit) to Temp_Group
                  • Custom script: call RemoveLocation(udg_Temp_Loc_2)
                • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
Temp_Loc_1 = Position of the first unit to spawn. He will be at the lower left corner of the formation, and the position of other units are calculated from his position.
Set Temp_Integer_1 = Number of units to spawn.
Set Temp_Real_1 = Offset between units.

Temp_Real_2 calculates the "length" of sides in the square. 4 units goes in a 2x2 square, 11 units goes into a 4x4 square, since 3x3 is less than 11, but 4x4 is more.
 
Level 11
Joined
May 31, 2008
Messages
698
I dont see how Makers trigger works it seems like it wouldnt but im not sure.

im pretty sure this works and will make a square formation. If the number of units isnt a square then it will make the closest thing to a square. I tested it out so i know that it works. And it does not leak.

  • Formation
    • Events
      • Time - Elapsed game time is 7.00 seconds
    • Conditions
    • Actions
      • Set UnitNumber = 10
      • Set x = (Center X of (Playable map area))
      • Set y = (Center Y of (Playable map area))
      • Set TempInt = (Integer((Square root((Real(UnitNumber))))))
        • Do Multiple ActionsFor each (Integer A) from 1 to UnitNumber, do (Actions)
          • Loop - Actions
            • Set TempLoc[0] = (Point(x, y))
            • Unit - Create 1 Footman for Player 1 (Red) at TempLoc[0] facing Default building facing (270.0) degrees
            • Custom script: call RemoveLocation(udg_TempLoc[0])
            • Set x = (x + 300.00)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Greater than or equal to (>=) TempInt
                • Then - Actions
                  • Set TempInt = (TempInt + (Integer((Square root((Real(UnitNumber)))))))
                  • Set x = (Center X of (Playable map area))
                  • Set y = (y + 300.00)
                • Else - Actions
 
Level 11
Joined
May 31, 2008
Messages
698
Set Temp_Integer_2 = (Integer((Square root((Real(Temp_Integer_1))))))
For each (Integer A) from 0 to Temp_Integer_2, do (Actions)

Well what is that supposed to do?
Because you set tempint1 = 11 and the square root of 11 would come out to be 3, so your trigger is making 16 units every time it runs because you have a loop inside another loop. from 0 to 3 would be 4 and you have a loop that runs 4 times inside a loop that runs 4 times, making it run a total of 16 times. Not too sure how thats supposed to work or how ur sposed to specify the number of units being created. But i didnt copy it and test it so im not sure if im 100% correct but thats what it looks like at least. Im not trying to say ur wrong
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Temp_Integer is the amount of units to spawn.

This limits the amount of units to spawn:
(Number of units in Temp_Group) Less than Temp_Integer_1

11 units does not go in a 3x3 "box". It needs to be 4x4.

23 units spawn like this:

formation.jpg


So...
 
Level 11
Joined
May 31, 2008
Messages
698
Ooooohhhh ok i see. I didnt see the if then else function lol. Also in your trigger i dont see that you destroyed the tempgroup so i think it leaks. But yeah my trigger does exactly the same thing as yours, its just a different way i guess :p
 
Status
Not open for further replies.
Top