xdh
2018-10-25 6366979426fccd97c0cb0bd384ada3a8b9843a24
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/AttackLogic/AttackCommon.py
@@ -41,7 +41,7 @@
import PlayerTruck
#import PlayerPrestigeSys
import PlayerFamily
import BossHurtMng
#import BossHurtMng
import PassiveBuffEffMng
import PlayerSuccess
import GameFuncComm
@@ -56,6 +56,7 @@
import PlayerState
import ChPyNetSendPack
import NetPackCommon
import FamilyRobBoss
import FBCommon
import datetime
@@ -610,7 +611,7 @@
#  @remarks 获得curPlayer是否是新手
def GetIsNewGuy(curPlayer):
    
    if curPlayer.GetLV() < ReadChConfig.GetEvalChConfig("MinPKLV"):
    if curPlayer.GetLV() < IpyGameDataPY.GetFuncCfg("PKConfig", 5):
        return True
    
    return False
@@ -679,7 +680,8 @@
    defNPCHurtList = curTagObj.GetPlayerHurtList()
    curObjType = curObj.GetGameObjType()
    if curObjType == IPY_GameWorld.gotPlayer:
        BossHurtMng.BossAddPlayerInHurtList(curObj, curTagObj, hurtHP)
        #BossHurtMng.BossAddPlayerInHurtList(curObj, curTagObj, hurtHP)
        FamilyRobBoss.OnPlayerHurtFamilyOwnerBoss(curObj, curTagObj, hurtHP)
        if curTagObj.GetGameObjType() == IPY_GameWorld.gotNPC:
            FBLogic.DoFB_Player_HurtNPC(curObj, curTagObj, hurtHP)
        if GameObj.GetHP(curTagObj) == 0:
@@ -748,6 +750,10 @@
        if not CheckKillNPCByCnt(attacker, defender):
            return False
        
        #仙盟归属NPC判断
        if not CheckCanAttackFamilyOwnerNPC(attacker, defender):
            return False
    # NPC打玩家,反过来判断
    elif atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotPlayer:
        ##攻击次数判断
@@ -758,12 +764,19 @@
        if not CheckKillNPCByCnt(defender, attacker, False):
            return False
        
        #仙盟归属NPC判断
        if not CheckCanAttackFamilyOwnerNPC(defender, attacker, False):
            return False
        
    # NPC打NPC
    elif atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotNPC:
        if PetControl.IsPet(attacker) or attacker.GetGameNPCObjType()== IPY_GameWorld.gnotSummon:
            #击杀次数判断
            if not CheckKillNPCByCnt(attacker, defender, False):
                return False
            #仙盟归属NPC判断
            if not CheckCanAttackFamilyOwnerNPC(attacker, defender, False):
                return False
            
    #攻击NPC等级限制
@@ -817,6 +830,34 @@
              
    return False
def CheckCanAttackFamilyOwnerNPC(attacker, defender, isNotify=True):
    ''' 判断可否攻击仙盟归属的NPC '''
    if defender.GetGameObjType() != IPY_GameWorld.gotNPC:
        #GameWorld.DebugLog("只判断被攻击的是NPC的情况")
        return True
    if NPCCommon.GetDropOwnerType(defender) != ChConfig.DropOwnerType_Family:
        return True
    atkPlayer, npcObjType = GetAttackPlayer(attacker)
    # 攻击者非玩家不限制
    if not atkPlayer:
        #GameWorld.DebugLog("攻击者非玩家不限制")
        return True
    atkLimitNotifyMark = ""
    if GetIsNewGuy(atkPlayer):
        atkLimitNotifyMark = "FairyGrabBossNotAtk"
    elif not atkPlayer.GetFamilyID():
        atkLimitNotifyMark = "FairyGrabBossNoFairy"
    if atkLimitNotifyMark:
        if npcObjType is None and isNotify:
            PlayerControl.NotifyCode(atkPlayer, atkLimitNotifyMark)
        return False
    return True
def CheckKillNPCByCnt(attacker, defender, isNotify=True):
    ''' 判断当日击杀该NPC次数是否已满 '''
    if defender.GetGameObjType() != IPY_GameWorld.gotNPC:
@@ -853,9 +894,9 @@
    
    
    if hasKillCnt >= limitCnt + itemAddKillCnt:
        if BossHurtMng.GetPlayerBossHurt(atkPlayer, defender):
            GameWorld.DebugLog("攻击过该boss可继续攻击")
            return True
        #if BossHurtMng.GetPlayerBossHurt(atkPlayer, defender):
        #    GameWorld.DebugLog("攻击过该boss可继续攻击")
        #    return True
        #次数不足
        # 实际攻击者类型None则需要提示玩家
        if npcObjType is None:
