Ticket #1720: patrol_V3.10.patch
File patrol_V3.10.patch, 9.1 KB (added by , 8 years ago) |
---|
-
binaries/data/config/default.cfg
286 286 garrison = Ctrl ; Modifier to garrison when clicking on building 287 287 autorallypoint = Ctrl ; Modifier to set the rally point on the building itself 288 288 guard = "G" ; Modifier to escort/guard when clicking on unit/building 289 patrol = "P" ; Modifier to patrol a unit 289 290 repair = "J" ; Modifier to repair when clicking on building/mechanical unit 290 291 queue = Shift ; Modifier to queue unit orders instead of replacing 291 292 batchtrain = Shift ; Modifier to train units in batches -
binaries/data/mods/public/gui/manual/intro.txt
84 84 [font="sans-bold-14"]Modify mouse action 85 85 [font="sans-14"]Ctrl + Right Click on building: Garrison 86 86 J + Right Click on building: Repair 87 P + Right Click: Patrol 87 88 Shift + Right Click: Queue the move/build/gather/etc order 88 89 Shift + Left click when training unit/s: Add units in batches of five 89 90 Shift + Left Click or Left Drag over unit on map: Add unit to selection -
binaries/data/mods/public/gui/session/input.js
16 16 const ACTION_GARRISON = 1; 17 17 const ACTION_REPAIR = 2; 18 18 const ACTION_GUARD = 3; 19 const ACTION_PATROL = 4; 19 20 var preSelectedAction = ACTION_NONE; 20 21 21 22 const INPUT_NORMAL = 0; … … 207 208 } 208 209 return { "possible": true, "data": data, "cursor": cursor }; 209 210 } 210 211 return { "possible": (action == "move" || action == "attack-move" || action == "remove-guard") }; 211 return { "possible": ["move", "attack-move", "remove-guard", "patrol"].indexOf(action) > -1 }; 212 212 } 213 213 214 214 // Look at the first targeted entity -
binaries/data/mods/public/gui/session/unit_actions.js
208 208 "specificness": 10, 209 209 }, 210 210 211 "patrol": 212 { 213 "execute": function(target, action, selection, queued) 214 { 215 Engine.PostNetworkCommand({ 216 "type": "patrol", 217 "entities": selection, 218 "x": target.x, 219 "z": target.z, 220 "target": action.target, 221 "targetClasses": { "attack": ["Unit"] }, // patrol should only attack units 222 "queued": queued, 223 "allowCapture": false 224 }); 225 Engine.GuiInterfaceCall("PlaySound", { "name": "order_patrol", "entity": selection[0] }); 226 return true; 227 }, 228 "getActionInfo": function(entState, targetState) 229 { 230 return { "possible": true }; 231 }, 232 "hotkeyActionCheck": function(target) 233 { 234 if (!Engine.HotkeyIsPressed("session.patrol") || !getActionInfo("patrol", target).possible) 235 return false; 236 return { 237 "type": "patrol", 238 "cursor": "action-patrol", 239 "target": target 240 }; 241 }, 242 "preSelectedActionCheck" : function(target) 243 { 244 if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target).possible) 245 return false; 246 return { 247 "type": "patrol", 248 "cursor": "action-patrol", 249 "target": target 250 }; 251 }, 252 "specificness": 37, 253 }, 254 211 255 "heal": 212 256 { 213 257 "execute": function(target, action, selection, queued) … … 1218 1262 }, 1219 1263 }, 1220 1264 1265 "patrol": { 1266 "getInfo": function(entState) 1267 { 1268 if (g_Selection.toList().every(ent => !GetExtendedEntityState(ent).unitAI)) 1269 return false; 1270 return { 1271 "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.patrol") + translate("Patrol"), 1272 "icon": "patrol.png" 1273 }; 1274 }, 1275 "execute": function(entState) 1276 { 1277 inputState = INPUT_PRESELECTEDACTION; 1278 preSelectedAction = ACTION_PATROL; 1279 }, 1280 }, 1281 1221 1282 "share-dropsite": { 1222 1283 "getInfo": function(entState) 1223 1284 { -
binaries/data/mods/public/simulation/components/UnitAI.js
514 514 this.FinishOrder(); 515 515 }, 516 516 517 "Order.Patrol": function(msg) { 518 // Let players move captured domestic animals around 519 if (this.IsAnimal() || this.IsTurret()) 520 { 521 this.FinishOrder(); 522 return; 523 } 524 525 if (this.CanPack()) 526 { 527 this.PushOrderFront("Pack", { "force": true }); 528 return; 529 } 530 531 this.MoveToPoint(this.order.data.x, this.order.data.z); 532 this.SetNextState("INDIVIDUAL.PATROL"); 533 }, 534 517 535 "Order.Heal": function(msg) { 518 536 // Check the target is alive 519 537 if (!this.TargetIsAlive(this.order.data.target)) … … 829 847 this.FinishOrder(); 830 848 }, 831 849 850 "Order.Patrol": function(msg) { 851 this.CallMemberFunction("SetHeldPosition", [msg.data.x, msg.data.z]); 852 853 this.MoveToPoint(this.order.data.x, this.order.data.z); 854 this.SetNextState("PATROL"); 855 }, 856 832 857 "Order.Guard": function(msg) { 833 858 this.CallMemberFunction("Guard", [msg.data.target, false]); 834 859 var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); … … 1078 1103 }, 1079 1104 }, 1080 1105 1106 "PATROL": { 1107 "enter": function(msg) { 1108 // Memorize the origin position in case that we want to go back 1109 let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); 1110 if (!cmpPosition || !cmpPosition.IsInWorld()) 1111 { 1112 this.FinishOrder(); 1113 return; 1114 } 1115 this.patrolStartPos = cmpPosition.GetPosition(); 1116 }, 1117 1118 "Timer": function(msg) { 1119 // Check if there are no enemies to attack 1120 this.FindWalkAndFightTargets(); 1121 }, 1122 1123 "leave": function(msg) { 1124 this.StopTimer(); 1125 }, 1126 1127 "MoveStarted": function(msg) { 1128 let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); 1129 cmpFormation.SetRearrange(true); 1130 cmpFormation.MoveMembersIntoFormation(true, true); 1131 }, 1132 1133 "MoveCompleted": function() { 1134 /** 1135 * A-B-A-B-..: 1136 * if the user only commands one patrol order, the patrol will be between 1137 * the last position and the defined waypoint 1138 * A-B-C-..-A-B-..: 1139 * otherwise, the patrol is only between the given patrol commands and the 1140 * last position is not included (last position = the position where the unit 1141 * is located at the time of the first patrol order) 1142 */ 1143 1144 if (this.orderQueue.length == 1) 1145 this.PushOrder("Patrol", this.patrolStartPos); 1146 1147 this.PushOrder(this.order.type, this.order.data); 1148 this.FinishOrder(); 1149 }, 1150 }, 1151 1081 1152 "GARRISON":{ 1082 1153 "enter": function() { 1083 1154 // If the garrisonholder should pickup, warn it so it can take needed action … … 1555 1626 }, 1556 1627 }, 1557 1628 1629 "PATROL": { 1630 "enter": function () { 1631 this.SelectAnimation("move"); 1632 1633 // Memorize the origin position in case that we want to go back 1634 let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); 1635 if (!cmpPosition || !cmpPosition.IsInWorld()) 1636 { 1637 this.FinishOrder(); 1638 return; 1639 } 1640 this.patrolStartPos = cmpPosition.GetPosition(); 1641 }, 1642 1643 "leave": function() { 1644 this.StopTimer(); 1645 }, 1646 1647 "Timer": function(msg) { 1648 this.FindWalkAndFightTargets(); 1649 }, 1650 1651 "MoveCompleted": function() { 1652 if (this.orderQueue.length == 1) 1653 this.PushOrder("Patrol",this.patrolStartPos); 1654 1655 this.PushOrder(this.order.type, this.order.data); 1656 this.FinishOrder(); 1657 }, 1658 }, 1659 1558 1660 "GUARD": { 1559 1661 "RemoveGuard": function() { 1560 1662 this.StopMoving(); … … 4779 4881 case "WalkToPointRange": 4780 4882 case "MoveIntoFormation": 4781 4883 case "GatherNearPosition": 4884 case "Patrol": 4782 4885 targetPositions.push(new Vector2D(order.data.x, order.data.z)); 4783 4886 break; // and continue the loop 4784 4887 … … 4991 5094 this.AddOrder("WalkAndFight", { "x": x, "z": z, "targetClasses": targetClasses, "force": true }, queued); 4992 5095 }; 4993 5096 5097 UnitAI.prototype.Patrol = function(x, z, targetClasses, queued) 5098 { 5099 this.AddOrder("Patrol", { "x": x, "z": z, "targetClasses": targetClasses, "force": true }, queued); 5100 }; 5101 4994 5102 /** 4995 5103 * Adds leave foundation order to queue, treated as forced. 4996 5104 */ -
binaries/data/mods/public/simulation/helpers/Commands.js
176 176 }); 177 177 }, 178 178 179 "patrol": function(player, cmd, data) 180 { 181 GetFormationUnitAIs(data.entities, player).forEach(cmpUnitAI => 182 cmpUnitAI.Patrol(cmd.x, cmd.z, cmd.targetClasses, cmd.queued) 183 ); 184 }, 185 179 186 "heal": function(player, cmd, data) 180 187 { 181 188 if (g_DebugCommands && !(IsOwnedByPlayer(player, cmd.target) || IsOwnedByAllyOfPlayer(player, cmd.target)))