| | |
| | | # @param finalHurtPer 对最终计算出来的伤害影响效果(有正负,默认10000)
|
| | | # @return None or HurtType 伤害结构体类
|
| | | # @remarks 函数详细说明.
|
| | | def GetHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick):
|
| | | atkObj = ElfChangeAttacker(atkObj) # Elf灵为替身攻击,要取玩家的属性
|
| | | def GetHurtHP(attacker, defObj, curSkill, atkSkillValue, atkSkillPer, tick):
|
| | | atkObj = ElfChangeAttacker(attacker) # Elf灵为替身攻击,要取玩家的属性
|
| | |
|
| | | resultHurtType = HurtType()
|
| | | defObjType = defObj.GetGameObjType()
|
| | |
| | | # 理论伤害一致, 多加点预算伤害避免计算误差
|
| | | #hurtValue = min(ShareDefine.Def_UpperLimit_DWord, hurtValue+10)
|
| | | #atkObj.SetDict(ChConfig.Def_PlayerKey_ClientMaxHurtValue, int(hurtValue*1.2))
|
| | | hurtValue = atkObj.GetMaxAtk()*atkSkillPer*10 + atkObj.GetSuperHit() # 加入被动计算不准确改成估算
|
| | | hurtValue = atkObj.GetMaxAtk()*atkSkillPer*20 # 加入被动计算不准确改成估算
|
| | |
|
| | | clientValue, hurtType = SkillShell.GetClientHurtByObj(defObj.GetID(), defObjType)
|
| | | if clientValue <= hurtValue:
|
| | |
| | | #GameWorld.DebugAnswer(atkObj, "客户端伤害 %s 服务端伤害 %s"%([defObj.GetID(), clientValue, hurtType], hurtValue))
|
| | |
|
| | | else:
|
| | | hurtValue, hurtType = CalcHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick)
|
| | | hurtValue, hurtType = CalcHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick, orgAtkObj=attacker)
|
| | |
|
| | | if defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldValue):
|
| | | # 麒麟护盾吸收伤害,将抵消的伤害存储
|
| | |
| | | if absorbHurt <= defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldMax):
|
| | | maxValue = min(absorbHurt + absortValue, defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldMax))
|
| | | defObj.SetDict(ChConfig.Def_PlayerKey_AbsorbShield, maxValue) # 记录护盾吸收的伤害用于爆炸
|
| | | |
| | |
|
| | | # buff减少伤害百分比
|
| | | reducePer = PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(defObj, atkObj, None, ChConfig.TriggerType_ReduceHurtHPPer)
|
| | | |
| | | # 被攻击被动技能特殊减免 受到单次伤害超过生命上限10%时候,减免50%伤害,CD10秒
|
| | | defObj.SetDict(ChConfig.Def_PlayerKey_curHurtValue, hurtValue)
|
| | | reducePer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(defObj, atkObj, None, ChConfig.TriggerType_ReduceHurtHPPer)
|
| | | hurtValue = int(hurtValue*(max(ChConfig.Def_MaxRateValue - reducePer, 0))*1.0/ChConfig.Def_MaxRateValue)
|
| | |
|
| | | |
| | |
|
| | | # 斩杀,濒死等情况的处理
|
| | | if PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AttackKill):
|
| | | # նɱ
|
| | |
| | | remainHP = min(dMaxHP, max(0, dHP - hurtValue)) # 剩余血量
|
| | |
|
| | | remainHP = int(remainHP) #防范
|
| | |
|
| | | if defObjType == IPY_GameWorld.gotPlayer:
|
| | | GameObj.SetHP(defObj, remainHP, False)
|
| | |
|
| | |
| | |
|
| | | # 计算攻击伤害
|
| | | # maxHurt参数用于模拟计算最大伤害,防范客户端攻击伤害过高
|
| | | def CalcHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick, happenState=None, maxHurt=False):
|
| | | def CalcHurtHP(atkObj, defObj, curSkill, atkSkillValue, atkSkillPer, tick, happenState=None, **atkwargs):
|
| | | # 翻滚闪避特殊处理
|
| | | if tick - defObj.GetDictByKey(ChConfig.Def_PlayerKey_SomersaultTime) < 500:
|
| | | return 0, ChConfig.Def_HurtType_Miss
|
| | |
|
| | | summonAtkPer = 1 # 召唤继承提高基础攻击力,取表
|
| | | if atkObj.GetGameObjType() == IPY_GameWorld.gotNPC and atkObj.GetGameNPCObjType() == IPY_GameWorld.gnotSummon:
|
| | | summonAtkPerValue = atkObj.GetDictByKey(ChConfig.Def_GameObjKey_InheritOwner)
|
| | | summonAtkObj = atkwargs.get('orgAtkObj', None) if atkwargs.get('orgAtkObj', None) else atkObj
|
| | | if summonAtkObj.GetGameObjType() == IPY_GameWorld.gotNPC and summonAtkObj.GetGameNPCObjType() == IPY_GameWorld.gnotSummon:
|
| | | summonAtkPerValue = summonAtkObj.GetDictByKey(ChConfig.Def_GameObjKey_InheritOwner)
|
| | | if summonAtkPerValue > 0:
|
| | | # 暴风雪类召唤兽转化为主人计算伤害
|
| | | atkObj = NPCCommon.GetSummonOwnerDetel(atkObj)
|
| | | if not atkObj:
|
| | | ownerAtkObj = NPCCommon.GetSummonOwnerDetel(summonAtkObj)
|
| | | if not ownerAtkObj:
|
| | | return 0, ChConfig.Def_HurtType_Miss
|
| | |
|
| | | summonAtkPer = summonAtkPerValue*1.0/ChConfig.Def_MaxRateValue
|
| | | #GameWorld.DebugLog("召唤兽取主人---------%s-%s-%s-%s"%(atkObj.GetID(), atkSkillPer, atkSkillValue, summonAtkPer))
|
| | | #GameWorld.DebugLog("召唤兽取主人---------%s-%s-%s-%s"%(ownerAtkObj.GetID(), atkSkillPer, atkSkillValue, summonAtkPer))
|
| | |
|
| | | atkObjType = atkObj.GetGameObjType()
|
| | | defObjType = defObj.GetGameObjType()
|
| | |
| | | #命中公式 攻击方类型不同,公式不同
|
| | | hitFormula = ReadChConfig.GetChConfig('CalcCanHit')
|
| | |
|
| | | if not maxHurt and not PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill, |
| | | ChConfig.TriggerType_Buff_MustBeHit): # maxHurt用于模拟计算, 被动有必命中效果
|
| | | if 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 \
|
| | | and SkillCommon.GetSkillBattleType(curSkill) == ChConfig.Def_BattleRelationType_CommNoBoss:
|
| | |
| | | and eval(hitFormula) < 0:
|
| | | return 0, ChConfig.Def_HurtType_Miss
|
| | |
|
| | | if maxHurt: # 用于模拟计算最大伤害
|
| | | rand = 1
|
| | | isLuckyHit, aLuckyHit, dLuckyHitReduce = True, atkObj.GetLuckyHitVal(), 0
|
| | | isSuperHit, aSuperHit, dSuperHitReduce = True, atkObj.GetSuperHit(), 0
|
| | | dDamChanceDef = 0
|
| | | hurtType = ChConfig.Def_HurtType_SuperHit
|
| | | else:
|
| | | hurtType, hurtTypeResultDict = CalcHurtTypeResult(atkObj, defObj, atkObjType, defObjType, happenState)
|
| | | #GameWorld.DebugLog("GetHurtHP hurtType=%s, hurtTypeResultDict=%s" % (hurtType, hurtTypeResultDict))
|
| | | isLuckyHit, aLuckyHit, dLuckyHitReduce = hurtTypeResultDict[ChConfig.Def_HurtType_LuckyHit] # 幸运一击
|
| | | isSuperHit, aSuperHit, dSuperHitReduce = hurtTypeResultDict[ChConfig.Def_HurtType_SuperHit] # 暴击
|
| | | dDamChanceDef = hurtTypeResultDict[ChConfig.Def_HurtType_Parry][2] # 抵御, 大于0代表触发抵御效果
|
| | |
|
| | | hurtType, hurtTypeResultDict = CalcHurtTypeResult(atkObj, defObj, atkObjType, defObjType, happenState)
|
| | | #GameWorld.DebugLog("GetHurtHP hurtType=%s, hurtTypeResultDict=%s" % (hurtType, hurtTypeResultDict))
|
| | | isLuckyHit, aLuckyHit, dLuckyHitReduce = hurtTypeResultDict[ChConfig.Def_HurtType_LuckyHit] # 幸运一击
|
| | | isSuperHit, aSuperHit, dSuperHitReduce = hurtTypeResultDict[ChConfig.Def_HurtType_SuperHit] # 暴击
|
| | | dDamChanceDef = hurtTypeResultDict[ChConfig.Def_HurtType_Parry][2] # 抵御, 大于0代表触发抵御效果
|
| | |
|
| | | if PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(defObj, atkObj, None, ChConfig.TriggerType_OneDamage):
|
| | | return 1, hurtType
|
| | |
| | | aNPCHurtAddPer = PlayerControl.GetNPCHurtAddPer(atkObj) # PVE伤害加成
|
| | | aDamagePerPVP = PlayerControl.GetDamagePerPVP(atkObj) # 外层PVP伤害加成
|
| | | aFinalHurtPer = PlayerControl.GetFinalHurtPer(atkObj) # 最外层伤害加成, 可能为负值
|
| | | aFinalHurtPer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AttackAddFinalPer)
|
| | | |
| | | aFinalHurt = PlayerControl.GetFinalHurt(atkObj) # 最终固定伤害
|
| | | # 被动增加最终伤害
|
| | | aFinalHurt += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AttackAddFinalValue)
|
| | |
| | | return 0, ChConfig.Def_HurtType_Miss
|
| | | hurtFormula = hurtDist[hurtFormulaKey]
|
| | | hurtValue = int(eval(FormulaControl.GetCompileFormula(hurtFormulaKey, hurtFormula)))
|
| | | |
| | |
|
| | | if hurtType == ChConfig.Def_HurtType_Normal and SuppressValueRealmRate > 10000:
|
| | | # 存在压制
|
| | | return hurtValue, ChConfig.Def_HurtType_RealmSupress
|