hch
2021-05-04 1a0ad714b01722f0a1c9bc4777b8e0d11ed15e01
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/python
# -*- coding: GBK -*-
#
##@package E:/GameSVN/U3DGame/ProjectSServer/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameObj.py
# @todo: 
#
# @author: Alee
# @date 2017-10-24 ÏÂÎç07:49:45
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
 
import ShareDefine
import ChConfig
import IPY_GameWorld
import IpyGameDataPY
import SkillCommon
import PlayerControl
 
# ¹ØÓÚѪÁ¿µÄº¯ÊýÕâÀïÖ»°ü×°×î¼òµ¥µÄ³¬DWORD´¦Àí
 
def GetMaxHP(gameObj):
    return gameObj.GetMaxHPEx() * ShareDefine.Def_PerPointValue + gameObj.GetMaxHP()
 
def SetMaxHP(gameObj, value):
    gameObj.SetMaxHP(value % ShareDefine.Def_PerPointValue, value / ShareDefine.Def_PerPointValue)
    return
 
def GetHP(gameObj):
    return gameObj.GetHPEx() * ShareDefine.Def_PerPointValue + gameObj.GetHP()
 
def SetHP(gameObj, value, isNotify=None, isByTime=False):
    if gameObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
        if isNotify == None:
            isNotify = True
        gameObj.SetHP(value % ShareDefine.Def_PerPointValue, value / ShareDefine.Def_PerPointValue, isNotify)
    else:
        if isNotify == None:
            isNotify = False
        if gameObj.GetGameObjType() == IPY_GameWorld.gotNPC:
            npcID = gameObj.GetNPCID()
            if IpyGameDataPY.GetIpyGameDataNotLog("NPCTimeLostHP", npcID) and not isByTime and value not in [GetMaxHP(gameObj), 0]:
                #GameWorld.DebugLog("²»ÄÜÉèÖð´Ê±¼äµôѪµÄ¹ÖÎïѪÁ¿! id=%s,npciD=%s,value=%s,isByTime=%s" % (gameObj.GetID(), gameObj.GetNPCID(), value, isByTime))
                return
        gameObj.SetHP(value % ShareDefine.Def_PerPointValue, value / ShareDefine.Def_PerPointValue, isNotify)
    return
 
def SetHPFull(gameObj):
    SetHP(gameObj, GetMaxHP(gameObj))
    return
 
def SetBaseMaxHP(gameObj, value):
    gameObj.SetBaseMaxHP(value % ShareDefine.Def_PerPointValue, value / ShareDefine.Def_PerPointValue)
    return
    
def GetAngryValue(curAngry):
    return curAngry.GetAngryValue() + curAngry.GetAngryValueEx() * ShareDefine.Def_PerPointValue
def SetAngryValue(curAngry, value):
    curAngry.SetAngryValue(value % ShareDefine.Def_PerPointValue, value / ShareDefine.Def_PerPointValue)
    return
 
## ÉèÖÃbuff״̬(½Å±¾×Ô¶¨Òåö¾Ù)
#  @param pyState ×´Ì¬
#  @param isTrue ÊÇ·ñÉèÖøÃ״̬
#  @return None
def SetPyPlayerState(gameObj, pyState, isAdd):
    if pyState == 0:
        return
    if pyState not in ChConfig.Def_PlayerStateList:
        return
    
    curState = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_CurState)
    if isAdd:
        # Ôö¼Ó
        updState = curState | pow(2, pyState)
    else:
        # É¾³ý
        if curState & pow(2, pyState) == 0:
            return
        else:
            updState = curState ^ pow(2, pyState)
 
    
    #GameWorld.DebugLog("SetPyPlayerState (%s - %s), curState=%s,updState=%s" 
    #                   % (pyState, isAdd, curState, updState))
    gameObj.SetDict(ChConfig.Def_PlayerKey_CurState, updState)
    return
 
## »ñÈ¡buff״̬(½Å±¾×Ô¶¨Òåö¾Ù)
#  @param pyState ×´Ì¬
#  @return ÊÇ·ñ¸Ã״̬
#  @remarks ¸Ã״̬Ϊbuff¶ÔÓ¦µÄ×Ô¶¨Òå״̬Ч¹û
 
