|  |  | 
 |  |  | import NetPackCommon
 | 
 |  |  | import FamilyRobBoss
 | 
 |  |  | import FBCommon
 | 
 |  |  | import ChNPC
 | 
 |  |  | 
 | 
 |  |  | import datetime
 | 
 |  |  | import math
 | 
 |  |  | 
 |  |  |         return attacker if not owner else owner
 | 
 |  |  |     
 | 
 |  |  |     return attacker
 | 
 |  |  |     | 
 |  |  | # 检查对象是否属于玩家,比如用于纯PVP验证
 | 
 |  |  | def CheckIsPlayerOnwer(gameObj):
 | 
 |  |  |     if not gameObj:
 | 
 |  |  |         return False
 | 
 |  |  |     
 | 
 |  |  |     objType = gameObj.GetGameObjType()
 | 
 |  |  |      | 
 |  |  |     if objType == IPY_GameWorld.gotPlayer:
 | 
 |  |  |         return True
 | 
 |  |  |      | 
 |  |  |     objNPCType = gameObj.GetGameNPCObjType()
 | 
 |  |  |     if objNPCType == IPY_GameWorld.gnotNormal:
 | 
 |  |  |         return False
 | 
 |  |  |      | 
 |  |  |     if objNPCType == IPY_GameWorld.gnotSummon:
 | 
 |  |  |         owner = NPCCommon.GetSummonOwnerDetel(gameObj)
 | 
 |  |  |         if not owner:
 | 
 |  |  |             return False
 | 
 |  |  |         if owner.GetGameObjType() != IPY_GameWorld.gotPlayer:
 | 
 |  |  |             return False
 | 
 |  |  |              | 
 |  |  |     return True
 | 
 |  |  |      | 
 |  |  | # 攻击时防守方神兵护盾的处理
 | 
 |  |  | def CalcAtkProDef(atkObj, defObj, hurtValue, curSkill, tick):
 | 
 |  |  |     if defObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
 | 
 |  |  |         return hurtValue
 | 
 |  |  |      | 
 |  |  |     if not CheckIsPlayerOnwer(atkObj):
 | 
 |  |  |         return hurtValue
 | 
 |  |  | 
 | 
 |  |  |     curProDef = PlayerControl.GetProDef(defObj)
 | 
 |  |  |     if not curProDef:
 | 
 |  |  |         return hurtValue
 | 
 |  |  |      | 
 |  |  |     absortValue = min(PlayerControl.GetProDefAbsorb(defObj)*hurtValue/ChConfig.Def_MaxRateValue, curProDef)
 | 
 |  |  |      | 
 |  |  |     PlayerControl.SetProDef(defObj, curProDef - absortValue)
 | 
 |  |  |      | 
 |  |  |     # 被动技能触发
 | 
 |  |  |     defObj.SetDict(ChConfig.Def_PlayerKey_GodWeaponBeforeProDef, curProDef)
 | 
 |  |  |     PassiveBuffEffMng.OnPassiveSkillTrigger(defObj, atkObj, None, ChConfig.TriggerType_ProDefValue, tick)
 | 
 |  |  |     return hurtValue - absortValue
 | 
 |  |  | 
 | 
 |  |  | ## 计算伤血值
 | 
 |  |  | #  @param atkObj 攻击者
 | 
 |  |  | #  @param defObj 防御者
 | 
 |  |  | 
 |  |  |     else:
 | 
 |  |  |         hurtValue, hurtType = CalcHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick, orgAtkObj=attacker)
 | 
 |  |  |     
 | 
 |  |  |     # 优先处理神兵护盾
 | 
 |  |  |     hurtValue = CalcAtkProDef(atkObj, defObj, hurtValue, curSkill, tick)
 | 
 |  |  | 
 | 
 |  |  |     # 伤害吸收盾回血型
 | 
 |  |  |     buffManager = defObj.GetBuffState()
 | 
 |  |  |     curEffect, plusValue, skillID = BuffSkill.FindBuffEffectPlusByEffectID(buffManager, ChConfig.Def_Skill_Effect_AbsorbShieldXMZJ)
 | 
 |  |  |     if skillID:
 | 
 |  |  |         absortValue = hurtValue*curEffect.GetEffectValue(0)/ShareDefine.Def_MaxRateValue
 | 
 |  |  |         if absortValue:
 | 
 |  |  |             hurtValue -= absortValue
 | 
 |  |  |             findBuff = SkillCommon.FindBuffByID(defObj, skillID)[0]
 | 
 |  |  |             if findBuff:
 | 
 |  |  |                 # 用于回血
 | 
 |  |  |                 findBuff.SetValue(int(findBuff.GetValue() + absortValue))
 | 
 |  |  | 
 | 
 |  |  |     if defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldValue):
 | 
 |  |  |         # 麒麟护盾吸收伤害,将抵消的伤害存储
 | 
 |  |  |         absortValue = int(defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldValue)/float(ShareDefine.Def_MaxRateValue)*hurtValue)   
 | 
 |  |  | 
 |  |  |         elif defObj.GetGameNPCObjType() == IPY_GameWorld.gnotTruck:
 | 
 |  |  |             remainHP = max(PlayerTruck.GetTruckDestroyMinHP(defObj), remainHP)
 | 
 |  |  |             GameObj.SetHP(defObj, remainHP)
 | 
 |  |  |          | 
 |  |  |         elif defObj.GetType() == ChConfig.ntHelpBattleRobot:
 | 
 |  |  |             remainHP = min(dHP, max(GameObj.GetMaxHP(defObj)/2, remainHP)) # 助战机器人剩余血量不能少于一半
 | 
 |  |  |             GameObj.SetHP(defObj, remainHP)
 | 
 |  |  |              | 
 |  |  |         else:
 | 
 |  |  |             #防守方是怪物NPC,只扣其血
 | 
 |  |  |             GameObj.SetHP(defObj, remainHP)
 | 
 |  |  | 
 |  |  |     suppressLV, suppressFightPower = 0, 0 # 压制等级差、战力差
 | 
 |  |  |     suppressReMaxHP = 0 # NPC压制等级生命值, 等级表中NPC等级对应的数据, 压制等级差大于0时才有值
 | 
 |  |  |     suppressNPCFightPower = 0 # 压制NPC战力
 | 
 |  |  |     fbFightPower, fbBaseHurt = 0, 0 # 副本战力, 副本保底伤害
 | 
 |  |  |     #当攻击方为NPC,防守方为玩家时,计算压制等级 及 压制战力
 | 
 |  |  |     if atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotPlayer:
 | 
 |  |  |         
 | 
 |  |  | 
 |  |  |         if suppressNPCFightPower:
 | 
 |  |  |             suppressFightPower = max(0, suppressNPCFightPower - defObj.GetFightPower())
 | 
 |  |  |             
 | 
 |  |  |     mustHit = False
 | 
 |  |  |     helpBattleFormatKey = ""
 | 
 |  |  |     if atkObjType == IPY_GameWorld.gotNPC and atkObj.GetType() == ChConfig.ntHelpBattleRobot:
 | 
 |  |  |         mustHit = True
 | 
 |  |  |         suppressNPCFightPower = NPCCommon.GetSuppressFightPower(atkObj)
 | 
 |  |  |         fbFightPower = GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.FBPD_HelpBattleFBFightPower)
 | 
 |  |  |         fbBaseHurt = GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.FBPD_HelpBattleFBBaseHurt)
 | 
 |  |  |         helpBattleFormatKey = "HelpRobot_Atk"
 | 
 |  |  |     if defObjType == IPY_GameWorld.gotNPC and defObj.GetType() == ChConfig.ntHelpBattleRobot:
 | 
 |  |  |         mustHit = True
 | 
 |  |  |         suppressNPCFightPower = NPCCommon.GetSuppressFightPower(defObj)
 | 
 |  |  |         fbFightPower = GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.FBPD_HelpBattleFBFightPower)
 | 
 |  |  |         fbBaseHurt = GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.FBPD_HelpBattleFBBaseHurt)
 | 
 |  |  |         helpBattleFormatKey = "HelpRobot_Def"
 | 
 |  |  |          | 
 |  |  |     #命中公式 攻击方类型不同,公式不同
 | 
 |  |  |     hitFormula = ReadChConfig.GetChConfig('CalcCanHit')
 | 
 |  |  |     
 | 
 |  |  |     if not PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill,  | 
 |  |  |     if not mustHit and not PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill,  | 
 |  |  |                            ChConfig.TriggerType_Buff_MustBeHit):
 | 
 |  |  |         # 技能对指定BOSS无效果的返回MISS
 | 
 |  |  |         if defObjType == IPY_GameWorld.gotNPC and defObj.GetIsBoss() not in ChConfig.Def_SkillAttack_NPCIsBoss \
 | 
 |  |  | 
 |  |  |         suppressLVHurtKey = "%s_%s" % (hurtFormulaKey, suppressLVGroup)
 | 
 |  |  |         if suppressLVHurtKey in hurtDist:
 | 
 |  |  |             hurtFormulaKey = suppressLVHurtKey
 | 
 |  |  |              | 
 |  |  |      | 
 |  |  |     # 助战机器人特殊伤血key
 | 
 |  |  |     if helpBattleFormatKey:
 | 
 |  |  |         hurtFormulaKey = helpBattleFormatKey
 | 
 |  |  |          | 
 |  |  |     if hurtFormulaKey not in hurtDist:
 | 
 |  |  |         GameWorld.ErrLog("CalcAttackValue.txt 伤害公式未配置, key=%s" % (hurtFormulaKey))
 | 
 |  |  |         return 0, ChConfig.Def_HurtType_Miss
 | 
 |  |  | 
 |  |  |     if atkObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
 | 
 |  |  |         # 记录最后一次伤害值
 | 
 |  |  |         atkObj.SetDict(ChConfig.Def_PlayerKey_LastHurtValue, resultHurtType.RealHurtHP)
 | 
 |  |  |         if defObj.GetGameObjType() == IPY_GameWorld.gotNPC:
 | 
 |  |  |             atkObj.SetDict(ChConfig.Def_PlayerKey_LastHurtNPCObjID, defObj.GetID())
 | 
 |  |  |         
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  | # @param curObjDetel 对象实例
 | 
 |  |  | # @return 返回值无意义
 | 
 |  |  | # @remarks 理对象死亡逻辑
 | 
 |  |  | def DoLogic_ObjDead(curObjDetel):
 | 
 |  |  | def DoLogic_ObjDead(atkObj, curObjDetel, curSkill, tick):
 | 
 |  |  |     if GameObj.GetHP(curObjDetel) > 0:
 | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  |     #---NPC处理---
 | 
 |  |  |     if not ChNPC.OnCheckCanDie(atkObj, curObjDetel, curSkill, tick):
 | 
 |  |  |         return
 | 
 |  |  |      | 
 |  |  |     npcControl = NPCCommon.NPCControl(curObjDetel)
 | 
 |  |  |     npcControl.SetKilled()
 | 
 |  |  |     return
 |