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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/python
# -*- coding: GBK -*-
#
# @todo: 
#
# @author: Alee
# @date 2017-12-7 ÏÂÎç05:18:11
# @version 1.0
#
# @note: ³ÖÐø¶¾É˺¦£¬ÕæÊµ¼ÆËã
#
#---------------------------------------------------------------------
#µ¼Èë
import SkillCommon
import GameWorld
import ChConfig
import GameObj
import AttackCommon
import SkillShell
import PassiveBuffEffMng
import BaseAttack
import BuffSkill
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
#---------------------------------------------------------------------
 
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ
## ³ÖÐøÐÔBuff´¦Àí 
#  @param defender ³ÐÊÜÕß
#  @param curBuff µ±Ç°Buff
#  @param curEffect BuffЧ¹û
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def ProcessBuff(defender, curBuff, curEffect, processBuffTick, tick):
    if curBuff.GetValue2() == 0:
        return
    
    layer = max(curBuff.GetLayer(), 1)
    #µ¥´ÎÉ˺¦, ¶¾Óв㼶µÄÇé¿ö
    singleDecHP = curBuff.GetValue()*layer
    hurtPer = FindBuffPer(defender, curBuff)    # ÕÒµ½ÁíÍâÒ»¸öbuff¶ÔÖж¾µÄÉ˺¦¼Ó³É
    
    singleDecHP = int((hurtPer + ChConfig.Def_MaxRateValue)*1.0/ChConfig.Def_MaxRateValue*singleDecHP)
    #GameWorld.DebugLog("1033---------%s-%s-%s-%s"%(curBuff.GetValue(), layer, hurtPer, singleDecHP ) )
    #buffÓµÓÐÕß
    buffOwner = SkillCommon.GetBuffOwner(curBuff)
    
    curBuffSkillID = curBuff.GetSkill().GetSkillTypeID()
    
    # SkillLostHPǰµ÷ÓàËÀÍö»òÕ߯äËûÇé¿ö»áÈ¡ÏûcurBuff
    curBuff.SetValue2(max(curBuff.GetValue2() - 1, 0))
    SkillCommon.SkillLostHP(defender, curBuffSkillID, buffOwner, singleDecHP, tick, hurtType=ChConfig.Def_HurtType_Bleed)
    
    return
 
 
##³ÖÐøÉ˺¦Buff, ¸ù¾Ý¹¥»÷ÕßÉ˺¦¼ÆËã
# @param attacker ¹¥»÷ÕßʵÀý
# @param curSkill ¼¼ÄÜʵÀý
# @param curEffect µ±Ç°¼¼ÄÜЧ¹û1
# @return ×ÜÖµ
def CalcBuffValue(attacker, defender, curSkill, changeBuffValueDict):
    curEffect = curSkill.GetEffect(0)
    skillPer = curEffect.GetEffectValue(0)/float(ChConfig.Def_MaxRateValue)
    skillEnhance = curEffect.GetEffectValue(1)
    
    # ¿Í»§¶Ë±íÏÖÆ®×ÖΪÁ÷Ѫ£¬ÎÞÐè֪ͨÆäËûÉËѪÀàÐÍ
    hurtValue, hurtType = AttackCommon.CalcHurtHP(attacker, defender, curSkill, 
                            skillEnhance, skillPer, GameWorld.GetGameWorld().GetTick(), 
                            ChConfig.Def_Skill_HappenState_HitOn)
    addTime = PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(attacker, None, curSkill, ChConfig.TriggerType_BuffTime)
    buffTick = SkillShell.GetProcessBuffTick(curSkill, attacker)
    
    # µ¥´ÎÉ˺¦Öµ£¬É˺¦ÀàÐÍ£¬´ÎÊý£¨ÅäºÏЧ¹ûID9999µÄ¼ä¸ô£©
    return [hurtValue, hurtType, int(addTime/buffTick + curEffect.GetEffectValue(2))]
 
 
# ÏûʧǰÈçÓÐδִÐдÎÊýÔò²¹ÉÏ
#  @param defender ³ÐÊÜÕß
def OnBuffDisappear(defender, curSkill, curBuff, curEffect, tick):
    #ÒѾ­ËÀÍö²»´¥·¢
    if GameObj.GetHP(defender) <= 0:
        return
    
    count = curBuff.GetValue2()
    #ÎÞÊ£Óà
    if count > 0:
    
        SkillCommon.SkillLostHP(defender, curSkill.GetSkillTypeID(), SkillCommon.GetBuffOwner(curBuff), 
                                curBuff.GetValue()*count, tick, hurtType=ChConfig.Def_HurtType_Bleed)
    #ÒѾ­ËÀÍö²»´¥·¢
    if GameObj.GetHP(defender) <= 0:
        return
    
    BuffBoom(defender, curSkill, curBuff, tick)
    return
 
# buff±¬Õ¨£¬É˺¦ËãÊÍ·ÅbuffÕߣ¬Í¨Öª¿Í»§¶Ë±íÏÖΪÖÐBUFFÕß,ĿǰֻÄÜ´¦ÀíÒ»ÖÖ±¬Õ¨
def BuffBoom(defender, curSkill, curBuff, tick):
    #buffÓµÓÐÕß
    attacker = SkillCommon.GetBuffOwner(curBuff)
    if not attacker:
        return
    
    skills = PassiveBuffEffMng.GetPassiveSkillByTriggerType(attacker, defender, curSkill, ChConfig.TriggerType_BuffBoom)
 
    if not skills:
        return
    
    boomSkill = skills[0]
    curEffect = curSkill.GetEffect(0)
    skillPer = curEffect.GetEffectValue(0)/float(ChConfig.Def_MaxRateValue)
    skillEnhance = curEffect.GetEffectValue(1)
 
    BaseAttack.AttackAreaDefenderNotify(attacker, defender, defender.GetPosX(), defender.GetPosY(), boomSkill,
                            skillPer, skillEnhance, tick)
    
    return
 
 
 
# ÕÒµ½¶ÔÓ¦¼Ó³ÉÉ˺¦µÄ¶¾
def FindBuffPer(curObj, curBuff):
    ownerID = curBuff.GetOwnerID()
    ownerType = curBuff.GetOwnerType()
    
    if not ownerType:
        return 0
    
    buffManager = curObj.GetDeBuffState()
    curEffect, plusValue, skillID = BuffSkill.FindBuffEffectByOwnertID(buffManager, ChConfig.Def_Skill_Effect_ProBloodPer, ownerID, ownerType)
    if not curEffect:
        return 0
    
    # buffÏàͬ¹éÊôÕßµÄÖ¸¶¨buff²ÅÓÐÉ˺¦¼Ó³É
    for i in range(buffManager.GetBuffCount()):
        findBuff = buffManager.GetBuff(i)
        if findBuff.GetBuffID() != skillID:
            continue
        if findBuff.GetOwnerID() != ownerID:
            continue
        
        if curEffect.GetEffectValue(1) == curBuff.GetBuffID():
            return curEffect.GetEffectValue(0)
 
    return 0