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

Simple Squad Formation System v1.0

- This system allows you to create a squad to any target unit (as long as the unit is non-Hero and the unit is yours).
- Can improve your micro-ing in RTS-based game.
- The units in the squad will do the actions as you do (if you Patrol, they Patrol too).
- Useful for massive war-type map.


External Instructions
- Open World Editor - File - Preferences... - General Tab - Tick the Automatically create unknown variables while pasting trigger data
- Copy the Simple Squad Formation System folder.
- Further instructions inside the SF Setup Trigger.

Internal Instructions
- None


  • SF Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_SF_Hashtable = InitHashtable()
      • -------- ---------- --------
      • -------- Make sure these variables follow these settings --------
      • -------- Set SF_FormationAbility = Squad Formation --------
      • -------- ---------- --------
      • Set SF_FormationAbility = Squad Formation
      • -------- ---------- --------
      • -------- SF_Max/MinPerimeterAOE sets how big does the perimeter covers the area, distance from Leader (center point) --------
      • -------- It is suggested that SF_MinPerimeterAOE should always be less than SF_MaxPerimeterAOE --------
      • -------- ---------- --------
      • Set SF_MinPerimeterAOE = 300
      • Set SF_MaxPerimeterAOE = 400
  • SF Formation
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to SF_FormationAbility
    • Actions
      • Custom script: local integer i
      • Custom script: local integer i2
      • Set SF_Leader = (Triggering unit)
      • Set TempUnit = (Target unit of ability being cast)
      • Custom script: set udg_SF_Key = GetHandleId(udg_SF_Leader)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 0 of SF_Key from SF_Hashtable) Equal to False
        • Then - Actions
          • Hashtable - Save True as 0 of SF_Key in SF_Hashtable
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit is in SF_Group) Equal to True
        • Then - Actions
          • Custom script: set i = GetHandleId(udg_TempUnit)
          • Custom script: set udg_TempUnit2 = LoadUnitHandle(udg_SF_Hashtable, i, 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SF_Leader Equal to TempUnit2
            • Then - Actions
            • Else - Actions
              • Custom script: set i2 = GetHandleId(udg_TempUnit2)
              • Custom script: call SaveInteger(udg_SF_Hashtable, i2, 2, LoadInteger(udg_SF_Hashtable, i2, 2) - 1)
              • Custom script: if LoadInteger(udg_SF_Hashtable, i2, 2) == 0 then
              • Custom script: call FlushChildHashtable(udg_SF_Hashtable, i2)
              • Custom script: endif
              • Custom script: set i2 = GetHandleId(udg_SF_Leader)
              • Custom script: call SaveInteger(udg_SF_Hashtable, i2, 2, LoadInteger(udg_SF_Hashtable, i2, 2) + 1)
        • Else - Actions
          • Hashtable - Save ((Load 2 of SF_Key from SF_Hashtable) + 1) as 2 of SF_Key in SF_Hashtable
      • Unit Group - Add TempUnit to SF_Group
      • Custom script: set udg_SF_Key = GetHandleId(udg_TempUnit)
      • Hashtable - Save Handle OfSF_Leader as 1 of SF_Key in SF_Hashtable
      • Trigger - Turn on SF Move Point <gen>
      • Trigger - Turn on SF Move Object <gen>
      • Trigger - Turn on SF Stop <gen>
      • Trigger - Turn on SF Reduce Counter <gen>
  • SF Move Point
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Load 0 of (Key (Triggering unit)) from SF_Hashtable) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(attack))
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(move))
          • (Issued order) Equal to (Order(patrol))
    • Actions
      • Custom script: set udg_TempReal = GetOrderPointX()
      • Custom script: set udg_TempReal2 = GetOrderPointY()
      • Set TempOrder = (Issued order)
      • Unit Group - Pick every unit in SF_Group and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_SF_Key = GetHandleId(udg_TempUnit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 1 of SF_Key in SF_Hashtable) Equal to (Triggering unit)
            • Then - Actions
              • Custom script: set udg_TempReal3 = GetRandomReal(0,6.2831853)
              • Custom script: set udg_TempInteger = GetRandomInt(udg_SF_MinPerimeterAOE, udg_SF_MaxPerimeterAOE)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempOrder Equal to (Order(attack))
                • Then - Actions
                  • Custom script: call IssuePointOrder(udg_TempUnit, "attack", udg_TempReal + udg_TempInteger * Cos(udg_TempReal3), udg_TempReal2 + udg_TempInteger * Sin(udg_TempReal3))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • TempOrder Equal to (Order(smart))
                          • TempOrder Equal to (Order(move))
                    • Then - Actions
                      • Custom script: call IssuePointOrder(udg_TempUnit, "smart", udg_TempReal + udg_TempInteger * Cos(udg_TempReal3), udg_TempReal2 + udg_TempInteger * Sin(udg_TempReal3))
                    • Else - Actions
                      • Custom script: call IssuePointOrder(udg_TempUnit, "patrol", udg_TempReal + udg_TempInteger * Cos(udg_TempReal3), udg_TempReal2 + udg_TempInteger * Sin(udg_TempReal3))
            • Else - Actions
  • SF Move Object
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Load 0 of (Key (Triggering unit)) from SF_Hashtable) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(attack))
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(move))
          • (Issued order) Equal to (Order(patrol))
    • Actions
      • Set TempUnit2 = (Target unit of issued order)
      • Custom script: set udg_TempReal = GetUnitX(udg_TempUnit2)
      • Custom script: set udg_TempReal2 = GetUnitY(udg_TempUnit2)
      • Set TempOrder = (Issued order)
      • Unit Group - Pick every unit in SF_Group and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_SF_Key = GetHandleId(udg_TempUnit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 1 of SF_Key in SF_Hashtable) Equal to (Triggering unit)
            • Then - Actions
              • Custom script: set udg_TempReal3 = GetRandomReal(0,6.2831853)
              • Custom script: set udg_TempInteger = GetRandomInt(udg_SF_MinPerimeterAOE, udg_SF_MaxPerimeterAOE)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempOrder Equal to (Order(attack))
                • Then - Actions
                  • Custom script: call IssueTargetOrder(udg_TempUnit, "attack", udg_TempUnit2)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • TempOrder Equal to (Order(smart))
                          • TempOrder Equal to (Order(move))
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (TempUnit2 belongs to an enemy of (Triggering player)) Equal to True
                        • Then - Actions
                          • Custom script: call IssueTargetOrder(udg_TempUnit, "attack", udg_TempUnit2)
                          • Custom script: call IssueTargetOrder(GetTriggerUnit(), "attack", udg_TempUnit2)
                        • Else - Actions
                          • Custom script: call IssuePointOrder(udg_TempUnit, "smart", udg_TempReal + udg_TempInteger * Cos(udg_TempReal3), udg_TempReal2 + udg_TempInteger * Sin(udg_TempReal3))
                    • Else - Actions
                      • Custom script: call IssuePointOrder(udg_TempUnit, "patrol", udg_TempReal + udg_TempInteger * Cos(udg_TempReal3), udg_TempReal2 + udg_TempInteger * Sin(udg_TempReal3))
                      • Custom script: call IssuePointOrder(GetTriggerUnit(), "patrol", udg_TempReal, udg_TempReal2)
            • Else - Actions
  • SF Stop
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Load 0 of (Key (Triggering unit)) from SF_Hashtable) Equal to True
      • (Issued order) Equal to (Order(stop))
    • Actions
      • Unit Group - Pick every unit in SF_Group and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Custom script: set udg_SF_Key = GetHandleId(udg_TempUnit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 1 of SF_Key in SF_Hashtable) Equal to (Triggering unit)
            • Then - Actions
              • Custom script: call IssueImmediateOrder(udg_TempUnit, "stop")
            • Else - Actions
  • SF Reduce Counter
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SF_Group) Equal to True
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local integer i = GetHandleId(u)
      • Custom script: local integer i2 = GetHandleId(LoadUnitHandle(udg_SF_Hashtable, i, 1))
      • Custom script: call GroupRemoveUnit(udg_SF_Group, u)
      • Custom script: call FlushChildHashtable(udg_SF_Hashtable, i)
      • Custom script: call SaveInteger(udg_SF_Hashtable, i2, 2, LoadInteger(udg_SF_Hashtable, i2, 2) - 1)
      • Custom script: if LoadInteger(udg_SF_Hashtable, i2, 2) == 0 then
      • Custom script: call FlushChildHashtable(udg_SF_Hashtable, i2)
      • Custom script: endif
      • Custom script: if CountUnitsInGroup(udg_SF_Group) == 0 then
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off SF Move Object <gen>
      • Trigger - Turn off SF Move Point <gen>
      • Trigger - Turn off SF Stop <gen>
      • Custom script: endif
      • Custom script: set u = null
