#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#  
 | 
# @todo:   
 | 
#  
 | 
# @author: Alee  
 | 
# @date 2017-11-23 ÏÂÎç01:56:11  
 | 
# @version 1.0  
 | 
#  
 | 
# @note:   
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
import GameWorld  
 | 
import IPY_GameWorld  
 | 
import SkillCommon  
 | 
import PlayerControl  
 | 
import NPCCommon  
 | 
import GameBuffs  
 | 
import ChConfig  
 | 
import FBLogic  
 | 
import SkillShell  
 | 
import PassiveBuffEffMng  
 | 
import ChNetSendPack  
 | 
import PlayerTJG  
 | 
import OperControlManager  
 | 
import GameObj  
 | 
import CrossPlayerData  
 | 
import AttackCommon  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Ö´ÐÐÌí¼ÓBuff²¢Ë¢ÐÂÊôÐÔ  
 | 
#  @param curObj µ±Ç°¶ÔÏó  
 | 
#  @param buffType buffÀàÐÍ  
 | 
#  @param curSkill µ±Ç°¼¼ÄÜ  
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @param value Buff×ÜÖµ->ÓÃÓÚ³ÖÐøÀ༼ÄÜ  
 | 
#  @param buffOwner BuffÓµÓÐÕß  
 | 
#  @param addForce ´ú±íÊÇ·ñÒ»¶¨Ìí¼Óbuff£¬±ÜÃ⻥Ïà·´µ¯buff  
 | 
def DoAddBuff( curObj, buffType, curSkill, tick, addBuffValueList = [], buffOwner = None, addForce = False ):  
 | 
    if curObj == None:  
 | 
        # ±ÜÃâÅä±í´íÎóµ¼Ö±¨´í  
 | 
        return False  
 | 
  
 | 
    if GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_GatherSoul and curObj.GetGameObjType() == IPY_GameWorld.gotNPC:  
 | 
        if curSkill.GetSkillTypeID() != 23052:  
 | 
            #GameWorld.DebugLog('¾Û»ê¸±±¾Íæ¼Ò²»ÄܶԹÖÎïÉÏbuff curSkill=%s,buffOwner=%s'%(curSkill.GetSkillTypeID(),buffOwner.GetID()))  
 | 
            return True  
 | 
        #GameWorld.DebugLog('¾Û»ê¸±±¾¶Ô¹ÖÎïÉÏbuff curSkill=%s,buffOwner=%s'%(curSkill.GetSkillTypeID(),buffOwner.GetID()))  
 | 
          
 | 
    if curObj.GetGameObjType() == IPY_GameWorld.gotNPC and curObj.GetIsBoss() not in ChConfig.Def_SkillAttack_NPCIsBoss \  
 | 
    and SkillCommon.GetSkillBattleType(curSkill) == ChConfig.Def_BattleRelationType_CommNoBoss and SkillShell.IsNPCSkillResist(curObj):  
 | 
        # Êͷźó ¶ÔÖ¸¶¨BOSSÎÞЧµÄ¼¼ÄÜ  
 | 
        return True  
 | 
      
 | 
    buffOwner = AttackCommon.ElfChangeAttacker(buffOwner)  # ElfÁéÎªÌæÉí¹¥»÷£¬ÒªÈ¡Íæ¼ÒµÄÊôÐÔ  
 | 
      
 | 
    result = AddBuffNoRefreshState(curObj, buffType, curSkill, tick, addBuffValueList, buffOwner, addForce)  
 | 
      
 | 
    if result is not 0:  
 | 
        # ±»µÖÏûµÄbuff ²»´¦Àí  
 | 
        #ÏÈË¢ÐÐΪBUFF³É¹¦Ôò²»Ë¢ ÊôÐÔ  
 | 
        __AddActBuffRefreshState(curObj, curSkill, buffType)  
 | 
      
 | 
    if result:  
 | 
        #Ë¢ÐÂÊôÐÔ  
 | 
        curObjType = curObj.GetGameObjType()  
 | 
        #Íæ¼Ò  
 | 
        if curObjType == IPY_GameWorld.gotPlayer:  
 | 
            #Ë¢ÐÂÍæ¼ÒÊôÐÔ  
 | 
            playerControl = PlayerControl.PlayerControl(curObj)  
 | 
            #playerControl.CalcPassiveBuffAttr()  
 | 
            playerControl.RefreshPlayerAttrByBuff()  
 | 
        #NPC  
 | 
        elif curObjType == IPY_GameWorld.gotNPC:  
 | 
            npcControl = NPCCommon.NPCControl(curObj)  
 | 
            npcControl.RefreshNPCAttrState()  
 | 
        #Òì³£  
 | 
        else:  
 | 
            GameWorld.Log("Ìí¼ÓbuffË¢ÐÂʧ°Ü curObjType = %s"%(curObjType))  
 | 
      
 | 
    return result  
 | 
  
 | 
  
 | 
# ¿ì½ÝËÑË÷ CanRepeatTime×Ö¶Î  
 | 
# buffʱ¼ä´¦ÀíÀàÐÍ£¬¸öλÊý  
 | 
def GetBuffRepeatTimeType(curSkill):  
 | 
    return curSkill.GetCanRepeatTime()%10  
 | 
  
 | 
# buffÌæ»»Âß¼£¬Ê®Î»Êý  
 | 
def GetBuffReplaceType(curSkill):  
 | 
    return curSkill.GetCanRepeatTime()/10%10  
 | 
  
 | 
# buff¸ù¾ÝÊÍ·ÅÕß²»Í¬ÅжÏÊÇ·ñ¹²´æbuff£¬°ÙλÊý Def_Buff_NoCoexist   
 | 
def GetBuffCoexistType(curSkill):  
 | 
    return curSkill.GetCanRepeatTime()/100  
 | 
  
 | 
def GetBuffMaxLayer(curSkill):  
 | 
    layerMaxCnt = 0  
 | 
    hasEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_LayerCnt)  
 | 
    if hasEffect:  
 | 
        layerMaxCnt = hasEffect.GetEffectValue(0)   # Äܵþ¼ÓµÄ×î´óÉÏÏÞ  
 | 
  
 | 
    return layerMaxCnt  
 | 
  
 | 
def IsLayerPlusAttr(curBuff):  
 | 
    ## ÊÇ·ñµþ¼ÓÊôÐԲ㼶buff£¬¿Éµþ¼Óʱ£¬ÊôÐÔ=µ¥²ãÊôÐÔ*²ã¼¶£¬Ä¬Èϵþ¼Ó  
 | 
    hasEffect = SkillCommon.GetSkillEffectByEffectID(curBuff.GetSkill(), ChConfig.Def_Skill_Effect_LayerCnt)  
 | 
    if not hasEffect:  
 | 
        return False  
 | 
    if hasEffect.GetEffectValue(1)/10 == 1:  
 | 
        # ÅäÖò»µþ¼Ó£¬Ö±½Ó·µ»ØFalse  
 | 
        return False  
 | 
    return True  
 | 
  
 | 
# ¸Ä±äBUFF³ÖÐøÊ±¼ä  
 | 
def ChangeLastTime(attacker, curSkill):  
 | 
    buffTime = curSkill.GetLastTime()   
 | 
    if not attacker:  
 | 
        return buffTime   
 | 
    if curSkill.GetEffect(0).GetEffectID() == ChConfig.Def_Skill_Effect_Burn:  
 | 
        # ×ÆÉÕµÄʱ¼äÌØÊâ´¦Àí  
 | 
        buffTime = buffTime*(ChConfig.Def_MaxRateValue + PlayerControl.GetBurnTimePer(attacker))/ChConfig.Def_MaxRateValue  
 | 
      
 | 
    buffTime += PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(attacker, None, curSkill, ChConfig.TriggerType_BuffTime)  
 | 
    return buffTime  
 | 
      
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Ôö¼ÓBUFF ¼õÉÙBUFF(²ÎÊý -> µ±Ç°¶ÔÏó,buffÀàÐÍ,µ±Ç°¼¼ÄÜ,µ±Ç°Ê±¼ä,Buff×ÜÖµ->ÓÃÓÚ³ÖÐøÀ༼ÄÜ , BuffÓµÓÐÕß)  
 | 
#  buffµÄeffectÔÚÌí¼ÓºÍɾ³ýµÄʱºò´¦Àí£¬buff¹²´æÓÉbuff±¾Éí¾ö¶¨¶ø²»ÊÇeffect»¥³â£¬²»ÔÙͳһµ÷ÓÃRefreshPlayerBuffOnAttrAddEffect  
 | 
