#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_FamilyBoss # # @todo:Õ½ÃËboss¸±±¾/ÏÉÃËÊÔÁ¶ # @author hxp # @date 2023-09-29 # @version 1.0 # # ÏêϸÃèÊö: Õ½ÃËboss¸±±¾/ÏÉÃËÊÔÁ¶ # #------------------------------------------------------------------------------- #"""Version = 2023-09-29 02:00""" #------------------------------------------------------------------------------- import FBCommon import GameWorld import IPY_GameWorld import PlayerControl import NPCCustomRefresh import ChPyNetSendPack import ItemControler import NetPackCommon import IpyGameDataPY import SkillCommon import PyGameData import BuffSkill import ChConfig #µ±Ç°¸±±¾µØÍ¼µÄ״̬ ( FB_Step_Open, # µØÍ¼¿ªÆô FB_Step_MapPrepare, # µØÍ¼×¼±¸ FB_Step_Fighting, # Õ½¶·ÖÐ FB_Step_LeaveTime, # ×ÔÓÉʱ¼ä FB_Step_Over, # ¸±±¾¹Ø±Õ ) = range(5) class BattlePlayer(): def __init__(self, playerID): self.playerID = playerID self.hurtValue = 0 # µ±Ç°ÀÛ¼ÆÉ˺¦ self.hurtValueLast = 0 # ÉÏ´Îͬ²½½áËãʱÉ˺¦ self.fightTickTotal = 0 # ÀÛ¼ÆÕ½¶·tick self.statsTick = 0 # ͳ¼Ætick return def onEnter(self, curPlayer, tick): hurtValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValue) hurtValuePoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValuePoint) self.hurtValue = hurtValuePoint * ChConfig.Def_PerPointValue + hurtValue self.hurtValueLast = self.hurtValue self.fightTickTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossFightSeconds) * 1000 self.statsTick = tick return def OnFBPlayerOnLogin(curPlayer): SyncFamilyBossPlayerInfo(curPlayer) return def OnFBPlayerOnDay(curPlayer): playerID = curPlayer.GetPlayerID() hurtValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValue) hurtValuePoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValuePoint) hurtValueTotal = hurtValuePoint * ChConfig.Def_PerPointValue + hurtValue rewardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAward) #ÏÉÃËÉËѪ½±ÀøGameServer´¦Àí²¹·¢ #GameWorld.DebugLog("ÏÉÃËbossÉËѪ¹ýÌì. hurtValueTotal=%s,rewardRecord=%s" % (hurtValueTotal, rewardRecord), playerID) ipyDataMgr = IpyGameDataPY.IPY_Data() for index in range(ipyDataMgr.GetFamilyBossHurtAwardCount()): ipyData = ipyDataMgr.GetFamilyBossHurtAwardByIndex(index) if ipyData.GetAwardType() != 1: continue needHurtTotal = ipyData.GetNeedHurtTotal() if hurtValueTotal < needHurtTotal: #GameWorld.DebugLog(" ÉËѪ²»×㣬²»²¹·¢¸Ã½±Àø! needHurtTotal=%s" % needHurtTotal, playerID) continue recordIndex = ipyData.GetRecordIndex() if rewardRecord & pow(2, recordIndex): #GameWorld.DebugLog(" ¸Ã¸öÈ˽±ÀøÒÑÁì½±! recordIndex=%s,rewardRecord=%s" % (recordIndex, rewardRecord), playerID) continue paramList = [needHurtTotal] awardItemList = ipyData.GetAwardItemList() PlayerControl.SendMailByKey("FamilyBossHurtAward", [playerID], awardItemList, paramList) #GameWorld.DebugLog(" Óʼþ²¹·¢ÉËѪ½±Àø! recordIndex=%s" % recordIndex, playerID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtValue, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtValuePoint, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossFightSeconds, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtAward, 0) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtAwardFamily, 0) SyncFamilyBossPlayerInfo(curPlayer) return def GetBattlePlayer(playerID): if playerID in PyGameData.g_familyBossHurtPlayerDict: batPlayer = PyGameData.g_familyBossHurtPlayerDict[playerID] else: batPlayer = BattlePlayer(playerID) PyGameData.g_familyBossHurtPlayerDict[playerID] = batPlayer return batPlayer def OnOpenFB(tick): return def OnCloseFB(tick): GameWorld.GetGameWorld().SetPropertyID(0) FBCommon.DoLogic_FBKickAllPlayer() return def OnEnterFBEvent(curPlayer, mapID, lineID, tick): if curPlayer.GetFamilyID() <= 0: GameWorld.DebugLog("ûÓÐÕ½ÃË£¬²»ÄܽøÈëÕ½ÃËboss¸±±¾£¡", curPlayer.GetPlayerID()) return False playerID = curPlayer.GetPlayerID() fightSeconds = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossFightSeconds) # ÒÑÕ½¶·Ê±³¤ fightSecondsMax = IpyGameDataPY.GetFuncCfg("FamilyBossFB", 1) if fightSeconds >= fightSecondsMax: GameWorld.DebugLog("ÒѾ­´ïµ½ÏÉÃËbossÕ½¶·Ê±³¤ÉÏÏÞ£¬ÎÞ·¨½øÈë. fightSeconds=%s" % fightSeconds, playerID) return False return True def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick): return ipyEnterPosInfo def OnChangeMapAsk(ask, tick): return IPY_GameWorld.cmeAccept def DoEnterFB(curPlayer, tick): playerID = curPlayer.GetPlayerID() gameFB = GameWorld.GetGameFB() fbStep = gameFB.GetFBStep() batPlayer = GetBattlePlayer(playerID) batPlayer.onEnter(curPlayer, tick) GameWorld.DebugLog("DoEnterFB: fbStep=%s,fightTickTotal=%s,hurtValue=%s" % (fbStep, batPlayer.fightTickTotal, batPlayer.hurtValue), playerID) fightSecondsMax = IpyGameDataPY.GetFuncCfg("FamilyBossFB", 1) remainTick = fightSecondsMax * 1000 - batPlayer.fightTickTotal if remainTick <= 0: PlayerControl.PlayerLeaveFB(curPlayer) return if fbStep != FB_Step_Fighting: __SetFBToFight(tick) curPlayer.Sync_TimeTick(IPY_GameWorld.tttAddUpTime, 0, remainTick, True)\ statsFBMemberHurt(tick, 1) return def __SetFBToFight(tick): FBCommon.SetFBStep(FB_Step_Fighting, tick) refreshMark, bossID = FBCommon.GetFBLineRefreshNPC(ChConfig.Def_FBMapID_FamilyBossMap, 0) if not GameWorld.FindNPCByNPCID(bossID): NPCCustomRefresh.SetNPCRefresh(refreshMark, [bossID]) return ##¸±±¾¶¨Ê±Æ÷ # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks ¸±±¾¶¨Ê±Æ÷ def OnProcess(tick): fbStep = GameWorld.GetGameFB().GetFBStep() if fbStep == FB_Step_Fighting: __DoLogic_MapFighting(tick) return def __DoLogic_MapFighting(tick): gameFB = GameWorld.GetGameFB() lastTick = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NotifyFBHelpTick) if tick - lastTick < 5000: return gameFB.SetGameFBDict(ChConfig.Def_FB_NotifyFBHelpTick, tick) statsFBMemberHurt(tick) return def statsFBMemberHurt(tick, statsType=0, exitPlayerID=0): ## ͳ¼Æ¸±±¾ÏÉÃ˳ÉÔ±É˺¦ # statsType 0-³£¹æ£»1-Íæ¼Ò½øÈ룻2-Íæ¼ÒÍ˳ö fightMemCount = 0 familyID = GameWorld.GetGameWorld().GetPropertyID() playerManager = GameWorld.GetMapCopyPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not curPlayer: continue playerID = curPlayer.GetPlayerID() if playerID != exitPlayerID: fightMemCount += 1 needMemCount, skillTypeID = IpyGameDataPY.GetFuncEvalCfg("FamilyBossFB", 2) fightSecondsMax = IpyGameDataPY.GetFuncCfg("FamilyBossFB", 1) addFamilyHurt = 0 for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if not curPlayer: continue playerID = curPlayer.GetPlayerID() batPlayer = GetBattlePlayer(playerID) if not batPlayer.statsTick: GameWorld.Log("ÏÉÃËÍæ¼Òδ³õʼ»¯Íê±Ï£¬²»Í³¼Æ!", playerID) continue hurtValue = batPlayer.hurtValue addHurtValue = max(0, hurtValue - batPlayer.hurtValueLast) batPlayer.hurtValueLast = hurtValue passTick = tick - batPlayer.statsTick if passTick > 0: batPlayer.fightTickTotal += passTick batPlayer.statsTick = tick fightSeconds = batPlayer.fightTickTotal / 1000 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtValue, hurtValue % ChConfig.Def_PerPointValue) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtValuePoint, hurtValue / ChConfig.Def_PerPointValue) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossFightSeconds, fightSeconds) addFamilyHurt += addHurtValue #GameWorld.DebugLog("ÏÉÃËÍæ¼ÒÉËѪͳ¼Æ: fightSeconds=%s,hurtValue=%s,addHurtValue=%s, %s" % (fightSeconds, hurtValue, addHurtValue, addFamilyHurt), playerID) # °ïÖúÐÅÏ¢ helpDict = {"hurtValue":hurtValue, "fightSeconds":fightSeconds, "fightMemCount":fightMemCount} FBCommon.Notify_FBHelp(curPlayer, helpDict) if playerID == exitPlayerID: batPlayer.statsTick = 0 BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick) SyncFamilyBossPlayerInfo(curPlayer) elif fightSeconds >= fightSecondsMax: GameWorld.DebugLog(" ûÓÐÕ½¶·Ê±³¤ÁË£¬Ìß³ö¸±±¾", playerID) PlayerControl.PlayerLeaveFB(curPlayer) else: # ´¦Àíbuff __parseFightBuff(curPlayer, fightMemCount, needMemCount, skillTypeID, tick) SendGameServer("FBMemberHurt", [statsType, familyID, fightMemCount, addFamilyHurt]) return def __parseFightBuff(curPlayer, fightMemCount, needMemCount, skillTypeID, tick): if fightMemCount < needMemCount: #GameWorld.DebugLog(" ÈËÊý²»×ãÕ½¶·buff", curPlayer.GetPlayerID()) BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick) return skillLV = fightMemCount - needMemCount + 1 findBuff = SkillCommon.FindBuffByID(curPlayer, skillTypeID)[0] if findBuff and findBuff.GetSkill().GetSkillLV() == skillLV: #GameWorld.DebugLog(" Õ½¶·buffµÈ¼¶²»±ä.skillTypeID=%s,skillLV=%s" % (skillTypeID, skillLV), curPlayer.GetPlayerID()) return #GameWorld.DebugLog(" Õ½¶·buffµÈ¼¶¸Ä±ä.skillTypeID=%s,skillLV=%s" % (skillTypeID, skillLV), curPlayer.GetPlayerID()) BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick) SkillCommon.AddBuffBySkillType(curPlayer, skillTypeID, tick, skillLV) return def OnEnterFamily(curPlayer): #½øÈëÏÉÃËʱ²¹Í¬²½Á콱״̬µ½GameServer SendGameServer_FamilyHurtAwardStateFamily(curPlayer) return def SendGameServer_FamilyHurtAwardStateFamily(curPlayer): playerID = curPlayer.GetPlayerID() familyID = curPlayer.GetFamilyID() hurtAwardStateFamily = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAwardFamily) SendGameServer("FamilyHurtAwardStateFamily", [familyID, playerID, hurtAwardStateFamily]) return ##Íæ¼ÒÍ˳ö¸±±¾ def DoExitFB(curPlayer, tick): statsFBMemberHurt(tick, 2, curPlayer.GetPlayerID()) return ##Íæ¼ÒÖ÷¶¯À뿪¸±±¾. def DoPlayerLeaveFB(curPlayer, tick): return ## Íæ¼Ò¶ÔNPCÔì³ÉÉ˺¦ def DoFB_Player_HurtNPC(curPlayer, curNPC, hurtHP): familyID = curPlayer.GetFamilyID() if not familyID: return bossID = FBCommon.GetFBLineRefreshNPC(ChConfig.Def_FBMapID_FamilyBossMap, 0)[1] if bossID != curNPC.GetNPCID(): return playerID = curPlayer.GetPlayerID() batPlayer = GetBattlePlayer(playerID) batPlayer.hurtValue += hurtHP #GameWorld.DebugLog("Ôö¼ÓÉËѪ: familyID=%s,hurtHP=%s, %s" % (familyID, hurtHP, batPlayer.hurtValue), playerID) return ## ÊÇ·ñ¸±±¾¸´»î def OnPlayerReborn(): return True def OnResetFBRebornPlacePos(curPlayer, rebornPlace, tick): ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(ChConfig.Def_FBMapID_FamilyBossMap, 0) posX, posY = ipyEnterPosInfo[:2] curPlayer.ResetPos(posX, posY) return def CheckCanAttackTagObjInFB(attacker, defender): gameFB = GameWorld.GetGameFB() if gameFB.GetFBStep() != FB_Step_Fighting: return False return True def GetFamilyBossHurtAward(curPlayer, awardType, awardIndex): ## awardType 1-¸öÈË£»2-ÏÉÃË awardIndex = GameWorld.ToIntDef(awardIndex) playerID = curPlayer.GetPlayerID() ipyData = IpyGameDataPY.GetIpyGameData("FamilyBossHurtAward", awardType, awardIndex) if not ipyData: return needHurtTotal = ipyData.GetNeedHurtTotal() awardItemList = ipyData.GetAwardItemList() familyID = curPlayer.GetFamilyID() if awardType == 2: if not familyID: return rewardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAwardFamily) if rewardRecord & pow(2, awardIndex): GameWorld.DebugLog("ÏÉÃËbossÉËѪÏÉÃ˽±ÀøÒÑÁì½±!awardIndex=%s,rewardRecord=%s" % (awardIndex, rewardRecord), playerID) return SendGameServer("FamilyHurtAwardReq", [familyID, awardType, awardIndex, needHurtTotal, awardItemList], playerID) return hurtValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValue) hurtValuePoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValuePoint) hurtValueTotal = hurtValuePoint * ChConfig.Def_PerPointValue + hurtValue if hurtValueTotal < needHurtTotal: GameWorld.DebugLog("ÏÉÃËbossÉËѪ¸öÈ˽±ÀøÉËѪ²»×ã²»ÄÜÁìÈ¡: awardIndex=%s,hurtValueTotal=%s < %s" % (awardIndex, hurtValueTotal, needHurtTotal), playerID) return rewardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAward) if rewardRecord & pow(2, awardIndex): GameWorld.DebugLog("ÏÉÃËbossÉËѪ¸öÈ˽±ÀøÒÑÁì½±!awardIndex=%s,rewardRecord=%s" % (awardIndex, rewardRecord), playerID) return updRewardRecord = rewardRecord | pow(2, awardIndex) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtAward, updRewardRecord) GameWorld.DebugLog("ÏÉÃËbossÉËѪÏÉÃ˽±Àø·¢·Å: familyID=%s,awardType=%s,awardIndex=%s,updRewardRecord=%s,awardItemList=%s" % (familyID, awardType, awardIndex, updRewardRecord, awardItemList), playerID) event = ["FamilyBossHurtAward", False, {"awardType":awardType, "awardIndex":awardIndex}] ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, None, event) SyncFamilyBossPlayerInfo(curPlayer) return def SendGameServer(msgType, msgData, playerID=0): msgInfo = str([msgType, msgData]) GameWorld.DebugLog("ÏÉÃËbossÊÔÁ¶Í¬²½GameServer: msgType=%s,%s" % (msgType, msgData), playerID) GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "FamilyBoss", msgInfo, len(msgInfo)) return def GameServer_FamilyBossInfo(curPlayer, resultList): playerID = curPlayer.GetPlayerID() msgType, msgData = resultList[:2] GameWorld.Log("ÏÉÃËBossÊÔÁ¶GameServer·µ»Ø: %s" % str(resultList), playerID) if msgType == "FamilyHurtAwardReq": familyID, awardType, awardIndex, needHurtTotal, awardItemList = msgData hurtValueTotal = resultList[2] if hurtValueTotal < needHurtTotal: GameWorld.DebugLog("ÏÉÃËbossÉËѪÏÉÃ˽±ÀøÉËѪ²»×ã²»ÄÜÁìÈ¡: awardIndex=%s,hurtValueTotal=%s < %s" % (awardIndex, hurtValueTotal, needHurtTotal), playerID) return rewardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAwardFamily) if rewardRecord & pow(2, awardIndex): GameWorld.DebugLog("ÏÉÃËbossÉËѪÏÉÃ˽±Àø·µ»ØÊ±ÒÑÁì½±!awardIndex=%s,rewardRecord=%s" % (awardIndex, rewardRecord), playerID) return updRewardRecord = rewardRecord | pow(2, awardIndex) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FamilyBossHurtAwardFamily, updRewardRecord) GameWorld.DebugLog("ÏÉÃËbossÉËѪÏÉÃ˽±Àø·¢·Å: familyID=%s,awardType=%s,awardIndex=%s,updRewardRecord=%s,awardItemList=%s" % (familyID, awardType, awardIndex, updRewardRecord, awardItemList), playerID) event = ["FamilyBossHurtAward", False, {"awardType":awardType, "awardIndex":awardIndex}] ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, None, event) SendGameServer_FamilyHurtAwardStateFamily(curPlayer) SyncFamilyBossPlayerInfo(curPlayer) return def SyncFamilyBossPlayerInfo(curPlayer): clientPack = ChPyNetSendPack.tagMCFamilyBosFBPlayerInfo() clientPack.Clear() clientPack.HurtTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValue) clientPack.HurtTotalPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtValuePoint) clientPack.FightSeconds = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossFightSeconds) clientPack.HurtAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAward) clientPack.HurtAwardStateFamily = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FamilyBossHurtAwardFamily) NetPackCommon.SendFakePack(curPlayer, clientPack) return