hxp
2018-10-19 6bb604a064530782efec7afd865ee919a4bc6616
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -4014,16 +4014,10 @@
        npcID = curNPC.GetNPCID()
        mapID = GameWorld.GetMap().GetMapID()
        mapID = FBCommon.GetRecordMapID(mapID)
        isGameBoss = ChConfig.IsGameBoss(curNPC)
        if isGameBoss:
            GameWorld.Log("NPC开始掉落: npcID=%s,dropPlayerID=%s" % (npcID, dropPlayer.GetPlayerID()))
        if mapID == ChConfig.Def_FBMapID_MunekadoTrial:
            return
        ipyDrop = GetNPCDropIpyData(npcID)
        if not ipyDrop:
            if isGameBoss:
                curWorldLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
                GameWorld.ErrLog("取不到NPC掉落信息!npcID=%s,curWorldLV=%s" % (npcID, curWorldLV))
            return
        
        #if mapID == ChConfig.Def_FBMapID_MunekadoTrial:
@@ -4272,11 +4266,9 @@
        self.__LastHurtPlayer = self.__FindLastTimeHurtObjEx()
        self.__MaxHurtPlayer = self.__FindBossMaxHurtObj() # py自定义伤血所得到的Boss最大伤血玩家
        
        isGameBoss = ChConfig.IsGameBoss(curNPC)
        self.__AllKillerDict, curTeam, hurtType, hurtID = self.__FindNPCKillerInfo(isGameBoss)
        self.__AllKillerDict, curTeam, hurtType, hurtID = self.__FindNPCKillerInfo()
        self.__OwnerHurtType, self.__OwnerHurtID = hurtType, hurtID
        if isGameBoss:
            GameWorld.Log("npcID=%s,hurtType=%s,hurtID=%s" % (npcID, hurtType, hurtID))
        isGameBoss = ChConfig.IsGameBoss(curNPC)
        
        #最后一击处理
        self.__DoLastTimeHurtLogic()
@@ -4385,7 +4377,7 @@
    ## NPC死亡, 分享经验逻辑
    #  @param self 类实例
    #  @return 返回击杀玩家信息元组, (玩家列表实例,队伍实例,归属类型,归属ID)
    def __FindNPCKillerInfo(self, isGameBoss):
    def __FindNPCKillerInfo(self):
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        objID = curNPC.GetID()
@@ -4404,39 +4396,36 @@
        
        #isLog = self.__GetIsLog()
        dropOwnerType = GetDropOwnerType(curNPC)
        if isGameBoss:
            GameWorld.Log("NPC被击杀, key=%s,dropOwnerType=%s" % (key, dropOwnerType))
        #GameWorld.DebugLog("NPC击杀者信息...npcID=%s,dropOwnerType=%s" % (npcID, dropOwnerType))
        # 最大伤血 - 伤血可能被重置
        if dropOwnerType == ChConfig.DropOwnerType_MaxHurt:
            npcHurtList = curNPC.GetPlayerHurtList()
            npcHurtList.Sort()
            if isGameBoss:
                GameWorld.Log("hurtCount=%s" % (npcHurtList.GetHurtCount()))
            #if isLog:
            #    GameWorld.DebugLog("NPC被击杀,npcID=%s,dropOwnerType=%s,hurtCount=%s" % (npcID, dropOwnerType, npcHurtList.GetHurtCount()))
            for i in xrange(npcHurtList.GetHurtCount()):
                #获得最大伤血对象
                maxHurtObj = npcHurtList.GetHurtAt(i)
                if isGameBoss:
                    GameWorld.Log("hurtIndex=%s,hurtValueType=%s,valueID=%s" % (i, maxHurtObj.GetValueType(), maxHurtObj.GetValueID()))
                curPlayer, curTeam = self.__GetTagByHurtObj(maxHurtObj, isLog=isGameBoss)
                #if isLog:
                #    GameWorld.DebugLog("    i=%s,hurtValueType=%s,valueID=%s" % (i, maxHurtObj.GetValueType(), maxHurtObj.GetValueID()))
                curPlayer, curTeam = self.__GetTagByHurtObj(maxHurtObj)
                #当前伤血对象超出指定范围或已经死亡
                if curPlayer == None and curTeam == None:
                    if isGameBoss:
                        GameWorld.Log("    当前伤血对象超出指定范围或已经死亡")
                    #if isLog:
                    #    GameWorld.DebugLog("        当前伤血对象超出指定范围或已经死亡")
                    continue
                
                if curPlayer:
                    playerID = curPlayer.GetPlayerID()
                    if playerID not in killerDict:
                        killerDict[playerID] = curPlayer
                    if isGameBoss:
                        GameWorld.Log("    归属最大伤血玩家: npcID=%s,dropOwnerType=%s,playerID=%s" % (npcID, dropOwnerType, playerID))
                    GameWorld.Log("    归属最大伤血玩家: npcID=%s,dropOwnerType=%s,playerID=%s" % (npcID, dropOwnerType, playerID))
                    return killerDict, None, ChConfig.Def_NPCHurtTypePlayer, playerID
                
                if curTeam:
                    killTeam = curTeam
                    if isGameBoss:
                        GameWorld.Log("    归属最大伤血队伍: npcID=%s,dropOwnerType=%s,teamID=%s" % (npcID, dropOwnerType, curTeam.GetTeamID()))
                    GameWorld.Log("    归属最大伤血队伍: npcID=%s,dropOwnerType=%s,teamID=%s" % (npcID, dropOwnerType, curTeam.GetTeamID()))
                    return killerDict, curTeam, ChConfig.Def_NPCHurtTypeTeam, curTeam.GetTeamID()
        # 最大伤血玩家 - 伤血不会被重置
        elif dropOwnerType == ChConfig.DropOwnerType_MaxHurtPlayer:
