Пример #1
0
def FightWithPlayer(dynamicId, characterId, tid):
    '''玩家PK
    @param dynamicId: int 客户端的动态id
    @param characterId: int 角色的id
    @param tid: int 对方的id
    '''
    res = CanDoServer(characterId)
    if not res['result']:
        return res
    player = PlayersManager().getPlayerByID(characterId)
    if not player or not player.CheckClient(dynamicId):
        return {'result': False, 'message': Lg().g(18)}
    toplayer = PlayersManager().getPlayerByID(tid)
    if not toplayer:
        return {'result': False, 'message': Lg().g(66)}
    guildid = player.guild.getID()
    tguildid = toplayer.guild.getID()
    town = player.baseInfo.getTown()
    ttown = toplayer.baseInfo.getTown()
    if not player.pvp.checktime():
        return {'result': False, 'message': u"PK战斗CD中"}
    if not toplayer.pvp.checktime():
        return {'result': False, 'message': u"对方PK战斗CD中"}
    if town != ttown:
        return {'result': False, 'message': u"不在统一场景无法进行战斗"}
    if player.guild.getID() == toplayer.guild.getID() or 0 in [
            guildid, tguildid
    ]:
        return {'result': False, 'message': u"不允许本国之间战斗"}
    level = player.level.getLevel()
    tlevel = player.level.getLevel()
    if level < 25 or tlevel < 25:
        return {'result': False, 'message': u"低于25级不能进行战斗"}
    player.pvp.recordtime()
    toplayer.pvp.recordtime()
    data = DoFight([player], [toplayer], now_X=550)
    #战后的处理
    battleresult = data.battleResult
    nowscene = MapManager().getMapId(ttown)  #获取当前场景
    if battleresult == 1:  #如果主动方胜利
        nowscene.dropPlayer(tid)  #在当前场景中移除被攻击的玩家
        toscene = MapManager().getMapId(1000)  #扔回其他场景
        toscene.addPlayer(tid)
        toscene.pushEnterPlace([toplayer.dynamicId])
        toplayer.baseInfo.setTown(1000)
    else:
        nowscene.dropPlayer(characterId)  #在当前场景中移主动攻击的玩家
        toscene = MapManager().getMapId(1000)  #扔回其他场景
        toscene.addPlayer(characterId)
        toscene.pushEnterPlace([player.dynamicId])
        player.baseInfo.setTown(1000)
    return {
        'result': True,
        'data': data,
        'sendlist': [dynamicId, toplayer.dynamicId]
    }
Пример #2
0
def updateSceneInfo(rate):
    '''更新场景中角色的位置'''
    try:
        MapManager().pushAllSceneInfo(rate)
        MapManager().produceMonster()


#        InstanceManager().pushAllInstanceInfo(rate)
    finally:
        reactor.callLater(rate, updateSceneInfo, rate)
Пример #3
0
def moveInScene(dynamicId, characterId, sceneId, x, y):
    '''在场景中移动
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    @param x: int 移动到的x坐标
    @param y: int 移动到的y坐标 
    '''
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return
    if x == -1 and y == -1:
        if player.baseInfo.getState() == 1:  #如果角色在副本
            sceneId = player.baseInfo.getLocation()  #获取角色所在场景Id
            #            id=player.baseInfo.getInstanceid() #副本模板Id
            dtid = player.baseInfo.getInstancetag()  #副本动态Id
            instance = InstanceManager().getInstanceByIdTag(dtid)  #获取副本实例
            sceneId = instance._Scenes.keys()[0]
            nowScene = instance._Scenes[sceneId]  #获取场景实例
            nowScene.pushNowScenePosition(dynamicId, characterId)
        else:
            scene = MapManager().getMapId(sceneId)
            scene.pushNowScenePosition(dynamicId, characterId)
        return
    if not player:
        return {'result': False, 'message': Lg().g(18)}
    if player.baseInfo.getStatus() != 1:
        return {
            'result': False,
            'message': u'您正处于%s状态' % player.baseInfo.getStatusName()
        }
    player.baseInfo.updateDestination((x, y))
