hxp
2024-09-18 d0d6f28bee730ee64bf46adffa4f768d6af6ac0c
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
71
72
73
74
#!/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 = []
    buff = SkillCommon.FindBuffByID(attacker, curSkill.GetSkillTypeID())[0]
    if buff:
        addBuffValueList = [buff.GetValue(), buff.GetValue1(), buff.GetValue2()]
        #GameWorld.DebugLog("͵ȡĿ±êÊôÐÔ£¬ÒѾ­´æÔÚbuff£¬Ö±½Óȡԭֵ! atkID=%s,defID=%s,addBuffValueList=%s,layer=%s" 
        #                   % (attacker.GetID(), defender.GetID(), addBuffValueList, buff.GetLayer()))
    else:
        # Ð§¹û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)
    return BuffSkill.DoAddBuff(attacker, buffType, curSkill, tick, addBuffValueList, attacker)
    #´¦Àí¼¼ÄÜ´¥·¢ºÍ¹¥»÷³É¹¦Âß¼­
    #return BaseAttack.DoSkillEx_AttackSucess(attacker, defender, curSkill, tick, isEnhanceSkill)