Dr. Boom & HappyTauren - Giving me suggestions on changing Locations to Coordinates random method.


v1.0
- Initial release



Keywords:
simple, squad, formation, system, battalion, RTS, RPG, defskull, hashtable, AI, patrol, smart, attack, move, stop.
Contents

Just another Warcraft III map (Map)

Reviews
13:07, 20th Sep 2012 PurgeandFire111: Okay, you've given your reason and it makes sense. This works and the code is fine, so approved. :) Could have some tweaks here and there to make the movement seem more organized but oh well. Good job overall.

Moderator

M

Moderator

13:07, 20th Sep 2012
PurgeandFire111:
Okay, you've given your reason and it makes sense. This works and the code is fine, so approved. :) Could have some tweaks here and there to make the movement seem more organized but oh well. Good job overall.
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
defskull (a.k.a. the system-boy). Dude, why all of your system are like "Simple xyzxyzxyz system"? They are all not so simple.
The system it's self is great, but i will give a suggestion :
It's kinda crappy when the units of a squad move in random locations like so. You should order them to move to the location that their leader is facing, so that they all imitate the leader's moves. This is probably not so good but with those random moves of the squad, some of it's members pretend to go in front of their leader so that he can't move (when i have like 30 units under one squad), this is probably the crappy thing.

