def onEnterWorld(self, prereqs):
    global ownVehicle, getDistanceID, visible
    if self.isPlayerVehicle and config.get(
            'sight/enabled',
            True) and self.isAlive() and battle.isBattleTypeSupported:
        ownVehicle = self
        visible = True
        getDistanceID = callback(0.1, getDistance)
예제 #2
0
def reloadingShot(duration):
    global leftTimeShot, reloadShotTimerCallbackID, endReloadTimeShot
    reloadShotTimerCallbackID = resetCallback(reloadShotTimerCallbackID)
    if duration > 0.0:
        leftTimeShot = duration
        endReloadTimeShot = time() + duration
        reloadShotTimerCallbackID = callback(0.1, reloadShotTimer)
    else:
        leftTimeShot = 0.0
    as_event('ON_RELOAD')
def smoothing(stepYaw, stepPitch, step):
    global dataHor, dataVert, smoothingID
    dataHor, dataVert = coordinate(stepYaw, stepPitch)
    if (step + STEP) < 1.001:
        smoothingID = callback(
            TIME_STEP, lambda: smoothing(stepYaw + currentStepYaw, stepPitch +
                                         currentStepPitch, step + STEP))
    else:
        smoothingID = None
    updateLabels()
예제 #4
0
def reloadShotTimer():
    global leftTimeShot, reloadShotTimerCallbackID
    if leftTimeShot is None:
        return
    leftTimeShot = max(0.0, endReloadTimeShot - time())
    if leftTimeShot > 0.0:
        reloadShotTimerCallbackID = callback(0.1, reloadShotTimer)
    else:
        reloadShotTimerCallbackID = None
    as_event('ON_RELOAD')
예제 #5
0
def autoReloadTimer():
    global autoReloadLeftTime, autoReloadTimerCallbackID, leftTime
    if autoReloadLeftTime is None:
        return
    autoReloadLeftTime = max(0.0, endAutoReloadTime - time())
    leftTime = max(0.0, endReloadTime - time())
    if (autoReloadLeftTime > 0.0) or (leftTime > 0.0):
        autoReloadTimerCallbackID = callback(0.1, autoReloadTimer)
    else:
        autoReloadTimerCallbackID = None
    as_event('ON_RELOAD')
예제 #6
0
def reloadTimer():
    global leftTime, reloadTimerCallbackID
    if leftTime is None:
        return
    leftTime = max(0.0, endReloadTime - time())
    if leftTime > 0.0:
        reloadTimerCallbackID = callback(0.1, reloadTimer)
    else:
        reloadTimerCallbackID = None
    if not isAutoReload:
        as_event('ON_RELOAD')
def getDistance():
    global distance, getDistanceID
    if ownVehicle is not None:
        pos = GUI.mcursor().position
        direction, start = getWorldRayAndPoint(*pos)
        end = start + direction.scale(100000.0)
        point = collideDynamicAndStatic(start, end, (ownVehicle.id, ), 0)
        aimingPoint = point[0] if point is not None else shootInSkyPoint(
            start, direction)
        prevDistance = distance
        distance = int((aimingPoint - ownVehicle.position).length)
        if prevDistance != distance:
            as_event('ON_CROSSHAIR')
        getDistanceID = callback(0.1, getDistance)
예제 #8
0
def reloading(duration, baseTime, startTime=0.0):
    global leftTime, reloadTime, endReloadTime, reloadTimeClip, reloadTimerCallbackID
    reloadTimerCallbackID = resetCallback(reloadTimerCallbackID)
    if duration > 0.0:
        leftTime = duration if leftTime != 0.0 else (duration - startTime)
        endReloadTime = time() + leftTime
        reloadTimerCallbackID = callback(0.1, reloadTimer)
    else:
        leftTime = 0.0
    if (baseTime != 0.0) and ((reloadTimeClip is None) or
                              (abs(reloadTimeClip - baseTime) > 0.01)):
        reloadTime = baseTime
    if not isAutoReload:
        as_event('ON_RELOAD')
예제 #9
0
def autoReloading(duration, baseTime):
    global autoReloadLeftTime, autoReloadTime, endAutoReloadTime, autoReloadTimerCallbackID, endReloadTime, leftTime, reloadTime
    _currentReloadTimeInClip = autoReloadTimes[quantityInClipShells]
    factor = (baseTime /
              _currentReloadTimeInClip) if _currentReloadTimeInClip != 0 else 0
    autoReloadTime = factor * reloadTimesClip[0]
    # log('autoReloadTime = %s, factor = %s, reloadTimesClip[0] = %s' % (autoReloadTime, factor, reloadTimesClip[0]))
    autoReloadTimerCallbackID = resetCallback(autoReloadTimerCallbackID)
    if duration > 0.0:
        autoReloadLeftTime = duration + factor * reloadTimesClip[
            quantityInClipShells + 1]
        leftTime = duration
        currentTime = time()
        endAutoReloadTime = currentTime + autoReloadLeftTime
        endReloadTime = currentTime + duration
        autoReloadTimerCallbackID = callback(0.1, autoReloadTimer)
    else:
        leftTime = autoReloadLeftTime = 0.0
    reloadTime = baseTime
    # log('autoReloading: [%s] autoReloadTime = %s, factor = %s, autoReloadLeftTime = %s' % (quantityInClipShells, autoReloadTime, factor, autoReloadLeftTime))
    as_event('ON_RELOAD')
예제 #10
0
 def update(self):
     if self.callbackID is None:
         self.callbackID = callback(self.DELAY, self.__refresh)