From c2a7d0326f1e779bf6ee184e60d04dd7d43b576b Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期五, 10 五月 2019 16:27:23 +0800
Subject: [PATCH] 3542 【BUG】【2.0】五行灵根重置点数后无法使用五行专精

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/SkillShell.py |  483 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 396 insertions(+), 87 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/SkillShell.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/SkillShell.py
index d1bdcc9..9db66f8 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/SkillShell.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/SkillShell.py
@@ -27,15 +27,11 @@
 import FBLogic
 import ItemCommon
 import OperControlManager
-import GameLogic_ManorWar
 import PetControl
 import ReadChConfig
 import DataRecordPack
-import ChItem
-import PlayerActivity
+#import ChItem
 import ShareDefine
-import PlayerGodWeapon
-import PlayerSuccess
 import PlayerGreatMaster
 import PlayerHorse
 import GameObj
@@ -45,9 +41,13 @@
 import GameMap
 import collections
 import PassiveBuffEffMng
+import EffGetSet
 import SkillShell
 import FBCommon
 import IpyGameDataPY
+import PyGameData
+import EventShell
+#import EquipZhuXian
 #---------------------------------------------------------------------
 GameWorld.ImportAll("Script\\Skill\\" , "GameSkills")
 GameWorld.ImportAll("Script\\Skill\\" , "GameBuffs")
@@ -101,9 +101,6 @@
 def ClearClientHurtDict(curPlayer):
     global g_ClientHurtDict
     g_ClientHurtDict = collections.OrderedDict()
-    
-    # 缓存单次技能攻击的最大伤害, 减少计算量
-    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientMaxHurtValue, 0)
     
     
 def GetClientHurtByObj(objID, objType):
@@ -166,6 +163,10 @@
 # 非客户端玩家释放的技能
 def IsPlayerUseSkill(attacker, curSkill):
     if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
+        return False
+    
+    if not curSkill:
+        # 玩家普通也是技能,正常是不会走到这边
         return False
     
     useSkillData = attacker.GetUseSkill()
@@ -245,7 +246,8 @@
     #还在冷却时间内无法释放
     if SkillCommon.RefreshSkillRemainTime(playerSkill, tick) != 0:
         PlayerControl.NotifyCode(curPlayer, "UseSkillCDLimit")
-        AttackFailNotify(curPlayer, curSkill, ChConfig.SkillFail_CD)
+        #AttackFailNotify(curPlayer, curSkill, ChConfig.SkillFail_CD)
+        playerSkill.Sync_Skill()
         return False
 
     #5:检查玩家的魔法值是否够用这个技能
@@ -345,6 +347,13 @@
 # @return 返回值真, 检查通过
 # @remarks 自定义函数, NPC使用有对象技能
 def NPCUseSkillTag(curNPC, curTag, curSkill, tick):
+    skillTag = GetSkillAffectTag(curSkill)
+    if skillTag == ChConfig.Def_UseSkillTag_AppointNPC:
+        # 指定释放的NPCID 和 Def_UseSkillTag_AppointNPC 搭配使用
+        curTag = GetAppointNPCBySkillEffect(curSkill)
+        if not curTag:
+            return False
+    
     if not NPCCanUseSkillTag(curNPC, curTag, curSkill, tick):
         return False
     
@@ -361,6 +370,29 @@
         curNPC.SetDict(ChConfig.Def_NPC_Dict_AtkMovePosY, 0)
         
     return result
+
+# 指定释放的NPCID 和 Def_UseSkillTag_AppointNPC 搭配使用
+def GetAppointNPCBySkillEffect(curSkill):
+    npcID = 0
+    effectID = ChConfig.Def_Skill_Effect_AppointNPC
+    for i in xrange(0, curSkill.GetEffectCount()):
+        curEffect = curSkill.GetEffect(i)
+        curEffectID = curEffect.GetEffectID()
+        
+        if not curEffectID:
+            #策划有可能中途删除,不用return
+            continue
+        
+        #不是需要的效果
+        if curEffectID != effectID:
+            continue
+
+        npcID = curEffect.GetEffectValue(0)
+        break
+
+    if not npcID:
+        return None
+    return GameWorld.FindNPCByNPCID(npcID)
 
 
 # 计算NPC技能位移坐标,预警和非预警都可以用
@@ -509,6 +541,9 @@
 # @return 返回值真, 检查通过
 def NPCCanUseSkillTag(curNPC, curTag, curSkill, tick):
     skillTag = GetSkillAffectTag(curSkill)
+    if skillTag == ChConfig.Def_UseSkillTag_AppointNPC:
+        return True
+    
     #---对象判定---
     if IsToPetOwnerSkill(curNPC, skillTag):
         return True
