9936 【BT0.1】【主干】人族法宝(任务 进度)给予奖励
# Conflicts:
# ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
| | |
| | | float NeedRMB; //所需充值元
|
| | | dict Reward; //职业对应的奖励内容,每个职业4组数据,物品ID和物品数量(1.枪豪2.道师3.剑修)
|
| | | };
|
| | |
|
| | | //奖励表
|
| | |
|
| | | struct tagCustomAward
|
| | | {
|
| | | BYTE _AwardID; //奖励ID 1~n
|
| | | list AwardItemList; //物品奖励[[物品ID,个数,是否拍品], ...]
|
| | | };
|
| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A3 CC 自定义奖励信息 #tagMCCustomAwardInfo
|
| | |
|
| | | class tagMCCustomAwardState(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("KeyNum", c_ubyte), # 奖励记录key编号,0~255,每个key存31个ID记录 0-30为编号0, 31-61为编号1..
|
| | | ("CanGetState", c_int), # 是否可领取;按位记录是否可领取
|
| | | ("GetState", c_int), # 是否已领取;按位记录是否已领取
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.KeyNum = 0
|
| | | self.CanGetState = 0
|
| | | self.GetState = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagMCCustomAwardState)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// A3 CC 自定义奖励信息 //tagMCCustomAwardInfo:
|
| | | KeyNum:%d,
|
| | | CanGetState:%d,
|
| | | GetState:%d
|
| | | '''\
|
| | | %(
|
| | | self.KeyNum,
|
| | | self.CanGetState,
|
| | | self.GetState
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | class tagMCCustomAwardInfo(Structure):
|
| | | Head = tagHead()
|
| | | RecordStateCnt = 0 #(BYTE RecordStateCnt)// 记录个数
|
| | | RecordStateList = list() #(vector<tagMCCustomAwardState> RecordStateList)// 记录列表
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Head.Cmd = 0xA3
|
| | | self.Head.SubCmd = 0xCC
|
| | | return
|
| | |
|
| | | def ReadData(self, _lpData, _pos=0, _Len=0):
|
| | | self.Clear()
|
| | | _pos = self.Head.ReadData(_lpData, _pos)
|
| | | self.RecordStateCnt,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | for i in range(self.RecordStateCnt):
|
| | | temRecordStateList = tagMCCustomAwardState()
|
| | | _pos = temRecordStateList.ReadData(_lpData, _pos)
|
| | | self.RecordStateList.append(temRecordStateList)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | | self.Head = tagHead()
|
| | | self.Head.Clear()
|
| | | self.Head.Cmd = 0xA3
|
| | | self.Head.SubCmd = 0xCC
|
| | | self.RecordStateCnt = 0
|
| | | self.RecordStateList = list()
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | length = 0
|
| | | length += self.Head.GetLength()
|
| | | length += 1
|
| | | for i in range(self.RecordStateCnt):
|
| | | length += self.RecordStateList[i].GetLength()
|
| | |
|
| | | return length
|
| | |
|
| | | def GetBuffer(self):
|
| | | data = ''
|
| | | data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
|
| | | data = CommFunc.WriteBYTE(data, self.RecordStateCnt)
|
| | | for i in range(self.RecordStateCnt):
|
| | | data = CommFunc.WriteString(data, self.RecordStateList[i].GetLength(), self.RecordStateList[i].GetBuffer())
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''
|
| | | Head:%s,
|
| | | RecordStateCnt:%d,
|
| | | RecordStateList:%s
|
| | | '''\
|
| | | %(
|
| | | self.Head.OutputString(),
|
| | | self.RecordStateCnt,
|
| | | "..."
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagMCCustomAwardInfo=tagMCCustomAwardInfo()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCCustomAwardInfo.Head.Cmd,m_NAtagMCCustomAwardInfo.Head.SubCmd))] = m_NAtagMCCustomAwardInfo
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A3 15 日常活动次数通知 #tagMCDailyActionCnt
|
| | |
|
| | | class tagMCDailyActionInfo(Structure):
|
| | |
| | | #神通
|
| | | Def_PDict_ShentongLVInfo = "ShentongLVInfo_%s" # 神通等级信息,参数(神通ID),阶级*100+等级
|
| | | Def_PDict_ShentongSkillID = "ShentongSkillID_%s" # 神通出战技能ID,参数(编号)
|
| | |
|
| | | #自定义奖励
|
| | | Def_PDict_CustomAwardCanGet = "CustomAwardCanGet_%s" # 是否可领取,参数(key编号)
|
| | | Def_PDict_CustomAwardGetState = "CustomAwardGetState_%s" # 是否已领取,参数(key编号)
|
| | | #-------------------------------------------------------------------------------
|
| | | #可以从07 41封包购买的背包类型,和对应字典{背包类型:[字典key, 默认格子数]}
|
| | |
|
| | |
| | | Def_RewardType_GubaoItemEff, #古宝特殊效果物品奖励 58
|
| | | Def_RewardType_SuccessScore, #成就积分奖励 59
|
| | | Def_RewardType_BuyOne, #买一送多活动免费奖励 60
|
| | | )= range(61)
|
| | | Def_RewardType_CustomAward, #自定义奖励 61
|
| | | )= range(62)
|
| | |
|
| | |
|
| | | #boss复活相关活动定义
|
| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A3 CC 自定义奖励信息 #tagMCCustomAwardInfo
|
| | |
|
| | | class tagMCCustomAwardState(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("KeyNum", c_ubyte), # 奖励记录key编号,0~255,每个key存31个ID记录 0-30为编号0, 31-61为编号1..
|
| | | ("CanGetState", c_int), # 是否可领取;按位记录是否可领取
|
| | | ("GetState", c_int), # 是否已领取;按位记录是否已领取
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.KeyNum = 0
|
| | | self.CanGetState = 0
|
| | | self.GetState = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagMCCustomAwardState)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// A3 CC 自定义奖励信息 //tagMCCustomAwardInfo:
|
| | | KeyNum:%d,
|
| | | CanGetState:%d,
|
| | | GetState:%d
|
| | | '''\
|
| | | %(
|
| | | self.KeyNum,
|
| | | self.CanGetState,
|
| | | self.GetState
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | class tagMCCustomAwardInfo(Structure):
|
| | | Head = tagHead()
|
| | | RecordStateCnt = 0 #(BYTE RecordStateCnt)// 记录个数
|
| | | RecordStateList = list() #(vector<tagMCCustomAwardState> RecordStateList)// 记录列表
|
| | | data = None
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Head.Cmd = 0xA3
|
| | | self.Head.SubCmd = 0xCC
|
| | | return
|
| | |
|
| | | def ReadData(self, _lpData, _pos=0, _Len=0):
|
| | | self.Clear()
|
| | | _pos = self.Head.ReadData(_lpData, _pos)
|
| | | self.RecordStateCnt,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | for i in range(self.RecordStateCnt):
|
| | | temRecordStateList = tagMCCustomAwardState()
|
| | | _pos = temRecordStateList.ReadData(_lpData, _pos)
|
| | | self.RecordStateList.append(temRecordStateList)
|
| | | return _pos
|
| | |
|
| | | def Clear(self):
|
| | | self.Head = tagHead()
|
| | | self.Head.Clear()
|
| | | self.Head.Cmd = 0xA3
|
| | | self.Head.SubCmd = 0xCC
|
| | | self.RecordStateCnt = 0
|
| | | self.RecordStateList = list()
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | length = 0
|
| | | length += self.Head.GetLength()
|
| | | length += 1
|
| | | for i in range(self.RecordStateCnt):
|
| | | length += self.RecordStateList[i].GetLength()
|
| | |
|
| | | return length
|
| | |
|
| | | def GetBuffer(self):
|
| | | data = ''
|
| | | data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
|
| | | data = CommFunc.WriteBYTE(data, self.RecordStateCnt)
|
| | | for i in range(self.RecordStateCnt):
|
| | | data = CommFunc.WriteString(data, self.RecordStateList[i].GetLength(), self.RecordStateList[i].GetBuffer())
|
| | | return data
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''
|
| | | Head:%s,
|
| | | RecordStateCnt:%d,
|
| | | RecordStateList:%s
|
| | | '''\
|
| | | %(
|
| | | self.Head.OutputString(),
|
| | | self.RecordStateCnt,
|
| | | "..."
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagMCCustomAwardInfo=tagMCCustomAwardInfo()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCCustomAwardInfo.Head.Cmd,m_NAtagMCCustomAwardInfo.Head.SubCmd))] = m_NAtagMCCustomAwardInfo
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # A3 15 日常活动次数通知 #tagMCDailyActionCnt
|
| | |
|
| | | class tagMCDailyActionInfo(Structure):
|
| | |
| | | import PlayerFeastTravel
|
| | | import PlayerWeekParty
|
| | | import PlayerFairyDomain
|
| | | import PlayerCustomAward
|
| | | import GameFuncComm
|
| | | import PlayerActLogin
|
| | | import PlayerHorse
|
| | |
| | | PlayerMagicWeapon.DoActiveMW(curPlayer, mwID)
|
| | | return
|
| | |
|
| | | ##设置自定义奖励可领取
|
| | | # @param None
|
| | | # @return None <Setcustomaward_Canget id="奖励ID"/>
|
| | | def DoType_Setcustomaward_Canget(curPlayer, curMission, curActionNode):
|
| | | awardID = GameWorld.ToIntDef(curActionNode.GetAttribute("id"), 0)
|
| | | PlayerCustomAward.SetCustomAwardCanGet(curPlayer, awardID, 1)
|
| | | return
|
| | |
|
| | | ## 人物隐身 <Visible id="0隐身1现身"/>
|
| | | def DoType_Visible(curPlayer, curMission, curActionNode):
|
| | | visible = GameWorld.ToIntDef(curActionNode.GetAttribute("id"), 0)
|
New file |
| | |
| | | #!/usr/bin/python |
| | | # -*- coding: GBK -*- |
| | | #------------------------------------------------------------------------------- |
| | | # |
| | | ##@package GM.Commands.CustomAward |
| | | # |
| | | # @todo:自定义奖励 |
| | | # @author hxp |
| | | # @date 2023-09-22 |
| | | # @version 1.0 |
| | | # |
| | | # 详细描述: 自定义奖励 |
| | | # |
| | | #------------------------------------------------------------------------------- |
| | | #"""Version = 2023-09-22 13:30""" |
| | | #------------------------------------------------------------------------------- |
| | | |
| | | import GameWorld |
| | | import PlayerCustomAward |
| | | import IpyGameDataPY |
| | | import PlayerControl |
| | | import ChConfig |
| | | |
| | | ## GM命令执行入口 |
| | | # @param curPlayer 当前玩家 |
| | | # @param msgList 参数列表 [] |
| | | # @return None |
| | | # @remarks 函数详细说明. |
| | | def OnExec(curPlayer, msgList): |
| | | if not msgList: |
| | | GameWorld.DebugAnswer(curPlayer, "重置所有: CustomAward 0") |
| | | GameWorld.DebugAnswer(curPlayer, "设置奖励: CustomAward ID 是否可领 是否已领") |
| | | return |
| | | |
| | | cmdType = msgList[0] |
| | | if cmdType == 0: |
| | | awardIDMax = 0 |
| | | ipyDataMgr = IpyGameDataPY.IPY_Data() |
| | | for index in range(ipyDataMgr.GetCustomAwardCount()): |
| | | ipyData = ipyDataMgr.GetCustomAwardByIndex(index) |
| | | if awardIDMax < ipyData.GetAwardID(): |
| | | awardIDMax = ipyData.GetAwardID() |
| | | |
| | | keyNumMax = GameWorld.GetDictKeyNumByBit(awardIDMax) |
| | | for keyNum in range(keyNumMax + 1): |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CustomAwardCanGet % keyNum, 0) |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CustomAwardGetState % keyNum, 0) |
| | | |
| | | PlayerCustomAward.Sync_CustomAwardInfo(curPlayer, None, True) |
| | | GameWorld.DebugAnswer(curPlayer, "重置OK") |
| | | else: |
| | | awardID = cmdType |
| | | canGet = msgList[1] if len(msgList) > 1 else 0 |
| | | getState = msgList[2] if len(msgList) > 2 else 0 |
| | | ipyData = IpyGameDataPY.GetIpyGameData("CustomAward", awardID) |
| | | if not ipyData: |
| | | GameWorld.DebugAnswer(curPlayer, "不存在该奖励ID:%s" % awardID) |
| | | return |
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardCanGet, awardID, canGet) |
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardGetState, awardID, getState) |
| | | PlayerCustomAward.Sync_CustomAwardInfo(curPlayer, awardID, True) |
| | | GameWorld.DebugAnswer(curPlayer, "奖励ID:%s,可领:%s,已领:%s" % (awardID, canGet, getState)) |
| | | |
| | | return |
| | |
| | | return value
|
| | | return defValue
|
| | |
|
| | | def GetDictKeyNumByBit(bit, isBin=True):
|
| | | perKeyMaxBit = 31 if isBin else 9
|
| | | keyNum = bit / perKeyMaxBit
|
| | | return keyNum
|
| | |
|
| | | ## 根据玩家字典对应的位值, 使用多个key支持N位索引
|
| | | # @param curPlayer
|
| | |
| | | ("float", "NeedRMB", 0),
|
| | | ("dict", "Reward", 0),
|
| | | ),
|
| | |
|
| | | "CustomAward":(
|
| | | ("BYTE", "AwardID", 1),
|
| | | ("list", "AwardItemList", 0),
|
| | | ),
|
| | | }
|
| | |
|
| | | |
| | |
| | | def GetID(self): return self.ID # id
|
| | | def GetNeedRMB(self): return self.NeedRMB # 所需充值元
|
| | | def GetReward(self): return self.Reward # 职业对应的奖励内容,每个职业4组数据,物品ID和物品数量(1.枪豪2.道师3.剑修) |
| | | |
| | | # 奖励表 |
| | | class IPY_CustomAward(): |
| | | |
| | | def __init__(self): |
| | | self.AwardID = 0
|
| | | self.AwardItemList = [] |
| | | return |
| | | |
| | | def GetAwardID(self): return self.AwardID # 奖励ID 1~n
|
| | | def GetAwardItemList(self): return self.AwardItemList # 物品奖励[[物品ID,个数,是否拍品], ...] |
| | |
|
| | |
|
| | | def Log(msg, playerID=0, par=0):
|
| | |
| | | self.ipyFuncSysPrivilegeLen = len(self.ipyFuncSysPrivilegeCache)
|
| | | self.ipyHistoryRechargeAwardCache = self.__LoadFileData("HistoryRechargeAward", IPY_HistoryRechargeAward)
|
| | | self.ipyHistoryRechargeAwardLen = len(self.ipyHistoryRechargeAwardCache)
|
| | | self.ipyCustomAwardCache = self.__LoadFileData("CustomAward", IPY_CustomAward)
|
| | | self.ipyCustomAwardLen = len(self.ipyCustomAwardCache)
|
| | | Log("IPY_FuncConfig count=%s" % len(self.ipyFuncConfigDict))
|
| | | Log("IPY_DataMgr InitOK!")
|
| | | return
|
| | |
| | | def GetFuncSysPrivilegeByIndex(self, index): return self.ipyFuncSysPrivilegeCache[index]
|
| | | def GetHistoryRechargeAwardCount(self): return self.ipyHistoryRechargeAwardLen
|
| | | def GetHistoryRechargeAwardByIndex(self, index): return self.ipyHistoryRechargeAwardCache[index]
|
| | | def GetCustomAwardCount(self): return self.ipyCustomAwardLen
|
| | | def GetCustomAwardByIndex(self, index): return self.ipyCustomAwardCache[index]
|
| | |
|
| | | IPYData = IPY_DataMgr()
|
| | | def IPY_Data(): return IPYData
|
New file |
| | |
| | | #!/usr/bin/python |
| | | # -*- coding: GBK -*- |
| | | #------------------------------------------------------------------------------- |
| | | # |
| | | ##@package Player.PlayerCustomAward |
| | | # |
| | | # @todo:自定义奖励 |
| | | # @author hxp |
| | | # @date 2023-09-22 |
| | | # @version 1.0 |
| | | # |
| | | # 详细描述: 自定义奖励 |
| | | # |
| | | #------------------------------------------------------------------------------- |
| | | #"""Version = 2023-09-22 13:30""" |
| | | #------------------------------------------------------------------------------- |
| | | |
| | | import GameWorld |
| | | import NetPackCommon |
| | | import ChPyNetSendPack |
| | | import IpyGameDataPY |
| | | import ItemCommon |
| | | import ChConfig |
| | | |
| | | def OnPlayerLogin(curPlayer): |
| | | Sync_CustomAwardInfo(curPlayer) |
| | | return |
| | | |
| | | def SetCustomAwardCanGet(curPlayer, awardID, canGet=1): |
| | | ipyData = IpyGameDataPY.GetIpyGameData("CustomAward", awardID) |
| | | if not ipyData: |
| | | return |
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardCanGet, awardID, canGet) |
| | | Sync_CustomAwardInfo(curPlayer, awardID) |
| | | return |
| | | |
| | | ## 领取自定义奖励 |
| | | def OnGetCustomAward(curPlayer, awardID): |
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardCanGet, awardID): |
| | | GameWorld.Log("该自定义奖励当前不可领取, awardID=%s" % awardID, curPlayer.GetPlayerID()) |
| | | return |
| | | if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardGetState, awardID): |
| | | GameWorld.Log("该自定义奖励已经领取过, awardID=%s" % awardID, curPlayer.GetPlayerID()) |
| | | return |
| | | ipyData = IpyGameDataPY.GetIpyGameData("CustomAward", awardID) |
| | | if not ipyData: |
| | | return |
| | | awardItemList = ipyData.GetAwardItemList() |
| | | |
| | | if not ItemCommon.GiveAwardItem(curPlayer, awardItemList): |
| | | return |
| | | |
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_CustomAwardGetState, awardID, 1) |
| | | GameWorld.Log("领取自定义奖励, awardID=%s" % awardID, curPlayer.GetPlayerID()) |
| | | Sync_CustomAwardInfo(curPlayer, awardID) |
| | | return |
| | | |
| | | ## 通知自定义奖励记录 |
| | | def Sync_CustomAwardInfo(curPlayer, awardID=None, force=False): |
| | | if awardID == None: |
| | | awardIDList = [] |
| | | ipyDataMgr = IpyGameDataPY.IPY_Data() |
| | | for index in range(ipyDataMgr.GetCustomAwardCount()): |
| | | ipyData = ipyDataMgr.GetCustomAwardByIndex(index) |
| | | awardIDList.append(ipyData.GetAwardID()) |
| | | else: |
| | | awardIDList = [awardID] |
| | | |
| | | keyNumList = [] |
| | | for aID in awardIDList: |
| | | keyNum = GameWorld.GetDictKeyNumByBit(aID) |
| | | if keyNum not in keyNumList: |
| | | keyNumList.append(keyNum) |
| | | |
| | | if not keyNumList: |
| | | return |
| | | |
| | | recordStateList = [] |
| | | for keyNum in keyNumList: |
| | | canGet = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CustomAwardCanGet % keyNum) |
| | | getState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CustomAwardGetState % keyNum) |
| | | if not canGet and not getState and not force: |
| | | continue |
| | | awardState = ChPyNetSendPack.tagMCCustomAwardState() |
| | | awardState.KeyNum = keyNum |
| | | awardState.CanGetState = canGet |
| | | awardState.GetState = getState |
| | | recordStateList.append(awardState) |
| | | |
| | | if not recordStateList: |
| | | return |
| | | |
| | | clientPack = ChPyNetSendPack.tagMCCustomAwardInfo() |
| | | clientPack.Clear() |
| | | clientPack.RecordStateList = recordStateList |
| | | clientPack.RecordStateCnt = len(clientPack.RecordStateList) |
| | | NetPackCommon.SendFakePack(curPlayer, clientPack) |
| | | return |