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

make certain unit types not be drag selected

Status
Not open for further replies.
Level 9
Joined
Apr 27, 2012
Messages
234
Hi,

I want certain units not to be selected when I drag select units. If one clicks on them, however, they're supposed to be selected as usual.



here's what I'm trying to do (you don't have to read this but maybe it helps to get the idea...)

I need this for a squad system. Basically every unit-type exists twice (one as group leader, the others as squad members) Graphically it will look as if all units of a squad are selected at once but actually only the squad leader is selected so only one icon appears in the interface.

Furthermore the squad members got the classification 'ward' so when you drag select units they will be ignored in favor of the squad leaders (this makes it possible to select greater numbers of squads via drag-select).


When you drag select units and 1 or more units do NOT have the 'ward' classification all units which ARE 'wards' will not be selected.

Consequently if I drag select only the squad members (which are all 'wards') but not the squad leader then these squad members are all selected at once.
This sucks because I'm trying to make a squad system here! Of course the squad system triggers will unselect them but there's a short delay before units are unselected by a trigger so for a short moment three or more unit icons appear in the selection.


[...]
So what I need is either what I described in the beginning or a way to make triggers instantly unselect units without that weird delay.
 
Level 7
Joined
Nov 15, 2009
Messages
225
Add the units to hashtable values.
Save the leaders unit id using a unit group as key.

Now when a unit is selected, check if the selected amount > 1 and leader is selected, then select leader.
Otherwise select triggering unit.

I made a very basic trigger, for testing.
But I didn't continued, because I noticed a little problem.
If you select several units at the same time, using the drag it will check the new selected units AND the old selected units.

However this can be avoided, when disabling the drag selection.

  • Select Units
    • Events
      • Unit - Footman 0002 <gen> Is selected
      • Unit - Footman 0001 <gen> Is selected
      • Unit - Footman 0003 <gen> Is selected
      • Unit - Rifleman 0004 <gen> Is selected
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Rifleman 0004 <gen> is selected by (Triggering player)) Equal to True
          • (Number of units in (Units currently selected by (Triggering player))) Greater than 1
        • Then - Actions
          • Selection - Clear selection for (Triggering player)
          • Selection - Select Rifleman 0004 <gen> for (Triggering player)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units currently selected by (Triggering player))) Greater than 1
            • Then - Actions
              • Selection - Clear selection for (Triggering player)
              • Selection - Select (Triggering unit) for (Triggering player)
            • Else - Actions
Maybe this helps you.
 

Attachments

  • Test.w3x
    16.6 KB · Views: 63
Level 9
Joined
Apr 27, 2012
Messages
234
thanks for the effort.
But note that all units of the squad are selected for a short moment before all of them except the leader are unselected by 'Clear Selection'.


I don't know why but the trigger action 'Clear Selection' is always delayed...


And that's exactly my problem. The units I don't want in the selection shouldn't be selected at all - not even a single second.


So I want these units to either be completley unselectable via drag-select or I'd like to know a way how to immediately clear the selection without delay
 
Level 7
Joined
Nov 15, 2009
Messages
225
Well the fastest solution would be the periodic event of 0.01 seconds.
But this is delayed either and a very big waste of performance.

It will always delay and I never saw any map or system without delay.

The only other possibility is the use of locust units, but you will loose the ability to click the members of course.
 
Level 7
Joined
Jan 22, 2013
Messages
293
Well I think I could try and make this for you. But woulding you need them all to follow the leader like a lap dog?
 
Level 9
Joined
Apr 27, 2012
Messages
234
Well I think I could try and make this for you. But woulding you need them all to follow the leader like a lap dog?

nah I got the whole 'follow the leader' triggers setup and functioning. All I need is a way to make the Squadmembers (all except the leader) not be selected when I drag select.
One way to achieve this is by adding the unit classification 'Ward' to them but this kills their command buttons (Attack etc.).

So if you know and alternative way to prevent units from being drag selected along all other units fire away! ;)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
Unit selection is asynchronous so requires network synchronization for any such events to fire. The result is a delay of at least 2*lag period from the time to player selects it until the event fires to deselect the unit. As lag can be upwards of 100ms for cross-continent play you are looking at near 0.25 seconds of selection minimum.
 
Status
Not open for further replies.
Top