@@ -682,9 +717,27 @@
             continue
         npcObj.StopMove()
         npcObj.ChangePos(npcPos.PosX, npcPos.PosY)
-
+        BeatBackMove(curPlayer, npcObj)
     return
 
+# 针对NPC被推出远距离一直卡墙角问题,法宝挑战副本特殊处理为超过4米 NPC自动回退一些
+def BeatBackMove(curPlayer, npcObj):
+    if GameWorld.GetMap().GetMapID() != ChConfig.Def_FBMapID_MagicWeapon:
+        return
+    if npcObj.GetCurAction() == IPY_GameWorld.laNPCSkillWarning:
+        return
+    
+    posMap = npcObj.GetRefreshPosAt(npcObj.GetCurRefreshPointIndex())
+    #范围校验
+    posMapX = posMap.GetPosX()
+    posMapY = posMap.GetPosY()
+    if GameWorld.GetDist(npcObj.GetPosX(), npcObj.GetPosY(), posMapX, posMapY) < 8:
+        # 单次位移不超过5米
+        return
+    npcControl = NPCCommon.NPCControl(npcObj)
+    moveDestX, moveDestY = npcControl.GetMoveNearPosEx(posMapX, posMapY, 5)
+    npcObj.Move(moveDestX, moveDestY)
+    return
 
 #===============================================================================
 # //B4 03 吸引NPC仇恨 #tagNPCAttention
@@ -852,6 +905,7 @@
     Def_Attack_DelayTick = 5000
     # tick 误差过大则过滤
     if abs(clientTick - tick) > Def_Attack_DelayTick:
+        curPlayer.Sync_ClientTick()
         GameWorld.DebugLog("tick 误差过大则过滤 > 5000")
         return False
     
@@ -929,10 +983,12 @@
         #GameWorld.ErrLog('UseSkill findSkillErr = %s'%(pack_SkillID), curPlayerID)
         return
 
-    if not CheckClientAttackTick(curPlayer, clientTick, tick):
-        AttackFailNotify(curPlayer, curSkill, ChConfig.SkillFail_AtkInterval)  
-        curPlayer.Sync_ClientTick() 
-        return
+    if pack_SkillID != ChConfig.Def_SkillID_Somersault:
+        # 翻滚特殊处理,实时响应, 由CD 总控制
+        if not CheckClientAttackTick(curPlayer, clientTick, tick):
+            AttackFailNotify(curPlayer, curSkill, ChConfig.SkillFail_AtkInterval)  
+            curPlayer.Sync_ClientTick() 
+            return
 
     #已经在攻击中
     if curPlayer.GetPlayerAction() == IPY_GameWorld.paAttack:
@@ -942,7 +998,7 @@
     #使用技能行为状态, 客户端限制    
     if not OperControlManager.IsObjCanDoAction(curPlayer, 
                                                ChConfig.Def_Obj_ActState_ClientSkill, 
-                                               curSkill.GetSkillOfSeries()):
+                                               curSkill.GetSkillOfSeries(), curSkill):
         AttackFailNotify(curPlayer, curSkill)
         return    
 
@@ -1028,6 +1084,7 @@
 def AttackFailNotify(curPlayer, curSkill, reason=0):
     sendPack = ChPyNetSendPack.tagMCAttackFail()
     sendPack.SkillID = curSkill.GetSkillID()
+    sendPack.Reason = reason
     NetPackCommon.SendFakePack(curPlayer, sendPack)
 #--------------------------玩家使用技能
 #===============================================================================
@@ -1797,17 +1854,19 @@
     
     #升级技能CD直接冷却
     curSkill.SetRemainTime(0)
+    learnSkillNotifyDict = IpyGameDataPY.GetFuncEvalCfg("SPSkillType", 3, {})
     if curSkill.GetFuncType() == ChConfig.Def_SkillFuncType_HorseSkill:
         PlayerControl.WorldNotify(0, 'GetMountSkill', [curPlayer.GetName(), curSkillID])
+    elif skillTypeID in learnSkillNotifyDict:
+        PlayerControl.WorldNotify(0, learnSkillNotifyDict[skillTypeID], [curPlayer.GetName(), curSkillID])        
     else:
         #通知技能已升级成功 GeRen_admin_31379
         PlayerControl.NotifyCode(curPlayer, "GeRen_admin_31379", [curSkillID, curSkill.GetSkillLV()])
     
     #获得技能等级
     curSkillLV = curSkill.GetSkillLV()
-    
     DataRecordPack.DR_LearnORUPSkill(curPlayer, curSkillID, curSkillLV)
