def __init__(self, position, equipment):
     _DefaultStrikeSelector.__init__(self, position, equipment)
     _VehiclesSelector.__init__(self, self.__intersected)
     self.hitPosition = position
     myTeam = BigWorld.player().team
     udos = BigWorld.userDataObjects.values()
     myArtyEquipment = [
         x for x in udos
         if isinstance(x, ArtilleryEquipment) and x.team == myTeam
     ]
     if len(myArtyEquipment) > 1:
         LOG_ERROR(
             'This map has multiple (%d) UDO of ArtilleryEquipment for team %d'
             % (len(myArtyEquipment), myTeam))
     myArtyEquipment = myArtyEquipment[0]
     self.__artyEquipmentUDO = myArtyEquipment
     self.__marker = ArtyHitMarker(self.__getArtyShotInfo,
                                   self.__updateMarkerComponent,
                                   self.__getDesiredBombardmentState)
     self.__marker.create()
     self.__marker.enable(None)
     self.__marker.setReloading(0, isReloading=False)
     self.__marker.setupShotParams({
         'maxDistance':
         1000.0,
         'gravity':
         self.__artyEquipmentUDO.gravity
     })
     self.__marker.setGUIVisible(True)
     self.processHover(position)
     self.writeStateToReplay()
     return
Example #2
0
 def __init__(self, position, equipment):
     _DefaultStrikeSelector.__init__(self, position, equipment)
     self.hitPosition = position
     myTeam = BigWorld.player().team
     udos = BigWorld.userDataObjects.values()
     myArtyEquipment = [ x for x in udos if isinstance(x, ArtilleryEquipment) and x.team == myTeam ]
     if len(myArtyEquipment) > 1:
         LOG_ERROR('This map has multiple (%d) UDO of ArtilleryEquipment for team %d' % (len(myArtyEquipment), myTeam))
     myArtyEquipment = myArtyEquipment[0]
     self.__artyEquipmentUDO = myArtyEquipment
     self.__marker = ArtyHitMarker(self.__getArtyShotInfo, self.__updateMarkerComponent, self.__getDesiredBombardmentState)
     self.__marker.create()
     self.__marker.enable(None)
     self.__marker.setReloading(0, isReloading=False)
     self.__marker.setupShotParams({'maxDistance': 1000.0,
      'gravity': self.__artyEquipmentUDO.gravity})
     self.__marker.setGUIVisible(True)
     self.processHover(position)
     self.writeStateToReplay()
     return
class _ArtilleryStrikeSelector(_DefaultStrikeSelector, _VehiclesSelector):

    def __init__(self, position, equipment):
        _DefaultStrikeSelector.__init__(self, position, equipment)
        _VehiclesSelector.__init__(self, self.__intersected)
        self.hitPosition = position
        myTeam = BigWorld.player().team
        udos = BigWorld.userDataObjects.values()
        myArtyEquipment = [ x for x in udos if isinstance(x, ArtilleryEquipment) and x.team == myTeam ]
        if len(myArtyEquipment) > 1:
            LOG_ERROR('This map has multiple (%d) UDO of ArtilleryEquipment for team %d' % (len(myArtyEquipment), myTeam))
        myArtyEquipment = myArtyEquipment[0]
        self.__artyEquipmentUDO = myArtyEquipment
        self.__marker = ArtyHitMarker(self.__getArtyShotInfo, self.__updateMarkerComponent, self.__getDesiredBombardmentState)
        self.__marker.create()
        self.__marker.enable(None)
        self.__marker.setReloading(0, isReloading=False)
        self.__marker.setupShotParams({'maxDistance': 1000.0,
         'gravity': self.__artyEquipmentUDO.gravity})
        self.__marker.setGUIVisible(True)
        self.processHover(position)
        self.writeStateToReplay()
        return

    def destroy(self):
        _DefaultStrikeSelector.destroy(self)
        _VehiclesSelector.destroy(self)
        self.__marker.destroy()
        self.__marker = None
        return

    def setGUIVisible(self, isVisible):
        if self.__marker:
            self.__marker.setGUIVisible(isVisible)

    def onRecreateDevice(self):
        if self.__marker:
            self.__marker.onRecreateDevice()

    def __updateMarkerComponent(self, component):
        component.setupFlatRadialDispersion(self.equipment.areaRadius)

    def __getDesiredBombardmentState(self):
        startPos = self.hitPosition + self.__artyEquipmentUDO.position
        endPos = self.hitPosition
        return (endPos, startPos, self.__artyEquipmentUDO.launchVelocity)

    def __getArtyShotInfo(self):
        launchPosition = self.hitPosition + self.__artyEquipmentUDO.position
        launchVelocity = self.__artyEquipmentUDO.launchVelocity
        gravity = Vector3(0, -self.__artyEquipmentUDO.gravity, 0)
        return (launchPosition, launchVelocity, gravity)

    def processSelection(self, position, reset = False):
        self.hitPosition = position
        if reset:
            return False
        BigWorld.player().setEquipmentApplicationPoint(self.equipment.id[1], self.hitPosition, Vector2(0, 1))
        return True

    def __markerForceUpdate(self):
        self.__marker.update(self.hitPosition, Vector3(0.0, 0.0, 1.0), (10.0, 10.0), 1000.0, None)
        return

    def processHover(self, position, force = False):
        if position is None:
            return
        else:
            if force:
                position = AimingSystems.getDesiredShotPoint(Math.Vector3(position[0], 500.0, position[2]), Math.Vector3(0.0, -1.0, 0.0), True, True, True)
                self.__marker.setPosition(position)
                BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
            else:
                self.__marker.update(position, Vector3(0.0, 0.0, 1.0), (10.0, 10.0), SERVER_TICK_LENGTH, None)
            self.hitPosition = position
            self.writeStateToReplay()
            return

    def tick(self):
        self.highlightVehicles()

    def processReplayHover(self):
        replayCtrl = BattleReplay.g_replayCtrl
        _, self.hitPosition, direction = replayCtrl.getGunMarkerParams(self.hitPosition, Math.Vector3(0.0, 0.0, 0.0))
        self.__marker.update(self.hitPosition, Vector3(0.0, 0.0, 1.0), (10.0, 10.0), SERVER_TICK_LENGTH, None)
        return

    def writeStateToReplay(self):
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isRecording:
            if self.hitPosition is not None:
                replayCtrl.setConsumablesPosition(self.hitPosition)
        return

    def __intersected(self, vehicles):
        vPositions = [ v.position for v in vehicles ]
        pointsInside = self.__marker.component.wg_pointsInside(vPositions)
        for v, isInside in zip(vehicles, pointsInside):
            if isInside:
                yield v
