hxp
2018-10-19 6bb604a064530782efec7afd865ee919a4bc6616
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_186.py
@@ -40,7 +40,6 @@
import PyGameData
import BuffSkill
import GameObj
import ItemCommon
## 初始化
#  @param curNPC 当前npc
@@ -103,15 +102,12 @@
    tagObj = None # 即将攻击的目标, 归属最大伤血取最大伤血玩家或队伍队员,其他取最大仇恨
    ownerType, ownerID = 0, 0
    dropOwnerType = NPCCommon.GetDropOwnerType(curNPC)
    if isDead:
        GameWorld.Log("Boss死亡: lineID=%s,objID=%s,npcID=%s,dropOwnerType=%s"
                      % (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), curNPC.GetNPCID(), dropOwnerType))
    if dropOwnerType == ChConfig.DropOwnerType_MaxHurt:
        maxHurtObj = npcControl.RefreshHurtList(tick, refreshInterval)
        if maxHurtObj:
            ownerType, ownerID = maxHurtObj.GetValueType(), maxHurtObj.GetValueID()
            if ownerType == ChConfig.Def_NPCHurtTypeTeam:
                tagObj = __GetMaxHurtTeamPlayer(curNPC, npcControl, ownerID, isDead)
                tagObj = __GetMaxHurtTeamPlayer(curNPC, npcControl, ownerID)
            elif ownerType == ChConfig.Def_NPCHurtTypePlayer:
                tagObj = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
                
@@ -120,9 +116,6 @@
        if ownerInfo:
            tagObj, ownerFamilyID = ownerInfo
            ownerType, ownerID = ChConfig.Def_NPCHurtTypeFamily, ownerFamilyID
    if isDead:
        GameWorld.Log("ownerType=%s, ownerID=%s, tagObjID=%s" % (ownerType, ownerID, 0 if not tagObj else tagObj.GetPlayerID()))
            
    # 没有攻击目标,则刷新仇恨,支持主动怪
    if not tagObj:
@@ -142,36 +135,22 @@
                ownerType, ownerID = ChConfig.Def_NPCHurtTypeTeam, teamID
            else:
                ownerType, ownerID = ChConfig.Def_NPCHurtTypePlayer, maxAngryObj.GetPlayerID()
        if isDead:
            GameWorld.Log("angryObj, ownerType=%s, ownerID=%s" % (ownerType, ownerID))
    __RefreshBossDropOwnerObjBuff(curNPC, npcControl, tick, ownerType, ownerID, isDead)
    return tagObj
def __GetMaxHurtTeamPlayer(curNPC, npcControl, teamID, isDead):
def __GetMaxHurtTeamPlayer(curNPC, npcControl, teamID):
    ## 获取最大伤血队伍中攻击的目标队员
    curTeam = GameWorld.GetTeamManager().FindTeam(teamID)
    if curTeam:
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        if isDead:
            GameWorld.Log("队伍成员数: teamID=%s,memberCount=%s" % (teamID, curTeam.GetMemberCount()))
        for i in xrange(curTeam.GetMemberCount()):
            curTeamPlayer = curTeam.GetMember(i)
            if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                if isDead:
                    GameWorld.Log("    i=%s, 队员为空!" % i)
                continue
            if curTeamPlayer.GetHP() <= 0:
                if isDead:
                    GameWorld.Log("    i=%s, 队员血量为0!, memPlayerID=%s" % (i, curTeamPlayer.GetPlayerID()))
                continue
            if isDead:
                GameWorld.Log("    i=%s, 队员坐标(%s, %s)! memPlayerID=%s" % (i, curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), curTeamPlayer.GetPlayerID()))
            if npcControl.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint):
                return curTeamPlayer
    else:
        GameWorld.ErrLog("找不到该队伍: teamID=%s" % teamID)
    return
