• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Super Noob Question? How to pick all units by a player?

Status
Not open for further replies.
Level 1
Joined
Apr 12, 2009
Messages
4
Hi, It's been driving me crazy that I can't find a GUI based function that picked all units owned by a player. I was able to do this in Warcraft 3, but I've started messing around with the SC2 editor and can't find a function for it.

You can see a screenshot here of me trying to do it.



Uploaded with ImageShack.us

Your help is much appreciated.
 
Level 1
Joined
Apr 12, 2009
Messages
4
Hi, thank you very much for the replay, but I still have the problem. In the screenshot provided, even If I changed the parameter from Any to 1, it still works on only one unit that is randomly selected.

Is there a way to change (Any Units) to (All Units)?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
There is no Any Units on screen, The "Any" is for the type (so all unit types are choosen). As it is it should be choosing all units matching that filter and running the actions on them.

The problem is the actions are probably total nonsense. The Wait is most likly messing up the enumeration on all units.

How to fix? Simple

1. Create group of units to affect and store as local.
2. Change movement speed of all units in group.
3. Wait
4. Change movememnt speed of all units in group.

Thus you are after enumerating through the group before the wait and after the wait. Storing the group as a local means multiple instances can run with no clash of variable space.
 
This is an example of how I do it:

  • Kill Everything
    • Events
      • UI - Player Any Player presses K key Down with shift Allow, control Allow, alt Allow
    • Local Variables
      • g = (Any units in (Playable map area) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) <Unit Group>
      • u = No Unit <Unit>
      • ut = No Game Link <Game Link - Unit>
      • cv = (Integer((Custom value CVS of u))) <Integer>
      • p = 0 <Integer>
    • Conditions
    • Actions
      • General - Custom Script: gf_DebugMsg(StringToText("3..."));...
JASS:
gf_DebugMsg(StringToText("3..."));
Wait(1.0, c_timeGame);
gf_DebugMsg(StringToText("2..."));
Wait(1.0, c_timeGame);
gf_DebugMsg(StringToText("1..."));
Wait(1.0, c_timeGame);
gf_DebugMsg(StringToText("MAP CLEARED!"));
UnitGroupLoopBegin(lv_g);
while (!UnitGroupLoopDone()) {
    lv_u = UnitGroupLoopCurrent();
    lv_p = UnitGetOwner(lv_u);
    lv_ut= UnitGetType(lv_u);
    
    if (lv_ut == gv_sheep) {
        gv_sheepCount[lv_p] += -1;
        gv_livestockTotal[lv_p] += -1;
        UnitGroupRemove(gv_livestockGroup[lv_p], lv_u);
        lv_cv = FixedToInt(UnitGetCustomValue(lv_u, gv_CVS));
        if (gv_gender[lv_cv]) {
            gv_sheepMale[lv_p] += -1;
        } else {
            gv_sheepFemale[lv_p] += -1;
        }
        gv_indexerArray[lv_cv] = false;
    } else if (lv_ut == gv_tree) {
        gv_treesCount += -1;
    } else if (lv_ut == gv_farmerMale) {
        gv_farmersMaleCount[lv_p] += -1;
    } else if (lv_ut == gv_farmerFemale) {
        gv_farmersFemaleCount[lv_p] += -1;
    }
    UnitRemove(lv_u);
    UnitGroupLoopStep();
}
UnitGroupLoopEnd();
 
Status
Not open for further replies.
Top