#  plusValueList ¸ÄΪbuff valueÁÐ±í µÚÒ»¸öΪÔö¼ÓÊýÖµ£¬ÆäËû×Ô¶¨Òå  
 | 
#  addForce ±íʾÊÇ·ñÒ»¶¨»áÔö¼Óbuff£¬±ÜÃ⻥Ïà·´µ¯buff  
 | 
#  ·µ»ØÖµ ·µ»ØÕæË¢ÊôÐÔ£¬·µ»Ø0 ´ú±í±»µÖÏûbuff  
 | 
def AddBuffNoRefreshState( curObj, buffType, curSkill, tick, plusValueList=[], buffOwner = None, addForce = False):  
 | 
    if not SkillCommon.IsBuff(curSkill):  
 | 
        GameWorld.ErrLog("%s ²»ÄܼÓÕâ¸öbuff, ÒòΪËüÊǹ¥»÷¼¼ÄÜ! %s-->TypeID = %d"%(curObj.GetName(), curSkill.GetSkillName(), curSkill.GetSkillType()))  
 | 
        return False  
 | 
  
 | 
    buffTuple = SkillCommon.GetBuffManagerByBuffType( curObj, buffType )  
 | 
    #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö  
 | 
    if buffTuple == ():  
 | 
        return False  
 | 
      
 | 
    if not addForce and curSkill.GetSkillType() in ChConfig.Def_Debuff_List:  
 | 
        if PassiveBuffEffMng.OnPassiveSkillHappen(curObj, buffOwner, curSkill, ChConfig.TriggerType_DebuffOff, tick):  
 | 
            # ´Ë´¦±ØÐë·µ»Ø0 ÓÃÓÚÍâ²ãÅжϱ»µÖÏû  
 | 
            return 0  
 | 
          
 | 
        if PassiveBuffEffMng.OnPassiveBuffHappen(curObj, buffOwner, curSkill, ChConfig.TriggerType_DebuffOff, tick):  
 | 
            # ±»¶¯ÀàbuffµÖÏû  
 | 
            # ´Ë´¦±ØÐë·µ»Ø0 ÓÃÓÚÍâ²ãÅжϱ»µÖÏû  
 | 
            return 0  
 | 
  
 | 
    buffState = buffTuple[0]  
 | 
    maxBuffCount = buffTuple[1]  
 | 
    buffCount = buffState.GetBuffCount()  
 | 
    #¼¼ÄÜID  
 | 
    curSkillID = curSkill.GetSkillID()  
 | 
    #¼¼ÄÜÀàÐÍID  
 | 
    curSkillTypeID = curSkill.GetSkillTypeID()  
 | 
    #µ±Ç°¼¼ÄܳÖÐøÊ±¼ä  
 | 
    curSkillLastTime = ChangeLastTime(buffOwner, curSkill)  
 | 
    #µ±Ç°¼¼Äܵȼ¶  
 | 
    curSkillLV = curSkill.GetSkillLV()  
 | 
    #Ìæ»»Ä£Ê½  
 | 
    buffReplaceType = GetBuffReplaceType(curSkill)  
 | 
    #¹²´æÄ£Ê½   
 | 
    buffCoexistType = GetBuffCoexistType(curSkill)  
 | 
    #ʱ¼ä´¦ÀíÀàÐÍ  
 | 
    buffRepeatTimeType = GetBuffRepeatTimeType(curSkill)   
 | 
    #ÓÃÓÚBUFFÂúµÄʱºò´¦ÀíË¢ÐÂÂß¼  
 | 
    isDelRefresh = False  
 | 
      
 | 
    #valueÖµÏÞÖÆ²»³¬¹ý20E  
 | 
    for i in range(len(plusValueList)):  
 | 
        plusValueList[i] = min(plusValueList[i], ChConfig.Def_UpperLimit_DWord)  
 | 
          
 | 
    # Ïò¿ç·þ·¢ËÍÊý¾Ý  
 | 
    CrossPlayerData.SendMergeData_Buff(curObj, curSkillID, plusValueList)  
 | 
      
 | 
    # buff²ã¼¶  
 | 
    layerMaxCnt = 0  
 | 
    layerCalc = 0  
 | 
    hasEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_LayerCnt)  
 | 
    if hasEffect:  
 | 
        layerMaxCnt = hasEffect.GetEffectValue(0)   # Äܵþ¼ÓµÄ×î´óÉÏÏÞ  
 | 
        layerCalc = hasEffect.GetEffectValue(1)%10     # Ôö¼Ó²ã¼¶»¹ÊǼõÉٲ㼶 Def_BuffLayer_Add  
 | 
  
 | 
      
 | 
    #1 ¼ì²éÊÇ·ñÓÐÏàͬµÄBUFF£¬Èç¹ûÓÐÏàͬµÄ¾ÍË¢ÐÂʱ¼ä  
 | 
    for i in range( 0, buffCount ):  
 | 
        curBuff = buffState.GetBuff(i)  
 | 
        if not curBuff:  
 | 
            continue  
 | 
          
 | 
        #ÅжÏÊÇ·ñÓµÓÐͬһÀàÐ͵ļ¼ÄÜ  
 | 
        buffSkill = curBuff.GetSkill()  
 | 
        if buffSkill.GetSkillTypeID() != curSkillTypeID:  
 | 
            continue  
 | 
          
 | 
        if buffCoexistType == ChConfig.Def_Buff_Coexist and buffOwner:  
 | 
            #¿Éͬʱ´æÔÚµÄbuff£¬ÅжÏÊÍ·ÅÕßÊÇ·ñ²»Ò»Ñù  
 | 
            if curBuff.GetOwnerID() != buffOwner.GetID() or curBuff.GetOwnerType() != buffOwner.GetGameObjType():  
 | 
                continue  
 | 
          
 | 
        #--------------¼¼ÄÜÀàÐÍIDÏàͬ  
 | 
        #buff¼¼Äܵȼ¶  
 | 
        buffSkillLV = buffSkill.GetSkillLV()  
 | 
        #buff¼¼ÄÜID  
 | 
        buffSkillID = buffSkill.GetSkillID()  
 | 
        buffValue = curBuff.GetValue() # µ±Ç°ÒÑÓÐÈÝÁ¿  
 | 
          
 | 
        if buffReplaceType == ChConfig.Def_Buff_Replace_Better:  
 | 
            if buffSkillLV > curSkillLV:  
 | 
                # Ö»È¡×îºÃµÄ, ²»¿É¼ÓÖ±½ÓÍ˳ö  
 | 
                return False  
 | 
          
 | 
        resultTime = -1 #²»¸Ä±äʱ¼äµÄÇé¿ö  
 | 
        if buffRepeatTimeType == ChConfig.Def_BuffTime_Reset:  
 | 
            # ÖØÖÃʱ¼ä  
 | 
            resultTime = curSkillLastTime  
 | 
        elif buffRepeatTimeType == ChConfig.Def_BuffTime_Add:  
 | 
            # ÑÓ³¤Ê±¼ä  
 | 
            curBuffRemainTime = curBuff.GetRemainTime()  
 | 
            resultTime = min(curSkillLastTime + curBuffRemainTime, ChConfig.Def_Max_Buff_RemainTime)  
 | 
            #__NotifyMsg_MaxLastTime( curObj, buffSkillID, buffSkillLV ) ¿Í»§¶ËÌáʾ  
 | 
        elif buffRepeatTimeType == ChConfig.Def_BuffTime_Keep_AddValue:  
 | 
            # Ê±¼ä²»¶¯Ôö¼ÓÖµ  
 | 
            if len(plusValueList) > 0:  
 | 
                plusValueList[0] = min(buffValue + plusValueList[0], ChConfig.Def_UpperLimit_DWord)  
 | 
                  
 | 
        if buffSkillLV == curSkillLV:  
 | 
            changeLayer = False  
 | 
            if layerMaxCnt and curBuff.GetLayer() < layerMaxCnt:  
 | 
                if layerCalc == ChConfig.Def_BuffLayer_Add:  
 | 
                    curBuff.SetLayer(curBuff.GetLayer() + 1)  
 | 
                    #BUFF²ã¼¶±ä»¯´¥·¢±»¶¯  
 | 
                    if buffOwner:  
 | 
                        curObj.SetDict(ChConfig.Def_PlayerKey_AddBuffLayer, curBuff.GetLayer())  
 | 
                        PassiveBuffEffMng.OnPassiveSkillTrigger(buffOwner, curObj, curSkill, ChConfig.TriggerType_AddLayer, tick)  
 | 
                        PassiveBuffEffMng.OnPassiveBuffTrigger(buffOwner, curObj, curSkill, ChConfig.TriggerType_AddLayer, tick)  
 | 
                        curObj.SetDict(ChConfig.Def_PlayerKey_AddBuffLayer, 0)  
 | 
                else:  
 | 
                    curBuff.SetLayer(layerMaxCnt)  
 | 
                changeLayer = True  
 | 
                      
 | 
            # Def_Buff_Replace_NewºÍDef_Buff_Recharge ¾ù¿É×ßµ½´ËÂß¼  
 | 
            __BuffCanRemain(curObj, buffState, curBuff, i, resultTime, plusValueList, buffOwner)  
 | 
  
 | 
            return changeLayer  
 | 
        else:  
 | 
            if buffReplaceType == ChConfig.Def_Buff_Recharge:  
 | 
                # ³äÄÜÐÍ  
 | 
                __BuffCanRemain(curObj, buffState, curBuff, i, resultTime, plusValueList, buffOwner)  
 | 
                return  
 | 
              
 | 
            processInterval = curBuff.GetProcessInterval()  
 | 
            ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()  
 | 
            buffState.DeleteBuffByIndex(i)  
 | 
            SkillShell.ClearBuffEffectBySkillID(curObj, buffSkillID, ownerID, ownerType)  
 | 
            return __AddBuff(curObj, buffState, curSkill, plusValueList, buffOwner, isDelRefresh,   
 | 
                             tick, curSkillLastTime, processInterval, layerMaxCnt, layerCalc)  
 | 
          
 | 
        #ÒѾÕÒµ½Í¬Ò»ÀàÐ͵ļ¼ÄÜ£¬Á¢¼´Í˳ö²»È»»áµ¼Ö´íÂÒ  
 | 
        return False  
 | 
          
 | 
      
 | 
    #2 ¼ì²éBUFFÊÇ·ñÒѾÂúÁË£¬Èç¹ûÒѾÂúÁ˾ͰÑ×îÔçµÄBUFF³åµô  
 | 
    while buffState.GetBuffCount() >= maxBuffCount:   
 | 
        curBuff = buffState.GetBuff(0)  
 | 
        ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()  
 | 
        DoBuffDisApper( curObj, curBuff, tick )  
 | 
        #ɾ³ý×îÔç¼ÓÉϵÄBuff  
 | 
        buffState.DeleteBuffByIndex(0)  
 | 
        SkillShell.ClearBuffEffectBySkillID(curObj, buffSkillID, ownerID, ownerType)  
 | 
        #ɾ³ýδ֪BUFF£¬Ë¢ÐÂÊôÐÔ  
 | 
        isDelRefresh = True  
 | 
      
 | 
    return __AddBuff(curObj, buffState, curSkill, plusValueList, buffOwner, isDelRefresh,   
 | 
                     tick, curSkillLastTime, 0, layerMaxCnt, layerCalc)  
 | 
  
 | 
  
 | 
