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

Unit Group Move Problem

Status
Not open for further replies.
Level 6
Joined
Dec 8, 2009
Messages
179
Hi Hivemembers^^

Tada! here is my lastest Problem for you^^

I made a Troop movement System for a Project of mine.

The System does following:
-saves a Commander for each Troop
-if selecting a unit of a Troop automaticly deselcts it and selets the fitting Commander
-Issues common orders (like move, stop, holdposition, attack etc.) when Issued to commander to Troop too.


Now The Problem^^
When you order Move Orders or similar things you get an unsortet and chaotic crowd of Units. but I want:

-all The commanders to be ordered moving to Points that are far enough of each other Commander in the Selected/ordered Units so that there is no Chaos.
-Also I want the Units to be kind of sorted:
-I thought about just giving the Commanders of different Unittypes different Numbers (maybe customizable in game) to sort them (like meele at front archers in back and ballista behind archers)


Main Problem is:
-I don't know how to structurize the Trigger that makes each selected Unit go to it's specific Place

Here's the System so that you all got a better Idea of what I mean
 

Attachments

  • Grantuu's Siege Triggers.w3x
    23.3 KB · Views: 48
First of all, you spammed the system with unnecessary triggers. You could check the order and do it within only one trigger:
  • Trigger
  • Events
    • Unit - A unit is issued an order targeting an object
    • Unit - A unit is issued an order targeting a point
    • Unit - A unit is issued an order with no target
  • Conditions
    • (Key(commander) of (Key(Triggering unit)) in Table) Equal to True
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable Map Area) matching X) and do (Actions)
      • Loop - Actions
        • Set Point = (Target point of issued order)
        • Custom script: if udg_Point == null then
        • Custom script: call IssueTargetOrder (GetEnumUnit(), I2S(GetIssuedOrderId()), GetOrderTarget())
        • Custom script: else
        • Custom script: call IssuePointOrderByIdLoc (GetEnumUnit(), I2S(GetIssuedOrderId()), udg_Point)
        • Custom script: endif
        • Custom script: call RemoveLocation (udg_Point)
 
Level 14
Joined
Aug 31, 2009
Messages
775
You could use offsets based on the unit type of the unit in each given troop group.

For example, you could give ranged units a value of -50, and make them always stand move that distance away from the ordered point instead of walking directly at the ordered point.

The problem comes in where you have multiple archers. Using your hashtables, you could assign each one a different number (1, 2, 3 etc. let's call this X, total number of archers = Y) and have them spread at equal distances based on that number.

So for example, each Archer goes to (Point) offset by (50*((Y/2)-X), -50)
(This makes half of them spread to the right, half will spread to the left).
The other problem however is that will always make them line up in the same direction.
Applying angles to this requires using a Polar Offset... which means adding trigonometry to the equation.

It's complicated, but there's an excellent map project on this website - that uses a very excellently implemented system just like this - http://www.hiveworkshop.com/forums/...o-beta-146028/?prev=r=20&extension=w3n&page=2.
Perhaps you could contact the creator of this and see if he'll be able to assist you?
 
Status
Not open for further replies.
Top