@@ -888,9 +929,9 @@
    hasAttackCnt = atkPlayer.NomalDictGetProperty(ChConfig.Def_PDict_WorldBoss_HurtCnt, 0)
    
    if hasAttackCnt >= limitCnt:
        if BossHurtMng.GetPlayerBossHurt(atkPlayer, defender):
            GameWorld.DebugLog("攻击过该boss可继续攻击")
            return True
        #if BossHurtMng.GetPlayerBossHurt(atkPlayer, defender):
        #    GameWorld.DebugLog("攻击过该boss可继续攻击")
        #    return True
        #次数不足
        # 实际攻击者类型None则需要提示玩家
        if npcObjType is None:
@@ -1506,7 +1547,6 @@
        
        # 血盾 
        hurtValue = CalcBloodShield(atkObj, defObj, hurtValue)
        remainHP = min(dMaxHP, max(0, dHP - hurtValue)) # 剩余血量
    
    remainHP = int(remainHP)    #防范
@@ -1528,6 +1568,12 @@
    else:
        GameWorld.ErrLog('计算伤血值时,防守方类型错误:defObjType = %s' % (defObjType))
        return resultHurtType
    if GameObj.GetHP(defObj) > 0:
        # 被攻击者将部分伤害转化为血量, 返回转化的百分比(小数点)
        changePer = PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(defObj, atkObj, None, ChConfig.TriggerType_ChangeHurtToHP)
        if changePer:
            SkillCommon.SkillAddHP(defObj, 0, int(changePer*hurtValue))
    
    lostValue = dHP - GameObj.GetHP(defObj) # 实际掉血量
    resultHurtType.LostHP = lostValue
@@ -1562,8 +1608,21 @@
    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)
        if summonAtkPerValue > 0:
            # 暴风雪类召唤兽转化为主人计算伤害
            atkObj = NPCCommon.GetSummonOwnerDetel(atkObj)
            if not atkObj:
                return 0, ChConfig.Def_HurtType_Miss
            summonAtkPer = summonAtkPerValue*1.0/ChConfig.Def_MaxRateValue
            #GameWorld.DebugLog("召唤兽取主人---------%s-%s-%s-%s"%(atkObj.GetID(), atkSkillPer, atkSkillValue, summonAtkPer))
    atkObjType = atkObj.GetGameObjType()
    defObjType = defObj.GetGameObjType()
    atkType = GetBattleType(atkObj, curSkill)
    happenState = happenState if happenState else SkillShell.GetHappenState(curSkill)
@@ -1580,6 +1639,7 @@
    dMissSuccessRate += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(defObj, atkObj, None, ChConfig.TriggerType_MissSuccessPer)
    skillID = curSkill.GetSkillID() if curSkill else 0
    
    atkIsBoss = 0 # 攻击方是否boss
    suppressValueLV = 0 # 等级最终压制值, 由压制规则及相关参数计算得出,可作为伤害公式计算参数使用
    suppressValueFP = 0 # 战力最终压制值, 由压制规则及相关参数计算得出,可作为伤害公式计算参数使用
@@ -1588,6 +1648,13 @@
    suppressNPCFightPower = 0 # 压制NPC战力
    #当攻击方为NPC,防守方为玩家时,计算压制等级 及 压制战力
    if atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotPlayer:
        if curSkill and curSkill.GetFuncType() == ChConfig.Def_SkillFuncType_RealmSuppress:
            # 境界压制技能不对高等级境界玩家产生攻击
            aRealmLV, dRealmLV = GetPVERealmLVs(atkObj, defObj, atkObjType, defObjType)
            if aRealmLV <= dRealmLV:
                return 0, ChConfig.Def_HurtType_Immune   # 免疫
        atkIsBoss = 1 if ChConfig.IsGameBoss(atkObj) else 0
        if NPCCommon.GetIsLVSuppress(atkObj):
            suppressLV = max(0, aLV - dLV)
@@ -1634,6 +1701,10 @@
    if PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(defObj, atkObj, None, ChConfig.TriggerType_OneDamage):
        return 1, hurtType
    
    worldLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
    wLVIpyData = PlayerControl.GetPlayerLVIpyData(worldLV)
    wReFightPower = 0 if not wLVIpyData else wLVIpyData.GetReFightPower() # 当前世界等级参考战力
    # 改变技能伤害
    atkSkillPer, atkSkillValue = ChangeSkillHurt(atkObj, defObj, curSkill, atkSkillPer, atkSkillValue)
    