-
+    EventShell.EventRespons_SkillUp(curPlayer, curSkill.GetFuncType(), curSkillLV)
     GameWorld.Log("升级技能名 = %s 成功, 当前等级 = %s"%(curSkill.GetSkillName(), curSkill.GetSkillLV()), curPlayer.GetPlayerID())
     return True
 
@@ -1840,6 +1899,11 @@
     if upSkill.GetFuncType() == ChConfig.Def_SkillFuncType_GiftSkill:
         if not PlayerGreatMaster.GetGreatMasterFreeSkillPoint(curPlayer):
             return False
+    #诛仙技能学习判断
+    #if upSkill.GetFuncType() == ChConfig.Def_SkillFuncType_ZhuXian:
+    #    if not EquipZhuXian.CheckLearnZhuXianSkill(curPlayer, curSkillTypeID):
+    #        return False
+        
     #经验检测
     skillLvUpNeedExp = upSkill.GetLVUpCostExp()
     
@@ -1924,35 +1988,29 @@
         return False
     
     skillManager = curPlayer.GetSkillManager()
-    #姿态需求
-    #hasStateSkillReq = False
+
     #前置技能需求
     hasLearnSkillReq = False
     #分支点总和
     numLearnSkillPoint = 0
-    #当前技能姿态需求,姿态等级需求
-    #curSkillStateReq = curSkill.GetStateSkillReq()
-    #lvCurSkillStateReq = curSkill.GetStateSkillLV()
     #当前技能前置技能需求,前置技能等级需求
     curSkillLearnReq = curSkill.GetLearnSkillReq()
     lvCurSkillLearnReq = curSkill.GetLearnSkillLV()
     #需要对应天赋系别点数
-    learnSkillPointReq = curSkill.GetLearnSkillPointReq()
+    learnSkillPointReq = curSkill.GetLearnSkillPointReq() #系别*10000+需要点数
     needSeries, needSeriesPoint= learnSkillPointReq/10000, learnSkillPointReq%10000
-    ipyData = IpyGameDataPY.GetIpyGameDataNotLog('TalentSkill', curSkill.GetSkillTypeID())
+    curSkillTypeID = curSkill.GetSkillTypeID()
+    ipyData = IpyGameDataPY.GetIpyGameDataNotLog('TalentSkill', curSkillTypeID)
     curTalentType = ipyData.GetTalentType() if ipyData else 0
     #获取玩家目前所有技能
-    for i in range(0, skillManager.GetSkillCount()):
+    for i in xrange(skillManager.GetSkillCount()):
         skill = skillManager.GetSkillByIndex(i)
         if skill == None:
             continue
         
         skillTypeID = skill.GetSkillTypeID()
         lvSkill = skill.GetSkillLV()
-        
-        #满足姿态ID需求
-#        if skillTypeID == curSkillStateReq and lvSkill >= lvCurSkillStateReq and not hasStateSkillReq:
-#            hasStateSkillReq = True
+
         
         #满足前置技能需求
         if skillTypeID == curSkillLearnReq and lvSkill >= lvCurSkillLearnReq and not hasLearnSkillReq:
@@ -1966,19 +2024,262 @@
     if curSkillLearnReq != 0 and not hasLearnSkillReq:
         PlayerControl.NotifyCode(curPlayer, "GeRen_wjr_717982", [curSkillLearnReq, lvCurSkillLearnReq])
         return False
-    
-#    #有姿态ID需求
-#    if curSkillStateReq != 0 and not hasStateSkillReq:
-#        PlayerControl.NotifyCode(curPlayer, "UseMagicLost15", [ curSkillStateReq, lvCurSkillStateReq ])
-#        return False
              
     #有分支点总和要求
     if learnSkillPointReq != 0 and numLearnSkillPoint < needSeriesPoint:
         PlayerControl.NotifyCode( curPlayer, "UseMagicLost13",[ needSeriesPoint ] ) 
         return False
     
+    #玩家属性点要求
+    if not CheckLearnSkillNeedAttr(curPlayer, curSkill):
+        return False
+        
     return True
 