## ÊÇ·ñѪ°ü/À¶°übuff  
 | 
# @param curSkill  
 | 
# @return   
 | 
def __IsMPHPPackageBuff(curSkill):  
 | 
    for i in range(0, curSkill.GetEffectCount()):  
 | 
        curEffect = curSkill.GetEffect(i)  
 | 
        curEffectID = curEffect.GetEffectID()  
 | 
          
 | 
        if not curEffectID:  
 | 
            continue  
 | 
          
 | 
        if curEffectID in [ChConfig.Def_Skill_Effect_HPPackage, ChConfig.Def_Skill_Effect_MPPackage,   
 | 
                           ChConfig.Def_Skill_Effect_PetHPPackage]:  
 | 
            return True  
 | 
          
 | 
    return False  
 | 
  
 | 
# Í¬²½ÎªÖ÷´ÓbuffµÄʱ¼ä  
 | 
def SyncMasterBuffTime(curObj, curBuff, curSkill):  
 | 
    curObjType = curObj.GetGameObjType()  
 | 
    #Íæ¼Ò  
 | 
    if curObjType != IPY_GameWorld.gotPlayer:  
 | 
        return  
 | 
    findEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_MasterBuff)  
 | 
    if not findEffect:  
 | 
        return  
 | 
      
 | 
    masterSkillTypeID = findEffect.GetEffectValue(0)  
 | 
    if not masterSkillTypeID:  
 | 
        return  
 | 
      
 | 
    findSkill = GameWorld.GetGameData().GetSkillBySkillID(masterSkillTypeID)  
 | 
    if not findSkill:  
 | 
        return  
 | 
      
 | 
    buffType = SkillCommon.GetBuffType(findSkill)  
 | 
    buffTuple = SkillCommon.GetBuffManagerByBuffType(curObj, buffType)  
 | 
    if buffTuple == ():  
 | 
        return  
 | 
      
 | 
    buffManager = buffTuple[0]  
 | 
    findBuff = buffManager.FindBuff(masterSkillTypeID)  
 | 
    if not findBuff:  
 | 
        return  
 | 
      
 | 
    #GameWorld.DebugLog("SyncMasterBuffTime----SetRemainTime--%s"%curSkill.GetSkillID())  
 | 
    curBuff.SetRemainTime(findBuff.GetRemainTime())  
 | 
  
 | 
##Ìí¼ÓBUFF, Ñ¹Èëbuffvalue, ¾ßÌåBUFF·ÖÖ§´¦Àí£¬¹ýÂËˢР 
 | 
# @param curObj ÊÜЧ¹ûÕß  
 | 
# @param buffState buff¹ÜÀíÆ÷  
 | 
# @param curSkill ¼¼ÄÜʵÀý  
 | 
# @param value Ñ¹ÈëbuffµÄÖµ  
 | 
# @param buffOwner buffµÄÊÍ·ÅÕß  
 | 
# @param isDelRefresh Íâ½çɾ³ýBUFFÊÇ·ñˢР 
 | 
# @param tick Ê±¼ä´Á  
 | 
# @return ÊÇ·ñË¢ÐÂÍæ¼ÒÊôÐÔ  
 | 
def __AddBuff(curObj, buffState, curSkill, plusValueList, buffOwner, isDelRefresh, tick,  
 | 
              curSkillLastTime, updProcessInterval, layerMaxCnt, layerCalc):  
 | 
    skillID = curSkill.GetSkillID()  
 | 
  
 | 
    #ÊÇ·ñÐèҪ֪ͨ¿Í»§¶Ë  
 | 
    isNotify = True if curSkill.GetClientEffectType() != 0 else False  
 | 
    # Ôö¼ÓµÚËĸö²ÎÊýÊÇ·ñÁ¢¼´¹ã²¥  
 | 
    addBuff = buffState.AddBuff(skillID, tick, isNotify, False)  
 | 
      
 | 
    if updProcessInterval > 0:  
 | 
        # ¼Ì³ÐÉÏÒ»¸öbuffµÄÑ»·¼Ç¼  
 | 
        addBuff.SetProcessInterval(updProcessInterval)  
 | 
          
 | 
    #ÉèÖÃbuffÊôÐÔ  
 | 
    __SetBuffValue(addBuff , plusValueList , buffOwner)  
 | 
      
 | 
    # ²ã¼¶  
 | 
    if layerMaxCnt:  
 | 
        if layerCalc == ChConfig.Def_BuffLayer_Add:  
 | 
            addBuff.SetLayer(1)  
 | 
        else:  
 | 
            addBuff.SetLayer(layerMaxCnt)  
 | 
  
 | 
    addBuff.SetRemainTime(curSkillLastTime)  
 | 
      
 | 
    # Í¬²½Ö÷´Ó¼¼ÄÜʱ¼ä  
 | 
    SyncMasterBuffTime(curObj, addBuff, curSkill)  
 | 
      
 | 
    passiveEff = None  
 | 
    onwerID = 0  
 | 
    onwerType = 0  
 | 
    isRefresh = False # ÊÇ·ñË¢ÊôÐÔ  
 | 
      
 | 
    if buffOwner:  
 | 
        onwerID, onwerType = buffOwner.GetID(), buffOwner.GetGameObjType()  
 | 
    # buffЧ¹û¼ÓÈë  
 | 
    for effectIndex in range(0, curSkill.GetEffectCount()):  
 | 
        curEffect = curSkill.GetEffect(effectIndex)  
 | 
        effectID = curEffect.GetEffectID()  
 | 
        if effectID == 0:  
 | 
            continue  
 | 
          
 | 
        # »ñµÃbuffЧ¹ûµÄ¼ÆËãÄ£¿éÎļþºó׺, Èç¹ûÄÜÕÒµ½ËµÃ÷ÐèҪˢÊôÐÔ  
 | 
        moduleSuffix = SkillShell.GetBuffModuleSuffix(curEffect)   
 | 
        calcTypeFunc = GameWorld.GetExecFunc(GameBuffs, "Buff_%s.%s"%(moduleSuffix, "GetCalcType"))  
 | 
        if calcTypeFunc:  
 | 
            isRefresh = True  
 | 
          
 | 
        # Ö¸¶¨µÄЧ¹ûID²Å¼Ç¼£¬Ë¢ÊôÐÔÒѾ²»ÔÙͨ¹ý±éÀúЧ¹û¶ÓÁиijɱéÀúbuff  
 | 
        if effectID in ChConfig.Def_BuffManager_EffectsID:  
 | 
            buffState.AddEffect(curEffect, addBuff.GetValue(), skillID, onwerID, onwerType)  
 | 
              
 | 
        triggerType = PassiveBuffEffMng.GetBuffTriggerTypeByEffectID(effectID)  
 | 
        if triggerType == -1:  
 | 
            continue  
 | 
        passiveEff = PassiveBuffEffMng.GetPassiveEffManager().InitObjPassiveEff(curObj)  
 | 
        passiveEff.AddBuffInfoByEffect(curEffect, skillID, onwerID, onwerType)  
 | 
          
 | 
    # Í¨Öª¿Í»§¶Ë  
 | 
    #buffState.Sync_AddBuffEx()  
 | 
    if isNotify:  
 | 
        PYSync_RefreshBuff(curObj, addBuff, SkillCommon.GetBuffType(curSkill), notifyAll=False, owner = buffOwner, errSkillID=skillID)  
 | 
          
 | 
    #Ìí¼ÓBUFFºóµÄÌØÊâ´¦Àí  
 | 
    DoAddBuffOver(curObj, curSkill, addBuff, buffOwner, tick)  
 | 
  
 | 
    #¼ì²éÊÇ·ñÊôÓÚË¢ÐÂBUFF  
 | 
    #===========================================================================  
 | 
    # if not CheckBuffRefresh(curSkill, isDelRefresh):  
 | 
    #    return False  
 | 
    #===========================================================================  
 | 
      
 | 
    return isRefresh  
 | 
  
 | 
  
 | 
