Example #1
0
    def handleKey(self, key, isDown, offset):
        cmdMap = CommandMapping.g_instance
        if cmdMap.isFired(CommandMapping.CMD_RADIAL_MENU_SHOW, key):
            if isDown:
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if self.__currentVehicleDesc is not None:
                    self.__currentTarget = BigWorld.target()
                    mouseUsedForShow = getScaleformKey(key) <= BW_TO_SCALEFORM[Keys.KEY_MOUSE7]
                    self.__onMenuShow(offset, mouseUsedForShow)
            else:
                self.__onMenuHide()
        elif isDown:
            if not self.__ingameMenuIsVisible():
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if not self.__showed:
                    self.__currentTarget = BigWorld.target()
                for command in self.KEYB_MAPPINGS:
                    shortcut = self.KEYB_CMDS_MAPPINGS[command]
                    if cmdMap.isFired(getattr(CommandMapping, shortcut), key):
                        action = self.__getMappedCommand(command)
                        if action not in self.DENIED_KEYB_CMDS:
                            self.onAction(action)

        return
Example #2
0
    def handleKey(self, key, isDown, offset):
        cmdMap = CommandMapping.g_instance
        if cmdMap.isFired(CommandMapping.CMD_RADIAL_MENU_SHOW, key):
            if isDown:
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if self.__currentVehicleDesc is not None:
                    self.__currentTarget = BigWorld.target()
                    mouseUsedForShow = getScaleformKey(key) <= BW_TO_SCALEFORM[
                        Keys.KEY_MOUSE7]
                    self.__onMenuShow(offset, mouseUsedForShow)
            else:
                self.__onMenuHide()
        elif isDown:
            if not self.__ingameMenuIsVisible():
                if self.__currentVehicleDesc is None:
                    self.__currentVehicleDesc = self.__getCurrentVehicleDesc()
                if not self.__showed:
                    self.__currentTarget = BigWorld.target()
                for command in self.KEYB_MAPPINGS:
                    shortcut = self.KEYB_CMDS_MAPPINGS[command]
                    if cmdMap.isFired(getattr(CommandMapping, shortcut), key):
                        action = self.__getMappedCommand(command)
                        if action not in self.DENIED_KEYB_CMDS:
                            self.onAction(action)

        return
    def find_autoaim_target(self):
        auto_aim_vehicle = property(lambda self_other: BigWorld.entities.get(self_other.__autoAimVehID, None))
        print('find_autoaim_target', auto_aim_vehicle)
        if auto_aim_vehicle is None and BigWorld.target() is not None:
            return BigWorld.target()
        player = BigWorld.player()
        vehicles = player.arena.vehicles
        camera_dir, camera_pos = cameras.getWorldRayAndPoint(0, 0)
        camera_dir.normalise()
        result_len = None
        las_vehicle = None
        min_radian = 100000.0
        for vId, vData in vehicles.items():
            if vData['team'] == player.team:
                continue
            vehicle = BigWorld.entity(vId)
            if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
                continue
            temp1, radian = self._calc_radian(vehicle.position, self.angle_autoaim) #1.289 градуса в радианах

            if not temp1 and temp1 is not None:
                continue
            length = self._calc_length(vehicle.position, BigWorld.player().position)
            if radian:
                if result_len is None:
                    result_len = length
                    las_vehicle = vehicle
                if radian < min_radian and result_len >= length:
                    min_radian = radian
                    las_vehicle = vehicle
        result = las_vehicle
        if result is not None:
            if BigWorld.wg_collideSegment(BigWorld.player().spaceID, BigWorld.entity(result.id).appearance.modelsDesc['gun']['model'].position, camera_pos, False) is None:
                return result
        return BigWorld.target()