+def CheckLearnSkillNeedAttr(curPlayer, curSkill):
+    #玩家属性点要求
+    curSkillTypeID = curSkill.GetSkillTypeID()
+    stateSkillLV = curSkill.GetStateSkillLV() #需要基础属性ID*100000+需要属性点
+    needBaseAttrID, needBaseAttrValue = GetSkillUpNeedAttr(stateSkillLV)
+    if needBaseAttrID and needBaseAttrValue:
+        baseAttrDict = {
+                            ShareDefine.Def_Effect_Metal:PlayerControl.GetMetal(curPlayer),
+                            ShareDefine.Def_Effect_Wood:PlayerControl.GetWood(curPlayer),
+                            ShareDefine.Def_Effect_Water:PlayerControl.GetWater(curPlayer),
+                            ShareDefine.Def_Effect_Fire:PlayerControl.GetFire(curPlayer),
+                            ShareDefine.Def_Effect_Earth:PlayerControl.GetEarth(curPlayer),
+                         }
+        if needBaseAttrID not in baseAttrDict:
+            GameWorld.ErrLog('    技能升级属性点条件配置错误,curSkillTypeID=%s,needBaseAttrID=%s'%(curSkillTypeID, needBaseAttrID))
+            return False
+        curBaseAttrValue = baseAttrDict.get(needBaseAttrID, 0)
+        if curBaseAttrValue < needBaseAttrValue:
+            #GameWorld.DebugLog('升级技能%s需要属性点 %s达到%s, 当前点数=%s!'%(curSkillTypeID, needBaseAttrID, needBaseAttrValue, curBaseAttrValue))
+            return False
+    return True
+
+## 获取技能升级属性需求 rutrun attrID, attrvalue
+def GetSkillUpNeedAttr(stateSkillLV):return stateSkillLV /100000, stateSkillLV%100000
+
+#// A5 16 选择技能五行专精 #tagCMSelectSkillElement
+#
+#struct    tagCMSelectSkillElement
+#{
+#    tagHead        Head;
+#    DWORD    SkillTypeID;    // 专精技能ID
+#};
+def OnSelectSkillElement(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    selectSkillID = clientData.SkillTypeID
+    ipyData = IpyGameDataPY.GetIpyGameData('SkillElement', selectSkillID)
+    if not ipyData:
+        return
+    mainSkillID = ipyData.GetMainSkillID()
+    if curPlayer.GetLV() < ipyData.GetNeedLV():
+        GameWorld.DebugLog('选择技能五行专精等级不足!')
+        return
+    
+    skillManager = curPlayer.GetSkillManager()
+    mainSkill = skillManager.FindSkillBySkillTypeID(mainSkillID)
+    if not mainSkill:
+        GameWorld.DebugLog('主技能未学习,无法选专精mainSkillID=%s'%mainSkillID)
+        return
+    curElementSkillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementID % mainSkillID)
+    activeSkillLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementLV % selectSkillID)
+    #先判断是否可升级
+    updSelectSkillLV = activeSkillLV
+    nextSkill = GameWorld.GetGameData().FindSkillByType(selectSkillID, activeSkillLV + 1)
+    if nextSkill:
+        if CheckLearnSkillNeedAttr(curPlayer, nextSkill):
+            updSelectSkillLV = activeSkillLV + 1
+    isChangeSkill = False #是否变更生效的技能
+    if updSelectSkillLV != activeSkillLV:
+        #可升级则激活升一级
+        EventShell.EventRespons_ElementSkill(curPlayer, mainSkillID, updSelectSkillLV)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SkillElementLV % selectSkillID, updSelectSkillLV)
+        if curElementSkillID == selectSkillID:
+            #正在使用的专精技能,则立即生效
+            isChangeSkill = True
+    elif selectSkillID != curElementSkillID:
+        isChangeSkill = True
+        
+    if isChangeSkill:
+        #更换专精
+        if not RefreshElementSkill(curPlayer, selectSkillID):
+            GameWorld.DebugLog('更换专精 不成功 selectSkillID=%s'%selectSkillID)
+            return
+        
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SkillElementID % mainSkillID, selectSkillID)
+        if curElementSkillID:
+            if curElementSkillID != selectSkillID:
+                #原技能删除
+                skillManager.DeleteSkillBySkillTypeID(curElementSkillID)
+        
+    
+        # 重刷被动技能
+        PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer)
+        # 重刷技能战力
+        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+       
+    NotifyElementSkillInfo(curPlayer, mainSkillID, selectSkillID if updSelectSkillLV != activeSkillLV else 0)
+    return
+
+def RefreshElementSkill(curPlayer, skillTypeID, isChangeLV=True):
+    ##更新专精技能生效的等级
+    __InitElementSkillInfo()
+    if skillTypeID not in PyGameData.g_elemntSkillDict:
+        return
+    baseAttrDict = {
+                            ShareDefine.Def_Effect_Metal:PlayerControl.GetMetal(curPlayer),
+                            ShareDefine.Def_Effect_Wood:PlayerControl.GetWood(curPlayer),
+                            ShareDefine.Def_Effect_Water:PlayerControl.GetWater(curPlayer),
+                            ShareDefine.Def_Effect_Fire:PlayerControl.GetFire(curPlayer),
+                            ShareDefine.Def_Effect_Earth:PlayerControl.GetEarth(curPlayer),
+                         }
+    activeSkillLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementLV % skillTypeID)
+    limitInfoList = PyGameData.g_elemntSkillDict[skillTypeID]
+    maxSkillLV = len(limitInfoList)
+    updSkillLV = 0
+    for i, limitInfo in enumerate(limitInfoList):
+        needAttrID, needAttrValue = GetSkillUpNeedAttr(limitInfo)
+        curAttrValue = baseAttrDict.get(needAttrID, 0)
+        if curAttrValue >= needAttrValue:
+            updSkillLV = maxSkillLV - i
+            break
+    if activeSkillLV > updSkillLV:
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SkillElementLV % skillTypeID, updSkillLV)
+    updSkillLV = min(updSkillLV, activeSkillLV) #不可超过激活的等级
+    skillManager = curPlayer.GetSkillManager()
+    curSkill = skillManager.FindSkillBySkillTypeID(skillTypeID)
+    curSkillLV = curSkill.GetSkillLV() if curSkill else 0
+    #GameWorld.DebugLog('更新专精技能生效的等级 skillTypeID=%s,curSkillLV=%s,activeSkillLV=%s,updSkillLV=%s'%(skillTypeID, curSkillLV, activeSkillLV, updSkillLV))
+    if not isChangeLV:
+        return
+    if updSkillLV == curSkillLV:
+        return
+    elif updSkillLV < curSkillLV:
+        skillManager.DeleteSkillBySkillTypeID(skillTypeID)
+        for _ in xrange(updSkillLV):
+            skillManager.LVUpSkillBySkillTypeID(skillTypeID)
+        if updSkillLV == 0:#重置为未选状态
+            ipyData = IpyGameDataPY.GetIpyGameData('SkillElement', skillTypeID)
+            mainSkillID = ipyData.GetMainSkillID()
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SkillElementID % mainSkillID, 0)
+    else:
+        for _ in xrange(updSkillLV-curSkillLV):
+            skillManager.LVUpSkillBySkillTypeID(skillTypeID)
+    return True
+
+def RefreshElementSkillByAttr(curPlayer, attrIDList):
+    #加点、丹药、境界、洗点 会影响灵根点
+    __InitElementSkillInfo()
+    
+    needRefreshSkillIDDict = {} #{skillid:是否变更技能等级}
+    skillManager = curPlayer.GetSkillManager()
+    for i in xrange(skillManager.GetSkillCount()):
+        hasSkill = skillManager.GetSkillByIndex(i)
+        hasSkillID = hasSkill.GetSkillTypeID()
+        ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('SkillElement', {'MainSkillID':hasSkillID}, True, False)
+        if not ipyDataList:
+            continue
+        curSelectSkillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementID % hasSkillID)
+        for ipyData in ipyDataList:
+            curElementSkillID = ipyData.GetElementSkillID()
+            if curElementSkillID not in PyGameData.g_elemntSkillDict:
+                continue
+            attrID = GetSkillUpNeedAttr(PyGameData.g_elemntSkillDict[curElementSkillID][0])[0]
+            if attrID not in attrIDList:
+                continue
+            needRefreshSkillIDDict[curElementSkillID] = curSelectSkillID == curElementSkillID
+    
+    #GameWorld.DebugLog('属性点变更 刷新专精attrIDList=%s,needRefreshSkillIDList=%s'%(attrIDList,needRefreshSkillIDList))
+    isRefresh = False
+    for skillID, isChangeLV in needRefreshSkillIDDict.items():
+        if RefreshElementSkill(curPlayer, skillID, isChangeLV):
+            isRefresh = True
+    if isRefresh:
+        # 重刷被动技能
+        PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer)    
+        # 重刷技能战力
+        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+    NotifyElementSkillInfo(curPlayer)
+    return
+
+def GetElementSkillCnt(curPlayer, mainSkillIDList, activeLV):
+    ##获取已选择的专精技能数量
+    cnt = 0
+    skillManager = curPlayer.GetSkillManager()
+    for i in xrange(skillManager.GetSkillCount()):
+        hasSkill = skillManager.GetSkillByIndex(i)
+        hasSkillID = hasSkill.GetSkillTypeID()
+        if hasSkillID not in mainSkillIDList:
+            continue
+        ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('SkillElement', {'MainSkillID':hasSkillID}, True, False)
+        if not ipyDataList:
+            continue
+        for ipyData in ipyDataList:
+            elementSkillID = ipyData.GetElementSkillID()
+            curActiveLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementLV % elementSkillID)
+            if curActiveLV >= activeLV:
+                cnt += 1
+    return cnt
+
+def __InitElementSkillInfo():
+    #缓存技能专精信息{skillID:[attrID*100000+needValue,..]}
+    if not PyGameData.g_elemntSkillDict:
+        ipyMgr = IpyGameDataPY.IPY_Data()
+        for i in xrange(ipyMgr.GetSkillElementCount()):
+            ipyData = ipyMgr.GetSkillElementByIndex(i)
+            elementSkillID = ipyData.GetElementSkillID()
+            skill = GameWorld.GetGameData().FindSkillByType(elementSkillID, 1)
+            if not skill:
+                continue
+            skillMaxLV = skill.GetSkillMaxLV() # 最高技能等级
+            for skillLV in xrange(skillMaxLV, 0, -1):
+                curSkill = GameWorld.GetGameData().FindSkillByType(elementSkillID, skillLV)
+                if not curSkill:
+                    continue
+                if elementSkillID not in PyGameData.g_elemntSkillDict:
+                    PyGameData.g_elemntSkillDict[elementSkillID] = []
+                PyGameData.g_elemntSkillDict[elementSkillID].append(curSkill.GetStateSkillLV())
+    return
+
+def NotifyElementSkillInfo(curPlayer, mainSkillID=0, changeSkillID=0):
+    ##通知五行专精信息
+    if not mainSkillID:
+        syncMainSkillDict = {}
+        skillManager = curPlayer.GetSkillManager()
+        for i in xrange(skillManager.GetSkillCount()):
+            hasSkill = skillManager.GetSkillByIndex(i)
+            hasSkillID = hasSkill.GetSkillTypeID()
+            ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('SkillElement', {'MainSkillID':hasSkillID}, True, False)
+            if not ipyDataList:
+                continue
+            syncMainSkillDict[hasSkillID] = []
+            for ipyData in ipyDataList:
+                syncMainSkillDict[hasSkillID].append(ipyData.GetElementSkillID())
+
+    else:
+        syncMainSkillDict = {mainSkillID:[changeSkillID]} if changeSkillID else {mainSkillID:[]}
+    sendPack = ChPyNetSendPack.tagMCSkillElementInfo()
+    sendPack.InfoList = []
+    for mSkillID, elementList in syncMainSkillDict.items():
+        curElementSkillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementID % mSkillID)
+        elementData = ChPyNetSendPack.tagMCSkillElementData()
+        elementData.MainSkillID = mSkillID
+        elementData.ElementSkillID = curElementSkillID
+        elementData.ActiveSkill = []
+        for elementSkillID in elementList:
+            activeData = ChPyNetSendPack.tagMCSkillElementActiveData()
+            activeData.SkillID = elementSkillID
+            activeData.ActiveLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SkillElementLV % elementSkillID)
+            elementData.ActiveSkill.append(activeData)
+        elementData.SkillCnt = len(elementData.ActiveSkill)
+        sendPack.InfoList.append(elementData)
+    sendPack.Cnt = len(sendPack.InfoList)
+    NetPackCommon.SendFakePack(curPlayer, sendPack)
+    return
+    
 #---------------------------------------------------------------------
 ##当前buff是否能够触发BuffProcess_%d 的脚本
 # @param curObj 对象
