Ticket #4015: UnitAI.js.2.patch
File UnitAI.js.2.patch, 1.8 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/public/simulation/components/UnitAI.js
3835 3835 // Special cases of orders that shouldn't be replaced: 3836 3836 // 1. Cheering - we're invulnerable, add order after we finish 3837 3837 // 2. Packing/unpacking - we're immobile, add order after we finish (unless it's cancel) 3838 // 2./1. If order is a move (or out of range attack), we cancel packing immediately and then add the moving order 3838 3839 // TODO: maybe a better way of doing this would be to use priority levels 3839 3840 if (this.order && this.order.type == "Cheering") 3840 3841 { … … 3842 3843 var cheeringOrder = this.orderQueue.shift(); 3843 3844 this.orderQueue = [cheeringOrder, order]; 3844 3845 } 3845 else if (this.IsPacking() && type != "CancelPack" && type != "CancelUnpack" )3846 else if (this.IsPacking() && type != "CancelPack" && type != "CancelUnpack" && this.ShouldPack(type, data)) 3846 3847 { 3847 3848 var order = { "type": type, "data": data }; 3848 3849 var packingOrder = this.orderQueue.shift(); 3849 3850 this.orderQueue = [packingOrder, order]; 3850 3851 } 3852 else if (this.IsPacking() && !this.ShouldPack(type, data)) 3853 { 3854 this.orderQueue = []; 3855 this.PushOrder("CancelUnpack", { "force": true }); 3856 this.PushOrder(type, data); 3857 } 3851 3858 else 3852 3859 { 3853 3860 this.orderQueue = []; … … 5960 5967 return (cmpPack && cmpPack.IsPacking()); 5961 5968 }; 5962 5969 5970 UnitAI.prototype.ShouldPack = function(type, data) 5971 { 5972 return type == "Attack" && this.CheckTargetAttackRange(data.target, this.GetBestAttackAgainst(data.target, false)); 5973 }; 5974 5963 5975 //// Formation specific functions //// 5964 5976 5965 5977 UnitAI.prototype.IsAttackingAsFormation = function()