| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package ChItem  | 
| # @todo: ÎïÆ·Âß¼´¦Àí  | 
| #  | 
| # @author panwei  | 
| # @date 2010-4-21  | 
| # @version 2.9  | 
| #  | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
| # @change: "2015-07-03 16:00" zqx È¥³ýGMÏÞÖÆ  | 
| # @change: "2015-07-14 21:00" xdh ÁÄÌìÐÅÏ¢Ô¸½¼ÓÖµ¸ÄΪExtras  | 
| # @change: "2015-09-18 19:30" hxp ÕóÓªÎïÆ·Ê°È¡±£»¤ÅÐ¶Ï  | 
| # @change: "2015-09-21 20:30" hxp ¹¦Ñ«ÎïÆ·Ê¹ÓÃ; ¼ñ¹¦Ñ«ÎïÆ·ÌØÊâÂß¼  | 
| # @change: "2015-11-06 16:30" hxp Ôö¼ÓpyÀ®°È£¬Ö§³Ö¿ç·þ  | 
| # @change: "2015-12-15 17:00" hxp ÊÇ·ñ×°±¸ÅжϷ½Ê½ÐÞ¸Ä  | 
| # @change: "2016-01-26 15:00" hxp PY±íÖ§³ÖÖØ¶Á  | 
| # @change: "2016-05-20 11:00" hxp µ¥È˸±±¾Ò»¼üʰȡ½ö¿Éʰȡ½ðÇ®  | 
| # @change: "2016-06-04 10:00" xdh ÐÞ¸´Ã¿ÈÕʹÓÃÎïÆ·¸öÊýÎïÆ·idÈ¡²»µ½ÎÊÌâ  | 
| # @change: "2016-07-20 14:30" hxp Ïû·ÑµãÁ÷ÏòÕûÀí  | 
| # @change: "2016-10-17 16:00" hxp Ôö¼ÓÓÀ¾Ã¹ó×弤»î¿¨  | 
| # @change: "2016-11-22 21:00" hxp µôÂäÎïÆ·ÌØÊâ¹éÊôIDÖ§³Ö  | 
| # @change: "2017-02-16 18:00" hxp Ö§³ÖÐéÄ⸱±¾Ê°È¡µôÂäÎïÆ·  | 
| # @change: "2017-03-10 16:00" hxp Ôö¼Ó³á°òÖ±½ÓÉý½×µÀ¾ßÎïÆ·Ê¹Óà  | 
| # @change: "2017-03-22 21:00" hxp ¶þάÂëºì°ü  | 
| # @change: "2017-03-24 20:00" hxp Ôö¼ÓÿÈÕʹÓôÎÊýÏÞÖÆÎïÆ·´ÎÊý֪ͨ¿Í»§¶Ë£»Ôö¼ÓÅжÏÎïÆ·Ê¹Óõȼ¶  | 
| # @change: "2017-05-09 15:30" hxp Ôö¼Ó¿ª³ö¶à¸öÎïÆ·µÄÏä×Ó£¬ Ö§³Ö¹ýÂËûÓнâËøµÄ·ûÓ¡; Ôö¼Ó¿ªÏä×Ó»ñµÃÎïÆ·Í¨Öª  | 
| #------------------------------------------------------------------------------  | 
| #"""Version = 2017-05-09 15:30"""  | 
| #------------------------------------------------------------------------------  | 
| import IPY_GameWorld  | 
| import GameWorld  | 
| import ItemControler  | 
| import UseItem  | 
| import ItemCommon  | 
| import ChConfig  | 
| import EventShell  | 
| import PlayerControl  | 
| import FBLogic  | 
| import ReadChConfig  | 
| import OperControlManager  | 
| import ShareDefine  | 
| import PlayerAttrFruit  | 
| import DataRecordPack  | 
| import PyMapTable  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import IpyGameDataPY  | 
| import PlayerSuccess  | 
| import PyGameData  | 
| import NPCCommon  | 
| import FBCommon  | 
|   | 
| import json  | 
| #---------------------------------------------------------------------  | 
| #µ¼Èë  | 
| GameWorld.ImportAll("Script\\Item\\" , "UseItem")  | 
| GameWorld.ImportAll("Script\\Item\\" , "")  | 
| #---------------------------------------------------------------------  | 
| ## ÖØÐ¶ÁÈ¡ËùÓÐÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä   | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ReloadItem(tick):  | 
|     scriptPath = ChConfig.GetAppPath() + "Script\\Item\\UseItem"  | 
|     GameWorld.ReloadScript(scriptPath, "UseItem")  | 
|       | 
|     scriptPath = ChConfig.GetAppPath() + "Script\\Item"  | 
|     GameWorld.ReloadScript(scriptPath, "")  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # ÎïÆ·ÀàÐÍ------  | 
| # 1£ºÒ©Æ·        2£º²ÄÁÏ        3£ºÔÓÎï        4£º¸ß¼¶ÔÓÎï        5£ºÈÎÎñÎïÆ·  | 
| # 6£ºÈÎÎñ¾íÖá     7£º³èÎïµ°      8£º±¦Ê¯        9£ºÆäËü           10:¼¼ÄÜÊé    | 
| # 11:Í·²¿×°±¸    12£ºÒ·þ       13£ºÐ¬×Ó       14£º»¤Íó          15£º½£×ÚÎäÆ÷  | 
| # 16£º½äÖ¸       17£ºÏîÁ´       18£º·¢ÐÍ       19£ºÁ³ÐÍ          20£ºÆäËûÎäÆ÷  | 
| # 25£ºÆø×ÚÎäÆ÷    35£ºÄ§×ÚÎäÆ÷   36£º×øÆï       37£ºÂíÆ¥ËÇÁÏ      41£ºµöÓã½±ÀøÎïÆ·  | 
| # 45£ºË«±¶¾ÑéÎïÆ· 46£º³èÎïµÀ¾ß  50£º¿É¼Ó¹¤²ÄÁÏ  51£º¿ª¹â²ÄÁÏ  | 
| #===============================================================================  | 
|   | 
| ## ³õʼ»¯ÎïÆ·ÖØÕûÓÅÏȼ¶   | 
| #  @param curPack Ç°±³°ü  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #===============================================================================  | 
| # def __InitPackResetPrior(curPack):  | 
| #    curPack.ClearAddResetPrior()  | 
| #    for value in ReadChConfig.GetEvalChConfig("ItemResetPrior"):  | 
| #        curPack.Init_AddResetPrior(value)  | 
| #===============================================================================  | 
| #---------------------------------------------------------------------  | 
| ## ³õʼ»¯ÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def InitItem(tick):  | 
|     GameWorld.GetPsycoFunc(__Func_InitItem)(tick)  | 
|     return  | 
|   | 
| ## ³õʼ»¯ÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #===============================================================================  | 
| def __Func_InitItem(tick):  | 
|     #³õʼ»¯ÎïÆ·µôÂä±£»¤  | 
|     MapItemProtectTime = IpyGameDataPY.GetFuncCfg("MapItemProtectTime")  | 
|     GameWorld.GetMapItemManager().SetProtectTime(MapItemProtectTime)  | 
|       | 
|     #===============================================================================================  | 
|     #   | 
|     # for i in range(0, GameWorld.GetPlayerManager().GetPlayerCount()):  | 
|     #    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(i)  | 
|     #    itemManager = curPlayer.GetItemManager()  | 
|     #      | 
|     #    #³õʼ»¯±³°ü  | 
|     #    curPack = itemManager.GetPack(IPY_GameWorld.rptItem)  | 
|     #    __InitPackResetPrior(curPack)  | 
|     #      | 
|     #===============================================================================================  | 
|     return  | 
| #===============================================================================  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ³õʼ»¯±³°ü  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #===============================================================================  | 
| # def InitPlayerLoginItem(curPlayer, tick):  | 
| #    itemManager = curPlayer.GetItemManager()  | 
| #    #³õʼ»¯±³°ü  | 
| #    curPack = itemManager.GetPack(IPY_GameWorld.rptItem)  | 
| #    __InitPackResetPrior(curPack)  | 
| #===============================================================================  | 
| #---------------------------------------------------------------------  | 
|   | 
| ## Ö´ÐÐʰȡÂß¼  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param mapItemID µØÍ¼ÎïÆ·ID  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DoPickup(curPlayer, mapItemID, tick, isGuard):  | 
|       | 
|     #ïÚ³µÖÐ,ÎÞ·¨Ê°È¡  | 
|     if not isGuard and curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvTruck:  | 
|         PlayerControl.NotifyCode(curPlayer, "Old_hgg_21675")  | 
|         #GameWorld.Log("ʹÓý»Í¨¹¤¾ßʱ,ÎÞ·¨Ê°È¡ÎïÆ·")  | 
|         return  | 
|       | 
|     if curPlayer.GetHP() == 0:  | 
|         #Íæ¼ÒÒѾËÀÍö  | 
|         #GameWorld.Log("µ±Ç°Íæ¼ÒÒѾËÀÍö")  | 
|         return  | 
|       | 
|     mapItemManager = GameWorld.GetMapItemManager()  | 
|     mapItem = mapItemManager.GetItemByID(mapItemID)  | 
|   | 
|     if mapItem == None or mapItem.IsEmpty():  | 
|         GameWorld.Log("µ±Ç°ÎïÆ·ÒѾ±»»ØÊÕ,Íæ¼Òʰȡʧ°Ü,mapItemID=%s" % mapItemID, curPlayer.GetPlayerID())  | 
|         return  | 
|   | 
|     pickDist = GameWorld.GetDist(curPlayer.GetPosX(), curPlayer.GetPosY(),   | 
|                                     mapItem.GetPosX(), mapItem.GetPosY())  | 
|       | 
|     # ÊØ»¤Ê°È¡²»Ñé֤ʰȡ·¶Î§  | 
|     if not isGuard and pickDist > curPlayer.GetPickupDist():  | 
|         #¾àÀë¹ýÔ¶, ²»ÄܼñÆð  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_805889")  | 
| #        GameWorld.Log("µ±Ç°¾àÀë¹ýÔ¶, Íæ¼Ò(%d,%d)-ÎïÆ·(%d,%d)"%(curPlayer.GetPosX(), curPlayer.GetPosY(),  | 
| #                                                                                 mapItem.GetPosX(), mapItem.GetPosY()))  | 
|         return  | 
|       | 
|     #ʰȡÅÐ¶Ï  | 
|     if not __CheckPickUpItemTime(curPlayer , mapItem , tick):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_913598")  | 
|         return  | 
|       | 
|     #°ÑµØÍ¼ÎïÆ··Åµ½±³°üÖÐ  | 
|     itemControl = ItemControler.PlayerItemControler(curPlayer)  | 
|     #ÌáʾÐÅÏ¢  | 
|     ownerType = mapItem.GetOwnerType()  | 
|     ownerID = mapItem.GetOwnerID()  | 
|     singItem = mapItem.GetItem()      | 
|       | 
|     mapItemType = singItem.GetType()  # ÎïÆ·ÀàÐÍ          | 
|     mapItemTypeID = singItem.GetItemTypeID()  | 
|     mapItemCount = singItem.GetCount()  | 
|     singItemGUID = singItem.GetGUID()  | 
|     curEffID = singItem.GetEffectByIndex(0).GetEffectID()  | 
|     playerTeam = curPlayer.GetTeam()  | 
|     #isTeamNotify = (ownerType == ChConfig.Def_NPCHurtTypeTeam and playerTeam != None)  | 
|     isTeamNotify = False  | 
|     # Ê°È¡½ðÇ®  | 
|     if mapItemType == ChConfig.Def_ItemType_Money:  | 
|         if not PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, mapItemCount,   | 
|                                        ChConfig.Def_GiveMoney_Pickup, {}, not isTeamNotify):  | 
|             return  | 
|           | 
|         # Ìáʾ»ñµÃ½ðÇ®ÊýÁ¿  | 
|         if isTeamNotify:  | 
|             PlayerControl.TeamNotify(playerTeam.GetTeamID(), "GeRen_lhs_295695", [curPlayer.GetName(),  | 
|                                                                                    mapItemCount])  | 
|         # ¸±±¾Ê°È¡½ðÇ®  | 
|         FBLogic.OnFBPickUpItem(curPlayer, singItem, tick)  | 
|         singItem.Clear()  | 
|     #===============================================================================================  | 
|     # # (¿ç·þµôÂ书ѫÎïÆ·, ²»¸øÊµ¼ÊÎïÆ·£¬×ª»¯Îª¹¦Ñ«Öµ)  | 
|     # elif curEffID == ChConfig.Def_Effect_ItemGiveGongXun and GameWorld.IsMergeServer():  | 
|     #    #=======================================================================  | 
|     #    # # ²»ÐèÒª¶ÓÎéÌáʾ  | 
|     #    # if not isTeamNotify:  | 
|     #    #    PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [mapItemTypeID, mapItemCount])  | 
|     #    # # ¶ÓÎéÖУ¬ÎïÆ·±»Ê°È¡Ìáʾ  | 
|     #    # else:  | 
|     #    #    PickupItemSysNotify(curPlayer, isTeamNotify, [mapItemTypeID], False)  | 
|     #    #=======================================================================  | 
|     #          | 
|     #    # ¸±±¾Ê°È¡½ðÇ®  | 
|     #    FBLogic.OnFBPickUpItem(curPlayer, singItem, tick)  | 
|     #    singItem.Clear()  | 
|     #===============================================================================================  | 
|     # Ê°È¡ÎïÆ·  | 
|     else:  | 
|         #=======================================================================  | 
|         # isEquip = ItemCommon.CheckItemIsEquip(singItem)    | 
|         # itemMsgList = [mapItemTypeID]  | 
|         #   | 
|         # if isTeamNotify and isEquip:    | 
|         #    # ¶ÓÎéʰȡװ±¸Ê±£¬Ïȱ£´æÎïÆ·µÄxmlÊôÐÔ£¬ÓÃÓÚÌáʾµÄxmlÏÔʾ  | 
|         #    itemMsgList = ItemCommon.GetItemXMLMsg(singItem)  | 
|         #=======================================================================  | 
|               | 
|         curItemCount = singItem.GetCount()  | 
|         curItemID = singItem.GetItemTypeID()  | 
|         curItemIsBind = singItem.GetIsBind()  | 
|           | 
|         isPutInTemp = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_PickupItemPutInTemp)  | 
|         packIndex = ShareDefine.rptTempItem if isPutInTemp else IPY_GameWorld.rptItem  | 
|           | 
|         # ÊÇ·ñ¿É·ÅÈë  | 
|         if not itemControl.CanPutInItem(packIndex, curItemID, curItemCount, curItemIsBind):  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packIndex])  | 
|             return  | 
|       | 
|         # ¸±±¾Ê°È¡ÎïÆ·  | 
|         FBLogic.OnFBPickUpItem(curPlayer, singItem, tick)  | 
|           | 
|         dropItemNPCID = GetMapItemUserDataValue(mapItem, ShareDefine.Def_MapItemInfo_NPCID)  | 
|         equipInfo = [singItem.GetEquipPlace(), ItemCommon.GetItemClassLV(singItem), singItem.GetItemColor(),   | 
|                      singItem.GetItemQuality(), singItem.GetUserData()]  | 
|         if not itemControl.PutInItem(packIndex, singItem, event=[ChConfig.ItemGive_Pickup, False, {"NPCID":dropItemNPCID}]):  | 
|             #ÎïÆ·²»ÄÜ·ÅÈë  | 
|             #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packIndex])  | 
|             return  | 
|   | 
|         if dropItemNPCID:  | 
|             mapID = GameWorld.GetGameWorld().GetMapID()  | 
|             NPCCommon.SendGameServerGoodItemRecord(mapID, dropItemNPCID, curPlayer.GetName(),   | 
|                                                    curPlayer.GetPlayerID(), curItemID, equipInfo)  | 
|               | 
|         # ²»ÐèÒª¶ÓÎéÌáʾ  | 
|         #=======================================================================  | 
|         # if not isTeamNotify:  | 
|         #    PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [mapItemTypeID, mapItemCount])  | 
|         # else:  | 
|         #    # ¶ÓÎéÖУ¬ÎïÆ·±»Ê°È¡Ìáʾ  | 
|         #    PickupItemSysNotify(curPlayer, isTeamNotify, itemMsgList, isEquip)  | 
|         #=======================================================================  | 
|           | 
|         #ÏìӦʼþ  | 
|         EventShell.EventRespons_OnGet(curPlayer, mapItemTypeID)  | 
|         #³É¾Í  | 
|         PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_PickUpItem, curItemCount, [curItemID])  | 
|       | 
|     #ÎïÆ·ÒѾ±»¼ñÆð, °ÑÎïÆ·Ö¸ÕëÖÃΪ¿Õ  | 
|     mapItem.SetDropItem(None)  | 
|     #֪ͨ¿Í»§¶Ë, ÈËÎï¼ñÆð¸ÃÎïÆ·, ÒÔ¼°»ØÊÕÎïÆ·µÄÂß¼  | 
|     curPlayer.PickupItem(mapItem)  | 
|     return True  | 
|   | 
|   | 
| ## ÎïÆ·±»Ê°È¡Ìáʾ  | 
| #  @param curPlayer Íæ¼Ò  | 
| #  @param isTeamNotify ÊÇ·ñ¶ÓÎéÌáʾ  | 
| #  @param itemMsgList ÐÅÏ¢²ÎÊý  | 
| #  @param isEquip ÎïÆ·ÊÇ·ñ×°±¸  | 
| #  @return None  | 
| def PickupItemSysNotify(curPlayer, isTeamNotify, itemMsgList, isEquip):  | 
|       | 
|     curTeam = curPlayer.GetTeam()  | 
|     msgList = [curPlayer.GetName()]  | 
|   | 
|     # ×°±¸´øxmlÊôÐÔ£¬ÆÕͨÎïÆ·Ôò²»ÐèÒª          | 
|     msgList.extend(itemMsgList)  | 
|     sysInfo = "GeRen_lhs_772321" if isEquip else "GeRen_lhs_85890"  | 
|       | 
|     PlayerControl.TeamNotify(curTeam.GetTeamID(), sysInfo, msgList)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #// A3 12 ÊØ»¤Ê°È¡ÎïÆ· #tagCMGuardPickupItem  | 
| #  | 
| #struct    tagCMGuardPickupItem  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        ItemCount;  | 
| #    WORD        MapItemID[ItemCount];    //size = ItemCount  | 
| #};  | 
| def OnGuardPickupItem(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     mapItemIDList = clientData.MapItemID  | 
|     __DoPickupItem(curPlayer, mapItemIDList, tick, True)  | 
|     return  | 
|   | 
| ## Íæ¼ÒʰȡÎïÆ·(·â°ü²ÎÊý)  | 
| #  @param index µ±Ç°Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def PlayerPickUpItem(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #Íæ¼Ò¼ñÆðÎïÆ·  | 
|     pickPack = IPY_GameWorld.IPY_PickUpItem()  | 
|     mapItemID = pickPack.GetMapItemID()  | 
|     __DoPickupItem(curPlayer, [mapItemID], tick, False)  | 
|     return  | 
|   | 
| def __DoPickupItem(curPlayer, mapItemIDList, tick, isGuard):  | 
|     # @param isGuard: ÊÇ·ñÊØ»¤Ê°È¡  | 
|       | 
|     if isGuard and GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:  | 
|         mapID = curPlayer.GetMapID()  | 
|         fbIpyData = FBCommon.GetFBIpyData(mapID)  | 
|         if fbIpyData and not fbIpyData.GetGuardPick():  | 
|             GameWorld.DebugLog("¸ÃµØÍ¼ÊØ»¤ÎÞ·¨Ê°È¡ÎïÆ·! mapID=%s" % mapID, curPlayer.GetPlayerID())  | 
|             return  | 
|           | 
| #    #µ¥È˸±±¾Ò»¼üʰȡ  | 
| #    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtSingle:  | 
| #        SingleFBTPickUP(curPlayer, mapItemID, tick)  | 
| #        return  | 
|       | 
|     succMapItemIDList = [] # ³É¹¦Ê°È¡µÄµØÍ¼ÎïÆ·  | 
|     for mapItemID in mapItemIDList:  | 
|         if __DoPickup(curPlayer, mapItemID, tick, isGuard):  | 
|             succMapItemIDList.append(mapItemID)  | 
|               | 
|     GameWorld.DebugLog("ÇëÇóʰȡÎïÆ·, isGuard=%s, MapItemID=%s, SuccMapItemID=%s"   | 
|                        % (isGuard, mapItemIDList, succMapItemIDList), curPlayer.GetPlayerID())  | 
|       | 
|     # ÊØ»¤Ê°È¡µÄ£¬¸½¼Óͬ²½ÊØ»¤Ê°È¡½á¹û  | 
|     if isGuard and succMapItemIDList:  | 
|         guradPickupSucc = ChPyNetSendPack.tagMCGuradPickupItemSucc()  | 
|         guradPickupSucc.MapItemID = succMapItemIDList  | 
|         guradPickupSucc.ItemCount = len(guradPickupSucc.MapItemID)  | 
|         NetPackCommon.SendFakePack(curPlayer, guradPickupSucc)  | 
|           | 
| # Íæ¼Òʰȡ½á¹ûĿǰ¿Í»§¶ËÔÝʱÎÞÓ㬲»Í¨Öª  | 
| #    if not __DoPickup(curPlayer, mapItemID, tick):  | 
| #        curPlayer.Notify_PickupItemResult(mapItemID, 0)  | 
| #    else:  | 
| #        curPlayer.Notify_PickupItemResult(mapItemID, 1)  | 
|     return  | 
|   | 
|   | 
| ###µ¥È˸±±¾Ò»¼üʰȡ  | 
| ## @param curPlayer mapItemID  | 
| ## @return None  | 
| #def SingleFBTPickUP(curPlayer, mapItemID, tick):  | 
| #    mapItemManager = GameWorld.GetMapItemManager()  | 
| #    curMapItem = mapItemManager.GetItemByID(mapItemID)  | 
| #    if curMapItem == None or curMapItem.IsEmpty():  | 
| #        return  | 
| #  | 
| #    posX = curPlayer.GetPosX()  | 
| #    posY = curPlayer.GetPosY()  | 
| #    itemPosX = curMapItem.GetPosX()  | 
| #    itemPosY = curMapItem.GetPosY()  | 
| #      | 
| #    pickDist = GameWorld.GetDist(posX, posY, itemPosX, itemPosY)  | 
| #  | 
| #    if pickDist > curPlayer.GetPickupDist():  | 
| #        #¾àÀë¹ýÔ¶, ²»ÄܼñÆð  | 
| #        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_805889")  | 
| #        return  | 
| #      | 
| #    mapItemIDList = [curMapItem.GetID()]  | 
| #    #ʰȡµ±Ç°¸ñ×ÓÖÜΧµÄÎïÆ·  | 
| #    mapItemManager = GameWorld.GetMapItemManager()  | 
| #    for index in range(mapItemManager.GetMapItemCount()):  | 
| #        mapItem = mapItemManager.GetMapItemByIndex(index)  | 
| #        if not mapItem or mapItem.IsEmpty():  | 
| #            continue  | 
| #          | 
| #        mapItemObjID = mapItem.GetID()  | 
| #        if mapItemObjID in mapItemIDList:  | 
| #            continue  | 
| #          | 
| #        curItem = mapItem.GetItem()  | 
| #        # Ö»Ò»¼üʰȡ½ðÇ®  | 
| #        if curItem.GetType() != ChConfig.Def_ItemType_Money:  | 
| #            continue  | 
| #              | 
| #        pickDist = GameWorld.GetDist(posX, posY, mapItem.GetPosX(), mapItem.GetPosY())  | 
| #          | 
| #        if pickDist > curPlayer.GetPickupDist():  | 
| #            continue  | 
| #          | 
| #        mapItemIDList.append(mapItemObjID)  | 
| #          | 
| #    for mapItemID in mapItemIDList:  | 
| #        if not __DoPickup(curPlayer, mapItemID, tick):  | 
| #            curPlayer.Notify_PickupItemResult(mapItemID, 0)  | 
| #        else:  | 
| #            curPlayer.Notify_PickupItemResult(mapItemID, 1)  | 
| #          | 
| #    return  | 
| #---------------------------------------------------------------------  | 
| ## Íæ¼ÒʹÓÃÎïÆ· ->×ÔÉíЧ¹û(·â°ü²ÎÊý)  | 
| #  @param index µ±Ç°Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def PlayerUseItemSelf(index, tick):  | 
|     GameWorld.GetPsycoFunc(__Func_PlayerUseItemSelf)(index, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Íæ¼ÒʹÓÃÎïÆ· ->×ÔÉíЧ¹û(·â°ü²ÎÊý)  | 
| #  @param index µ±Ç°Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __Func_PlayerUseItemSelf(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #·â°ü²ÎÊý  | 
|     packUseItem = IPY_GameWorld.IPY_CUseItem()  | 
|       | 
|     #ʹÓÃÎïÆ·  | 
|     __DoLogic_PlayerUseItemSelf(curPlayer, packUseItem.GetItemIndex(), tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Ê¹ÓÃÎïÆ·£¬¸ø×Ô¼º  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param useItemIndex Ê¹ÓõÄÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DoLogic_PlayerUseItemSelf(curPlayer, useItemIndex, tick, useCnt=1, exData=0):  | 
|       | 
|     #ʹÓÃÎïÆ·ÐÐΪ״̬, ÅжϿͻ§¶ËÏÞÖÆ  | 
|     if not OperControlManager.IsObjCanDoAction(  | 
|                                         curPlayer,   | 
|                                         ChConfig.Def_Obj_ActState_ClientAct,   | 
|                                         IPY_GameWorld.oalUseItem  | 
|                                         ):  | 
|         return False  | 
|   | 
|     #------------------·â°ü²ÎÊý »ñµÃ Íæ¼ÒÎïÆ·  | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     curItem = backPack.GetAt(useItemIndex)    | 
|   | 
|     #¼ì²éÊÇ·ñ¿ÉÒÔʹÓÃÎïÆ·  | 
|     if not CheckPlayerUseItemSelf(curPlayer, curItem, tick):  | 
|         return False  | 
|   | 
|     # -1(²»ÏÞÖÆ); >=0(»¹¿ÉʹÓôÎÊý)  | 
|     todayCanUseCnt = __GetTodayCanUseCnt(curPlayer, curItem)  | 
|     if todayCanUseCnt == 0:  | 
|         return False  | 
|   | 
|     if todayCanUseCnt > 0:  | 
|         useCnt = min(todayCanUseCnt, useCnt)  | 
|     useCnt = min(useCnt, curItem.GetCount()) # ×î´óʹÓÃÊý²»Äܳ¬¹ýÎïÆ·µ±Ç°ÊýÁ¿  | 
|       | 
|     #------------------¼Ç¼ÎïÆ·Ïà¹ØÊôÐÔ //±ØÐëÏȼǼ, ÒòΪDoUseItemLogicÖ´Ðкó, ÎïÆ·ÒѾÏûʧ  | 
|     curItemTypeID = curItem.GetItemTypeID()  | 
|     curItemCDType = curItem.GetCDType()  | 
|       | 
|     #Ö´ÐÐʹÓÃÎïÆ·Âß¼  | 
|     useResult = DoUseItemLogic(curPlayer, curItem, tick, useCnt, exData)  | 
|     isOK, successCnt = __AnalysisUseItemResult(useResult)  | 
|     GameWorld.DebugLog("__DoLogic_PlayerUseItemSelf itemID=%s,result=%s,isOK=%s,successCnt=%s"   | 
|                        % (curItemTypeID, useResult, isOK, successCnt))      | 
|     if not isOK:  | 
|         return False  | 
|       | 
|     #------------ʹÓÃÎïÆ·³É¹¦, Ö´ÐÐÏà¹Ø²Ù×÷  | 
|     PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_UseItem, successCnt, [curItemTypeID])  | 
|       | 
|     curPlayer.Sync_UseItem(curItemTypeID, useItemIndex)  | 
|     curPlayer.SetItemCD(curItemCDType, tick)  | 
|       | 
|     #ʹÓÃÎïÆ·µÄÌØÊâÌáʾ  | 
|     ItemCommon.UseItemSpecialNotify(curPlayer, curItemTypeID)  | 
|       | 
|     #Ôö¼Ó½ñÈÕʹÓôÎÊý  | 
|     if todayCanUseCnt > 0:  | 
|         __AddItemUseCntToday(curPlayer, curItemTypeID, successCnt)  | 
|     return True  | 
|   | 
| ## Ê¹ÓÃÎïÆ··µ»ØÖµ´¦Àí£¬ ×ª»¯Îª¹Ì¶¨¸ñʽ·µ»Ø  | 
| #  @param useResult ²»¶¨ÀàÐÍ·µ»ØÖµ  | 
| #  @return ÊÇ·ñʹÓóɹ¦, ³É¹¦Ê¹ÓøöÊý  | 
| #  @remarks ÓÅ»¯ÅúÁ¿Ê¹ÓÃÎïÆ·Ê±ÎªÁ˼æÈÝоɰ汾×öµÄÁÙʱ´¦Àí  | 
| def __AnalysisUseItemResult(useResult):  | 
|     # Ö§³ÖNone, bool·µ»ØÖµ, tuple·µ»ØÖµ  | 
|     # Í³Ò»×ª»¯Îª  isOK, ³É¹¦Ê¹ÓôÎÊý  | 
|     isOK = False  | 
|     successCnt = 0  | 
|       | 
|     if isinstance(useResult, tuple):  | 
|         isOK, successCnt = useResult  | 
|     elif isinstance(useResult, bool):  | 
|         isOK = useResult  | 
|         if isOK:  | 
|             successCnt = 1  | 
|           | 
|     return isOK, successCnt  | 
|   | 
| ## ¼ì²éÊÇ·ñ¿ÉÒÔʹÓÃÎïÆ·  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks   | 
| def CheckPlayerUseItemSelf(curPlayer, curItem, tick):  | 
|     #----------------------¼ì²é·Ç·¨ÎïÆ·ÊôÐÔ  | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")  | 
|         return False  | 
|       | 
|     #----------------------¼ì²éÍæ¼ÒÊôÐÔ  | 
|     if not CheckUseItemSelf_Player(curPlayer):  | 
|         return False  | 
|       | 
|     #----------------------¼ì²éÕý³£ÎïÆ·ÊôÐÔ  | 
|     if not UseItemSelf_Item(curPlayer, curItem, tick):  | 
|         return False  | 
|       | 
|     if not ItemCommon.CheckItemCanUseByExpireTime(curItem):  | 
|         # ¹ýÆÚ  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_774045")  | 
|         return False  | 
|   | 
|     return True  | 
|   | 
| ## »ñÈ¡ÎïÆ·½ñÈÕ»¹¿ÉʹÓôÎÊý  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @return -1(²»ÏÞÖÆ); >=0(»¹¿ÉʹÓôÎÊý)  | 
| def __GetTodayCanUseCnt(curPlayer, curItem):  | 
|     maxCnt = ItemCommon.GetCanUseCountDaily(curItem)  | 
|     if maxCnt <= 0:  | 
|         return -1  | 
|       | 
|     itemID = curItem.GetItemTypeID()  | 
|     useCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemUseCntToday % itemID)  | 
|     canUseCnt = max(0, maxCnt - useCnt)  | 
|       | 
|     if canUseCnt <= 0:  | 
|         GameWorld.DebugLog("ÒÑ´ïµ½½ñÈÕʹÓôÎÊýÉÏÏÞ!itemID=%s,useCnt=%s,maxCnt=%s" % (itemID, useCnt, maxCnt))  | 
|         #PlayerControl.NotifyCode(curPlayer, notifyMark, [itemID])  | 
|           | 
|     #GameWorld.DebugLog("ÎïÆ·ID(%s)½ñÈÕÒÑʹÓôÎÊý(%s), maxCnt=%s" % (itemID, useCnt, maxCnt))  | 
|     return canUseCnt  | 
|   | 
| ## Ôö¼ÓÎïÆ·½ñÈÕʹÓôÎÊý  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @return   | 
| def __AddItemUseCntToday(curPlayer, itemID, addCnt=1):  | 
|     useCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemUseCntToday % itemID)  | 
|     updCnt = min(useCnt + addCnt, ChConfig.Def_UpperLimit_DWord)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ItemUseCntToday % itemID, updCnt)  | 
|     #GameWorld.DebugLog("¸üÐÂÎïÆ·ID(%s)½ñÈÕÒÑʹÓôÎÊý(%s)" % (itemID, updCnt))  | 
|     Sync_ItemDayUseCnt(curPlayer, [itemID])  | 
|     return updCnt  | 
|   | 
| ## ÖØÖÃÎïÆ·½ñÈÕʹÓôÎÊý  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @return   | 
| def ResetItemUseCntToday(curPlayer):  | 
|     resetItemIDList = []  | 
|     for itemID in PyGameData.DailyUseCountLimitItemIDList:  | 
|         if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemUseCntToday % itemID):  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ItemUseCntToday % itemID, 0)  | 
|             resetItemIDList.append(itemID)  | 
|     if resetItemIDList:  | 
|         Sync_ItemDayUseCnt(curPlayer, resetItemIDList)  | 
|     return  | 
|   | 
| def Sync_ItemDayUseCnt(curPlayer, syncItemIDList=[]):  | 
|     isForceSync = True  | 
|     if not syncItemIDList:  | 
|         isForceSync = False # Ã»ÓÐÖ¸¶¨ID£¬Ôòֻ֪ͨÓÐʹÓôÎÊýµÄ  | 
|         syncItemIDList = PyGameData.DailyUseCountLimitItemIDList  | 
|           | 
|     useCntInfoPack = ChPyNetSendPack.tagMCItemDayUseCntInfo()  | 
|     useCntInfoPack.Clear()  | 
|     useCntInfoPack.ItemUseCntList = []  | 
|     for itemID in syncItemIDList:  | 
|         useCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemUseCntToday % itemID)  | 
|         if not useCount and not isForceSync:  | 
|             continue  | 
|         useCntPack = ChPyNetSendPack.tagMCItemDayUseCnt()  | 
|         useCntPack.Clear()  | 
|         useCntPack.ItemID = itemID  | 
|         useCntPack.UseCnt = useCount  | 
|         useCntInfoPack.ItemUseCntList.append(useCntPack)  | 
|     useCntInfoPack.Count = len(useCntInfoPack.ItemUseCntList)  | 
|     if useCntInfoPack.Count:  | 
|         NetPackCommon.SendFakePack(curPlayer, useCntInfoPack)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Ö´ÐÐʹÓÃÎïÆ·Âß¼ // ·µ»ØÕæ±íʾʹÓóɹ¦( Íâ²ãתCDºÍ֪ͨ¿Í»§¶Ë )  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DoUseItemLogic(curPlayer, curItem, tick, useCnt=1, exData=0):  | 
|     #ʹÓÃÌØÊâÎïÆ·½á¹û //·µ»Ø-1´ú±íÒ»°ãÎïÆ·  | 
|     useSpecialItemResult = __DealWith_SpecialItem(curPlayer, curItem, tick, useCnt, exData)  | 
|     | 
|     if useSpecialItemResult != -1:  | 
|         #Õâ¸öÎïÆ·²»ÊÇÒ»°ãÎïÆ·, Ö±½Ó·µ»Ø½á¹û  | 
|         return useSpecialItemResult  | 
|       | 
|     #---ÌØÊâ×°±¸²»Ñé֤װ±¸ÊôÐÔ, ÆÕͨÎïÆ·ÒªÑé֤װ±¸ÊôÐÔ---  | 
|     itemControler = ItemControler.PlayerItemControler(curPlayer)  | 
|       | 
|     #×°±¸ÎÞ·¨Ê¹Óà  | 
|     if itemControler.PlayerCanEquipItem(curItem, False):  | 
|         #Õâ¸öÎïÆ·ÊÇ×°±¸  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_774045")  | 
|         return  | 
|       | 
|     #ÎïÆ·ÀàÐÍID  | 
|     itemTypeID = curItem.GetItemTypeID()  | 
|       | 
|     # Ä¬ÈÏÅúÁ¿Ê¹Óà  | 
|     callFunc = GameWorld.GetExecFunc(UseItem, "Item_%d.%s"%(itemTypeID, "BatchUseItem"))  | 
|     if callFunc:  | 
|         return callFunc(curPlayer, curItem, tick, useCnt, exData)  | 
|   | 
|     #¾É´úÂë¼æÈÝ£¬ÅúÁ¿Ê¹ÓÃÓ¦¸Ãµ÷ÓÃBatchUseItem£¬¶ÔUseItemÑ»·µ÷Óò»ÑϽ÷  | 
|     callFunc = GameWorld.GetExecFunc(UseItem, "Item_%d.%s"%(itemTypeID, "UseItem"))  | 
|       | 
|     if not callFunc:  | 
|         #ÎïÆ·²»¿ÉCall  | 
|         GameWorld.ErrLog("ʹÓÃÎïÆ· = %s²»¿ÉCall"%(itemTypeID), curPlayer.GetID())  | 
|         return  | 
|       | 
|     #·µ»ØÕæ±íʾʹÓóɹ¦( Íâ²ãתCDºÍ֪ͨ¿Í»§¶Ë )  | 
|     return callFunc(curPlayer, curItem, tick)  | 
| #---------------------------------------------------------------------  | 
| ## ´¦ÀíÌØÊâÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DealWith_SpecialItem(curPlayer, curItem, tick, useCnt, exData):  | 
|     #¹ûʵÎïÆ·  | 
|     useFruitResult = PlayerAttrFruit.DoPlayerEatFruitItem(curPlayer, curItem, useCnt)  | 
|     if useFruitResult != -1:  | 
|         return useFruitResult  | 
|       | 
|     #------------------------»ñµÃÎïÆ·Ïà¹ØÊôÐÔ  | 
|     itemTypeID = curItem.GetItemTypeID()  #ÎïÆ·ÀàÐÍid  | 
|     curItemType = curItem.GetType()  # ÎïÆ·ÀàÐÍ  | 
|     curEffID = curItem.GetEffectByIndex(0).GetEffectID()  | 
|       | 
|     #¸ù¾ÝÎïÆ·ÀàÐÍʹÓÃ{ÎïÆ·ÀàÐÍ:callµÄpyÃû}  | 
|     itemTypeCallFuncDic = {  | 
|                            ChConfig.Def_ItemType_HPMP:"Item_Add_HPMP",                # ²¹ºì²¹ÀºÒ©¼Á  | 
|                            ChConfig.Def_ItemType_AddExp:"Item_AddExp",         # ¸ø¾ÑéµÀ¾ß  | 
|                            ChConfig.Def_ItemType_GiveMoney:"Item_GiveMoney",         # ¸øÈËÎï½ðÇ®  | 
|                            ChConfig.Def_ItemType_AddLimitBuff:"Item_Add_LimitingBuff",         # ¸øÏÞʱbuffÎïÆ·  | 
|                            ChConfig.Def_ItemType_AddExpBuff:"Item_Add_LimitingBuff",         # ¸øÏÞʱbuffÎïÆ·  | 
|                            ChConfig.Def_ItemType_ResetAttrPoint:"Item_ResetAttrPoint"    #µ¥¸öÊôÐÔµãÖØÖà  | 
|                            }   | 
|       | 
|     #¸ù¾ÝÎïÆ·Ð§¹ûʹÓÃ{ÎïÆ·Ð§¹ûID:callµÄpyÃû}  | 
|     itemEffIdCallFuncDic = {  | 
|                             ChConfig.Def_Effect_UseItemGiveZhenQi:"Item_UseItemGiveZhenQi", # Ê¹ÓõÀ¾ß¸øÓèÕæÆø  | 
|                             ChConfig.Def_Effect_AddDienstgrad:"Item_AddDienstgrad", #µÀ¾ß»ñµÃ³ÆºÅ  | 
|                             ChConfig.Def_Effect_ItemAddLV:"Item_AddLV", #Éý¼¶µÀ¾ß  | 
|                             ChConfig.Def_Effect_TJGAddTime:"Item_TJGAddTime", #Ôö¼ÓÍÑ»ú¹Òʱ¼ä  | 
|                             ChConfig.Def_Effect_CleanGuilt:"Item_CleanGuilt", # Ï´ºìÃû  | 
|                             ChConfig.Def_Effect_PrizeCoin:"Item_PrizeCoin", # ½±Àø³äÖµµãȯ  | 
|                             ChConfig.Def_Effect_AddVIPExp:"Item_AddVIPExp", # Ôö¼ÓVIP¾Ñé  | 
|                             ChConfig.Def_Effect_ResetBossKillCnt:"Item_ResetBossKillCnt", # ÖØÖÃboss»÷ɱƣÀÍ  | 
|                             ChConfig.Def_Effect_AddFBCnt:"Item_AddFBCnt", # Ôö¼Ó¸±±¾¿É½øÈë´ÎÊý  | 
|                             ChConfig.Def_Effect_AddKillBossCnt:"Item_AddKillBossCnt", # Ôö¼ÓBOSS¿É»÷ɱ´ÎÊý  | 
|                             #ChConfig.Def_PhoneVip_EffID:"Item_AddPhoneVip", # ÊÖ»úVIPÎïÆ·¿¨  | 
|                             #ChConfig.Def_Effect_AddZhenQiByTimes:"Item_AddZhenQiByTimes", # Ôö¼ÓÕæÆø°´Ò»ÌìʹÓôÎÊý¼õÉÙ  | 
|                             #ChConfig.Def_Effect_AddPrestige:"Item_AddPrestige",  # ¸øÈËÎïÍþÍû  | 
|                             #ChConfig.Def_Effect_FamilyImpeach:"Item_FamilyImpeach",  # µ¯ÛÀ·û  | 
|                             #ChConfig.Def_Effect_ClothesCoatSkin:"Item_ClothesCoatSkin", #¼¤»îʱװƤ·ô  | 
|                             #ChConfig.Def_Effect_AddOfficialExp:"Item_AddOfficialExp", # Ôö¼Ó¾ôλ¾Ñé  | 
|                             }  | 
|       | 
|     callFuncName = itemTypeCallFuncDic.get(curItemType, "")  | 
|       | 
|     if not callFuncName:  | 
|         callFuncName = itemEffIdCallFuncDic.get(curEffID, "")  | 
|       | 
|     if not callFuncName:  | 
|         chestsIpyData = IpyGameDataPY.GetIpyGameDataNotLog("Chests", itemTypeID)  | 
|         if chestsIpyData:  | 
|             callFuncName = "Item_Chests"  | 
|               | 
|     if callFuncName:  | 
|         pass  | 
|     elif itemTypeID == ChConfig.Def_ItemID_VIPExperience:  | 
|         callFuncName = "Item_VIPExperience" #VIPÌåÑ鿨  | 
|           | 
|     if callFuncName == '':  | 
|         #//Õâ¸öÎïÆ·ÊÇÒ»°ãÎïÆ·, ·µ»ØÍâ²ã¼ÌÐø´¦Àí  | 
|         return -1  | 
|   | 
|     GameWorld.DebugLog("__DealWith_SpecialItem %s" % callFuncName)  | 
|     # Ä¬ÈÏʹÓà  | 
|     callFunc = GameWorld.GetExecFunc(UseItem, "%s.BatchUseItem" % callFuncName)  | 
|     if callFunc:  | 
|         return callFunc(curPlayer, curItem, tick, useCnt, exData)  | 
|           | 
|     # ¾É´úÂë¼æÈÝ£¬ÅúÁ¿Ê¹ÓÃÓ¦¸Ãµ÷ÓÃBatchUseItem£¬¶ÔUseItemÑ»·µ÷Óò»ÑϽ÷  | 
|     callFunc = GameWorld.GetExecFunc(UseItem, "%s.UseItem"%callFuncName)  | 
|   | 
|     if not callFunc:  | 
|         GameWorld.ErrLog('###ʹÓÃÎïÆ·Òì³£, ÎÞ·¨²éÕÒ %s Îļþ'%(callFuncName))  | 
|         return  | 
|   | 
|     return callFunc(curPlayer, curItem, tick)  | 
| #---------------------------------------------------------------------  | 
|   | 
|   | 
|   | 
| #===============================================================================  | 
| # //07 16 Ê¹ÓÃСÀ®°È#tagCUseSpeaker  | 
| # tagCUseSpeaker       *   GettagCUseSpeaker();  | 
| #   | 
| # class   IPY_CUseSpeaker  | 
| # {  | 
| # public:  | 
| #    //ÊÇ·ñʹÓýðǮ˵»°  | 
| #    int      GetUseGold();  | 
| #    //ʹÓÃÎïÆ·Ëµ»°Ê±, ÎïÆ·Index  | 
| #    int      GetItemIndex();  | 
| #    //×Ö·û³¤¶È  | 
| #    int      GetTextLen();  | 
| #    //size = TextLen  | 
| #    char *      GetText();  | 
| # };  | 
| #===============================================================================  | 
| ## Ê¹ÓÃÀ®°È  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseSpeaker(index, tick):  | 
|     # ·ÏÆú£¬Ê¹ÓàA2 17 À®°ÈÁÄÌì #tagCMPYSpeaker   | 
|   | 
|     return  | 
|   | 
|   | 
|   | 
| ## Ê¹ÓÃÎïÆ·Ð¡À®°È  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param itemIndex ÎïÆ·Ë÷Òý  | 
| #  @return Ð¡À®°ÈµÈ¼¶  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DoSpeaker_UseItem(curPlayer, itemIndex, speakerType=0):  | 
|     #µÃµ½Íæ¼ÒµÄ±³°ü  | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     #µÃµ½µ±Ç°ÎïÆ·  | 
|     curItem = backPack.GetAt(itemIndex)  | 
|         | 
|     #»ñµÃʹÓõÄÀ®°ÈµÈ¼¶  | 
|     speakerLV = __GetSpeakerLV(curPlayer, curItem)  | 
|       | 
|     if not speakerLV or (speakerType and speakerType != speakerLV):  | 
|         return 0  | 
|       | 
|     dataDict = {"ItemID":curItem.GetItemTypeID(), "ItemCount":1, "ItemGUID":curItem.GetGUID()}  | 
|     DataRecordPack.DR_DeleteItem(curPlayer, 'SpeakerUseItem', dataDict)  | 
|       | 
|     ItemControler.SetItemCount(curItem, curItem.GetCount() - 1,   | 
|                                curPlayer.GetID(), curPlayer.GetAccID(), curPlayer.GetPlayerName())  | 
|       | 
|     return speakerLV  | 
|   | 
| ### Ê¹ÓýðǮСÀ®°È  | 
| ##  @param curPlayer µ±Ç°Íæ¼Ò  | 
| ##  @param useGold  | 
| ##  @return None or speakerLV  | 
| ##  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #def __DoSpeaker_UseGold(curPlayer , useGold):  | 
| #    #ʹÓÃÀ®°ÈµÈ¼¶  | 
| #    speakerLV = 0  | 
| #    #useGold 1:ʹÓýðÀ®°È , 2:ʹÓÃÒøÀ®°È  | 
| #    if useGold == 1:  | 
| #        speakerLV = 3  | 
| #        curItemData = GameWorld.GetGameData().GetItemByTypeID(ChConfig.Def_SpeakerItem_GoldID)  | 
| #    else:  | 
| #        speakerLV = 2  | 
| #        curItemData = GameWorld.GetGameData().GetItemByTypeID(ChConfig.Def_SpeakerItem_SilverID)  | 
| #      | 
| #    if not curItemData:  | 
| #        GameWorld.Log('###Êý¾Ý¿âÎÞ·¨²éÕÒСÀ®°È')  | 
| #        return speakerLV  | 
| #      | 
| #    price , priceType = ItemCommon.GetItemSellPrice(curPlayer , curItemData , 1)  | 
| #      | 
| #    if not PlayerControl.PayMoney(curPlayer, priceType, price):  | 
| #        #ûǮ,·µ»Ø  | 
| #        return speakerLV  | 
| #      | 
| #    GameWorld.Login_Interface_GoldRec(curPlayer , curItemData.GetItemTypeID() , 1 , curItemData.GetName() , priceType , price)  | 
| #      | 
| #    return speakerLV  | 
|   | 
|   | 
| #---------------------------------------------------------------------  | 
| ## »ñÈ¡·¢ÑԵȼ¶  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓõÄÎïÆ·  | 
| #  @return ·¢ÑԵȼ¶  | 
| #  @remarks »ñÈ¡·¢ÑԵȼ¶.  | 
| def __GetSpeakerLV(curPlayer, curItem):  | 
|     #Òì³£ÎïÆ·  | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         return 0  | 
|   | 
|     if not ItemControler.CheckItemUseLV(curPlayer, curItem):  | 
|         return 0  | 
|       | 
|     #µÃµ½µ±Ç°Ð§¹û  | 
|     curEff = curItem.GetEffectByIndex(0)  | 
|     curEffID = curEff.GetEffectID()  | 
|       | 
|     if curEffID != ChConfig.Def_Effect_ItemSpeak:  | 
|         return 0  | 
|       | 
|     curEffValue = curEff.GetEffectValue(0)  | 
|       | 
|     if curEffValue < 1 or curEffValue > 3:  | 
|         GameWorld.ErrLog("СÀ®°ÈÌî±í´íÎó curEffID = %s, value = %s"%(curEffID, curEffValue), curPlayer.GetPlayerID())  | 
|         return 0  | 
|       | 
|     return curEffValue  | 
| #---------------------------------------------------------------------  | 
| ## ¼ì²éʹÓÃÎïÆ·µÄÍæ¼ÒÊôÐÔ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks ¼ì²éʹÓÃÎïÆ·µÄÍæ¼ÒÊôÐÔ.  | 
| def CheckUseItemSelf_Player(curPlayer):  | 
|     if curPlayer.GetHP() <= 0 :  | 
|         return False  | 
|       | 
| #    #Ñ£ÔÎʱ, ²»¿ÉʹÓÃÎïÆ·  | 
| #    if curPlayer.GetAbnormalState() == IPY_GameWorld.sctFaint:  | 
| #        return False  | 
|       | 
|     #ʹÓÃÎïÆ·ÐÐΪ״̬, ÅжϷþÎñ¶ËÏÞÖÆ  | 
|     if not OperControlManager.IsObjCanDoAction(  | 
|                                         curPlayer,   | 
|                                         ChConfig.Def_Obj_ActState_ServerAct,   | 
|                                         IPY_GameWorld.oalUseItem  | 
|                                         ):  | 
|         return False  | 
|       | 
|     #ÔÚïÚ³µÖÐ, ²»¿ÉʹÓÃÎïÆ·  | 
|     if curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvTruck :  | 
|         PlayerControl.NotifyCode(curPlayer, "Old_hgg_0")  | 
|         return False  | 
|       | 
|     #½»Ò×״̬, ²»¿ÉʹÓÃÎïÆ·  | 
|     if curPlayer.GetPlayerAction() == IPY_GameWorld.paTrade:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_372238")  | 
|         return False  | 
|       | 
| #    #GM½ûֹʹÓà  | 
| #    if GameWorld.IsGM(curPlayer):  | 
| #        PlayerControl.NotifyCode(curPlayer, "GeRen_admin_59724")  | 
| #        return False  | 
|       | 
|     return True  | 
| #---------------------------------------------------------------------      | 
| ## ¼ì²éÄÜ·ñʹÓÃÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseItemSelf_Item(curPlayer, curItem, tick):  | 
|     if (tick - curPlayer.GetItemCDStartTime(curItem.GetCDType())) < curItem.GetCDTime():  | 
|         #CDÀäȴʱ¼äδµ½  | 
|         #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_749572")  | 
|         return  | 
|   | 
|     #¼ì²éʹÓõȼ¶  | 
|     if curItem.GetUseLV() == 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_774045")  | 
|         return  | 
|       | 
|     if curItem.GetUseLV() > curPlayer.GetLV():  | 
|         PlayerControl.NotifyCode(curPlayer, "DJ_Equip_UnUse_Lv")  | 
|         return  | 
|       | 
|     if ItemControler.IsEventItem(curItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")  | 
|         return  | 
|       | 
|     #Íæ¼ÒÔÚïÚ³µÖÐ,²»ÄÜʹÓÃÎïÆ·  | 
|     if curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvTruck:  | 
|         PlayerControl.NotifyCode(curPlayer, "Old_hgg_0")  | 
|         return  | 
|       | 
| #    #Íæ¼ÒʼþÖÐ, ²»ÄÜʹÓÃÎïÆ·  | 
| #    if (curPlayer.GetPlayerAction() == IPY_GameWorld.paEvent and  | 
| #            not curItem.GetEventCanUse()):  | 
| #        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_372238")  | 
| #        return  | 
|       | 
|     #Ö°ÒµÏÞÖÆ  | 
|     if not ItemCommon.JobUseable(curPlayer, curItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_31379")  | 
|         return  | 
|       | 
|     #ÎïÆ·Ê¹Óõȼ¶¼ì²é  | 
|     if not ItemControler.CheckItemUseLV(curPlayer, curItem):  | 
|         return  | 
|   | 
|     #ʹÓÃÎïÆ·¼ì²éÊÇ·ñÂú×ãÊôÐÔ  | 
|     if not ItemControler.CheckItemAttrLimit(curPlayer, curItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "itemuse_andyshao_671654")  | 
|         return  | 
|       | 
| #===============================================================================  | 
| #    #¼ì²é¶ÔÏóÊÇ·ñÕýÈ·  | 
| #    if curItem.GetUseTag() not in [1,5,12]:  | 
| #        GameWorld.Log("curItem is : %s  UseTag is : %s"%(curItem.GetItemTypeID(),curItem.GetUseTag()))  | 
| #        PlayerControl.NotifyCode(curPlayer, "UseResLost09")  | 
| #        return  | 
| #===============================================================================  | 
|     #------------------------ÌØÊⳡ¾°¼ì²é  | 
|     #FB½ûֹʹÓÃÎïÆ·  | 
|     if FBLogic.DoFBForbidUseItem(curPlayer, curItem):  | 
|         return  | 
|       | 
|     return True  | 
|   | 
|   | 
| ## ÎïÆ·¼ì²éÊÇ·ñ¿ÉÒÔɾ³ý  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @return False or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __CheckItemCanDel(curPlayer, curItem):  | 
|     #ÎïÆ·²»´æÔÚ  | 
|     if curItem == None or curItem.IsEmpty():  | 
|         return False  | 
|       | 
|     if curItem.GetIsLocked():  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")  | 
|         return False  | 
|       | 
|     if curItem.GetCanDrop() == 0:  | 
|         PlayerControl.NotifyCode(curPlayer, "UseResLost10")  | 
|         return False  | 
|       | 
|     #°ó¶¨ÎïÆ·²»¿ÉµôÂä  | 
|     if curItem.GetIsBind():  | 
|         PlayerControl.NotifyCode(curPlayer, "UseResLost10")  | 
|         return False  | 
|       | 
|     if ItemControler.IsEventItem(curItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")  | 
|         return False  | 
|       | 
|     # ÅжÏÊÇ·ñÊǹóÖØÆ·  | 
|     if ItemControler.IsValuableItem(curItem):  | 
|         return False  | 
|       | 
|     return True  | 
|   | 
|   | 
| #---------------------------------------------------------------------      | 
| #//A3 02 ¶ªÆú±³°üÎïÆ· #tagPlayerDropItem  | 
| #  | 
| #struct    tagPlayerDropItem  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        PackType;        //±³°üÀàÐÍ  | 
| #    WORD        ItemIndex;        //ÎïÆ·ÔÚ±³°üÖÐË÷Òý  | 
| #    WORD        DropPosX;  | 
| #    WORD        DropPosY;    //µôÂäÎïÆ·  | 
| #};  | 
| #---------------------------------------------------------------------      | 
| ## Íæ¼Ò¶ªÆúÎïÆ·(·â°ü²ÎÊý)      | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def PlayerDropItem(index, packData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|       | 
|     packType = packData.PackType  | 
|     if IPY_GameWorld.rptItem != packType:  | 
|         return  | 
|   | 
|     dropPosX = packData.DropPosX  | 
|     dropPosY = packData.DropPosY  | 
|     # Õϰµã      | 
|     if not GameWorld.GetMap().CanMove(dropPosX, dropPosY):  | 
|         return  | 
|   | 
|     itemIndex = packData.ItemIndex      | 
|       | 
|     #»ñµÃÍæ¼ÒÎïÆ·¹ÜÀíÆ÷  | 
|     ItemManager = curPlayer.GetItemManager()  | 
|     #»ñµÃÍæ¼Ò±³°ü   | 
|     curPack = ItemManager.GetPack(packType)  | 
|     #¸ù¾Ý·â°ü,»ñµÃ±³°üÖеÄÎïÆ·  | 
|     curItem = curPack.GetAt(itemIndex)  | 
|       | 
|     #ÎïÆ·²»´æÔÚ  | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         return  | 
|   | 
|     #¼ì²éÎïÆ·¿É·ñ¶ªÆú  | 
|     if not __CheckItemCanDel(curPlayer, curItem):  | 
|         return  | 
|   | 
|     #ÒòÈռǼǼÁ¿¹ý´ó,Ìí¼Óɸѡ  | 
|     if ItemControler.ItemNeedRecord(curItem):  | 
|         #Ïêϸ¼Ç¼װ±¸ÐÅÏ¢  | 
|         equipNoteDict = ItemCommon.GetItemNoteDict(curItem, curItem.GetCount())  | 
|         DataRecordPack.DR_DeleteItemInRecycle(curPlayer, equipNoteDict)  | 
|         ItemCommon.DR_DelItem(curPlayer, packType, "DropPackItem", equipNoteDict)  | 
|       | 
|     #ɾ³ýÎïÆ·  | 
|     #ItemManager.DeleteItem(curItem)  | 
|     curMapItem = AddMapDropItem(dropPosX, dropPosY, curItem.GetItem())  | 
|     curMapItem.SetOwnerType(ChConfig.Def_NPCHurtTypePlayer)  | 
|     curMapItem.SetOwnerID(curPlayer.GetPlayerID())      | 
|       | 
|     #Çå³ýÔ±³°üÎïÆ·  | 
|     curItem.Wipe()  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------      | 
| #===============================================================================  | 
| # //07 12 Íæ¼Òɾ³ý³ÆºÅ#tagCDeleteTitle  | 
| #   | 
| # struct         tagCDeleteTitle  | 
| # {  | 
| #         tagHead            Head;  | 
| #         WORD               TitleIndex;                   //³ÆºÅ±³°üÖеĵڼ¸¸ö  | 
| # };  | 
| #===============================================================================  | 
| ## É¾³ý³ÆºÅ(·â°ü²ÎÊý)  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks //07 12 Íæ¼Òɾ³ý³ÆºÅ#tagCDeleteTitle  | 
| def DeleteTitle(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #Ҫɾ³ý³ÆºÅµÄλÖà  | 
|     sendPack = IPY_GameWorld.IPY_CDeleteTitle()  | 
|     titleIndex = sendPack.GetTitleIndex()  | 
|     #»ñµÃҪɾ³ýµÄ³ÆºÅ  | 
|     itemManager = curPlayer.GetItemManager()  | 
|     curItem = itemManager.GetPack(IPY_GameWorld.rptTitle).GetAt(titleIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         #CallcannotDelete Ëø¶¨µÄ³ÆºÅ,ÎÞ·¨É¾³ý  | 
|         PlayerControl.NotifyCode(curPlayer, "CallcannotDelete")  | 
|         return  | 
|       | 
|     DataRecordPack.DR_DeleteItem(curPlayer, "DeleteTitle", {"ItemID":curItem.GetItemTypeID()})  | 
|     #ɾ³ý³ÆºÅ  | 
|     itemManager.DeleteItem(curItem)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ## ´Ó»ØÊÕÕ¾ÖÐÈ¡»ØÎïÆ·(·â°üË÷Òý)  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetbackItemInRecycle(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     sendPack = IPY_GameWorld.IPY_CGetbackItemInRecycle()  | 
|     #»ØÊÕÕ¾ÖÐÎïÆ·Î»Öà  | 
|     recycleIndex = sendPack.GetRecycleIndex()  | 
|     #»ñµÃÍæ¼ÒÎïÆ·¹ÜÀíÆ÷  | 
|     itemManager = curPlayer.GetItemManager()  | 
|     #»ñµÃ»ØÊÕÕ¾   | 
|     curRecyclePack = itemManager.GetPack(IPY_GameWorld.rptRecycle)  | 
|     #¸ù¾Ý·â°ü,»ñµÃ»ØÊÕÕ¾ÖеÄÎïÆ·¸ñ  | 
|     curRecycleItem = curRecyclePack.GetAt(recycleIndex)  | 
|     #ÎïÆ·²»´æÔÚ  | 
|     if not ItemCommon.CheckItemCanUse(curRecycleItem):  | 
|         return  | 
|       | 
|     #»ñµÃ·ÅÈëµÄÍæ¼Ò±³°üλÖà  | 
|     itemPackIndex = sendPack.GetItemIndex()  | 
|     curItemPack = itemManager.GetPack(IPY_GameWorld.rptItem)  | 
|       | 
|     if itemPackIndex >= curItemPack.GetCount() or itemPackIndex < 0:  | 
|         GameWorld.Log("GetbackItemInRecycle -> µ±Ç°¸ñ×Ó±³°üδ´ò¿ª,  %s%s"%(itemPackIndex, curItemPack.GetCount()) , curPlayer.GetPlayerID())  | 
|         return  | 
|       | 
|     #»ñµÃÎïÆ·¸öÊý  | 
|     curCount = curRecycleItem.GetCount()  | 
|     curItemID = curRecycleItem.GetItemTypeID()  | 
|     #»Ø¹ºÎïÆ··ÑÓÃ=ÎïÆ·¼þÊý*#»Ø¹ºµ¥¼þÎïÆ··ÑÓà  | 
|     curRecycleItemPrice = curCount * ChConfig.Def_RecycleReturnMoney  | 
|     curSilverType = curPlayer.GetUseSilverType()  | 
|     #silverValue = PlayerControl.GetSilver(curPlayer)  | 
|     itemControl = ItemControler.PlayerItemControler(curPlayer)  | 
|       | 
|     #ÊÇ·ñÓÐ×ã¹»µÄ¿Õ¼ä  | 
|     if not itemControl.CanPutInItem(IPY_GameWorld.rptItem, curItemID, curCount, curRecycleItem.GetIsBind()):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|         return  | 
|       | 
|     if not PlayerControl.PayMoney(curPlayer, curSilverType, curRecycleItemPrice, ChConfig.Def_Cost_BuyItemBack,   | 
|                                   {ChConfig.Def_Cost_Reason_SonKey:curItemID}):  | 
|         return  | 
|       | 
|     ItemControler.DragItem(curPlayer, IPY_GameWorld.rptRecycle, recycleIndex, IPY_GameWorld.rptItem, itemPackIndex, curCount)  | 
| #---------------------------------------------------------------------  | 
| ## Çå¿Õ»ØÊÕÕ¾(·â°üË÷Òý)  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ClearRecycle(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #sendPack = IPY_GameWorld.IPY_CClearRecycle()  | 
|     #»ñµÃÍæ¼ÒÎïÆ·¹ÜÀíÆ÷  | 
|     ItemManager = curPlayer.GetItemManager()  | 
|     #»ñµÃ»ØÊÕÕ¾   | 
|     curPack = ItemManager.GetPack(IPY_GameWorld.rptRecycle)  | 
|     #¸ù¾Ý·â°ü,ɾ³ý»ØÊÕÕ¾ÖеÄËùÓÐÎïÆ·  | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|           | 
|         if not ItemCommon.CheckItemCanUse(curItem):  | 
|             continue  | 
|   | 
|         #ɾ³ýÎïÆ·  | 
|         ItemManager.DeleteItem(curItem)  | 
|           | 
|     return  | 
|   | 
|   | 
| #---------------------------------------------------------------------      | 
| ## Í϶¯ÎïÆ·(·â°üË÷Òý)  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DragItem(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
| #    if curPlayer.GetPlayerAction() == IPY_GameWorld.paEvent:  | 
| #        GameWorld.Log("Íæ¼ÒʼþÖÐ, ²»ÔÊÐíÍÏ×§")  | 
| #        return  | 
|     clientDrag = IPY_GameWorld.IPY_CDragItem()  | 
|     ItemControler.DragItem(curPlayer, IPY_GameWorld.rptItem, clientDrag.GetSrcIndex(), IPY_GameWorld.rptItem, clientDrag.GetDestIndex(), clientDrag.GetItemCount())  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ## ÎïÆ·Ê°È¡¼ì²é(²ÎÊý - > µ±Ç°Íæ¼Ò,µØÍ¼ÎïÆ·,µ±Ç°Ê±¼ä)  | 
| #  @param index ÎïÆ·Ë÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __CheckPickUpItemTime(curPlayer , mapItem , tick):  | 
|     #ÅжÏÎïÆ·±£»¤Ê±¼ä  | 
|     #Íæ¼Ò»÷ɱµôÂäµÄ  | 
|     if mapItem.GetRemainTick(tick) == 0:  | 
|         return True  | 
|     itemOwnerType =  mapItem.GetOwnerType()  | 
|       | 
|     #ËùÓÐÈ˶¼¿ÉÒÔʰȡµÄÎïÆ·  | 
|     if itemOwnerType == ChConfig.Def_NPCHurtTypeAll:  | 
|         return True  | 
|     #¸öÈËÎïÆ·  | 
|     elif itemOwnerType == ChConfig.Def_NPCHurtTypePlayer:  | 
|         if mapItem.GetOwnerID() != curPlayer.GetPlayerID():  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄã,²»ÄÜʰȡ1")  | 
|             return False  | 
|     #¶ÓÎéÎïÆ·  | 
|     elif itemOwnerType == ChConfig.Def_NPCHurtTypeTeam:  | 
|         curTeam = curPlayer.GetTeam()  | 
|         if curTeam == None:  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄã,²»ÄÜʰȡ2")  | 
|             return False  | 
|         if curTeam.GetTeamID() != mapItem.GetOwnerID():  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄã,²»ÄÜʰȡ3")  | 
|             return False  | 
|     #ÕóÓªÎïÆ·  | 
|     elif itemOwnerType == ChConfig.Def_NPCHurtTypeFaction:  | 
|         if mapItem.GetOwnerID() != curPlayer.GetFaction():  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄã,²»ÄÜʰȡ5")  | 
|             return False  | 
|     #ÌØÊâÍæ¼ÒID¹éÊô  | 
|     elif itemOwnerType == ChConfig.Def_NPCHurtTypeSpecial:  | 
|         ownerIDList = GetMapItemUserDataValue(mapItem, ShareDefine.Def_MapItemInfo_SpecOwner, [])  | 
|         if curPlayer.GetPlayerID() not in ownerIDList:  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄã,²»ÄÜʰȡ6! ownerIDList=%s" % ownerIDList, curPlayer.GetPlayerID())  | 
|             return False  | 
|     #ÏÉÃ˹éÊô  | 
|     elif itemOwnerType == ChConfig.Def_NPCHurtTypeFamily:  | 
|         if mapItem.GetOwnerID() != curPlayer.GetFamilyID():  | 
|             #GameWorld.Log("¸ÃÎïÆ·²»ÊôÓÚÄãÏÉÃ˵Ä,²»ÄÜʰȡ7! ownerFamilyID=%s,curFamilyID=%s"   | 
|             #              % (mapItem.GetOwnerID(), curPlayer.GetFamilyID()), curPlayer.GetPlayerID())  | 
|             return False  | 
|           | 
|     return True  | 
|   | 
| def GetMapItemUserDataValue(mapItem, dataIndex, defaultValue=None):  | 
|     userData = mapItem.GetUserData()  | 
|     try:  | 
|         userData = eval(userData)  | 
|     except:  | 
|         return defaultValue  | 
|     key = str(dataIndex)  | 
|     if key not in userData:  | 
|         return defaultValue  | 
|     return userData[key]  | 
|   | 
| #===============================================================================  | 
| # //07 19 ÍòÄܱ³°üÈ¡³öÎïÆ·#tagCGetAnyWhereItem  | 
| # tagCGetAnyWhereItem       *   GettagCGetAnyWhereItem();  | 
| #   | 
| # class   IPY_CGetAnyWhereItem  | 
| # {  | 
| # public:  | 
| #    //ÍòÄܱ³°üµÄindex  | 
| #    int      GetAnyWhereItemIndex();  | 
| #    //×Ô¼º±³°üµÄindex  | 
| #    int      GetDestIndex();  | 
| #    //ÍòÄܱ³°üÈ¡³öÀàÐÍTAnyWherePackType  | 
| #    int      GetAnyWherePackType();  | 
| # };  | 
| #===============================================================================  | 
| ## »ñÈ¡ÍòÄܱ³°üÎïÆ·  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetAnyWhereItem(index , tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     pack = IPY_GameWorld.IPY_CGetAnyWhereItem()  | 
|     srcIndex = pack.GetAnyWhereItemIndex()  | 
|     destIndex = pack.GetDestIndex()  | 
|     anyWherePackType = pack.GetAnyWherePackType()  | 
|     __DoLogic_GetAnyWhereItem(curPlayer , srcIndex , destIndex , anyWherePackType)  | 
|     return  | 
|   | 
| ## ´ÓÍòÄܱ³°üÈ¡ÎïÆ·  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param srcIndex ÍòÄܱ³°üË÷Òý  | 
| #  @param destIndex ±³°üË÷Òý  | 
| #  @param anyWherePackType ±³°üÀàÐÍ  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DoLogic_GetAnyWhereItem(curPlayer , srcIndex , destIndex , anyWherePackType):  | 
|     curItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptAnyWhere).GetAt(srcIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         return  | 
|       | 
|     curItemCount = curItem.GetCount()  | 
|     curItemTypeID = curItem.GetItemTypeID()  | 
|     itemControl = ItemControler.PlayerItemControler(curPlayer)  | 
|       | 
|     if not itemControl.CanPutInItem(IPY_GameWorld.rptItem, curItemTypeID, curItemCount, curItem.GetIsBind()):  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])   | 
|         return  | 
|       | 
|     #ÊÀ½ç¹ã²¥¼«Æ·  | 
|     #__Notify_GoodItem(curPlayer , anyWherePackType , curItem)  | 
|       | 
|     #GeRen_chenxin_341290 ¹§Ï²Äú,»ñµÃ[s1][s2]  | 
|     #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_341290", [curItemTypeID , curItemCount])  | 
|       | 
|     #֪ͨ·ÅÈëÌØÐ§  | 
|     #curPlayer.Sync_GetItemView(curItemTypeID, curItemCount)  | 
|       | 
|     #È¡»ØÎïÆ·µ½±³°ü  | 
|     ItemControler.DragItem(curPlayer, IPY_GameWorld.rptAnyWhere, srcIndex, IPY_GameWorld.rptItem, destIndex, curItemCount)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //07 20 ÎïÆ··ÅÈë·¨±¦±³°ü#tagCPutItemInFabao  | 
| # tagCPutItemInFabao       *   GettagCPutItemInFabao();  | 
| #   | 
| # class   IPY_CPutItemInFabao  | 
| # {  | 
| # public:  | 
| #    //·¨±¦µÄIndex  | 
| #    int      GetItemIndex();  | 
| # };  | 
| #===============================================================================  | 
| ## ²»Ïê  | 
| #  @param   | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def PutItemInFabao(index , tick):  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //07 21 È¡³ö·¨±¦±³°üµÄÎïÆ·#tagCGetBackItemInFabao  | 
| # tagCGetBackItemInFabao       *   GettagCGetBackItemInFabao();  | 
| #   | 
| # class   IPY_CGetBackItemInFabao  | 
| # {  | 
| # public:  | 
| #    //È¡³öµÄÄ¿±êλÖà  | 
| #    int      GetTagItemIndex();  | 
| # };  | 
| #===============================================================================  | 
| ## ²»Ïê   | 
| #  @param index  | 
| #  @param tick  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetBackItemInFabao(index , tick):  | 
|     return  | 
|   | 
| ##===============================================================================  | 
| ##07 24   tagCDingDianTransport  | 
| #  | 
| ### ¶¨µã£¨³ÇÊУ©´«ËÍ ºÍ ¶´Ñ¨´«ËÍ £¨ÊÕ°ü²ÎÊý£©  | 
| ##  @param index Íæ¼ÒË÷Òý  | 
| ##  @param tick µ±Ç°Ê±¼ä  | 
| ##  @return None  | 
| ##  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #def PointTransport(index, tick):  | 
| #    return  | 
| #    packUseItem = IPY_GameWorld.IPY_CDingDianTransport()  | 
| #    useItemIndex = packUseItem.GetItemIndex()  | 
| #    transportIndex = packUseItem.GetTransportIndex()  | 
| #      | 
| #    #»ñµÃÍæ¼ÒʹÓõÄÎïÆ·  | 
| #    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
| #    backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
| #    curItem = backPack.GetAt(useItemIndex)  | 
| #      | 
| #    #¼ì²éÍæ¼Ò״̬ºÍÎïÆ·  | 
| #    if not CheckUseTransformItem(curPlayer, curItem, tick):  | 
| #        return  | 
| #      | 
| #    #ÅжÏÊôÓÚÄÄÖÖ´«ËÍ  | 
| #    effIndex = curItem.GetEffectByIndex(0)  | 
| #    curEffID = effIndex.GetEffectID()  | 
| #      | 
| #    #CDÑéÖ¤  | 
| #    if (tick - curPlayer.GetItemCDStartTime(curEffID)) < curItem.GetCDTime():  | 
| #        #CDÀäȴʱ¼äδµ½  | 
| #        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_749572")  | 
| #        return  | 
| #      | 
| #    #Åжϲ¢Ö´Ðд«ËÍ  | 
| #    if not __DoTransport(curPlayer, curItem, curEffID, transportIndex, useItemIndex, tick):  | 
| #        return  | 
| #  | 
| ### Ö´Ðд«ËÍ  | 
| ##  @param curPlayer µ±Ç°Íæ¼Ò  | 
| ##  @param curItem Ê¹ÓÃÎïÆ·  | 
| ##  @param curEffID µ±Ç°Ð§¹û  | 
| ##  @param transportIndex ´«Ë͵ãË÷Òý  | 
| ##  @param useItemIndex Ê¹ÓõÄÎïÆ·Ë÷Òý  | 
| ##  @param tick µ±Ç°Ê±¼ä  | 
| ##  @return None  | 
| ##  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #def __DoTransport(curPlayer, curItem, curEffID, transportIndex, useItemIndex, tick):  | 
| #    #¶¨µãÁÐ±í  | 
| #    cityPosList = ReadChConfig.GetEvalChConfig('Def_List_City_Pos')  | 
| #    #ɽ¶´ÁÐ±í  | 
| #    cavePosList = ReadChConfig.GetEvalChConfig('Def_List_Cave_Pos')  | 
| #      | 
| #    #¶¨µã  | 
| #    if curEffID == ChConfig.Def_Item_150_Effect:  | 
| #        posList = cityPosList  | 
| #    #ɽ¶´  | 
| #    elif curEffID == ChConfig.Def_Item_152_Effect:  | 
| #        posList = cavePosList  | 
| #    else:  | 
| #        GameWorld.Log('###·Ç·¨Ê¹ÓÃÎïÆ·,Ч¹ûÖµ%s'%(curEffID,), curPlayer.GetPlayerID())  | 
| #        return  | 
| #      | 
| #    #¼ì²éÔ½½ç  | 
| #    if transportIndex < 0 or transportIndex >= len(posList):  | 
| #        GameWorld.Log('###¶¨µã´«ËÍÔ½½ç--%s'%(transportIndex))  | 
| #        return  | 
| #      | 
| #    #Ä¿±êµØÍ¼ÅÐ¶Ï  | 
| #    if not PlayerControl.CheckTagCountry(curPlayer, posList[transportIndex][0]):  | 
| #        return  | 
| #      | 
| #    itemID = curItem.GetItemTypeID()  | 
| #      | 
| #      | 
| #    #ʹÓÃxxÒ»¸ö  | 
| #    PlayerControl.NotifyCode(curPlayer, "LostRes", [itemID, 1])  | 
| #    #֪ͨ¿Í»§¶Ë  | 
| #    curPlayer.Sync_UseItem(itemID, useItemIndex)  | 
| #    curPlayer.SetItemCD(curItem.GetCDType(), tick)  | 
| #      | 
| #    #¿Û³ýÎïÆ·£¨ÏȼǼÔÙɾ³ý£¬±ÜÃâµ×²ãÒѾɾ³ý´ËÎïÆ·£©  | 
| #    curItem.SetCount(curItem.GetCount() - 1)  | 
| #      | 
| #    #Åжϳɹ¦£¬½øÐд«ËÍ  | 
| #    PlayerControl.PlayerResetWorldPos(curPlayer, posList[transportIndex][0], posList[transportIndex][1], posList[transportIndex][2], False)  | 
| #      | 
| #    #´«ËÍXXµØµãÌáʾ  | 
| #    PlayerControl.NotifyCode(curPlayer, "Map_Deliver_Succeed", [posList[transportIndex][0]])  | 
|       | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //07 26 ÓжÔÏóµÄʹÓÃÎïÆ·#tagCUseItemTag  | 
| # tagCUseItemTag       *   GettagCUseItemTag();  | 
| #   | 
| # class   IPY_CUseItemTag  | 
| # {  | 
| # public:  | 
| #    //ÎïÆ·Index  | 
| #    int      GetItemIndex();  | 
| #    //ÀàÐÍ  | 
| #    int      GetTagType();  | 
| #    //ID  | 
| #    int      GetTagID();  | 
| # };  | 
| #===============================================================================  | 
| ## Íæ¼ÒʹÓÃÎïÆ·(Ðè»Ø°ü)£¨²ÎÊý·â°ü£©  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def PlayerUseItemTag(index , tick):  | 
|     #µÃµ½Íæ¼Ò  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #Íæ¼ÒʹÓÃÎïÆ·  | 
|     packUseItem = IPY_GameWorld.IPY_CUseItemTag()  | 
|       | 
|     useItemIndex = packUseItem.GetItemIndex()  | 
|       | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     curItem = backPack.GetAt(useItemIndex)  | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         return  | 
|       | 
|     curItemType = curItem.GetType()  | 
|     curItemID = curItem.GetItemTypeID()  | 
|       | 
|     #Ö´ÐÐʹÓÃÎïÆ·Âß¼  | 
|     useItemResult = __DoLogic_PlayerUseItemSelf(curPlayer, useItemIndex, tick)  | 
|       | 
|     #ʹÓÃÎïÆ·Çé¿ö»Ø°ü   | 
|     __SendUseItemBackPack(curPlayer, curItemType, curItemID, useItemResult)  | 
|     return  | 
|   | 
| #// A3 23 Ê¹ÓÃÎïÆ· #tagCMUseItems  | 
| #  | 
| #struct    tagCMUseItems  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ItemIndex;    //ÎïÆ·ÔÚ±³°üÖÐË÷Òý  | 
| #    WORD        UseCnt;        //ʹÓøöÊý£¬0±íʾȫ²¿Ê¹Óà  | 
| #    DWORD        ExData;        //ʹÓÃÀ©Õ¹Öµ, Ä¬ÈÏ0, Ñ¡ÔñÎïÆ·±¦Ïäʱ·¢ËÍÑ¡ÔñµÄÎïÆ·ID  | 
| #};  | 
| def OnUseItems(index, packData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     itemIndex = packData.ItemIndex  | 
|     useCnt = packData.UseCnt  | 
|     exData = packData.ExData  | 
|     GameWorld.DebugLog("OnUseItems itemIndex=%s,useCnt=%s,exData=%s" % (itemIndex, useCnt, exData), curPlayer.GetPlayerID())  | 
|       | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     curItem = backPack.GetAt(itemIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curItem):  | 
|         GameWorld.DebugLog("    ÎïÆ·ÎÞ·¨Ê¹Óã¡")  | 
|         return  | 
|       | 
|     if useCnt <= 0:  | 
|         useCnt = curItem.GetCount()  | 
|         GameWorld.DebugLog("    Ã»Ö¸¶¨Ê¹ÓøöÊý£¬Ä¬ÈÏʹÓÃÈ«²¿=%s" % useCnt)  | 
|           | 
|     __DoLogic_PlayerUseItemSelf(curPlayer, itemIndex, tick, useCnt, exData)  | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Ê¹ÓÃÎïÆ·Çé¿ö»Ø°ü   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param useItemType Ê¹ÓõÄÎïÆ·ÀàÐÍ  | 
| #  @param useItemType Ê¹ÓõÄÎïÆ·ID  | 
| #  @param useItemResult Ê¹ÓõÄÎïÆ·Çé¿ö  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __SendUseItemBackPack(curPlayer, useItemType, useItemID, useItemResult):  | 
|       | 
|     #¿ÉÁ¬ÐøÊ¹ÓÃÎïÆ·ÅäÖà0:[ÎïÆ·ÀàÐÍ]£¬1:[ÎïÆ·ID]  | 
|     useItem_CanSeriesUse = ReadChConfig.GetEvalChConfig("UseItem_CanSeriesUse")  | 
|       | 
|     #---¿ÉÁ¬ÐøÊ¹ÓÃÎïÆ·Åжϣ¬»Ø°ü---  | 
|     if useItemType in useItem_CanSeriesUse.get(0, []) or useItemID in useItem_CanSeriesUse.get(1, []):  | 
|         # »Ø°ü¸£´üʹÓóɹ¦  | 
|         if useItemResult:  | 
|             curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitUseFuDai, ChConfig.Def_UseFuDai_Sucess)  | 
|         # »Ø°ü¸£´üʹÓÃʧ°Ü  | 
|         else:  | 
|             curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitUseFuDai, ChConfig.Def_UseFuDai_Fail)  | 
|   | 
|     return  | 
|   | 
| def SendUseItemGetItemResult(curPlayer, useItemID, useCount, getItemInfo, moneyType=0, moneyCount=0):  | 
|     # Í¨Öª¿Í»§¶ËʹÓÃÎïÆ·½á¹û°ü  | 
|     # @param getItemInfo: [{"ItemID":ÎïÆ·ID, "Count":¸öÊý, "IsBind":ÊÇ·ñ°ó¶¨, "IsSuite":ÊÇ·ñÌ××°»¯, "UserData":"×Ô¶¨ÒåÊôÐÔ×Ö·û´®"}, ...]  | 
|       | 
|     getItemInfo = json.dumps(getItemInfo, ensure_ascii=False)  | 
|     getItemInfo = getItemInfo.replace(" ", "")  | 
|     getItemPack = ChPyNetSendPack.tagMCNotifyUseItemGetItem()  | 
|     getItemPack.Clear()  | 
|     getItemPack.UseItemID = useItemID  | 
|     getItemPack.UseCount = useCount  | 
|     getItemPack.GetItemData = str(getItemInfo)  | 
|     getItemPack.GetItemLen = len(getItemPack.GetItemData)  | 
|     getItemPack.MoneyType = moneyType  | 
|     getItemPack.MoneyCount = moneyCount  | 
|     NetPackCommon.SendFakePack(curPlayer, getItemPack)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
|   | 
| ## ×¼±¸½áÊø  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param prepareState ×¼±¸×´Ì¬  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def OnPrepareEnd(curPlayer, prepareState):  | 
|     if prepareState == IPY_GameWorld.pstCatching:  | 
|         callFunc = GameWorld.GetExecFunc(UseItem, "Item_CallNPC.OnPrepareOK")  | 
|           | 
|         if not callFunc:  | 
|             GameWorld.Log('###³ÌÐòÒì³£,ÎÞ·¨²éÕÒÎļþ Item_CallNPC.py"')  | 
|             return  | 
|           | 
|         callFunc(curPlayer, GameWorld.GetGameWorld().GetTick())  | 
|         return  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //07 33 Ê¹ÓÃÎåÐоí#tagCUseWuXingJuan  | 
| # tagCUseWuXingJuan       *   GettagCUseWuXingJuan();  | 
| #   | 
| # class   IPY_CUseWuXingJuan  | 
| # {  | 
| # public:  | 
| #    //ÎïÆ·Index  | 
| #    int      GetItemIndex();  | 
| #    //еÄÎåÐÐ  | 
| #    int      GetNewWuXing();  | 
| # };  | 
| #===============================================================================  | 
| ## Ê¹ÓÃÎåÐоíÖᣨ·â°ü²ÎÊý£©  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseWuXingJuan(index , tick):  | 
|     return  | 
|   | 
| ## ¼ì²âÎïÆ·ÊÇ·ñÊÇÎåÐоíÖá  | 
| #  @param curItem µÈ´ý¼ì²âµÄÎïÆ·  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| #===============================================================================  | 
| # def CheckWuXingJuan(curItem):  | 
| #    if not ItemCommon.CheckItemCanUse(curItem):  | 
| #        return False  | 
| #      | 
| #    #Õâ¸öÎïÆ·²»ÊÇÎåÐÐת»»¾íÖá  | 
| #    if curItem.GetEffectByIndex(0).GetEffectID() != ChConfig.Def_Effect_ItemWuXingJuan:  | 
| #        return False  | 
| #      | 
| #    return True  | 
| #===============================================================================  | 
|   | 
|   | 
| ## Ê¹ÓÃ»Ø³Ç  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò   | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseTownPortal(curPlayer):  | 
|     #¼ì²éÊÇ·ñÊÇ»Ø³Ç¾í  | 
|     itemIndex = curPlayer.GetDictByKey(ChConfig.Def_Use_Item_303_Index)  | 
|     curItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem).GetAt(itemIndex)  | 
|       | 
|     #ÎïÆ·²»´æÔÚ,²»ÊÇ»Ø³Ç¾í²»´¦Àí  | 
|     if not ItemCommon.CheckItemCanUse(curItem) or curItem.GetItemTypeID() != 303:  | 
|         #²»ÄÜ»ñµÃÎïÆ·IDÖ»ÄÜдËÀ£¬·ñÔòÍæ¼ÒÒÆ¶¯½«ÕÒ²»µ½ÎïÆ·£¬»òID²»Æ¥Åä  | 
|         PlayerControl.NotifyCode(curPlayer, "B66BA2D6-0B3C-4177-B3FE66153B638DD0", [303, 303])  | 
|         return  | 
|       | 
|     useCount = 1  | 
|     itemID = curItem.GetItemTypeID()  | 
|     guID = curItem.GetGUID()  | 
|       | 
|     dataDict = {"ItemID":itemID, "ItemCount":useCount, "IsBind":curItem.GetIsBind(),"ItemGUID":guID}  | 
|     DataRecordPack.DR_DeleteItem(curPlayer, 'UseTownPortal', dataDict)  | 
|   | 
|     #ÎïÆ·Ê¹ÓüõÉÙ  | 
|     if curItem.GetCount() > useCount:  | 
|         ItemControler.SetItemCount(curItem, curItem.GetCount() - useCount,   | 
|                                    curPlayer.GetID(), curPlayer.GetAccID(), curPlayer.GetPlayerName())  | 
|     else:   | 
|         curItem.Clear()  | 
|           | 
|     #PlayerControl.NotifyCode(curPlayer, "LostRes", [itemID, useCount])  | 
|     playerControl = PlayerControl.PlayerControl(curPlayer)  | 
|     #°ÑÈËÎïÉèÖûØÖØÉúµã  | 
|     playerControl.SetToBornPlace()  | 
|   | 
|     return True  | 
|       | 
| #===============================================================================  | 
| # 07 39 Ê¹ÓÃÖ¸¶¨ÊýÁ¿µÄÎïÆ· tagCUseItemCount  | 
| # struct    tagCUseItemCount  | 
| # {  | 
| #     tagHead        Head;  | 
| #     BYTE        Type;    //ÎïÆ·ÀàÐÍ  | 
| #     DWORD        Count;       //ÎïÆ·ÊýÁ¿  | 
| # }  | 
| #===============================================================================  | 
|   | 
| ## 07 39·â°ü Ê¹ÓÃÖ¸¶¨ÊýÁ¿µÄÎïÆ·  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return ÎÞ  | 
| #  @remarks ºÍ¿Í»§¶ËÔ¼¶¨µÄÀàÐÍÀ´È¡µÃÖ¸¶¨ÎïÆ·£¬Ä¿Ç°ÓÃÓÚÀëÏß¹Ò»ú£¬¿ÛǬÀ¤Öé  | 
| def UseOfflineTime(index, tick):  | 
|     return  | 
|   | 
|       | 
| #===============================================================================  | 
| # struct   tagCPetUseItemByIndex  | 
| # {  | 
| #  tagHead       Head;  | 
| #  BYTE       PetIndex;     // ³èÎïÔÚ³èÎïÀ¸µÄË÷Òý  | 
| #  WORD       ItemIndex;  | 
| # };  | 
| #===============================================================================  | 
| ## 16 08·â°ü Ê¹ÓóèÎïµÀ¾ß  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return ÎÞÒâÒå  | 
| #  @remarks  | 
| def UsePetItem(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     pack = IPY_GameWorld.IPY_CPetUseItemByIndex()  | 
|       | 
|     petID = pack.GetPetID()  | 
|     itemIndex = pack.GetItemIndex()  | 
|   | 
|     #»ñµÃÎïÆ·  | 
|     curItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem).GetAt(itemIndex)  | 
|       | 
|     if not CheckPlayerUseItemSelf(curPlayer, curItem, tick):  | 
|         #´ËÎïÆ·²»¿ÉʹÓà  | 
|         return  | 
|       | 
|     if curItem.GetType() != ChConfig.Def_ItemType_PetItem:  | 
|         #²»ÊdzèÎïµÀ¾ß  | 
|         return  | 
|       | 
|     # ³èÎïУÑé  | 
|     rolePet = curPlayer.GetPetMgr().PetList_Find(petID)  | 
|       | 
|     if rolePet == None:  | 
|         return  | 
|       | 
|     #»º´æÎïÆ·ÊôÐÔ  | 
|     curItemEffectID = curItem.GetEffectByIndex(0).GetEffectID()  | 
|     curItemTypeID = curItem.GetItemTypeID()  | 
|     curItemCDType = curItem.GetCDType()  | 
|       | 
|     callFuncName = ""  | 
|       | 
| #    # Ò×Ë赤  | 
| #    if curItemEffectID == ChConfig.Def_Effect_PetReSet:  | 
| #        callFuncName = "Item_PetReSet.UsePetItem"  | 
| #      | 
| #    # Ô컯µ¤  | 
| #    elif curItemEffectID == ChConfig.Def_Effect_PetUpdateTalent:  | 
| #        callFuncName = "Item_PetUpdateTalent.UsePetItem"  | 
| #      | 
| #    # ÉñÆíÖ®Àá  | 
| #    elif curItemEffectID == ChConfig.Def_Effect_PetRePoint:  | 
| #        callFuncName = "Item_PetRePoint.UsePetItem"  | 
| #     | 
| #    # ³èÎï±äÎïÆ·  | 
| #    elif curItemEffectID == ChConfig.Def_Effect_PetEmptySoul:  | 
| #        callFuncName = "Item_PetEmptySoul.UsePetItem"  | 
| #      | 
| #    # ÖØÏ´¼¼ÄÜ  | 
| #    elif curItemEffectID == ChConfig.Def_Effect_PetRewashSkill:  | 
| #        callFuncName = "Item_PetRewashSkill.UsePetItem"  | 
| #      | 
| #    # ÖØÏ´×ÊÖÊ  | 
| #    elif curItemEffectID == ChConfig.Def_Effect_PetReSetTalentl:  | 
| #        callFuncName = "Item_PetReSetTalentl.UsePetItem"  | 
|       | 
|     if callFuncName == '':  | 
|         GameWorld.ErrLog('###ʹÓÃÎïÆ·Òì³£, ÎÞ·¨²éÕÒ %s Ð§¹ûID'%(curItemEffectID))  | 
|         return  | 
|       | 
|     callFunc = GameWorld.GetExecFunc(UseItem, callFuncName)  | 
|           | 
|     if not callFunc:  | 
|         GameWorld.ErrLog('###ʹÓÃÎïÆ·Òì³£, ÎÞ·¨²éÕÒ %s Îļþ'%(callFuncName))  | 
|         return  | 
|           | 
|     if not callFunc(curPlayer, rolePet, curItem):  | 
|         #ʹÓÃÎïÆ·Ê§°Ü  | 
|         return  | 
|       | 
|     #------------ʹÓÃÎïÆ·³É¹¦, Ö´ÐÐÏà¹Ø²Ù×÷  | 
|     curPlayer.Sync_UseItem(curItemTypeID, itemIndex)  | 
|     curPlayer.SetItemCD(curItemCDType, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ÔÚµØÉÏÌí¼ÓÎïÆ·(ͳһ½Ó¿Ú)  | 
| #  @param itemPosX Î»ÖÃx  | 
| #  @param itemPosY Î»ÖÃy  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param effIndex ÒªÏÔʾµÄÌØÐ§Ë÷Òý  | 
| #  @param ownerInfo µôÂä¹éÊôÐÅÏ¢[¹éÊôÀàÐÍ, ¹éÊôID, [ÌØÊâ¹éÊôÍæ¼ÒIDÁбí]]  | 
| #  @return ·µ»ØÖµÎÞÒâÒå  | 
| def AddMapDropItem(itemPosX, itemPosY, curItem, effIndex=0, ownerInfo=[], dropNPCID=0, isOnlySelfSee=False):  | 
|     itemDataStr = GetMapDropItemDataStr(curItem, effIndex, ownerInfo, dropNPCID, isOnlySelfSee)  | 
|       | 
|     curMapItem = GameWorld.GetMapItemManager().AddDropItem(itemPosX, itemPosY, curItem,  | 
|                                                             len(itemDataStr), itemDataStr)  | 
|     if ownerInfo:  | 
|         ownerType, ownerID = ownerInfo[:2]  | 
|         curMapItem.SetOwnerType(ownerType)  | 
|         curMapItem.SetOwnerID(ownerID)  | 
|           | 
|     #GameWorld.DebugLog("AddMapDropItem ID=%s,ownerType=%s,ownerID=%s,GetDropTick=%s,isBind=%s"   | 
|     #                   % (curMapItem.GetID(), ownerType, ownerID, curMapItem.GetDropTick(), curItem.GetIsBind()))  | 
|     return curMapItem  | 
|   | 
| def GetMapDropItemDataStr(curItem, effIndex=0, ownerInfo=[], dropNPCID=0, isOnlySelfSee=False):  | 
|     itemData = {}  | 
|       | 
|     if ItemCommon.CheckItemIsEquip(curItem):          | 
|         # Ìí¼Ó×°±¸ÊôÐÔÏÔʾ  | 
|         itemData.update(GetMapEquipInfo(curItem))  | 
|                       | 
|     elif curItem.GetCount() > 1:  | 
|         # ½ðÇ®ÊýÁ¿ÏÔʾ  | 
|         itemData[ShareDefine.Def_MapItemInfo_Count] = curItem.GetCount()  | 
|   | 
|     if effIndex > 0:  | 
|         itemData[ShareDefine.Def_MapItemInfo_Effect] = effIndex  | 
|   | 
|     if ownerInfo and len(ownerInfo) > 2 and ownerInfo[2]:  | 
|         itemData[ShareDefine.Def_MapItemInfo_SpecOwner] = ownerInfo[2]  | 
|         #GameWorld.DebugLog("µôÂäÎïÆ·ÌØÊâ¹éÊô: %s" % ownerInfo[2])  | 
|           | 
|     if dropNPCID:  | 
|         itemData[ShareDefine.Def_MapItemInfo_NPCID] = dropNPCID  | 
|           | 
|     if isOnlySelfSee:  | 
|         itemData[ShareDefine.Def_MapItemInfo_OnlySelfSee] = 1  | 
|           | 
|     return json.dumps(itemData, ensure_ascii=False)  | 
|   | 
|   | 
| ## »ñµÃµôÂä×°±¸µÄÏÔʾÐÅÏ¢  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @return ·µ»ØÖµÎÞÒâÒå  | 
| def GetMapEquipInfo(curItem):  | 
|     infoDict = {}  | 
|   | 
|     # Ì××°  | 
|     if curItem.GetIsSuite():    | 
|         infoDict[ShareDefine.Def_MapItemInfo_IsSuite] = 1  | 
|              | 
|     return infoDict  | 
|   | 
| # ÌرðÉ趨:׿ԽÎïÆ·±Ø´øÎäÆ÷¼¼ÄÜÔöǿЧ¹û£¬Ê¹ÓÃÕßÇëÌØ±ð×¢Òâ  | 
| ## ×°±¸¶¯Ì¬ÊôÐÔ£¬Ö»ÓÃÓÚδÉèÖÃÊôÐÔµÄsingleItem£¬roleItemʹÓöà´Î·¢±³°üˢаü  | 
| #  @param curItem Íæ¼ÒʵÀý  | 
| #  @param equipData  | 
| #  @return   | 
| def EquipAddAdditionEx(curItem, equipData):  | 
|     # °ó¶¨  | 
|     if equipData.isBind:  | 
|         ItemControler.SetItemIsBind(curItem, equipData.isBind)  | 
|       | 
|     if not ItemCommon.CheckItemIsEquip(curItem):  | 
|         return  | 
|           | 
|     #===========================================================================  | 
|     # # Ç¿»¯µÈ¼¶  | 
|     # if equipData.starLV:  | 
|     #    curItem.SetItemStarLV(equipData.starLV)  | 
|     # # ´ò¿×  | 
|     # if 0 < equipData.holeCnt <= curItem.GetMaxHoleCount():  | 
|     #    curItem.SetCanPlaceStoneCount(equipData.holeCnt)  | 
|     #      | 
|     # # ¸øÏâǶ±¦Ê¯  | 
|     # for i, stoneID in enumerate(equipData.stoneData):  | 
|     #    if i > equipData.holeCnt - 1:  | 
|     #        break  | 
|     #      | 
|     #    if stoneID <= 0:  | 
|     #        continue  | 
|     #      | 
|     #    curItem.SetStone(i, stoneID)  | 
|     #===========================================================================  | 
|              | 
|     # Ì××°  | 
|     if equipData.isSuite:  | 
|         curItem.SetIsSuite(equipData.isSuite)  | 
|     if equipData.suiteLV:  | 
|         curItem.SetUserAttr(ShareDefine.Def_IudetSuiteLV, equipData.suiteLV)  | 
|     # ÎïÆ·À´Ô´  | 
|     if equipData.source:  | 
|         curItem.SetUserAttr(ShareDefine.Def_IudetSource, equipData.source)  | 
|       | 
|     # ´«ÆæÊôÐÔ  | 
|     if equipData.legendAttrIDList and equipData.legendAttrValueList:  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)  | 
|         for i in xrange(len(equipData.legendAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, equipData.legendAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, equipData.legendAttrValueList[i])  | 
|       | 
|     #¾ø°æÊôÐÔ  | 
|     if equipData.OutOfPrintAttrIDList and equipData.OutOfPrintAttrValueList:  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetOutOfPrintAttrID)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetOutOfPrintAttrValue)  | 
|         for i in xrange(len(equipData.OutOfPrintAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetOutOfPrintAttrID, equipData.OutOfPrintAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetOutOfPrintAttrValue, equipData.OutOfPrintAttrValueList[i])  | 
|               | 
|     ItemCommon.MakeEquipGS(curItem)   | 
|     return  | 
|   | 
|   | 
| ## ÅжÏ×°±¸ÊÇ·ñÊǿɼÓǿװ±¸  | 
| #  @param curItem ÎïÆ·ÊµÀý  | 
| #  @return None  | 
| def CheckItemCanPlus(curItem):  | 
|       | 
|     # ´ÓÇ¿»¯±íÖлñµÃÊý¾Ý  | 
|     if curItem.GetType() in ReadChConfig.GetEvalChConfig("EquipPlus_EquipType"):  | 
|         return True  | 
|       | 
|     return False  | 
|   | 
| (  | 
|     Def_Discount_ItemType,    #ÕÛ¿Û¿¨ÎïÆ·ÀàÐÍ  | 
|     Def_SelectMore_ItemType   #¶àÑ¡Àñ°üÎïÆ·ÀàÐÍ  | 
| ) = range(2)  | 
|   | 
| #//A3 21 Ê¹ÓÃÌØÊâÔËÓªÎïÆ· #tagCMUseSpecialItem  | 
| #  | 
| #struct tagCMUseSpecialItem  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        SpeicalItemType;   //ÌØÊâÔËÓªÎïÆ·ÀàÐÍ£¬0´òÕÛ¿¨£¬1¶àÑ¡Àñ°ü  | 
| #    int        ItemID;                  //ÎïÆ·ID  | 
| #    BYTE        ItemIndex;            //ÎïÆ·ÔÚ±³°üÖеÄË÷ÒýλÖà  | 
| #    BYTE        Select;                 //Ñ¡Ôñ£¬Ö»¶Ô¶àÑ¡Àñ°üÓÐÓà     | 
| #};  | 
| ## Ê¹ÓÃÌØÊâÔËÓªÎïÆ·(·â°ü²ÎÊý)      | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param packData ½ÓÊÕµ½µÄ·â°üÊý¾Ý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def OnUseSpecialItem(index, packData, tick):  | 
| #    #GameWorld.Log("OnUseSpecialItem")  | 
| #    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
| #    specialItemType = packData.SpeicalItemType  | 
| #    itemID = packData.ItemID  | 
| #    itemIndex = packData.ItemIndex  | 
| #    selectIndex = packData.Select  | 
| #      | 
| #    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
| #    curItem = curPack.GetAt(itemIndex)  | 
| #    if curItem.GetItemTypeID() != itemID:  | 
| #        GameWorld.Log("ʹÓÃÌØÊâÔËÓªÎïÆ·Ê§°Ü£¬ÎïÆ·ID²»Ò»ÖÂ")  | 
| #        return  | 
| #    isBind = curItem.GetIsBind()#¼Ì³Ð±»Ê¹ÓÃÎïÆ·µÄ°ó¶¨ÊôÐÔ,ÏȼǼ  | 
| #    itemName = curItem.GetName()  | 
| #      | 
| #    needGold = 0  #ÐèÒªÏûºÄ¶àÉÙ×êʯ  | 
| #    itemInfoList = []  | 
| #    useMoneyInfo = ""  | 
| #    #Èç¹ûÊÇ´òÕÛ¿¨ÀàÐÍ  | 
| #    if specialItemType == Def_Discount_ItemType:  | 
| #        #GameWorld.Log("´¦Àí´òÕÛ¿¨ÎïÆ·ÀàÐÍ")  | 
| #        discountItem = ReadChConfig.GetEvalChConfig("DiscountItem")  | 
| #        #GameWorld.Log("¶ÁÈ¡µ½µÄ´òÕÛ¿¨ÎïÆ·ÅäÖÃÐÅÏ¢=%s"%discountItem)  | 
| #        itemSetInfo = discountItem.get(itemID, None)  | 
| #        if not itemSetInfo:  | 
| #            GameWorld.ErrLog("ÕÛ¿Û¿¨£¬Ã»ÓÐÕÒµ½¶ÔÓ¦ÎïÆ·µÄÅäÖÃÐÅÏ¢£¬ÎïÆ·ID£º%s"%itemID)  | 
| #            return  | 
| #        needGold, itemInfo = itemSetInfo  | 
| #        itemInfoList.append(itemInfo)  | 
| #        useMoneyInfo = "UseSpecialItem_Discount"  | 
| #    else:  | 
| #        #GameWorld.Log("´¦Àí¶àÑ¡Àñ°üÎïÆ·ÀàÐÍ")  | 
| #        selectMoreItem = ReadChConfig.GetEvalChConfig("SelectMoreItem")  | 
| #        #GameWorld.Log("¶ÁÈ¡µ½µÄ¶àÑ¡Àñ°üÎïÆ·ÅäÖÃÐÅÏ¢=%s"%selectMoreItem)  | 
| #        itemSetInfo = selectMoreItem.get(itemID, None)  | 
| #        if not itemSetInfo:  | 
| #            GameWorld.ErrLog("¶àÑ¡Àñ°ü£¬Ã»ÓÐÕÒµ½¶ÔÓ¦ÎïÆ·µÄÅäÖÃÐÅÏ¢£¬ÎïÆ·ID£º%s"%itemID)  | 
| #            return  | 
| #        if selectIndex < 0 or selectIndex >= len(itemSetInfo):  | 
| #            GameWorld.ErrLog("¶àÑ¡Àñ°ü£¬Ñ¡ÔñË÷ÒýÔ½½ç£¬ÎïÆ·ID£º%s Ñ¡ÔñË÷Òý:%s"%(itemID, selectIndex))  | 
| #            return  | 
| #        itemSetInfo = itemSetInfo[selectIndex]  | 
| #        needGold, itemInfoList = itemSetInfo  | 
| #        useMoneyInfo = "UseSpecialItem_SelectMore"  | 
| #    #GameWorld.Log("needGold=%s  itemInfoList=%s"%(needGold, itemInfoList))  | 
| #      | 
| #    #×êʯ²»×ã  | 
| #    if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, needGold):  | 
| #        GameWorld.ErrLog("×êʯ²»×ã")  | 
| #        return  | 
| #    #±³°üÊ£Óà¿Õ¼ä  | 
| #    packSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  | 
| #    if packSpace < len(itemInfoList):  | 
| #        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  | 
| #        GameWorld.ErrLog("±³°ü¿Õ¼ä²»×ã")  | 
| #        return  | 
| #    #¸øÎïÆ·  | 
| #    for itemInfo in itemInfoList:  | 
| #        newItemId, itemCount, bind, isAppoint = itemInfo  | 
| #        makeItemID = newItemId  | 
| #        #ÊǶ¨ÖÆÎïÆ·  | 
| #        if isAppoint:  | 
| #            appointItemList = PyMapTable.GetPyMapTable("AppointItemList")   #¶¨ÖÆÎïÆ·ÁÐ±í  | 
| #            itemData = appointItemList.GetRecord("ItemIndex", str(newItemId))  | 
| #            if not itemData:  | 
| #                GameWorld.ErrLog("ʹÓÃÌØÊâÔËÓªÎïÆ· ÕÒ²»µ½¶¨ÖÆÎïÆ·Êý¾Ý, itemID = %s"%newItemId)  | 
| #                return False  | 
| #              | 
| #            if len(itemData) != 1:  | 
| #                GameWorld.ErrLog("ʹÓÃÌØÊâÔËÓªÎïÆ· ¶¨ÖƱíÅäÖõÄÊý¾ÝÓÐÎó, itemID = %s"%newItemId)  | 
| #                return False  | 
| #              | 
| #            itemDictData = itemData[0]  | 
| #            makeItemID = int(itemDictData['ItemID'])  | 
| #            itemCount = 1  | 
| #            itemDictData['IsBind'] = isBind  | 
| #            if not ItemControler.GivePlayerEquip(curPlayer, itemDictData, False,   | 
| #                                                 [IPY_GameWorld.rptItem]):  | 
| #                GameWorld.ErrLog("ʹÓÃÌØÊâÔËÓªÎïÆ· ¸øÓè¶¨ÖÆÎïÆ·Ê§°Ü")  | 
| #                return  | 
| #        else:  | 
| #            #¸øÓèÎïÆ·  | 
| #            if not ItemControler.GivePlayerItem(curPlayer, newItemId, itemCount, isBind,   | 
| #                                         [IPY_GameWorld.rptItem], False):  | 
| #                GameWorld.ErrLog("ʹÓÃÌØÊâÔËÓªÎïÆ· ¸øÓèÆÕͨÎïÆ·Ê§°Ü")  | 
| #                return  | 
| #        #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [makeItemID, itemCount])  | 
| #      | 
| #    #¿Û³ýÎïÆ·  | 
| #    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
| #    #¿Û³ýÎïÆ·  | 
| #    ItemCommon.ReduceItem(curPlayer, itemPack, [itemIndex], 1, False)  | 
| #      | 
| #    #¿Û½ðÇ®  | 
| #    addDataDict = {"SpecialItemType":specialItemType, "UseItemID":itemID, "SelectIndex":selectIndex, ChConfig.Def_Cost_Reason_SonKey:itemName}  | 
| #    PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, needGold, ChConfig.Def_Cost_GiftBag, addDataDict)  | 
|     return  | 
|   | 
| #// A3 07 ¹ýÆÚÎïÆ·Ðø·Ñ #tagCMItemRenew  | 
| #  | 
| #struct    tagCMItemRenew  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        ItemIndex;        //ÎïÆ·ÔÚ±³°üÖÐË÷Òý  | 
| #    BYTE        MoneyType;        //½ðÇ®ÀàÐÍ  | 
| #};  | 
| def OnItemRenew(index, clientData, tick):  | 
|     ## ¹ýÆÚÎïÆ·Ðø·Ñ  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     timeOutItemIndex = clientData.ItemIndex  | 
|     moneyType = clientData.MoneyType #1 ÏÉÓñ 2 °óÓñ  | 
|     itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     timeOutItem = itemPack.GetAt(timeOutItemIndex)  | 
|     if not ItemCommon.CheckItemCanUse(timeOutItem):  | 
|         return  | 
|     timeOutItemID =timeOutItem.GetItemTypeID()  | 
|     itemTimeOutDict = IpyGameDataPY.GetFuncEvalCfg('ItemTimeOut')  | 
|     if str(timeOutItemID) not in itemTimeOutDict:  | 
|         GameWorld.DebugLog('ItemTimeOut Ã»ÓиÃÎïÆ·Ðø·ÑÅäÖàtimeOutItemID=%s'%timeOutItemID)  | 
|         return  | 
|     if ItemCommon.CheckItemCanUseByExpireTime(timeOutItem):  | 
|         GameWorld.DebugLog('¹ýÆÚÎïÆ·Ðø·Ñ ¸ÃÎïÆ·Î´¹ýÆÚ  timeOutItemID=%s'%timeOutItemID)  | 
|         return  | 
|       | 
|     renewInfo = itemTimeOutDict[str(timeOutItemID)]  | 
|     changeItemID = renewInfo[0]  | 
|     if moneyType == 1:  | 
|         needMoney = renewInfo[1]  | 
|     elif moneyType == 2:  | 
|         needMoney = renewInfo[2]  | 
|     else:  | 
|         return  | 
|     if not needMoney:  | 
|         return  | 
|     #¿ÛÇ®  | 
|     infoDict = {ChConfig.Def_Cost_Reason_SonKey:timeOutItemID}  | 
|     if not PlayerControl.PayMoney(curPlayer, moneyType, needMoney, ChConfig.Def_Cost_BuyStoreItem, infoDict):  | 
|         return  | 
|     #ÏÈɾÔÎïÆ·ÔÙ¸øÐÂÎïÆ·  | 
|     ItemCommon.DelItem(curPlayer, timeOutItem, 1, False, "RenewItem")  | 
|     ItemControler.GivePlayerItem(curPlayer, changeItemID, 1, True, [IPY_GameWorld.rptItem])  | 
|     PlayerControl.NotifyCode(curPlayer, 'Guardian_ContinuePay')  | 
|     return |