| | |
| | | # @change: "2014-12-31 14:40" Alee 降低NPCAI消耗
|
| | | # @change: "2016-11-22 21:00" hxp 支持添加最大仇恨buff
|
| | | #------------------------------------------------------------------------------
|
| | | """Version = 2016-11-22 21:00"""
|
| | | #"""Version = 2016-11-22 21:00"""
|
| | | #-------------------------------------------------------------------------------
|
| | | import ChConfig
|
| | | import NPCCommon
|
| | | import AICommon
|
| | | import IPY_GameWorld
|
| | | import AttackCommon
|
| | | import GameWorld
|
| | | import BaseAttack
|
| | | import PlayerState
|
| | | import SkillCommon
|
| | | import BuffSkill
|
| | | import GameObj
|
| | |
|
| | | ## 初始化
|
| | |
| | | AICommon.NormalNPCFast_Move(curNPC, tick)
|
| | | return
|
| | |
|
| | | tagObj = __RefreshDropOwner(curNPC, tick)
|
| | | #默认攻击归属者
|
| | | tagObj = npcControl.RefreshDropOwner(tick)
|
| | |
|
| | | if not curNPC.GetIsNeedProcess() or not tagObj:
|
| | | # 先回血,等回满再做其他事情
|
| | |
| | | npcControl.DoHPPerLogic(ChConfig.Def_NPCHurtTypeAll, 0)
|
| | | return
|
| | |
|
| | | def __RefreshDropOwner(curNPC, tick, refreshInterval=3000):
|
| | | ## 刷新boss掉落归属
|
| | | # @return: 可攻击的掉落归属目标玩家
|
| | | |
| | | npcControl = NPCCommon.NPCControl(curNPC)
|
| | | tagObj = None # 即将攻击的目标, 归属最大伤血取最大伤血玩家或队伍队员,其他取最大仇恨
|
| | | ownerType, ownerID = 0, 0
|
| | | dropOwnerType = NPCCommon.GetDropOwnerType(curNPC)
|
| | | 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)
|
| | | elif ownerType == ChConfig.Def_NPCHurtTypePlayer:
|
| | | tagObj = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
|
| | | |
| | | # 没有攻击目标,则刷新仇恨,支持主动怪
|
| | | if not tagObj:
|
| | | angryObjType, maxAngryObj = None, None
|
| | | npcControl.RefreshAngryList(tick, refreshInterval, isUpdAngry=True)
|
| | | maxAngry = npcControl.GetMaxAngryTag()
|
| | | if maxAngry:
|
| | | angryID = maxAngry.GetObjID()
|
| | | angryObjType = maxAngry.GetObjType()
|
| | | #GameWorld.DebugLog("最大仇恨目标: ID=%s, Type=%s" % (angryID, angryObjType))
|
| | | maxAngryObj = GameWorld.GetObj(angryID, angryObjType)
|
| | | |
| | | tagObj = maxAngryObj
|
| | | if dropOwnerType == ChConfig.DropOwnerType_MaxAngry and angryObjType == IPY_GameWorld.gotPlayer and maxAngryObj:
|
| | | teamID = maxAngryObj.GetTeamID()
|
| | | if teamID:
|
| | | ownerType, ownerID = ChConfig.Def_NPCHurtTypeTeam, teamID
|
| | | else:
|
| | | ownerType, ownerID = ChConfig.Def_NPCHurtTypePlayer, maxAngryObj.GetPlayerID()
|
| | | __RefreshBossDropOwnerObjBuff(curNPC, npcControl, tick, ownerType, ownerID)
|
| | | return tagObj
|
| | |
|
| | | def __GetMaxHurtTeamPlayer(curNPC, npcControl, teamID):
|
| | | ## 获取最大伤血队伍中攻击的目标队员
|
| | | curTeam = GameWorld.GetTeamManager().FindTeam(teamID)
|
| | | if curTeam:
|
| | | refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
|
| | | for i in xrange(curTeam.GetMemberCount()):
|
| | | curTeamPlayer = curTeam.GetMember(i)
|
| | | if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
|
| | | continue
|
| | | if curTeamPlayer.GetHP() <= 0:
|
| | | continue
|
| | | if npcControl.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint):
|
| | | return curTeamPlayer
|
| | | return
|
| | |
|
| | | def __RefreshBossDropOwnerObjBuff(curNPC, npcControl, tick, ownerType=0, ownerID=0):
|
| | | npcID = curNPC.GetNPCID()
|
| | | dropOwnerType = NPCCommon.GetDropOwnerType(curNPC)
|
| | | if dropOwnerType not in [ChConfig.DropOwnerType_MaxHurt, ChConfig.DropOwnerType_MaxAngry]:
|
| | | #GameWorld.DebugLog("不需要展示掉落归属的NPC! npcID=%s,dropOwnerType=%s" % (npcID, dropOwnerType))
|
| | | return
|
| | | |
| | | lastDropOwnerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
|
| | | lastDropOwnerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
|
| | | |
| | | if lastDropOwnerID and (lastDropOwnerType != ownerType or lastDropOwnerID != ownerID):
|
| | | GameWorld.DebugLog("归属变更, 清除旧归属! ownerType=%s,ownerID=%s,lastDropOwnerType=%s,lastDropOwnerID=%s" |
| | | % (ownerType, ownerID, lastDropOwnerType, lastDropOwnerID))
|
| | | __DelBossDropOwnerBuff(curNPC, lastDropOwnerType, lastDropOwnerID, tick)
|
| | | |
| | | # 更新归属
|
| | | curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerID, ownerID)
|
| | | curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerType, ownerType)
|
| | | |
| | | # 刷新归属
|
| | | if ownerType == ChConfig.Def_NPCHurtTypePlayer:
|
| | | curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
|
| | | if curPlayer:
|
| | | __AddBossDropOwnerPlayerBuff(curPlayer, tick, curNPC)
|
| | | |
| | | elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
|
| | | curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
|
| | | if not curTeam:
|
| | | return
|
| | | |
| | | refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
|
| | | for i in xrange(curTeam.GetMemberCount()):
|
| | | curTeamPlayer = curTeam.GetMember(i)
|
| | | if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
|
| | | continue
|
| | | |
| | | if curTeamPlayer.GetCopyMapID() == GameWorld.GetGameWorld().GetCopyMapID() \
|
| | | and npcControl.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint) \
|
| | | and AttackCommon.CheckKillNPCByCnt(curTeamPlayer, curNPC, False):
|
| | | __AddBossDropOwnerPlayerBuff(curTeamPlayer, tick, curNPC)
|
| | | |
| | | # 不同线、或者距离超出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()))
|
| | | return
|
| | |
|
| | | def __AddBossDropOwnerPlayerBuff(curPlayer, tick, curNPC):
|
| | | findBuff = SkillCommon.FindBuffByID(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff)[0]
|
| | | if not findBuff:
|
| | | SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
|
| | | GameWorld.DebugLog("添加归属buff: playerID=%s" % curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def __DelBossDropOwnerBuff(curNPC, ownerType, ownerID, tick):
|
| | | |
| | | if ownerType == ChConfig.Def_NPCHurtTypePlayer:
|
| | | curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
|
| | | if not curPlayer:
|
| | | return
|
| | | GameWorld.DebugLog("删除归属玩家buff: playerID=%s" % (ownerID))
|
| | | BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
|
| | | |
| | | elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
|
| | | curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
|
| | | if not curTeam:
|
| | | return
|
| | | GameWorld.DebugLog("删除归属队伍buff: teamID=%s" % (ownerID))
|
| | | for i in xrange(curTeam.GetMemberCount()):
|
| | | curTeamPlayer = curTeam.GetMember(i)
|
| | | if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
|
| | | continue
|
| | | BuffSkill.DelBuffBySkillID(curTeamPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
|
| | | return
|
| | |
|
| | | def __DelayBossDropOwnerBuff(curNPC):
|
| | | ''' 延迟boss掉落归属buff消失时间 '''
|
| | | |
| | | ownerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
|
| | | ownerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
|
| | | |
| | | if ownerType == ChConfig.Def_NPCHurtTypePlayer:
|
| | | curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
|
| | | if not curPlayer:
|
| | | return
|
| | | __SetBossDropOwnerBuffDisappearTime(curPlayer, curNPC)
|
| | | |
| | | elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
|
| | | curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
|
| | | if not curTeam:
|
| | | return
|
| | | for i in xrange(curTeam.GetMemberCount()):
|
| | | curTeamPlayer = curTeam.GetMember(i)
|
| | | if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
|
| | | continue
|
| | | __SetBossDropOwnerBuffDisappearTime(curTeamPlayer, curNPC)
|
| | | return
|
| | |
|
| | | def __SetBossDropOwnerBuffDisappearTime(curPlayer, curNPC):
|
| | | |
| | | findSkill = GameWorld.GetGameData().GetSkillBySkillID(ChConfig.Def_SkillID_DropOwnerBuff)
|
| | | if not findSkill:
|
| | | return
|
| | | |
| | | buffType = SkillCommon.GetBuffType(findSkill)
|
| | | buffTuple = SkillCommon.GetBuffManagerByBuffType(curPlayer, buffType)
|
| | | if buffTuple == ():
|
| | | return
|
| | | |
| | | RemainTime = 10000 # 延迟10秒消失
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | |
| | | buffStateManager = buffTuple[0]
|
| | | for index in xrange(buffStateManager.GetBuffCount()):
|
| | | curBuff = buffStateManager.GetBuff(index)
|
| | | buffSkill = curBuff.GetSkill()
|
| | | |
| | | if buffSkill.GetSkillTypeID() != ChConfig.Def_SkillID_DropOwnerBuff:
|
| | | continue
|
| | | |
| | | if curNPC.GetID() != curBuff.GetOwnerID():
|
| | | #GameWorld.DebugLog("非buff归属着,不设置消失时间!", curPlayer.GetPlayerID())
|
| | | break
|
| | | |
| | | curBuff.SetCalcStartTick(tick) |
| | | curBuff.SetRemainTime(RemainTime)
|
| | | |
| | | # 通知buff刷新
|
| | | buffStateManager.Sync_RefreshBuff(index, curBuff.GetRemainTime())
|
| | | #GameWorld.DebugLog("掉落归属buff消失时间: RemainTime=%s" % (RemainTime), curPlayer.GetPlayerID())
|
| | | break
|
| | | return
|
| | |
|
| | | ## 每次被攻击处理结果
|
| | | # @param atkObj 攻击发起者
|
| | | # @param defObj 被攻击者
|
| | |
| | | PlayerState.SetBossStateTick(atkObj, tick)
|
| | | return
|
| | |
|
| | | def OnCheckCanDie(atkObj, curNPC, skill, tick):
|
| | | ## 检查NPC是否可死亡
|
| | | dropOwnerType = NPCCommon.GetDropOwnerType(curNPC)
|
| | | if dropOwnerType not in [ChConfig.DropOwnerType_MaxHurt]:
|
| | | return True
|
| | | npcControl = NPCCommon.NPCControl(curNPC)
|
| | | tagObj = npcControl.RefreshDropOwner(tick, 0)
|
| | | if not atkObj or not tagObj:
|
| | | GameObj.SetHP(curNPC, 1)
|
| | | GameWorld.ErrLog("Boss当前状态下不可以死亡!npcID=%s" % curNPC.GetNPCID())
|
| | | return False
|
| | | return True
|
| | |
|
| | | ## NPC被玩家杀死
|
| | | def OnAttackDieByPlayer(curNPC, curPlayer, skill):
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | PlayerState.SetBossStateTick(curPlayer, tick)
|
| | |
|
| | | #被击杀时强制刷新归属
|
| | | __RefreshDropOwner(curNPC, tick, 0)
|
| | | npcControl = NPCCommon.NPCControl(curNPC)
|
| | | npcControl.RefreshDropOwner(tick, 0, True)
|
| | | return
|
| | |
|
| | | ## NPC死亡处理
|
| | |
| | | # @return None
|
| | | def OnDie(curNPC, HurtType, HurtID):
|
| | | AICommon.DoNPCUseSkillOnDie(curNPC)
|
| | | __DelayBossDropOwnerBuff(curNPC)
|
| | | return
|
| | | |
| | |
|
| | | def OnNPCSetDead(curNPC):
|
| | | npcControl = NPCCommon.NPCControl(curNPC)
|
| | | npcControl.DelayDropOwnerBuffDisappearTime()
|
| | | return
|
| | |
|
| | | ## npc攻击逻辑
|
| | | # @param curNPC 当前npc
|
| | | # @param tagID curNPCAngryID
|