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

8 hours ago, Buchi said:

Is there a shortcut for that? Chatgpt said no.

yes. its there already for many years

maybe you just net to config your autoCiv

examples:

hotkey.autociv.selection.nowoundedonly = "K"

hotkey.autociv.session.entity.by.health.wounded.by.class.select.(Cavalry|Infantry|Soldier|Siege|Dog|Elephant|Support) = "J"

this for e.g. is aready integreated here: https://github.com/sl5net/0ad-TTS-speaking-population/blob/main/0ad_tts_data/intuitive_config.json

 

 

Edited by seeh
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...