Пример #1
0
 def OnTarget(self, what, tid=None, reason=None):
     if (what == "lost"):
         if (reason == None) and (tid in self.__balls):
             ball = self.__balls[tid]
             del self.__balls[tid]
             if ball in self.__eligibleBalls:
                 self.__eligibleBalls.remove(ball)
         if tid in self.__lockedTargets:
             self.__lockedTargets.remove(tid) 
             setItemColor(tid, None)
     
     elif (what == "clear"):
         for id in self.__lockedTargets:
             setItemColor(id, None)
         
         self.__lockedTargets = set()
Пример #2
0
    def OnTarget(self, what, tid=None, reason=None):
        if (what == "lost"):
            if (reason == None) and (tid in self.__balls):
                ball = self.__balls[tid]
                del self.__balls[tid]
                if ball in self.__eligibleBalls:
                    self.__eligibleBalls.remove(ball)
            if tid in self.__lockedTargets:
                self.__lockedTargets.remove(tid)
                setItemColor(tid, None)

        elif (what == "clear"):
            for id in self.__lockedTargets:
                setItemColor(id, None)

            self.__lockedTargets = set()
Пример #3
0
 def populateBalls(self):        
     self.__balls = {}
     
     ballpark = eve.LocalSvc("michelle").GetBallpark()
     if not ballpark:
         return
     
     targetSvc = sm.services.get('target', None)
     if targetSvc:
         self.__lockedTargets = set(targetSvc.targets)
         for id in self.__lockedTargets:
             setItemColor(id, "Automatic Target")
     
     lst = []
     for ballID, ball in ballpark.balls.iteritems():
        lst.append((ball, ballpark.GetInvItem(ballID)))
     
     self._DoBallsAdded(lst)
Пример #4
0
    def populateBalls(self):
        self.__balls = {}

        ballpark = eve.LocalSvc("michelle").GetBallpark()
        if not ballpark:
            return

        targetSvc = sm.services.get('target', None)
        if targetSvc:
            self.__lockedTargets = set(targetSvc.targets)
            for id in self.__lockedTargets:
                setItemColor(id, "Automatic Target")

        lst = []
        for ballID, ball in ballpark.balls.iteritems():
            lst.append((ball, ballpark.GetInvItem(ballID)))

        self._DoBallsAdded(lst)
Пример #5
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
             )
Пример #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)