From 1e3f8cd83080ab4f140f862b2b2a0e60282b521e Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期四, 30 八月 2018 20:11:31 +0800
Subject: [PATCH] fix:3106 【后端】新增守卫人皇参与奖励
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 217 insertions(+), 22 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 4029be1..e5e9691 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -52,6 +52,7 @@
import PlayerMagicWeapon
import PlayerBossReborn
import PlayerFairyCeremony
+import FamilyRobBoss
import IpyGameDataPY
import PyGameData
import PlayerTeam
@@ -104,6 +105,7 @@
return curNPC.GetLV()
def GetRealmLV(curNPC): return curNPC.GetMAtkMin() # NPC表中此字段含义改成境界等级
+def SetRealmLV(curNPC, realmLV): return curNPC.SetMAtkMin(realmLV) # NPC表中此字段含义改成境界等级
def GetIsLVSuppress(curNPC): return curNPC.GetWindDef() # 风防代表是否等级压制
def GetSuppressFightPower(curNPC): return curNPC.GetThunderDef() # 雷防代表压制战力
def SetSuppressFightPower(curNPC, value): return curNPC.SetThunderDef(value)
@@ -112,6 +114,7 @@
def GetFaction(curNPC): return curNPC.GetCountry()
def GetSkillAtkRate(curNPC): return curNPC.GetPoisionAtk() # 毒攻代表NPC技能伤害加成万分率
def GetFinalHurt(curNPC): return curNPC.GetFireAtk() # 火攻代表NPC最终固定伤害加成, 普攻也有效果
+def SetFinalHurt(curNPC, hurt): return curNPC.SetFireAtk(hurt) # 火攻代表NPC最终固定伤害加成, 普攻也有效果
def GetSkillEnhance(curNPC): return curNPC.GetWindAtk() # 风攻代表NPC 《普攻》 的技能附加伤害固定值
def GetNPCSeries(curNPC): return curNPC.GetPoisionDef() # 毒防字段代表NPC系,按二进制位区分
@@ -822,13 +825,28 @@
tagPlaceSortList.sort() # 升序排序
tagPlaceSortList2.sort() # 升序排序
if isKillCountDropEquipEx:
- GameWorld.DebugLog("都不满足目标装备的优先级信息: npcID=%s, 颜色,阶,星,评分,部位,职业=%s" % (npcID, tagPlaceSortList), playerID)
- GameWorld.DebugLog("部分满足目标装备的优先级信息: npcID=%s, 颜色,阶,星,评分,部位,职业=%s" % (npcID, tagPlaceSortList2), playerID)
- tagPlaceSortList += tagPlaceSortList2
- if tagPlaceSortList:
- tagPlace = tagPlaceSortList[0][-2]
- tagJob = tagPlaceSortList[0][-1]
-
+ GameWorld.DebugLog("都不满足目标装备的优先级信息: npcID=%s, 数量=%s, 颜色,阶,星,评分,部位,职业=%s" % (npcID, len(tagPlaceSortList), tagPlaceSortList), playerID)
+ GameWorld.DebugLog("部分满足目标装备的优先级信息: npcID=%s, 数量=%s, 颜色,阶,星,评分,部位,职业=%s" % (npcID, len(tagPlaceSortList2), tagPlaceSortList2), playerID)
+ if tagPlaceSortList or tagPlaceSortList2:
+ isOptimalPlace = IpyGameDataPY.GetFuncCfg("DropEquipPlaceMode", 1) # 是否取最优解部位
+ if isOptimalPlace:
+ tagPlaceSortList += tagPlaceSortList2
+ if tagPlaceSortList:
+ tagPlace = tagPlaceSortList[0][-2]
+ tagJob = tagPlaceSortList[0][-1]
+ GameWorld.DebugLog("掉落目标部位取最优解: tagPlace=%s,tagJob=%s" % (tagPlace, tagJob), playerID)
+ else:
+ randPlaceCountLimit = IpyGameDataPY.GetFuncCfg("DropEquipPlaceMode", 2) # 全不满足目标条件部位有几个时才优先随机
+ if len(tagPlaceSortList) < randPlaceCountLimit:
+ tagPlaceSortList += tagPlaceSortList2
+ else:
+ GameWorld.DebugLog("优先随机都不满足目标装备的,randPlaceCountLimit=%s" % randPlaceCountLimit, playerID)
+ randPlaceIndex = random.randint(0, len(tagPlaceSortList) - 1)
+ GameWorld.DebugLog("掉落目标部位随机, randPlaceIndex=%s, 颜色,阶,星,评分,部位,职业=%s" % (randPlaceIndex, tagPlaceSortList), playerID)
+ tagPlace = tagPlaceSortList[randPlaceIndex][-2]
+ tagJob = tagPlaceSortList[randPlaceIndex][-1]
+ GameWorld.DebugLog("掉落目标部位随机不满足条件的: tagPlace=%s,tagJob=%s" % (tagPlace, tagJob), playerID)
+
if isKillCountDropEquipEx:
GameWorld.DebugLog("附加掉落指定目标装备信息: npcID=%s,玩家最少的击杀次数=%s,目标击杀数=%s,tagClassLV=%s,tagColor=%s,tagStar=%s,tagStarMin=%s,tagPlace=%s,tagJob=%s"
% (npcID, dropEquipExKillCount, tagKillCount, tagClassLV, tagColor, tagStar, tagStarMin, tagPlace, tagJob), playerID)
@@ -1080,12 +1098,18 @@
if len(jobItemList) < job:
GameWorld.ErrLog("职业物品集合key没有配置对应职业ID: npcID=%s,jobItemKey=%s,job=%s" % (npcID, jobItemKey, job))
continue
+ mustDropCount = dropRate / Def_NPCMaxDropRate
+ dropRate = dropRate % Def_NPCMaxDropRate # 基础概率
+ canDropCount = mustDropCount
doCnt = ItemKeyMaxDropCountDict.get(jobItemKey, 1) # 默认1个
doCnt = __GetNPCDropDoCountChange(doCnt, doCountRate, doCountAdd)
for _ in xrange(doCnt):
if not GameWorld.CanHappen(dropRate, maxRate=Def_NPCMaxDropRate):
continue
- jobItemID = jobItemList[job - 1]
+ canDropCount += 1
+
+ jobItemID = jobItemList[job - 1]
+ for _ in xrange(canDropCount):
dropItemIDList.append(jobItemID)
#GameWorld.DebugLog("掉落自身职业指定物品ID: jobItemKey=%s,jobItemID=%s" % (jobItemKey, jobItemID))
@@ -1102,11 +1126,17 @@
# 在只掉本职业里的不处理
if jobItemKey in ItemKeyDropRateJobDict:
continue
+ mustDropCount = dropRate / Def_NPCMaxDropRate
+ dropRate = dropRate % Def_NPCMaxDropRate # 基础概率
+ canDropCount = mustDropCount
doCnt = ItemKeyMaxDropCountDict.get(jobItemKey, 1) # 默认1个
doCnt = __GetNPCDropDoCountChange(doCnt, doCountRate, doCountAdd)
for _ in xrange(doCnt):
if not GameWorld.CanHappen(dropRate, maxRate=Def_NPCMaxDropRate):
continue
+ canDropCount += 1
+
+ for _ in xrange(canDropCount):
randJobItemID = random.choice(jobItemList)
dropItemIDList.append(randJobItemID)
#GameWorld.DebugLog("掉落随机职业指定物品ID: jobItemKey=%s,randJobItemID=%s" % (jobItemKey, randJobItemID))
@@ -1175,6 +1205,48 @@
msgInfo = str([itemID, updKilledCnt])
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "GlobalDropRate", msgInfo, len(msgInfo))
+ # 4. 指定全服击杀次数必掉,算额外掉落
+ globalKillDropDict = IpyGameDataPY.GetFuncEvalCfg("GlobalDropCD", 2) # {NPCID:{击杀次数:[是否本职业, [物品ID, ...], [随机物品ID, ...]]}, ...}
+ if npcID in globalKillDropDict:
+ killCountDropDict = globalKillDropDict[npcID]
+ updNPCKilledCount = min(gw.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_NPCKilledCount % npcID) + 1, ShareDefine.Def_UpperLimit_DWord)
+ GameWorld.DebugLog("更新全服击杀次数: %s" % updNPCKilledCount)
+ # 通知GameServer记录
+ msgInfo = str([npcID, updNPCKilledCount])
+ GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "GlobalKillCount", msgInfo, len(msgInfo))
+ if updNPCKilledCount in killCountDropDict:
+ isJobLimit, itemIDList, randItemIDList = killCountDropDict[updNPCKilledCount]
+ for itemID in itemIDList:
+ if isJobLimit:
+ itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
+ if not itemData:
+ continue
+ itemJob = itemData.GetJobLimit() / 100
+ if itemJob and itemJob != curPlayer.GetJob():
+ # 非本职业可用,不掉落
+ GameWorld.DebugLog("全服击杀次数必掉,非本职业可用,不掉落! itemID=%s" % itemID)
+ continue
+ dropItemIDList.append(itemID)
+ GameWorld.DebugLog("全服击杀次数必掉物品: itemID=%s" % itemID)
+ if randItemIDList:
+ if isJobLimit:
+ randJobItemList = []
+ for rItemID in randItemIDList:
+ itemData = GameWorld.GetGameData().GetItemByTypeID(rItemID)
+ if not itemData:
+ continue
+ itemJob = itemData.GetJobLimit() / 100
+ if itemJob and itemJob != curPlayer.GetJob():
+ # 非本职业可用,不掉落
+ GameWorld.DebugLog("全服击杀次数必掉随机,非本职业可用,不掉落! rItemID=%s" % rItemID)
+ continue
+ randJobItemList.append(rItemID)
+ randItemID = random.choice(randJobItemList)
+ else:
+ randItemID = random.choice(randItemIDList)
+ dropItemIDList.append(randItemID)
+ GameWorld.DebugLog("全服击杀次数必掉随机物品: randItemID=%s" % randItemID)
+
return dropItemIDList
def __GetEquipIDList(npcID, classLV, color, placeList, star, itemJobList, tagPlace=None):
@@ -1917,11 +1989,14 @@
#因为存在boss分流,所以用gameFB字典,但是存活状态还是用GameWorld字典
GameWorld.GetGameFB().SetGameFBDict(ChConfig.Map_NPC_WorldBossDeadTick % npcid, GameWorld.GetGameWorld().GetTick())
+ if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
+ FamilyRobBoss.ClearFamilyOwnerBossHurt(curNPC)
+
# 清除队伍成员伤血列表
AttackCommon.ClearTeamPlayerHurtValue(curNPC)
# 清除自定义伤血列表
- BossHurtMng.ClearHurtValueList(curNPC)
+ #BossHurtMng.ClearHurtValueList(curNPC)
# C++设置npc死亡
curNPC.SetDead(curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason),
@@ -1955,6 +2030,9 @@
self.__Killer = None # 击杀者, 由各种规则得出, 一般也是物品归属的代表, 用于广播、记录等确保与归属一致
self.__AllKillerDict = {} # 所有击杀的玩家ID对应字典, 非队伍, 一般也是归属的拥有者
self.__FeelPlayerList = [] # 所有摸怪玩家列表,处理任务及某些逻辑用
+
+ self.__OwnerHurtType = 0
+ self.__OwnerHurtID = 0
return
#---------------------------------------------------------------------
## 移动到某一个点的附近点
@@ -2485,7 +2563,7 @@
self.__AddAngryValue(npcAngry, curObjID, curObjType, plusAngryValue, canPile)
#激活呆滞的NPC
- if curNPC.GetHP() > 0 and not curNPC.GetIsNeedProcess() :
+ if GameObj.GetHP(curNPC) > 0 and not curNPC.GetIsNeedProcess() :
curNPC.SetIsNeedProcess(True)
@@ -3330,6 +3408,9 @@
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GameWorldBossState',
'%s' % (msgList), len(str(msgList)))
+ if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
+ FamilyRobBoss.FamilyOwnerBossOnReborn(curNPC)
+
# 检查是否有光环, 在重生时处理,不然可能导致有些无战斗逻辑的怪物无法套上光环buff
skillManager = curNPC.GetSkillManager()
for index in xrange(skillManager.GetSkillCount()):
@@ -3707,7 +3788,7 @@
#=====================================================================================================
#boss伤血排行榜击杀逻辑
- BossHurtMng.BossOnKilled(curNPC)
+ #BossHurtMng.BossOnKilled(curNPC)
#掉落需要用到摸怪,所以在处理掉落奖励之前设置
self.__SetFeelNPCPlayerList()
@@ -3723,6 +3804,8 @@
# 记录boss击杀信息的NPC
bossIpyData = IpyGameDataPY.GetIpyGameDataListNotLog('BOSSInfo', npcID)
if bossIpyData:
+ if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
+ killerName = FamilyRobBoss.FamilyOwnerBossOnKilled(curNPC, self.__OwnerHurtID)
#KillerJob = 0 if not self.__Killer else self.__Killer.GetJob()
GameServer_KillGameWorldBoss(curNPC.GetNPCID(), killerName, 0)
#===========================================================================================
@@ -4168,7 +4251,8 @@
self.__MaxHurtPlayer = self.__FindBossMaxHurtObj() # py自定义伤血所得到的Boss最大伤血玩家
self.__AllKillerDict, curTeam, hurtType, hurtID = self.__FindNPCKillerInfo()
-
+ self.__OwnerHurtType, self.__OwnerHurtID = hurtType, hurtID
+
#最后一击处理
self.__DoLastTimeHurtLogic()
@@ -4198,6 +4282,10 @@
elif curTeam != None:
self.__KilledByTeamSetPrize(curTeam, hurtType, hurtID)
+ #被仙盟杀死
+ elif hurtType == ChConfig.Def_NPCHurtTypeFamily:
+ self.__KilledByFamilySetPrize(hurtType, hurtID)
+
else:
GameWorld.ErrLog("NPC归属异常:npcID=%s,hurtType=%s,hurtID=%s" % (npcID, hurtType, hurtID))
@@ -4592,7 +4680,60 @@
self.__NPCDropItem(dropPlayer, hurtType, hurtID, ownerPlayerList)
#GameWorld.Log("队伍杀死怪物奖励,逻辑成功结束")
return
-
+
+ def __KilledByFamilySetPrize(self, hurtType, hurtID):
+ ## 仙盟杀死NPC奖励逻辑
+ curNPC = self.__Instance
+
+ maxLV = 0
+ dropPlayer = None
+ ownerPlayerList = []
+ refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
+ copyPlayerMgr = GameWorld.GetMapCopyPlayerManager()
+ for index in xrange(copyPlayerMgr.GetPlayerCount()):
+ player = copyPlayerMgr.GetPlayerByIndex(index)
+ if not player:
+ continue
+
+ if player.GetFamilyID() != hurtID or not self.GetIsInRefreshPoint(player.GetPosX(), player.GetPosY(), refreshPoint):
+ continue
+
+ curPlayerLV = player.GetLV()
+ if maxLV < curPlayerLV:
+ maxLV = curPlayerLV
+ dropPlayer = player
+ ownerPlayerList.append(player)
+
+ if not ownerPlayerList:
+ GameWorld.Log("奖励归属仙盟,但是不存在可获得该奖励的成员!npcID=%s,hurtType=%s,hurtID=%s"
+ % (curNPC.GetNPCID(), hurtType, hurtID))
+
+ # 因为仙盟归属boss归属伤血第一的仙盟,仙盟伤血有保护,可能存在伤血第一仙盟在boss死亡的时候都不在
+ # 此时掉落计算玩家算最后一击玩家,归属还是算伤血第一仙盟的
+ if not dropPlayer:
+ dropPlayer = self.__LastHurtPlayer
+
+ if not dropPlayer:
+ GameWorld.ErrLog("奖励归属仙盟,找不到掉落玩家!npcID=%s,hurtType=%s,hurtID=%s"
+ % (curNPC.GetNPCID(), hurtType, hurtID))
+ return
+
+ # 赶时间,先简单处理直接取最大等级的,之后可按实际情况来
+ if not self.__LastHurtPlayer:
+ self.__LastHurtPlayer = dropPlayer
+ if not self.__MaxHurtPlayer:
+ self.__MaxHurtPlayer = dropPlayer
+ if not self.__Killer:
+ self.__Killer = dropPlayer
+ maxHurtID = dropPlayer.GetPlayerID()
+
+ for curPlayer in ownerPlayerList:
+ self.__KillNPCFuncEx(curPlayer, curNPC, maxHurtID, False)
+
+ #调用物品掉落
+ self.__NPCDropItem(dropPlayer, hurtType, hurtID, ownerPlayerList)
+ return
+
## 队伍或自己击杀NPC扩展功能
# @param curPlayer
# @return None
@@ -5320,6 +5461,7 @@
# @param None
# @param None
def SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, syncItemInfoList, collectNPCID=0):
+ return #暂不同步
if addExp <= 0 and addMoney <= 0 and addZhenQi <= 0 and not syncItemInfoList:
return
@@ -5407,15 +5549,15 @@
collectNPCIDTimeLimit = ReadChConfig.GetEvalChConfig('CollectNPCIDTimeLimit')
npcIDList = collectNPCIDTimeLimit.keys()
- if funcTypeList:
- collection = ChPyNetSendPack.tagMCFuncNPCCollectionCnt()
- for fType in funcTypeList:
- todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcCollTime % fType)
- collection.Clear()
- collection.FuncType = fType
- collection.CollectionCnt = todayCollTime
- collection.BuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcBuyTime % fType)
- NetPackCommon.SendFakePack(curPlayer, collection)
+# if funcTypeList:
+# collection = ChPyNetSendPack.tagMCFuncNPCCollectionCnt()
+# for fType in funcTypeList:
+# todayCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcCollTime % fType)
+# collection.Clear()
+# collection.FuncType = fType
+# collection.CollectionCnt = todayCollTime
+# collection.BuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcBuyTime % fType)
+# NetPackCommon.SendFakePack(curPlayer, collection)
if npcIDList:
npcIDCollInfo = ChPyNetSendPack.tagMCNPCIDCollectionCntInfo()
@@ -5530,6 +5672,59 @@
NetPackCommon.SendFakePack(curPlayer, npcInfoPack)
return
+
+## 获取本地图NPC数量
+# @param queryNPCIDList:查询的NPCID列表
+# @param tick
+# @return {NPCID:cnt}
+def GetNPCCntInfo(queryNPCIDList, tick):
+ npcCntDict = {}
+
+ if not queryNPCIDList:
+ return npcCntDict
+
+ gameNPCManager = GameWorld.GetNPCManager()
+ GameWorld.DebugLog("GetNPCCntInfo...queryNPCIDList=%s" % (str(queryNPCIDList)))
+
+ for index in xrange(gameNPCManager.GetNPCCount()):
+ curNPC = gameNPCManager.GetNPCByIndex(index)
+ curID = curNPC.GetID()
+ if curID == 0:
+ continue
+
+ curNPCID = curNPC.GetNPCID()
+
+ if curNPCID not in queryNPCIDList:
+ continue
+ if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
+ continue
+ npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1
+
+ GameWorld.DebugLog(" npcCntDict=%s" % (str(npcCntDict)))
+ return npcCntDict
+
+## 同步地图NPC数量信息
+# @param curPlayer:采集玩家实例
+# @param mapID:
+# @param npcInfoDict:
+# @return None
+def SyncNPCCntInfo(curPlayer, mapID, npcCntDict):
+ npcInfoPack = ChPyNetSendPack.tagMCNPCCntList()
+ npcInfoPack.Clear()
+ npcInfoPack.MapID = mapID
+ npcInfoPack.NPCInfoList = []
+
+ for npcid, npcCnt in npcCntDict.items():
+ npcInfo = ChPyNetSendPack.tagMCNPCCntInfo()
+ npcInfo.Clear()
+ npcInfo.NPCID = npcid
+ npcInfo.Cnt = npcCnt
+ npcInfoPack.NPCInfoList.append(npcInfo)
+
+ npcInfoPack.NPCInfoCnt = len(npcInfoPack.NPCInfoList)
+ NetPackCommon.SendFakePack(curPlayer, npcInfoPack)
+ return
+
def SendGameServerGoodItemRecord(mapID, npcID, playerName, playerID, itemID, equipInfo=[]):
# @param equipInfo: [equipPlace, itemClassLV, itemColor, itemQuality, itemUserData]
# GameWorld.DebugLog("检查物品是否发送GameServer: mapID=%s, npcID=%s, playerName=%s, itemID=%s"
--
Gitblit v1.8.0