#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GameWorldLogic.FBProcess.GameLogic_CrossDemonKing
|
#
|
# @todo:¿ç·þÑýÍõ
|
# @author hxp
|
# @date 2019-04-11
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þÑýÍõ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2019-04-11 14:30"""
|
#-------------------------------------------------------------------------------
|
|
import FBCommon
|
import GameWorld
|
import IPY_GameWorld
|
import IpyGameDataPY
|
import ChConfig
|
import PyGameData
|
import NPCCommon
|
import ItemCommon
|
import ShareDefine
|
import PlayerSuccess
|
import PlayerActLogin
|
|
FBDict_StartTick = 'FBDict_StartTick%s' #¿ªÊ¼Ê±¼ä
|
FBDict_Speed = 'FBDict_Speed%s' #µôѪËÙ¶È /s
|
FBDict_RemainHP = 'FBDict_RemainHP%s' #Ê£Óàʱ¼ä
|
FBDict_IsOver = 'FBDict_IsOver' #ÊÇ·ñÒѽáËã, ½áËãʱµÄtick
|
FBDict_IsReduceing = 'FBDict_IsReduceing%s' #ÊÇ·ñµôѪÖÐ
|
FBDict_BossTotalHP = 'FBDict_BossTotalHP%s' #BOSSѪÁ¿£¬ÐèÒªµÄ×Üʱ¼ä
|
FBDict_LastHurtTick = 'FBDict_LastHurtTick' #ÉÏ´ÎÉ˺¦Ê±¼ä
|
|
g_heroHurtDict = {} #{playerID:hurt}
|
|
|
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
|
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
|
return True
|
|
## ²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼
|
def OnChangeMapAsk(ask, tick):
|
return IPY_GameWorld.cmeAccept
|
|
## ¿ªÆô¸±±¾
|
def OnOpenFB(tick):
|
lineID = GetCurFBFuncLineID()
|
killTime = 60
|
GameWorld.GetGameWorld().SetGameWorldDict(FBDict_BossTotalHP % lineID, killTime * 1000)
|
return
|
|
## ½ø¸±±¾
|
def DoEnterFB(curPlayer, tick):
|
playerID = curPlayer.GetPlayerID()
|
zoneID = GetCurFBLineZoneID()
|
funcLineID = GetCurFBFuncLineID()
|
GameWorld.DebugLog("DoEnterFB zoneID=%s,funcLineID=%s" % (zoneID, funcLineID), playerID)
|
return
|
|
## ¹Ø±Õ¸±±¾
|
def OnCloseFB(tick):
|
# gameWorld = GameWorld.GetGameWorld()
|
# lineID = gameWorld.GetPropertyID() - 1
|
# gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, 0)
|
# gameWorld.SetGameWorldDict(FBDict_Speed % lineID, 0)
|
# gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, 0)
|
#
|
# gameWorld.SetPropertyID(0)
|
return
|
|
## Íæ¼ÒÍ˳ö¸±±¾
|
def DoExitFB(curPlayer, tick):
|
UpdateHPReduceSpeed(tick, True)
|
return
|
|
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
|
def DoPlayerLeaveFB(curPlayer, tick):
|
# FBCommon.SetHadDelTicket(curPlayer, 0)
|
# #Ö÷¶¯Í˳öµÄÈ¥µôÅÅÐаñÐÅÏ¢
|
# lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
# playerHurtDict = PyGameData.g_ZhuXianBossPlayerHurtDict.get(lineID, {})
|
# playerHurtDict.pop(curPlayer.GetPlayerID(), 0)
|
# PyGameData.g_ZhuXianBossPlayerHurtDict[lineID] = playerHurtDict
|
# if not playerHurtDict: #°ñÉÏûÈË£¬Í£Ö¹µôѪ
|
# StopReduceHP(lineID, tick)
|
return
|
|
## ÊÇ·ñ¸±±¾¸´»î
|
def OnPlayerReborn():
|
return True
|
|
## »ñµÃ¸±±¾°ïÖúÐÅÏ¢
|
def DoFBHelp(curPlayer, tick):
|
|
if GameWorld.GetGameFB().GetGameFBDictByKey(FBDict_IsOver):
|
return
|
|
lineID = GetCurFBFuncLineID()
|
curSpeed = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_Speed % lineID)
|
isReduceing = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_IsReduceing % lineID)
|
remainHP = GetBossRemainHP(lineID, tick)
|
totalHP = __GetBossTotalHP(lineID)
|
hpReduceSpeed = curSpeed * 10000 / totalHP if totalHP else 0
|
remainHPPer = min(1000000, remainHP * 1000000 / totalHP) if totalHP else 0
|
fbHelpDict = {FBCommon.Help_lineID:lineID, 'hpReduceSpeed':hpReduceSpeed, 'remainHPPer':remainHPPer, 'isReduceing':isReduceing}
|
GameWorld.DebugLog("DoFBHelp: %s" % fbHelpDict, curPlayer.GetPlayerID())
|
FBCommon.Notify_FBHelp(curPlayer, fbHelpDict)
|
return
|
|
## Íæ¼Ò¶ÔNPCÔì³ÉÉ˺¦
|
def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP):
|
return
|
lineID = GetCurFBFuncLineID()
|
#ÓÐÈËÉϰñ¿ªÊ¼µôѪ
|
StartReduceHP(lineID, GameWorld.GetGameWorld().GetTick())
|
GameWorld.GetGameFB().SetGameFBDict(FBDict_LastHurtTick, GameWorld.GetGameWorld().GetTick())
|
return
|
|
##---¸±±¾×ÜÂß¼¼ÆÊ±Æ÷---
|
# @param tick:ʱ¼ä´Á
|
# @return ÎÞÒâÒå
|
# @remarks ¸±±¾×ÜÂß¼¼ÆÊ±Æ÷
|
def OnProcess(tick):
|
return
|
gameFB = GameWorld.GetGameFB()
|
overTick = gameFB.GetGameFBDictByKey(FBDict_IsOver)
|
# ½áËã20ÃëºóÇ¿ÖÆ¹Ø±Õ¸±±¾, ·ÀÖ¹Íæ¼Ò²»¼ñ¶«Î÷µ¼Ö²»½áË㣬ǿ¹ØºóµØ°åÉϵĶ«Î÷»áÓʼþ·¢·Å¸øÍæ¼Ò
|
if overTick and tick - overTick >= ChConfig.Def_FBPickupItemTime:
|
GameWorld.Log("Ç¿ÖÆÌß³öÍæ¼Ò¹Ø±Õ¸±±¾: overTick=%s,tick=%s" % (overTick, tick))
|
FBCommon.DoLogic_FBKickAllPlayer()
|
return
|
|
lineID = GetCurFBFuncLineID()
|
if lineID < 0:
|
return
|
gameWorld = GameWorld.GetGameWorld()
|
startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
|
if not startTick or overTick:
|
return
|
lastHurtTick = gameFB.GetGameFBDictByKey(FBDict_LastHurtTick)
|
if lastHurtTick and tick - lastHurtTick >= 2000:
|
StopReduceHP(lineID, tick)
|
GameWorld.GetGameFB().SetGameFBDict(FBDict_LastHurtTick, 0)
|
|
FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000)
|
__CheckBossHP(tick)
|
return
|
|
def __DoLogicZhuXianBossOver(isPass, tick, dropPosX, dropPosY):
|
#½áËã
|
# gameFB = GameWorld.GetGameFB()
|
# mapID = GameWorld.GetMap().GetMapID()
|
# lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
# leaveTick = FBCommon.GetFBLineStepTime(mapID, lineID) * 1000
|
# playerHurtList = __GetSortHurtList(lineID)
|
# if not playerHurtList:
|
# GameWorld.Log(' __DoLogicZhuXianBossOver£¬ É˺¦°ñÉÏûÓÐÈË£¡£¡lineID=%s' % lineID)
|
# return
|
# firsthurtInfo = playerHurtList[0]
|
# firstPlayerID = firsthurtInfo[0]
|
# firstPlayerFamilyID = firsthurtInfo[1][2]
|
# playerManager = GameWorld.GetMapCopyPlayerManager()#GameWorld.GetPlayerManager()
|
# firstPlayer = playerManager.FindPlayerByID(firstPlayerID)
|
# if firstPlayer:
|
# gameFB.SetPlayerGameFBDict(firstPlayerID, FBPlayerDict_Rank, 1)
|
# if not dropPosX or not dropPosY:
|
# dropPosX, dropPosY = firstPlayer.GetPosX(), firstPlayer.GetPosY()
|
# prizeItemList = GiveZhuXianBossAward(firstPlayer, lineID, dropItemMapInfo=[dropPosX, dropPosY, True, True])
|
# if not prizeItemList:
|
# # ûÓеôÂäʱֱ½Ó֪ͨ½áË㣬·ÀÖ¹¿¨¸±±¾
|
# firstPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True)
|
# overDict = {FBCommon.Over_rank:1, FBCommon.Over_itemInfo:prizeItemList}
|
# FBCommon.NotifyFBOver(firstPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict)
|
# else:
|
# firstPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, ChConfig.Def_FBPickupItemTime, True)
|
# else:
|
# leaveServerTick = PlayerControl.GetPlayerLeaveServerTick(firstPlayerID)
|
# if leaveServerTick and tick - leaveServerTick < ChConfig.Def_PlayerOfflineProtectTime:
|
# #ÀëÏß³¬¹ý3·ÖÖӵIJ»¸ø½±Àø
|
# msgStr = str([ShareDefine.Def_UniversalGameRecType_ZhuXianBossRecord, [firstPlayerID, lineID], [], 0, 0])
|
# GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'AddUniversalGameRec', msgStr, len(msgStr))
|
#
|
# helpItemList = FBCommon.GetFBLineReward(mapID, lineID)
|
# if helpItemList: #ͬÃËÐÖú½±Àø
|
# jsonItemList = FBCommon.GetJsonItemList(helpItemList)
|
# for index in range(0 , playerManager.GetPlayerCount()):
|
# curPlayer = playerManager.GetPlayerByIndex(index)
|
# curPlayerID = curPlayer.GetPlayerID()
|
# if not curPlayerID:
|
# continue
|
# if curPlayerID == firstPlayerID:
|
# continue
|
# curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True)
|
# remainCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt)
|
# if curPlayer.GetFamilyID() == firstPlayerFamilyID and remainCnt:
|
# PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ZhuXianBossHelpCnt, remainCnt - 1)
|
# ItemControler.GivePlayerItemOrMail(curPlayer, helpItemList, 'ZXBossHelperReward')
|
# overDict = {FBCommon.Over_rank:0, FBCommon.Over_itemInfo:jsonItemList}
|
# FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict)
|
# else:
|
# overDict = {FBCommon.Over_rank:0}
|
# FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, 0, overDict)
|
|
return
|
|
def GiveZhuXianBossAward(curPlayer, lineID, isMail=False, dropItemMapInfo=[]):
|
##¸ø¹éÊôÕß½±Àø
|
addCnt = 1
|
equipList = []
|
prizeItemDict = {}
|
bossID = GetCurFBLineBOSSID(lineID)
|
|
jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, {bossID:addCnt},
|
mailTypeKey="ZXBossBelongerReward", isMail=isMail,
|
dropItemMapInfo=dropItemMapInfo)
|
for jsonItem in jsonItemList:
|
if 'UserData' in jsonItem:
|
equipList.append(jsonItem)
|
else:
|
itemID, itemCnt = jsonItem['ItemID'], jsonItem.get('Count', 1)
|
prizeItemDict[itemID] = prizeItemDict.get(itemID, 0) + itemCnt
|
|
GameWorld.DebugLog("ÖïÏÉboss½áËã½±Àø: lineID=%s,bossID=%s,totalExp=%s,totalMoney=%s,jsonItemList=%s"
|
% (lineID, bossID, totalExp, totalMoney, jsonItemList), curPlayer.GetPlayerID())
|
|
prizeItemList = equipList + FBCommon.GetJsonItemList(prizeItemDict.items())
|
#PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ZhuXianBoss, addCnt)
|
|
#»÷É±ÌØ¶¨NPC³É¾Í
|
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillSpecificNPC, addCnt, [bossID])
|
FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, addCnt)
|
# ÿÈջ
|
#PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_ZhuXianBoss, addCnt)
|
PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_ZhuXianBOSS, addCnt)
|
return prizeItemList
|
|
def OnPickUpItem(curPlayer, curItem, tick):
|
mapItemType = curItem.GetType()
|
if mapItemType == ChConfig.Def_ItemType_Money:
|
return
|
playerID = curPlayer.GetID()
|
isEquip = ItemCommon.CheckItemIsEquip(curItem)
|
jsonItem = ItemCommon.GetJsonItem(curItem)
|
if playerID in PyGameData.g_fbPickUpItemDict:
|
if isEquip:
|
PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
|
else:
|
isIn = False
|
for itemInfo in PyGameData.g_fbPickUpItemDict[playerID]:
|
if itemInfo["ItemID"] == jsonItem["ItemID"] and itemInfo.get("IsBind") == jsonItem.get("IsBind"):
|
itemInfo["Count"] = itemInfo.get("Count", 1) + jsonItem.get("Count", 1)
|
isIn = True
|
break
|
if not isIn:
|
PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
|
else:
|
PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem]
|
|
playerItemCount = 0
|
mapItemManager = GameWorld.GetMapItemManager()
|
for index in xrange(mapItemManager.GetMapItemCount()):
|
mapItem = mapItemManager.GetMapItemByIndex(index)
|
if not mapItem or mapItem.IsEmpty():
|
continue
|
|
# »¹ÓÐÊôÓÚ×Ô¼ºµÄ¶«Î÷û¼ñ²»Í¨Öª½áÊø
|
if mapItem.GetOwnerID() == curPlayer.GetPlayerID():
|
playerItemCount += 1
|
|
isItemAllPickUp = (playerItemCount <= 1)
|
if not isItemAllPickUp:
|
return
|
|
isPass = 1
|
lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
leaveTick = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_ZhuXianBoss, lineID) * 1000
|
gameFB = GameWorld.GetGameFB()
|
rank = 1###gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_Rank)
|
|
jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, [])
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True)
|
overDict = {FBCommon.Over_rank:rank, FBCommon.Over_itemInfo:jsonItemList}
|
FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss, lineID, isPass, overDict)
|
return
|
|
|
def __CheckBossHP(tick):
|
gameFB = GameWorld.GetGameFB()
|
isOver = gameFB.GetGameFBDictByKey(FBDict_IsOver)
|
lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
|
if not isOver and GetBossRemainHP(lineID, tick) == 0:
|
|
bossID = GetCurFBLineBOSSID(lineID)
|
curBoss = GameWorld.FindNPCByNPCID(bossID)
|
dropPosX, dropPosY = 0, 0
|
if curBoss:
|
dropPosX, dropPosY = curBoss.GetPosX(), curBoss.GetPosY()
|
|
#½áÊø ÉèÖÃBOSSËÀÍö
|
FBCommon.ClearFBNPC()
|
FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
|
GameWorld.DebugLog('½áÊø ÉèÖÃBOSSËÀÍö lineID=%s' % lineID)
|
###playerHurtList = __GetSortHurtList(lineID)
|
playerHurtList = []
|
if playerHurtList:
|
killerName, hurtValue = playerHurtList[0][1][:2]
|
NPCCommon.GameServer_KillGameWorldBoss(bossID, killerName, hurtValue)
|
|
NPCCommon.GameServe_GameWorldBossState(bossID, 0)
|
|
###__DoLogicZhuXianBossOver(1, tick, dropPosX, dropPosY)
|
gameFB.SetGameFBDict(FBDict_IsOver, tick)
|
return
|
|
def UpdateHPReduceSpeed(tick, isExit=False):
|
gameWorld = GameWorld.GetGameWorld()
|
playerCnt = gameWorld.GetMapCopyPlayerManager().GetPlayerCount()
|
playerCnt = playerCnt - 1 if isExit else playerCnt
|
if playerCnt <= 0:
|
return
|
lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
if lineID < 0:
|
return
|
|
curSpeed = int(min(1 + 0.08 * (playerCnt - 1), 1.8) * 1000)
|
gameWorld.SetGameWorldDict(FBDict_Speed % lineID, curSpeed)
|
if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing % lineID):
|
return
|
|
startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
|
remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID)
|
lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID)
|
if not startTick:
|
startTick = tick
|
lastSpeed = curSpeed
|
remainHP = __GetBossTotalHP(lineID)
|
remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
|
gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, tick)
|
|
gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, remainHP)
|
GameWorld.DebugLog(' curSpeed=%s, remainHP=%s, passTime=%s, lastSpeed=%s' % (curSpeed, remainHP, tick - startTick, lastSpeed))
|
FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
|
return
|
|
def StopReduceHP(lineID, tick):
|
##ÔÝÍ£BOSSѪÁ¿¼õÉÙ
|
gameWorld = GameWorld.GetGameWorld()
|
if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing % lineID):
|
return
|
remainHP = GetBossRemainHP(lineID, tick)
|
if not remainHP:
|
return
|
gameWorld.SetGameWorldDict(FBDict_IsReduceing % lineID, 0)
|
gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, remainHP)
|
return
|
|
def StartReduceHP(lineID, tick):
|
##¿ªÊ¼BOSSµôѪ
|
gameWorld = GameWorld.GetGameWorld()
|
if gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing % lineID):
|
return
|
gameWorld.SetGameWorldDict(FBDict_IsReduceing % lineID, 1)
|
startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
|
if not startTick:
|
gameWorld.SetGameWorldDict(FBDict_RemainHP % lineID, __GetBossTotalHP(lineID))
|
gameWorld.SetGameWorldDict(FBDict_StartTick % lineID, tick)
|
FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
|
return
|
|
def __GetBossTotalHP(lineID):return GameWorld.GetGameWorld().GetGameWorldDictByKey(FBDict_BossTotalHP % lineID)
|
|
def GetBossRemainHP(lineID, tick):
|
gameWorld = GameWorld.GetGameWorld()
|
|
startTick = gameWorld.GetGameWorldDictByKey(FBDict_StartTick % lineID)
|
lastSpeed = gameWorld.GetGameWorldDictByKey(FBDict_Speed % lineID)
|
remainHP = gameWorld.GetGameWorldDictByKey(FBDict_RemainHP % lineID)
|
if not gameWorld.GetGameWorldDictByKey(FBDict_IsReduceing % lineID):
|
return remainHP
|
if not startTick:
|
startTick = tick
|
remainHP = __GetBossTotalHP(lineID)
|
else:
|
remainHP = max(0, int((remainHP - (tick - startTick) / 1000.0 * lastSpeed)))
|
return remainHP
|
|
def GetCurFBLineBOSSID(lineID= -1):
|
#¸Ã·ÖÏßË¢µÄBOSSID
|
if lineID == -1:
|
lineID = GameWorld.GetGameWorld().GetPropertyID() - 1
|
if lineID == -1:
|
return 0
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":ChConfig.Def_FBMapID_CrossDemonKing, "LineID":lineID})
|
if not ipyData:
|
return 0
|
bossID = ipyData.GetBossID()
|
return bossID
|
|
def GetCurFBFuncLineID(): return GameWorld.GetGameWorld().GetPropertyID() % 1000
|
def GetCurFBLineZoneID(): return GameWorld.GetGameWorld().GetPropertyID() / 1000
|
|
##Íæ¼ÒËÀÍö.
|
# @param curPlayer:ËÀÍöµÄÍæ¼Ò
|
# @param tick ʱ¼ä´Á
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
|
def DoPlayerDead(curPlayer):
|
return
|
|
##´¦Àí¸±±¾ÖÐɱËÀÍæ¼ÒÂß¼
|
def DoFBOnKill_Player(atkobj, defender, tick):
|
return True
|