def __RefreshBossDropOwnerObjBuff(curNPC, npcControl, tick, ownerType=0, ownerID=0, isDead=False):
@@ -184,10 +163,9 @@
    lastDropOwnerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
    lastDropOwnerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
    
    key = (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), npcID)
    if lastDropOwnerID and (lastDropOwnerType != ownerType or lastDropOwnerID != ownerID):
        GameWorld.Log("归属变更, 清除旧归属! key=%s,ownerType=%s,ownerID=%s,lastDropOwnerType=%s,lastDropOwnerID=%s"
                      % (key, ownerType, ownerID, lastDropOwnerType, lastDropOwnerID))
        GameWorld.DebugLog("归属变更, 清除旧归属! ownerType=%s,ownerID=%s,lastDropOwnerType=%s,lastDropOwnerID=%s"
                           % (ownerType, ownerID, lastDropOwnerType, lastDropOwnerID))
        __DelBossDropOwnerBuff(curNPC, lastDropOwnerType, lastDropOwnerID, tick)
    
    killerDict, curTeam, hurtType, hurtID = {}, None, 0, 0
@@ -196,9 +174,6 @@
    curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerID, ownerID)
    curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerType, ownerType)
    
    if isDead:
        GameWorld.Log("Boss归属: key=%s,ownerType=%s,ownerID=%s" % (key, ownerType, ownerID))
    # 刷新归属
    if ownerType == ChConfig.Def_NPCHurtTypePlayer:
        curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
@@ -215,14 +190,11 @@
        
        # 因为有击杀次数限制,所以不是所有的队员都可以获得归属,所以这里设置为特殊指定玩家掉落
        hurtType, hurtID = ChConfig.Def_NPCHurtTypeSpecial, 0
        if isDead:
            GameWorld.Log("队伍成员数: %s" % (curTeam.GetMemberCount()))
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        for i in xrange(curTeam.GetMemberCount()):
            curTeamPlayer = curTeam.GetMember(i)
            if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                if isDead:
                    GameWorld.Log("    i=%s, 成员不存在!" % (i))
                continue
            
            if curTeamPlayer.GetCopyMapID() == GameWorld.GetGameWorld().GetCopyMapID() \
@@ -230,20 +202,12 @@
                and AttackCommon.CheckKillNPCByCnt(curTeamPlayer, curNPC, False):
                __AddBossDropOwnerPlayerBuff(curTeamPlayer, tick, curNPC)
                killerDict[curTeamPlayer.GetPlayerID()] = curTeamPlayer
                if isDead:
                    GameWorld.Log("    i=%s, 成员有归属权! memPlayerID=%s,背包剩余空格=%s"
                                  % (i, curTeamPlayer.GetPlayerID(), ItemCommon.GetItemPackSpace(curTeamPlayer, IPY_GameWorld.rptItem)))
            # 不同线、或者距离超出boss范围的队员不加归属buff
            else:
                isOk = BuffSkill.DelBuffBySkillID(curTeamPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
                if isOk:
                    GameWorld.DebugLog("删除归属队员buff: teamID=%s,playerID=%s" % (ownerID, curTeamPlayer.GetPlayerID()))
                if isDead:
                    GameWorld.Log("    i=%s, 成员无归属权! memPlayerID=%s,copyMapID=%s,pos(%s,%s),CheckKillNPCByCnt=%s"
                                  % (i, curTeamPlayer.GetPlayerID(), curTeamPlayer.GetCopyMapID(),
                                     curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(),
                                     AttackCommon.CheckKillNPCByCnt(curTeamPlayer, curNPC, False)))
                    
    elif ownerType == ChConfig.Def_NPCHurtTypeFamily:
        
@@ -265,7 +229,7 @@
                    GameWorld.DebugLog("删除非归属仙盟成员buff: teamID=%s,playerID=%s" % (ownerID, player.GetPlayerID()))
            
    if isDead:
        #key = (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), npcID)
        key = (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), npcID)
        teamID = curTeam.GetTeamID() if curTeam else 0
        if killerDict:
            PyGameData.g_npcKillerInfo[key] = killerDict, curTeam, hurtType, hurtID