Пример #4
0
def FightInScene(dynamicId, characterId, monsterId):
    '''副本战斗
    @param dynamicId: int 客户端的动态id
    @param characterId: int 角色的id
    @param monsterId: int 碰撞的怪物在场景中的id
    '''
    res = CanDoServer(characterId)
    if not res['result']:
        return res
    player = PlayersManager().getPlayerByID(characterId)
    if not player.CheckClient(dynamicId):
        return {'result': False, 'message': Lg().g(18)}
    if not player.status.getLifeStatus():
        return {'result': False, 'message': Lg().g(97)}
    if player.baseInfo.getState() == 1:  #如果角色在副本
        dtid = player.baseInfo.getInstancetag()  #副本动态Id
        instance = InstanceManager().getInstanceByIdTag(dtid)  #获取副本实例
        sceneId = player.baseInfo.getLocation()
        nowScene = instance._Scenes[sceneId]  #获取场景实例
    else:
        town = player.baseInfo.getTown()
        nowScene = MapManager().getMapId(town)
#        return {'result':False,'message':Lg().g(64)}
    data = nowScene.FightInScene(monsterId,
                                 int(player.baseInfo.getPosition()[0]),
                                 characterId)
    if data.get('result'):
        player.baseInfo.setStatus(4)  #角色状态设置为战斗状态
    return data
Пример #5
0
def NetConnLost_2(dynamicId):
    '''loginout'''
    player = PlayersManager().getPlayerBydynamicId(dynamicId)
    if not player:
        return True
    try:
        tag = player.baseInfo.getInstancetag()  #副本动态Id
        InstanceManager().dropInstanceById(tag)  #如果角色下线的时候在副本中,就清空副本
        player.afk.stopMeditation()  #在线挂机结算
        player.updatePlayerDBInfo()
        #        player.qhtime.dbupdate()#记录角色强化冷却时间
        player.nobility.dbupdate()  #记录爵位限制信息
        player.petShop.dbupdate()  #记录宠物商店信息
        #        publicnoderemote.callRemote('dropPCharacter',player.baseInfo.id)
        PlayersManager().dropPlayer(player)
        state = player.baseInfo.getState()
        if state == 0:
            sceneId = player.baseInfo.getTown()
            scene = MapManager().getMapId(sceneId)
            scene.dropPlayer(player.baseInfo.id)
            if player.baseInfo.getState() == 0:
                scene.dropPlayer(player.baseInfo.id)
                for petId, pet in player.pet._pets.items():
                    if pet.getFlowFlag():
                        scene.dropPet(petId)
    except Exception as ex:
        log.err(ex)
    finally:
        return True
Пример #6
0
def loadModule():
    from app.scense.nodeapp import *
    #    from app.scense.publicnodeapp import *
    from app.scense.chatnodeapp import *
    dbScene.getALlInstanceSceneInfo()
    dbScene.getAllPublicSceneInfo()
    dbPortals.getAllPortalsInfo()
    dbStrengthen.getAll()
    dbInstance_colonize_title.updateAll()  #更新殖民头衔配置
    dbNpc.getAllNpcInfo()
    dbAward.getAllAwardInfo()
    dbSchedule.getAllScheduleBound()
    dbSchedule.getAllScheduleConfig()
    dbdaily.getAllDaily()
    dbGodhead.getAllGodhead()
    dbGodhead.getAllHeadtype()
    dbItems.getAllsetInfo()
    dbItems.getAllGemInfo()
    dbItems.getAllCompoundInfo()
    dbMonster.getAllMonsterInfo()
    dbMap.getAllDoorInfo()
    dbMap.getAllMonsterConfig()
    dbMap.getAllMapInfo()
    GuildManager()
    MapManager()
    serviceByStart.doService()
    updateInstanceInfo(1)
    updateSceneInfo(1)
    cleanMeM(1800)
Пример #7
0
 def getSceneName(self):
     '''获取角色当前场景名称 return str'''
     from app.scense.world.scene import Scene
     from app.scense.core.map.MapManager import MapManager
     if self._state < 0:
         return Lg().g(272)
     sceneId = self._owner.baseInfo.getTown()
     scene = MapManager().getMapId(sceneId)
     return scene._name
Пример #8
0
def backScnee(pid, instanceid, boo):
    '''角色退出殖民战斗,返回城镇场景
    @param pid: int 角色id
    @param instanceid: int 副本id
    @param boo: bool 战斗结果
    '''
    player = PlayersManager().getPlayerByID(pid)
    player.msgbox.AfterFightMsgHandle()
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.addPlayer(pid)
    scene.pushEnterPlace([player.getDynamicId()])
