DP-S_Script/_DPS_/_BuiltProject/毁梦定制装备继承/毁梦定制装备继承.nut

81 lines
2.9 KiB
Plaintext

class HM_InheritC {
constructor() {
//注册客户端收包
RegisterClient();
}
function RegisterClient() {
ClientSocketPackFuncMap.rawset(21013001, function(SUser, Jso) {
//获取背包
local InvenObj = SUser.GetInven();
local Equip1 = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + Jso.item.Pos);
local Equip2 = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + Jso.item2.Pos);
local Level1 = PvfItem.GetPvfItemById(Equip1.GetIndex()).GetUsableLevel();
local Level2 = PvfItem.GetPvfItemById(Equip2.GetIndex()).GetUsableLevel();
if (Level1< 50 || Level2< 50) {
SUser.SendNotiBox(" 继承失败 装备等级不可低于50", 1);
return;
}
local Rarity1 = PvfItem.GetPvfItemById(Equip1.GetIndex()).GetRarity();
local Rarity2 = PvfItem.GetPvfItemById(Equip2.GetIndex()).GetRarity();
if (Rarity1< 4 || Rarity2< 4) {
SUser.SendNotiBox(" 继承失败 装备品级不可低于史诗", 1);
return;
}
if (Equip1.GetIndex() != Jso.item.ItemId || Equip2.GetIndex() != Jso.item2.ItemId) {
SUser.SendNotiBox(" 继承失败 继承时请不要操作背包", 1);
return;
}
local itemType1 = NativePointer(PvfItem.GetPvfItemById(Jso.item.ItemId).C_Object).add(141 * 4).readU32();
local itemType2 = NativePointer(PvfItem.GetPvfItemById(Jso.item2.ItemId).C_Object).add(141 * 4).readU32();
if (itemType1 != itemType2) {
SUser.SendNotiBox(" 继承失败 继承时需要同类型装备", 1);
return;
}
local forging = Equip1.GetForging(); //锻造
local upgrade = Equip1.GetUpgrade(); //强化
local amplification = Equip1.GetAmplification(); //增幅
local enchanting = Equip1.GetEnchanting(); //附魔
local Jewel = NativePointer(Equip1.C_Object).add(25).readU32(); //镶嵌
Equip2.SetForging(forging);
Equip2.SetUpgrade(upgrade);
Equip2.SetAmplification(amplification);
Equip2.SetEnchanting(enchanting);
Equip2.Flush();
NativePointer(Equip2.C_Object).add(25).writeU32(Jewel);
Equip1.Delete();
SUser.SendUpdateItemList(1, 0, 9 + Jso.item.Pos);
SUser.SendUpdateItemList(1, 0, 9 + Jso.item2.Pos);
SUser.GiveItem(Jso.item.ItemId, 1);
SUser.SendNotiBox(" 继承成功", 1);
SUser.SendJso({
op = 21013002
});
}.bindenv(this));
}
}
Timer.SetTimeOut(function() {
getroottable()._HM_InheritC_ <- HM_InheritC();
print("双端插件·毁梦定制继承系统 - 已加载");
}, 1);