xdh
2019-04-20 e3abcda123dce539f821ab2520cbb7bb8e70daad
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/PassiveBuffEffMng.py
@@ -21,7 +21,6 @@
        
#导入
import IPY_GameWorld
import ReadChConfig
import PassiveBuff
import GameWorld
import ChConfig
@@ -260,6 +259,8 @@
    # 助战神兽技能
    GetPassiveEffManager().RegistPassiveEffDogz(curPlayer)
    GetPassiveEffManager().RegistSuperEquipSkillDict(curPlayer)
#-被动逻辑处理--------------------------------------------------------------------------------------------------
##离开地图处理
@@ -279,6 +280,7 @@
             2102:ChConfig.TriggerType_BeAttackOver,   # 被攻击后触发 20
             2104:ChConfig.TriggerType_LockHP, # 锁血触发技能 63
             2105:ChConfig.TriggerType_BeLuckyHit, # 被会心一击触发技能 64
             2106:ChConfig.TriggerType_BeSuperHit,  # 被暴击触发技能
             
             4000:ChConfig.TriggerType_BuffState,   # 进入4012的某个状态触发技能 2
             4001:ChConfig.TriggerType_TagBuffState,   # 目标进入4012的某个状态触发技能 2
@@ -303,7 +305,7 @@
             4021:ChConfig.TriggerType_AddSingleSkillPer,   # 持续性攻击的单次攻击逐次增加技能伤害18,
             4022:ChConfig.TriggerType_SkillOverNoAttack,   # 技能释放后 与TriggerType_AttackOver相反19,
             4023:ChConfig.TriggerType_BeAttackOver,   # 被攻击后触发 20
             4024:ChConfig.TriggerType_AddIceAtkPer,    # 攻击附加真实伤害百分比 21
             #4024:ChConfig.TriggerType_AddIceAtkPer,    # 攻击附加真实伤害百分比 21
             4025:ChConfig.TriggerType_AddIceAtk,    # 攻击附加真实伤害固定值 22
             4026:ChConfig.TriggerType_DebuffOff,    # 抵消一次debuff 23
             4027:ChConfig.TriggerType_AttackKill,   # նɱ 24
@@ -330,7 +332,7 @@
             4048:ChConfig.TriggerType_MissSkill,   # 闪避后触发释放技能
             4049:ChConfig.TriggerType_MissSuccessPer, # 闪避成功率提升
             4050:ChConfig.TriggerType_OneDamage,   # 伤害降低到1点
             4051:ChConfig.TriggerType_LuckyHit, # 会心一击时增加会心伤害百分比 50
             4051:ChConfig.TriggerType_LuckyHit, # 会心一击时增加会心伤害固定值 50
             4052:ChConfig.TriggerType_Buff_SuckBloodPer,   # 攻击 百分比吸血
             4053:ChConfig.TriggerType_AddLayer, # BUFF层级增加时 52
             4054:ChConfig.TriggerType_AttackAddSkillPer,  # 所有攻击伤害(SkillPer)增加,含普攻,计算时 5
@@ -348,6 +350,18 @@
             4066:ChConfig.TriggerType_AddDamagePer,   # 提高增加伤害属性值,计算时 3
             4067:ChConfig.TriggerType_ProDefValue, # 神兵护盾值下降时 62
             4068:ChConfig.TriggerType_LockHP, # 锁血触发技能 63
             4069:ChConfig.TriggerType_ZhongjiZhansha, # 终极斩杀 64
             4070:ChConfig.TriggerType_DebuffOff,    # 抵消一次debuff 23
             4071:ChConfig.TriggerType_Buff_SuckBloodPer,   # 攻击 百分比吸血
             4072:ChConfig.TriggerType_SuperHitSkipCD, # 暴击无冷却 68
             4073:ChConfig.TriggerType_BuffHurtCnt, # 当持续buff伤害第X次时触发技能 69
             4074:ChConfig.TriggerType_BounceHP,   # 反弹伤害固定值14, 记录值
             4075:ChConfig.TriggerType_4074PerValue,   # 增加4074的反弹比例
             4076:ChConfig.TriggerType_dFinalHurtReducePer, # 防守方的最终伤害减少百分比 71
             4077:ChConfig.TriggerType_AttackAddFinalPer, # 增加最终伤害百分比 59
             4078:ChConfig.TriggerType_AttackOver,  # 攻击(对敌技能)后被动技能被触发 4
             4079:ChConfig.TriggerType_IsDealy,  # 是否触发致命一击 72
             4080:ChConfig.TriggerType_BounceHPPer, # 反弹伤害百分比值17,
             }
    return tdict.get(effectID, -1) 
    #===========================================================================
