From 46cb09f4e24e4c1019cb7150338c5adce1cc64e7 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期六, 18 一月 2025 18:44:34 +0800 Subject: [PATCH] 10263 【越南】【英文】【BT】【砍树】后端支持NPC仿真实玩家战斗和快速战斗(本服竞技场支持掉线重登后结算战斗结果) --- ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py | 151 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 146 insertions(+), 5 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py index 44b1b6d..d9af3a4 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamily.py @@ -29,13 +29,17 @@ import DataRecordPack import PlayerFamilyBoss import IpyGameDataPY +import PlayerFamilyZhenbaoge import PlayerFamilyRedPacket import GameWorldFamilyWar import ChPyNetSendPack import NetPackCommon import PyDataManager import PyGameData +import PlayerBillboard +import PlayerActBossTrial import PlayerCompensation +import PlayerFamilyEmblem import PlayerFamilyParty import PlayerFamilySWRH import PlayerViewCache @@ -73,6 +77,9 @@ if not family: return 0 return GetFamilyTotalFightPower(family) +# 徽章ID +def GetFamilyEmblemID(curFamily): return curFamily.GetExtra6() +def SetFamilyEmblemID(curFamily, emblemID): return curFamily.SetExtra6(emblemID) # 公告修改次数 def GetFamilyBroadcastCnt(curFamily): return curFamily.GetExtra3() @@ -98,6 +105,53 @@ def GetMemberJoinTime(curMember): return curMember.GetExattr4() def SetMemberJoinTime(curMember, joinTime): return curMember.SetExattr4(joinTime) #---------------------------------------------------------------------- + +def OnGameServerInitOK(): + ## 服务器启动成功处理 + DoFamilySort() + return + +def OnMixServerInit(): + ## 合服后首次启动成功处理 + + # 仙盟联赛重置 + GameWorldFamilyWar.DoFamilyWarReset() + # 重置所有仙盟联赛评级 + familyManager = GameWorld.GetFamilyManager() + for i in xrange(familyManager.GetCount()): + family = familyManager.GetAt(i) + SetFamilyWarRank(family, 0) + + # 仙盟榜相关榜单重新上榜 + familyID = family.GetID() + familyBillInfo = GetFamilyBillboardInfo(family) + + familySubmitTotal = PlayerActBossTrial.GetFamilySubmitTotalByID(familyID) + PlayerBillboard.UpdateFamilyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamily, familyBillInfo, familySubmitTotal) + + DoFamilySort() + return + +def OnLoadDBPlayerOK(): + ## 服务器启动加载DB玩家成功处理 + + # 检查仙盟ServerID + familyManager = GameWorld.GetFamilyManager() + for i in xrange(familyManager.GetCount()): + family = familyManager.GetAt(i) + if family.GetServerID(): + continue + familyID = family.GetID() + # 没有则默认取盟主的 + leaderID = family.GetLeaderID() + leaderAccID = PlayerControl.GetDBPlayerAccIDByID(leaderID) + if not leaderAccID: + continue + serverID = GameWorld.GetAccIDServerID(leaderAccID) + family.SetServerID(serverID) + GameWorld.Log("启动更新仙盟所属服务器ID: familyID=%s,serverID=%s,leaderID=%s,%s" % (familyID, serverID, leaderID, leaderAccID)) + + return def RandomFakeFamily(): '''随机3个假仙盟''' @@ -218,7 +272,7 @@ # @param tick 当前时间 # @return None # @remarks 函数详细说明. -def DoCreateFamily(curPlayer, familyName, fakeIndex, tick): +def DoCreateFamily(curPlayer, familyName, fakeIndex, tick, emblemID=0): #---验证玩家属性--- curPlayerID = curPlayer.GetPlayerID() @@ -275,11 +329,16 @@ if curFamily == None: GameWorld.ErrLog("家族创建数目已满, 创建家族失败", curPlayerID) return - GameWorld.Log("创建仙盟: familyID=%s,playerID=%s" % (curFamily.GetID(), curPlayerID)) + emblemIDList = PlayerFamilyEmblem.GetDefaultFamilyEmblemIDList() + if not emblemID or emblemID not in emblemIDList: + emblemID = random.choice(emblemIDList) # 从默认徽章中随机选择一个 + GameWorld.Log("创建仙盟: familyID=%s,playerID=%s,emblemID=%s" % (curFamily.GetID(), curPlayerID, emblemID)) #---创建家族--- + curFamily.SetServerID(GameWorld.GetAccIDServerID(curPlayer.GetAccID())) curFamily.SetCreateTime(GameWorld.GetCurrentDataTimeStr()) curFamily.SetLV(1) curFamily.SetAcceptJoin(ShareDefine.FamilyAcceptJoin_Agree) #设置收人方式为直接通过申请 + SetFamilyEmblemID(curFamily, emblemID) PyDataManager.GetFamilyStoreItemManager().DelFamilyStoreItemAll(curFamily.GetID()) #新创建的仙盟默认设置已处理过合服 @@ -296,6 +355,8 @@ if fakeIndex and fakeIndex in fakeIndexList: PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_FakeFamilyIndex % fakeIndexList.index(fakeIndex), 0) GameWorld.Log(' 创建前n个假仙盟不扣钱! 假仙盟索引%s'%fakeIndexList.index(fakeIndex)) + fakeAwardItemList = IpyGameDataPY.GetFuncEvalCfg("FakeFamilyName", 3) + PlayerCompensation.SendMailByKey("FackFamilyNotice", [curPlayerID], fakeAwardItemList) elif creatFamilyTimes < IpyGameDataPY.GetFuncCfg('CreateFamilyNeedMoney', 3): GameWorld.Log(' 创建前n个仙盟不扣钱! creatFamilyTimes=%s' % creatFamilyTimes) else: @@ -343,6 +404,8 @@ GameWorld.Log('创建家族 : %s(%s), fakeIndex=%s, creatFamilyTimes=%s' % (fullFamilyName, curFamily.GetID(), fakeIndex, creatFamilyTimes+1), curPlayerID) PlayerControl.WorldNotify(0, "jiazu_liubo_671654", [curPlayer.GetName(), fullFamilyName, curFamily.GetID()]) + + PlayerFamilyZhenbaoge.OnZhenbaogeReset(curFamily) return ## 获取家族全名 @@ -542,6 +605,7 @@ # tagHead Head; # char Name[33]; # WORD FakeID; +# BYTE EmblemID; //选择徽章ID,解锁仙盟等级为1级的均为可选ID #}; ## 查看申请帮会的成员信息 # @param index 玩家索引 @@ -552,8 +616,9 @@ curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) inputName = clientPack.Name fakeIndex = clientPack.FakeID + emblemID = clientPack.EmblemID #执行创建家族逻辑 - DoCreateFamily(curPlayer, inputName, fakeIndex, tick) + DoCreateFamily(curPlayer, inputName, fakeIndex, tick, emblemID) #重置查看家族状态(仅创建家族时候重置, 其余状态由MapServer退出事件时重置) __ClearViewFamilyState(curPlayer) #玩家离开事件 @@ -689,6 +754,7 @@ totalFightPower = GetFamilyTotalFightPower(family) familyView.TotalFightPower = totalFightPower % ChConfig.Def_PerPointValue familyView.TotalFightPowerEx = totalFightPower / ChConfig.Def_PerPointValue + familyView.EmblemID = GetFamilyEmblemID(family) return familyView ## 玩家模糊查询家族,0F 0D封包 @@ -769,6 +835,19 @@ break familyViewPack.PageCount = len(familyViewPack.Family) NetPackCommon.SendFakePack(curPlayer, familyViewPack) + return + +#// A4 13 修改家族徽章 #tagCGChangeFamilyEmblem +# +#struct tagCGChangeFamilyEmblem +#{ +# tagHead Head; +# BYTE EmblemID; // 更换的徽章ID +#}; +def OnChangeFamilyEmblem(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + changeEmblemID = clientData.EmblemID + PlayerFamilyEmblem.OnChangeFamilyEmblem(curPlayer, changeEmblemID) return #class IPY_CFamilyChangeBroadcast @@ -2079,6 +2158,8 @@ curMember.SetJob(curPlayer.GetJob()) curMember.SetOperateInfo(curPlayer.GetOperateInfo()) curMember.SetOfficialRank(curPlayer.GetOfficialRank()) + curMember.SetFace(curPlayer.GetFace()) + curMember.SetFacePic(curPlayer.GetFacePic()) return #--------------------------------------------------------------------- ## 玩家刷新 @@ -2693,6 +2774,8 @@ family = familyManager.GetAt(i) #仙盟boss PlayerFamilyBoss.FamilyBossFBOnDayEx(family) + #珍宝阁 + PlayerFamilyZhenbaoge.OnDayEx(family) return #--------------------------------------------------------------------- @@ -2846,7 +2929,7 @@ GameWorld.ErrLog("key = %s not in tagFamily.txt" % familyLv) return 0 keyStr = ChConfig.FamilySettingDict[index] - return getattr(curFamilyLvSetting, keyStr) + return getattr(curFamilyLvSetting, "Get%s" % keyStr)() #=============================================================================== @@ -3632,6 +3715,8 @@ __DoChuangong_Response(curPlayer, tagPlayerID, isOK) return + if msgType == "ThanksGift": + __DoChuangong_ThanksGift(curPlayer, msgData) return def __CheckChuangongPlayer(curPlayer, tagPlayerID): @@ -3651,8 +3736,26 @@ def __DoChuangong_Invite(curPlayer, tagPlayerID): ## 邀请 playerID = curPlayer.GetPlayerID() - tagPlayer = __CheckChuangongPlayer(curPlayer, tagPlayerID) + curFamily = curPlayer.GetFamily() + if not curFamily: + return + tagMember = curFamily.FindMember(tagPlayerID) + if not tagMember: + GameWorld.DebugLog("非盟友无法传功! tagPlayerID=%s" % tagPlayerID, curPlayer.GetPlayerID()) + return + tagPlayer = tagMember.GetPlayer() if not tagPlayer: + clientPack = ChPyNetSendPack.tagGCChuangongStart() + clientPack.Clear() + clientPack.PlayerID = tagMember.GetPlayerID() + clientPack.Name = tagMember.GetName() + clientPack.NameLen = len(clientPack.Name) + clientPack.LV = tagMember.GetLV() + clientPack.Job = tagMember.GetJob() + clientPack.RealmLV = tagMember.GetOfficialRank() + NetPackCommon.SendFakePack(curPlayer, clientPack) + PyGameData.g_chuangongTagPlayerDict[playerID] = tagPlayerID + GameWorld.DebugLog("对方离线,则自己直接开始传功: tagPlayerID=%s, %s" % (tagPlayerID, PyGameData.g_chuangongPlayerDict), playerID) return invitePlayerIDList = PyGameData.g_chuangongPlayerDict.get(playerID, []) if tagPlayerID not in invitePlayerIDList: @@ -3666,6 +3769,8 @@ clientPack.LV = curPlayer.GetLV() clientPack.Job = curPlayer.GetJob() clientPack.RealmLV = curPlayer.GetOfficialRank() + clientPack.Face = curPlayer.GetFace() + clientPack.FacePic = curPlayer.GetFacePic() NetPackCommon.SendFakePack(tagPlayer, clientPack) GameWorld.DebugLog("邀请传功: tagPlayerID=%s, %s" % (tagPlayerID, PyGameData.g_chuangongPlayerDict), playerID) return @@ -3706,7 +3811,43 @@ clientPack.Job = tagPlayer.GetJob() clientPack.RealmLV = tagPlayer.GetOfficialRank() NetPackCommon.SendFakePack(curPlayer, clientPack) + PyGameData.g_chuangongTagPlayerDict[curPlayer.GetPlayerID()] = tagPlayer.GetPlayerID() + return + +def __DoChuangong_ThanksGift(curPlayer, msgData): + itemID = msgData[0] + playerID = curPlayer.GetPlayerID() + tagPlayerID = PyGameData.g_chuangongTagPlayerDict.pop(playerID, 0) + GameWorld.DebugLog("__DoChuangong_ThanksGift tagPlayerID=%s" % tagPlayerID, playerID) + if not tagPlayerID: + return + curFamily = curPlayer.GetFamily() + if not curFamily: + return + tagMember = curFamily.FindMember(tagPlayerID) + if not tagMember: + return + assistPlayerDict = {tagPlayerID:{"PlayerName":tagMember.GetName(), "Job":tagMember.GetJob(), + "LV":tagMember.GetLV(), "RealmLV":tagMember.GetOfficialRank(), + "Face":tagMember.GetFace(), "FacePic":tagMember.GetFacePic()}} + GameWorld.DebugLog(" assistPlayerDict %s" % assistPlayerDict, playerID) + PlayerAssist.AddNewAssistThanksEx(curPlayer, itemID, assistPlayerDict) return ##-------------------------------------------------------------------------------------------------- +def GetFamilyBillboardInfo(curFamily): + ## 获取仙盟榜单信息 区服ID、徽章、仙盟名、盟主名、仙盟总战力、仙盟等级 + familyID = curFamily.GetID() + name = curFamily.GetName() + id2 = curFamily.GetLeaderID() + name2 = curFamily.GetLeaderName() + fightPower = GetFamilyTotalFightPower(curFamily) + value1 = fightPower / ChConfig.Def_PerPointValue + value2 = fightPower % ChConfig.Def_PerPointValue + value3 = GetFamilyEmblemID(curFamily) + value4 = curFamily.GetLV() + value5 = curFamily.GetServerID() + return {"id":familyID, "name":name, "id2":id2, "name2":name2, "value1":value1, "value2":value2, + "value3":value3, "value4":value4, "value5":value5} + -- Gitblit v1.8.0