Otherwise, it's great. Nice job!
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Dude, why all of your system are like "Simple xyzxyzxyz system"? They are all not so simple.
Because that's my trademark, Simple XXX System, I live up to that trademark ;p (although I've seen before people using Simple XXX System as base name, but I think i should stick to this trademark) :)

It's kinda crappy when the units of a squad move in random locations like so. You should order them to move to the location that their leader is facing, so that they all imitate the leader's moves
I was thinking this too, move according to Leader's facing angle and there would be many changes should be done (depends on user's feedbacks).
This one is a must because currently, the squad are moving at "total random"

I want to keep the "random" but in an arranged order, I suppose I'll find a method for it, thanks :)
 
Here is my feedback:
The code seems fine. However, one thing you may want to support is when the hero issues a non-move/attack/smart/patrol order. For example, what if the hero casts flame strike on a point? The units should follow, right? But idk, it really depends on what you intend for it to do, but I assume that in a squad system it would support that.

It really depends on what you are aiming for. If you don't want to support that, that is fine. But if you did and just forgot, then it is something to consider.

Otherwise it should be approvable. The squad handling could be a bit better, but I suppose then it wouldn't be simple. :p
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
The code seems fine. However, one thing you may want to support is when the hero issues a non-move/attack/smart/patrol order. For example, what if the hero casts flame strike on a point? The units should follow, right? But idk, it really depends on what you intend for it to do, but I assume that in a squad system it would support that.
Well you could re-order those basic orders for your squad to react.
The thing I don't want to work with abilities is that ability can be very unique to one another - imagine custom abilities, the possibilities are endless.
Well my system truly aims for basic commands only.
 
Top