Example #4
0
def find_autoaimtarget(self):
    #AutoaimSelf._PlayerAvatar__autoAimVehID
    autoAimVehicle = property(
        lambda self: BigWorld.entities.get(self.__autoAimVehID, None))
    if autoAimVehicle is None and BigWorld.target() is not None:
        return BigWorld.target()
    player = BigWorld.player()
    vehicles = player.arena.vehicles
    cameraDir, cameraPos = cameras.getWorldRayAndPoint(0, 0)
    cameraDir.normalise()

    result = None
    result_len = None
    las_vehicle = None
    minRadian = 100000.0
    for vId, vData in vehicles.items():
        if vData['team'] == player.team:
            continue
        vehicle = BigWorld.entity(vId)
        if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
            continue
        temp1, Radian = calc_radian(vehicle.position, radians_angle_autoaim,
                                    minRadian)  #1.289 градуса в радианах

        if temp1 == False:
            continue
        len = cacl_lengh(vehicle.position, BigWorld.player().position)
        if Radian:
            debugs('%s, distance: %dm., Angle = %.2f degrees' %
                   (vehicle.id, len, math.degrees(Radian)))
            if result_len is None:
                result_len = len
                las_vehicle = vehicle
            if Radian < minRadian and result_len >= len:
                minRadian = Radian
                las_vehicle = vehicle
                debugs(
                    'Set priority: %s, distance: %dm., Angle = %.2f degrees' %
                    (las_vehicle.id, result_len, math.degrees(minRadian)))
    result = las_vehicle

    #if BigWorld.wg_collideSegment(BigWorld.player().spaceID, result.position, cameraPos,False) == None:
    #    debugs('get visible target: %s' % (result.id))
    #    return result
    if result is not None:
        if BigWorld.wg_collideSegment(
                BigWorld.player().spaceID,
                BigWorld.entity(
                    result.id).appearance.modelsDesc['gun']['model'].position,
                cameraPos, False) == None:
            debugs('get visible gun target: %s' % (result.id))
            return result
        debugs('target gun: %s not visible' % (result.id))
    return BigWorld.target()
    def getDynamicArc(self, vehicle, vehicleTypeDescriptor, vehicleMatrix, turretYawRad, cameraTurretYawRad, gunPitch):
        if self.isCamAngle:
            turretYaw = cameraTurretYawRad
        else:
            turretYaw = turretYawRad

        playerVehiclePos = BigWorld.player().getOwnVehiclePosition()

        if ME_Tank.hullHeight is None:
            hullMin, hullMax, _ = vehicleTypeDescriptor.hull.hitTester.bbox
            ME_Tank.hullHeight = hullMin + hullMax
        hullHeightHitVector = ME_Tank.hullHeight * self.hitHullHeight
        fakeHitHullHeight = hullHeightHitVector.y + vehicleTypeDescriptor.chassis.hullPosition.y

        shotRay, shotPoint = self.getShotRayAndPoint(vehicleTypeDescriptor, vehicleMatrix, turretYaw, gunPitch)

        if self.useTargetGunY and BigWorld.target() is not None:
            # noinspection PyBroadException
            try:
                currTarget = BigWorld.target()
                fakeShotStart_ = shotPoint + utills.getNormalisedVector(shotRay).scale(self.rayLength)
                fakeShotAimPoint_ = playerVehiclePos + utills.getNormalisedVector(self.upDir).scale(fakeHitHullHeight)
                fakeShotStart_.y = fakeShotAimPoint_.y
                fakeShotStart = BigWorld.entity(currTarget.id).appearance.compoundModel.node('gun').position
                fakeShotAimPoint = playerVehiclePos + utills.getNormalisedVector(self.upDir).scale(fakeHitHullHeight)
            except Exception as eTargetGunY:
                utills.eDebug(eTargetGunY, "error with eAP.useTargetGunY and BigWorld.target() is not None")
                fakeShotStart = shotPoint + utills.getNormalisedVector(shotRay).scale(self.rayLength)
                fakeShotAimPoint = playerVehiclePos + utills.getNormalisedVector(self.upDir).scale(fakeHitHullHeight)
                if self.useGunPitch:
                    fakeShotStart.y = fakeShotAimPoint.y
        else:
            fakeShotStart = shotPoint + utills.getNormalisedVector(shotRay).scale(self.rayLength)
            fakeShotAimPoint = playerVehiclePos + utills.getNormalisedVector(self.upDir).scale(fakeHitHullHeight)
            if self.useGunPitch:
                fakeShotStart.y = fakeShotAimPoint.y

        fakeShotDir = fakeShotAimPoint - fakeShotStart
        # Only really interested in the hitAngleCos and Distance from collideVehicle. Distance to pass on to debug render
        try:
            dist, hitAngleCos, _ = utills.collideVehicle(vehicle, fakeShotStart, fakeShotAimPoint, skipGun=True)
        except Exception as e2:
            # TODO - Use last known angle or save initial angles at start of match and fall back to the old non-dynamic method
            utills.eDebug("Error:", e2, "error getting dynamic armor angle, use armor at 45 degrees as total angle.")
            hitAngleCos = 0.785398163397
            dist = 8.0

        if debugRender.drawDebugRender:
            fakeShotHitPos = fakeShotStart + utills.getNormalisedVector(fakeShotDir).scale(dist)
            debugRender.render(fakeShotHitPos, fakeShotStart)

        realArmorAngle = 90 - math.degrees(hitAngleCos)
        return realArmorAngle
Example #6
0
def new_ChatCommandsController_handleShortcutChatCommand(self, key):
    player = BigWorld.player()
    target = BigWorld.target()
    # Target substitution begins.
    config = g_config['plugins']['radialMenu']
    if target is None and config['useTargetScan']:
        targetScanner = getattr(player.inputHandler, 'XTargetScanner', None)
        if targetScanner is not None:
            target = targetScanner.scanTarget().target
    if target is None and config['useTargetInfo']:
        targetInfo = getattr(player.inputHandler, 'XTargetInfo', None)
        if targetInfo is not None and not targetInfo.isExpired:
            target = targetInfo.getVehicle()
    # Target substitution ends.
    for chatCommand, keyboardCommand in gui.battle_control.controllers.chat_cmd_ctrl.KB_MAPPING.iteritems(
    ):
        if CommandMapping.g_instance.isFired(keyboardCommand, key):
            crosshairType = self._ChatCommandsController__getCrosshairType(
                player, target)
            action = chatCommand
            if crosshairType != gui.battle_control.controllers.chat_cmd_ctrl.DEFAULT_CUT:
                if chatCommand in gui.battle_control.controllers.chat_cmd_ctrl.TARGET_TRANSLATION_MAPPING:
                    if crosshairType in gui.battle_control.controllers.chat_cmd_ctrl.TARGET_TRANSLATION_MAPPING[
                            chatCommand]:
                        action = gui.battle_control.controllers.chat_cmd_ctrl.TARGET_TRANSLATION_MAPPING[
                            chatCommand][crosshairType]
            if action in gui.battle_control.controllers.chat_cmd_ctrl.TARGET_ACTIONS:
                if crosshairType != gui.battle_control.controllers.chat_cmd_ctrl.DEFAULT_CUT:
                    self.handleChatCommand(action, target.id)
            else:
                self.handleChatCommand(action)
    return