@@ -2198,14 +2499,6 @@
             #GameWorld.Log("删除场景Buff %d"%skillID)
             processResult = True
             continue
-        else:
-            # 非领地战期间, 该区域有领地旗buff, 删除区域buff
-            if skillID == ChConfig.Def_SkillID_ManorFlagArea and not GameLogic_ManorWar.CanManorWarAtk():
-                mapBuffManager.DeleteBuffByIndex(index)
-                ClearBuffEffectBySkillID(curPlayer, skillID, ownerID, ownerType)
-                processResult = True
-                #GameWorld.DebugLog("非领地战期间, 该区域有领地旗buff, 删除区域buff")
-                continue
         
         index += 1
         
@@ -2231,10 +2524,7 @@
                 continue
             if findBuff.GetSkill().GetSkillLV() > curSkill.GetSkillLV():
                 continue
-        
-        if skillTypeID == ChConfig.Def_SkillID_ManorFlagArea and not GameLogic_ManorWar.CanManorWarAtk():
-            #GameWorld.DebugLog("    i=%s,effectID=%s,skillID=%s, 该位置有buff, 非领地战期间, 不添加" % (i, effectID, skillTypeID))
-            continue
+            
         #添加场景buff
         isOK = BuffSkill.AddBuffNoRefreshState(curPlayer, IPY_GameWorld.bfMapBuff, curSkill, tick)
         processResult = processResult or isOK
