Ticket #4276: 4276_uselessvar.diff
File 4276_uselessvar.diff, 1.6 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Attack.js
Attack.prototype.GetBestAttackAgainst = 310 310 311 311 // Always slaughter domestic animals instead of using a normal attack 312 312 if (isTargetClass("Domestic") && this.template.Slaughter) 313 313 return "Slaughter"; 314 314 315 let attack = this; 316 let types = this.GetAttackTypes().filter(type => !attack.GetRestrictedClasses(type).some(isTargetClass)); 315 let types = this.GetAttackTypes().filter(type => !this.GetRestrictedClasses(type).some(isTargetClass)); 317 316 318 317 // check if the target is capturable 319 318 let captureIndex = types.indexOf("Capture"); 320 319 if (captureIndex != -1) 321 320 { 322 321 let cmpCapturable = QueryMiragedInterface(target, IID_Capturable); 323 322 324 323 let cmpPlayer = QueryOwnerInterface(this.entity); 325 324 if (allowCapture && cmpPlayer && cmpCapturable && cmpCapturable.CanCapture(cmpPlayer.GetPlayerID())) 326 325 return "Capture"; 327 // not captur eable, so remove this attack326 // not capturable, so remove this attack 328 327 types.splice(captureIndex, 1); 329 328 } 330 329 331 let isPreferred = className => attack.GetPreferredClasses(className).some(isTargetClass);330 let isPreferred = className => this.GetPreferredClasses(className).some(isTargetClass); 332 331 333 332 return types.sort((a, b) => 334 333 (types.indexOf(a) + (isPreferred(a) ? types.length : 0)) - 335 334 (types.indexOf(b) + (isPreferred(b) ? types.length : 0))).pop(); 336 335 };