Ejemplo n.º 1
0
    def doRecall(self, *dronesToRecall):
        if self.disabled:
            return

        dronesToRecall = list(dronesToRecall)
        timestamp = blue.os.GetTime(1)

        for droneID in list(dronesToRecall):
            droneObj = self.getDroneObject(droneID)
            if ((droneObj.state == const.entityDeparting)
                    or (droneObj.state == const.entityDeparting2)
                    or (droneObj.state == const.entityPursuit)
                    or (droneObj.state == const.entityFleeing)
                    or abs(droneObj.actionTimestamp - timestamp) <=
                    ActionThreshold):
                dronesToRecall.remove(droneID)

        if len(dronesToRecall):
            entity = moniker.GetEntityAccess()
            if entity:
                log("Drone(s) returning: %s",
                    ", ".join(getNamesOfIDs(dronesToRecall)))
                entity.CmdReturnBay(dronesToRecall)
                for droneID in dronesToRecall:
                    droneObj = self.getDroneObject(droneID)
                    droneObj.setState(const.entityDeparting, timestamp)
                    droneObj.actionTimestamp = timestamp
                    self.__recalling.add(droneObj.id)
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def doRecall(self, *dronesToRecall):
     if self.disabled:
         return
     
     dronesToRecall = list(dronesToRecall)
     timestamp = blue.os.GetTime(1)
     
     for droneID in list(dronesToRecall):
         droneObj = self.getDroneObject(droneID)
         if ((droneObj.state == const.entityDeparting) or
            (droneObj.state == const.entityDeparting2) or
            (droneObj.state == const.entityPursuit) or
            (droneObj.state == const.entityFleeing) or
            abs(droneObj.actionTimestamp - timestamp) <= ActionThreshold):
             dronesToRecall.remove(droneID)
     
     if len(dronesToRecall):
         entity = moniker.GetEntityAccess()
         if entity:
             log("Drone(s) returning: %s", ", ".join(getNamesOfIDs(dronesToRecall)))
             entity.CmdReturnBay(dronesToRecall)
             for droneID in dronesToRecall:                    
                 droneObj = self.getDroneObject(droneID)
                 droneObj.setState(const.entityDeparting, timestamp)
                 droneObj.actionTimestamp = timestamp
                 self.__recalling.add(droneObj.id)
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    def doAttack(self,
                 idleOnly,
                 targetID=None,
                 dronesToAttack=[],
                 oldTarget=None):
        if self.disabled:
            return

        ballpark = eve.LocalSvc("michelle").GetBallpark()
        timestamp = blue.os.GetTime(1)
        isCommonTarget = False
        if not targetID:
            targetID = self.getCommonTarget()
            if targetID:
                slimItem = ballpark.GetInvItem(targetID)
                if slimItem:
                    targetName = uix.GetSlimItemName(slimItem)
                    isCommonTarget = True

        if not targetID:
            targetID = self.selectTarget()

        if targetID:
            slimItem = ballpark.GetInvItem(targetID)
            if slimItem:
                targetName = uix.GetSlimItemName(slimItem)
            else:
                targetName = "Unknown"

            drones = list(self.getDronesInLocalSpace().keys())
            for id in dronesToAttack:
                if id not in drones:
                    drones.append(id)

            for id in list(drones):
                droneObj = self.getDroneObject(id)
                if ((droneObj.state == const.entityDeparting)
                        or (droneObj.state == const.entityDeparting2)
                        or (droneObj.state == const.entityFleeing)
                        or (droneObj.state == const.entityPursuit)):
                    drones.remove(id)
                elif ((droneObj.target == targetID)
                      or abs(droneObj.actionTimestamp - timestamp) <=
                      ActionThreshold):
                    drones.remove(id)
                elif (idleOnly and (droneObj.state != const.entityIdle)):
                    drones.remove(id)

            if len(drones):
                if ((len(drones) > 1) or (not self.__lastAttackOrder)):
                    self.__lastAttackOrder = targetID

                entity = moniker.GetEntityAccess()
                if entity:
                    if isCommonTarget:
                        targetName += " (existing target)"

                    oldTargetName = None
                    if oldTarget:
                        slimItem = ballpark.GetInvItem(oldTarget)
                        oldTargetName = uix.GetSlimItemName(slimItem)

                    if oldTargetName:
                        log("%s changing target from %s to %s",
                            ", ".join(getNamesOfIDs(drones)), oldTargetName,
                            targetName)
                    else:
                        log("%s attacking %s",
                            ", ".join(getNamesOfIDs(drones)), targetName)

                    for id in drones:
                        droneObj = self.getDroneObject(id)
                        droneObj.setTarget(targetID, timestamp)
                        droneObj.actionTimestamp = timestamp
                    ret = entity.CmdEngage(drones, targetID)