@@ -372,19 +386,23 @@
             4506:ChConfig.TriggerType_BeAttackOver, # BUFF类:被攻击触发技能  只刷新属性 不触发技能
             4507:ChConfig.TriggerType_Buff_AddSuperHitRate, # BUFF类:增加暴击率
             4508:ChConfig.TriggerType_Buff_AttackSubLayer,  # BUFF类:攻击减buff层,0消失
             4514:ChConfig.TriggerType_Buff_BeAttackSubLayer,  # BUFF类:被攻击减buff层,0消失
             4509:ChConfig.TriggerType_Buff_SuckBloodPer,   # BUFF类: 百分比吸血, 此处非属性类
             4510:ChConfig.TriggerType_Buff_MustBeHit,   # BUFF类: 无视闪避必中
             4511:ChConfig.TriggerType_AttackAddFinalValue,   #攻击增加输出伤害11
             4512:ChConfig.TriggerType_ReduceHurtHPPer, # 百分比减少攻击计算后伤害 
             4513:ChConfig.TriggerType_AttackAddFinalValue,   #攻击增加输出伤害11
             4515:ChConfig.TriggerType_AddIceAtkPer,    # BUFF类:攻击附加真实伤害百分比
             4514:ChConfig.TriggerType_Buff_BeAttackSubLayer,  # BUFF类:被攻击减buff层,0消失
             #4515:ChConfig.TriggerType_AddIceAtkPer,    # BUFF类:攻击附加真实伤害百分比
             4516:ChConfig.TriggerType_ChangeHurtToHP,    # BUFF类:buff中把受到伤害的xx%转化为生命值
             4517:ChConfig.TriggerType_DebuffOff,   # BUFF类: 抵消debuff
             4518:ChConfig.TriggerType_ForbidenCure, # BUFF类: 禁止治疗 53
             4519:ChConfig.TriggerType_WillDead,   # BUFF类: 进入濒死状态 25
             4520:ChConfig.TriggerType_AddLayer, # BUFF类: 目标BUFF层级增加时 52
             4521:ChConfig.TriggerType_BeLuckyHitSubPer, # 减少受到的会心伤害 65
             4522:ChConfig.TriggerType_DebuffOff,   # BUFF类: 抵消debuff
             4523:ChConfig.TriggerType_SuperHitSkillPer, # 暴击时,增加技能伤害 10
             4524:ChConfig.TriggerType_SuperHitSubLayer, # 暴击减层 67
             4525:ChConfig.TriggerType_SuperHitSkipCD, # 暴击无冷却 68
             
             803:ChConfig.TriggerType_BloodShield,  # 血盾
             806:ChConfig.TriggerType_BloodShield,  # 血盾
@@ -406,6 +424,8 @@
        self.AffectSkillDict = {}    # 被动技能 {(触发模式, 被影响的技能ID):[被动技能ID,效果]
        self.AffectPassiveSkillSetDict = {}    # 被动技能装备 {(触发模式, 被影响的技能ID):[被动技能ID,效果]
        self.AffectDogzSkillDict = {}   # 神兽助战技能
        self.AffectSuperEquipSkillDict = {}   # 特殊装备持有技能,相同技能不重复,数值增长性衰减, 触发使用
        self.AffectSuperEquipEffectCntDict = {}  # 特殊装备技能效果对应的已计算后的数值,直接调用
    
    #记录会影响其他技能或者被动触发释放技能的BUFF
    def AddBuffInfoByEffect(self, effect, skillID):
