| | |
| | | import PlayerControl
|
| | | import ShareDefine
|
| | | import PyGameData
|
| | | import NPCCommon
|
| | | import ChConfig
|
| | | import ChItem
|
| | |
|
| | | FBDict_IsOver = 'FBDict_IsOver' #是否已结算, 结算时的tick
|
| | | FBDict_IsPlayerOver = 'IsPlayerOver_%s' #玩家是否已经结算掉落的,参数playerID
|
| | |
|
| | | g_ownerInfo = {} # 归属者信息 {funcLineID:[ownerID, ownerName], }
|
| | |
|
| | | def __SetDemonKingVisitState(curPlayer, mapID, lineID, state):
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
|
| | | if not ipyData:
|
| | | return False
|
| | | eventID = ipyData.GetID()
|
| | | if not PlayerFairyDomain.SetFairyDomainEventState(curPlayer, eventID, state):
|
| | | return False
|
| | | return True
|
| | | ## 是否需要做进入副本通用检查条件逻辑,默认需要检查
|
| | | def OnNeedCheckCanEnterFBComm(curPlayer, mapID, lineID):
|
| | | curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
|
| | | return curState != PlayerFairyDomain.FDEventState_Visiting
|
| | |
|
| | | ## 是否能够通过活动查询进入
|
| | | def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
|
| | | if not __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting):
|
| | | return False
|
| | | return True
|
| | | curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
|
| | | return curState in [PlayerFairyDomain.FDEventState_CanVisit, PlayerFairyDomain.FDEventState_Visiting]
|
| | |
|
| | | ## 查询是否可以进入地图
|
| | | def OnChangeMapAsk(ask, tick):
|
| | | return IPY_GameWorld.cmeAccept
|
| | | ## 进入跨服副本注册数据前逻辑
|
| | | ## @return: 是否可以注册前往跨服副本,次函数中可以写一些扣除消耗逻辑等
|
| | | def OnRegEnterCrossFB(curPlayer, mapID, lineID):
|
| | | curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
|
| | | if curState == PlayerFairyDomain.FDEventState_CanVisit:
|
| | | return PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting)
|
| | | |
| | | if curState == PlayerFairyDomain.FDEventState_Visiting:
|
| | | return True
|
| | | |
| | | return False
|
| | |
|
| | | ## 开启副本
|
| | | def OnOpenFB(tick):
|
| | | return
|
| | |
|
| | | ## 副本玩家进入点
|
| | | # @return posX, posY, 随机半径(可选)
|
| | | def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
|
| | | return ipyEnterPosInfo
|
| | |
|
| | | def GetCurFBLineBOSSID(lineID=-1):
|
| | | def GetCurFBLineBOSSID(mapID=-1, lineID=-1):
|
| | | #该分线刷的BOSSID
|
| | | if mapID == -1:
|
| | | mapID = ChConfig.Def_FBMapID_CrossDemonKing if GameWorld.IsCrossServer() else ChConfig.Def_FBMapID_DemonKing
|
| | | if lineID == -1:
|
| | | lineID = GetCurFBFuncLineID()
|
| | | if lineID == -1:
|
| | | if mapID == -1 or lineID == -1:
|
| | | return 0
|
| | | mapID = ChConfig.Def_FBMapID_CrossDemonKing if GameWorld.IsCrossServer() else ChConfig.Def_FBMapID_DemonKing
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
|
| | | if not ipyData:
|
| | | return 0
|
| | |
| | | def GetCurFBFuncLineID():
|
| | | ## 获取本线路功能线路ID
|
| | | if GameWorld.IsCrossServer():
|
| | | return GameWorld.GetGameWorld().GetPropertyID() % 1000
|
| | | return FBCommon.GetCrossDynamicLineMapFuncLineID()
|
| | | return GameWorld.GetGameWorld().GetPropertyID() - 1
|
| | |
|
| | | def GetCurFBLineZoneID():
|
| | | ## 获取本线路所属跨服分区
|
| | | if GameWorld.IsCrossServer():
|
| | | return GameWorld.GetGameWorld().GetPropertyID() / 1000
|
| | | return FBCommon.GetCrossDynamicLineMapZoneID()
|
| | | return 0
|
| | |
|
| | | ## 进副本
|
| | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | zoneID = GetCurFBLineZoneID()
|
| | | funcLineID = GetCurFBFuncLineID()
|
| | | bossID = GetCurFBLineBOSSID(funcLineID)
|
| | | visitCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
| | | GameWorld.Log("DoEnterFB zoneID=%s,funcLineID=%s,bossID=%s,visitCount=%s" % (zoneID, funcLineID, bossID, visitCount), playerID)
|
| | | bossID = GetCurFBLineBOSSID(lineID=funcLineID)
|
| | | GameWorld.Log("DoEnterFB zoneID=%s,funcLineID=%s,bossID=%s" % (zoneID, funcLineID, bossID), playerID)
|
| | | PyGameData.g_fbPickUpItemDict.pop(playerID, 0)
|
| | | if not GameWorld.IsCrossServer():
|
| | | PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, ChConfig.Def_FBMapID_DemonKing, funcLineID, PlayerFairyDomain.FDEventState_Visiting)
|
| | | |
| | | gameFB = GameWorld.GetGameFB()
|
| | | ## 副本已经结束,但是没有结算掉落的玩家直接通知结束
|
| | | if gameFB.GetGameFBDictByKey(FBDict_IsOver) and not gameFB.GetGameFBDictByKey(FBDict_IsPlayerOver % playerID):
|
| | | __NotifyFBOver(curPlayer, 0)
|
| | | return
|
| | |
|
| | | ## 副本总逻辑计时器
|
| | |
| | |
|
| | | ## 关闭副本
|
| | | def OnCloseFB(tick):
|
| | | global g_ownerInfo
|
| | | funcLineID = GetCurFBFuncLineID()
|
| | | g_ownerInfo.pop(funcLineID, None)
|
| | | GameWorld.GetGameWorld().SetPropertyID(0)
|
| | |
| | |
|
| | | ## 执行副本杀怪逻辑
|
| | | def __FBNPCOnKilled(curNPC, tick):
|
| | | global g_ownerInfo
|
| | | |
| | | bossID = curNPC.GetNPCID()
|
| | | funcLineID = GetCurFBFuncLineID()
|
| | | if bossID != GetCurFBLineBOSSID(funcLineID):
|
| | | if bossID != GetCurFBLineBOSSID(lineID=funcLineID):
|
| | | return
|
| | |
|
| | | zoneID = GetCurFBLineZoneID()
|
| | |
| | | if not curPlayer:
|
| | | continue
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | gameFB.SetGameFBDict(FBDict_IsPlayerOver % playerID, 1)
|
| | | isOwner = playerID == ownerID
|
| | | if isOwner:
|
| | | ownerName = curPlayer.GetPlayerName()
|
| | | giveItemList = __GetDemonKingPrizeItemList(curPlayer, mapID, funcLineID, eventID, isOwner)
|
| | | GameWorld.Log("玩家奖励: %s" % giveItemList, playerID)
|
| | | ChItem.DropItem(curPlayer, giveItemList, bossID, dropPosX, dropPosY, isOnlySelfSee=True, isDropDisperse=True)
|
| | | ChItem.DoMapDropItem(curPlayer, giveItemList, bossID, dropPosX, dropPosY, isOnlySelfSee=True, isDropDisperse=True)
|
| | | #curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, ChConfig.Def_FBPickupItemTime, True)
|
| | | if not isCrossServer:
|
| | | __SetDemonKingVisitState(curPlayer, mapID, funcLineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, funcLineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | else:
|
| | | serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
| | | if serverGroupID not in serverGroupIDList:
|
| | |
| | |
|
| | | ## 结束跨服副本
|
| | | def OnEndCrossFB(curPlayer, mapID, lineID, exData):
|
| | | __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | return
|
| | |
|
| | | def OnPickUpItem(curPlayer, curItem, tick):
|
| | |
| | | if not isItemAllPickUp:
|
| | | return
|
| | |
|
| | | isPass = 1
|
| | | __NotifyFBOver(curPlayer, 1)
|
| | | return
|
| | |
|
| | | def __NotifyFBOver(curPlayer, isPass):
|
| | | global g_ownerInfo
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | mapID = ChConfig.Def_FBMapID_CrossDemonKing if GameWorld.IsCrossServer() else ChConfig.Def_FBMapID_DemonKing
|
| | | funcLineID = GetCurFBFuncLineID()
|
| | | leaveTick = FBCommon.GetFBLineStepTime(mapID, funcLineID) * 1000
|
| | | ownerID, ownerName = g_ownerInfo.pop(funcLineID, [0, ""])
|
| | | ownerID, ownerName = g_ownerInfo.get(funcLineID, [0, ""])
|
| | | jsonItemList = PyGameData.g_fbPickUpItemDict.pop(playerID, [])
|
| | | overDict = {FBCommon.Over_ownerID:ownerID, FBCommon.Over_ownerName:ownerName, FBCommon.Over_itemInfo:jsonItemList}
|
| | | FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isPass, overDict)
|
| | |
| | |
|
| | | ## 客户端进入自定义场景
|
| | | def OnEnterCustomScene(curPlayer, mapID, lineID):
|
| | | __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting)
|
| | | PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting)
|
| | | return
|
| | |
|
| | | ## 客户端发送刷新自定义副本奖励
|
| | | def OnRefreshCustomFBPrize(curPlayer, mapID, lineID):
|
| | | visitCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
|
| | | fakeImmortalCount = IpyGameDataPY.GetFuncCfg("FakeImmortalCount", 1)
|
| | | if visitCount > fakeImmortalCount:
|
| | | GameWorld.DebugLog("当前寻访次数不能获取自定义副本奖励!visitCount=%s" % visitCount)
|
| | | return []
|
| | | if not __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting):
|
| | | GameWorld.DebugLog("寻访状态异常不能获取自定义副本奖励!")
|
| | | return []
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
|
| | | ## 自定义场景副本击杀NPC
|
| | | def DoCustomScene_Player_KillNPC(curPlayer, curNPC, mapID, lineID):
|
| | | |
| | | bossID = curNPC.GetNPCID()
|
| | | funcLineID = lineID
|
| | | curBossID = GetCurFBLineBOSSID(lineID=funcLineID)
|
| | | curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
|
| | | GameWorld.DebugLog("自定义场景击杀NPC: mapID=%s,lineID=%s,bossID=%s,curBossID=%s,eventState=%s" |
| | | % (mapID, lineID, bossID, curBossID, curState))
|
| | | if bossID != curBossID:
|
| | | return
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":funcLineID})
|
| | | if not ipyData:
|
| | | return []
|
| | | return
|
| | | eventID = ipyData.GetID()
|
| | | eventFBType = ipyData.GetEventFBType()
|
| | | if eventFBType != PlayerFairyDomain.FDEventFBType_Client:
|
| | | GameWorld.DebugLog(" 非前端本,不能掉落!", playerID)
|
| | | return
|
| | | if curState != PlayerFairyDomain.FDEventState_Visiting:
|
| | | GameWorld.DebugLog(" 非寻访中,不能掉落!", playerID)
|
| | | return
|
| | | PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, funcLineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | PlayerControl.SetCustomMap(curPlayer, 0, 0)
|
| | | |
| | | isOwner = True
|
| | | giveItemList = __GetDemonKingPrizeItemList(curPlayer, mapID, lineID, eventID, isOwner)
|
| | | return giveItemList
|
| | |
|
| | | ## 给自定义副本奖励后续处理
|
| | | def OnGiveCustomFBPrizeOK(curPlayer, mapID, lineID):
|
| | | __SetDemonKingVisitState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visited)
|
| | | giveItemList = __GetDemonKingPrizeItemList(curPlayer, mapID, funcLineID, eventID, isOwner)
|
| | | NPCCommon.DoGiveItemByVirtualDrop(curPlayer, giveItemList, bossID)
|
| | | |
| | | isPass = 1
|
| | | overDict = {FBCommon.Over_ownerID:playerID, FBCommon.Over_ownerName:curPlayer.GetPlayerName(), |
| | | FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)}
|
| | | FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
| | | return
|
| | |
|
| | | def __GetDemonKingPrizeItemList(curPlayer, mapID, lineID, eventID, isOwner):
|
| | |
| | | return giveItemList
|
| | |
|
| | | # 没有定制奖励则取常规奖励
|
| | | # {物品ID:[归属者获得个数饼图[[概率, 个数], ...], 非归属者获得个数饼图[[概率, 个数], ...], 是否拍品], ...}
|
| | | # [[归属者随机次数, 非归属随机次数, [[权重,[物品ID,个数,是否拍品]], ...]], ...]
|
| | | |
| | | giveItemList = []
|
| | | awardDict = FBCommon.GetFBLineReward(mapID, lineID)
|
| | | for itemID, itemInfo in awardDict.items():
|
| | | ownerCountRateList, notOwnerCountRateList, isAuctionItem = itemInfo
|
| | | awardList = FBCommon.GetFBLineReward(mapID, lineID)
|
| | | for awardInfo in awardList:
|
| | | ownerCount, otherCount, itemWeightList = awardInfo
|
| | | if isOwner:
|
| | | itemCount = GameWorld.GetResultByRandomList(ownerCountRateList)
|
| | | if not ownerCount:
|
| | | continue
|
| | | randCount = ownerCount
|
| | | else:
|
| | | itemCount = GameWorld.GetResultByRandomList(notOwnerCountRateList)
|
| | | if not itemCount:
|
| | | if not otherCount:
|
| | | continue
|
| | | randCount = otherCount
|
| | | realWeightList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, itemWeightList, 1)
|
| | | if not realWeightList:
|
| | | continue
|
| | | giveItemList.append([itemID, itemCount, isAuctionItem])
|
| | |
|
| | | for _ in xrange(randCount):
|
| | | itemInfo = GameWorld.GetResultByWeightList(realWeightList)
|
| | | itemID, itemCount, isAuctionItem = itemInfo
|
| | | if not itemID:
|
| | | continue
|
| | | giveItemList.append([itemID, itemCount, isAuctionItem])
|
| | | |
| | | return giveItemList
|
| | |
|
| | |
|