Example #7
0
 def catch(self):
     # noinspection PyProtectedMember
     if self.player._PlayerAvatar__autoAimVehID: return
     if BigWorld.target() is not None: return
     if self.player.isObserver(): return
     playerPosition = self.player.getOwnVehiclePosition()
     minRadian = 100000.0
     result = None
     result_len = None
     for vId, vData in self.player.arena.vehicles.iteritems():
         if vData['team'] != self.player.team and vData['isAlive']:
             vehicle = BigWorld.entity(vId)
             if vehicle is not None and vehicle.isStarted and vehicle.isAlive(
             ):
                 radian = self.calc_radian(
                     vehicle.position,
                     self.angle)  # 1.289 градуса в радианах
                 if radian:
                     length = Math.Vector3(vehicle.position -
                                           playerPosition).length
                     if result_len is None:
                         result_len = length
                         result = vehicle
                     if radian < minRadian and result_len >= length:
                         minRadian = radian
                         result = vehicle
     if config.data['catchHiddenTarget']:
         self.player.autoAim(result)
         return result if result is not None else None
     if result is not None and BigWorld.wg_collideSegment(
             self.player.spaceID, result.position,
             cameras.getWorldRayAndPoint(0, 0)[1], 128) is None:
         self.player.autoAim(result)
         return result if result is not None else None
     return
Example #8
0
def new_RadialMenu_show(self):
    player = BigWorld.player()
    target = BigWorld.target()
    # Target substitution begins.
    config = g_config['plugins']['radialMenu']
    if target is None and config['useTargetScan']:
        targetScanner = getattr(player.inputHandler, 'XTargetScanner', None)
        if targetScanner is not None:
            target = targetScanner.scanTarget().target
    if target is None and config['useTargetInfo']:
        targetInfo = getattr(player.inputHandler, 'XTargetInfo', None)
        if targetInfo is not None and not targetInfo.isExpired:
            target = targetInfo.getVehicle()
    # Target substitution ends.
    self._RadialMenu__targetID = target.id if target is not None else None
    ctrl = self.sessionProvider.shared.crosshair
    guiScreenWidth, guiScreenHeight = GUI.screenResolution()
    screenRatio = float(guiScreenWidth / BigWorld.screenWidth()), float(
        guiScreenHeight / BigWorld.screenHeight())
    screenPosition = ctrl.getDisaredPosition() if ctrl is not None else (
        guiScreenWidth * 0.5, guiScreenHeight * 0.5)
    crosshairType = self._RadialMenu__getCrosshairType(player, target)
    if self.app is not None:
        self.app.registerGuiKeyHandler(self)
    self.as_showS(crosshairType, screenPosition, screenRatio)
    return
def getSPGShotResult(targetPosition,
                     shotIdx,
                     shotPos,
                     shotVel,
                     shotGravity,
                     player=None,
                     target=None):
    if player is None:
        player = BigWorld.player()
    shotResult = SPGShotResultEnum.NOT_HIT
    if targetPosition is None or player is None:
        return shotResult
    else:
        vehicleDescriptor = player.getVehicleDescriptor()
        shotDescr = vehicleDescriptor.getShot(shotIdx)
        minBounds, maxBounds = player.arena.getSpaceBB()
        endPos, _, collData, usedMaxDistance = AimingSystems.getCappedShotTargetInfos(
            shotPos, shotVel, shotGravity, shotDescr, player.playerVehicleID,
            minBounds, maxBounds, CollisionStrategy.COLLIDE_DYNAMIC_AND_STATIC)
        if not usedMaxDistance:
            if collData is None and (
                    endPos -
                    targetPosition).lengthSquared < _SPG_SHOT_RESULT_TOLERANCE:
                shotResult = SPGShotResultEnum.HIT
            elif collData is not None and collData.isVehicle():
                if target is None:
                    target = BigWorld.target()
                if isinstance(target, VehicleEntity):
                    targetVehicleID = target.id
                else:
                    targetVehicleID = None
                if targetVehicleID == collData.entity.id:
                    shotResult = SPGShotResultEnum.HIT
        return shotResult
Example #10
0
	def getTarget(self):
		target = BigWorld.target()
		if VehicleInfo.isVehicle(target):
			if self.filterID is None or self.filterID(target.id):
				if self.filterVehicle is None or self.filterVehicle(target):
					return target
		return None
Example #11
0
def inj_hkKeyEvent(event):
    BattleApp = g_appLoader.getDefBattleApp()
    try:
        if BattleApp and _config.data['enabled']:
            isDown = PYmodsCore.checkKeys(_config.data['mapMenu_key'])
            if isDown or _config.wasAltMenuPressed:
                _config.wasAltMenuPressed = isDown
                CommandMapping.g_instance.onMappingChanged()
            if event.isKeyDown():
                target = BigWorld.target()
                player = BigWorld.player()
                commandsData = _config.commands.get(
                    _config.activeConfigs[_config.data['selectedConfig']], {})
                state = getCrosshairType(player, target)
                menuConf, _ = findBestFitConf(commandsData)
                commandsList = commandsData.get('hotkeyOnly', [])
                if menuConf is not None:
                    commandsList.extend(menuConf.get(state, []))
                for command in commandsList:
                    if command and command.handleKeys(command.hotKeys):
                        BigWorld.callback(
                            _config.data['hotDelay'] / 1000.0,
                            partial(onCustomAction, command, target))
    except StandardError:
        print 'RadialMenu: ERROR at inj_hkKeyEvent'
        traceback.print_exc()
    def ally_silouhette(self):
        if self.__enableRenderModel:
            try:
                BigWorld.wgSetEdgeDetectColors((self.__color, self.__enemyhigh, self.__allyhigh))
                player = BigWorld.player()
                if player is not None:
                    if hasattr(player, 'isOnArena'):
                        curCtrl = getattr(getattr(BigWorld.player(), 'inputHandler', None), 'ctrl', None)
                        if player.isOnArena:
                            for v in BigWorld.entities.values():
                                if isinstance(v, Vehicle):
                                    if v.isAlive() and v.isStarted:
                                        if v.publicInfo['team'] is BigWorld.player().team:
                                            target = BigWorld.target()
                                            if BigWorld.entity(BigWorld.player().playerVehicleID) is not None and BigWorld.entity(v.id) is not None:
                                                distance = (BigWorld.entity(BigWorld.player().playerVehicleID).position - BigWorld.entity(v.id).position).length
                                            else:
                                                distance = 1
                                            if target is not None and target.id == v.id:
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                                BigWorld.wgAddEdgeDetectEntity(v, 2, False)
                                            elif int(v.id) != int(BigWorld.player().playerVehicleID) and distance <= self.__distancevalue or self.__sniperonly == True and not isinstance(curCtrl, SniperControlMode):
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                            elif int(v.id) == int(BigWorld.player().playerVehicleID):
                                                continue
                                            else:
                                                BigWorld.wgDelEdgeDetectEntity(v)
                                                BigWorld.wgAddEdgeDetectEntity(v, 0, False)
                                    else:
                                        BigWorld.wgDelEdgeDetectEntity(v)

            except TypeError as err:
                print ('[ally_silouhette] Error: ', err)

        return
def find_autoaimtarget(self):
    #AutoaimSelf._PlayerAvatar__autoAimVehID
    autoAimVehicle = property(lambda self: BigWorld.entities.get(self.__autoAimVehID, None))
    if autoAimVehicle is None and BigWorld.target() is not None:
        return BigWorld.target()
    player = BigWorld.player()
    vehicles = player.arena.vehicles
    cameraDir, cameraPos = cameras.getWorldRayAndPoint(0, 0)
    cameraDir.normalise()


    
    result = None
    result_len = None
    las_vehicle = None
    minRadian = 100000.0
    for vId, vData in vehicles.items():
        if vData['team'] == player.team:
            continue
        vehicle = BigWorld.entity(vId)
        if vehicle is None or not vehicle.isStarted or not vehicle.isAlive():
            continue
        temp1, Radian = calc_radian(vehicle.position, radians_angle_autoaim, minRadian) #1.289 градуса в радианах
        
        if temp1 == False:
            continue
        len = cacl_lengh(vehicle.position, BigWorld.player().position)
        if Radian:
            debugs('%s, distance: %dm., Angle = %.2f degrees' % (vehicle.id, len, math.degrees(Radian)))
            if result_len is None:
                result_len = len
                las_vehicle = vehicle
            if Radian < minRadian and result_len >= len:
                minRadian = Radian
                las_vehicle = vehicle
                debugs('Set priority: %s, distance: %dm., Angle = %.2f degrees' % (las_vehicle.id, result_len, math.degrees(minRadian)))
    result = las_vehicle
    
    #if BigWorld.wg_collideSegment(BigWorld.player().spaceID, result.position, cameraPos,False) == None:
    #    debugs('get visible target: %s' % (result.id))
    #    return result
    if result is not None:
        if BigWorld.wg_collideSegment(BigWorld.player().spaceID, BigWorld.entity(result.id).appearance.modelsDesc['gun']['model'].position, cameraPos,False) == None:
            debugs('get visible gun target: %s' % (result.id))
            return result
        debugs('target gun: %s not visible' % (result.id))
    return BigWorld.target()
Example #14
0
def PlayerAvatar_handleKey(self, isDown, key, mods):
    if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices:
        cmdMap = CommandMapping.g_instance
        #print 'PlayerAvatar_handleKey {0} {1} {2}'.format(cmdMap.isFired(CommandMapping.CMD_CHAT_SHORTCUT_ATTACK, key), isDown, self._PlayerAvatar__maySeeOtherVehicleDamagedDevices)
        if isDown and cmdMap.isFired(CommandMapping.CMD_CHAT_SHORTCUT_ATTACK, key):
            setNewTarget(BigWorld.target())

    return oldPlayerAvatar_handleKey(self, isDown, key, mods)
Example #15
0
def PlayerAvatar_handleKey(self, isDown, key, mods, *args):
    if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices:
        cmdMap = CommandMapping.g_instance
        #print 'PlayerAvatar_handleKey {0} {1} {2}'.format(cmdMap.isFired(CommandMapping.CMD_CHAT_SHORTCUT_ATTACK, key), isDown, self._PlayerAvatar__maySeeOtherVehicleDamagedDevices)
        if isDown and cmdMap.isFired(CommandMapping.CMD_CHAT_SHORTCUT_ATTACK, key):
            setNewTarget(BigWorld.target())

    return oldPlayerAvatar_handleKey(self, isDown, key, mods, *args)
