From 93591a53c1cdabb4e595fa4d5c36eb89998a6e6f Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期六, 25 五月 2019 18:50:56 +0800 Subject: [PATCH] 6805 【后端】【2.0】副本前端化(召唤木桩由玩家召唤兽改为普通NPC) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py | 80 ++++++++++++++-------------------------- 1 files changed, 28 insertions(+), 52 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py index 0a1dac5..342bef8 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py @@ -2040,39 +2040,32 @@ if count != 1: hp, hpEx = 0, 0 # 指定血量的暂仅适用于单只的 + playerID = curPlayer.GetPlayerID() + if playerID not in PyGameData.g_playerPriWoodPileNPCDict: + PyGameData.g_playerPriWoodPileNPCDict[playerID] = [] + playerPriWoodNPCList = PyGameData.g_playerPriWoodPileNPCDict[playerID] maxCount = 10 - nowCount = 0 - # 只允许存在一个私有木桩 - indexList = range(curPlayer.GetSummonCount()) - for index in indexList[::-1]: - summonNPC = curPlayer.GetSummonNPCAt(index) - if not summonNPC: - continue - npcType = summonNPC.GetType() - if npcType not in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]: - continue - if nowCount >= maxCount or summonNPC.GetNPCID() != npcID: - SetDeadEx(summonNPC) - else: - nowCount += 1 - + nowCount = len(playerPriWoodNPCList) summonCount = min(count, maxCount - nowCount) #GameWorld.DebugLog("召唤: count=%s,maxCount=%s,nowCount=%s,summonCount=%s,hp=%s,hpEx=%s" # % (count, maxCount, nowCount, summonCount, hp, hpEx)) if summonCount <= 0: return + npcManager = GameWorld.GetNPCManager() for _ in xrange(summonCount): - summonNPC = curPlayer.SummonNewNPC() + #summonNPC = curPlayer.SummonNewNPC() + summonNPC = npcManager.AddPlayerSummonNPC() #设置召唤兽基础信息 summonNPC.SetNPCTypeID(npcID) + summonNPC.SetSightLevel(curPlayer.GetSightLevel()) #初始化 InitNPC(summonNPC) #玩家召唤兽列表添加召唤兽,召唤兽添加主人 - summonNPC.SetOwner(curPlayer) - summonNPC.SetDict(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID, curPlayer.GetPlayerID()) + #summonNPC.SetOwner(curPlayer) + summonNPC.SetDict(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID, playerID) #将召唤兽召唤出来 #玩家周围随机出生点 @@ -2082,36 +2075,19 @@ if hp or hpEx: summonNPC.SetHP(hp) summonNPC.SetHPEx(hpEx) - - #if not curPlayer.GetSight(): - summonNPCAppear = ChNetSendPack.tagPlayerSummonNPCAppear() - summonNPCAppear.Clear() - summonNPCAppear.PlayerID = curPlayer.GetPlayerID() - summonNPCAppear.ObjID = summonNPC.GetID() - summonNPCAppear.NPCID = summonNPC.GetNPCID() - summonNPCAppear.PosX = summonNPC.GetPosX() - summonNPCAppear.PosY = summonNPC.GetPosY() - summonNPCAppear.HP = summonNPC.GetHP() - summonNPCAppear.HPEx = summonNPC.GetHPEx() - summonNPCAppear.MaxHP = summonNPC.GetMaxHP() - summonNPCAppear.MaxHPEx = summonNPC.GetMaxHPEx() - summonNPCAppear.Speed = summonNPC.GetSpeed() - summonNPCAppear.LV = GetNPCLV(summonNPC) - summonNPCAppear.OwnerName = curPlayer.GetPlayerName() - summonNPCAppear.OwnerNameLen = len(summonNPCAppear.OwnerName) - NetPackCommon.SendFakePack(curPlayer, summonNPCAppear) + summonNPC.NotifyAppear() # 最终统一通知NPC出现 + playerPriWoodNPCList.append(summonNPC) return def ClearPriWoodPile(curPlayer): ## 清除私有木桩 - indexList = range(curPlayer.GetSummonCount()) - for index in indexList[::-1]: - summonNPC = curPlayer.GetSummonNPCAt(index) + playerID = curPlayer.GetPlayerID() + if playerID not in PyGameData.g_playerPriWoodPileNPCDict: + return + playerPriWoodNPCList = PyGameData.g_playerPriWoodPileNPCDict.pop(playerID) + for summonNPC in playerPriWoodNPCList: if not summonNPC: - continue - npcType = summonNPC.GetType() - if npcType not in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]: continue SetDeadEx(summonNPC) return @@ -2134,10 +2110,8 @@ if curNPC.GetGameObjType() == IPY_GameWorld.gotNPC: FBLogic.DoFB_NPCDead(curNPC) - ownerPlayer = None summonPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID) if summonPlayerID > 0: - ownerPlayer = GameWorld.GetObj(summonPlayerID, IPY_GameWorld.gotPlayer) curNPC.SetDict(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID, 0) # 暗金boss @@ -2165,14 +2139,16 @@ lineRobotJobDict.pop(curNPC.GetID(), 0) PyGameData.g_fbRobotJobDict[lineID] = lineRobotJobDict - if ownerPlayer and not ownerPlayer.GetSight(): - npcDie = ChNetSendPack.tagNPCDie() - npcDie.ObjID = curNPC.GetID() - npcDie.Reason = curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason) - npcDie.KillerType = curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerType) - npcDie.KillerID = curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerID) - NetPackCommon.SendFakePack(ownerPlayer, npcDie) - + priWoodPilePlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID) + if priWoodPilePlayerID > 0 and priWoodPilePlayerID in PyGameData.g_playerPriWoodPileNPCDict: + priWoodPileNPCList = PyGameData.g_playerPriWoodPileNPCDict[priWoodPilePlayerID] + for priWoodNPC in priWoodPileNPCList: + if priWoodNPC and priWoodNPC.GetID() == curNPC.GetID(): + priWoodPileNPCList.remove(priWoodNPC) + if not priWoodPileNPCList: + PyGameData.g_playerPriWoodPileNPCDict.pop(priWoodPilePlayerID) + break + # C++设置npc死亡 curNPC.SetDead(curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason), curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerType), -- Gitblit v1.8.0