Ejemplo n.º 6
0
 def updateTargets(self):
     if self.disabled:
         self.__updateTimer = None
         return
     
     ballpark = sm.services["michelle"].GetBallpark()
     if not ballpark:
         return
 
     targetSvc = sm.services.get('target', None)
     if not targetSvc:
         return
     
     targetSvc_targeting = [long(k) for k in targetSvc.targeting.keys()]
     targetSvc_autoTargeting = [long(k) for k in targetSvc.autoTargeting]
         
     maxTargets = self.getMaxTargets()
     if maxTargets <= 0:
         return
     
     reservedSlots = int(getPref("ReservedTargetSlots", 1))
     maxAutoTargets = max(0, maxTargets - reservedSlots)
         
     gd = Memoized(self.getDistance)
     gp = Memoized(getPriority)
     
     currentTargets = [self.__balls.get(id, None) for id in self.__lockedTargets 
         if id in targetSvc.targets]
     currentTargets = [bi.id for bi in self.filterTargets(currentTargets, gp, gd)]
     exclusionSet = set(targetSvc_targeting + targetSvc_autoTargeting + currentTargets)
     targetSorter = self.makeTargetSorter(exclusionSet, gp, gd)
     
     targets = self.filterTargets(self.__eligibleBalls, gp, gd)        
     targets.sort(targetSorter)
             
     currentlyTargeting = set([
         id for id in (targetSvc_targeting + targetSvc_autoTargeting) 
         if id in self.__lockedTargets
     ])
     
     allLockedTargets = set(targetSvc_targeting + targetSvc_autoTargeting + targetSvc.targets)
     maxNewTargets = max(maxTargets - len(allLockedTargets), 0)
     targets = set([bi.id for bi in targets[0:maxAutoTargets]])
     
     currentTargets = set(currentTargets)
                 
     targetsToUnlock = (currentTargets - targets) - currentlyTargeting
     targetsToLock = list((targets - set(targetSvc.targets)) - currentlyTargeting)
     targetsToLock = targetsToLock[0:maxNewTargets]
             
     if len(targetsToUnlock):
         log("Unlocking %s", ", ".join(getNamesOfIDs(targetsToUnlock)))
         for targetID in targetsToUnlock:
             if targetID in self.__lockedTargets:
                 self.__lockedTargets.remove(targetID)
                 setItemColor(targetID, None)
             
             targetSvc.UnlockTarget(targetID)
     
     if len(targetsToLock):
         log("Locking %s", ", ".join(getNamesOfIDs(targetsToLock)))
         for targetID in targetsToLock:
             if targetID not in self.__lockedTargets:
                 self.__lockedTargets.add(targetID)
                 setItemColor(targetID, "Automatic Target")
             
             uthread.pool(
                 "LockTarget",
                 self.tryLockTarget,
                 targetSvc, targetID
             )