class _ArtilleryStrikeSelector(_DefaultStrikeSelector, _VehiclesSelector):
    def __init__(self, position, equipment):
        _DefaultStrikeSelector.__init__(self, position, equipment)
        _VehiclesSelector.__init__(self, self.__intersected)
        self.hitPosition = position
        myTeam = BigWorld.player().team
        udos = BigWorld.userDataObjects.values()
        myArtyEquipment = [
            x for x in udos
            if isinstance(x, ArtilleryEquipment) and x.team == myTeam
        ]
        if len(myArtyEquipment) > 1:
            LOG_ERROR(
                'This map has multiple (%d) UDO of ArtilleryEquipment for team %d'
                % (len(myArtyEquipment), myTeam))
        myArtyEquipment = myArtyEquipment[0]
        self.__artyEquipmentUDO = myArtyEquipment
        self.__marker = ArtyHitMarker(self.__getArtyShotInfo,
                                      self.__updateMarkerComponent,
                                      self.__getDesiredBombardmentState)
        self.__marker.create()
        self.__marker.enable(None)
        self.__marker.setReloading(0, isReloading=False)
        self.__marker.setupShotParams({
            'maxDistance':
            1000.0,
            'gravity':
            self.__artyEquipmentUDO.gravity
        })
        self.__marker.setGUIVisible(True)
        self.processHover(position)
        self.writeStateToReplay()
        return

    def destroy(self):
        _DefaultStrikeSelector.destroy(self)
        _VehiclesSelector.destroy(self)
        self.__marker.destroy()
        self.__marker = None
        return

    def setGUIVisible(self, isVisible):
        if self.__marker:
            self.__marker.setGUIVisible(isVisible)

    def onRecreateDevice(self):
        if self.__marker:
            self.__marker.onRecreateDevice()

    def __updateMarkerComponent(self, component):
        component.setupFlatRadialDispersion(self.equipment.areaRadius)

    def __getDesiredBombardmentState(self):
        startPos = self.hitPosition + self.__artyEquipmentUDO.position
        endPos = self.hitPosition
        return (endPos, startPos, self.__artyEquipmentUDO.launchVelocity)

    def __getArtyShotInfo(self):
        launchPosition = self.hitPosition + self.__artyEquipmentUDO.position
        launchVelocity = self.__artyEquipmentUDO.launchVelocity
        gravity = Vector3(0, -self.__artyEquipmentUDO.gravity, 0)
        return (launchPosition, launchVelocity, gravity)

    def processSelection(self, position, reset=False):
        self.hitPosition = position
        if reset:
            return False
        BigWorld.player().setEquipmentApplicationPoint(self.equipment.id[1],
                                                       self.hitPosition,
                                                       Vector2(0, 1))
        return True

    def __markerForceUpdate(self):
        self.__marker.update(self.hitPosition, Vector3(0.0, 0.0, 1.0),
                             (10.0, 10.0), 1000.0, None)
        return

    def processHover(self, position, force=False):
        if position is None:
            return
        else:
            if force:
                position = AimingSystems.getDesiredShotPoint(
                    Math.Vector3(position[0], 500.0, position[2]),
                    Math.Vector3(0.0, -1.0, 0.0), True, True, True)
                self.__marker.setPosition(position)
                BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
            else:
                self.__marker.update(position, Vector3(0.0, 0.0, 1.0),
                                     (10.0, 10.0), SERVER_TICK_LENGTH, None)
            self.hitPosition = position
            self.writeStateToReplay()
            return

    def tick(self):
        self.highlightVehicles()

    def processReplayHover(self):
        replayCtrl = BattleReplay.g_replayCtrl
        _, self.hitPosition, direction = replayCtrl.getGunMarkerParams(
            self.hitPosition, Math.Vector3(0.0, 0.0, 0.0))
        self.__marker.update(self.hitPosition, Vector3(0.0, 0.0, 1.0),
                             (10.0, 10.0), SERVER_TICK_LENGTH, None)
        return

    def writeStateToReplay(self):
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isRecording:
            if self.hitPosition is not None:
                replayCtrl.setConsumablesPosition(self.hitPosition)
        return

    def __intersected(self, vehicles):
        vPositions = [v.position for v in vehicles]
        pointsInside = self.__marker.component.wg_pointsInside(vPositions)
        for v, isInside in zip(vehicles, pointsInside):
            if isInside:
                yield v
Example #5
0
class _ArtilleryStrikeSelector(_DefaultStrikeSelector):
    maker = property(lambda self: self.__marker)

    def __init__(self, position, equipment):
        _DefaultStrikeSelector.__init__(self, position, equipment)
        self.hitPosition = position
        myTeam = BigWorld.player().team
        udos = BigWorld.userDataObjects.values()
        myArtyEquipment = [ x for x in udos if isinstance(x, ArtilleryEquipment) and x.team == myTeam ]
        if len(myArtyEquipment) > 1:
            LOG_ERROR('This map has multiple (%d) UDO of ArtilleryEquipment for team %d' % (len(myArtyEquipment), myTeam))
        myArtyEquipment = myArtyEquipment[0]
        self.__artyEquipmentUDO = myArtyEquipment
        self.__marker = ArtyHitMarker(self.__getArtyShotInfo, self.__updateMarkerComponent, self.__getDesiredBombardmentState)
        self.__marker.create()
        self.__marker.enable(None)
        self.__marker.setReloading(0, isReloading=False)
        self.__marker.setupShotParams({'maxDistance': 1000.0,
         'gravity': self.__artyEquipmentUDO.gravity})
        self.__marker.setGUIVisible(True)
        self.processHover(position)
        self.writeStateToReplay()
        return

    def destroy(self):
        self.__marker.destroy()
        self.__marker = None
        return

    def __updateMarkerComponent(self, component):
        component.setupFlatRadialDispersion(self.equipment.areaRadius)

    def __getDesiredBombardmentState(self):
        startPos = self.hitPosition + self.__artyEquipmentUDO.position
        endPos = self.hitPosition
        return (endPos, startPos, self.__artyEquipmentUDO.launchVelocity)

    def __getArtyShotInfo(self):
        launchPosition = self.hitPosition + self.__artyEquipmentUDO.position
        launchVelocity = self.__artyEquipmentUDO.launchVelocity
        gravity = Vector3(0, -self.__artyEquipmentUDO.gravity, 0)
        return (launchPosition, launchVelocity, gravity)

    def processSelection(self, position, reset = False):
        self.hitPosition = position
        if reset:
            return False
        BigWorld.player().setEquipmentApplicationPoint(self.equipment.id[1], self.hitPosition, Vector2(0, 1))
        return True

    def __markerForceUpdate(self):
        self.__marker.update(self.hitPosition, Vector3(0, 0, 1), 10, 1000, None)
        return

    def processHover(self, position, force = False):
        if force:
            self.__marker.setPosition(position)
            BigWorld.callback(SERVER_TICK_LENGTH, self.__markerForceUpdate)
        else:
            self.__marker.update(position, Vector3(0, 0, 1), 10, SERVER_TICK_LENGTH, None)
        self.hitPosition = position
        self.writeStateToReplay()
        return

    def processReplayHover(self):
        replayCtrl = BattleReplay.g_replayCtrl
        _, self.hitPosition, direction = replayCtrl.getGunMarkerParams(self.hitPosition, Math.Vector3(0.0, 0.0, 0.0))
        self.__marker.update(self.hitPosition, Vector3(0, 0, 1), 10, SERVER_TICK_LENGTH, None)
        return

    def writeStateToReplay(self):
        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isRecording:
            if self.hitPosition is not None:
                replayCtrl.setConsumablesPosition(self.hitPosition)
        return