##buff¼ÓÉÏÖ®ºóµÄ´¦Àí£¬ÕâÀï»á¶ÔBUFFValue´¦Àí£¬´ËǰҪÏÈÉèÖúà  
 | 
# @param curObj ÊÜЧ¹û·½  
 | 
# @param curSkill buff¼¼ÄÜÊý¾Ý  
 | 
# @param addBuff Íæ¼ÒÉíÉϵÄBUFFʵÀý  
 | 
# @param tick Ê±¼ä´Á  
 | 
# @return None   
 | 
def DoAddBuffOver(curObj, curSkill, addBuff, buffOwner, tick):  
 | 
    #´¥·¢±»¶¯¼¼ÄÜ  
 | 
    if buffOwner:  
 | 
        PassiveBuffEffMng.OnPassiveSkillTrigger(buffOwner, curObj, curSkill, ChConfig.TriggerType_AddBuffOver, tick)  
 | 
        # ´Ë´¦²»ÄÜ´«¼¼ÄÜcurSkill ÆÁ±Î±»¶¯´¥·¢±»¶¯ÏÞÖÆ  
 | 
        # ÔÝÇÒÌØÊâ´¦Àí¿ØÖÆÀàbuff²Å´¥·¢  
 | 
        if SkillCommon.GetBuffType(curSkill) == IPY_GameWorld.bfActionBuff:  
 | 
            PassiveBuffEffMng.GetValueByPassiveBuffTriggerType(curObj, buffOwner, curSkill, ChConfig.TriggerType_AddBuffOver, False)  
 | 
          
 | 
    #ÊÇ·ñÊdzÖÐøÐÔ¼¼ÄÜ  
 | 
    isLstSkill = curSkill.GetSkillType() in ChConfig.Def_LstBuff_List  
 | 
      
 | 
    #buff¼ÓÉϺóµÄÌØÊâ´¦Àí  
 | 
    for effectIndex in range(0, curSkill.GetEffectCount()):  
 | 
        curEffect = curSkill.GetEffect(effectIndex)  
 | 
        effectID = curEffect.GetEffectID()  
 | 
          
 | 
        if not effectID:  
 | 
            continue  
 | 
          
 | 
        if isLstSkill:  
 | 
            callFunc = GameWorld.GetExecFunc(GameBuffs, "BuffProcess_%d.%s"%(effectID, "DoAddBuffOver"))  
 | 
            if not callFunc:  
 | 
                callFunc = GameWorld.GetExecFunc(GameBuffs, "Buff_%d.%s"%(effectID, "DoAddBuffOver"))  
 | 
        else:          
 | 
            callFunc = GameWorld.GetExecFunc(GameBuffs, "Buff_%d.%s"%(effectID, "DoAddBuffOver"))  
 | 
          
 | 
        if not callFunc:  
 | 
            continue  
 | 
          
 | 
        callFunc(curObj, addBuff, curEffect, tick, buffOwner)  
 | 
      
 | 
    return  
 | 
  
 | 
  
 | 
##Ìí¼ÓBUFF¹ýÂËˢР 
 | 
# @param curSkill  
 | 
# @param isDelRefresh Íâ½çɾ³ýBUFFÊÇ·ñˢР 
 | 
# @return ÊÇ·ñË¢ÐÂÍæ¼ÒÊôÐÔ  
 | 
def CheckBuffRefresh(curSkill, isDelRefresh):  
 | 
    #===========================================================================  
 | 
    # skillType, skillTypeID = curSkill.GetSkillType(), curSkill.GetSkillTypeID()  
 | 
    # #³ÖÐøÐÔBUFF²»Ë¢ÐÂÊôÐÔ  
 | 
    # if skillType in ChConfig.Def_LstBuff_List:  
 | 
    #    return False  
 | 
    #===========================================================================  
 | 
      
 | 
    #¶¥ÌæBUFFÖ±½ÓˢУ¬²»×öÏêϸÅж¨  
 | 
    if isDelRefresh:  
 | 
        return True  
 | 
      
 | 
    isRefresh = False  
 | 
    for effectIndex in range(0, curSkill.GetEffectCount()):  
 | 
        curEffect = curSkill.GetEffect(effectIndex)  
 | 
        effectID = curEffect.GetEffectID()  
 | 
        if effectID == 0:  
 | 
            continue  
 | 
          
 | 
        # »ñµÃbuffЧ¹ûµÄ¼ÆËãÄ£¿éÎļþºó׺  
 | 
        moduleSuffix = SkillShell.GetBuffModuleSuffix(curEffect)   
 | 
        calcTypeFunc = GameWorld.GetExecFunc(GameBuffs, "Buff_%s.%s"%(moduleSuffix, "GetCalcType"))  
 | 
        if calcTypeFunc:  
 | 
            isRefresh = True  
 | 
            break  
 | 
  
 | 
    return isRefresh  
 | 
  
 | 
  
 | 
## Ìí¼ÓBUFF Ë¢ÐÂÐÐΪ״̬  
 | 
#  @param curObj µ±Ç°¶ÔÏó  
 | 
#  @param curSkill µ±Ç°¼¼ÄÜ  
 | 
#  @param buffType buffÀàÐÍ  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.AddBuffNoRefreshStateÖÐʹÓà  
 | 
def __AddActBuffRefreshState(curObj, curSkill, buffType):  
 | 
    #Ë¢ÐÂÐÐΪ״̬£¬  
 | 
    if buffType != IPY_GameWorld.bfActionBuff:  
 | 
        return False  
 | 
  
 | 
    #Ë¢ÐÂÊôÐÔ  
 | 
    curObjType = curObj.GetGameObjType()  
 | 
    # Ìí¼Ó¿ØÖÆBUFF²»ÓÃÈ«²¿Ë¢Ð  
 | 
    #Íæ¼Ò  
 | 
    if curObjType == IPY_GameWorld.gotPlayer:  
 | 
        #Ë¢ÐÂËùÓÐ״̬  
 | 
        #playerControl = PlayerControl.PlayerControl(curObj)  
 | 
        #playerControl.RefreshPlayerActionState()  
 | 
        OperControlManager.SetObjActState(curObj, curSkill)  
 | 
    #NPC  
 | 
    elif curObjType == IPY_GameWorld.gotNPC:  
 | 
        #npcControl = NPCCommon.NPCControl(curObj)  
 | 
        #npcControl.RefreshNPCActionState()  
 | 
        OperControlManager.SetObjActState(curObj, curSkill)  
 | 
    #Òì³£  
 | 
    else:  
 | 
        GameWorld.Log("Ìí¼ÓÐÐΪbuffË¢ÐÂʧ°Ü curObjType = %s"%(curObjType))  
 | 
        return False  
 | 
      
 | 
    return True  
 | 
