Ticket #4253: patrol_prepare_v1.patch

File patrol_prepare_v1.patch, 2.8 KB (added by elexis, 8 years ago)

Removes the duplicate "Unit" entry and makes it accessible from the GUI. Not sure if it's 100% safe (i.e. if the current order always exsists and if its always the patrol one), but it ought to.

  • binaries/data/mods/public/gui/session/input.js

    function getActionInfo(action, target)  
    207207                cursor = "action-attack-move";
    208208            }
    209209            else if (Engine.HotkeyIsPressed("session.patrol"))
    210210            {
    211211                data.command = "patrol";
    212                 data.targetClasses = { "attack": ["Unit"] };
     212                data.targetClasses = { "attack": g_PatrolTargets };
    213213                cursor = "action-patrol";
    214214            }
    215215            return { "possible": true, "data": data, "cursor": cursor };
    216216        }
    217217
  • binaries/data/mods/public/gui/session/unit_actions.js

     
    11/**
     2 * Which enemy entity types will be attacked on sight when patroling.
     3 */
     4var g_PatrolTargets = ["Unit", "Structure"];
     5
     6/**
    27 * List of different actions units can execute,
    38 * this is mostly used to determine which actions can be executed
    49 *
    510 * "execute" is meant to send the command to the engine
    611 *
    var unitActions =  
    216221                "type": "patrol",
    217222                "entities": selection,
    218223                "x": target.x,
    219224                "z": target.z,
    220225                "target": action.target,
    221                 "targetClasses": { "attack": ["Unit"] }, // patrol should only attack units
     226                "targetClasses": { "attack": g_PatrolTargets },
    222227                "queued": queued,
    223228                "allowCapture": false
    224229            });
    225230            Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] });
    226231            return true;
  • binaries/data/mods/public/simulation/components/UnitAI.js

    UnitAI.prototype.UnitFsmSpec = {  
    11131113                    return;
    11141114                }
    11151115                if (!this.patrolStartPosOrder)
    11161116                {
    11171117                    this.patrolStartPosOrder = cmpPosition.GetPosition();
    1118                     this.patrolStartPosOrder.targetClasses = { "attack": ["Unit"] };
     1118                    this.patrolStartPosOrder.targetClasses = this.order.data.targetClasses;
    11191119                }
    11201120
    11211121                this.StartTimer(0, 1000);
    11221122            },
    11231123
    UnitAI.prototype.UnitFsmSpec = {  
    16431643                    return;
    16441644                }
    16451645                if (!this.patrolStartPosOrder)
    16461646                {
    16471647                    this.patrolStartPosOrder = cmpPosition.GetPosition();
    1648                     this.patrolStartPosOrder.targetClasses = { "attack": ["Unit"] };
     1648                    this.patrolStartPosOrder.targetClasses = this.order.data.targetClasses;
    16491649                }
    16501650
    16511651                this.StartTimer(0, 1000);
    16521652                this.SelectAnimation("move");
    16531653            },