@@ -2339,6 +2629,9 @@
         #骑马触发技能
         houseSkill = ChConfig.Def_Skill_TypeID_Speed
         curSkillType = curSkill.GetSkillTypeID()
+        
+        if not SkillCommon.IsBuff(curSkill):
+            continue
         
         if curSkillType in houseSkill:
             #不使用,不添加buff
@@ -2448,6 +2741,13 @@
         callFunc(objDetel, curEffect, allAttrList[index], plusValue)
     else:
         callFunc = GameWorld.GetExecFunc(GameBuffs, "Buff_%s.%s"%(moduleSuffix, "OnCalcBuffEx"))
+        if callFunc:
+            callFunc(objDetel, curEffect, allAttrList[index], curBuff)
+    
+    #是否持续性技能
+    if curBuff and curBuff.GetSkill().GetSkillType() in ChConfig.Def_LstBuff_List:
+        # 持续性属性变化的buff,目前只有持续减益
+        callFunc = GameWorld.GetExecFunc(GameBuffs, "BuffProcess_%s.%s"%(moduleSuffix, "OnCalcBuffEx"))
         if callFunc:
             callFunc(objDetel, curEffect, allAttrList[index], curBuff)
     return
@@ -2578,7 +2878,7 @@
         buffState.DeleteEffectByIndex(i)
 
 