#---------------------------------------------------------------------  
 | 
## µ±Buffʱ¼äÂúµÄʱºò, Êä³öϵͳÌáʾ²¢¼Ç¼Á÷Ïò  
 | 
#  @param curObj Ä¿±ê  
 | 
#  @param skillID ¼¼ÄÜID  
 | 
#  @param skillLV ¼¼Äܵȼ¶  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __NotifyMsg_MaxLastTime( curObj, skillID, skillLV ):  
 | 
    curObjID = curObj.GetID()  
 | 
    curObjType = curObj.GetGameObjType()  
 | 
      
 | 
    #Ö»´¦ÀíÍæ¼Ò  
 | 
    if curObjType != IPY_GameWorld.gotPlayer:  
 | 
        return  
 | 
      
 | 
    curPlayer = GameWorld.GetObj( curObjID, curObjType )  
 | 
      
 | 
    if not curPlayer:  
 | 
        GameWorld.Log('###__NotifyMsg_MaxLastTime Err ( %s , %s )'%( curObjID, curObjType ) )  
 | 
        return  
 | 
      
 | 
    #¶Ô²»Æð£¬ÄúÉíÉÏÀÛ»ýµÄҩˮʱ¼äÒÑ´ïÉÏÏÞ,ÎÞ·¨¼ÌÐøµþ¼Ó!  
 | 
    #F607977B-0A57-4B68-A5CDB2C5DAEF4D18Ìæ»»ÎªGeRen_chenxin_60292  
 | 
    PlayerControl.NotifyCode( curPlayer, "GeRen_chenxin_60292" )  
 | 
      
 | 
    return  
 | 
#---------------------------------------------------------------------  
 | 
## ÅжÏÕâ¸öbuffÊÇ·ñ¿ÉÒÔµþ¼Ó  
 | 
#  @param curSkill µ±Ç°¼¼ÄÜ  
 | 
#  @param buffState buff״̬  
 | 
#  @param curBuff µ±Ç°buff  
 | 
#  @param buffIndex buffË÷Òý  
 | 
#  @param curSkillLastTime µ±Ç°¼¼ÄܳÖÐøÊ±¼ä  
 | 
#  @param sumTime ÀÛ¼Óʱ¼ä  
 | 
#  @param value Buff×ÜÖµ->ÓÃÓÚ³ÖÐøÀ༼ÄÜ  
 | 
#  @param buffOwner buffÓµÓÐÕß  
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __BuffCanRemain(curObj, buffState, curBuff, buffIndex, resultTime, plusValueList, buffOwner):  
 | 
    if resultTime != -1:  
 | 
        curBuff.SetRemainTime(resultTime)  
 | 
    #ÖØÖÃbuff×ÜÖµ  
 | 
    __SetBuffValue(curBuff , plusValueList , buffOwner)  
 | 
  
 | 
    buffState.Sync_RefreshBuff(buffIndex, curBuff.GetRemainTime())  
 | 
      
 | 
    DoAddBuffOver(curObj, curBuff.GetSkill(), curBuff, buffOwner, GameWorld.GetGameWorld().GetTick())    
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## ´Ó¹ÜÀíÆ÷ÖÐÈ¡µÃBUFFʵÀýºÍË÷Òý  
 | 
#  @param buffManager Buff¹ÜÀíÆ÷  
 | 
#  @param skillTypeID ¼¼ÄÜÀàÐÍID  
 | 
#  @return BUFFʵÀýºÍË÷Òý  
 | 
#  @remarks ´Ó¹ÜÀíÆ÷ÖÐÈ¡µÃBUFFʵÀýºÍË÷Òý  
 | 
def GetBuffAndIndexInManager(buffManager, skillTypeID):  
 | 
    for i in range(0, buffManager.GetBuffCount()):  
 | 
        curBuff = buffManager.GetBuff(i)  
 | 
          
 | 
        if not curBuff:  
 | 
            continue  
 | 
          
 | 
        #ÅжÏÊÇ·ñÓµÓÐͬһÀàÐ͵ļ¼ÄÜ  
 | 
        if curBuff.GetSkill().GetSkillTypeID() != skillTypeID:  
 | 
            continue  
 | 
          
 | 
        return curBuff, i  
 | 
      
 | 
    return None, 0  
 | 
  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Ë¢ÐÂBUFFµÄʱ¼ä  
 | 
#  @param curBuff µ±Ç°BUFF  
 | 
#  @param buffManager BUFF¹ÜÀíÆ÷  
 | 
#  @param buffIndex buffË÷Òý  
 | 
#  @param sumTime BUFF³ÖÐøÊ±¼ä  
 | 
#  @return None  
 | 
#  @remarks Ë¢ÐÂBUFFµÄʱ¼ä£¨²»°üÀ¨ÓÀ¾ÃBUFF£©  
 | 
def Add_SyncBuffTime(curBuff, buffManager, buffIndex, addTime):  
 | 
    #·À·¶Ê±¼äΪ0£¨´ú±íÓÀ¾Ã£©  
 | 
    remainTime =curBuff.GetRemainTime()  
 | 
    if remainTime == 0:  
 | 
        GameWorld.ErrLog("²»¿É¸Ä±ä³ÖÐøÊ±¼ä£¬¸ÃBUFFΪÓÀ¾ÃÐÔBUFF %s"%curBuff.GetBuffID())  
 | 
        return  
 | 
      
 | 
    sumTime = remainTime + addTime  
 | 
    if sumTime <= 0:  
 | 
        GameWorld.ErrLog("BUFFʱ¼äÀÛ¼ÓÒì³£ %s = %s + %s"%(sumTime, remainTime, addTime))  
 | 
        return  
 | 
      
 | 
    curBuff.SetRemainTime(sumTime)  
 | 
    #֪ͨ¿Í»§¶Ë  
 | 
    buffManager.Sync_RefreshBuff(buffIndex, sumTime)  
 | 
      
 | 
#---------------------------------------------------------------------                  
 | 
## ÉèÖÃbuffµÄÊôÐÔ  
 | 
#  @param buff buff  
 | 
#  @param value buffÖµ  
 | 
#  @param buffOwner buffÓµÓÐÕß  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __SetBuffValue(buff , valueList , buffOwner):  
 | 
    #Ìí¼ÓBuffÉèÖÃ  
 | 
    for i in range(len(valueList)):  
 | 
        if i == 0:  
 | 
            buff.SetValue(valueList[0])  
 | 
        elif i == 1:  
 | 
            buff.SetValue1(valueList[1])  
 | 
        elif i == 2:  
 | 
            buff.SetValue2(valueList[2])  
 | 
              
 | 
    #if hasattr(curTime, callObj) != True:  
 | 
    if buffOwner != None :  
 | 
        buff.SetOwnerID(buffOwner.GetID())  
 | 
        buff.SetOwnerType(buffOwner.GetGameObjType())  
 | 
          
 | 
    return  
 | 
#---------------------------------------------------------------------  
 | 
## Ë¢ÐÂBuff  
 | 
#  @param curObj  µ±Ç°¶ÔÏó  
 | 