Ejemplo n.º 7
0
    def updateTargets(self):
        if self.disabled:
            self.__updateTimer = None
            return

        ballpark = sm.services["michelle"].GetBallpark()
        if not ballpark:
            return

        targetSvc = sm.services.get('target', None)
        if not targetSvc:
            return

        targetSvc_targeting = [long(k) for k in targetSvc.targeting.keys()]
        targetSvc_autoTargeting = [long(k) for k in targetSvc.autoTargeting]

        maxTargets = self.getMaxTargets()
        if maxTargets <= 0:
            return

        reservedSlots = int(getPref("ReservedTargetSlots", 1))
        maxAutoTargets = max(0, maxTargets - reservedSlots)

        gd = Memoized(self.getDistance)
        gp = Memoized(getPriority)

        currentTargets = [
            self.__balls.get(id, None) for id in self.__lockedTargets
            if id in targetSvc.targets
        ]
        currentTargets = [
            bi.id for bi in self.filterTargets(currentTargets, gp, gd)
        ]
        exclusionSet = set(targetSvc_targeting + targetSvc_autoTargeting +
                           currentTargets)
        targetSorter = self.makeTargetSorter(exclusionSet, gp, gd)

        targets = self.filterTargets(self.__eligibleBalls, gp, gd)
        targets.sort(targetSorter)

        currentlyTargeting = set([
            id for id in (targetSvc_targeting + targetSvc_autoTargeting)
            if id in self.__lockedTargets
        ])

        allLockedTargets = set(targetSvc_targeting + targetSvc_autoTargeting +
                               targetSvc.targets)
        maxNewTargets = max(maxTargets - len(allLockedTargets), 0)
        targets = set([bi.id for bi in targets[0:maxAutoTargets]])

        currentTargets = set(currentTargets)

        targetsToUnlock = (currentTargets - targets) - currentlyTargeting
        targetsToLock = list((targets - set(targetSvc.targets)) -
                             currentlyTargeting)
        targetsToLock = targetsToLock[0:maxNewTargets]

        if len(targetsToUnlock):
            log("Unlocking %s", ", ".join(getNamesOfIDs(targetsToUnlock)))
            for targetID in targetsToUnlock:
                if targetID in self.__lockedTargets:
                    self.__lockedTargets.remove(targetID)
                    setItemColor(targetID, None)

                targetSvc.UnlockTarget(targetID)

        if len(targetsToLock):
            log("Locking %s", ", ".join(getNamesOfIDs(targetsToLock)))
            for targetID in targetsToLock:
                if targetID not in self.__lockedTargets:
                    self.__lockedTargets.add(targetID)
                    setItemColor(targetID, "Automatic Target")

                uthread.pool("LockTarget", self.tryLockTarget, targetSvc,
                             targetID)
Ejemplo n.º 8
0
 def doAttack(self, idleOnly, targetID=None, dronesToAttack=[], oldTarget=None):
     if self.disabled:
         return
         
     ballpark = eve.LocalSvc("michelle").GetBallpark()
     timestamp = blue.os.GetTime(1)
     isCommonTarget = False
     if not targetID:
         targetID = self.getCommonTarget()
         if targetID:
             slimItem = ballpark.GetInvItem(targetID)
             if slimItem:
                 targetName = uix.GetSlimItemName(slimItem)
                 isCommonTarget = True
     
     if not targetID:
         targetID = self.selectTarget()
     
     if targetID:        
         slimItem = ballpark.GetInvItem(targetID)
         if slimItem:
             targetName = uix.GetSlimItemName(slimItem)
         else:
             targetName = "Unknown"
         
         drones = list(self.getDronesInLocalSpace().keys())
         for id in dronesToAttack:
             if id not in drones:
                 drones.append(id)
             
         for id in list(drones):
             droneObj = self.getDroneObject(id)
             if ((droneObj.state == const.entityDeparting) or
                 (droneObj.state == const.entityDeparting2) or
                 (droneObj.state == const.entityFleeing) or
                 (droneObj.state == const.entityPursuit)):
                 drones.remove(id)
             elif ((droneObj.target == targetID) or
                 abs(droneObj.actionTimestamp - timestamp) <= ActionThreshold):
                 drones.remove(id)
             elif (idleOnly and (droneObj.state != const.entityIdle)):
                 drones.remove(id)
         
         if len(drones):
             if ((len(drones) > 1) or 
                 (not self.__lastAttackOrder)):
                 self.__lastAttackOrder = targetID
             
             entity = moniker.GetEntityAccess()
             if entity:
                 if isCommonTarget:
                     targetName += " (existing target)"
                 
                 oldTargetName = None
                 if oldTarget:
                     slimItem = ballpark.GetInvItem(oldTarget)
                     oldTargetName = uix.GetSlimItemName(slimItem)
                 
                 if oldTargetName:
                     log("%s changing target from %s to %s", ", ".join(getNamesOfIDs(drones)), oldTargetName, targetName)
                 else:
                     log("%s attacking %s", ", ".join(getNamesOfIDs(drones)), targetName)
                 
                 for id in drones:
                     droneObj = self.getDroneObject(id)
                     droneObj.setTarget(targetID, timestamp)
                     droneObj.actionTimestamp = timestamp
                 ret = entity.CmdEngage(drones, targetID)