Ticket #3302: 3302.js.patch
File 3302.js.patch, 3.9 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/UnitAI.js
241 241 // Stop moving immediately. 242 242 this.StopMoving(); 243 243 this.FinishOrder(); 244 this.RemoveGuard(); 244 245 245 246 // No orders left, we're an individual now 246 247 if (this.IsAnimal()) … … 268 269 return; 269 270 } 270 271 272 this.RemoveGuard(); 273 271 274 this.SetHeldPosition(this.order.data.x, this.order.data.z); 272 275 if (!this.order.data.max) 273 276 this.MoveToPoint(this.order.data.x, this.order.data.z); … … 297 300 return; 298 301 } 299 302 303 this.RemoveGuard(); 304 300 305 this.SetHeldPosition(this.order.data.x, this.order.data.z); 301 306 this.MoveToPoint(this.order.data.x, this.order.data.z); 302 307 if (this.IsAnimal()) … … 324 329 return; 325 330 } 326 331 332 this.RemoveGuard(); 333 327 334 var ok = this.MoveToTarget(this.order.data.target); 328 335 if (ok) 329 336 { … … 360 367 needToMove = false; 361 368 } 362 369 370 this.RemoveGuard(); 371 363 372 // TODO: what if the units are on a cliff ? the ship will go below the cliff 364 373 // and the units won't be able to garrison. Should go to the nearest (accessible) shore 365 374 if (needToMove && this.MoveToTarget(this.order.data.target)) … … 425 434 } 426 435 this.order.data.attackType = type; 427 436 437 this.RemoveGuard(); 438 428 439 // If we are already at the target, try attacking it from here 429 440 if (this.CheckTargetAttackRange(this.order.data.target, this.order.data.attackType)) 430 441 { … … 587 598 return; 588 599 } 589 600 601 this.RemoveGuard(); 602 590 603 // Try to move within range 591 604 if (this.MoveToTargetRange(this.order.data.target, IID_ResourceGatherer)) 592 605 { … … 665 678 666 679 "Order.Repair": function(msg) { 667 680 // Try to move within range 681 this.RemoveGuard(); 668 682 if (this.MoveToTargetRange(this.order.data.target, IID_Builder)) 669 683 { 670 684 // We've started walking to the given point … … 702 716 return; 703 717 } 704 718 719 this.RemoveGuard(); 720 705 721 if (this.MoveToGarrisonRange(this.order.data.target)) 706 722 { 707 723 this.SetNextState("INDIVIDUAL.GARRISON.APPROACHING"); … … 785 801 "Order.Walk": function(msg) { 786 802 this.CallMemberFunction("SetHeldPosition", [msg.data.x, msg.data.z]); 787 803 804 this.RemoveGuard(); 788 805 this.MoveToPoint(this.order.data.x, this.order.data.z); 789 806 this.SetNextState("WALKING"); 790 807 }, … … 792 809 "Order.WalkAndFight": function(msg) { 793 810 this.CallMemberFunction("SetHeldPosition", [msg.data.x, msg.data.z]); 794 811 812 this.RemoveGuard(); 795 813 this.MoveToPoint(this.order.data.x, this.order.data.z); 796 814 this.SetNextState("WALKINGANDFIGHTING"); 797 815 }, … … 799 817 "Order.MoveIntoFormation": function(msg) { 800 818 this.CallMemberFunction("SetHeldPosition", [msg.data.x, msg.data.z]); 801 819 820 this.RemoveGuard(); 802 821 this.MoveToPoint(this.order.data.x, this.order.data.z); 803 822 this.SetNextState("FORMING"); 804 823 }, … … 834 853 "Order.Stop": function(msg) { 835 854 if (!this.IsAttackingAsFormation()) 836 855 this.CallMemberFunction("Stop", [false]); 856 this.RemoveGuard(); 837 857 this.FinishOrder(); 838 858 }, 839 859 … … 859 879 this.FinishOrder(); 860 880 return; 861 881 } 882 this.RemoveGuard(); 862 883 this.CallMemberFunction("Attack", [target, false, allowCapture]); 863 884 if (cmpAttack.CanAttackAsFormation()) 864 885 this.SetNextState("COMBAT.ATTACKING"); … … 867 888 }, 868 889 869 890 "Order.Garrison": function(msg) { 891 this.RemoveGuard(); 870 892 if (!Engine.QueryInterface(msg.data.target, IID_GarrisonHolder)) 871 893 { 872 894 this.FinishOrder(); … … 895 917 }, 896 918 897 919 "Order.Gather": function(msg) { 920 this.RemoveGuard(); 898 921 if (this.MustKillGatherTarget(msg.data.target)) 899 922 { 900 923 // The target was visible when this order was given, … … 4888 4911 4889 4912 UnitAI.prototype.RemoveGuard = function() 4890 4913 { 4914 warn("RemoveGuard") 4891 4915 if (this.isGuardOf) 4892 4916 { 4893 4917 var cmpGuard = Engine.QueryInterface(this.isGuardOf, IID_Guard);