hch
2019-01-14 e5db513abff704b3ea6112618651e7d2b622a7c0
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
#!/usr/bin/python
# -*- coding: GBK -*-
#
##@package Ä£°å30
#
# @todo: Çå³ýijÀàdebuffÆäÖÐÒ»¸ö, Def_SkillType_Count
#
# @author: Alee
# @date 2018-5-10 ÏÂÎç08:07:10
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
import SkillCommon
import ChConfig
import BuffSkill
import SkillShell
import BaseAttack
import GameObj
import PlayerControl
import IPY_GameWorld
import NPCCommon
import GameWorld
#------------------------------------------------------------------------------ 
 
 
 
#def UseBuff(attacker, defender, curSkill, tick, tagRoundPosX, tagRoundPosY):
def UseSkill(attacker, defender, curSkill, tagRoundPosX, tagRoundPosY, isEnhanceSkill, tick):
    if not defender:
        return
    
    if not GameWorld.CanHappen(curSkill.GetHappenRate(), ChConfig.Def_MaxRateValue):
        #Çå³ýʧ°ÜÒ²´¥·¢CD
        return BaseAttack.DoSkillEx_AttackSucess(attacker, defender, curSkill, tick, isEnhanceSkill)
    
    skillType = curSkill.GetEffect(0).GetEffectValue(0)
    if skillType == 0:
        # ÎÞÅäÖôú±íÇå³ý¸ºÃæbuffÈÎÒâ1¸ö
        skillTypeList = [
                           ChConfig.Def_SkillType_LstDepBuff   ,  #³ÖÐø¼õÒæBUFF  4
                           ChConfig.Def_SkillType_DepBuff      ,  #¼õÒæBUFF 6
                           ChConfig.Def_SkillType_Action       ,  #Ó°ÏìÐÐΪBUFF 14
                         ]
    else:
        skillTypeList = [skillType]
    
    delSuccess = False
    
    for skillType in skillTypeList:
        
        buffType = ChConfig.Def_SkillBuffList.get(skillType)
        buffTuple = SkillCommon.GetBuffManagerByBuffType(defender, buffType)
        if buffTuple == ():
            continue
        
        buffManager = buffTuple[0]
        if buffManager.GetBuffCount() == 0:
            continue
        
        curBuff = buffManager.GetBuff(0)
        ownerID, ownerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()
        
        #ɾ³ýBuff
        BuffSkill.DoBuffDisApperEx(defender, curBuff, tick)
        buffSkill = curBuff.GetSkill()
        if not buffSkill:
            continue
        skillID = buffSkill.GetSkillID()
        buffManager.DeleteBuffByTypeID(buffSkill.GetSkillTypeID())
        SkillShell.ClearBuffEffectBySkillID(defender, skillID, ownerID, ownerType)
        delSuccess = True
        break
    
    if not delSuccess:
        # Ã»ÓпÉÇå³ýBUFFÒ²½øÈëCD
        return BaseAttack.DoSkillEx_AttackSucess(attacker, defender, curSkill, tick, isEnhanceSkill)
    
    #Ë¢ÐÂÊôÐÔ
    curObjType = defender.GetGameObjType()
    #Íæ¼Ò
    if curObjType == IPY_GameWorld.gotPlayer:
        #Ë¢ÐÂÍæ¼ÒÊôÐÔ
        playerControl = PlayerControl.PlayerControl(defender)
        
        if buffType == IPY_GameWorld.bfActionBuff:
            playerControl.RefreshPlayerActionState()
            if BuffSkill.CheckBuffRefresh(buffSkill, False):
                playerControl.RefreshPlayerAttrByBuff()
        else:
            playerControl.RefreshPlayerAttrByBuff()
    #NPC
    elif curObjType == IPY_GameWorld.gotNPC:
        npcControl = NPCCommon.NPCControl(defender)
        
        if buffType == IPY_GameWorld.bfActionBuff:
            npcControl.RefreshNPCActionState()
            if BuffSkill.CheckBuffRefresh(buffSkill, False):
                npcControl.RefreshNPCAttrState()
        else:
            npcControl.RefreshNPCAttrState()
        
    return BaseAttack.DoSkillEx_AttackSucess(attacker, defender, curSkill, tick, isEnhanceSkill)