#  @param buffState buff״̬  
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @return True or False  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def RefreshBuff( curObj, buffState, tick ):  
 | 
    #º¯ÊýÌå·µ»ØÖµ,ÊÇ·ñ³åË¢ÊôÐÔ  
 | 
    isRefresh = False  # É¾³ýµÄbuffÊÇ·ñË¢ÊôÐÔ  
 | 
    delResult = False     # É¾³ýµÄbuffÊÇ·ñË¢¿ØÖÆ  
 | 
      
 | 
    # Èç¹ûÔÚbuffˢйý³ÌÖе¼ÖÂÍæ¼ÒËÀÍö£¬²¢ÇÒÒòËÀÍöÌáǰµ¼ÖÂbuff±»ÇåÀíÔò»áµ¼Ö±¨´í  
 | 
    # µ«¿ÉÒÔÔÚË¢ÐÂǰ¾ÍÒѾËÀÍöµÄ£¬Ôò¿ÉÒÔË¢ÐÂbuff  
 | 
    beforeHP = GameObj.GetHP(curObj)  
 | 
      
 | 
    index = 0  
 | 
    isPlayerTJG = (curObj.GetGameObjType() == IPY_GameWorld.gotPlayer and PlayerTJG.GetIsTJG(curObj))  
 | 
      
 | 
    skillIDListInDelBuff = []   # buffÏûʧÖÐÐèÒª´¦ÀíÌí¼Óbuff£¬Íâ²ã´¦Àí±ÜÃâ´íÂÒ  
 | 
      
 | 
    while index < buffState.GetBuffCount():  
 | 
        curBuff = buffState.GetBuff( index )  
 | 
        if not curBuff:  
 | 
            index += 1  
 | 
            GameWorld.Log( "###Ë¢ÐÂBuffÒì³£ , ¶ÔÏó = %s"%( curObj.GetID() ) )  
 | 
            continue  
 | 
        curBuffRemainTime = curBuff.GetRemainTime()  
 | 
        curSkill = curBuff.GetSkill()  
 | 
        #Ìî±í,³ÖÐøÊ±¼äΪ0µÄBuffΪÓÀ¾ÃBuff  
 | 
        if not curSkill.GetLastTime() and not curBuffRemainTime:  
 | 
            index += 1  
 | 
            continue  
 | 
          
 | 
        if isPlayerTJG and curSkill.GetSkillTypeID() in ChConfig.TJGStateNotRefreshTimeBuff:  
 | 
            curBuff.SetCalcStartTick( tick )   
 | 
            index += 1  
 | 
            #GameWorld.DebugLog("ÍÑ»ú¹Ò״̬ϲ»Ë¢ÐÂbuffʱ¼ä: skillTypeID=%s" % curSkill.GetSkillTypeID())  
 | 
            continue  
 | 
          
 | 
        remainTime = curBuffRemainTime - ( tick - curBuff.GetCalcStartTick() )  
 | 
        #»¹ÓÐÊ£Óàʱ¼ä  
 | 
        if remainTime > 0:  
 | 
            curBuff.SetCalcStartTick( tick )   
 | 
            curBuff.SetRemainTime( remainTime )  
 | 
            index += 1  
 | 
            continue  
 | 
        #-------------------ÎÞÊ£Óàʱ¼äÁË  
 | 
        curBuff.SetRemainTime(0)  
 | 
  
 | 
        ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()  
 | 
        #Õâ¸öº¯ÊýÀïÃæ²»ÄÜ×öBuffÌí¼ÓºÍɾ³ýÂß¼!!!!!²»È»Ö¸Õë»á´íÂÒ  
 | 
        DoBuffDisApper( curObj, curBuff, tick )  
 | 
          
 | 
        if beforeHP != 0 and GameObj.GetHP(curObj) == 0:  
 | 
            # Ë¢ÐÂǰÓÐѪÁ¿£¬Ë¢ÐºóËÀÍöÔòÍ˳ö£¬´ýÏÂÒ»´ÎˢУ¬±ØÐëËÀÍöÌáǰɾbuffµ¼Ö±¨´í  
 | 
            return False, False  
 | 
          
 | 
        #±ê¼Çɾ³ý±ê¼Ç  
 | 
        if not isRefresh and CheckBuffRefresh(curSkill, False):  
 | 
            # ÊôÐÔÀà  
 | 
            isRefresh = True  
 | 
  
 | 
        if not delResult:  
 | 
            # ÓÃÓÚ¿ØÖÆÀàÅÐ¶Ï  
 | 
            delResult = True  
 | 
        buffState.DeleteBuffByIndex( index )  
 | 
        SkillShell.ClearBuffEffectBySkillID(curObj, curSkill.GetSkillID(), ownerID, ownerType)  
 | 
          
 | 
        addSkillID = curObj.GetDictByKey(ChConfig.Def_PlayerKey_SkillInDelBuff)   
 | 
        if addSkillID:  
 | 
            skillInfo = [addSkillID, ownerID, ownerType]  
 | 
            if skillInfo not in skillIDListInDelBuff:  
 | 
                skillIDListInDelBuff.append(skillInfo)  
 | 
            curObj.SetDict(ChConfig.Def_PlayerKey_SkillInDelBuff, 0)   
 | 
              
 | 
    OnSkillAfterBuffDisappear(curObj, skillIDListInDelBuff, tick)  
 | 
      
 | 
    #Ö´ÐÐDoBuffDisApperÖÐ,±ê¼ÇµÄÍæ¼Ò´¦ÀíÒªÇó  
 | 
    __DoBuffDisApperByKey( curObj , tick )  
 | 
          
 | 
    return isRefresh, delResult  
 | 
  
 | 
  
 | 
# DoBuffDisApper²»ÄÜ×öBuffÌí¼ÓºÍɾ³ýÂß¼!!!!!²»È»Ö¸Õë»á´íÂÒ, ¹ÊÔÚÍâ²ã´¦Àí  
 | 
def OnSkillAfterBuffDisappear(curObj, skillIDListInDelBuff, tick):  
 | 
    posX, posY = curObj.GetPosX(), curObj.GetPosY()  
 | 
    for skillInfo in skillIDListInDelBuff:  
 | 
        attacker = GameWorld.GetObj(skillInfo[1], skillInfo[2])  
 | 
        if not attacker:  
 | 
            attacker = curObj  
 | 
        skillData = GameWorld.GetGameData().GetSkillBySkillID(skillInfo[0])  
 | 
        if not skillData:  
 | 
            continue  
 | 
          
 | 
        SkillShell.Trigger_UseSkill(attacker, curObj, skillData, tick, posX, posY)  
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Ö´ÐÐbuffÏûʧ´¥·¢Âß¼  
 | 
#  @param curObj µ±Ç°OBj  
 | 
#  @param curBuff µ±Ç°buff  
 | 
#  @param tick µ±Ç°Ê±¼ä  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def DoBuffDisApper( curObj, curBuff, tick ):  
 | 
    #Õâ¸öº¯ÊýÀïÃæ²»ÄÜ×öBuffÌí¼ÓºÍɾ³ýÂß¼!!!!!²»È»Ö¸Õë»á´íÂÒ  
 | 
    curSkill = curBuff.GetSkill()  
 | 
  
 | 
    curObjType = curObj.GetGameObjType()  
 | 
    skillData = GameWorld.GetGameData().GetSkillBySkillID(curSkill.GetSkillID())  
 | 
      
 | 
    #ÊÇ·ñÊdzÖÐøÐÔ¼¼ÄÜ  
 | 
    isLstSkill = curSkill.GetSkillType() in ChConfig.Def_LstBuff_List  
 | 
      
 | 
    PassiveBuffEffMng.OnPassiveSkillTrigger(curObj, None, curSkill, ChConfig.TriggerType_BuffDisappear, tick)  
 | 
      
 | 
    #buffÏûʧµÄ´¥·¢  
 | 
    for effectIndex in range( 0, curSkill.GetEffectCount() ):  
 | 
        curEffect = curSkill.GetEffect( effectIndex )  
 | 
        effectID = curEffect.GetEffectID()  
 | 
          
 | 
        if not effectID:  
 | 
            continue  
 | 
          
 | 
        if isLstSkill:  
 | 
            callFunc = GameWorld.GetExecFunc( GameBuffs, "BuffProcess_%d.%s"%( effectID, "OnBuffDisappear") )  
 | 
            if not callFunc:  
 | 
                callFunc = GameWorld.GetExecFunc( GameBuffs, "Buff_%d.%s"%( effectID, "OnBuffDisappear") )  
 | 
        else:          
 | 
            callFunc = GameWorld.GetExecFunc( GameBuffs, "Buff_%d.%s"%( effectID, "OnBuffDisappear") )  
 | 
          
 | 
        if not callFunc:  
 | 
            continue  
 | 
          
 | 
        callFunc( curObj, curSkill, curBuff, curEffect, tick )  
 | 
          
 | 
        #=======================================================================  
 | 
        # if curObjType == IPY_GameWorld.gotPlayer and curSkillTypeID in ChConfig.Ded_ComboBuffProcessSkillIDList:  
 | 
        #    curObj.SetDict(ChConfig.Def_PlayerKey_ComboBuffProcessState, 0)  
 | 
        #    #GameWorld.DebugLog("Á¬»÷buffÏûʧ£¬ÖØÖô¦Àí״̬£¡%s" % curSkillTypeID)  
 | 
        #=======================================================================  
 | 
              
 | 
    passiveEff = PassiveBuffEffMng.GetPassiveEffManager().GetPassiveEff(curObj)  
 | 
    if passiveEff:  
 | 
        passiveEff.DelBuffInfo(skillData)  
 | 
    return  
 | 
  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Ö´ÐÐbuffÏûʧ´¥·¢Âß¼£¬²»´¦ÀíbuffµÄ¹¦ÄÜÂß¼£¬Ö»´¦ÀíÐèÒªµÄ±ØÐë״̬Âß¼  
 | 
