#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerGodWeapon # # @todo:Éñ±ø # @author alee # @date 2017-07-20 # @version 1.0 # # ÏêϸÃèÊö: Éñ±ø # #--------------------------------------------------------------------- #"""Version = 2017-07-20 16:00""" #--------------------------------------------------------------------- import GameWorld import EventShell import ChConfig import PlayerControl import ItemCommon import IPY_GameWorld import ChPyNetSendPack import NetPackCommon import PlayerSuccess import ShareDefine import SkillShell import DataRecordPack import GameFuncComm import SkillCommon import BuffSkill import PlayerWeekParty #import EventReport import IpyGameDataPY import PassiveBuffEffMng import OpenServerCampaign import random Def_GodWeaponType_HP = 1 # ÉúÃüÉñ±øÀàÐÍ Def_GodWeaponType_Atk = 2 # ¹¥»÷Éñ±øÀàÐÍ Def_GodWeaponType_SuperHit = 3 # ±©»÷Éñ±øÀàÐÍ Def_GodWeaponType_Def = 4 # »¤¶ÜÉñ±øÀàÐÍ ## ÉñÆ÷¹¦ÄܵǼ´¦Àí # @param curPlayer Íæ¼Ò # @return None def OnLogin(curPlayer): if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon): return Sync_GodWeaponLVInfo(curPlayer) return def SetGodWeaponLV(curPlayer, weaponType, lv): ## ÉèÖÃÉñ±øµÈ¼¶£¬Í¬²½ÉèÖó¡¾°Éñ±øµÈ¼¶ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponLV % weaponType, lv) totalLV = GetGodWeaponTotalLV(curPlayer) # ¿ª·þ»î¶¯Êý¾Ý OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_GodWeaponLV, totalLV) PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_GodWeapon, totalLV, False, True) return def GetGodWeaponTotalLV(curPlayer): ##»ñÈ¡Éñ±ø×ܵȼ¶ totalLV = 0 ipyDataMgr = IpyGameDataPY.IPY_Data() maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType() for gwType in xrange(1, maxType + 1): totalLV += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType) return totalLV ## ÉñÆ÷¿ªÆô # @return: ÊÇ·ñ¼¤»î³É¹¦ def DoGodWeaponOpen(curPlayer): # ĬÈϼ¤»î1¼¶µÄÀàÐÍ for i in IpyGameDataPY.GetFuncEvalCfg('GodWeaponActive'): SetGodWeaponLV(curPlayer, i, 1) PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, 1, [i]) Sync_GodWeaponLVInfo(curPlayer) return True ## Ë¢ÐÂÉñ±øÊôÐÔ def RefreshGodWeaponAttr(curPlayer): CalcGodWeaponAttr(curPlayer) # ²»Á¢¼´Ë¢Ð PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return ## ¼ÆËãÊôÐÔ # @param curPlayer Íæ¼Ò # @param allAttrList ÊôÐÔÁбí # @return None def CalcGodWeaponAttr(curPlayer): if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon): return ipyDataMgr = IpyGameDataPY.IPY_Data() maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType() fightPowerEx = 0 # ¶îÍâÔö¼ÓµÄÕ½Á¦ allAttrList = [{} for i in range(4)] for gwType in xrange(1, maxType + 1): # ÒòΪÉñ±ø½âËøÌõ¼þ×öÁ˵÷Õû£¬ÓÉ֮ǰµÄ0~1½×½âËø¸ÄΪÓÉǰÖÃÉñ±øÀàÐ͵ȼ¶½âËø£¬Ä¬ÈϽâËøºóΪ1½× # Ϊ¼æÈÝÀϺţ¬Ë¢ÊôÐÔʱֻҪÅжϵȼ¶ÊÇ·ñ´óÓÚ0£¬²»¹ÜÊÇ·ñ½âËø£¬ÐºŽâËøÓÉÉñ±øÉý¼¶µÄʱºò½øÐнâËø attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType) if not attrLV: continue godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', gwType, attrLV) if not godWeaponData: continue attrTypeList, attrValueList = godWeaponData.GetAttrType(), godWeaponData.GetAttrNum() for i, attrID in enumerate(attrTypeList): PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList) fightPowerEx += IpyGameDataPY.GetFuncEvalCfg('MagicExterior').get(str(gwType), 0) # ¸½¼ÓÕ½Á¦ curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_GodWeapon, fightPowerEx) #GameWorld.DebugLog("Éñ±øÊôÐÔ£º%s" % allAttrList) # ±£´æ¼ÆËãÖµ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GodWeapon, allAttrList) return #--------------------------------------------------------------------------------------------------- #// A5 56 Éñ±ø¼¤»î #tagCMGodWeaponActivate # #struct tagCMGodWeaponActivate #{ # tagHead Head; # DWORD WeaponType; // Éñ±øÀàÐÍ #}; def OnGodWeaponActivate(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) weaponType = clientData.WeaponType if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % weaponType): GameWorld.DebugLog("ÒѾ­½âËøµÄÉñ±ø!weaponType=%s" % weaponType) return # Âú×ãÍæ¼ÒµÈ¼¶»òÕßǰÖÃÉñ±øµÈ¼¶¿É½âËø if __GWCheckPlayerLV(curPlayer, weaponType) or __GWCheckOtherGWLV(curPlayer, weaponType): SetGodWeaponLV(curPlayer, weaponType, 1) RefreshGodWeaponAttr(curPlayer) GameWorld.DebugLog("½âËøÉñ±ø: weaponType=%s" % weaponType) Sync_GodWeaponLVInfo(curPlayer, weaponType) return # Éñ±ø¼¤»îÐè2´ÎÅжϵȼ¶ {2:100, 4:100} def __GWCheckPlayerLV(curPlayer, weaponType): godWeaponUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GodWeaponActive", 3, {}) if str(weaponType) not in godWeaponUnlockDict: GameWorld.DebugLog("¸ÃÉñ±ø²»ÄܽâËø!weaponType=%s" % weaponType) return False return curPlayer.GetLV() >= godWeaponUnlockDict[str(weaponType)] # Éñ±ø¼¤»îÐèÅжÏǰÖÃÉñ±øµÈ¼¶ def __GWCheckOtherGWLV(curPlayer, weaponType): godWeaponUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GodWeaponActive", 2, {}) if str(weaponType) not in godWeaponUnlockDict: GameWorld.DebugLog("¸ÃÉñ±ø²»ÄܽâËø!weaponType=%s" % weaponType) return False conditionList = godWeaponUnlockDict[str(weaponType)] for needType, needLV in conditionList: needTypeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % needType) if needTypeLV < needLV: GameWorld.DebugLog("ËùÐèǰÖÃÉñ±øµÈ¼¶²»×㣬ÎÞ·¨½âËø£¡weaponType=%s,needType=%s,needLV=%s > needTypeLV(%s)" % (weaponType, needType, needLV, needTypeLV)) return False return True #=============================================================================== #// A5 55 Éñ±øÉý¼¶ #tagCMGodWeaponPlus # #struct tagCMGodWeaponPlus #{ # tagHead Head; # DWORD WeaponType; // Éñ±øÀàÐÍ # DWORD ItemID; //ÏûºÄµÄÎïÆ·ID # BYTE ItemCount; //ÏûºÄ¸öÊý£¬Ä¬ÈÏ1 # BYTE IsAutoBuy; //ÊÇ·ñ×Ô¶¯¹ºÂò£¬Ä¬ÈÏ0 #}; #=============================================================================== def OnPlusGodWeapon(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) weaponType = clientData.WeaponType useItemID = clientData.ItemID useItemCount = max(1, clientData.ItemCount) isAutoBuy = clientData.IsAutoBuy if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon): #µÈ¼¶²»×ã return #1.ÅжϱíÖÐÓÐû´ËÀàÐÍ£¬2.ÊÇ·ñÂú¼¶£¬3.ÅжÏÊÇ·ñÓÐÎïÆ· attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % weaponType) # if not attrLV and Def_GodWeaponType_SuperHit != weaponType: # GameWorld.DebugLog("Éñ±øÎ´½âËø£¬ÎÞ·¨Éý¼¶£¡weaponType=%s,attrLV=%s" % (weaponType, attrLV)) # return ÓÉÅäÖñí¾ö¶¨µÈ¼¶0ÊÇ·ñ¿ÉÉý¼¶ beforeAttrLV = attrLV # ÓÃÓÚÌáʾ godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV) if not godWeaponData: GameWorld.DebugLog('Éñ±øÉý¼¶ÕÒ²»µ½Êý¾Ý %s-%s'%(weaponType, attrLV)) return totalExp = godWeaponData.GetExp() if totalExp == 0: #Âú¼¶ return #ÑéÖ¤ÊÇ·ñÖ¸¶¨µÄÎïÆ·ID if useItemID not in IpyGameDataPY.GetFuncEvalCfg("GodWeapon%s"%weaponType): return itemData = GameWorld.GetGameData().GetItemByTypeID(useItemID) if not itemData: return effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Item_Eff_GodWeaponExp) if not effect: GameWorld.DebugLog('###Éñ±ø¼Ù°ü£¬ÎïÆ·ID=%sûÓо­ÑéÖµ'%useItemID) return itemExp = effect.GetEffectValue(0) if not itemExp: GameWorld.DebugLog('###Éñ±ø¼Ù°ü£¬ÎïÆ·ID=%sûÓо­ÑéÖµ'%useItemID) return goldExpTotal = 0 costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, useItemID, useItemCount) lackCount = max(0, useItemCount - (bindCnt + unBindCnt)) if lackCount > 0: if not isAutoBuy: GameWorld.DebugLog("Éñ±øÉý¼¶ÏûºÄ²»×ã!useItemID=%s,useItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCount=%s" % (useItemID, useItemCount, bindCnt, unBindCnt, lackCount)) return godMagicExpDict = IpyGameDataPY.GetFuncEvalCfg("GodMagicExp", 1, {}) if str(weaponType) not in godMagicExpDict: return costGold, goldExp = godMagicExpDict[str(weaponType)] lackCost = costGold * lackCount goldExpTotal = goldExp * lackCount #lackCost = ItemCommon.GetAutoBuyItemNeedGold({useItemID:lackCount}) if lackCost <= 0: return infoDict = {ChConfig.Def_Cost_Reason_SonKey:useItemID, "lackCount":lackCount} if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, lackCost, ChConfig.Def_Cost_GodWeapon, infoDict, lackCount): return delUseItemCount = useItemCount - lackCount # ¿Û³ýÏûºÄ if delUseItemCount: ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delUseItemCount, ChConfig.ItemDel_GodWeapon) addTotalExp = itemExp * delUseItemCount + goldExpTotal befExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType) curExp = befExp + addTotalExp GameWorld.DebugLog("Ö´ÐÐÉñ±øÉý¼¶: weaponType=%s,beforeAttrLV=%s,befExp=%s,addTotalExp=%s(%s*%s+%s),curExp=%s" % (weaponType, beforeAttrLV, befExp, addTotalExp, itemExp, delUseItemCount, goldExpTotal, curExp)) isLVUP = False # °²È«ÎªÖ÷²»ÓÃwhile for _ in xrange(100): if curExp < totalExp: break godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV+1) if not godWeaponData: GameWorld.DebugLog('Éñ±øÉý¼¶ÕÒ²»µ½Êý¾Ý %s-%s'%(weaponType, attrLV)) break GameWorld.DebugLog(" Éñ±øÉý¼¶: attrLV=%s,needExp=%s" % (attrLV, totalExp)) curExp = curExp - totalExp attrLV += 1 isLVUP = True GodWeaponLVUP(curPlayer, godWeaponData, attrLV) totalExp = godWeaponData.GetExp() if totalExp == 0: curExp = 0 #Âú¼¶ break PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponExp % weaponType, curExp) if isLVUP: SetGodWeaponLV(curPlayer, weaponType, attrLV) GameWorld.DebugLog("Éñ±øÉý¼¶½á¹û: attrLV=%s,curExp=%s" % (attrLV, curExp)) RefreshGodWeaponAttr(curPlayer) #xÉñÆ÷´ïµ½X¼¶³É¾Í PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, attrLV, [weaponType]) EventShell.EventRespons_GodWeaponUp(curPlayer, weaponType, attrLV) if beforeAttrLV == 0: # ½â·â֪ͨ sysMark = IpyGameDataPY.GetFuncEvalCfg('GodWeaponSys', 1, {}).get(weaponType, 'GetGodWeapon') PlayerControl.WorldNotify(0, sysMark, [curPlayer.GetName(), weaponType]) #{1:[100,200,300,400],2:[100,200,300,400],3:[100,200,300,400]} #======================================================================= # notifyDict = IpyGameDataPY.GetFuncEvalCfg('GodLv', 1, {}) # if weaponType in notifyDict: # for notifyLV in notifyDict[weaponType]: # if beforeAttrLV < notifyLV and attrLV >= notifyLV: # PlayerControl.WorldNotify(0, 'GodWeaponLv', [curPlayer.GetName(), weaponType, notifyLV]) #======================================================================= totalExp = godWeaponData.GetExp() Sync_GodWeaponLVInfo(curPlayer, weaponType) #ÈÎÎñ EventShell.EventRespons_PlusGodWeapon(curPlayer, weaponType) return #Éñ±øÉý¼¶´¥·¢ÆäËû¹¦ÄÜ£º¼¼ÄÜ def GodWeaponLVUP(curPlayer, godWeaponData, attrLV): skillID = godWeaponData.GetSkillID() if skillID: if __GiveGodWeaponSkill(curPlayer, skillID): sysMark = godWeaponData.GetSysMark() if sysMark: PlayerControl.WorldNotify(0, sysMark, [curPlayer.GetName(), attrLV, skillID]) return skillID return ## ͬ²½ÉñÆ÷µÈ¼¶ # @param curPlayer # @param godWeaponId ÉñÆ÷ID # @return None def Sync_GodWeaponLVInfo(curPlayer, godWeaponID=0): sendPack = ChPyNetSendPack.tagMCGodWeaponLVList() sendPack.Clear() sendPack.WeaponInfoList = [] if godWeaponID <= 0: # weaponStateStr = bin(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponState))[::-1][:-2] # for i in range(0, len(weaponStateStr)): # if weaponStateStr[i] == '0': # #ÕÒ³ö¼¤»îµÄÉñ±ø # continue ipyDataMgr = IpyGameDataPY.IPY_Data() maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType() for i in xrange(1, maxType + 1): weaponInfo = ChPyNetSendPack.tagMCGodWeaponLVInfo() weaponInfo.Clear() weaponInfo.WeaponType = i weaponInfo.WeaponLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % i) weaponInfo.WeaponExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % i) sendPack.WeaponInfoList.append(weaponInfo) else: weaponInfo = ChPyNetSendPack.tagMCGodWeaponLVInfo() weaponInfo.Clear() weaponInfo.WeaponType = godWeaponID weaponInfo.WeaponLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % godWeaponID) weaponInfo.WeaponExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % godWeaponID) sendPack.WeaponInfoList.append(weaponInfo) sendPack.WeaponNum = len(sendPack.WeaponInfoList) NetPackCommon.SendFakePack(curPlayer, sendPack) return def __GiveGodWeaponSkill(curPlayer, skillID): # ÉñÆ÷ѧϰ¼¼ÄÜ skillManager = curPlayer.GetSkillManager() if skillManager.FindSkillBySkillID(skillID): GameWorld.DebugLog("godSkill() have learned skill(%s)" % skillID) return skillData = GameWorld.GetGameData().GetSkillBySkillID(skillID) if skillData == None: GameWorld.DebugLog("godSkill() hasn't find skill(%s)" % skillID) return if not SkillShell.CheckLearnSkillCondition(curPlayer, skillData): GameWorld.DebugLog("godSkill() learn skill(%s) condition isn't enough" % skillID) return skillLV = skillData.GetSkillLV() skillTypeID = skillData.GetSkillTypeID() befSkillID, beforeFightPower = 0, 0 befSkill = skillManager.FindSkillBySkillTypeID(skillTypeID) if befSkill: befSkillLV = befSkill.GetSkillLV() befSkillID = befSkill.GetSkillID() beforeFightPower = befSkill.GetFightPower() if skillLV <= befSkillLV: GameWorld.DebugLog("godSkill() learn skill(%s) skillLV(%s) <= befSkillLV(%s),befSkillID=%s no need learn." % (skillID, skillLV, befSkillLV, befSkillID)) return skillManager.LearnSkillByID(skillID) #PlayerControl.NotifyCode(curPlayer, "Skill_andyshao_31379", [skillResId]) GameWorld.DebugLog("godSkill() skill(%s) success! befSkillID=%s,beforeFightPower=%s" % (skillID, befSkillID, beforeFightPower)) DataRecordPack.DR_LearnORUPSkill(curPlayer, skillID, 0) #if SkillCommon.isPassiveSkill(skillData): # buffType = SkillCommon.GetBuffType(skillData) # BuffSkill.DoAddBuff(curPlayer, buffType, skillData, GameWorld.GetGameWorld().GetTick(), [], curPlayer) PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, skillID) PlayerControl.PlayerControl(curPlayer).RefreshSkillFightPowerEx(skillID, beforeFightPower) return True