1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
# -*- coding: GBK -*-
#
##@package
#
# @todo: ÎüÊÕ¶Ô·½ÊôÐÔ£¬ÓÐÄ¿±ê¼¼ÄÜ£¨41£©, ÔöÒæbuff
#
# @author: Alee
# @date 2019-3-15 ÏÂÎç04:05:05
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
 
import ChConfig
import BaseAttack
import BuffSkill
import IPY_GameWorld
import EffGetSet
import GameWorld
import SkillCommon
 
 
def UseBuff(attacker, defender, curSkill, tick, tagRoundPosX, tagRoundPosY):
#def UseSkill(attacker, defender, curSkill, tagRoundPosX, tagRoundPosY, isEnhanceSkill, tick):
    if not defender:
        return
    
    atkObjType = attacker.GetGameObjType()
    defObjType = defender.GetGameObjType()
    
    attrIndexAllowList = [] # ´æÔÚNPC£¬½öÔÊÐí͵ȡµÄÊôÐÔÀàÐÍ
    if atkObjType != IPY_GameWorld.gotPlayer or defObjType != IPY_GameWorld.gotPlayer:
        attrIndexAllowList = [ChConfig.TYPE_Calc_AttrMaxHP, ChConfig.TYPE_Calc_AttrATKMin, ChConfig.TYPE_Calc_AttrATKMax,
                              ChConfig.TYPE_Calc_AttrDEF, ChConfig.TYPE_Calc_AttrAtkSpeed]
        
    #GameWorld.DebugLog("͵ȡĿ±êÊôÐÔ: atkID=%s,defID=%s,attrIndexAllowList=%s" % (attacker.GetID(), defender.GetID(), attrIndexAllowList))
    addBuffValueList = []
    # Ð§¹ûID | ÊôÐÔÏÍò·ÖÂÊ
    # ×î¶àÎüÊÕÄ¿±ê3ÖÖÊôÐÔ ´æÈëbuffvalue£¬¹Ì¶¨Ç°3¸öЧ¹û
    # AÖµ-ÊôÐÔID BÖµ-ÎüÈ¡Íò·ÖÂÊ CÖµ-×î¸ß²»³¬¹ý×ÔÉíÊôÐÔÍò·ÖÂÊ£¬Åä0²»ÏÞÖÆ
    for i in range(3):
        effect = curSkill.GetEffect(i)
        attrIndex = effect.GetEffectValue(0)
        if not attrIndex:
            continue
        if attrIndexAllowList and attrIndex not in attrIndexAllowList:
            continue
        
        attrRate = effect.GetEffectValue(1)
        tagValue = EffGetSet.GetValueByEffIndex(defender, attrIndex)
        addValue = int(tagValue * attrRate / float(ChConfig.Def_MaxRateValue))
        
        maxRate = effect.GetEffectValue(2)
        curValue = EffGetSet.GetValueByEffIndex(attacker, attrIndex)
        if maxRate:
            maxValue = int(curValue * maxRate / float(ChConfig.Def_MaxRateValue))
            addValue = min(addValue, maxValue)
            
        addBuffValueList.append(addValue)
        GameWorld.DebugLog("͵ȡĿ±êÊôÐÔ: atkID=%s,defID=%s,attrIndex=%s,attrRate=%s,addValue=%s,tagValue=%s,curValue=%s,maxRate=%s" 
                           % (attacker.GetID(), defender.GetID(), attrIndex, attrRate, addValue, tagValue, curValue, maxRate))
        
    buffType = SkillCommon.GetBuffType(curSkill)
    BuffSkill.DoAddBuff(attacker, buffType, curSkill, tick, addBuffValueList, attacker)
    
    return True
    #´¦Àí¼¼ÄÜ´¥·¢ºÍ¹¥»÷³É¹¦Âß¼­
    #return BaseAttack.DoSkillEx_AttackSucess(attacker, defender, curSkill, tick, isEnhanceSkill)