@@ -1644,6 +1715,8 @@
    
    aIceAtkSuperHit = 1 # 元素真伤倍值,暂时默认为1,之后扩展
    aIceAtkSuperHit += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AddIceAtkPer)
    aIceAtkSuperHit += PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AddIceAtkPer)
    
    if isSuperHit:
        addASuperHit = PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_SuperHitValue)
@@ -1652,12 +1725,17 @@
        # 暴击增加技能伤害
        atkSkillPer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_SuperHitSkillPer)
    if isLuckyHit:
        # 会心一击时增加会心伤害百分比
        aLuckyHit += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_LuckyHit)
    #参与运算的数值
    rand = random.random()                #种子数 0~1
    
    #------- 攻击方
    aMinAtk = atkObj.GetMinAtk()        # 攻击方最小攻击
    aMaxAtk = atkObj.GetMaxAtk()        # 攻击方最大攻击
    aMinAtk = atkObj.GetMinAtk() * summonAtkPer        # 攻击方最小攻击
    aMaxAtk = atkObj.GetMaxAtk() * summonAtkPer       # 攻击方最大攻击
    aIceAtk = atkObj.GetIceAtk()        # 冰攻, 元素真伤, 玩家及NPC通用
    aIceAtk += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AddIceAtk)
    #------- 防守方
@@ -1677,7 +1755,9 @@
        aDamagePer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AddDamagePer)
        aDamagePer += PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AddDamagePer)
        
        aNPCHurtAddPer = PlayerControl.GetNPCHurtAddPer(atkObj)     # PVE伤害加成
        aDamagePerPVP = PlayerControl.GetDamagePerPVP(atkObj)     # 外层PVP伤害加成
        aFinalHurtPer = PlayerControl.GetFinalHurtPer(atkObj) # 最外层伤害加成, 可能为负值
        aFinalHurt = PlayerControl.GetFinalHurt(atkObj)     # 最终固定伤害
        # 被动增加最终伤害
        aFinalHurt += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, curSkill, ChConfig.TriggerType_AttackAddFinalValue)
@@ -1691,11 +1771,12 @@
        aSkillAtkRate = NPCCommon.GetSkillAtkRate(atkObj)   # 技能攻击力加成
        if atkObjType == IPY_GameWorld.gotNPC and atkObj.GetGameNPCObjType() == IPY_GameWorld.gnotPet:
            aSkillAtkRate += atkObj.GetSkillAtkRate()
        aNPCHurtAddPer = 0  # PVE伤害加成
        aDamagePer = 0      # 外层伤害加成
        aDamagePerPVP = 0   # 外层PVP伤害加成
        aFinalHurtPer = 0 # 最外层伤害加成, 可能为负值
        aFinalHurt = NPCCommon.GetFinalHurt(atkObj) # 最终固定伤害
        aFightPower = NPCCommon.GetSuppressFightPower(atkObj)
        
    #防守方的类型
    if defObjType == IPY_GameWorld.gotPlayer:
@@ -1732,7 +1813,7 @@
            suppressFPFormula = hurtDist[suppressFormulaKeyFP]
            suppressValueFP = eval(FormulaControl.GetCompileFormula(suppressFormulaKeyFP, suppressFPFormula))
    
    # 境界压制百分比, 仅限PVP
    # 境界压制百分比
    SuppressValueRealmRate = 10000 # 默认值
    suppressRealm = 0
    if atkObjType == IPY_GameWorld.gotPlayer and defObjType == IPY_GameWorld.gotPlayer:
