hxp
2019-04-16 767426c623624202acd0c97854946f4fafafe904
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -5487,21 +5487,6 @@
    return max(value / pow(10, nlen), 1)
Def_CollNPCCfg_Len = 10
(
Def_CollNPCCfg_CanTogether, # 是否允许同时采集
Def_CollNPCCfg_SysMsgMark, # 不可同时采集提示
Def_CollNPCCfg_CostItemInfo, # 采集消耗物品信息
Def_CollNPCCfg_PrepareTime, # 采集时间毫秒
Def_CollNPCCfg_ExpFormat, # 获得经验公式
Def_CollNPCCfg_MoneyFormat, # 获得金币公式
Def_CollNPCCfg_ZhenQi, # 获得的真气/魔魂
Def_CollNPCCfg_GiveItemModeID, # 获得的物品信息模板编号
Def_CollNPCCfg_NotCostItemNotify, # 消耗品不足提示
Def_CollNPCCfg_LimitSysMsgMark, #采集上限提示
) = range(Def_CollNPCCfg_Len)
def CheckCanCollectByNPCID(curPlayer, npcID, collectNPCIpyData):
    # 根据NPCID判断是否可以采集
    
@@ -5667,6 +5652,24 @@
        DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData)
    return
#// A2 34 自定义场景中获取采集奖励 #tagCMGetCustomSceneCollectAward
#
#struct    tagCMGetCustomSceneCollectAward
#{
#    tagHead        Head;
#    DWORD        NPCID;    //采集的NPCID
#};
def OnGetCustomSceneCollectAward(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    npcID = clientData.NPCID
    if not curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene):
        GameWorld.DebugLog("非自定义场景中,无法获取定义采集奖励!")
        return
    collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID)
    if collectNPCIpyData:
        DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData)
    return
def DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData, collectCnt=1):
    GameWorld.DebugLog("给采集奖励: npcID=%s,collectCnt=%s" % (npcID, collectCnt))
    if collectCnt <= 0:
@@ -5684,13 +5687,52 @@
        updCollTime = todayCollTime + collectCnt
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime)
        SyncCollNPCTime(curPlayer, [npcID])
        GameWorld.DebugLog("        增加当日采集次数: todayCollTime=%s,updCollTime=%s" % (todayCollTime, updCollTime))
    giveItemList = collectNPCIpyData.GetCollectAward()
    if giveItemList:
        itemID, itemCount, isAuctionItem = giveItemList
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
        GameWorld.DebugLog("        增加采集次数: todayCollTime=%s,updCollTime=%s" % (todayCollTime, updCollTime))
        
    awardIitemList = []
    collectAwardCfg = collectNPCIpyData.GetCollectAward()
    collectAppointAwardCfg = collectNPCIpyData.GetCollectAppointAward()
    if collectAppointAwardCfg:
        collTotalTime = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID) + 1, ChConfig.Def_UpperLimit_DWord)
        if collTotalTime in collectAppointAwardCfg:
            awardIitemList.append(collectAppointAwardCfg[collTotalTime])
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID, collTotalTime)
        #GameWorld.DebugLog("采集次数定制奖励: collTotalTime=%s,awardIitemList=%s" % (collTotalTime, awardIitemList))
    if not awardIitemList:
        alchemyDiffLV = collectNPCIpyData.GetAlchemyDiffLV()
        giveItemWeightList = []
        if alchemyDiffLV:
            curAlchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV)
            for itemInfo in collectAwardCfg:
                itemID = itemInfo[1][0]
                itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
                if not itemData:
                    continue
                if ItemCommon.GetItemClassLV(itemData) > curAlchemyLV + alchemyDiffLV:
                    continue
                giveItemWeightList.append(itemInfo)
        else:
            giveItemWeightList = collectAwardCfg
        giveItemInfo = GameWorld.GetResultByWeightList(giveItemWeightList)
        awardIitemList.append(giveItemInfo)
    if awardIitemList:
        for itemID, itemCount, isAuctionItem in awardIitemList:
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
        if collectNPCIpyData.GetNotifyCollectResult():
            awardPack = ChPyNetSendPack.tagMCCollectAwardItemInfo()
            awardPack.CollectNPCID = npcID
            for itemID, itemCount, isAuctionItem in awardIitemList:
                awardItem = ChPyNetSendPack.tagMCCollectAwardItem()
                awardItem.ItemID = itemID
                awardItem.Count = itemCount
                awardItem.IsAuctionItem = isAuctionItem
                awardPack.AwardItemList.append(awardItem)
            awardPack.Count = len(awardPack.AwardItemList)
            NetPackCommon.SendFakePack(curPlayer, awardPack)
    #采集成就
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, collectCnt, [npcID])
    #SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, giveItemInfoList, npcID)
@@ -5740,11 +5782,20 @@
def CollNPCTimeOnDay(curPlayer):
    ## 采集NPCOnDay处理
    DoResetCollectNPCTimeByType(curPlayer, 1)
    return
def DoResetCollectNPCTimeByType(curPlayer, resetTypeList=[]):
    '''重置采集物采集次数
            重置类型: 0-不重置,1-每日5点,12-灵草园重置,14-仙草园重置
    '''
    resetNPCIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for index in xrange(ipyDataMgr.GetCollectNPCCount()):
        ipyData = ipyDataMgr.GetCollectNPCByIndex(index)
        npcID = ipyData.GetNPCID()
        if resetTypeList and ipyData.GetCollectResetType() not in resetTypeList:
            continue
        if not ipyData.GetMaxCollectCount():
            continue
        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID):
@@ -5753,6 +5804,7 @@
        resetNPCIDList.append(npcID)
        
    if resetNPCIDList:
        #GameWorld.DebugLog("重置采集次数: resetTypeList=%s,resetNPCIDList=%s" % (resetTypeList, resetNPCIDList), curPlayer.GetPlayerID())
        SyncCollNPCTime(curPlayer, resetNPCIDList)
    return