Example #16
0
def ModCallBack():
	player = BigWorld.player()
	if hasattr(player, 'isOnArena') and player.isOnArena:
		validControlMode = False
		for controlMode in player.inputHandler.ctrls:
			if controlMode in g_modSetting['controlModes'] and player.inputHandler.ctrl == player.inputHandler.ctrls[controlMode]:
				validControlMode = True
				break
		
		for vehicle in player.vehicles:	
			if not vehicle.isAlive():
				continue
			
			isFriend = player.team == vehicle.publicInfo['team']
			if isFriend:
				if not g_modSetting['isFriendBlur'] or player.playerVehicleID == vehicle.id:
					continue
			else:
				if not g_modSetting['isEnemyBlur']:
					continue
			
			isTarget = BigWorld.target() and BigWorld.target().id == vehicle.id
			if isTarget:
				vehicle.removeEdge()
				vehicle.drawEdge(2 if isFriend else 1, 0)
				continue
			
			if not validControlMode:
				vehicle.removeEdge()
				continue
			
			distToVeh = (BigWorld.camera().position - vehicle.position).length
			if distToVeh > g_modSetting['distanceToBlur']:
				if not isInAngle(vehicle.position) or distToVeh > g_modSetting['disAngleToBlur']:
					vehicle.removeEdge()
					continue
			
			if g_modSetting['isFullBlur'] and isRayAtVehicle(BigWorld.camera().position, vehicle.appearance.modelsDesc['gun']['model'].position):
				vehicle.removeEdge()
				continue
			
			vehicle.drawEdge(3 if g_modSetting['isCustomColors'] else 0, 0 if g_modSetting['isFullBlur'] else 1)
			
	BigWorld.callback(0.1, ModCallBack)
	
	return
Example #17
0
def getCrosshairType():
    target = BigWorld.target()
    player = BigWorld.player()
    if type(target) is Vehicle.Vehicle and __getIsLive(player, target.id):
        if not __getIsFriendly(player, target.id):
            return 'enemy'
        else:
            return 'ally'
    return 'default'
Example #18
0
def target(player, string):
    """Send a chat message to the targeted player"""
    t = BigWorld.target()
    if t:
        try:
            t.cell.directedChat(player.id, string)
            FantasyDemo.addChatMsg(player.id, '[To ' + t.playerName + '] ' + string)
        except:
            pass
Example #19
0
 def _getTargetDisplayName(self):
     target = BigWorld.target()
     if target is not None:
         arenaDP = self.sessionProvider.getArenaDP()
         if arenaDP is not None:
             vInfo = arenaDP.getVehicleInfo(target.id)
             if vInfo is not None:
                 return vInfo.player.name
     return
Example #20
0
def magneticAimProcessor(previousSimpleTarget=None,
                         previousMagneticTarget=None):
    if BigWorld.target() is None:
        target = magneticAimFindTarget()
        if target and target != previousSimpleTarget and target != previousMagneticTarget:
            gui_event_dispatcher.addAutoAimMarker(vehicle=target)
            BigWorld.player().autoAim(target=target, magnetic=True)
            return target
    return previousSimpleTarget
Example #21
0
def target(player, string):
    t = BigWorld.target()
    if t:
        try:
            t.cell.directedChat(player.id, string)
            FantasyDemo.addChatMsg(player.id,
                                   '[To ' + t.playerName + '] ' + string)
        except:
            pass
Example #22
0
def target(player, string):
    """Send a chat message to the targeted player"""
    t = BigWorld.target()
    if t:
        try:
            t.cell.directedChat(player.id, string)
            FantasyDemo.addChatMsg(player.id, '[To ' + t.playerName + '] ' + string)
        except:
            pass
def attackEnemyCommandOnSight(avatar, target):
    global lastAttackCommandTime

    if ((BigWorld.serverTime() - lastAttackCommandTime) >
            battleMessagesConfig['attackCommandOnSight']['timeout']) and (
                BigWorld.target() == target):
        avatar.guiSessionProvider.shared.chatCommands.sendTargetedCommand(
            BATTLE_CHAT_COMMAND_NAMES.ATTACK_ENEMY, target.id)

    lastAttackCommandTime = BigWorld.serverTime()
Example #24
0
    def find_autoaim_target(self):
        auto_aim_vehicle = property(lambda self_other: BigWorld.entities.get(
            self_other.__autoAimVehID, None))
        print('find_autoaim_target', auto_aim_vehicle)
        if auto_aim_vehicle is None and BigWorld.target() is not None:
            return BigWorld.target()
        player = BigWorld.player()
        vehicles = player.arena.vehicles
        camera_dir, camera_pos = cameras.getWorldRayAndPoint(0, 0)
        camera_dir.normalise()
        result_len = None
        las_vehicle = None
        min_radian = 100000.0
        for vId, vData in vehicles.items():
            if vData['team'] == player.team:
                continue
            vehicle = BigWorld.entity(vId)
            if vehicle is None or not vehicle.isStarted or not vehicle.isAlive(
            ):
                continue
            temp1, radian = self._calc_radian(
                vehicle.position,
                self.angle_autoaim)  #1.289 градуса в радианах

            if not temp1 and temp1 is not None:
                continue
            length = self._calc_length(vehicle.position,
                                       BigWorld.player().position)
            if radian:
                if result_len is None:
                    result_len = length
                    las_vehicle = vehicle
                if radian < min_radian and result_len >= length:
                    min_radian = radian
                    las_vehicle = vehicle
        result = las_vehicle
        if result is not None:
            if BigWorld.wg_collideSegment(
                    BigWorld.player().spaceID,
                    BigWorld.entity(result.id).appearance.modelsDesc['gun']
                ['model'].position, camera_pos, False) is None:
                return result
        return BigWorld.target()