@@ -4466,8 +4455,8 @@
        if self.__LastHurtPlayer:
            lastHurtPlayerID = self.__LastHurtPlayer.GetPlayerID()
            teamID = self.__LastHurtPlayer.GetTeamID()
            if isGameBoss:
                GameWorld.Log("    归属最后一击,npcID=%s,lastHurtPlayerID=%s,teamID=%s" % (npcID, lastHurtPlayerID, teamID))
            #if isLog:
            #    GameWorld.DebugLog("    归属最后一击,npcID=%s,lastHurtPlayerID=%s,teamID=%s" % (npcID, lastHurtPlayerID, teamID))
            if teamID:
                killTeam = GameWorld.GetTeamManager().FindTeam(teamID)
            if not killTeam and lastHurtPlayerID not in killerDict:
@@ -4475,8 +4464,9 @@
                
        if dropOwnerType == ChConfig.DropOwnerType_All:
            hurtType = ChConfig.Def_NPCHurtTypeAll
            if isGameBoss:
                GameWorld.Log("    无归属...npcID=%s" % npcID)
            #if isLog:
            #    GameWorld.DebugLog("    无归属...npcID=%s" % npcID)
            #GameWorld.DebugLog("    无归属...")
            
        elif dropOwnerType == ChConfig.DropOwnerType_Faction:
            #阵营归属
@@ -4484,22 +4474,23 @@
            if protectFaction > 0:
                hurtType = ChConfig.Def_NPCHurtTypeFaction
                hurtID = protectFaction
                if isGameBoss:
                    GameWorld.Log("    阵营归属...factionID=%s" % protectFaction)
                #GameWorld.DebugLog("    阵营归属...factionID=%s" % protectFaction)
                
        if hurtType == 0:
            #归属队伍
            if killTeam:
                hurtType = ChConfig.Def_NPCHurtTypeTeam
                hurtID = killTeam.GetTeamID()
                if isGameBoss:
                    GameWorld.Log("    归属默认队伍, npcID=%s,teamID=%s" % (npcID, hurtID))
                #if isLog:
                #    GameWorld.DebugLog("    归属默认队伍, npcID=%s,teamID=%s" % (npcID, hurtID))
                #GameWorld.DebugLog("    归属默认队伍, teamID=%s" % hurtID)
            #伤血归属玩家
            elif killerDict:
                hurtType = ChConfig.Def_NPCHurtTypePlayer
                hurtID = killerDict.keys()[0]
                if isGameBoss:
                    GameWorld.Log("    归属默认玩家, npcID=%s,playerID=%s" % (npcID, hurtID))
                #if isLog:
                #    GameWorld.DebugLog("    归属默认玩家, npcID=%s,playerID=%s" % (npcID, hurtID))
                #GameWorld.DebugLog("    归属默认玩家, playerID=%s" % hurtID)
                
        return killerDict, killTeam, hurtType, hurtID
    