#===============================================================================
# ´ËÎÊÌâÔÚ4012 Ïûʧʱ´¦Àí
# #  Ä¿Ç°µ±Ä¿±êÉíÉ϶à¸öbuff¶¼ÓÐͬһЧ¹ûʱ(È綨Éí)£¬ÔÚÒ»¸öbuffÏûʧʱ»á½â³ý¸Ã״̬
# #  ¹Ê¸Ã״̬±ê¼Ç½öΪһ¸ö·Ç¾«È·µÄ±ê¼Ç£¬Ó¦ÓÃÖÐÇë×¢Ò⣡£¡£¡(µ±ÇÒ½öµ±¶à¸öbuffÓÐͬһ¸öЧ¹ûʱ»áÌáǰ½áÊø¸Ã״̬)
#===============================================================================
def GetPyPlayerState(gameObj, pyState, ownerID=0, ownerType=0):
    if not gameObj:
        return False
    if pyState == 0:
        # 0²»ÐèÒªÅжÏ
        return True
    curState = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_CurState)
    
    state = curState & pow(2, pyState) 
    
    if state and ownerID:
        # ½øÒ»²½ÅжÏÊÇ·ñÊÍ·ÅÕß
        return True if IsInStateEffectByOwner(gameObj, ChConfig.Def_Skill_Effect_BuffState, pyState, ownerID, ownerType) else False
    return state
 
# ´óÓÚµÈÓÚ2¸ö״̬ Ôò²»ÇåÀí״̬
def IsInStateEffectByOwner(curObj, effectID, stateType, ownerID, ownerType):
    
    for buffType in xrange(IPY_GameWorld.bfBuff, IPY_GameWorld.btBufMax):
        if buffType in ChConfig.Def_BuffType_OnlyPlayer:
            continue
        
        buffTuple = SkillCommon.GetBuffManagerByBuffType(curObj, buffType)
        #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö
        if buffTuple == ():
            continue
    
        buffManager = buffTuple[0]
        
        for i in range(buffManager.GetEffectCount()):
            effect = buffManager.GetEffect(i)
            if not effect:
                continue
            
            if effect.GetEffectID() != effectID:
                continue
            
            if effect.GetEffectValue(0) != stateType:
                continue
            
            if buffManager.GetEffectOwnerID(i) != ownerID:
                continue
            
            if buffManager.GetEffectOwnerType(i) != ownerType:
                continue
            
            return True
    return False
 
 
def ClearPyPlayerState(gameObj):
    gameObj.SetDict(ChConfig.Def_PlayerKey_CurState, 0)
    return
 
def GetPetDamPer(gameObj): return gameObj.GetDictByKey(ChConfig.Def_PlayerKey_AttrPetDamPer)
def SetPetDamPer(gameObj, value): 
    gameObj.SetDict(ChConfig.Def_PlayerKey_AttrPetDamPer, value)
    if gameObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
        PlayerControl.SendPropertyRefresh(gameObj, ShareDefine.CDBPlayerRefresh_PetDamPer, value)
    return
 
def GetLastHurtValue(gameObj):
    ## ×îºóÒ»»÷É˺¦Öµ
    hurt = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_LastHurtValue)
    hurtEx = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_LastHurtValueEx)
    return hurtEx * ShareDefine.Def_PerPointValue + hurt
def SetLastHurtValue(gameObj, value):
    gameObj.SetDict(ChConfig.Def_PlayerKey_LastHurtValue, value % ShareDefine.Def_PerPointValue)
    gameObj.SetDict(ChConfig.Def_PlayerKey_LastHurtValueEx, value / ShareDefine.Def_PerPointValue)
    return
 
def GetBloodShiledHurt(gameObj):
    ## É˺¦ÖµÓÃÓÚѪ¶ÜµÖÏû
    hurt = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_BloodShiledHurt)
    hurtEx = gameObj.GetDictByKey(ChConfig.Def_PlayerKey_BloodShiledHurtEx)
    return hurtEx * ShareDefine.Def_PerPointValue + hurt
def SetBloodShiledHurt(gameObj, value):
    gameObj.SetDict(ChConfig.Def_PlayerKey_BloodShiledHurt, value % ShareDefine.Def_PerPointValue)
    gameObj.SetDict(ChConfig.Def_PlayerKey_BloodShiledHurtEx, value / ShareDefine.Def_PerPointValue)
    return