Example #25
0
 def handleShortcutChatCommand(self, key):
     cmdMap = CommandMapping.g_instance
     import BigWorld
     player = BigWorld.player()
     target = BigWorld.target()
     for chatCmd, keyboardCmd in KB_MAPPING.iteritems():
         if cmdMap.isFired(keyboardCmd, key):
             crosshairType = self.__getCrosshairType(player, target)
             if crosshairType != DEFAULT_CUT and chatCmd in TARGET_TRANSLATION_MAPPING and crosshairType in TARGET_TRANSLATION_MAPPING[chatCmd]:
                 self.handleChatCommand(TARGET_TRANSLATION_MAPPING[chatCmd][crosshairType], target.id)
             else:
                 self.handleChatCommand(chatCmd)
Example #26
0
 def _onNotifyCursorOver3dScene(self, isCursorOver3dScene):
     if self.__selected3DEntity:
         if isCursorOver3dScene:
             self.__highlight3DEntity(self.__selected3DEntity)
         else:
             self.__fade3DEntity(self.__selected3DEntity)
     else:
         targetEntity = BigWorld.target()
         if targetEntity is not None:
             if isCursorOver3dScene and self._filterEntity(targetEntity):
                 self.__onMouseEnter(targetEntity)
     return
def ArcadeControlModehandleKeyEvent(self, isDown, key, mods, event = None):
    cmdMap = CommandMapping.g_instance
    isFiredFreeCamera = cmdMap.isFired(CommandMapping.CMD_CM_FREE_CAMERA, key)
    isFiredLockTarget = cmdMap.isFired(CommandMapping.CMD_CM_LOCK_TARGET, key) and isDown
    if isFiredFreeCamera or isFiredLockTarget:
        if isFiredFreeCamera:
            self.setAimingMode(isDown, AIMING_MODE.USER_DISABLED)
        if isFiredLockTarget:
            if XML['setup'].readBool('module_autoaim_optimize') == True:
                BigWorld.player().autoAim(find_autoaimtarget(self))
            else:
                BigWorld.player().autoAim(BigWorld.target())
        return True
    else:
        OldArcadeControlModehandleKeyEvent(self, isDown, key, mods, event)
Example #28
0
 def handleShortcutChatCommand(self, key):
     cmdMap = CommandMapping.g_instance
     import BigWorld
     player = BigWorld.player()
     target = BigWorld.target()
     for chatCmd, keyboardCmd in KB_MAPPING.iteritems():
         if cmdMap.isFired(keyboardCmd, key):
             crosshairType = self.__getCrosshairType(player, target)
             if crosshairType != DEFAULT_CUT and chatCmd in TARGET_TRANSLATION_MAPPING and crosshairType in TARGET_TRANSLATION_MAPPING[
                     chatCmd]:
                 self.handleChatCommand(
                     TARGET_TRANSLATION_MAPPING[chatCmd][crosshairType],
                     target.id)
             else:
                 self.handleChatCommand(chatCmd)
Example #29
0
def ArcadeControlModehandleKeyEvent(self, isDown, key, mods, event=None):
    cmdMap = CommandMapping.g_instance
    isFiredFreeCamera = cmdMap.isFired(CommandMapping.CMD_CM_FREE_CAMERA, key)
    isFiredLockTarget = cmdMap.isFired(CommandMapping.CMD_CM_LOCK_TARGET,
                                       key) and isDown
    if isFiredFreeCamera or isFiredLockTarget:
        if isFiredFreeCamera:
            self.setAimingMode(isDown, AIMING_MODE.USER_DISABLED)
        if isFiredLockTarget:
            if XML['setup'].readBool('module_autoaim_optimize') == True:
                BigWorld.player().autoAim(find_autoaimtarget(self))
            else:
                BigWorld.player().autoAim(BigWorld.target())
        return True
    else:
        OldArcadeControlModehandleKeyEvent(self, isDown, key, mods, event)