@@ -4570,10 +4561,9 @@
    #  @param maxHurtObj 最大伤血对象
    #  @return 返回值, 伤血对象
    #  @remarks 获得伤血对象,支持抢怪
    def __GetTagByHurtObj(self, maxHurtObj, isCheckRefreshArea=False, isLog=False):
    def __GetTagByHurtObj(self, maxHurtObj, isCheckRefreshArea=False):
        #获得死亡的NPC
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        # 伤害的obj类型元组(玩家, 队伍)
        hurtObjTuple = (None, None)
        if maxHurtObj == None:
@@ -4588,28 +4578,18 @@
            curPlayer = GameWorld.GetObj(maxHurtObj.GetValueID(), IPY_GameWorld.gotPlayer)
            
            if curPlayer == None:
                if isLog:
                    GameWorld.Log("找不到该目标伤血玩家: npcID=%s,playerID=%s" % (npcID, maxHurtObj.GetValueID()))
                return hurtObjTuple
            
            #支持抢怪,个人杀死,但自己死亡,不算
            if curPlayer.GetHP() <= 0 or curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
                if isLog:
                    GameWorld.Log("该目标伤血玩家已死亡: npcID=%s,playerID=%s" % (npcID, maxHurtObj.GetValueID()))
                return hurtObjTuple
            
            if isCheckRefreshArea:
                if not self.GetIsInRefreshPoint(curPlayer.GetPosX(), curPlayer.GetPosY(), refreshPoint):
                    if isLog:
                        GameWorld.Log("该目标伤血玩家不在NPC区域内: npcID=%s,playerID=%s,pos(%s,%s)"
                                      % (npcID, maxHurtObj.GetValueID(), curPlayer.GetPosX(), curPlayer.GetPosY()))
                    return hurtObjTuple
            #如果玩家已经超出指定距离,不加经验
            elif GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(),
                                     curPlayer.GetPosX(), curPlayer.GetPosY()) > ChConfig.Def_Team_GetExpScreenDist:
                if isLog:
                    GameWorld.Log("该目标伤血玩家超出指定距离: npcID=%s,playerID=%s,npcPos(%s,%s),playerPos(%s,%s)"
                                  % (npcID, maxHurtObj.GetValueID(), curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY()))
                return hurtObjTuple
            
            #正常返回
@@ -4620,39 +4600,23 @@
            #获得当前队伍
            teamID = maxHurtObj.GetValueID()
            curTeam = GameWorld.GetTeamManager().FindTeam(teamID)
            if isLog:
                GameWorld.Log("目标伤血队伍: npcID=%s,teamID=%s" % (npcID, teamID))
            if curTeam == None:
                if isLog:
                    GameWorld.Log("找不到目标队伍, teamID=%s" % (teamID))
                return hurtObjTuple
            
            if isLog:
                GameWorld.Log("队伍成员数: GetMemberCount=%s" % (curTeam.GetMemberCount()))
            #遍历队伍,半径为一屏半的距离内的所有队伍/团队成员,可以获得经验
            for i in xrange(curTeam.GetMemberCount()):
                curTeamPlayer = curTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    if isLog:
                        GameWorld.Log("    i=%s, 无该队员!" % (i))
                    continue
                
                if curTeamPlayer.GetHP() <= 0 or curTeamPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
                    if isLog:
                        GameWorld.Log("    i=%s, 队员已死亡!memPlayerID=%s" % (i, curTeamPlayer.GetPlayerID()))
                    continue
                
                if isCheckRefreshArea:
                    if not self.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint):
                        if isLog:
                            GameWorld.Log("    i=%s, 队员不在NPC区域内!memPlayerID=%s,pos(%s,%s)"
                                          % (i, curTeamPlayer.GetPlayerID(), curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY()))
                        continue
                elif GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTeamPlayer.GetPosX(),
                                       curTeamPlayer.GetPosY()) > ChConfig.Def_Team_GetExpScreenDist:
                    if isLog:
                        GameWorld.Log("    i=%s, 队员超出指定距离!memPlayerID=%s,npcPos(%s,%s),playerPos(%s,%s)"
                                      % (i, curTeamPlayer.GetPlayerID(), curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY()))
                    continue
                
                hurtObjTuple = (None, curTeam)
@@ -4885,7 +4849,7 @@
    def __GetIsLog(self):
        ## 测试查错日志,临时用
        ## 相关bug: 仙界秘境无经验、boss无掉落
        return ChConfig.IsGameBoss(self.__Instance)
        return False
        #return GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_BZZD or ChConfig.IsGameBoss(self.__Instance)
    #---------------------------------------------------------------------