#  Èç²»´¦ÀíbuffµÄ É˺¦£¬±¬Õ¨µÈ£¬µ«±ØÐë´¦Àí»Ö¸´Ñ£ÔÎ״̬µÈ  
 | 
def DoBuffDisApperEx( curObj, curBuff, tick ):  
 | 
    #Õâ¸öº¯ÊýÀïÃæ²»ÄÜ×öBuffÌí¼ÓºÍɾ³ýÂß¼!!!!!²»È»Ö¸Õë»á´íÂÒ  
 | 
    curSkill = curBuff.GetSkill()  
 | 
  
 | 
    skillData = GameWorld.GetGameData().GetSkillBySkillID(curSkill.GetSkillID())  
 | 
      
 | 
    #ÊÇ·ñÊdzÖÐøÐÔ¼¼ÄÜ  
 | 
    isLstSkill = curSkill.GetSkillType() in ChConfig.Def_LstBuff_List  
 | 
      
 | 
    PassiveBuffEffMng.OnPassiveSkillTrigger(curObj, None, curSkill, ChConfig.TriggerType_BuffDisappear, tick)  
 | 
      
 | 
    #buffÏûʧµÄ´¥·¢  
 | 
    for effectIndex in range( 0, curSkill.GetEffectCount() ):  
 | 
        curEffect = curSkill.GetEffect( effectIndex )  
 | 
        effectID = curEffect.GetEffectID()  
 | 
          
 | 
        if not effectID:  
 | 
            continue  
 | 
          
 | 
        if isLstSkill:  
 | 
            callFunc = GameWorld.GetExecFunc( GameBuffs, "BuffProcess_%d.%s"%( effectID, "OnBuffDisappearEx") )  
 | 
            if not callFunc:  
 | 
                callFunc = GameWorld.GetExecFunc( GameBuffs, "Buff_%d.%s"%( effectID, "OnBuffDisappearEx") )  
 | 
        else:          
 | 
            callFunc = GameWorld.GetExecFunc( GameBuffs, "Buff_%d.%s"%( effectID, "OnBuffDisappearEx") )  
 | 
          
 | 
        if not callFunc:  
 | 
            continue  
 | 
          
 | 
        callFunc( curObj, curSkill, curBuff, curEffect, tick )  
 | 
              
 | 
    passiveEff = PassiveBuffEffMng.GetPassiveEffManager().GetPassiveEff(curObj)  
 | 
    if passiveEff:  
 | 
        passiveEff.DelBuffInfo(skillData)  
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## buffÏûʧ  
 | 
#  @param curObj µ±Ç°Ä¿±ê  
 | 
#  @param µ±Ç°Ê±¼ä  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __DoBuffDisApperByKey( curObj, tick ):  
 | 
      
 | 
    #2012-06-13 jiang Ð޸ĺìÃûbuffÏûʧʱֱ½ÓÇå³ýpkÖµ  
 | 
    #===========================================================================  
 | 
    # if curObj.GetDictByKey(ChConfig.Def_Player_DelBuff_PncRed):  
 | 
    #    #Ê£ÓàPKÖµ²»Îª0,Ìí¼ÓºìÃûBuff  
 | 
    #    if curObj.GetPKValue() > 0:  
 | 
    #        curObj.SetPKValue(0)  
 | 
    #      
 | 
    #    #Çå¿Õ×ÖµäÖµ  
 | 
    #    curObj.SetDict( ChConfig.Def_Player_DelBuff_PncRed , 0 )  
 | 
    #===========================================================================  
 | 
      
 | 
    #-------------¸±±¾µØÍ¼Âß¼´¦Àí  
 | 
    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtNull:  
 | 
        return  
 | 
      
 | 
    #FB BUFFÏûʧÂß¼  
 | 
    FBLogic.DoBuffDisAppear( curObj, tick )  
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##ͨ¹ý¼¼ÄÜIDɾ³ý¶ÔÏóBuff£¬ Íâ²ãË¢ÐÂÊôÐÔ  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
# @param skillID ¼¼ÄÜID  
 | 
# @param tick Ê±¼ä´Á  
 | 
# @return ²¼¶ûÖµ  
 | 
def DelBuffBySkillID(curObj, skillID, tick, disappearTrigger=True, buffOwner=None):  
 | 
    buffSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)  
 | 
      
 | 
    #Òì³£´íÎó  
 | 
    if not buffSkill:  
 | 
        #GameWorld.Log("²éÕÒBuffÒì³£ = %s "%(ChConfig.Def_SkillID_JoinExam) , curPlayer.GetPlayerID())  
 | 
        return False  
 | 
      
 | 
    buffType = SkillCommon.GetBuffType(buffSkill)  
 | 
    buffTuple = SkillCommon.GetBuffManagerByBuffType(curObj, buffType)  
 | 
    #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö  
 | 
    if buffTuple == ():  
 | 
        return False  
 | 
      
 | 
    buffMgr = buffTuple[0]  
 | 
    #ÅжÏÊÇ·ñ´æÔÚµÄBUFF  
 | 
    buffSkillTypeID = buffSkill.GetSkillTypeID()  
 | 
    curBuff = buffMgr.FindBuff(buffSkillTypeID)  
 | 
    if not curBuff:  
 | 
        #Buff²»´æÔÚ  
 | 
        return False  
 | 
      
 | 
    ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()  
 | 
    if buffOwner:  
 | 
        if buffOwner.GetGameObjType() != ownerType or buffOwner.GetID() != ownerID:  
 | 
            #GameWorld.DebugLog("buff¹éÊô²»Í¬£¬²»ÄÜÇå³ý£¡skillID=%s" % skillID, curObj.GetID())  
 | 
            return False  
 | 
    if disappearTrigger:  
 | 
        #ɾ³ýBuff  
 | 
        DoBuffDisApper(curObj, curBuff, tick)  
 | 
    buffMgr.DeleteBuffByTypeID(buffSkillTypeID)  
 | 
      
 | 
    SkillShell.ClearBuffEffectBySkillID(curObj, skillID, ownerID, ownerType)  
 | 
    #ÕâÀïֻˢÐÂBUFFЧ¹ûÊý£¬Íâ²ã¾ö¶¨ÊÇ·ñË¢ÐÂÊôÐÔ  
 | 
    #if refresh:  
 | 
    #    SkillShell.RefreshPlayerBuffOnAttrAddEffect(curPlayer, buffType)  
 | 
          
 | 
    # É¾³ýbuffÒ²ÐèÒª¿¼ÂÇÊÇ·ñÒòbuff×öË¢ÐÂÊôÐÔ ÈçÎÞÊôÐÔbuffºÍ¹¥ËÙ£¬Òƶ¯ËÙ¶È  
 | 
    return True  
 | 
  
 | 
  
 | 
# Í¨¹ý¼¼ÄÜtypeidɾ³ýbuff  
 | 
def DelBuffBySkillTypeID(curPlayer, skillTypeID, tick, disappearTrigger=True):  
 | 
    buffSkill = GameWorld.GetGameData().GetSkillBySkillID(skillTypeID)  
 | 
      
 | 
    #Òì³£´íÎó  
 | 
    if not buffSkill:  
 | 
        #GameWorld.Log("²éÕÒBuffÒì³£ = %s "%(ChConfig.Def_SkillID_JoinExam) , curPlayer.GetPlayerID())  
 | 
        return False  
 | 
      
 | 
    buffType = SkillCommon.GetBuffType(buffSkill)  
 | 
    buffTuple = SkillCommon.GetBuffManagerByBuffType(curPlayer, buffType)  
 | 
    #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö  
 | 
    if buffTuple == ():  
 | 
        return False  
 | 
      
 | 
    buffMgr = buffTuple[0]  
 | 
    #ÅжÏÊÇ·ñ´æÔÚµÄBUFF  
 | 
    buffSkillTypeID = buffSkill.GetSkillTypeID()  
 | 
    curBuff = buffMgr.FindBuff(buffSkillTypeID)  
 | 
    if not curBuff:  
 | 
        #Buff²»´æÔÚ  
 | 
        return False  
 | 
      
 | 
    ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()  
 | 
    #ɾ³ýBuff  
 | 
    if disappearTrigger:  
 | 
        DoBuffDisApper(curPlayer, curBuff, tick)  
 | 
    buffMgr.DeleteBuffByTypeID(buffSkillTypeID)  
 | 
      
 | 
    SkillShell.ClearBuffEffectBySkillTypeID(curPlayer, skillTypeID, ownerID, ownerType)   
 | 
      
 | 
    # É¾³ýbuffÒ²ÐèÒª¿¼ÂÇÊÇ·ñÒòbuff×öË¢ÐÂÊôÐÔ ÈçÎÞÊôÐÔbuffºÍ¹¥ËÙ£¬Òƶ¯ËÙ¶È  
 | 
    return True  
 | 
  
 | 
  
 | 