@@ -489,6 +509,45 @@
                self.AffectDogzSkillDict[key].append((skillTypeID, effectID))
        
        return self.AffectDogzSkillDict
    # 重刷特殊装备技能
    def RefreshSuperEquipSkillDict(self):
        self.AffectSuperEquipSkillDict = {}
        self.AffectSuperEquipEffectCntDict = {}
        skillsDict = FindSuperEquipSkills(self.gameObj)
        for skillID, value in skillsDict.items():
            curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
            if not curSkill:
                continue
            if not SkillCommon.isPassiveTriggerSkill(curSkill):
                continue
            skillTypeID = curSkill.GetSkillTypeID()
            connSkillID = SkillShell.GetConnectSkillID(curSkill)    # 关联技能ID, 0代表不限技能
            for i in xrange(curSkill.GetEffectCount()):
                curEffect = curSkill.GetEffect(i)
                effectID = curEffect.GetEffectID()
                if effectID == 0:
                    continue
                triggerType = GetTriggerTypeByEffectID(effectID)
                if triggerType == -1:
                    continue
                key = (triggerType,connSkillID)
                if key not in self.AffectSuperEquipSkillDict:
                    self.AffectSuperEquipSkillDict[key] = []
                self.AffectSuperEquipSkillDict[key].append((skillTypeID, effectID))
                # 效果叠加根据技能个数会衰减 = 1-pow((1-初始值),相同技能个数)
                self.AffectSuperEquipEffectCntDict[effectID] = 1 - pow((1 - curEffect.GetEffectValue(0)),value)
        GameWorld.DebugLog("RefreshSuperEquipSkillDict %s-%s"%(self.AffectSuperEquipSkillDict, self.AffectSuperEquipEffectCntDict))
        return self.AffectSuperEquipSkillDict
    
    
    # 重刷可装备的被动技能
@@ -598,10 +657,13 @@
        skillList.extend(self.AffectSkillDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectPassiveSkillSetDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectDogzSkillDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectSuperEquipSkillDict.get((triggerType, connSkillID), []))
        if connSkillID != 0 and connSkillID != ChConfig.Def_SkillID_Somersault:
            skillList.extend(self.AffectSkillDict.get((triggerType, 0), []))
            skillList.extend(self.AffectPassiveSkillSetDict.get((triggerType, 0), []))
            skillList.extend(self.AffectDogzSkillDict.get((triggerType, 0), []))
            skillList.extend(self.AffectSuperEquipSkillDict.get((triggerType, 0), []))
        return skillList
        
