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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package OperControlManager
# ¼òҪ˵Ã÷
# @todo: ¿ØÖÆÐÐΪ¹ÜÀí
# @author: Alee
# @date: 2010-11-22 12:15
# @version 1.3
# ÏêϸÃèÊö
# Î»²Ù×÷˵Ã÷: I¡¢ ÔÚ¼¼ÄܱíÖРÏÞÖÆ×ֶΠ1 ´ú±í×èÖ¹£¬0 ´ú±í²»Ó°Ïì
#           II¡¢¼¼ÄܱíÖеĠËùÊôϵ×ֶΠ1 ´ú±í¸Ã¼¼ÄÜËùÊôϵ£¬0·´Ö®
#           III¡¢×´Ì¬¶¨ÒåÖР1 ´ú±íÒªÖ´ÐУ¨¸ÃλËù´ú±íµÄ£©ÐÐΪ£¬0 ´ú±í²»Ö´ÐÐ
#
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
#
# @change: "2010-12-07 12:00" Alee Ìí¼Óº¯ÊýÓɶ¯×÷»ñµÃ¶¯×÷λ
# @change: "2011-01-26 15:30" Alee Á¢¼´×èÖ¹½øÐÐÖе͝×÷
# @change: "2011-06-20 17:40" Alee ÏÞÖÆÆï³ËÌí¼ÓÏÂÂíÂß¼­
# @change: "2011-12-28 17:00" jiang ÏÞÖÆÌí¼Ó´ò¶Ï´«Ëͽø¶ÈÌõ
#---------------------------------------------------------------------
"""Version = 2011-06-20 17:40"""
#µ¼Èë
import ChConfig
import GameWorld
import IPY_GameWorld
import PlayerHorse
import ShareDefine
import SkillCommon
import PassiveBuffEffMng
 
#GameObj×Öµä-----------------------------------------------------------
 
#===============================================================================
# //¶ÔÏóÐÐΪÏÞÖÆ
# enum    EOjbActionLimit
# {
#    oalMove =     0x0001,    Òƶ¯
#    oalRide =     0x0002,    ÆïÂí
#    oalCollect =  0x0004,    ²É¼¯
#    oalSit =      0x0008,    ´ò×ø
#    oalCatch =    0x0010,    ²¶×½
#    oalFish =     0x0020,    µöÓã
#    oalDance =    0x0040,    ÌøÎè
#    oalLook =     0x0080,    ±íÇé
#    oalUseItem =  0x0100,    Ê¹ÓÃÎïÆ·
#    oalTransmit = 0x0200,    ´«ËÍ
# };
# ¶¨ÒåÓÃÓÚ Def_Obj_ActState_ClientAct£¬ Def_Obj_ActState_ServerAct
#===============================================================================
 
 
#===============================================================================
# #ÓÃÓÚ¿ØÖÆÎïÌåµÄÐÐΪ¶¯×÷£¬ËäÈ»¼Ì³ÐÓÚGameObj, ´úÂëÖв»ÒªÓÃÓÚ ËÀÎÎïÆ·£©
# #¶ÔÏó£¨Íæ¼Ò£¬NPC£©µÄÐÐΪ×Öµä
# Def_Obj_ActState_ClientAct = "ClientActState"            # ¿Í»§¶Ë¶¯×÷ÏÞÖÆ
# Def_Obj_ActState_ServerAct = "ServerActState"            # ·þÎñ¶Ë¶¯×÷ÏÞÖÆ
# Def_Obj_ActState_ClientSkill = "ClientSkillActState"     # ¿Í»§¶Ë¼¼ÄÜÏÞÖÆ
# Def_Obj_ActState_ServerSkill = "ServerSkillActState"     # ·þÎñ¶Ë¼¼ÄÜÏÞÖÆ
#===============================================================================
 
KeyTypeList = [
               ChConfig.Def_Obj_ActState_ClientAct, ChConfig.Def_Obj_ActState_ServerAct,
               ChConfig.Def_Obj_ActState_ClientSkill, ChConfig.Def_Obj_ActState_ServerSkill
               ]
 
#===============================================================================
 
## ÅжÏÊÇ·ñ¿ÉÖ´ÐвÙ×÷µ¥Ö¸Áî £¨Óë½á¹û È¡·´£©
# @param curActionState Ëù³ÖÓÐ״̬
# @param curOperState ÇëÇó״̬
# @return boolÖµ
# @remarks ÅжÏÊÇ·ñ¿ÉÖ´ÐвÙ×÷µ¥Ö¸Áî £¨Óë½á¹û È¡·´£©
def IsCanDoAction(curActionState, curOperState):
    if curActionState & curOperState == 0:
        #GameWorld.Log("ͨ¹ý")
        return True
    else:
        #GameWorld.Log("²»Í¨¹ý")
        return False
 
 
## ¸üÐÂÐÐΪ״̬£¬·µ»ØÓ°ÏìºóµÄ״̬ (»ò)
# @param curActionState Ëù³ÖÓÐ״̬
# @param curOperState ÇëÇó״̬
# @return ÇëÇóºóµÄ״̬
# @remarks ¸üÐÂÐÐΪ״̬£¬·µ»ØÓ°ÏìºóµÄ״̬ (»ò)
def UpdateActionState(curActionState, curOperState):
    return curActionState | curOperState
 
 
#===============================================================================
## Åж϶ÔÏóÊÇ·ñ¿ÉÖ´ÐвÙ×÷
# @param curObj ¶ÔÏóʵÀý
# @param keyType ÇëÇóÓò×ÖµäÀàÐÍ
# @param curOperState ÇëÇó״̬
# @return boolÖµ
# @remarks Åж϶ÔÏóÊÇ·ñ¿ÉÖ´ÐвÙ×÷
def IsObjCanDoAction(curObj, keyType, curOperState, curSkill=None):
    if SkillCommon.GetUsingPassiveSkill(curObj):
        # ±»¶¯¼¼Äܲ»ÏÞÖÆ
        return True
    
    if curSkill and PassiveBuffEffMng.GetPassiveSkillValueByTriggerType(curObj, None, curSkill, ChConfig.TriggerType_NoControl):
        return True
    curActionState = GetObjActStateByType(curObj, keyType)
    #GameWorld.Log("Íæ¼Ò µ±Ç°×´Ì¬%s,ÅжÏÐÐΪ %s, ÔÚ %s¶ËµÄÑéÖ¤ÊÇ·ñͨ¹ý"%\
    #(curActionState, curOperState, keyType), curObj.GetID())
    return IsCanDoAction(curActionState, curOperState)
 
 
##ͨ¹ýÀàÐÍ»ñÈ¡¶ÔÏóÐÐΪ״̬
# @param curObj ¶ÔÏóʵÀý
# @param keyType ÇëÇóÓò×ÖµäÀàÐÍ
# @return ¶ÔÏóµ±Ç°×´Ì¬Óò
# @remarks Í¨¹ýÀàÐÍ»ñÈ¡¶ÔÏóÐÐΪ״̬
def GetObjActStateByType(curObj, keyType):
    return curObj.GetDictByKey(keyType)
 
##ÉèÖöÔÏóµÄÐÐΪ״̬
# @param curObj ¶ÔÏóʵÀý
# @param curSkill Ó°Ïì¶ÔÏó״̬µÄ¼¼ÄÜ
# @return ÎÞ·µ»ØÖµ
# @remarks ÉèÖöÔÏóµÄÐÐΪ״̬
def SetObjActState(curObj, curSkill):
    operStateList = [
                     curSkill.GetClientActionLimit(),
                     curSkill.GetServerActionLimit(),
                     curSkill.GetClientSkillSeriesLimit(),
                     curSkill.GetServerSkillSeriesLimit()
                     ]    
    
    for index in range(len(KeyTypeList)):
        SetObjActStateByType(curObj, 
                             GetObjActStateByType(curObj, KeyTypeList[index]),
                             operStateList[index],
                             KeyTypeList[index]
                             )
    
    #Á¢¼´ÖÕÖ¹½øÐÐÖеÄÐÐΪºÍÓÃÓڽű¾ÎÞʱ»ú¸Ä±ä
    StopObjProcessingAction(curObj)
 
##Á¢¼´ÖÕÖ¹½øÐÐÖеÄÐÐΪºÍÓÃÓڽű¾ÎÞʱ»ú¸Ä±ä
# @param curObj ¶ÔÏóʵÀý
# @return ÎÞ·µ»ØÖµ
# @remarks Á¢¼´ÖÕÖ¹½øÐÐÖеÄÐÐΪºÍÓÃÓڽű¾ÎÞʱ»ú¸Ä±ä
def StopObjProcessingAction(curObj):
    #·þÎñ¶Ë¶¯×÷״̬
    curServerActionState = GetObjActStateByType(curObj, ChConfig.Def_Obj_ActState_ServerAct)
    
    #Í£Ö¹ÒÆ¶¯
    if not IsCanDoAction(curServerActionState, IPY_GameWorld.oalMove):
        curObj.StopMove()
    
    #Íæ¼ÒרÓд¦Àí
    PlayerLimitAct(curObj, curServerActionState)
        
    return
 
 
##Íæ¼ÒÏÞÖÆ²Ù×÷רÓÐ
# @param curObj ¶ÔÏóʵÀý
# @param curServerActionState ¶¯×÷λ
# @return ÎÞÒâÒå
def PlayerLimitAct(curObj, curServerActionState):
    if curObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return
 
    #ÏÂÂí
    if not IsCanDoAction(curServerActionState, IPY_GameWorld.oalRide):
        PlayerHorse.PlayerRideHorseDown(curObj, True)
    
    if not IsCanDoAction(curServerActionState, IPY_GameWorld.oalTransmit):
        #ÊÇ·ñÔÚ´«Ë͵Ľø¶ÈÌõÖÐ
        if curObj.GetPrepareState() == ShareDefine.Def_PstTrans:
            curObj.SetPlayerAction(IPY_GameWorld.paNull)
                         
 
##ÉèÖöÔÏóµÄÖ¸¶¨ÀàÐ͵ÄÐÐΪ״̬
# @param curObj ¶ÔÏóʵÀý
# @param curActionState Ëù³ÖÓÐ״̬
# @param curOperState ÇëÇó״̬
# @param keyType ÇëÇóÓò×ÖµäÀàÐÍ
# @return ÎÞ·µ»ØÖµ
# @remarks ÉèÖöÔÏóµÄÖ¸¶¨ÀàÐ͵ÄÐÐΪ״̬
def SetObjActStateByType(curObj, curActionState, curOperState, keyType):
    #GameWorld.Log("¸Ä±äǰ״̬£¨%s = %s£©£¬½«Ö´ÐеÄÐÐΪ %s"%(keyType, curActionState, curOperState), curObj.GetID())
    curActionState = UpdateActionState(curActionState, curOperState)
    curObj.SetDict(keyType, curActionState)
    
    #GameWorld.Log("¸Ä±äºó״̬£¨%s = %s£©"%(keyType, GetObjActStateByType(curObj, keyType)), curObj.GetID())
    
    
##Çå³ý¶ÔÏóµÄÐÐΪ״̬
# @param curObj ¶ÔÏóʵÀý
# @return ÎÞ·µ»ØÖµ
# @remarks Çå³ý¶ÔÏóµÄÐÐΪ״̬
def ClearObjActionState(curObj):
    for keyType in KeyTypeList:
        curObj.SetDict(keyType, 0)
    
##ͨ¹ýÐÐΪ»ñµÃÐÐΪ±êʶλ
# @param actModule ¶¯×÷Ä£¿é
# @param actType ¶¯×÷ÀàÐÍ
# @return None»òö¾ÙÖµ
# @remarks Í¨¹ýÐÐΪ»ñµÃÐÐΪ±êʶλ
def GetActBitByAction(actModule, actType):
    curActModuleDict = ChConfig.Def_ActBit_Action.get(actModule)
    
    if curActModuleDict == None:
        return None
    
    curActBit = curActModuleDict.get(actType)
    
    return curActBit