| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Skill.PassiveBuffEffMng  | 
| #  | 
| # @todo:±»¶¯buffЧ¹û¹ÜÀí  | 
| # @author hxp  | 
| # @date 2015-3-6  | 
| # @version 1.1  | 
| #  | 
| # @change: "2016-11-16 15:30" hxp Ôö¼Ó»ñȡ˥ÈõЧ¹ûÐÅÏ¢ÁÐ±í  | 
| #  | 
| # ÏêϸÃèÊö: ±»¶¯buffЧ¹û¹ÜÀís  | 
| #  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2016-11-16 15:30"""  | 
| #---------------------------------------------------------------------  | 
|           | 
| #µ¼Èë  | 
| import IPY_GameWorld  | 
| import ReadChConfig  | 
| import PassiveBuff  | 
| import GameWorld  | 
| import ChConfig  | 
| import IpyGameDataPY  | 
| import SkillCommon  | 
| import BuffSkill  | 
| import SkillShell  | 
| import PlayerControl  | 
| import NetPackCommon  | 
| import ChPyNetSendPack  | 
| import PlayerVip  | 
| import AttackCommon  | 
| import PyGameData  | 
| import PlayerHorse  | 
| import BaseAttack  | 
| import EventShell  | 
| import NPCCommon  | 
| import PetControl  | 
| import QuestCommon  | 
|   | 
| GameWorld.ImportAll("Script\\Skill\\", "PassiveBuff")  | 
|   | 
|   | 
|   | 
| # --------±»¶¯¹¦·¨ÉèÖÃ--------------------------------------------------------------------  | 
|   | 
| #===============================================================================  | 
| # // B4 07 ±»¶¯¼¼ÄÜÉèÖ㨹¦·¨£© # tagCMPassiveSet  | 
| #   | 
| # struct    tagCMPassiveSet  | 
| # {  | 
| #    tagHead        Head;  | 
| #    BYTE        Page;    // ·ÖÒ³  | 
| #    BYTE        Index;    // ÐòºÅ  | 
| #    DWORD        SkillID;    // ¼¼ÄÜID  | 
| # };  | 
| #===============================================================================  | 
| def OnPassiveSet(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     findSkill = None  | 
|     if clientData.SkillID != 0:  | 
|         findSkill = curPlayer.GetSkillManager().FindSkillBySkillID(clientData.SkillID)  | 
|         if not findSkill:  | 
|             return  | 
|           | 
|         if findSkill.GetFuncType() != ChConfig.Def_SkillFuncType_FbPassiveSkill:  | 
|             return  | 
|     | 
|     holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)  | 
|     if clientData.Index >= holeCnt:  | 
|         # ³¬³ö¿×Êý  | 
|         return  | 
|       | 
|     pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)  | 
|     if clientData.Page >= pageCnt:  | 
|         # ³¬³öÒ³Êý  | 
|         return  | 
|       | 
|     tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)  | 
|     # Ê£ÓàVIPʱ¼ä  | 
|     #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)  | 
|     strIndex = str(clientData.Index)   | 
|     if strIndex in tmpDict:  | 
|         # ÅжÏÌõ¼þ  | 
|         for key, value in tmpDict[strIndex].items():  | 
|             if key == "level" and curPlayer.GetLV() < value:  | 
|                 return  | 
|             if key == "vipLv":  | 
|                 if curPlayer.GetVIPLv() < value:# or haveVipTime <=0:  | 
|                     return  | 
|             if key == "MountLv":  | 
|                 if PlayerHorse.GetHorseSumLV(curPlayer) < value:  | 
|                     return  | 
|               | 
|   | 
|             # ¶à¼ÓÒ»ÖÖÈÎÎñÅÐ¶Ï  | 
|             if key == "OpenSkillSlots":  | 
|                 # Ö÷ÏßÈÎÎñÍê³Éʱ»áÉèÖñêÖ¾¿É½øµØÍ¼±êÖ¾  | 
|                 mission_1 = QuestCommon.GetCommonMission(curPlayer)  | 
|                 if not mission_1:  | 
|                     return  | 
|   | 
|                 if (pow(2, int(strIndex)) & mission_1.GetProperty("OpenSkillSlots")) == 0:  | 
|                     return  | 
|                   | 
|     PlayerControl.NomalDictSetProperty(curPlayer,   | 
|                                        ChConfig.Def_PDict_GFPassiveIndex%(clientData.Page, clientData.Index),  | 
|                                        clientData.SkillID,  | 
|                                        ChConfig.Def_PDictType_GFPassive)  | 
|       | 
|     # Í¨Öª¿Í»§¶ËÉèÖóɹ¦  | 
|     sendPack = ChPyNetSendPack.tagMCPassiveSetAnswer()  | 
|     sendPack.Page = clientData.Page  | 
|     sendPack.Index = clientData.Index  | 
|     sendPack.SkillID = clientData.SkillID  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|       | 
|     # Ë¢±»¶¯Ð§¹ûºÍÊôÐÔ  | 
|     page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)  | 
|     if clientData.Page == page:  | 
|         GetPassiveEffManager().RegistPassiveEffSet(curPlayer)  | 
|         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|           | 
|     EventShell.EventRespons_PassiveSet(curPlayer)  | 
|     return  | 
|   | 
|   | 
| #===============================================================================  | 
| # //B4 08 ±»¶¯¼¼ÄÜҳѡÔñ£¨¹¦·¨£© # tagCMPassivePage  | 
| #   | 
| # struct    tagCMPassivePage  | 
| # {  | 
| #    tagHead        Head;  | 
| #    BYTE        Page;    // ·ÖÒ³  | 
| # };  | 
| #===============================================================================  | 
|   | 
| def OnPassivePage(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)  | 
|     if clientData.Page >= pageCnt:  | 
|         # ³¬³öÒ³Êý  | 
|         return  | 
|       | 
|       | 
|     PlayerControl.NomalDictSetProperty(curPlayer,   | 
|                                        ChConfig.Def_PDict_GFPassivePage,  | 
|                                        clientData.Page,  | 
|                                        ChConfig.Def_PDictType_GFPassive)  | 
|       | 
|     # Í¨Öª¿Í»§¶ËÉèÖóɹ¦  | 
|     sendPack = ChPyNetSendPack.tagMCPassivePage()  | 
|     sendPack.Page = clientData.Page  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|       | 
|     # Ë¢±»¶¯Ð§¹ûºÍÊôÐÔ  | 
|     GetPassiveEffManager().RegistPassiveEffSet(curPlayer)  | 
|     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|     return  | 
|   | 
|   | 
| # ¼ì²éÊÇ·ñµ±Ç°ÕýÔÚʹÓõı»¶¯¼¼ÄÜ  | 
| def FindUsePassiveSkills(curPlayer):  | 
|     page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)  | 
|     holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)  | 
|     skills = []  | 
|     for i in xrange(holeCnt):  | 
|         findSkillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassiveIndex%(page, i), 0,   | 
|                                                      ChConfig.Def_PDictType_GFPassive)  | 
|         if findSkillID == 0:  | 
|             continue  | 
|         skills.append(findSkillID)  | 
|           | 
|     return skills  | 
|   | 
| # µÇ¼֪ͨ£¬²¢¹ýÂ˹ýÆÚVIP¿×  | 
| def OnLoginGFPassive(curPlayer):  | 
|     # ---֪ͨÿҳÊý¾Ý---  | 
|     holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)  | 
|     pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)  | 
|       | 
|     sendPack = ChPyNetSendPack.tagMCPassiveSet()  | 
|     sendPack.PageCnt = pageCnt  | 
|     sendPack.PassiveSkills = []  | 
|       | 
|       | 
|     #tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)  | 
|       | 
|     # Ê£ÓàVIPʱ¼ä  | 
|     #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)  | 
|       | 
|     for i in xrange(pageCnt):  | 
|         skills = ChPyNetSendPack.tagMCPassiveSkills()  | 
|         skills.Count = holeCnt  | 
|         skills.SkillIDList = []  | 
|         for j in xrange(holeCnt):  | 
|   | 
|             #===================================================================  | 
|             # # ÅжÏVIP¹ýÆÚµÄÇé¿ö  | 
|             # for key, value in tmpDict.get(j, {}).items():  | 
|             #    if key == "vipLv":  | 
|             #        if curPlayer.GetVIPLv() < value or haveVipTime <=0:  | 
|             #            PlayerControl.NomalDictSetProperty(curPlayer,   | 
|             #                                               ChConfig.Def_PDict_GFPassiveIndex%(i, j),   | 
|             #                                               0,  | 
|             #                                               ChConfig.Def_PDictType_GFPassive)  | 
|             #===================================================================  | 
|           | 
|             skillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassiveIndex%(i, j), 0,  | 
|                                                      ChConfig.Def_PDictType_GFPassive)  | 
|             skills.SkillIDList.append(skillID)  | 
|           | 
|         sendPack.PassiveSkills.append(skills)  | 
|       | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|       | 
|     # ---֪ͨ¼¤»îÒ³---  | 
|     page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)  | 
|     sendPack = ChPyNetSendPack.tagMCPassivePage()  | 
|     sendPack.Page = page  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   | 
| # Çл»µØÍ¼  | 
| def OnLoadMapGFPassive(curPlayer):  | 
|     # ±»¶¯¼¼ÄÜ  | 
|     GetPassiveEffManager().RegistPassiveEff(curPlayer)  | 
|       | 
|     #tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)  | 
|     #holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)  | 
|       | 
|     # Ê£ÓàVIPʱ¼ä  | 
|     #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)  | 
|       | 
|     #µ±Ç°Ê¹ÓÃÒ³  | 
|     #page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)  | 
|   | 
| #===============================================================================  | 
| #    for j in xrange(holeCnt):  | 
| #   | 
| #        # ÅжÏVIP¹ýÆÚµÄÇé¿ö  | 
| #        for key, value in tmpDict.get(j, {}).items():  | 
| #            if key != "vipLv":  | 
| #                continue  | 
| #            if curPlayer.GetVIPLv() < value or haveVipTime <= 0:  | 
| #                PlayerControl.NomalDictSetProperty(curPlayer,   | 
| #                                                   ChConfig.Def_PDict_GFPassiveIndex%(page, j),   | 
| #                                                   0,  | 
| #                                                   ChConfig.Def_PDictType_GFPassive)  | 
| #===============================================================================  | 
|       | 
|     # Ä§×å·¨±¦-±»¶¯¼¼ÄÜÒ³  | 
|     GetPassiveEffManager().RegistPassiveEffSet(curPlayer)  | 
|       | 
|     GetPassiveEffManager().RegistPassiveBuff(curPlayer)  | 
|   | 
|   | 
| #-±»¶¯Âß¼´¦Àí--------------------------------------------------------------------------------------------------  | 
| ##À뿪µØÍ¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @return   | 
| def OnPlayerLeaveMap(curPlayer):  | 
|     GetPassiveEffManager().RemovePassiveEff((curPlayer.GetID(), IPY_GameWorld.gotPlayer))  | 
|     for i in range(1,3):  | 
|         #³èÎï  | 
|         GetPassiveEffManager().RemovePassiveEff((curPlayer.GetID()*10+i, IPY_GameWorld.gotNPC))  | 
|     return  | 
|   | 
| # »ñµÃ¡¾¼¼ÄÜ¡¿±»¶¯Ð§¹û¶ÔÓ¦µÄ ±»¶¯´¥·¢·½Ê½ ÓëGetBuffTriggerTypeByEffectID»¥²¹  | 
| def GetTriggerTypeByEffectID(effectID):  | 
|     # ÁÙʱÅäÖà  | 
|     tdict = {  | 
|              4000:ChConfig.TriggerType_BuffState,   # ½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2  | 
|              4001:ChConfig.TriggerType_TagBuffState,   # Ä¿±ê½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2  | 
|              4002:ChConfig.TriggerType_AddDamagePer,   # Ìá¸ßÔö¼ÓÉ˺¦ÊôÐÔÖµ£¬¼ÆËãʱ 3  | 
|              4003:ChConfig.TriggerType_AddDamagePer,   # Ìá¸ßÔö¼ÓÉ˺¦ÊôÐÔÖµ£¬¼ÆËãʱ 3  | 
|              4004:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4  | 
|              4005:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5  | 
|              4006:ChConfig.TriggerType_SuperHit, # ±©»÷ʱ ´¥·¢¼¼ÄÜ6,  | 
|              4007:ChConfig.TriggerType_SuperHitValue, # ±©»÷ʱ Ôö¼Ó±©»÷Öµ7,  | 
|              4008:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5  | 
|              4009:ChConfig.TriggerType_HurtObjAddBuff, # »÷ÖÐÍæ¼Ò£¨Èº¹¥¶à´Î´¥·¢£©8,  | 
|              4010:ChConfig.TriggerType_ReduceCD, # ¼õÉÙCD9, #CD  | 
|              4011:ChConfig.TriggerType_SuperHitSkillPer, # ±©»÷ʱ£¬Ôö¼Ó¼¼ÄÜÉ˺¦ 10  | 
|              4013:ChConfig.TriggerType_AttackAddFinalValue,   #¹¥»÷Ôö¼ÓÊä³öÉ˺¦11  | 
|              4014:ChConfig.TriggerType_HappenState,   #±Ø¶¨´¥·¢  | 
|              4015:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5  | 
|              4016:ChConfig.TriggerType_AbsorbShield,  # Ìá¸ß÷è÷ëÓÓÉíµÄ¼õÉÙÉ˺¦Ð§¹ûÌáÉý20% 13  | 
|              4017:ChConfig.TriggerType_BounceHP,   # ·´µ¯É˺¦¹Ì¶¨Öµ14,  | 
|              4018:ChConfig.TriggerType_BuffDisappear,   # buffÏûʧºó´¥·¢¼¼ÄÜ15,  | 
|              4019:ChConfig.TriggerType_BuffTime,   # ÑÓ³¤BUFFʱ¼ä16,  | 
|              4020:ChConfig.TriggerType_BounceHPPer,   # ·´µ¯É˺¦°Ù·Ö±ÈÖµ17,  | 
|              4021:ChConfig.TriggerType_AddSingleSkillPer,   # ³ÖÐøÐÔ¹¥»÷µÄµ¥´Î¹¥»÷Öð´ÎÔö¼Ó¼¼ÄÜÉ˺¦18,  | 
|              4022:ChConfig.TriggerType_SkillOverNoAttack,   # ¼¼ÄÜÊͷźó ÓëTriggerType_AttackOverÏà·´19,  | 
|              4023:ChConfig.TriggerType_BeAttackOver,   # ±»¹¥»÷ºó´¥·¢ 20  | 
|              4024:ChConfig.TriggerType_AddIceAtkPer,    # ¹¥»÷¸½¼ÓÕæÊµÉ˺¦°Ù·Ö±È 21  | 
|              4025:ChConfig.TriggerType_AddIceAtk,    # ¹¥»÷¸½¼ÓÕæÊµÉ˺¦¹Ì¶¨Öµ 22  | 
|              4026:ChConfig.TriggerType_DebuffOff,    # µÖÏûÒ»´Îdebuff 23  | 
|              4027:ChConfig.TriggerType_AttackKill,   # Õ¶É± 24  | 
|              4028:ChConfig.TriggerType_WillDead,   # ½øÈë±ôËÀ״̬ʱ´¥·¢¼¼ÄÜ 25  | 
|              4029:ChConfig.TriggerType_BuffBoom,   # Öж¾ºó±¬Õ¨ 26  | 
|              4030:ChConfig.TriggerType_Success_Buff_SkillPer, # Ìá¸ß4501³É¹¦¸ÅÂÊ 27  | 
|              4031:ChConfig.TriggerType_HurtObjAddBuff,   # ÔÚËãÉ˺¦Ê±Èº¹¥1¶Ô1¼Óbuff£¬¿ÉÓÃÓÚÒ»¸öÉ˺¦¶à´Î´¥·¢ 28  | 
|              4032:ChConfig.TriggerType_BeBoomSeed,   # ±»¶¯Òý±¬ÊÓÒ°ÄÚ¶ÔÏóµÄbuffÖÖ×Ó 29  | 
|              4033:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4  | 
|              4034:ChConfig.TriggerType_AttackAddSkillPer,  # Ôö¼ÓXP¼¼ÄÜ·ÇС¹ÖÉ˺¦  | 
|              4035:ChConfig.TriggerType_AttackAddSkillPer,  # Ôö¼ÓXP¼¼ÄÜС¹ÖÉ˺¦  | 
|              4036:ChConfig.TriggerType_AttackCnt,  # Ôö¼Ó¼¼Äܹ¥»÷ÊýÁ¿£¨Ð§¹ûID1200£©  | 
|              4037:ChConfig.TriggerType_SuperHitOneByOne, # Ö»¶Ô±©»÷Ä¿±ê´¥·¢¼¼ÄÜ  | 
|              4038:ChConfig.TriggerType_BuffState,   # ½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2  | 
|              4039:ChConfig.TriggerType_AttackOverPassive,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ÔÚÆäËû±»¶¯Ð§¹û´¦Àíºóµ÷Ó㬴¥·¢Ë³ÐòÔÒò  | 
|              4040:ChConfig.TriggerType_BeSuperHit,  # ±»±©»÷´¥·¢¼¼ÄÜ  | 
|              4041:ChConfig.TriggerType_AddExpRate,  # ¸ÅÂÊÐÔ¼Ó³Éɱ¹Ö¾Ñé  | 
|              4042:ChConfig.TriggerType_DamageReduce,   # ¼õÉÙÉ˺¦  | 
|              4043:ChConfig.TriggerType_DamageReducePVP,   # PVP¼õÉÙÉ˺¦  | 
|              4044:ChConfig.TriggerType_MissPer, # ÉÁ±ÜÌáÉý°Ù·Ö±È  | 
|              4045:ChConfig.TriggerType_SkillDist,   # Ôö¼Ó¼¼Äܹ¥»÷¾àÀë  | 
|              4046:ChConfig.TriggerType_ReduceHurtHPPer,  # °Ù·Ö±È¼õÉÙ¹¥»÷¼ÆËãºóÉ˺¦   | 
|              4047:ChConfig.TriggerType_TimeCalc, # Ò»¶¨Ê±¼äÑ»·Öд¥·¢Êͷż¼ÄÜ  | 
|              4048:ChConfig.TriggerType_MissSkill,   # ÉÁ±Üºó´¥·¢Êͷż¼ÄÜ  | 
|              4049:ChConfig.TriggerType_MissSuccessPer, # ÉÁ±Ü³É¹¦ÂÊÌáÉý  | 
|              4050:ChConfig.TriggerType_OneDamage,   # É˺¦½µµÍµ½1µã  | 
|              }  | 
|     return tdict.get(effectID, -1)  | 
|     #===========================================================================  | 
|     # # ´Ë±íÅäÖàӰÏìÀàÐÍ  | 
|     # ipyData = IpyGameDataPY.GetIpyGameData('SkillEffect', effectID)  | 
|     # if not ipyData:  | 
|     #    return -1  | 
|     #   | 
|     # #{(´¥·¢·½Ê½/µã£¬ ¹ØÁª¼¼ÄÜ)£º{buff£º¡¾Ð§¹û¡¿}}  | 
|     #   | 
|     # return ipyData.GetTriggerType()  | 
|     #===========================================================================  | 
|   | 
| # »ñµÃ¡¾BUFF¡¿±»¶¯´¥·¢µÄ·½Ê½ ÓëGetTriggerTypeByEffectID»¥²¹  | 
| def GetBuffTriggerTypeByEffectID(effectID):  | 
|     tdict = {  | 
|              4500:ChConfig.TriggerType_AttackOver, # BUFFÀࣺ¹¥»÷´¥·¢Ð¼¼ÄÜ  | 
|              4501:ChConfig.TriggerType_AttackAddSkillPer, # BUFFÀࣺÌá¸ßÖ÷¶¯¼¼Äܵļ¼ÄÜÉ˺¦  | 
|              4502:ChConfig.TriggerType_BeAttackOver, # BUFFÀࣺ±»¹¥»÷´¥·¢¼¼ÄÜ  | 
|              4503:ChConfig.TriggerType_AddDamagePer,  # BUFFÀࣺ ¹¥»÷ʱÌá¸ßÔö¼ÓÉ˺¦  | 
|              4504:ChConfig.TriggerType_BounceHP,  # BUFFÀࣺ ·´µ¯É˺¦¹Ì¶¨Öµ  | 
|              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Àࣺ¹¥»÷¸½¼ÓÕæÊµÉ˺¦°Ù·Ö±È   | 
|              803:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü  | 
|              806:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü  | 
|              808:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü  | 
|              }  | 
|     return tdict.get(effectID, -1)  | 
|   | 
|   | 
| #--------±»¶¯Ð§¹û---------------------------  | 
| # ±»¶¯Ð§¹ûµÄÀ´Ô´¿ÉÄÜÊDZ»¶¯¼¼ÄÜ£¬±»¶¯buff£¬»òÕ߯äËûÔöÒæbuff  | 
| # ¸ù¾Ý´¥·¢µã×éÖ¯²»Í¬µÄ´æ´¢  | 
| # Êý¾ÝΪ¿ÕÖØÐÂ×éÖ¯  | 
| class PassiveEff(object):  | 
|     def __init__(self, gameObj):  | 
|         self.gameObj = gameObj  | 
|         #{(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):{BUFFid£º[Ó°ÏìBUFFµÄ¸½´øÐ§¹û]}}  | 
|         self.AffectBuffDict = {}    # µ±Ç°ÕýÊÜÓ°ÏìµÄЧ¹ûbuff, keyΪ´¥·¢µã  | 
|         self.AffectSkillDict = {}    # ±»¶¯¼¼ÄÜ {(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):[±»¶¯¼¼ÄÜID£¬Ð§¹û]  | 
|         self.AffectPassiveSkillSetDict = {}    # ±»¶¯¼¼ÄÜ×°±¸ {(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):[±»¶¯¼¼ÄÜID£¬Ð§¹û]  | 
|       | 
|       | 
|     #¼Ç¼»áÓ°ÏìÆäËû¼¼ÄÜ»òÕß±»¶¯´¥·¢Êͷż¼ÄܵÄBUFF  | 
|     def AddBuffInfoByEffect(self, effect, skillID):  | 
|         effectID = effect.GetEffectID()  | 
|           | 
|         #{(´¥·¢·½Ê½/µã£¬ ¹ØÁª¼¼ÄÜ)£º{BUFFID£º¡¾Ð§¹û¡¿}}  | 
|         triggerType = GetBuffTriggerTypeByEffectID(effectID)  | 
|         if triggerType == -1:  | 
|             return  | 
|   | 
|         releaseSkillID = 0  | 
|         keyTuple = (triggerType, releaseSkillID)  | 
|         if keyTuple not in self.AffectBuffDict:  | 
|             self.AffectBuffDict[keyTuple] = {}  | 
|               | 
|         if skillID not in self.AffectBuffDict[keyTuple]:  | 
|             self.AffectBuffDict[keyTuple][skillID] = []  | 
|         self.AffectBuffDict[keyTuple][skillID].append(effect)  # ´æ´¢ÊÜÓ°ÏìµÄÐÅÏ¢  | 
|         return  | 
|           | 
|   | 
|           | 
|     # ÐèÔÚɾ³ýBUFF´¦Àí  | 
|     def DelBuffInfo(self, skillData):  | 
|         if not skillData:  | 
|             return  | 
|           | 
|         skillID = skillData.GetSkillID()  | 
|         releaseSkillID = 0 # ÔÝÇÒÎÞ¹ØÁª¾ßÌå¼¼ÄÜ  | 
|         for i in range(0, skillData.GetEffectCount()):  | 
|             curEffect = skillData.GetEffect(i)  | 
|             effectID = curEffect.GetEffectID()  | 
|               | 
|             triggerType = GetBuffTriggerTypeByEffectID(effectID)  | 
|             if triggerType == -1:  | 
|                 continue  | 
|               | 
|             if (triggerType, releaseSkillID) not in self.AffectBuffDict:  | 
|                 continue  | 
|               | 
|             if skillID not in self.AffectBuffDict[(triggerType, releaseSkillID)]:  | 
|                 continue  | 
|               | 
|             self.AffectBuffDict[(triggerType, releaseSkillID)].pop(skillID)  | 
|               | 
|         return  | 
|       | 
|       | 
|       | 
|     # »ñµÃ±»¶¯´¥·¢µÄ buff  | 
|     def GetBuffsByTriggerType(self, triggerType, useSkillID=0):  | 
|         return self.AffectBuffDict.get((triggerType, 0), {})  | 
|        | 
|       | 
|     # ÖØË¢¿É×°±¸µÄ±»¶¯¼¼ÄÜ  | 
|     def RefreshPassiveSkillSet(self):  | 
|         self.AffectPassiveSkillSetDict = {}  | 
|         skillManager = self.gameObj.GetSkillManager()  | 
|         skills = FindUsePassiveSkills(self.gameObj)  | 
|           | 
|         for skillID in skills:  | 
|             curSkill = skillManager.FindSkillBySkillID(skillID)  | 
|             if not 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.AffectPassiveSkillSetDict:  | 
|                     self.AffectPassiveSkillSetDict[key] = []  | 
|                       | 
|                 self.AffectPassiveSkillSetDict[key].append((skillTypeID, effectID))  | 
|           | 
|         return self.AffectPassiveSkillSetDict  | 
|       | 
|       | 
|     # ÖØË¢±»¶¯Ðͼ¼ÄÜ£¨º¬sp£¬Ì츳£¬²»º¬±»¶¯¼¼Äܹ¦ÄÜ£©´æ´¢  | 
|     def RefreshPassiveSkill(self):  | 
|         self.AffectSkillDict = {}  | 
|         skillManager = self.gameObj.GetSkillManager()  | 
|         for i in range(0 , skillManager.GetSkillCount()):  | 
|             curSkill = skillManager.GetSkillByIndex(i)  | 
|             if not curSkill:  | 
|                 continue  | 
|               | 
|             if not SkillCommon.isPassiveTriggerSkill(curSkill):  | 
|                 continue  | 
|               | 
|             if curSkill.GetFuncType() == ChConfig.Def_SkillFuncType_FbPassiveSkill:  | 
|                 # ±»¶¯¼¼ÄÜÐè×°±¸  | 
|                 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.AffectSkillDict:  | 
|                     self.AffectSkillDict[key] = []  | 
|                   | 
|                 self.AffectSkillDict[key].append((skillTypeID, effectID))  | 
|           | 
|         return self.AffectSkillDict  | 
|       | 
|     # Ìí¼Ó±»¶¯¼¼ÄÜ  | 
|     def AddPassiveSkill(self, skillID):  | 
|         curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)  | 
|         if not curSkill:  | 
|             return  | 
|           | 
|         if not SkillCommon.isPassiveTriggerSkill(curSkill):  | 
|             return  | 
|           | 
|         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.AffectSkillDict:  | 
|                 self.AffectSkillDict[key] = []  | 
|               | 
|             if (skillTypeID, effectID) not in self.AffectSkillDict[key]:  | 
|                 self.AffectSkillDict[key].append((skillTypeID, effectID))  | 
|           | 
|         return self.AffectSkillDict  | 
|       | 
|   | 
|     def GetPassiveSkillsByTriggerType(self, triggerType, connSkillID=0):  | 
|         skillList = []  | 
|         ## bug:2018-03-15  | 
|         ## skillList=self.AffectSkillDict.get((triggerType, connSkillID), [])ÔÙÓÃextend»áµ¼ÖÂAffectSkillDictÎÞÏÞÔö³¤  | 
|         skillList.extend(self.AffectSkillDict.get((triggerType, connSkillID), []))  | 
|         skillList.extend(self.AffectPassiveSkillSetDict.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), []))  | 
|               | 
|         return skillList  | 
|           | 
| #ËùÓÐobjµÄ±»¶¯Ð§¹û¹ÜÀí  | 
| class PassiveEffManager(object):  | 
|       | 
|     def __init__(self):  | 
|         self.passiveEffClassDict = {}  | 
|           | 
|     # ÊÇ·ñ³õʼ»¯  | 
|     def GetPassiveEff(self, gameObj):  | 
|         key = (gameObj.GetID(), gameObj.GetGameObjType())   | 
|   | 
|         return self.passiveEffClassDict.get(key, None)  | 
|   | 
|       | 
|     def InitObjPassiveEff(self, gameObj):  | 
|         key = (gameObj.GetID(), gameObj.GetGameObjType())   | 
|         if key not in self.passiveEffClassDict:   | 
|             self.passiveEffClassDict[key] = PassiveEff(gameObj)  | 
|         return self.passiveEffClassDict[key]  | 
|       | 
|     def AddPassiveEff(self, gameObj, passiveEff):  | 
|         key = (gameObj.GetID(), gameObj.GetGameObjType())   | 
|         self.passiveEffClassDict[key] = passiveEff  | 
|       | 
|     # ×¢²á±»¶¯¼¼ÄÜ  | 
|     def RegistPassiveEff(self, gameObj, skillID=0):  | 
|         passiveEff = self.GetPassiveEff(gameObj)  | 
|         if not passiveEff or not skillID:  | 
|               | 
|             if passiveEff:  | 
|                 # µ±´ÓÓб»¶¯µ½ÍêȫûÓб»¶¯µÄ¹ý³Ì£¬ÐèÒªÔÚ´ËˢР | 
|                 passiveEff.RefreshPassiveSkill()  | 
|                 return  | 
|               | 
|             # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ  | 
|             passiveEff = PassiveEff(gameObj)  | 
|             if not passiveEff.RefreshPassiveSkill():  | 
|                 # ´Ë´¦ÊÇΪÁ˲»¸øAddPassiveEffÔö¼Ó¿ÕÀà. ¹Ê²»Ã¿´Îµ÷ÓÃAddPassiveEff  | 
|                 # µ«ÁíÒ»ÖÖ´ÓÓб»¶¯µ½ÍêȫûÓб»¶¯»á±»´Ë¹ýÂË£¬µ¼ÖÂɾ³ý²»ÁË£¬ÔÚÉÏÃæ´¦Àí  | 
|                 return  | 
|             self.AddPassiveEff(gameObj, passiveEff)  | 
|         elif skillID:  | 
|             # µ¥¸öÌí¼Ó±»¶¯¼¼ÄÜ  | 
|             passiveEff.AddPassiveSkill(skillID)  | 
|   | 
|         return  | 
|       | 
|     # ÈËÎïÐèͬ²½×¢²á±»¶¯¼¼ÄÜ  | 
|     def RegistPassiveEffSet(self, gameObj):  | 
|         passiveEff = self.GetPassiveEff(gameObj)  | 
|         if not passiveEff:  | 
|             # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ  | 
|             passiveEff = PassiveEff(gameObj)  | 
|             if not passiveEff.RefreshPassiveSkillSet():  | 
|                 return  | 
|             self.AddPassiveEff(gameObj, passiveEff)  | 
|         else:  | 
|             passiveEff.RefreshPassiveSkillSet()  | 
|         return  | 
|           | 
|           | 
|     def RegistPassiveBuff(self, gameObj):  | 
|         # buff # É¸Ñ¡buffType ·ñÔòNPCûÓд˽ӿڻᱨ´í  | 
|         for buffType in [IPY_GameWorld.bfBuff, IPY_GameWorld.bfDeBuff, IPY_GameWorld.bfProcessBuff  | 
|                          , IPY_GameWorld.btPassiveBuf, IPY_GameWorld.bfActionBuff, IPY_GameWorld.bfProcessDeBuff]:  | 
|               | 
|             if buffType == IPY_GameWorld.btPassiveBuf and gameObj.GetGameObjType() == IPY_GameWorld.gotNPC:  | 
|                 # NPCÖ»ÓгèÎïÓб»¶¯BUFF  | 
|                 if not PetControl.IsPet(gameObj):  | 
|                     continue  | 
|               | 
|             buffTuple = SkillCommon.GetBuffManagerByBuffType(gameObj, buffType)  | 
|             #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö  | 
|             if buffTuple == ():  | 
|                 continue  | 
|       | 
|             buffManager = buffTuple[0]  | 
|               | 
|             for i in xrange(buffManager.GetBuffCount()):  | 
|                 curBuff = buffManager.GetBuff(i)  | 
|                 buffSkill = curBuff.GetSkill()  | 
|                 if not buffSkill:  | 
|                     continue  | 
|                 for effectIndex in range(0, buffSkill.GetEffectCount()):  | 
|                     curEffect = buffSkill.GetEffect(effectIndex)  | 
|                     effectID = curEffect.GetEffectID()  | 
|                     if effectID == 0:  | 
|                         continue  | 
|                       | 
|                     triggerType = GetBuffTriggerTypeByEffectID(effectID)  | 
|                     if triggerType == -1:  | 
|                         continue  | 
|                     passiveEff = self.InitObjPassiveEff(gameObj)  | 
|                     passiveEff.AddBuffInfoByEffect(curEffect, buffSkill.GetSkillID())  | 
|           | 
|         return  | 
|       | 
|       | 
|     def RemovePassiveEff(self, key):  | 
|         if key in self.passiveEffClassDict:  | 
|             self.passiveEffClassDict.pop(key)  | 
|         return  | 
|       | 
|       | 
| def GetPassiveEffManager():  | 
|     if not PyGameData.g_PassiveEffManager:  | 
|         PyGameData.g_PassiveEffManager = PassiveEffManager()  | 
|     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.²é·þÎñ¶ËÉ˺¦¶ÓÁР     | 
|     if defender and defender != attacker:  | 
|         return defender  | 
|   | 
|     # Ã»ÓÐÄ¿±êµÄÇé¿öÈ¡É˺¦¶ÓÁÐÖеĵÚÒ»¸ö¶ÔÏó  | 
|     if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:  | 
|         return  | 
|       | 
|     useSkillTagID = attacker.GetUseSkillTagID()  | 
|     useSkillTagType = attacker.GetUseSkillTagType()  | 
|     defender = GameWorld.GetObj(useSkillTagID, useSkillTagType)  | 
|     if defender:  | 
|         return defender  | 
|       | 
|     curHurt = BaseAttack.GetFirstHurtObj()  | 
|     if not curHurt:  | 
|         return  | 
|       | 
|     return GameWorld.GetObj(curHurt.GetObjID(), curHurt.GetObjType())  | 
|           | 
|   | 
| # ±»¶¯¼¼ÄÜ´¥·¢ÊÍ·Å  | 
| def OnPassiveSkillTrigger(attacker, defender, connSkill, triggerType, tick, isEnhanceSkill=False, skillIDSet=None):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return False  | 
|   | 
|     if connSkill:  | 
|         if not connSkill.GetFuncType():  | 
|             # ·Ç¹¦ÄÜÀ༼ÄÜ£¬±ÜÃâËÀÑ»·  | 
|             return False  | 
|         if SkillCommon.isPassiveSkill(connSkill):  | 
|             #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")  | 
|             return False  | 
|           | 
|     if SkillCommon.GetUsingPassiveSkill(attacker) and triggerType != ChConfig.TriggerType_BuffState:  | 
|         # ·À·¶±»¶¯¼¼ÄÜ´¥·¢µÄ ·Ç±»¶¯¼¼ÄÜ  | 
|         GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ---%s"%triggerType)  | 
|         return  | 
|       | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return False  | 
|       | 
|     connSkillID = connSkill.GetSkillTypeID() if connSkill else 0  | 
|     skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkillID)  | 
|     if not skills:  | 
|         return False  | 
|       | 
|     defender = GetPassiveDefender(attacker, defender)  | 
|   | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|     #GameWorld.DebugLog("OnPassiveSkillTrigger-----------%s-%s"%(skills, battleRelationType))  | 
|     for skillTypeID, effectID in skills:  | 
|         curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)  | 
|         if not curSkill:  | 
|             continue  | 
|   | 
|         effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)  | 
|         if not effect:  | 
|             continue  | 
|   | 
|         if SkillCommon.RefreshSkillRemainTime(curSkill, tick):  | 
|             continue  | 
|           | 
|         skillBattleType = SkillCommon.GetSkillBattleType(curSkill)  | 
|         if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|             # PKģʽµÄÅж¨  | 
|             continue  | 
|           | 
|         pyName = "PassiveSkill_%s" % effectID  | 
|         callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|         if callFunc and not callFunc(attacker, defender, effect, curSkill):  | 
|             continue  | 
|           | 
|         # ÉèÖñêÖ¾±ÜÃâ±»¶¯¼¼ÄÜ´¥·¢±»¶¯¼¼ÄÜ, ±»¶¯µ±ÖпÉÄܻᴥ·¢¶àÖÖÀàÐͼ¼ÄÜ£¬¹Ê²»ÓÃisPassiveSkill×öÆÁ±Î  | 
|         SkillCommon.SetUsingPassiveSkill(attacker, 1)  | 
|         if SkillShell.UsePassiveTriggerSkill(attacker, curSkill, defender, tick, isEnhanceSkill):  | 
|             if skillIDSet:   | 
|                 curSkill.SetRemainTime(0)  # Ò»´Î¹¥»÷¶à´Îµ÷Ó࣬ÔÚÍâ²ãͳһµ÷ÓÃCD  | 
|                 skillIDSet.add(skillTypeID)  | 
|         SkillCommon.SetUsingPassiveSkill(attacker, 0)  | 
|           | 
|     return True  | 
|   | 
| # ntElf ¶¨ÒåΪÈËÎïʹÓöԵسÖÐøÐÔ¼¼ÄÜ£¬²¢ÇÒÈËÎï¿ÉÒÔÒÆ¶¯£¬ÔòÐèÒªntElf×öÒÀÍÐÎïµÄÇé¿ö  | 
| # ÄÇôntElfÖ´ÐÐÈËÎïµÄÉ˺¦¼ÆËãºÍ±»¶¯´¥·¢Ð§¹û  | 
| # ±»¶¯¼¼ÄÜÖ»´¦ÀíÍæ¼Ò£¬³èÎºÍÁé  | 
| def FindRealAttacker(attacker):  | 
|     if attacker.GetGameObjType() != IPY_GameWorld.gotNPC:  | 
|         # --Íæ¼Ò  | 
|         return attacker  | 
|       | 
|     npcType = attacker.GetType()  | 
|     if npcType not in [IPY_GameWorld.ntPet, IPY_GameWorld.ntElf]:  | 
|         if attacker.GetIsBoss():  | 
|             return attacker  | 
|         return  | 
|       | 
|     if npcType == IPY_GameWorld.ntPet:  | 
|         # --³èÎï  | 
|         return attacker  | 
|       | 
|     if npcType == IPY_GameWorld.ntElf:  | 
|         # ntElf ¶¨ÒåΪÈËÎïʹÓöԵسÖÐøÐÔ¼¼ÄÜ£¬²¢ÇÒÈËÎï¿ÉÒÔÒÆ¶¯£¬ÔòÐèÒªntElf×öÒÀÍÐÎïµÄÇé¿ö  | 
|         # ÄÇôntElfÖ´ÐÐÈËÎïµÄÉ˺¦¼ÆËãºÍ±»¶¯´¥·¢Ð§¹û  | 
|         attacker = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, attacker)  | 
|         return attacker  | 
|       | 
|     return  | 
|           | 
| # ±»¶¯¼¼ÄܸıäÖµ  connSkill ÎªÖ÷¶¯Êͷż¼ÄÜ  | 
| def GetPassiveSkillValueByTriggerType(attacker, defender, connSkill, triggerType):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return 0  | 
|       | 
|     if connSkill and SkillCommon.isPassiveSkill(connSkill):  | 
|         #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")  | 
|         return 0  | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return 0  | 
|     connSkillID = connSkill.GetSkillTypeID() if connSkill else 0  | 
|     skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkillID)  | 
|     if not skills:  | 
|         return 0  | 
|       | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|     tick = GameWorld.GetGameWorld().GetTick()  | 
|     curValue = 0  | 
|   | 
|     for skillTypeID, effectID in skills:  | 
|         curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)  | 
|         if not curSkill:  | 
|             continue  | 
|         if curSkill.GetCoolDownTime() and SkillCommon.RefreshSkillRemainTime(curSkill, tick):  | 
|             #ÓÐÅäÖÃCDµÄ²ÅÅÐ¶Ï  | 
|             continue  | 
|           | 
|         effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)  | 
|         if not effect:  | 
|             continue  | 
|         skillBattleType = SkillCommon.GetSkillBattleType(curSkill)  | 
|         if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|             continue  | 
|           | 
|         pyName = "PassiveSkill_%s" % effectID  | 
|           | 
|         callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|           | 
|         # Ìõ¼þ²»Âú×ã  | 
|         if callFunc and not callFunc(attacker, defender, effect, curSkill):  | 
|             continue  | 
|           | 
|         callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetValue"))  | 
|         if callFunc is None:  | 
|             continue  | 
|           | 
|         curValue += callFunc(attacker, defender, effect)  | 
|         if curSkill.GetCoolDownTime():  | 
|             SkillCommon.SetSkillRemainTime(curSkill, 0, tick, attacker)  | 
|           | 
|     return curValue  | 
|   | 
|   | 
| # È¡³öÊÜÓ°ÏìµÄ±»¶¯¼¼ÄÜ£¬Íⲿ´¦Àí  | 
| def GetPassiveSkillByTriggerType(attacker, defender, connSkill, triggerType):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return []  | 
|     if connSkill and SkillCommon.isPassiveSkill(connSkill):  | 
|         #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")  | 
|         return []  | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return []  | 
|     connSkillID = connSkill.GetSkillTypeID() if connSkill else 0  | 
|     skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkillID)  | 
|     if not skills:  | 
|         return []  | 
|       | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|     #tick = GameWorld.GetGameWorld().GetTick()  | 
|     skillList = []  | 
|     for skillTypeID, effectID in skills:  | 
|         curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)  | 
|         #if SkillCommon.RefreshSkillRemainTime(curSkill, tick):  | 
|         #    continue  | 
|         if not curSkill:  | 
|             continue  | 
|           | 
|         effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)  | 
|         if not effect:  | 
|             continue  | 
|         skillBattleType = SkillCommon.GetSkillBattleType(curSkill)  | 
|         if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|             continue  | 
|           | 
|         pyName = "PassiveSkill_%s" % effectID  | 
|           | 
|         callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|           | 
|         # Ìõ¼þ²»Âú×ã  | 
|         if callFunc and not callFunc(attacker, defender, effect, curSkill):  | 
|             continue  | 
|           | 
|         skillList.append(curSkill)  | 
|           | 
|     return skillList  | 
|   | 
|   | 
| # ±»¶¯¼¼ÄÜ´¥·¢µ«ÎÞÐèÊÍ·Å£¬ÈçµÖÏûdebuff£¬Ö»Ðè×ßCD¼´¿É  | 
| def OnPassiveSkillHappen(attacker, defender, connSkill, triggerType, tick):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return  | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return  | 
|     connSkillID = connSkill.GetSkillTypeID() if connSkill else 0  | 
|     skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkillID)  | 
|     if not skills:  | 
|         return  | 
|       | 
|     defender = GetPassiveDefender(attacker, defender)  | 
|           | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|       | 
|     for skillTypeID, effectID in skills:  | 
|         curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)  | 
|         if not curSkill:  | 
|             continue  | 
|           | 
|         effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)  | 
|         if not effect:  | 
|             continue  | 
|         if SkillCommon.RefreshSkillRemainTime(curSkill, tick):  | 
|             continue  | 
|         skillBattleType = SkillCommon.GetSkillBattleType(curSkill)  | 
|         if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|             # PKģʽµÄÅж¨  | 
|             continue  | 
|               | 
|         pyName = "PassiveSkill_%s" % effectID  | 
|         callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|           | 
|         if callFunc and not callFunc(attacker, defender, effect, curSkill, connSkill):  | 
|             continue  | 
|           | 
|         SkillCommon.SetSkillRemainTime(curSkill, 0, tick, attacker)  | 
|         SkillShell.DoLogic_UseEnhanceSkill(attacker, defender, curSkill, tick)  | 
|           | 
|         return True  | 
|           | 
|     return False  | 
|   | 
|   | 
|   | 
| #------------------------BuffÀà ±»¶¯´¥·¢, ²¢·ÇÈ«ÊDZ»¶¯¼¼ÄÜ-----------------------------------------------  | 
|   | 
| #buffÀà´¥·¢Êͷż¼ÄÜ£¬ÎÞCDÑéÖ¤  | 
| def OnPassiveBuffTrigger(attacker, defender, useSkill, triggerType, tick):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return  | 
|     if useSkill:  | 
|         if not useSkill.GetFuncType():  | 
|             # ·Ç¹¦ÄÜÀ༼ÄÜ£¬±ÜÃâËÀÑ»·  | 
|             return  | 
|         if SkillCommon.isPassiveSkill(useSkill):  | 
|             #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")  | 
|             return  | 
|           | 
|     if SkillCommon.GetUsingPassiveSkill(attacker):  | 
|         # ·À·¶±»¶¯¼¼ÄÜ´¥·¢µÄ ·Ç±»¶¯¼¼ÄÜ  | 
|         GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ---%s"%triggerType)  | 
|         return  | 
|           | 
|           | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return  | 
|       | 
|     buffDict = passiveEff.GetBuffsByTriggerType(triggerType)  | 
|     if not buffDict:  | 
|         return  | 
|       | 
|     defender = GetPassiveDefender(attacker, defender)  | 
|           | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|       | 
|     for skillID, effectList in buffDict.items():  | 
|         for passiveEffect in effectList:  | 
|             # ±»¶¯´¥·¢µÄ¼¼ÄÜ  | 
|             pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()  | 
|               | 
|             callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|             if not callFunc:  | 
|                 continue  | 
|               | 
|             if not callFunc(attacker, defender, passiveEffect, skillID):  | 
|                 continue  | 
|               | 
|             callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetSkillData"))  | 
|             if not callFunc:  | 
|                 continue  | 
|               | 
|             skillData = callFunc(passiveEffect)  | 
|             if not skillData:  | 
|                 continue  | 
|   | 
|             skillBattleType = SkillCommon.GetSkillBattleType(skillData)  | 
|             if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|                 # PKģʽµÄÅж¨  | 
|                 continue  | 
|               | 
|             SkillCommon.SetUsingPassiveSkill(attacker, 1)  | 
|             if SkillShell.UsePassiveTriggerSkill(attacker, skillData, defender, tick):  | 
|                 AfterUsePassiveSkill(pyName, attacker, defender, passiveEffect, tick)  | 
|             SkillCommon.SetUsingPassiveSkill(attacker, 0)  | 
|   | 
| def AfterUsePassiveSkill(pyName, attacker, defender, passiveEffect, tick):  | 
|     # ¸½¼Ó´¥·¢ºóÂß¼  | 
|     callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "AfterUsePassiveSkill"))  | 
|     if not callFunc:  | 
|         return  | 
|     callFunc(attacker, defender, passiveEffect, tick)  | 
|     return  | 
|   | 
| # buff Ó°ÏìµÄ(¹¥»÷)ÐÐΪֵ  | 
| # ·µ»ØÊýÖµ  | 
| def GetValueByPassiveBuffTriggerType(attacker, defender, useSkill, triggerType):  | 
|     attacker = FindRealAttacker(attacker)  | 
|     if not attacker:  | 
|         return 0  | 
|     if useSkill and SkillCommon.isPassiveSkill(useSkill):  | 
|         #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")  | 
|         return 0  | 
|   | 
|     passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)  | 
|     if not passiveEff:  | 
|         return 0  | 
|     buffDict = passiveEff.GetBuffsByTriggerType(triggerType)  | 
|     if not buffDict:  | 
|         return 0  | 
|       | 
|     # µ±Ç°Õ½¶·¹ØÏµ pvp pve  | 
|     battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)  | 
|     skillBattleType = SkillCommon.GetSkillBattleType(useSkill)  | 
|     if not CheckBattleRelationType(skillBattleType, battleRelationType):  | 
|         return 0  | 
|               | 
|     #tick = GameWorld.GetGameWorld().GetTick()  | 
|     curValue = 0  | 
|   | 
|     for skillID, effectList in buffDict.items():  | 
|         for passiveEffect in effectList:  | 
|             # ±»¶¯´¥·¢µÄ¼¼ÄÜ  | 
|             pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()  | 
|               | 
|             callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))  | 
|             if not callFunc:  | 
|                 continue  | 
|               | 
|             if not callFunc:  | 
|                 continue  | 
|               | 
|             # Ìõ¼þ²»Âú×ã  | 
|             if not callFunc(attacker, defender, passiveEffect, skillID):  | 
|                 continue  | 
|               | 
|             callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetValue"))  | 
|             if callFunc is None:  | 
|                 continue  | 
|               | 
|             curValue += callFunc(attacker, defender, passiveEffect)  | 
|               | 
|     return curValue  | 
|   |