#所有obj的被动效果管理
@@ -678,6 +740,21 @@
        return
        
        
    # 人物需同步注册装备技能,技能目前为可触发的被动类,若有定义冲突则可用功能类型划分
    def RegistSuperEquipSkillDict(self, gameObj):
        passiveEff = self.GetPassiveEff(gameObj)
        if not passiveEff:
            # 强制刷新所有被动技能
            passiveEff = PassiveEff(gameObj)
            if not passiveEff.RefreshSuperEquipSkillDict():
                return
            self.AddPassiveEff(gameObj, passiveEff)
        else:
            passiveEff.RefreshSuperEquipSkillDict()
        return
    def RegistPassiveBuff(self, gameObj):
        # buff # 筛选buffType 否则NPC没有此接口会报错
        for buffType in [IPY_GameWorld.bfBuff, IPY_GameWorld.bfDeBuff, IPY_GameWorld.bfProcessBuff
@@ -727,36 +804,6 @@
    return PyGameData.g_PassiveEffManager
## 当前释放技能 skillData
#def CalcBuffTriggerSkill(attacker, skillData, target, tick):
#    #===========================================================================
#    # passiveEff = GetPassiveEffManager().GetPassiveEff(attacker, False)
#    # if not passiveEff:
#    #    return
#    # #影响技能的BUFF
#    # buffTriggerSkillDict = passiveEff.GetBuffTriggerSkill(skillData.GetSkillID())
#    # if not buffTriggerSkillDict:
#    #    return
#    #
#    # passiveEff.CalcBuffTriggerSkill(attacker, target, skillData, buffTriggerSkillDict, tick)
#    #===========================================================================
#    OnPassiveSkillTrigger(attacker, target, ChConfig.TriggerType_AttackOver, tick)
#===============================================================================
# # 判断PK关系是否可攻击 Def_BattleRelationType_CommNoBoss也可攻击 只是攻击无效果
# def CheckBattleRelationType(skillBattleType, battleRelationType):
#    if skillBattleType in [ChConfig.Def_BattleRelationType_Comm, ChConfig.Def_BattleRelationType_CommNoBoss]:
#        return True
#
#    #if battleRelationType in [ChConfig.Def_BattleRelationType_Comm, ChConfig.Def_BattleRelationType_CommNoBoss]:
#    #    return True
#
#    if skillBattleType != battleRelationType:
#        # PK模式的判定
#        return False
#    return True
#===============================================================================
# 查找被动技能时的对象
def GetPassiveDefender(attacker, defender):
    # 寻找被击者,1.目标排除是自己(后面逻辑会更换) 2. 查客户端伤害队列,3.查服务端伤害队列    
@@ -778,7 +825,15 @@
        return
    
    return GameWorld.GetObj(curHurt.GetObjID(), curHurt.GetObjType())
# 当前有效被动触发技能, 可用于基础使用判定
def IsValidPassiveSkill(curSkill):
    validMap = SkillShell.GetAttrMapID(curSkill)
    if validMap and validMap != GameWorld.GetMap().GetMapID():
        # 有效地图可触发
        return False
    return True
# 多种被动技能优先触发释放一个,如被动 血量40%触发无敌技能,血量一定是停留在40%
# 先锁血,后触发技能 同 DelayUsePassiveTriggerSkill 使用
@@ -823,6 +878,9 @@
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # 只有天赋才可以再次被触发
            continue 
@@ -973,6 +1031,9 @@
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # 只有天赋才可以再次被触发
            continue 
@@ -1068,6 +1129,10 @@
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # 只有天赋才可以再次被触发
            continue 
@@ -1131,6 +1196,9 @@
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
@@ -1174,6 +1242,9 @@
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
@@ -1223,6 +1294,13 @@
    
    for skillID, effectList in buffDict.items():
        if tagSkillID == skillID:
            continue
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        for passiveEffect in effectList:
            # 被动触发的技能
@@ -1283,15 +1361,19 @@
    for skillID, effectList in buffDict.items():
        if skillID == useSkillID:
            continue
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # 只有天赋才可以再次被触发
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        for passiveEffect in effectList:
            # 被动触发的技能
            pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()
            curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
            if not curSkill:
                continue
            if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
                # 只有天赋才可以再次被触发
                continue
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
            if not callFunc:
                continue
@@ -1361,6 +1443,9 @@
            continue
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        if not IsValidPassiveSkill(curSkill):
            continue
        
        for passiveEffect in effectList:
@@ -1452,3 +1537,31 @@
        skills.append(curSkill)
        
    return skills
# 遍历身上装备技能以及各自个数,装备技能不需要学习
# 保证不同的装备技能不会有相同的效果, 效果数值的衰减是根据相同技能个数计算而不是效果个数 1-pow((1-初始值),相同技能个数)
def FindSuperEquipSkills(gameObj):
    skillsDict = {}
    if gameObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return skillsDict
    equipPack = gameObj.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    for i in xrange(equipPack.GetCount()):
        curEquip = equipPack.GetAt(i)
        if not curEquip or curEquip.IsEmpty():
            continue
        if curEquip.GetAddSkill(0) == 0:
            #无技能
            continue
        for j in xrange(curEquip.GetAddSkillCount()):
            skillID = curEquip.GetAddSkill(j)
            if skillID == 0:
                break
            skillsDict[skillID] = skillsDict.get(skillID, 0) + 1
    return skillsDict