#!/usr/bin/python # -*- coding: GBK -*- #--------------------------------------------------------------------- # #--------------------------------------------------------------------- ##@package PlayerVip # @todo: Íæ¼ÒVIPÂß¼­ # # @author: sgj # @date 2017-10-24 # @version 1.0 # # @note: # #--------------------------------------------------------------------- #"""Version = 2017-10-23 16:40""" #--------------------------------------------------------------------- import PlayerControl import GameWorld import ChConfig import NetPackCommon import ChPyNetSendPack import ItemControler import IPY_GameWorld import PlayerDienstgrad import PlayerMagicWeapon import PlayerSuccess import ShareDefine import ItemCommon import DataRecordPack import IpyGameDataPY import NPCCommon import EventReport import EventShell import PassiveBuffEffMng import PlayerFamilyRedPacket import time #--------------------------------------------------------------------- #»ñÈ¡vipÉý¼¶ËùÐèÀۼƾ­Ñé×Öµä key-µÈ¼¶£¬value-¾­Ñé def GetVIPLvUpExp(): return IpyGameDataPY.GetFuncEvalCfg("VIPLV", 1, {}) #»ñÈ¡VIPÿÈÕ¾­Ñé def GetVIPDayExp(): return IpyGameDataPY.GetFuncCfg("VIPLV", 2) #»ñÈ¡vip¼Û¸ñ def GetVIPPrice(cardType): priceDict = IpyGameDataPY.GetFuncEvalCfg("VIPPrice", 1, {}) return priceDict.get(cardType, 0) #»ñÈ¡VIP¿¨¶ÔÓ¦µÄʱ¼ä£¨Ð¡Ê±£© def GetVIPTime(cardType): timeDict = IpyGameDataPY.GetFuncEvalCfg("VIPPrice", 2, {}) return timeDict.get(cardType, 0) #»ñÈ¡VIPµÈ¼¶¶ÔÓ¦µÄ³ÆºÅ def GetVIPTitle(): titleDict = IpyGameDataPY.GetFuncEvalCfg("VIPTitle", 1, {}) return titleDict #»ñÈ¡VIPʱ¼äµÄÉÏÏÞ def GetVIPMaxTime(): maxDay = IpyGameDataPY.GetFuncCfg("VIPLimit", 1) maxHour = maxDay * 24 return GetSeconds(maxHour) #¸ù¾ÝСʱ»ñµÃÃë def GetSeconds(hour): return hour * 60 * 60 #»ñÈ¡ÓʼþµÄ¸ñʽºÍÌìÊý def GetMailMessage(): maxDay = IpyGameDataPY.GetFuncCfg("VIPLimit", 2) return maxDay #»ñÈ¡Ê×´ÎÂò¿¨»ñµÃµÄ¾­Ñé def GetFirstBuyExp(cardType): buyDict = IpyGameDataPY.GetFuncEvalCfg("VIPLimit", 4, {}) return buyDict.get(cardType, 0) ## A8 01 ·â°ü ## ¹ºÂòVIPʱ¼ä # @param None # @return None #struct tagCMBuyVipLV #{ # tagHead Head; # BYTE VipType; // vip¿¨ÀàÐÍ #}; def BuyVipLV(index, clientPack, tick): return # curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) # buyType = clientPack.VipType # price = GetVIPPrice(buyType) # if not price: # return # vipTime = GetVIPTime(buyType) # if not vipTime: # return # # haveVipTime = GetCurVIPTime(curPlayer) # maxTime = GetVIPMaxTime() # if haveVipTime >= maxTime: # GameWorld.DebugLog("VIPʱ¼äÒѾ­µ½´ï×î´óÉÏÏÞ£¬²»¿É¼ÌÐø¹ºÂò--time:%s" % haveVipTime) # return # #ÓеÀ¾ß¿ÛµÀ¾ß£¬Ã»ÓеÀ¾ß¿ÛÇ® # vipCardItemIDDict = IpyGameDataPY.GetFuncEvalCfg('VIPCard', 1) # needItemID = vipCardItemIDDict.get(buyType) # if not needItemID: # return # itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) # hasEnough, itemList = ItemCommon.GetItem_FromPack_ByID(needItemID, itemPack, 1) # if hasEnough: # ItemCommon.ReduceItem(curPlayer, itemPack, itemList, 1, False) # PlayerControl.NotifyCode(curPlayer, 'VipCardHint3', [needItemID]) # else: # infoDict = {"VIPType":buyType} # if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, price, ChConfig.Def_Cost_OpenNoble, infoDict): # GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % price) # return # # record = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipBuyRecord) # hasBuy = record & pow(2, buyType) # if not hasBuy: # addExp = GetFirstBuyExp(buyType) # AddVIPExp(curPlayer, addExp) # GameWorld.DebugLog("Ê×´ÎÂò¿¨--type:%s" % buyType) # record = record|(1 << buyType) # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipBuyRecord, record) # addTime = GetSeconds(vipTime) # AddVIPTime(curPlayer, addTime, "buyVIPCard") # return ##¼ì²éVIP³ÆºÅ # @param curPlayer # @return None def CheckVIPDienstgrad(curPlayer): playerVIPLV = curPlayer.GetVIPLv() if playerVIPLV <= 0: return vipDienstgradDict = GetVIPTitle() for vipLV, dienstgradID in vipDienstgradDict.items(): if playerVIPLV < vipLV: break curDienstgrad = curPlayer.GetDienstgradManager().GetDienstgrad(dienstgradID) # ²»´æÔÚ¸ÃVIP³ÆºÅÔòÌí¼Ó if curDienstgrad == None: PlayerDienstgrad.PlayerAddDienstgrad(curPlayer, dienstgradID) GameWorld.DebugLog("CheckVIPDienstgrad playerVIPLV=%s,vipLV=%s,dienstgradID=%s" % (playerVIPLV, vipLV, dienstgradID), curPlayer.GetPlayerID()) return ## ¹ºÂòÏû·ÑVIPÀñ°ü # @param index # @param clientPack # @param tick # @return def BuyVIPItem(index, clientPack, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) vipLV = clientPack.VIPLV awardMsg = IpyGameDataPY.GetIpyGameData('VIPAward', vipLV) if not awardMsg: GameWorld.DebugLog("ûÓÐvipµÈ¼¶Îª%sµÄÀñ°ü" % vipLV) return curVipLV = curPlayer.GetVIPLv() if curVipLV < vipLV: GameWorld.DebugLog("VIPµÈ¼¶²»×ã--VIPLV:%s" % curVipLV) return record = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipAwardRecord) hasBuy = record & pow(2, vipLV) if hasBuy: GameWorld.DebugLog("vipµÈ¼¶Îª%sµÄÀñ°üÒѾ­¹ºÂò¹ý£¬²»ÄÜÖØ¸´¹ºÂò" % vipLV) return tatalItemDict = awardMsg.GetItemID() playerJob = str(curPlayer.GetJob()) if playerJob not in tatalItemDict: GameWorld.DebugLog("ûÓиÃÖ°ÒµµÄÀñ°üÐÅÏ¢-Ö°Òµ:%s--%s" % (playerJob, str(tatalItemDict))) return itemList = tatalItemDict[playerJob] needSpace = len(itemList) packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) if needSpace > packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem]) return itemPrice = awardMsg.GetPrice() infoDict = {"VIPLV":vipLV} if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, itemPrice, ChConfig.Def_Cost_BuyVIPItem, infoDict): GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % itemPrice) return record = record|(1 << vipLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipAwardRecord, record) EventShell.EventResponse_BuyVIPItem(curPlayer, vipLV) GameWorld.DebugLog("vipÀñ°ü-%s" % itemList) for itemid, cnt, isBind in itemList: ItemControler.GivePlayerItem(curPlayer, int(itemid), int(cnt), isBind, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], True, showSysInfo=True, event=["buyVIPGift", False, {"VIPLV":vipLV}]) # else: # __AwardToPlayerByMail(curPlayer, itemList) openuiid = IpyGameDataPY.GetFuncEvalCfg('VIPPanel', 1, {}).get(vipLV, 0) PlayerControl.WorldNotify(0, 'BuyVIPGift', [curPlayer.GetName(), vipLV, itemList[0][0], openuiid]) Sycn_VIPAwardRecord(curPlayer) return #·¢Óʼþ def __AwardToPlayerByMail(curPlayer, mailItemInfoList): MailMessage = GetMailMessage() content = ShareDefine.Def_MailFormat % (MailMessage[0], '') getDays = MailMessage[1] PlayerControl.SendMail('', content, getDays, [curPlayer.GetPlayerID()], mailItemInfoList) ##VIPµÇ¼´¦Àí # @param curPlayer # @return None def DoOnLogin(curPlayer, tick): #¼Ç¼µÇ½ʱ¼ä Sycn_VIPMsg(curPlayer) Sycn_VIPAwardRecord(curPlayer) Sycn_VIPTime(curPlayer, True) SyncVIPKillNPCLVInfo(curPlayer) return #------------------------------------------------------------------------------- #VIPÿÈÕ´¦Àí def VipOnDay(curPlayer): return # vipTime = PlayerControl.GetVIPExpireTime(curPlayer) # if not vipTime: # return # vipStr = GameWorld.ChangeTimeNumToStr(vipTime, timeFormat=ChConfig.TYPE_Time_Format) # vipZeroTime = GetZeroTime(vipStr) # curZeroTime = GetZeroTime(GameWorld.GetCurrentDataTimeStr()) # lastTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPLastTime) # if lastTime == 0: # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPLastTime, curZeroTime) # # if vipZeroTime >= curZeroTime: # n = (curZeroTime - lastTime) / (24 * 60 * 60) # elif vipZeroTime > lastTime: # n = (vipZeroTime - lastTime) / (24 * 60 * 60) # else: # n = 0 # AddVIPExp(curPlayer, GetVIPDayExp() * n) # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPLastTime, curZeroTime) #¸ù¾Ýʱ¼ä»ñµÃµ±ÌìµÄÁãµãʱ¼ä def GetZeroTime(strTick): tickList = strTick.split(' ') newStrTick = tickList[0] + ' ' + '00:00:00' return GameWorld.ChangeTimeStrToNum(newStrTick) #VIP¾­ÑéÔö¼ÓÈë¿Ú def AddVIPExp(curPlayer, exp): if exp <= 0: return vipExp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipExp) + exp preVIPLV = curPlayer.GetVIPLv() vipLV = preVIPLV + 1 vipExpDict = GetVIPLvUpExp() PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipExp, vipExp) if vipLV not in vipExpDict: GameWorld.DebugLog("vipÒѾ­Âú¼¶--vipLV:%s" % (vipLV - 1)) Sycn_VIPMsg(curPlayer) return while vipLV in vipExpDict and vipExp >= vipExpDict[vipLV]: curPlayer.SetVIPLv(vipLV) OnChangeVIPLv(curPlayer, vipLV) ##µ±VIPµÈ¼¶±ä¸ü£¬´¥·¢µÄ·½·¨Ð´ÔÚÕâÀï PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_VIPLV, 1, [vipLV]) vipLV += 1 GameWorld.DebugLog("VIPµÈ¼¶--%s,¾­Ñé--%s" % (curPlayer.GetVIPLv(), vipExp)) Sycn_VIPMsg(curPlayer) if not preVIPLV: Sycn_VIPTime(curPlayer) DataRecordPack.DR_VIPChange(curPlayer, "addVIPExp", {"Viplv":curPlayer.GetVIPLv(), 'VipExp':vipExp}) return True ##µ±VIPµÈ¼¶±ä¸ü£¬´¥·¢µÄ·½·¨Ð´ÔÚÕâÀï # @param curPlayer Íæ¼Ò # @return None def OnChangeVIPLv(curPlayer, vipLV): #vipµÈ¼¶¸Ä±ä´¥·¢ÈÎÎñ EventShell.EventResponse_OnVipLvUp(curPlayer, vipLV) CheckVIPDienstgrad(curPlayer) #ɾ³ýVIPÌåÑ鿨ÎïÆ· __DelVIPExperienceItem(curPlayer) RefreshVIPAttr(curPlayer) EventReport.WriteEvent_VIP(curPlayer) #ºì°ü½±Àø redPacketID = IpyGameDataPY.GetFuncEvalCfg('VIPRedPackAward', 1, {}).get(vipLV, 0) if redPacketID: PlayerFamilyRedPacket.CreatRedPacketByID(curPlayer, redPacketID) return #Í¨ÖªÍæ¼Ò¹ºÂòÀñ°ü¼Í¼ def Sycn_VIPAwardRecord(curPlayer): pack = ChPyNetSendPack.tagMCVIPAwardMsg() pack.AwardMsg = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipAwardRecord) GameWorld.DebugLog("ÁìÈ¡¼Ç¼!--%s" % pack.AwardMsg) NetPackCommon.SendFakePack(curPlayer, pack) #֪ͨvip¾­ÑéºÍµÈ¼¶ #Exp --vip¾­Ñé #BuyState --vipµÈ¼¶ def Sycn_VIPMsg(curPlayer): pack = ChPyNetSendPack.tagMCVIPInfo() pack.Exp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipExp) pack.VIPLV = curPlayer.GetVIPLv() NetPackCommon.SendFakePack(curPlayer, pack) #֪ͨVIPÊ£Óàʱ¼ä def Sycn_VIPTime(curPlayer, islogin=False, isForce=False): pack = ChPyNetSendPack.tagMCNotifyVipTime() pack.Time = GetCurVIPTime(curPlayer, islogin) pack.ExperienceTime = GetVIPExperienceTime(curPlayer, islogin) if pack.Time > 0 or pack.ExperienceTime > 0 or isForce: NetPackCommon.SendFakePack(curPlayer, pack) #Ψһ»ñȡʵʱµÄVIPʱ¼äµÄ·½·¨£¬²»ÄÜÖ±½Óͨ¹ý PlayerControl.GetVIPExpireTime(curPlayer) »ñÈ¡ def GetCurVIPTime(curPlayer, islogin=False): return 1 # vipTime = PlayerControl.GetVIPExpireTime(curPlayer) # curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr()) # if vipTime <= curTime: # if vipTime: # timeoutRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipTimeOutRecord) # # ³£¹æ¹ýÆÚ´¦Àí # if not timeoutRecord: # GameWorld.DebugLog("VIP¹ýÆÚ´¦Àí: vipTime=%s,curTime=%s" % (vipTime, curTime), curPlayer.GetPlayerID()) # # ¹ýÆÚ±ä¸ü´¦Àí # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipTimeOutRecord, 1) # #Operate_EquipStone.OnVIPTimeOut(curPlayer) # RefreshVIPAttr(curPlayer) # # # µÇ¼״̬϶îÍâ´¦Àí # if islogin and timeoutRecord != 2: # GameWorld.DebugLog("VIP¹ýÆÚµÇ¼´¦Àí: vipTime=%s,curTime=%s" % (vipTime, curTime), curPlayer.GetPlayerID()) # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipTimeOutRecord, 2) # PlayerControl.NotifyCode(curPlayer, 'Vip_Timeout') # return 0 # else: # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipTimeOutRecord, 0) # return vipTime - curTime # return vipTime #Ôö¼ÓVIPʱ¼ä # addTime µ¥Î»Ãë def AddVIPTime(curPlayer, addTime, addType="buyVIPTime"): # isReActivate = False # ÊÇ·ñÖØÐ¼¤»îµÄ # haveVipTime = GetCurVIPTime(curPlayer) # if not haveVipTime: # isReActivate = True # curZeroTime = GetZeroTime(GameWorld.GetCurrentDataTimeStr()) # PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPLastTime, curZeroTime) # haveVipTime += addTime # if haveVipTime > ShareDefine.Def_UpperLimit_DWord: # haveVipTime = ShareDefine.Def_UpperLimit_DWord # curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr()) # totalTime = curTime + haveVipTime # PlayerControl.SetVIPExpireTime(curPlayer, totalTime) # timeDict = {"oldTime":haveVipTime, "newTime":totalTime, "addTime":addTime, "addType":addType} # DataRecordPack.DR_VIPTimeChange(curPlayer, "addVIPTime", timeDict) # GameWorld.DebugLog("µ½ÆÚʱ¼ä--%s" % GameWorld.ChangeTimeNumToStr(totalTime, timeFormat=ChConfig.TYPE_Time_Format)) # Sycn_VIPTime(curPlayer) # if isReActivate: # RefreshVIPAttr(curPlayer) return True def __DelVIPExperienceItem(curPlayer): ## VIP±ä¸üʱɾ³ý±³°üºÍ²Ö¿âµÄvipÌåÑ鿨 for packIndex in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]: curPack = curPlayer.GetItemManager().GetPack(packIndex) for i in range(0, curPack.GetCount()): curItem = curPack.GetAt(i) if not curItem: continue if curItem.GetItemTypeID() != ChConfig.Def_ItemID_VIPExperience: continue itemCount = curItem.GetCount() ItemCommon.DelItem(curPlayer, curItem, itemCount, True, "DelVIPExperienceItem") return def UseItemVIPExperience(curPlayer): ## ʹÓÃvipÌåÑ鿨 if curPlayer.GetVIPLv(): PlayerControl.NotifyCode(curPlayer, 'VipCardHint2') return #ѧϰÁú·ïïí¼¼ÄÜ£¬Ê§Ð§ºóÔÙɾ³ý PlayerMagicWeapon.GiveSkill(curPlayer, ChConfig.Def_SkillID_LFZ, GameWorld.GetGameWorld().GetTick(), False) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipExperienceStartTime, int(time.time())) Sycn_VIPTime(curPlayer) PlayerControl.NotifyCode(curPlayer, 'VipCardHint1') return True def CheckVIPExperience(curPlayer, tick): ## ¼ì²évipÌåÑéÊÇ·ñ½áÊø startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipExperienceStartTime) if not startTime: return if not GameWorld.CheckPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_VIPExperience, tick): return if not GetVIPExperienceTime(curPlayer): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VipExperienceStartTime, 0) if curPlayer.GetVIPLv() == 0: PlayerControl.NotifyCode(curPlayer, 'VipTiyan_Timeout') Sycn_VIPTime(curPlayer, isForce=True) GameWorld.DebugLog(' VIPÌåÑ鿨½áÊø£¡', curPlayer.GetID()) #ɾ³ýÌåÑé¼¼ÄÜ skillManager = curPlayer.GetSkillManager() if skillManager.FindSkillBySkillTypeID(ChConfig.Def_SkillID_LFZ): skillManager.DeleteSkillBySkillTypeID(ChConfig.Def_SkillID_LFZ) # ÖØË¢±»¶¯¼¼ÄÜ PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer) # ÖØË¢¼¼ÄÜÕ½Á¦ PlayerControl.PlayerControl(curPlayer).RefreshAllSkill() return True return def GetVIPExperienceTime(curPlayer, isLogin=False): ## ÊÇ·ñVIPÌåÑéÖÐ startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipExperienceStartTime) if not startTime: return 0 if curPlayer.GetVIPLv(): return 0 curTime = int(time.time()) experienceTime = IpyGameDataPY.GetFuncCfg('VIPExperience', 2) if curTime - startTime >= experienceTime: return 0 return experienceTime - (curTime - startTime) #¸ù¾ÝÌØÈ¨ID ºÍ VIPµÈ¼¶»ñµÃÌØÈ¨Öµ #tequanID ÌØÈ¨ID #playerVipLv Íæ¼ÒVIPµÈ¼¶£¬»ñµÃ¶ÔÓ¦vipµÈ¼¶µÄÌØÈ¨Öµ£¬-1ʱ»ñµÃÍæ¼ÒVIPµÈ¼¶¶ÔÓ¦µÄÌØÈ¨Öµ def GetPrivilegeValue(curPlayer, privilegeID, playerVipLv=-1, isCheckTime=True): if privilegeID not in ChConfig.VIPPrivilegeList: return 0 isExperience = False if playerVipLv != -1: vipLV = playerVipLv elif GetVIPExperienceTime(curPlayer): isExperience = True VIPExperiencePrivilegeDict = IpyGameDataPY.GetFuncCfg('VIPExperience', 1) vipLV = VIPExperiencePrivilegeDict.get(privilegeID, 0) else: vipLV = curPlayer.GetVIPLv() vipMsg = IpyGameDataPY.GetIpyGameData('VipPrivilege', privilegeID) if not vipMsg: return 0 priVlaue = getattr(vipMsg, 'GetVIP%d' % vipLV)() if not isCheckTime: return priVlaue if vipLV and GetCurVIPTime(curPlayer) <= 0 and playerVipLv == -1 and not isExperience: priVlaue = vipMsg.GetVIP0() return priVlaue #»ñÈ¡VIPÌØÈ¨±íÌØÈ¨Êý¾Ý def GetVipPrivilegeData(privilegeID): return IpyGameDataPY.GetIpyGameData('VipPrivilege', privilegeID) #--------------------------------------------------------------------- ##»ñÈ¡µ±Ç°´¢ÖµÓ¦¸ÃÓµÓеÄVIPµÈ¼¶ def RefreshVIPAttr(curPlayer): CalcVIPAttr(curPlayer) PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return def CalcVIPAttr(curPlayer): allAttrList = [{} for _ in range(4)] # ÊôÐÔÐèÒªÅжÏÊÇ·ñ¹ýÆÚ #if GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_VIPKillNPCAddAtk): mwID = IpyGameDataPY.GetFuncCfg("VIPAddAtkEXP", 2) # VIPɱ¹Ö¼ÓÊôÐÔËùÐ輤»î·¨±¦ if PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, mwID): killLV = GetVIPKillNPCLV(curPlayer) killLVIpyData = IpyGameDataPY.GetIpyGameData("VIPKillNPC", killLV) if killLVIpyData: PlayerControl.CalcAttrDict_Type(ShareDefine.Def_Effect_MinAtk, killLVIpyData.GetAddMinAtk(), allAttrList) PlayerControl.CalcAttrDict_Type(ShareDefine.Def_Effect_MaxAtk, killLVIpyData.GetAddMaxAtk(), allAttrList) PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_VIP, allAttrList) return #// A8 05 VIPɱ¹ÖµÈ¼¶ÐÅϢͬ²½¿ª¹Ø #tagCMVIPKillNPCLVInfoSwitch # #struct tagCMVIPKillNPCLVInfoSwitch #{ # tagHead Head; # BYTE IsOn; // ÊÇ·ñ¿ªÆôͬ²½ #}; def OnVIPKillNPCLVInfoSwitch(index, clientPack, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) isOn = clientPack.IsOn curPlayer.SetDict(ChConfig.Def_PlayerKey_SyncVIPKillNPCLVInfo, isOn) if isOn: SyncVIPKillNPCLVInfo(curPlayer) GameWorld.DebugLog("VIPɱ¹ÖµÈ¼¶ÐÅϢͬ²½¿ª¹Ø, isOn=%s" % isOn, curPlayer.GetPlayerID()) return def DoAddVIPKillLVExp(curPlayer, curNPC, killCount=1): ''' »÷ɱNPCÔö¼ÓVIPɱ¹ÖµÈ¼¶¾­Ñ飬ֻËã»÷ɱµÄ£¬¶ÓÔ±»÷ɱÎÞЧ ''' # ¹ýÆÚʱҲÓÐЧ #if not GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_VIPKillNPCAddAtk, isCheckTime=False): # return mwID = IpyGameDataPY.GetFuncCfg("VIPAddAtkEXP", 2) # VIPɱ¹Ö¼ÓÊôÐÔËùÐ輤»î·¨±¦ if not mwID or not PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, mwID): return npcLV = NPCCommon.GetNPCLV(curNPC) addExp = eval(IpyGameDataPY.GetFuncCompileCfg("VIPAddAtkEXP", 1)) addExp *= killCount if not addExp: return totalKillLVExp = GetVIPKillNPCLVExp(curPlayer) + addExp # Âú¼¶Ò²¼ÌÐø¼Ó befKillLV = GetVIPKillNPCLV(curPlayer) maxKillLV = IpyGameDataPY.IPY_Data().GetVIPKillNPCCount() aftKillLV = befKillLV # ·ÇÂú¼¶²Å´¦ÀíÉý¼¶Âß¼­ if befKillLV < maxKillLV: aftKillLV, totalKillLVExp = __DoVIPKillNPCLVUp(curPlayer, befKillLV, maxKillLV, totalKillLVExp) totalKillLVExp = SetVIPKillNPCLVExp(curPlayer, totalKillLVExp) #GameWorld.DebugLog("ɱ¹ÖÔö¼ÓVIPɱ¹ÖµÈ¼¶¾­Ñé: npcLV=%s,addExp=%s,totalKillLVExp=%s,befKillLV=%s,aftKillLV=%s,maxKillLV=%s" # % (npcLV, addExp, totalKillLVExp, befKillLV, aftKillLV, maxKillLV), curPlayer.GetPlayerID()) #ͬ²½¿Í»§¶Ë if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_SyncVIPKillNPCLVInfo) or befKillLV != aftKillLV: SyncVIPKillNPCLVInfo(curPlayer) return def __DoVIPKillNPCLVUp(curPlayer, befKillLV, maxKillLV, totalKillLVExp): ## ´¦ÀíVIP»÷ɱNPCµÈ¼¶Éý¼¶ aftKillLV = befKillLV killLVIpyData = IpyGameDataPY.GetIpyGameData("VIPKillNPC", aftKillLV) if killLVIpyData: lvUPNeedExp = killLVIpyData.GetLVExpPoint() * ChConfig.Def_PerPointValue + killLVIpyData.GetLVExp() while killLVIpyData and totalKillLVExp >= lvUPNeedExp: totalKillLVExp -= lvUPNeedExp aftKillLV += 1 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPKillLV, aftKillLV) if aftKillLV >= maxKillLV: break killLVIpyData = IpyGameDataPY.GetIpyGameData("VIPKillNPC", aftKillLV) if killLVIpyData: lvUPNeedExp = killLVIpyData.GetLVExpPoint() * ChConfig.Def_PerPointValue + killLVIpyData.GetLVExp() if befKillLV != aftKillLV: RefreshVIPAttr(curPlayer) return aftKillLV, totalKillLVExp def GetVIPKillNPCLV(curPlayer): return max(1, curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPKillLV)) def GetVIPKillNPCLVExp(curPlayer): exp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPKillLVExp) expPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPKillLVExpPoint) return expPoint * ChConfig.Def_PerPointValue + exp def SetVIPKillNPCLVExp(curPlayer, totalKillLVExp): totalKillLVExp = min(totalKillLVExp, ChConfig.Def_HugeValue) updExp = totalKillLVExp % ChConfig.Def_PerPointValue updExpPoint = totalKillLVExp / ChConfig.Def_PerPointValue PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPKillLVExp, updExp) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_VIPKillLVExpPoint, updExpPoint) return totalKillLVExp def SyncVIPKillNPCLVInfo(curPlayer): killLVInfo =ChPyNetSendPack.tagMCVIPKillNPCLVInfo() killLVInfo.KillLV = GetVIPKillNPCLV(curPlayer) killLVInfo.KillLVExpPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPKillLVExpPoint) killLVInfo.KillLVExp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VIPKillLVExp) NetPackCommon.SendFakePack(curPlayer, killLVInfo) return