Example #30
0
def calltext():
    try:
        chatType = getCrosshairType()
        target = BigWorld.target()
        player = BigWorld.player()
        if target is None:
            target = BigWorld.entities.get(player.playerVehicleID)
        curVariantList = _config.i18n[chatType + 'Text']
        msg, _config.lastRandID[chatType] = PYmodsCore.pickRandomPart(
            curVariantList, _config.lastRandID[chatType])
        if '{name}' in msg:
            msg = msg.format(name=target.publicInfo.name)
        if msg:
            PYmodsCore.sendChatMessage(msg, 1, 1.0)
    except StandardError:
        traceback.print_exc()
 def handleShortcutChatCommand(self, key):
     cmdMap = CommandMapping.g_instance
     player = BigWorld.player()
     target = BigWorld.target()
     for chatCmd, keyboardCmd in KB_MAPPING.iteritems():
         if cmdMap.isFired(keyboardCmd, key):
             action = chatCmd
             crosshairType = self.__getCrosshairType(player, target)
             if crosshairType != DEFAULT_CUT and chatCmd in TARGET_TRANSLATION_MAPPING and crosshairType in TARGET_TRANSLATION_MAPPING[chatCmd]:
                 action = TARGET_TRANSLATION_MAPPING[chatCmd][crosshairType]
             if action in TARGET_ACTIONS:
                 if crosshairType == OBJECTIVE_CUT:
                     self.sendAttentionToObjective(target.destructibleEntityID, player.team == EPIC_BATTLE_TEAM_ID.TEAM_ATTACKER)
                 elif crosshairType != DEFAULT_CUT:
                     self.handleChatCommand(action, targetID=target.id)
             else:
                 self.handleChatCommand(action)
Example #32
0
 def show(self):
     player = BigWorld.player()
     target = BigWorld.target()
     self.__targetID = target.id if target is not None else None
     screenWidth = BigWorld.screenWidth()
     screenHeight = BigWorld.screenHeight()
     guiScreenWidth, guiScreenHeight = GUI.screenResolution()
     ratioWidth = float(guiScreenWidth / screenWidth)
     ratioHeight = float(guiScreenHeight / screenHeight)
     ratio = (ratioWidth, ratioHeight)
     crosshairType = self.__getCrosshairType(player, target)
     ctrl = g_sessionProvider.shared.crosshair
     if ctrl is not None:
         position = ctrl.getPosition()
     else:
         position = (guiScreenWidth >> 1, guiScreenHeight >> 1)
     self.as_showS(crosshairType, position, ratio)
     return
Example #33
0
 def show(self):
     player = BigWorld.player()
     target = BigWorld.target()
     self.__targetID = target.id if target is not None else None
     screenWidth = BigWorld.screenWidth()
     screenHeight = BigWorld.screenHeight()
     guiScreenWidth, guiScreenHeight = GUI.screenResolution()
     ratioWidth = float(guiScreenWidth / screenWidth)
     ratioHeight = float(guiScreenHeight / screenHeight)
     ratio = (ratioWidth, ratioHeight)
     crosshairType = self.__getCrosshairType(player, target)
     ctrl = g_sessionProvider.shared.crosshair
     if ctrl is not None:
         position = ctrl.getPosition()
     else:
         position = (guiScreenWidth >> 1, guiScreenHeight >> 1)
     self.as_showS(crosshairType, position, ratio)
     return
Example #34
0
def shoot(base, self, isRepeat = False):
    if not (safeShotConfig['enabled'] and safeShotEnabled):
        base(self, isRepeat)
        return
    player = BigWorld.player()
    target = BigWorld.target()
    if target is None:
        if safeShotConfig['wasteShotBlock']:
            addClientMessage(safeShotConfig['wasteShotBlockedMessage'])
            return
    else:
        if safeShotConfig['teamShotBlock'] and (player.team is target.publicInfo.team):
            if not (safeShotConfig['teamKillerShotUnblock'] and player.guiSessionProvider.getArenaDP().isTeamKiller(target.id)):
                addClientMessage(safeShotConfig['teamShotBlockedMessage'])
                return
        elif safeShotConfig['deadShotBlock'] and not target.isAlive():
            addClientMessage(safeShotConfig['deadShotBlockedMessage'])
            return
    base(self, isRepeat)
Example #35
0
def PlayerAvatar_showOtherVehicleDamagedDevices(self, vehicleID, damagedExtras,
                                                destroyedExtras):
    #print 'PlayerAvatar_showOtherVehicleDamagedDevices'
    global gExpertTarget
    target = gExpertTarget or BigWorld.target()
    if target is None or not isinstance(target, Vehicle.Vehicle):
        if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices and vehicleID != 0:
            self.cell.monitorVehicleDamagedDevices(0)
            #print 'PlayerAvatar_showOtherVehicleDamagedDevices monitor {0}'.format(0)
            #FLUSH_LOG()
    elif target.id == vehicleID:
        g_windowsManager.battleWindow.damageInfoPanel.show(
            vehicleID, damagedExtras, destroyedExtras)
    else:
        if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices:
            self.cell.monitorVehicleDamagedDevices(target.id)
            #print 'PlayerAvatar_showOtherVehicleDamagedDevices monitor {0}'.format(target.id)
            #FLUSH_LOG()
        g_windowsManager.battleWindow.damageInfoPanel.hide()
Example #36
0
def collide(x, y):
    player = BigWorld.player()
    if player is None:
        return (COLLIDE_OTHER, None)
    else:
        entity = BigWorld.target()
        if entity and entity != player:
            if hasattr(entity, 'intersectMouseCoordinates'):
                locationX, locationY = entity.intersectMouseCoordinates(x, y)
                if locationX != -1 or locationY != -1:
                    return (COLLIDE_ENTITY, entity)
            else:
                return (COLLIDE_ENTITY, entity)
        spaceID = player.spaceID
        src, dst = getMouseTargettingRay()
        terrain = BigWorld.collide(spaceID, src, dst)
        if terrain:
            return (COLLIDE_TERRAIN, terrain[0])
        return (COLLIDE_NONE, dst)
        return
