hxp
2019-04-18 c562008bec642a25245295eeec567081bc4e4c42
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -51,6 +51,7 @@
import PlayerFairyCeremony
import PlayerNewFairyCeremony
import GameLogic_CrossDemonKing
import GameLogic_CrossGrassland
import PlayerWeekParty
import PlayerActLogin
import FamilyRobBoss
@@ -5675,31 +5676,34 @@
    if collectCnt <= 0:
        return
    
    isMaxTime = False # 是否达到了采集最大次数
    limitMaxTime = collectNPCIpyData.GetMaxCollectCount()
    if limitMaxTime > 0:
        todayCollTime = GetTodayCollectCount(curPlayer, npcID)
        canCollectCnt = max(0, limitMaxTime - todayCollTime)
        collectCnt = min(collectCnt, canCollectCnt)
        if collectCnt <= 0:
            GameWorld.DebugLog("    该NPC已达到最大采集次数: todayCollTime=%s,limitMaxTime=%s" % (todayCollTime, limitMaxTime))
            GameWorld.DebugLog("    该NPC已达到最大采集次数: npcID=%s,todayCollTime=%s,limitMaxTime=%s" % (npcID, todayCollTime, limitMaxTime))
            return
        
        updCollTime = todayCollTime + collectCnt
        curCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID)
        updCollTime = curCollTime + collectCnt
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime)
        SyncCollNPCTime(curPlayer, [npcID])
        GameWorld.DebugLog("        增加采集次数: todayCollTime=%s,updCollTime=%s" % (todayCollTime, updCollTime))
        GameWorld.DebugLog("        增加采集次数: npcID=%s,todayCollTime=%s,curCollTime=%s,updCollTime=%s" % (npcID, todayCollTime, curCollTime, updCollTime))
        isMaxTime = todayCollTime + collectCnt >= limitMaxTime
        
    awardIitemList = []
    awardItemList = []
    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])
            awardItemList.append(collectAppointAwardCfg[collTotalTime])
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID, collTotalTime)
        #GameWorld.DebugLog("采集次数定制奖励: collTotalTime=%s,awardIitemList=%s" % (collTotalTime, awardIitemList))
        #GameWorld.DebugLog("采集次数定制奖励: collTotalTime=%s,awardItemList=%s" % (collTotalTime, awardItemList))
        
    if not awardIitemList:
    if not awardItemList:
        alchemyDiffLV = collectNPCIpyData.GetAlchemyDiffLV()
        giveItemWeightList = []
        if alchemyDiffLV:
@@ -5716,15 +5720,15 @@
            giveItemWeightList = collectAwardCfg
            
        giveItemInfo = GameWorld.GetResultByWeightList(giveItemWeightList)
        awardIitemList.append(giveItemInfo)
        awardItemList.append(giveItemInfo)
        
    if awardIitemList:
        for itemID, itemCount, isAuctionItem in awardIitemList:
    if awardItemList:
        for itemID, itemCount, isAuctionItem in awardItemList:
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
        if collectNPCIpyData.GetNotifyCollectResult():
            awardPack = ChPyNetSendPack.tagMCCollectAwardItemInfo()
            awardPack.CollectNPCID = npcID
            for itemID, itemCount, isAuctionItem in awardIitemList:
            for itemID, itemCount, isAuctionItem in awardItemList:
                awardItem = ChPyNetSendPack.tagMCCollectAwardItem()
                awardItem.ItemID = itemID
                awardItem.Count = itemCount
@@ -5736,6 +5740,10 @@
    #采集成就
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, collectCnt, [npcID])
    #SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, giveItemInfoList, npcID)
    if isMaxTime:
        GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer)
    return
## 采集结果同步
@@ -6097,3 +6105,45 @@
    sendPack.Value = speed
    curNPC.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength())
    return
def UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount=0):
    ## 更新玩家攻击NPC次数
    GameWorld.DebugLog("更新玩家攻击NPC次数: npcID=%s,attackCount=%s,maxCount=%s" % (npcID, attackCount, maxCount))
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NPCAttackCount % npcID, attackCount)
    if GameWorld.IsCrossServer():
        serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
        msgInfo = {"PlayerID":curPlayer.GetPlayerID(), "NPCID":npcID, "AttackCount":attackCount, "MaxCount":maxCount}
        GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_NPCAttackCount, msgInfo, [serverGroupID])
    else:
        SyncNPCAttackCount(curPlayer, [npcID])
        if attackCount and attackCount >= maxCount:
            GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer)
    return
def CrossServerMsg_NPCAttackCount(curPlayer, msgData):
    ## 收到跨服服务器同步的攻击NPC次数
    npcID = msgData["NPCID"]
    attackCount = msgData["AttackCount"]
    maxCount = msgData["MaxCount"]
    UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount)
    return
def SyncNPCAttackCount(curPlayer, npcIDList):
    ## 同步NPC攻击次数
    if not npcIDList:
        return
    clientPack = ChPyNetSendPack.tagMCNPCAttackCountInfo()
    for npcID in npcIDList:
        attackCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NPCAttackCount % npcID)
        atkCountObj = ChPyNetSendPack.tagMCNPCAttackCount()
        atkCountObj.NPCID = npcID
        atkCountObj.AttackCount = attackCount
        clientPack.NPCAttackCountList.append(atkCountObj)
    clientPack.Count = len(clientPack.NPCAttackCountList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return