Jump to content

Select wounded units only


Buchi
 Share

Recommended Posts

Is there a shortcut for that? Chatgpt said no.

Can anyone help me create a mod for that? Chatgpt gave me this code:

Can you give me some help how to test it or how to continue?

 

function selectWoundedUnits() {
    var selectedUnits = Engine.GetGUIObjectByName("unitselection").selected;
    var woundedUnits = [];

    for (var i = 0; i < selectedUnits.length; i++) {
        var unit = selectedUnits[i];
        var health = unit.GetHealth() / unit.GetMaxHealth();
        
        if (health < 0.6) {
            woundedUnits.push(unit);
        }
    }

    Engine.GetGUIObjectByName("unitselection").selected = woundedUnits;
}

Engine.RegisterGuiCallback("onSelectionChanged", selectWoundedUnits);

 

Link to comment
Share on other sites

  On 01/06/2023 at 10:00 PM, Buchi said:

Is there a shortcut for that? Chatgpt said no.

Can anyone help me create a mod for that? Chatgpt gave me this code:

Can you give me some help how to test it or how to continue?

 

function selectWoundedUnits() {
    var selectedUnits = Engine.GetGUIObjectByName("unitselection").selected;
    var woundedUnits = [];

    for (var i = 0; i < selectedUnits.length; i++) {
        var unit = selectedUnits[i];
        var health = unit.GetHealth() / unit.GetMaxHealth();
        
        if (health < 0.6) {
            woundedUnits.push(unit);
        }
    }

    Engine.GetGUIObjectByName("unitselection").selected = woundedUnits;
}

Engine.RegisterGuiCallback("onSelectionChanged", selectWoundedUnits);

 

Expand  

Yes is "o"

  • Like 1
Link to comment
Share on other sites

  On 01/06/2023 at 11:07 PM, Gurken Khan said:

With an area selection to actually get the wounded units.

Expand  

Drag box selection* also drag selection 

https://ux.stackexchange.com/questions/114092/whats-the-name-of-the-pattern-where-you-draw-a-rectangle-to-select-items

https://www.computerhope.com/jargon/d/dragsele.htm

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...