Example #37
0
def collide(x, y):
    player = BigWorld.player()
    if player is None:
        return (COLLIDE_OTHER, None)
    else:
        entity = BigWorld.target()
        if entity and entity != player:
            if hasattr(entity, 'intersectMouseCoordinates'):
                locationX, locationY = entity.intersectMouseCoordinates(x, y)
                if locationX != -1 or locationY != -1:
                    return (COLLIDE_ENTITY, entity)
            else:
                return (COLLIDE_ENTITY, entity)
        spaceID = player.spaceID
        src, dst = getMouseTargettingRay()
        terrain = BigWorld.collide(spaceID, src, dst)
        if terrain:
            return (COLLIDE_TERRAIN, terrain[0])
        return (COLLIDE_NONE, dst)
        return
 def show(self):
     player = BigWorld.player()
     target = BigWorld.target()
     self.__targetID = target.id if target is not None else None
     screenWidth = BigWorld.screenWidth()
     screenHeight = BigWorld.screenHeight()
     guiScreenWidth, guiScreenHeight = GUI.screenResolution()
     ratioWidth = float(guiScreenWidth / screenWidth)
     ratioHeight = float(guiScreenHeight / screenHeight)
     ratio = (ratioWidth, ratioHeight)
     crosshairType = self.__getCrosshairType(player, target)
     ctrl = self.sessionProvider.shared.crosshair
     if ctrl is not None:
         position = ctrl.getDisaredPosition()
     else:
         position = (guiScreenWidth * 0.5, guiScreenHeight * 0.5)
     if self.app is not None:
         self.app.registerGuiKeyHandler(self)
     self.as_showS(crosshairType, position, ratio)
     return
Example #39
0
 def onHotkeyPressed(self, event):
     if not isPlayerAvatar() or not self.data['enabled']:
         return
     isDown = checkKeys(self.data['mapMenu_key'])
     if isDown != self.altMenuActive:
         self.altMenuActive = isDown
         self.updateMenu()
     if not event.isKeyDown():
         return
     target = BigWorld.target()
     player = BigWorld.player()
     state = getCrosshairType(player, target)
     commandsList = self.selectedCommands.get('hotkeyOnly', [])[:]
     menuConf, _ = self.findBestFitConf()
     if menuConf is not None:
         commandsList.extend(menuConf.get(state, []))
     for command in commandsList:
         if command and command.handleKeys(command.hotKeys, event.key):
             command.onCustomAction(
                 target.id if target is not None else None, True)
Example #40
0
 def __getAimedAtVehicleOrObject(self):
     player = BigWorld.player()
     target = BigWorld.target()
     targetID = -1
     markerSubType = INVALID_MARKER_SUBTYPE
     targetMarkerType = MarkerType.INVALID_MARKER_TYPE
     if self.__isTargetCorrect(player, target):
         if isinstance(target, DestructibleEntity.DestructibleEntity):
             targetID = target.destructibleEntityID
             targetMarkerType = MarkerType.HEADQUARTER_MARKER_TYPE
             markerSubType = DefaultMarkerSubType.ENEMY_MARKER_SUBTYPE if avatar_getter.getPlayerTeam(
             ) == EPIC_BATTLE_TEAM_ID.TEAM_ATTACKER else DefaultMarkerSubType.ALLY_MARKER_SUBTYPE
         elif target.publicInfo['team'] == avatar_getter.getPlayerTeam():
             targetID = target.id
             targetMarkerType = MarkerType.VEHICLE_MARKER_TYPE
             markerSubType = DefaultMarkerSubType.ALLY_MARKER_SUBTYPE
         else:
             targetID = target.id
             targetMarkerType = MarkerType.VEHICLE_MARKER_TYPE
             markerSubType = DefaultMarkerSubType.ENEMY_MARKER_SUBTYPE
     return (targetID, targetMarkerType, markerSubType)
Example #41
0
def new_AutoAimControlMode_handleKeyEvent(
        old_AutoAimControlMode_handleKeyEvent,
        self,
        isDown,
        key,
        mods,
        event=None):
    result = old_AutoAimControlMode_handleKeyEvent(self, isDown, key, mods,
                                                   event)
    if not result and CommandMapping.g_instance.get(
            'CMD_CM_LOCK_TARGET') == key and isDown:
        target = BigWorld.target()
        # Target substitution begins.
        if target is None and g_config['plugins']['autoAim']['useTargetScan']:
            targetScanner = getattr(self._aih, 'XTargetScanner', None)
            if targetScanner is not None:
                target = targetScanner.scanTarget().target
        if target is None and g_config['plugins']['autoAim']['useTargetInfo']:
            targetInfo = getattr(self._aih, 'XTargetInfo', None)
            if targetInfo is not None and not targetInfo.isExpired:
                target = targetInfo.getVehicle()
        # Target substitution ends.
        BigWorld.player().autoAim(target)
    return result
Example #42
0
def follow(player, string):
    """Follow the current target"""
    if BigWorld.target() != None:
        player.physics.chase(BigWorld.target(), 2.0, 0.5)
        player.physics.velocity = (0, 0, 6.0)
    return
Example #43
0
	def isTarget(vehicleID):
		target = BigWorld.target()
		return target and target.id == vehicleID
Example #44
0
def getTarget():
    return BigWorld.target()
Example #45
0
def _vehicle():
    vehicle = BigWorld.target()
    if not vehicle:
        vehicle = BigWorld.player().getVehicleAttached()
    return vehicle