hch
2019-03-20 df824550205e9f266f51ebbf4028ac37fe0992bc
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
@@ -57,7 +57,7 @@
import ChPyNetSendPack
import NetPackCommon
import FamilyRobBoss
import EquipZhuXian
#import EquipZhuXian
import FBCommon
import ChNPC
@@ -1427,13 +1427,14 @@
    if atkObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return skillPer
    
    skillTypeID = curSkill.GetSkillTypeID()
    #skillTypeID = curSkill.GetSkillTypeID()
    
    addPer = EquipZhuXian.GetZhuXianEquipSkillAddPer(atkObj.GetPlayerID(), skillTypeID)
    addPer = 0
    reducePer = 0
    #addPer += EquipZhuXian.GetZhuXianEquipSkillAddPer(atkObj.GetPlayerID(), skillTypeID)
    
    if defObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
        reducePer = EquipZhuXian.GetZhuXianEquipSkillReducePer(defObj.GetPlayerID(), skillTypeID)
        #reducePer = EquipZhuXian.GetZhuXianEquipSkillReducePer(defObj.GetPlayerID(), skillTypeID)
        
        #根据防守方职业 计算攻击方伤害加成
        if defObj.GetJob() in [ShareDefine.PlayerJob_Warrior, ShareDefine.PlayerJob_Knight]:
@@ -1604,6 +1605,7 @@
    atkObj = ElfChangeAttacker(attacker)  # Elf灵为替身攻击,要取玩家的属性
    
    resultHurtType = HurtType()
    atkObjType = attacker.GetGameObjType()
    defObjType = defObj.GetGameObjType()
    dHP = GameObj.GetHP(defObj)                # 防守方当前血量
    dMaxHP = GameObj.GetMaxHP(defObj)          # 防守方最大血量
@@ -1628,38 +1630,16 @@
            hurtValue = clientValue
        else:
            # 外挂最高伤害基本防范
            GameWorld.DebugAnswer(atkObj, "%s----客户端伤害 %s 服务端最高伤害 %s"%(atkObj.GetID(), [clientValue, hurtType], hurtValue))
            GameWorld.DebugLog(atkObj, "%s----客户端伤害 %s 服务端最高伤害 %s"%(atkObj.GetID(), [clientValue, hurtType], hurtValue))
            hurtValue = int(hurtValue*0.8)
        #GameWorld.DebugAnswer(atkObj, "客户端伤害 %s 服务端伤害 %s"%([defObj.GetID(), clientValue, hurtType], hurtValue))
    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)
        hurtValue -= absortValue
        # 吸收至指定血量比例值
        absorbHurt = defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShield)
        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)    # 记录护盾吸收的伤害用于爆炸
    WriteHurtLog(attacker, defObj, curSkill, hurtValue, hurtType, "公式层")
    hurtValue = CalcHurtHPWithBuff(atkObj, defObj, hurtValue, curSkill, tick)
    # buff减少伤害百分比
    reducePer = PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(defObj, atkObj, None, ChConfig.TriggerType_ReduceHurtHPPer)
@@ -1751,7 +1731,9 @@
    resultHurtType.LostHP = lostValue
    if defObjType == IPY_GameWorld.gotPlayer:
        FBLogic.OnFBLostHP(defObj, lostValue)
    WriteHurtLog(attacker, defObj, curSkill, resultHurtType.LostHP, resultHurtType.HurtType, "最终扣血")
    #攻击触发事件, 该代码应该放在DoAttack函数中处理逻辑比较清晰,也不会破坏GetHurtHP函数
    #因为DoAttack修改点比较多,暂不迁移,相关攻击事件逻辑,就往此函数中添加
    AttackEventTrigger(atkObj, defObj, curSkill, resultHurtType, tick)
@@ -1762,6 +1744,75 @@
    
    return resultHurtType