Пример #9
0
def goto(characterId,argument):
    '''跳转场景
    @param characterId: int 角色的ID
    '''
    if len(argument)<1:
        return 
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return
    from app.scense.core.map.MapManager import MapManager
    placeId = int(argument[0])
    lastscene = MapManager().getMapId(player.baseInfo.getTown())
    scene = MapManager().getMapId(placeId)
    if not scene:
        return
    player.baseInfo.setTown( placeId)
    player.baseInfo.setState(0)
    player.baseInfo.initPosition((300,300))
    scene.addPlayer(characterId)
    player.quest.setNpcList(scene._npclist)
    dynamicId = player.dynamicId
    scene.pushEnterPlace([dynamicId])
    lastscene.dropPlayer(characterId)
Пример #10
0
def ModifyPetStatus(dynamicId, characterId, petId):
    '''更新宠物的携带状态'''
    from app.scense.core.map.MapManager import MapManager
    player = PlayersManager().getPlayerByID(characterId)
    if not player:
        return {'result': False, 'message': Lg().g(18)}
    result = player.pet.updateShow(petId)
    msg = result.get('message', '')
    if result.get('result'):
        if result.get('data'):
            if player.baseInfo.getState() == 0:  #如果角色在场景中
                sceneId = player.baseInfo.getTown()
                scene = MapManager().getMapId(sceneId)
                scene.dropPet(petId)
    if msg:
        pushOtherMessage(905, msg, [dynamicId])
    return result
Пример #11
0
def getBattlePlayer(instanceid, cid):
    '''副本殖民战斗,返回对手实例'''
    from app.scense.core.instance.Instance import Instance
    from app.scense.core.map.MapManager import MapManager
    player = PlayersManager().getPlayerByID(cid)  #获取角色实例
    if player.baseInfo._state != 0:  #如果在普通场景
        return False, Lg().g(144), False


#    cityid=InstanceGroupManage().getcityidBygroupid(instanceid)
#    if player.baseInfo._town!=cityid:
#        pushObjectNetInterface.pushOtherMessage(905, u'只能殖民本场景的副本', [player.getDynamicId()])
#        return False,u'只能殖民本场景的副本',False

    if player.level._level <= 12:
        return False, Lg().g(145), False

    guildLevel = player.guild.getGuildLevel()  #当前角色行会等级
    if guildLevel < 1:  #没有国
        return False, Lg().g(146), False

    zmcount = int(math.ceil((guildLevel / 5.0)))  #可殖民副本数量
    yydata = 0  #该角色已殖民数量
    for info in ColonizeManage().getI().values():
        if info['pid'] == cid:
            yydata += 1
    if zmcount <= yydata:
        pushObjectNetInterface.pushOtherMessage(905,
                                                Lg().g(147),
                                                [player.getDynamicId()])
        return False, Lg().g(147), False

    player.schedule.noticeSchedule(17, goal=1)
    tlist = []
    sceneId = player.baseInfo.getTown()
    scene = MapManager().getMapId(sceneId)
    scene.dropPlayer(cid)
    allInfo = instance_app.allInfo
    info = allInfo.get(instanceid)
    downlevel = info.get('downlevle', 0)  #殖民等级
    if downlevel > player.level.getLevel():  #如果角色等级<副本等级要求
        return False, Lg().g(148), False

    instancegroupid = InstanceGroupManage().getFristInstanceBy(
        instanceid)  #根据副本id获取副本组id
    pid = ColonizeManage().getpidByinstanceid(
        instancegroupid)  #通过副本组id获得副本殖民者id
    mosterid = 15001
    if pid < 1:  #如果此副本没有被殖民
        try:
            mosterid = instanceColonizeChallenge.getColonizeChallengeByMosterid(
                instancegroupid)  #获取怪物id
            if mosterid < 0:
                log.err(u'殖民战斗当中副本组中没有配置对应的殖民挑战怪物,殖民副本组id为%d' %
                        instancegroupid)
        except Exception as e:
            log.err(u'殖民战斗当中副本组中没有配置对应的殖民挑战怪物,殖民副本组id为%d' % instancegroupid)
            log.err(e.message)

        tlist.append(Monster(templateId=mosterid))
    else:  #如果此副本被殖民了
        py = PlayersManager().getPlayerByID(pid)
        if not py:
            py = PlayerCharacter(pid)
        tlist.append(py)
    instance = Instance(instanceid)  #副本
    scene = instance.getScene(instance._inSceneid)  #第一个场景实例
    del instance
    zon = random.randint(500, scene._width - 500)
    return tlist, zon, scene.formatSceneInfo()  #场景资源id