# µ±²ã¼¶Îª0µÄʱºòɾ³ý´Ëbuff  
 | 
def SetBuffLayer(gameObj, buff, layer, delBuff=True, skillTypeID=0, disappearTrigger=True, isSync=False):  
 | 
    buff.SetLayer(layer)  
 | 
    if layer == 0 and delBuff:  
 | 
        tick = GameWorld.GetGameWorld().GetTick()  
 | 
        DelBuffBySkillTypeID(gameObj, skillTypeID, tick, disappearTrigger)  
 | 
          
 | 
        curObjType = gameObj.GetGameObjType()  
 | 
        #Íæ¼Ò  
 | 
        if curObjType == IPY_GameWorld.gotPlayer:  
 | 
            #Ë¢ÐÂÍæ¼ÒÊôÐÔ  
 | 
            playerControl = PlayerControl.PlayerControl(gameObj)  
 | 
            #playerControl.CalcPassiveBuffAttr()  
 | 
            playerControl.RefreshPlayerAttrByBuff()  
 | 
        #NPC  
 | 
        elif curObjType == IPY_GameWorld.gotNPC:  
 | 
            npcControl = NPCCommon.NPCControl(gameObj)  
 | 
            npcControl.RefreshNPCAttrState()  
 | 
    else:  
 | 
        curObjType = gameObj.GetGameObjType()  
 | 
        if isSync and curObjType == IPY_GameWorld.gotPlayer:  
 | 
            buffType = SkillCommon.GetBuffType(buff.GetSkill())  
 | 
            PYSync_RefreshBuff(gameObj, buff, buffType)  
 | 
    return  
 | 
  
 | 
def ReduceBuffLayer(gameObj, buff, skillTypeID, delLayerCnt=1):  
 | 
    ## ¼õÉÙbuffµÄValueÖµ  
 | 
    #GameWorld.DebugLog("ReduceBuffLayer: skillTypeID=%s,delLayerCnt=%s %s" % (skillTypeID, delLayerCnt, buff))  
 | 
    if not buff and not skillTypeID:  
 | 
        return  
 | 
      
 | 
    if not buff:  
 | 
        buff = SkillCommon.FindBuffByID(gameObj, skillTypeID)[0]  
 | 
          
 | 
    if not buff or buff.GetLayer() <= 0:  
 | 
        return  
 | 
      
 | 
    SetBuffLayer(gameObj, buff, max(0, buff.GetLayer() - delLayerCnt), skillTypeID=skillTypeID, isSync=True)  
 | 
    return  
 | 
  
 | 
## ÊôÐÔbuffЧ¹ûid¶ÔÓ¦¼ÆËãÄ£¿é×Öµä{Ч¹ûid:(¼ÆËãÄ£¿éÃûºó׺, [ÊôÐÔÀàÐÍ])}  
 | 
#  ´øÊôÐÔµÄbuff Ä¬ÈÏÒÔÊôÐÔÀàÐÍΪЧ¹ûID  
 | 
def FindBuffAttrByEffectID(effect):  
 | 
    """  
 | 
    buffЧ¹ûID¶¨Òå  
 | 
    1.»ù´¡ÊôÐÔÒÔ TYPE_Calc_AttrList µÄÀàÐÍΪID£¬AֵΪ¾ßÌåÖµ£¬BֵΪÏßÐÔ£¨¼ÆË㣩ÀàÐÍ£¬ÒÔ¶àЧ¹ûµÄ·½Ê½Ö§³ÖÅäÖöàÊôÐÔ  
 | 
    2.·Ç»ù´¡ÊôÐÔ»ò¶àÊôÐÔ¿ÉÅäÖÃÔÚ Def_Skill_BuffEffectDict ÖÐ  
 | 
    3.ÆäËûÌØ¶¨Ð§¹ûΪ¾ßÌå×ö·¨  
 | 
    """  
 | 
    effectID = effect.GetEffectID()  
 | 
    if effectID in ChConfig.TYPE_Calc_AttrList:  
 | 
        # ´Ë´¦IDΪDef_Calc_AllAttrType_MAXÖеÄÀàÐÍ  
 | 
        return ChConfig.EffCalcTypeDict.get(effect.GetEffectValue(1), ""), [effectID]  
 | 
  
 | 
    return ChConfig.Def_Skill_BuffEffectDict.get(effectID, ("", []))  
 | 
  
 | 
  
 | 
# Ê¹ÓÃÀà FindEffect º¯Êý£¬Í¨¹ýЧ¹ûIDÕÒÉíÉϵÄbuffЧ¹û  
 | 
def FindBuffEffectPlusByEffectID(buffState, effectID):  
 | 
    #gameObj.GetBuffState().FindEffect(ChConfig)  
 | 
    for i in range(buffState.GetEffectCount()):  
 | 
        effect = buffState.GetEffect(i)  
 | 
        if not effect:  
 | 
            continue  
 | 
        if effect.GetEffectID() != effectID:  
 | 
            continue  
 | 
          
 | 
        return effect, buffState.GetEffectPlusValue(i), buffState.GetEffectFromSkillID(i)  
 | 
    return None, None, None  
 | 
  
 | 
  
 | 
# Ê¹ÓÃÀà FindEffect º¯Êý£¬Í¨¹ýЧ¹ûIDºÍÓµÓÐÕßÕÒÉíÉϵÄbuffЧ¹û  
 | 
def FindBuffEffectByOwnertID(buffState, effectID, ownerID, ownerType):  
 | 
    #gameObj.GetBuffState().FindEffect(ChConfig)  
 | 
    for i in range(buffState.GetEffectCount()):  
 | 
        effect = buffState.GetEffect(i)  
 | 
        if not effect:  
 | 
            continue  
 | 
        if effect.GetEffectID() != effectID:  
 | 
            continue  
 | 
          
 | 
        if buffState.GetEffectOwnerID(i) != ownerID:  
 | 
            continue  
 | 
        if buffState.GetEffectOwnerType(i) != ownerType:  
 | 
            continue  
 | 
  
 | 
        return effect, buffState.GetEffectPlusValue(i), buffState.GetEffectFromSkillID(i)  
 | 
    return None, None, None  
 | 
  
 | 
  
 | 
def DeleteBuffByEffectID(curObj, buffState, effectID, tick):  
 | 
    curEffect, plusValue, skillID = FindBuffEffectPlusByEffectID(buffState, effectID)  
 | 
    if not curEffect:  
 | 
        return  
 | 
      
 | 
    return DelBuffBySkillID(curObj, skillID, tick)  
 | 
  
 | 
def PYSync_RefreshBuff(gameObj, curBuff, buffType, notifyAll=True, owner = None, errSkillID=None):  
 | 
    try:  
 | 
        sendPack = ChNetSendPack.tagObjAddBuff()  
 | 
        if not curBuff:  
 | 
            return  
 | 
        if not hasattr(curBuff, "GetSkill"):  
 | 
            return  
 | 
        curSkill = curBuff.GetSkill()  
 | 
        if not curSkill or not hasattr(curSkill, "GetSkillID"):  
 | 
            return  
 | 
        skillID = curSkill.GetSkillID()  
 | 
        if GameObj.GetHP(gameObj) <= 0 or AttackCommon.GetIsDead(gameObj):  
 | 
            return  
 | 
        sendPack.ObjType = gameObj.GetGameObjType()  
 | 
        sendPack.ObjID = gameObj.GetID();  
 | 
        sendPack.SkillID = skillID;  
 | 
        sendPack.LastTime = curBuff.GetRemainTime();  
 | 
        sendPack.BuffType = buffType;  
 | 
        sendPack.Value = curBuff.GetValue();  
 | 
        sendPack.Value1 = curBuff.GetValue1();  
 | 
        sendPack.Value2 = curBuff.GetValue2();  
 | 
        sendPack.Layer = curBuff.GetLayer();  
 | 
        if owner:  
 | 
            sendPack.OwnerID = owner.GetID()  
 | 
            sendPack.OwnerType = owner.GetGameObjType()  
 | 
        if notifyAll or gameObj.GetGameObjType() != IPY_GameWorld.gotPlayer:  
 | 
            gameObj.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength());  
 | 
        else:  
 | 
            PlayerControl.PyNotifyAll(gameObj, sendPack, notifySelf=True, notifyCnt=-1)  
 | 
    except:  
 | 
        GameWorld.RaiseException("PYSync_RefreshBuff error errSkillID=%s" % errSkillID)  
 | 
        return  
 | 
      
 | 
     
 |