[REL] Advanced Unit Selection

Discussion in 'Mod Discussions' started by elmauru, March 14, 2014.

  1. elmauru

    elmauru Member

    Messages:
    46
    Likes Received:
    27
    What does it do?
    mAdvancedSelect provides a set of hotkeys for working with unit selections in the heat of battle.

    Compatibility(last checked):
    Gamma v 63180

    Features:
    1. Orbital Unit Selection!
    2. Given a Selection of Units allows to sub-select Land/Air/Naval/Orbital, if no units are selected it will simply select all Land/Air/Naval/Orbital units on screen, so no hotkeys are wasted.
    3. If a Selection is filtered by mAdvancedSelect, it preserves the original selection so you can switch around in your active selection with a simple key-press.
    4. Also works for fabbers and factories!

    Example:
    You have panic-dragged a big ball of units and attack-move. You decide you want all the air units to perform a different maneuver or save them from flying in ahead to get butchered. You press the hotkey for "Select Air" and all the air units in your selection get selected, so you order them to take a longer route.
    Now you want to get back to moving the other units in your deathball, so you hit the "Select Excluded" key and your original deathball is selected again - you hit "Select Land" and now you can move your Land Units.

    I.e.: no more frantic dragging or clicking to filter out special units!
    Combine this mod with hotbuild2 and its unit selection keys and you can easily micro groups of units without having to painfully organize Selection Groups!

    Installation:
    Get it off the PA Mod Manager.
    You will also need the mEventHandler Mod (Automatically added if by PAMM, Links below).

    You can set up the hotkeys in your keyboard settings section.
    You should replace Select All X Units on Screen with the respective keybinds under mAdvancedSelect.

    I suggest the following setup:
    CTRL+SHIFT+A : All units on screen
    CTRL+A: Select Air
    CTRL+S: Select Naval
    CTRL+D: Select Land
    CTRL+Q: Recall Select

    Github URL:
    https://github.com/Mauru/mAdvancedSelect

    Note:
    This mode requires mEventHandler to work:
    https://forums.uberent.com/threads/rel-wip-reventhandler-a-pa-engine-process-event-framework.57858/
    Last edited: March 21, 2014
  2. Quitch

    Quitch Post Master General

    Messages:
    5,885
    Likes Received:
    6,045
    I totally missed this, but sounds like a life saver.
  3. stuart98

    stuart98 Post Master General

    Messages:
    6,009
    Likes Received:
    3,888
    And so rises the APM ceiling...
  4. zweistein000

    zweistein000 Post Master General

    Messages:
    1,362
    Likes Received:
    727
    Does this always select ahh the units of sleted type on your screen or can i click shift, drag a box and then have only ground/air/orbital/naval units selected?
  5. Quitch

    Quitch Post Master General

    Messages:
    5,885
    Likes Received:
    6,045
    I believe these keys are for narrowing an existing selection. Say you select some planes and tanks, you then press CTRL-D and it changes the selection to the tanks only.
    zweistein000 likes this.
  6. zweistein000

    zweistein000 Post Master General

    Messages:
    1,362
    Likes Received:
    727
    awesome.. worth a try.
  7. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    still works?
    possibility of fusion with Hotbuild?
  8. alienmind

    alienmind New Member

    Messages:
    20
    Likes Received:
    23
    elmauru: Great stuff. I needed the user rectangle selection be remembered and being based off that when pressing "air", "land", etc. keys, without using "recall key", until another rectangle selection takes place. So I've modded your mod:

    Add this to C:\Users\<yourname>\AppData\Local\Uber Entertainment\Planetary Annihilation\mods\mAdvancedSelect\ui\mods\mAdvancedSelect\mAdvancedSelect_live.js:

    Code:
    //reference: ui/main/game/live_game/live_game.js
    //HOOK into model.playSelectionSound, so we can react to the call to holodeck.endDragSelect
    var oldPlaySelectionSound_tew3tg4r45y983 = model.playSelectionSound;
    model.playSelectionSound = function() {
      oldPlaySelectionSound_tew3tg4r45y983.apply(this, arguments);
      //user made rectancle select, store it in group 99
      api.select.captureGroup(99);
    }   
    

    Add/change this in C:\Users\<yourname>\AppData\Local\Uber Entertainment\Planetary Annihilation\mods\mAdvancedSelect\ui\mods\mAdvancedSelect\mAdvancedSelect.js:

    Code:
      // given a selectionList-array, return the array without _type
       this.filter_apply_exclude2= function(excludePath, typeArr) {
         var typeArrWithoutExcludePath= [];
         for(i in typeArr) {
           if(typeArr.indexOf('units/'+excludePath+'/') === -1) {
             typeArrWithoutExcludePath.push(typeArr);
           }
         }
         return(typeArrWithoutExcludePath);
       }
    
       // filter the active selection
       this.filter_select=function(_type){
         //restore previous rectangle select
         api.select.recallGroup(99);
         setTimeout(function() {
         //model = LiveGameViewModel
         var selectionViewModel= model.selectionModel();
         //types = ["/pa/units/air/air_scout/air_scout.json", "/pa/units/air/bomber/bomber.json", "/pa/units/air/fighter/fighter.json"]
         var types= selectionViewModel.types();
         //unselect all units not of wanted _type
         model.holodeck.view.selectByTypes("remove", COBJ.filter_apply_exclude2(_type, types));
         }, 100);
       };
    

    Are there any more elegant ways how to hook model.playSelectionSound ?
    Can I subscribe some kind of listener to the recallGroup(99) call, so I don't have to use setTimeout ?
    elmauru likes this.
  9. elmauru

    elmauru Member

    Messages:
    46
    Likes Received:
    27
    Take a look at the eventHandler class and how this mod handles orbital selection filters - that should point you into the righ direction.
    I will eventually add more detailed selection types or the ability to customize the filters but hotbuild does this allready in a way and i didn't see much use for it yet.
  10. tohron

    tohron Active Member

    Messages:
    272
    Likes Received:
    168
    One thing I'm curious about - can you mod a way to alter what gets selected in the first place when you drag a selection box or use left-click? For example, say you wanted to select three bot factories in the middle of a group of units - could you alter drag-select to ignore the units and select the buildings? (double clicking a bot factory wouldn't work, since that would select every bot factory nearby)
  11. elmauru

    elmauru Member

    Messages:
    46
    Likes Received:
    27
    hotbuild 2 pretty much lets you do that atm. I suggest you take a look at it
  12. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    does it add anything compared to 66567?

    I get the feeling the devs added most of these actions.
  13. Dromed

    Dromed New Member

    Messages:
    19
    Likes Received:
    15
    I'm thinking this might be bugged in the current 68331 build. That or the Process-Event-Handler Framework

    I get an odd bug when I press enter or shift-enter to chat - the chat box stays open and the camera locks and during this you can't control anything. The only option is to ALT+F4. The mod wasn't working for me anyway so I'm thinking this is generally our of date, though I like the idea for quick tactical reactions during a fight.

    Disabling the mod caused the bug to not occur any longer.
  14. elmauru

    elmauru Member

    Messages:
    46
    Likes Received:
    27
    unfortunately i don't have the time to look at this right now, but it sounds like uber did some changes to event handling
  15. ViolentMind

    ViolentMind Active Member

    Messages:
    394
    Likes Received:
    186
    Hope you get the time to look into getting this to work again. This was really helpful in my opinion. They should definitely incorporate various selection features like this into the game.
    zweistein000 likes this.
  16. mishtakashi

    mishtakashi Active Member

    Messages:
    369
    Likes Received:
    217
    I've been playing a lot the last few days and I really really want this mod back :) The amount of time I spend manually filtering my selections is astonishing. I offer virtual cookies!
  17. Clopse

    Clopse Post Master General

    Messages:
    2,535
    Likes Received:
    2,865
    I will give real cookies.
  18. mishtakashi

    mishtakashi Active Member

    Messages:
    369
    Likes Received:
    217

Share This Page