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

12 minutes ago, 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);

 

Yes is "o"

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...