def filterTargets(self, ids, chanceToHitGetter): ballpark = eve.LocalSvc("michelle").GetBallpark() result = [] cannotHit = set() minChanceToHit = float(getPref("MinimumChanceToHit", 1)) / 100.0 for id in ids: invItem = ballpark.GetInvItem(id) if not invItem: continue flag = getFlagName(id) if (flag != "HostileNPC") and (flag is not None): continue if getPriority(id) < 0: continue if chanceToHitGetter(id) < minChanceToHit: cannotHit.add(id) continue result.append(id) if (len(cannotHit) > 0) and (len(result) == 0): log("Cannot hit target(s) %s", ", ".join(getNamesOfIDs(cannotHit))) return result
def filterTargets(self, ids): targetSvc = sm.services.get('target', None) if not targetSvc: return [] ballpark = eve.LocalSvc("michelle").GetBallpark() if not ballpark: return [] controlRange = self.getDroneControlRange() result = [] for id in ids: invItem = ballpark.GetInvItem(id) if not invItem: continue if not (id in targetSvc.targets): continue flag = getFlagName(id) if (flag != "HostileNPC") and (flag is not None): continue if getPriority(id) < 0: continue if ballpark.DistanceBetween(eve.session.shipid, id) > controlRange: continue result.append(id) return result
def isEligible(self, cachedItem): return ( (getPref("TargetHostileNPCs", False) and cachedItem.flag in FlagHostileNPC) or (getPref("TargetHostilePlayers", False) and cachedItem.flag in FlagHostilePlayer) or (getPref("TargetNeutralPlayers", False) and cachedItem.flag in FlagNeutralPlayer) or (getPref("TargetFriendlyPlayers", False) and cachedItem.flag in FlagFriendlyPlayer) or ((cachedItem.flag is None) and (getPriority(cachedItem.id) > 0)) )
def isEligible(self, cachedItem): return ((getPref("TargetHostileNPCs", False) and cachedItem.flag in FlagHostileNPC) or (getPref("TargetHostilePlayers", False) and cachedItem.flag in FlagHostilePlayer) or (getPref("TargetNeutralPlayers", False) and cachedItem.flag in FlagNeutralPlayer) or (getPref("TargetFriendlyPlayers", False) and cachedItem.flag in FlagFriendlyPlayer) or ((cachedItem.flag is None) and (getPriority(cachedItem.id) > 0)))
def updateDrones(self): if self.disabled: self.__updateTimer = None return ballpark = eve.LocalSvc("michelle").GetBallpark() if not ballpark: return targetSvc = sm.services["target"] if not targetSvc: return if self.__lastAttackOrder: if not ballpark.GetBall(self.__lastAttackOrder): self.__lastAttackOrder = None timestamp = blue.os.GetTime(1) droneIDs = set(self.getDronesInLocalSpace().keys()) dronesToRecall = [] dronesToAttack = [] self.__numFighters = 0 for droneID in droneIDs: slimItem = ballpark.GetInvItem(droneID) if (slimItem and ((slimItem.groupID == const.groupFighterDrone) or (slimItem.groupID == const.groupFighterBomber))): self.__numFighters += 1 self.__numSentries = 0 for droneObj in self.__drones.itervalues(): if droneObj.isSentry: self.__numSentries += 1 for (pendingID, psc) in list(self.__pendingStateChanges.items()): if self.__pendingStateChanges.has_key(pendingID): del self.__pendingStateChanges[pendingID] if pendingID not in droneIDs: continue (ts, oldState, newState) = psc self.OnDroneStateChange2(pendingID, oldState, newState, timestamp=ts) for droneID in droneIDs: drone = self.getDroneObject(droneID) drone.update(timestamp) if self.checkDroneHealth(drone): dronesToRecall.append(droneID) elif ((drone.state == const.entityIdle) and getPref("WhenIdle", False)): dronesToAttack.append(droneID) if getPref("RedeployAfter", True) and len(self.__recalled): redeployAfter = int( float(getPref("RedeployAfterSeconds", 30.0)) * 10000000) dronesToRelaunch = [] ts, id = self.__recalled[0] while ts + redeployAfter <= timestamp: dronesToRelaunch.append(id) self.__recalled.pop(0) if len(self.__recalled): ts, id = self.__recalled[0] else: break if len(dronesToRelaunch): self.doLaunch(*dronesToRelaunch) if len(dronesToRecall): for id in dronesToRecall: if id in dronesToAttack: dronesToAttack.remove(id) self.doRecall(*dronesToRecall) if len(dronesToAttack): self.doAttack(idleOnly=True, targetID=None, dronesToAttack=dronesToAttack) elif getPref("WhenTargetLost", False): commonTarget = self.getCommonTarget(filtered=False) if commonTarget == eve.session.shipid: return oldPriority = getPriority(commonTarget) newTarget = self.selectTarget() newPriority = getPriority(newTarget) if commonTarget and (newPriority > oldPriority): if ((commonTarget == self.__lastAttackOrder) or (commonTarget not in targetSvc.targets)): self.doAttack(idleOnly=False, targetID=newTarget, oldTarget=commonTarget)
def updateDrones(self): if self.disabled: self.__updateTimer = None return ballpark = eve.LocalSvc("michelle").GetBallpark() if not ballpark: return targetSvc = sm.services["target"] if not targetSvc: return if self.__lastAttackOrder: if not ballpark.GetBall(self.__lastAttackOrder): self.__lastAttackOrder = None timestamp = blue.os.GetTime(1) droneIDs = set(self.getDronesInLocalSpace().keys()) dronesToRecall = [] dronesToAttack = [] self.__numFighters = 0 for droneID in droneIDs: slimItem = ballpark.GetInvItem(droneID) if (slimItem and ( (slimItem.groupID == const.groupFighterDrone) or (slimItem.groupID == const.groupFighterBomber) )): self.__numFighters += 1 self.__numSentries = 0 for droneObj in self.__drones.itervalues(): if droneObj.isSentry: self.__numSentries += 1 for (pendingID, psc) in list(self.__pendingStateChanges.items()): if self.__pendingStateChanges.has_key(pendingID): del self.__pendingStateChanges[pendingID] if pendingID not in droneIDs: continue (ts, oldState, newState) = psc self.OnDroneStateChange2(pendingID, oldState, newState, timestamp=ts) for droneID in droneIDs: drone = self.getDroneObject(droneID) drone.update(timestamp) if self.checkDroneHealth(drone): dronesToRecall.append(droneID) elif ((drone.state == const.entityIdle) and getPref("WhenIdle", False)): dronesToAttack.append(droneID) if getPref("RedeployAfter", True) and len(self.__recalled): redeployAfter = int(float(getPref("RedeployAfterSeconds", 30.0)) * 10000000) dronesToRelaunch = [] ts, id = self.__recalled[0] while ts + redeployAfter <= timestamp: dronesToRelaunch.append(id) self.__recalled.pop(0) if len(self.__recalled): ts, id = self.__recalled[0] else: break if len(dronesToRelaunch): self.doLaunch(*dronesToRelaunch) if len(dronesToRecall): for id in dronesToRecall: if id in dronesToAttack: dronesToAttack.remove(id) self.doRecall(*dronesToRecall) if len(dronesToAttack): self.doAttack(idleOnly=True, targetID=None, dronesToAttack=dronesToAttack) elif getPref("WhenTargetLost", False): commonTarget = self.getCommonTarget(filtered=False) if commonTarget == eve.session.shipid: return oldPriority = getPriority(commonTarget) newTarget = self.selectTarget() newPriority = getPriority(newTarget) if commonTarget and (newPriority > oldPriority): if ((commonTarget == self.__lastAttackOrder) or (commonTarget not in targetSvc.targets)): self.doAttack(idleOnly=False, targetID=newTarget, oldTarget=commonTarget)