# 计算伤害后,因各种buff和状态的影响处理
def CalcHurtHPWithBuff(atkObj, defObj, hurtValue, curSkill, tick):
    # 优先处理神兵护盾
    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_AbsorbValue):
        defObj.SetDict(ChConfig.Def_PlayerKey_AbsorbValue, 0) #吸收的单次伤害,单次伤害必须清空
    if defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldValue):
        # 麒麟护盾吸收伤害,将抵消的伤害存储
        absortValue = int(defObj.GetDictByKey(ChConfig.Def_PlayerKey_AbsorbShieldValue)/float(ShareDefine.Def_MaxRateValue)*hurtValue)
        hurtValue -= absortValue
        defObj.SetDict(ChConfig.Def_PlayerKey_AbsorbValue, absortValue) #吸收的单次伤害
    # 天罡护法,将期间受到的伤害总值用于回血,不改变伤害
    curEffect, plusValue, skillID2 = BuffSkill.FindBuffEffectPlusByEffectID(buffManager, ChConfig.Def_Skill_Effect_StoreBlood)
    if skillID2:
        absortValue = hurtValue*curEffect.GetEffectValue(0)/ShareDefine.Def_MaxRateValue
        if absortValue:
            findBuff = SkillCommon.FindBuffByID(defObj, skillID2)[0]
            if findBuff:
                # 用于回血
                findBuff.SetValue(int(findBuff.GetValue() + absortValue))
    return hurtValue
# GM 命令  HurtLog 查看战斗伤害日志
def WriteHurtLog(attacker, defObj, curSkill, hurtValue, hurtType, msg):
    logLevel = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_HurtLog)
    if not logLevel:
        return
    if logLevel == 1:
        # 只看玩家伤害
        if not attacker:
            return
        if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
            return
        msg = "玩家" + msg
    attackerID = attacker.GetID() if attacker else 0
    defenderID = defObj.GetID() if defObj else 0
    skillID = curSkill.GetSkillID() if curSkill else 0
    skillName = curSkill.GetSkillName()  if curSkill else ""
    attackerName = attacker.GetName() if attacker else ""
    defenderName = defObj.GetName() if defObj else ""
    if attacker and attacker.GetGameObjType() == IPY_GameWorld.gotPlayer:
        attackerName = attackerName.decode("utf8").encode('gbk')
    if defObj and defObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
        defenderName = defenderName.decode("utf8").encode('gbk')
    GameWorld.DebugLog("攻击伤害-%s:(%s %s)攻击(%s %s), 技能ID:(%s %s), 伤害值:%s, 伤害类型:%s "%(
                        msg, attackerID, attackerName, defenderID, defenderName,
                        skillID, skillName, hurtValue, hurtType))
# 血盾支持多个同时存在
def CalcBloodShield(atkObj, defObj, hurtValue):
@@ -1913,6 +1964,11 @@
        # 暴击增加技能伤害
        atkSkillPer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_SuperHitSkillPer)
        atkSkillPer += PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_SuperHitSkillPer)
        # buff中暴击减层,无触发技能
        PassiveBuffEffMng.OnPassiveBuffTrigger(atkObj, defObj, curSkill, ChConfig.TriggerType_SuperHitSubLayer, tick)
    if isLuckyHit:
        # 会心一击时增加会心伤害百分比 
@@ -2157,7 +2213,8 @@
        atkObj.SetDict(ChConfig.Def_PlayerKey_LastHurtValue, resultHurtType.RealHurtHP)
        if defObj.GetGameObjType() == IPY_GameWorld.gotNPC:
            atkObj.SetDict(ChConfig.Def_PlayerKey_LastHurtNPCObjID, defObj.GetID())
        else:
            defObj.SetDict(ChConfig.Def_PlayerKey_LastAttackerObjID, atkObj.GetID())
    return
@@ -2310,7 +2367,7 @@
        atkBackHPPer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_Buff_SuckBloodPer)
        
        atkBackHP += int(hurtValue * atkBackHPPer*1.0 / ChConfig.Def_MaxRateValue)
    suckHP += atkBackHP
    
    if suckHP <= 0: