#!/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
|
|
|