Ticket #4015: UnitAI.js.patch
File UnitAI.js.patch, 1.9 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 if(type == "Walk") 5973 return false; 5974 if(type == "Attack") 5975 { 5976 let target = data.target; 5977 let attackType = this.GetBestAttackAgainst(target, false); 5978 return this.CheckTargetAttackRange(data.target, attackType) 5979 } 5980 return true; 5981 }; 5982 5963 5983 //// Formation specific functions //// 5964 5984 5965 5985 UnitAI.prototype.IsAttackingAsFormation = function()