-# 通过技能ID列表删除buff对应的效果ID
+# 通过技能ID列表删除buff对应的效果ID, 死亡调用
 def ClearBuffEffectBySkillIDList(curObj, buffState, skillIDList):
     
     effectIndexList = []
@@ -2588,11 +2888,17 @@
         if curEffectID == 0:
             continue
         
-        # [技能ID, 来源对象ID,对象类型]
-        if [buffState.GetEffectFromSkillID(i), 
-            buffState.GetEffectOwnerID(i), 
-            buffState.GetEffectOwnerType(i)] not in skillIDList:
+        #=======================================================================
+        # # [技能ID, 来源对象ID,对象类型]
+        # if [buffState.GetEffectFromSkillID(i), 
+        #    buffState.GetEffectOwnerID(i), 
+        #    buffState.GetEffectOwnerType(i)] not in skillIDList:
+        #    continue
+        #=======================================================================
+        # 改成只判断技能ID
+        if buffState.GetEffectFromSkillID(i) not in skillIDList:
             continue
+        
         effectIndexList.append(i)
         
     # 倒序删除
@@ -2639,6 +2945,7 @@
         OperControlManager.SetObjActState(curObj, buffSkill)
 
 
+
 # 计算属性类技能的属性,同buff层不算战力
 def CalcPassiveAttr_Effect(curPlayer, allAttrList):
     skillManager = curPlayer.GetSkillManager()
@@ -2653,7 +2960,8 @@
         if curPlayerSkill.GetFuncType() not in [ChConfig.Def_SkillFuncType_FbSkill,
                                             ChConfig.Def_SkillFuncType_FbSPSkill,
                                             ChConfig.Def_SkillFuncType_GiftSkill,
-                                            ChConfig.Def_SkillFuncType_GWSkill]:
+                                            ChConfig.Def_SkillFuncType_GWSkill,
+                                            ChConfig.Def_SkillFuncType_ZhuXian]:
             # 根据技能情况调整
             continue
         
@@ -2689,15 +2997,15 @@
 def CalcBuffers_Effect(curPlayer, allAttrList, calcEffectIDList=[]):
     
     for buffType in range(IPY_GameWorld.bfBuff, IPY_GameWorld.btBufMax):
+        #这些类型不影响玩家计算属性
+        if buffType in [IPY_GameWorld.bfProcessBuff, #IPY_GameWorld.bfProcessDeBuff, 
+                        IPY_GameWorld.bfMapBuff,
+                        IPY_GameWorld.bfEquipBuff]:
+            continue
+        
         buffTuple = SkillCommon.GetBuffManagerByBuffType(curPlayer, buffType)
         #通过类型获取目标的buff管理器为空,则跳出
         if buffTuple == ():
-            continue
-        
-        #这些类型不影响玩家计算属性
-        if buffType in [IPY_GameWorld.bfProcessBuff,
-                        IPY_GameWorld.bfProcessDeBuff, IPY_GameWorld.bfMapBuff,
-                        IPY_GameWorld.bfEquipBuff]:
             continue
         
         buffManager = buffTuple[0]
@@ -3126,7 +3434,6 @@
 
 # 不受限制和影响的技能
 def Trigger_UseSkill(attacker, defender, curSkill, tick, tagRoundPosX = 0, tagRoundPosY = 0, isEnhanceSkill = False):
-
     
     #这个技能是Buff
     if SkillCommon.IsBuff(curSkill):
@@ -3207,16 +3514,6 @@
     return True
 
 
