From d5b67363261409849207d8516b29e34f4726300e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 25 十月 2018 14:47:12 +0800
Subject: [PATCH] 2215 脱机挂在线时间异常
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py | 133 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 120 insertions(+), 13 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
index 03abf41..9e1cc88 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py
@@ -25,11 +25,14 @@
import IpyGameDataPY
import ChConfig
import PlayerSuccess
+import DataRecordPack
import PlayerWing
import PlayerDogz
+import EventShell
import random
import math
+
#//A3 03 物品合成 #tagCMItemCompound
@@ -99,6 +102,12 @@
GameWorld.DebugLog("货币不足合成! totalNeedMoney=%s" % totalNeedMoney, playerID)
return
+ # 目标物品可否拆解判断
+ canDecompoundItemTypeList = IpyGameDataPY.GetFuncEvalCfg("ItemDecompound", 1)
+ decompoundMinColor = IpyGameDataPY.GetFuncCfg("ItemDecompound", 2)
+ canDecompound = makeItemData.GetType() in canDecompoundItemTypeList and makeItemData.GetItemColor() >= decompoundMinColor
+ decompoundItemInfo = [] # 拆解返还物品列表 [装备ID,材料1ID,个数,是否绑定,材料2ID,个数,是否绑定,...]
+
itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
wingItemExpInfo = None #材料翅膀精炼信息
dogzEquipPlusExp = 0 #神兽装备强化熟练度
@@ -125,11 +134,12 @@
fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt = fixedItemInfo
# 检查附加道具增加成功率消耗
- addSuccRate = 0
+ addSuccRate, addSuccRateItemInfo = 0, []
if addonsCountMax > 0:
- addSuccRate = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
- if addSuccRate == None:
+ addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
+ if addSuccRateInfo == None:
return
+ addSuccRate, addSuccRateItemInfo = addSuccRateInfo
# 扣铜钱
PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce,
@@ -144,7 +154,11 @@
hasBind = ItemCommon.ReduceItem(curPlayer, unfixedItemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount,
False, ChConfig.ItemDel_ItemCompound, drDict)
makeItemBind = True if hasBind else makeItemBind
-
+
+ if canDecompound:
+ decompoundUnfixedItemID = 0 if not unfixedItemIDList else random.choice(unfixedItemIDList) # 拆解时随机返还一件不固定消耗道具
+ decompoundItemInfo.append(decompoundUnfixedItemID)
+
# 扣固定消耗物品
if fixedItemIDList:
for fixedItemID, countInfo in fixedItemNeedCntDict.items():
@@ -153,9 +167,17 @@
if delBindCnt:
makeItemBind = True
ItemCommon.ReduceItem(curPlayer, itemPack, bindFixedIndexList, delBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
+ if canDecompound:
+ decompoundItemInfo.append(fixedItemID)
+ decompoundItemInfo.append(delBindCnt)
+ decompoundItemInfo.append(1) # 绑定
if delUnBindCnt:
ItemCommon.ReduceItem(curPlayer, itemPack, unbindFixedIndexList, delUnBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
-
+ if canDecompound:
+ decompoundItemInfo.append(fixedItemID)
+ decompoundItemInfo.append(delUnBindCnt)
+ decompoundItemInfo.append(0) # 不绑定
+
# 扣附加道具
if addonsCountMax > 0:
for i, addonsItemIndex in enumerate(addonsItemIndexList):
@@ -180,9 +202,22 @@
GameWorld.DebugLog("首次合成一代翅膀,必定成功!totalSuccRate=%s" % totalSuccRate, playerID)
# 合成成功
- if GameWorld.CanHappen(totalSuccRate, ShareDefine.Def_MaxRateValue):
+ maxRateValue = ShareDefine.Def_MaxRateValue
+ randValue = random.randint(1, maxRateValue)
+ canHappen = randValue <= totalSuccRate
+ GameWorld.DebugLog("canHappen=%s,randValue=%s,totalSuccRate=%s,maxRateValue=%s"
+ % (canHappen, randValue, totalSuccRate, maxRateValue), playerID)
+ # 不是百分百成功的记录合成流向
+ if successRate != maxRateValue:
+ drDict = {"PlayerID":curPlayer.GetPlayerID(), "AccID":curPlayer.GetAccID(), "ID":compoundID, "MakeItemID":makeItemID, "IsSuccess":canHappen,
+ "RateInfo":{"totalSuccRate":"%s(%s+%s)" % (totalSuccRate, successRate, addSuccRate), "randValue":randValue, "maxRateValue":maxRateValue},
+ "AddSuccRateItemInfo":addSuccRateItemInfo
+ }
+ DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer)
+
+ if canHappen:
GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s" % (makeItemID, compoundCnt, compoundBindCnt), playerID)
- userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp)
+ userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
msgMark = ipyData.GetSysMark()
paramType = ipyData.GetSysMarkParamType()
@@ -201,7 +236,7 @@
itemColor = makeItemData.GetItemColor()
itemQuality = makeItemData.GetItemQuality()
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundEquip, compoundCnt, [classLV, itemColor, itemQuality])
-
+ EventShell.EventRespons_CompoundEquip(curPlayer, itemColor, itemQuality)
# 合成失败
else:
GameWorld.DebugLog("合成失败!")
@@ -377,6 +412,7 @@
# ComposeAddonsQuality 4|2 0 0 0 0 阶数和颜色
# ComposeAddonsFormula level*10 0 0 0 0 计算合成时附加材料增加的几率公式
+ addSuccRateItemInfo = []
composeAddonsTypeList = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsType")
classLV, color = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsQuality", 1)
ComposeAddonsFormula = IpyGameDataPY.GetFuncCfg("ComposeAddonsFormula")
@@ -428,8 +464,9 @@
addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula))
addTotalSuccRate += (addSuccRate*costCount)
+ addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount})
- return int(addTotalSuccRate)
+ return int(addTotalSuccRate), addSuccRateItemInfo
def __CheckItemCanUseCompound(playerID, index, curItem):
@@ -456,19 +493,19 @@
# @param newItem: 新物品
# @param itemCount: 合成数量
# @return None
-def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp):
+def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
compoundUnBindCnt = itemCount - compoundBindCnt
if compoundBindCnt > 0:
- userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp)
+ userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
if compoundUnBindCnt > 0:
- userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp)
+ userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
if not userData:
return ""
return userData
-def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp):
+def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
playerID = curPlayer.GetPlayerID()
curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind)
if not curSingleItem:
@@ -499,6 +536,13 @@
GameWorld.DebugLog("合成神兽装备成功, dogzEquipLV=%s,dogzEquipExp=%s,remainExp=%s,总EXP=%s"
% (dogzEquipLV, dogzEquipExp, remainExp, dogzEquipPlusExp), playerID)
__SendDogzEquipRemainExpMail(playerID, remainExp, True)
+
+ # 保留合成材料消耗,拆解时用
+ if decompoundItemInfo:
+ curSingleItem.ClearUserAttr(ShareDefine.Def_IudetItemDecompound)
+ for decompoundValue in decompoundItemInfo:
+ curSingleItem.AddUserAttr(ShareDefine.Def_IudetItemDecompound, decompoundValue)
+ GameWorld.Log("保存可拆解装备拆解物品信息: %s" % decompoundItemInfo, playerID)
userData = curSingleItem.GetUserData()
if not ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curSingleItem,
@@ -540,3 +584,66 @@
PlayerControl.SendMailByKey(mailTypeKey, [playerID], [[expItemID, giveItemCount, isBind]])
return
+#// A3 13 物品拆解 #tagCMItemDecompound
+#
+#struct tagCMItemDecompound
+#{
+# tagHead Head;
+# BYTE Index; // 拆解物品所在背包索引
+#};
+def OnItemDecompound(index, clientData, tick):
+ curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+ playerID = curPlayer.GetPlayerID()
+
+ decompoundItemIndex = clientData.Index
+ GameWorld.DebugLog("玩家拆解物品: decompoundItemIndex=%s" % decompoundItemIndex, playerID)
+
+ itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
+ if decompoundItemIndex < 0 or decompoundItemIndex >= itemPack.GetCount():
+ return
+ curEquip = itemPack.GetAt(decompoundItemIndex)
+
+ if not ItemCommon.CheckItemCanUse(curEquip):
+ return
+
+ attrCount = curEquip.GetUserAttrCount(ShareDefine.Def_IudetItemDecompound)
+ if not attrCount:
+ GameWorld.DebugLog(" 该物品没有记录拆解物品信息,无法拆解!", playerID)
+ return
+
+ giveItemList = []
+ giveEquipID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, 0)
+ if giveEquipID:
+ giveItemList.append([giveEquipID, 1, curEquip.GetIsBind()])
+
+ if attrCount > 1:
+ for i in range(1, attrCount)[::3]:
+ if i + 3 > attrCount:
+ break
+ itemID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i)
+ itemCount = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 1)
+ isBind = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 2)
+ giveItemList.append([itemID, itemCount, isBind])
+
+ needSpace = len(giveItemList)
+ emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
+ #验证背包空间
+ if needSpace > emptySpace:
+ PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
+ return
+
+ decompoundItemNoteDict = ItemCommon.GetItemNoteDict(curEquip, curEquip.GetCount())
+
+ # 删除拆解的物品
+ saveDataDict = {"giveItemList":giveItemList}
+ ItemCommon.DelItem(curPlayer, curEquip, curEquip.GetCount(), False, "ItemDecompound", saveDataDict, isForceDR=True)
+
+ # 返还物品
+ for itemID, itemCount, isBind in giveItemList:
+ ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem],
+ event=["ItemDecompound", True, {"decompoundItemNoteDict":decompoundItemNoteDict}])
+
+ GameWorld.Log("拆解物品成功: decompoundItemNoteDict=%s" % str(decompoundItemNoteDict), playerID)
+ GameWorld.Log(" giveItemList=%s" % str(giveItemList), playerID)
+ return
+
--
Gitblit v1.8.0