@@ -1751,17 +1832,35 @@
        #GameWorld.DebugLog("境界压制:aRealmLV=%s,dRealmLV=%s,aRealmGroup=%s,dRealmGroup=%s,SuppressValueRealmRate=%s" 
        #                   % (aRealmLV, dRealmLV, aRealmGroup, dRealmGroup, SuppressValueRealmRate))    
        
    else:
        #PVE 境界压制
    elif atkObjType == IPY_GameWorld.gotNPC and defObjType == IPY_GameWorld.gotPlayer:
        # EVP 境界压制
        aRealmLV, dRealmLV = GetPVERealmLVs(atkObj, defObj, atkObjType, defObjType) 
        if aRealmLV + dRealmLV != 0:
            #有压制
            suppressRealm = aRealmLV - dRealmLV
            suppressRealm = aRealmLV - dRealmLV # 存在负数
            suppressRealmHurtPer = GetRealmHurtPer(aRealmLV, dRealmLV, 2) # 境界压制加成百分比,存在负数
            suppressFormulaKeyRealm = "EVPSuppressValueRealm"
            if suppressFormulaKeyRealm in hurtDist:
                SuppressValueRealmRate = int(eval(FormulaControl.GetCompileFormula(suppressFormulaKeyRealm, hurtDist[suppressFormulaKeyRealm])))
    elif atkObjType == IPY_GameWorld.gotPlayer and defObjType == IPY_GameWorld.gotNPC:
        # PVE 境界压制
        aRealmLV, dRealmLV = GetPVERealmLVs(atkObj, defObj, atkObjType, defObjType)
        if aRealmLV + dRealmLV != 0:
            #有压制
            suppressRealm = aRealmLV - dRealmLV # 存在负数
            suppressRealmHurtPer = GetRealmHurtPer(aRealmLV, dRealmLV, 3) # 境界压制加成百分比,存在负数
            suppressFormulaKeyRealm = "PVESuppressValueRealm"
            if suppressFormulaKeyRealm in hurtDist:
                SuppressValueRealmRate = int(eval(FormulaControl.GetCompileFormula(suppressFormulaKeyRealm, hurtDist[suppressFormulaKeyRealm])))
        # 骑宠争夺最终伤害衰减
        if FamilyRobBoss.IsHorsePetRobBoss(defObj.GetNPCID()):
            findBuff = SkillCommon.FindBuffByID(atkObj, ChConfig.Def_SkillID_HorsePetRobBossKillCntBuff)[0]
            if findBuff:
                reduceFinalHurtPer = findBuff.GetSkill().GetEffect(0).GetEffectValue(0)
                aFinalHurtPer -= reduceFinalHurtPer
    atkStateMark = GetObjAtkStateMark(atkObj)
    defStateMark = GetObjAtkStateMark(defObj)
    hurtFormulaKey = "%sV%s_%s" % (atkStateMark, defStateMark, atkType)
@@ -1787,9 +1886,32 @@
    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
    return hurtValue, hurtType
# 获取EVP和PVE伤害百分比差,PVE无境界压制, 境界等级对应列表的index,越界取最高
def GetRealmHurtPer(aRealmLV, dRealmLV, gridIndex):
    suppressRealmHurtPer = 0
    suppressRealmDict = IpyGameDataPY.GetFuncEvalCfg("RealmGroup", gridIndex)
    plus_minus = 1  # 负数为反压制
    if aRealmLV >= dRealmLV:
        suppressList = range(dRealmLV+1, aRealmLV+1)
    else:
        suppressList = range(aRealmLV+1, dRealmLV+1)
        plus_minus = -1
    for realmLV in suppressList:
        suppressRealmHurtPer += suppressRealmDict.get(realmLV, 0)
    return suppressRealmHurtPer*plus_minus
# 获取双方境界值
def GetPVERealmLVs(atkObj, defObj, atkObjType, defObjType):
    if atkObjType == IPY_GameWorld.gotNPC:
        aRealmLV = NPCCommon.GetRealmLV(atkObj)
@@ -1966,7 +2088,9 @@
        #PVP 攻击回血
        atkBackHP += PlayerControl.GetPVPAtkBackHP(atkObj)
        # 百分比吸血
        atkBackHPPer = PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, None, None, ChConfig.TriggerType_Buff_SuckBloodPer)
        atkBackHPPer = PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(atkObj, defObj, None, ChConfig.TriggerType_Buff_SuckBloodPer)
        atkBackHPPer += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(atkObj, defObj, None, ChConfig.TriggerType_Buff_SuckBloodPer)
        atkBackHP += int(hurtValue * atkBackHPPer*1.0 / ChConfig.Def_MaxRateValue)
    suckHP += atkBackHP
@@ -2150,6 +2274,12 @@
    if tagPlayer.GetPlayerAction() == IPY_GameWorld.paSit:
        return ChConfig.Type_Relation_None, ChConfig.Def_PASysMessage_SitNotPK
    
    if GetIsNewGuy(curPlayer):
        return ChConfig.Type_Relation_None, ChConfig.Def_PASysMessage_NewGuy
    if GetIsNewGuy(tagPlayer):
        return ChConfig.Type_Relation_None, ChConfig.Def_PASysMessage_NotAttackNewGuy
    #攻守双方同一队伍,不可PK,可加增益buff
    #if curPlayerAreaType not in [ShareDefine.gatManor] and CanAlikeTeam(curPlayer, tagPlayer):
    #    #副本队友特殊判断