-#===============================================================================
-# Def_Effect_GoddessAddHP = 1300    # 加血 (压总值血量百分比)
-# Def_Effect_AddHPValue_All = 1027    # 持续加血(压总值攻击)
-# Def_Effect_LostHPValue_All = 1033    # 持续减血(压总值攻击)
-# Def_Effect_LostAndAddHPValue_All = 1050    # 持续吸血(压总值攻击)
-# Def_Effect_LostHPValue_Single = 1201    # 持续单次减血计算 攻击
-# Def_Effect_AddHPValue_Single = 1202    # 持续单次加血计算 攻击
-# Def_Effect_LostHP_MaxHP = 1089    # 持续减血(压总值, 血量百分比)
-#===============================================================================
-
 #waring: 此值影响了BUFF的替换规则,值大替换小的
 ##添加BUFF前压入BUFF的值,这边只计算和攻击者相关,仅支持放在效果1的buff
 # @param attacker 攻击方
@@ -3225,7 +3522,6 @@
 def GetAddBuffValue(attacker, curSkill, defender):
     #验证该技能效果1的ID,提取公式
     curEffect = curSkill.GetEffect(0)
-    effectID = curEffect.GetEffectID()  
     
     moduleSuffix = GetBuffModuleSuffix(curEffect)
     
@@ -3342,7 +3638,7 @@
     return
 
 #---------------------------------------------------------------------
-# 获得关联技能
+# 获得关联技能,0 全部 1是主动型技能(法宝,普攻)   其他技能ID
 def GetConnectSkillID(curSkill):
     return curSkill.GetExAttr1()
 
@@ -3362,7 +3658,7 @@
     
     return curSkill.GetExAttr2()
 
-# 只有在指定地图才能生效的buff效果
+# 只有在指定地图才能生效的buff效果,或者指定地图可被动触发
 def GetAttrMapID(curSkill):
     return curSkill.GetExAttr3()
 
@@ -3378,6 +3674,7 @@
 # @return 技能升级消耗物品数量
 def GetUpLVCostItemNum(curSkill):
     return curSkill.GetExAttr5()
+
 
 
 ##获得当前技能升级消耗的真气值
@@ -3426,9 +3723,11 @@
 
     if skillAim == ChConfig.Def_UseSkillAim_None:
         if curSkill.GetSkillType() in ChConfig.Def_CanAttackSkill_List:
-            if target and target.GetGameObjType() == IPY_GameWorld.gotNPC and target.GetType() == IPY_GameWorld.ntElf:
-                # 有害技能特殊处理,不能对自己的召唤物释放
-                target = None
+            if target and target.GetGameObjType() == IPY_GameWorld.gotNPC and target.GetGameNPCObjType() == IPY_GameWorld.gnotSummon:
+                owner = NPCCommon.GetNpcObjOwnerDetail(target)
+                if owner and owner.GetID() == attacker.GetID():
+                    # 有害技能特殊处理,不能对自己的召唤物释放
+                    target = None
                 
             result = DoLogic_UseSkill(attacker, target, curSkill, tick, attacker.GetPosX(), attacker.GetPosY(), isEnhanceSkill=isEnhanceSkill)
         else:
@@ -3478,25 +3777,35 @@
 
 
 
-## 获取技能总等级
+## 获取某类型技能达到X等级的个数
 #  @param curPlayer
-#  @return allSkillLV:总技能等级
-def GetAllSkillLV(curPlayer):
-    successSkillIDList = ReadChConfig.GetEvalChConfig("SuccessSkillIDList")
-    allSkillLV = 0
+#  @return
+def GetSkillCntByFunc(curPlayer, funcType, skilllv=0):
+    allSkillCnt = 0
     skillManager = curPlayer.GetSkillManager()
-    for i in range(0 , skillManager.GetSkillCount()):
+    for i in xrange(skillManager.GetSkillCount()):
         curPlayerSkill = skillManager.GetSkillByIndex(i)
         if curPlayerSkill == None:
             continue
-        
-        skillTypeID = curPlayerSkill.GetSkillTypeID()
-        if skillTypeID not in successSkillIDList:
+        if curPlayerSkill.GetFuncType() != funcType:
             continue
+        if curPlayerSkill.GetSkillLV() >= skilllv:
+            allSkillCnt += 1
         
+    return allSkillCnt
+
+## 获取技能总等级
+#  @param curPlayer
+#  @return allSkillLV:总技能等级
+def GetAllSkillLV(curPlayer, funcType):
+    allSkillLV = 0
+    skillManager = curPlayer.GetSkillManager()
+    for i in xrange(skillManager.GetSkillCount()):
+        curPlayerSkill = skillManager.GetSkillByIndex(i)
+        if curPlayerSkill == None:
+            continue
+        if curPlayerSkill.GetFuncType() != funcType:
+            continue
         skillLV = curPlayerSkill.GetSkillLV()
         allSkillLV += skillLV
-        
     return allSkillLV
-
-

--
Gitblit v1.8.0