1111
This commit is contained in:
@@ -54,7 +54,6 @@ class EquimentUseJewel {
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(CheckSql, ["int"]);
|
||||
printT(Ret);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
//没结婚要返回false
|
||||
@@ -184,7 +183,6 @@ class EquimentUseJewel {
|
||||
function GetByte(value) {
|
||||
local Blob = blob();
|
||||
Blob.writen(value, 'w');
|
||||
print(Blob.len());
|
||||
return Blob;
|
||||
}
|
||||
|
||||
@@ -226,262 +224,358 @@ class EquimentUseJewel {
|
||||
|
||||
HackReturnAddSocketToAvatarFalg = null;
|
||||
|
||||
|
||||
function HackReturnAddSocketToAvatar(Code) {
|
||||
//通过hook get short直接返回0达到错误返回的效果
|
||||
//标记flag
|
||||
HackReturnAddSocketToAvatarFalg = Code;
|
||||
Haker.LoadHook("0x0858D0B0", ["pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
},
|
||||
function(args) {
|
||||
Haker.UnLoadHook("0x0858D0B0");
|
||||
return 0;
|
||||
});
|
||||
|
||||
Cb_PacketBuf_get_short_Leave_Func.EquimentUseJewel <- function(args) {
|
||||
Cb_PacketBuf_get_short_Leave_Func.rawdelete("EquimentUseJewel");
|
||||
return 0;
|
||||
}.bindenv(this);
|
||||
}
|
||||
|
||||
|
||||
function FixFunction() {
|
||||
//称号回包
|
||||
Haker.LoadHook("0x08641A6A", ["pointer", "pointer", "int", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(args[3]).add(25).readU32());
|
||||
local ret = args.pop();
|
||||
if (JewelSocketData && NativePointer(JewelSocketData).add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[1]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
Cb_CTitleBook_putItemData_Leave_Func.EquimentUseJewel <- function(args) {
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(args[3]).add(25).readU32());
|
||||
local ret = args.pop();
|
||||
if (JewelSocketData && NativePointer(JewelSocketData).add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[1]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
//设计图继承
|
||||
Haker.LoadHook("0x08671EB2", ["pointer", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
local jewelSocketID = NativePointer(args[2]).add(25).readU32();
|
||||
NativePointer(args[1]).add(25).writeU32(jewelSocketID);
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
Cb_CUsercopyItemOption_Enter_Func.EquimentUseJewel <- function(args) {
|
||||
local jewelSocketID = NativePointer(args[2]).add(25).readU32();
|
||||
NativePointer(args[1]).add(25).writeU32(jewelSocketID);
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
//装备开孔
|
||||
Haker.LoadHook("0x0821A412", ["pointer", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
Cb_AddSocketToAvatar_Enter_Func.EquimentUseJewel <- function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local equ_slot = Pack.GetShort();
|
||||
local equitem_id = Pack.GetInt();
|
||||
local sta_slot = Pack.GetShort();
|
||||
local CurCharacInvenW = SUser.GetInven();
|
||||
local inven_item = CurCharacInvenW.GetSlot(1, equ_slot);
|
||||
|
||||
if (equ_slot > 56) { //修改后:大于56则是时装装备 原:如果不是装备文件就调用原逻辑
|
||||
equ_slot = equ_slot - 57;
|
||||
local C_PacketBuf = api_PacketBuf_get_buf(args[2]) //获取原始封包数据
|
||||
C_PacketBuf.add(0).writeShort(equ_slot) //修改掉装备位置信息 时装类镶嵌从57开始。
|
||||
|
||||
//执行原逻辑
|
||||
return null;
|
||||
}
|
||||
//如果已开启镶嵌槽则不执行
|
||||
local equ_id = NativePointer(inven_item.C_Object).add(25).readU32();
|
||||
if (api_exitjeweldata(equ_id)) {
|
||||
HackReturnAddSocketToAvatar(0x13);
|
||||
return null;
|
||||
}
|
||||
|
||||
local item = PvfItem.GetPvfItemById(equitem_id);
|
||||
local ItemType = Sq_CallFunc(S_Ptr("0x08514D26"), "int", ["pointer"], item.C_Object);
|
||||
|
||||
if (ItemType == 10) {
|
||||
SUser.SendNotiBox("装备为武器类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
} else if (ItemType == 11) {
|
||||
SUser.SendNotiBox("装备为称号类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}
|
||||
|
||||
local id = add_equiment_socket(ItemType);
|
||||
|
||||
Sq_Inven_RemoveItemFormCount(CurCharacInvenW.C_Object, 1, sta_slot, 1, 8, 1); //删除打孔道具
|
||||
NativePointer(inven_item.C_Object).add(25).writeU32(id) //写入槽位标识
|
||||
SUser.SendUpdateItemList(1, 0, equ_slot);
|
||||
|
||||
local JewelSocketData = api_get_jewel_socket_data(id);
|
||||
CUser_SendUpdateItemList_DB(SUser, equ_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 209);
|
||||
Pack.Put_Byte(1);
|
||||
Pack.Put_Short(equ_slot + 104);
|
||||
Pack.Put_Short(sta_slot);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
Cb_AddSocketToAvatar_Leave_Func.EquimentUseJewel <- function(args) {
|
||||
|
||||
local Pack = Packet(args[2]);
|
||||
local equ_slot = Pack.GetShort();
|
||||
print(equ_slot);
|
||||
//跳的错误返回0 正常调用的话不处理返回值
|
||||
if (HackReturnAddSocketToAvatarFalg != null) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local equ_slot = Pack.GetShort();
|
||||
local equitem_id = Pack.GetInt();
|
||||
local sta_slot = Pack.GetShort();
|
||||
local CurCharacInvenW = SUser.GetInven();
|
||||
local inven_item = CurCharacInvenW.GetSlot(1, equ_slot);
|
||||
// SUser.SendItemSpace(0);
|
||||
CUser_SendCmdErrorPacket(SUser, 209, HackReturnAddSocketToAvatarFalg);
|
||||
HackReturnAddSocketToAvatarFalg = null;
|
||||
return 0;
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
if (equ_slot > 56) { //修改后:大于56则是时装装备 原:如果不是装备文件就调用原逻辑
|
||||
equ_slot = equ_slot - 57;
|
||||
local C_PacketBuf = api_PacketBuf_get_buf(args[2]) //获取原始封包数据
|
||||
C_PacketBuf.add(0).writeShort(equ_slot) //修改掉装备位置信息 时装类镶嵌从57开始。
|
||||
//执行原逻辑
|
||||
return null;
|
||||
}
|
||||
//如果已开启镶嵌槽则不执行
|
||||
local equ_id = NativePointer(inven_item.C_Object).add(25).readU32();
|
||||
if (api_exitjeweldata(equ_id)) {
|
||||
HackReturnAddSocketToAvatar(0x13);
|
||||
return null;
|
||||
}
|
||||
//装备镶嵌和时装镶嵌
|
||||
Cb_Dispatcher_UseJewel_Enter_Func.EquimentUseJewel <- function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local PackIndex = NativePointer(args[2]).add(4).readInt();
|
||||
local State = SUser.GetState();
|
||||
if (State != 3) return null;
|
||||
|
||||
local item = PvfItem.GetPvfItemById(equitem_id);
|
||||
local ItemType = Sq_CallFunc(S_Ptr("0x08514D26"), "int", ["pointer"], item.C_Object);
|
||||
local avartar_inven_slot = Pack.GetShort();
|
||||
local avartar_item_id = Pack.GetInt();
|
||||
local emblem_cnt = Pack.GetByte();
|
||||
|
||||
if (ItemType == 10) {
|
||||
SUser.SendNotiBox("装备为武器类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
} else if (ItemType == 11) {
|
||||
SUser.SendNotiBox("装备为称号类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
local id = add_equiment_socket(ItemType);
|
||||
Sq_Inven_RemoveItemFormCount(CurCharacInvenW.C_Object, 1, sta_slot, 1, 8, 1); //删除打孔道具
|
||||
NativePointer(inven_item.C_Object).add(25).writeU32(id) //写入槽位标识
|
||||
SUser.SendUpdateItemList(1, 0, equ_slot);
|
||||
//下面是参照原时装镶嵌的思路写的。个别点标记出来。
|
||||
if (avartar_inven_slot > 104) {
|
||||
local equipment_inven_slot = avartar_inven_slot - 104; //取出真实装备所在背包位置值
|
||||
local Inven = SUser.GetInven();
|
||||
local equipment = Inven.GetSlot(1, equipment_inven_slot);
|
||||
//校验是否合法
|
||||
if (!equipment || equipment.IsEmpty || (equipment.GetIndex() != avartar_item_id) || SUser.CheckItemLock(1, equipment_inven_slot)) return;
|
||||
|
||||
local id = NativePointer(equipment.C_Object).add(25).readU32();
|
||||
local JewelSocketData = api_get_jewel_socket_data(id);
|
||||
CUser_SendUpdateItemList_DB(SUser, equ_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
if (!JewelSocketData) return;
|
||||
|
||||
local emblems = {};
|
||||
if (emblem_cnt <= 3) {
|
||||
for (local i = 0; i< emblem_cnt; i++) {
|
||||
local emblem_inven_slot = Pack.GetShort();
|
||||
local emblem_item_id = Pack.GetInt();
|
||||
local equipment_socket_slot = Pack.GetByte();
|
||||
local emblem = Inven.GetSlot(1, emblem_inven_slot);
|
||||
//校验徽章及插槽数据是否合法
|
||||
if (!emblem || emblem.IsEmpty || (emblem.GetIndex() != emblem_item_id) || (equipment_socket_slot >= 3)) return;
|
||||
|
||||
//校验徽章是否满足时装插槽颜色要求
|
||||
//获取徽章pvf数据
|
||||
local citem = PvfItem.GetPvfItemById(emblem_item_id);
|
||||
if (!citem) return;
|
||||
|
||||
//校验徽章类型
|
||||
if (!citem.IsStackable() || citem.GetItemType() != 20) return;
|
||||
|
||||
//获取徽章支持的插槽
|
||||
local emblem_socket_type = CStackableItem_getJewelTargetSocket(citem.C_Object);
|
||||
//获取要镶嵌的时装插槽类型
|
||||
local avartar_socket_type = JewelSocketData.add(equipment_socket_slot * 6).readShort();
|
||||
|
||||
if (!(emblem_socket_type & avartar_socket_type)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emblems[equipment_socket_slot] <- [emblem_inven_slot, emblem_item_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach(equipment_socket_slot, emblemObject in emblems) {
|
||||
//删除徽章
|
||||
local emblem_inven_slot = emblemObject[0];
|
||||
Sq_Inven_RemoveItemFormCount(Inven.C_Object, 1, emblem_inven_slot, 1, 8, 1); //删除打孔道具
|
||||
//设置时装插槽数据
|
||||
local emblem_item_id = emblemObject[1];
|
||||
JewelSocketData.add(2 + 6 * equipment_socket_slot).writeU32(emblem_item_id);
|
||||
}
|
||||
|
||||
local Buf = Sq_Point2Blob(JewelSocketData.C_Object, 30);
|
||||
local Str = "";
|
||||
foreach(Value in Buf) {
|
||||
Str += format("%02X", Value);
|
||||
}
|
||||
|
||||
save_equiment_socket(Str, id);
|
||||
// if (!save_equiment_socket(DB_JewelSocketData, id)) {
|
||||
// print("写入失败了");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
CUser_SendUpdateItemList_DB(SUser, equipment_inven_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 209);
|
||||
Pack.Put_Byte(1);
|
||||
Pack.Put_Short(equ_slot + 104);
|
||||
Pack.Put_Short(sta_slot);
|
||||
Pack.Put_Short(equipment_inven_slot + 104);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
//跳的错误返回0 正常调用的话不处理返回值
|
||||
if (HackReturnAddSocketToAvatarFalg != null) {
|
||||
local SUser = User(args[1]);
|
||||
// SUser.SendItemSpace(0);
|
||||
CUser_SendCmdErrorPacket(SUser, 209, HackReturnAddSocketToAvatarFalg);
|
||||
HackReturnAddSocketToAvatarFalg = null;
|
||||
return 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
AvatarLogic(args, PackIndex);
|
||||
|
||||
//装备镶嵌和时装镶嵌
|
||||
Haker.LoadHook("0x8217BD6", ["int", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local State = SUser.GetState();
|
||||
if (State != 3) return null;
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
local avartar_inven_slot = Pack.GetShort();
|
||||
local avartar_item_id = Pack.GetInt();
|
||||
local emblem_cnt = Pack.GetByte();
|
||||
|
||||
//下面是参照原时装镶嵌的思路写的。个别点标记出来。
|
||||
if (avartar_inven_slot > 104) {
|
||||
local equipment_inven_slot = avartar_inven_slot - 104; //取出真实装备所在背包位置值
|
||||
local Inven = SUser.GetInven();
|
||||
local equipment = Inven.GetSlot(1, equipment_inven_slot);
|
||||
//校验是否合法
|
||||
if (!equipment || equipment.IsEmpty || (equipment.GetIndex() != avartar_item_id) || SUser.CheckItemLock(1, equipment_inven_slot)) return;
|
||||
|
||||
local id = NativePointer(equipment.C_Object).add(25).readU32();
|
||||
local JewelSocketData = api_get_jewel_socket_data(id);
|
||||
if (!JewelSocketData) return;
|
||||
|
||||
local emblems = {};
|
||||
if (emblem_cnt <= 3) {
|
||||
for (local i = 0; i< emblem_cnt; i++) {
|
||||
local emblem_inven_slot = Pack.GetShort();
|
||||
local emblem_item_id = Pack.GetInt();
|
||||
local equipment_socket_slot = Pack.GetByte();
|
||||
local emblem = Inven.GetSlot(1, emblem_inven_slot);
|
||||
//校验徽章及插槽数据是否合法
|
||||
if (!emblem || emblem.IsEmpty || (emblem.GetIndex() != emblem_item_id) || (equipment_socket_slot >= 3)) return;
|
||||
|
||||
//校验徽章是否满足时装插槽颜色要求
|
||||
//获取徽章pvf数据
|
||||
local citem = PvfItem.GetPvfItemById(emblem_item_id);
|
||||
if (!citem) return;
|
||||
|
||||
//校验徽章类型
|
||||
if (!citem.IsStackable() || citem.GetItemType() != 20) return;
|
||||
|
||||
//获取徽章支持的插槽
|
||||
local emblem_socket_type = CStackableItem_getJewelTargetSocket(citem.C_Object);
|
||||
//获取要镶嵌的时装插槽类型
|
||||
local avartar_socket_type = JewelSocketData.add(equipment_socket_slot * 6).readShort();
|
||||
|
||||
if (!(emblem_socket_type & avartar_socket_type)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emblems[equipment_socket_slot] <- [emblem_inven_slot, emblem_item_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach(equipment_socket_slot, emblemObject in emblems) {
|
||||
//删除徽章
|
||||
local emblem_inven_slot = emblemObject[0];
|
||||
Sq_Inven_RemoveItemFormCount(Inven.C_Object, 1, emblem_inven_slot, 1, 8, 1); //删除打孔道具
|
||||
//设置时装插槽数据
|
||||
local emblem_item_id = emblemObject[1];
|
||||
JewelSocketData.add(2 + 6 * equipment_socket_slot).writeU32(emblem_item_id);
|
||||
}
|
||||
|
||||
local Buf = Sq_Point2Blob(JewelSocketData.C_Object, 30);
|
||||
local Str = "";
|
||||
foreach(Value in Buf) {
|
||||
Str += format("%02X", Value);
|
||||
}
|
||||
|
||||
save_equiment_socket(Str, id);
|
||||
// if (!save_equiment_socket(DB_JewelSocketData, id)) {
|
||||
// print("写入失败了");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
CUser_SendUpdateItemList_DB(SUser, equipment_inven_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 209);
|
||||
Pack.Put_Byte(1);
|
||||
Pack.Put_Short(equipment_inven_slot + 104);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
return 0;
|
||||
}.bindenv(this));
|
||||
Cb_Dispatcher_UseJewel_Leave_Func.EquimentUseJewel <- function(args) {
|
||||
return -1;
|
||||
}.bindenv(this);
|
||||
|
||||
//额外数据包,发送装备镶嵌数据给本地处理
|
||||
Haker.LoadHook("0x0815098e", ["pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local ret = args.pop();
|
||||
local Inven_Item = NativePointer(args[1]);
|
||||
if (Inven_Item.add(1).readU8() == 1) {
|
||||
local ItemObj = Item(args[1]);
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(ItemObj.C_Object).add(25).readU32());
|
||||
if (JewelSocketData && JewelSocketData.add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[0]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
Cb_InterfacePacketBuf_put_packet_Leave_Func.EquimentUseJewel <- function(args) {
|
||||
local ret = args.pop();
|
||||
local Inven_Item = NativePointer(args[1]);
|
||||
if (Inven_Item.add(1).readU8() == 1) {
|
||||
local ItemObj = Item(args[1]);
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(ItemObj.C_Object).add(25).readU32());
|
||||
if (JewelSocketData && JewelSocketData.add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[0]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this);
|
||||
|
||||
//装备全字节复制
|
||||
Haker.LoadHook("0x0814A62E", ["pointer", "pointer", "pointer"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
L_HookEquimentUseJewel();
|
||||
}
|
||||
|
||||
function(args) {
|
||||
local Old = NativePointer(args[1]);
|
||||
local New = NativePointer(args[0]);
|
||||
Memory.copy(New, Old, 61);
|
||||
return args[0];
|
||||
}.bindenv(this));
|
||||
|
||||
//装备全字节删除
|
||||
Haker.LoadHook("0x080CB7D8", ["pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local New = NativePointer(args[0]);
|
||||
Memory.reset(New, 61);
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
|
||||
function WongWork_CAvatarItemMgr_getJewelSocketData(a, b) {
|
||||
return Sq_CallFunc(S_Ptr("0x82F98F8"), "pointer", ["pointer", "int"], a, b);
|
||||
}
|
||||
|
||||
function CStackableItem_getJewelTargetSocket(C_Object) {
|
||||
return Sq_CallFunc(S_Ptr("0x0822CA28"), "int", ["pointer"], C_Object);
|
||||
}
|
||||
|
||||
function CInventory_delete_item(C_Object, Type, Slot, Count, Ps, Log) {
|
||||
return Sq_CallFunc(S_Ptr("0x850400C"), "int", ["pointer", "int", "int", "int", "int", "int"], C_Object, Type, Slot, Count, Ps, Log);
|
||||
}
|
||||
|
||||
function api_set_JewelSocketData(jewelSocketData, slot, emblem_item_id) {
|
||||
if (jewelSocketData) {
|
||||
NativePointer(jewelSocketData).add(slot * 6 + 2).writeInt(emblem_item_id);
|
||||
}
|
||||
}
|
||||
|
||||
function DB_UpdateAvatarJewelSlot_makeRequest(a, b, c) {
|
||||
return Sq_CallFunc(S_Ptr("0x843081C"), "pointer", ["int", "int", "pointer"], a, b, c);
|
||||
}
|
||||
|
||||
//获取时装在数据库中的uid
|
||||
function api_get_avartar_ui_id(avartar) {
|
||||
return NativePointer(avartar).add(7).readInt();
|
||||
}
|
||||
|
||||
|
||||
function AvatarLogic(args, PackIndex) {
|
||||
//角色
|
||||
local SUser = User(args[1]);
|
||||
//包数据
|
||||
local Pack = Packet(args[2]);
|
||||
//还原包读取数据号位
|
||||
NativePointer(args[2]).add(4).writeInt(PackIndex);
|
||||
|
||||
//校验角色状态是否允许镶嵌
|
||||
if (!SUser || SUser.GetState() != 3) {
|
||||
return;
|
||||
}
|
||||
//时装所在的背包槽
|
||||
local Inven_Slot = Pack.GetShort();
|
||||
//时装item_id
|
||||
local Item_Id = Pack.GetInt();
|
||||
//本次镶嵌徽章数量
|
||||
local Emblem_Count = Pack.GetByte();
|
||||
|
||||
//获取时装道具
|
||||
local InvemObj = SUser.GetInven();
|
||||
local AvatarObj = InvemObj.GetSlot(2, Inven_Slot);
|
||||
|
||||
|
||||
//校验时装 数据是否合法
|
||||
if (!AvatarObj || AvatarObj.IsEmpty || (AvatarObj.GetIndex() != Item_Id) || SUser.CheckItemLock(2, Inven_Slot)) return;
|
||||
|
||||
local Avartar_AddInfo = AvatarObj.GetAdd_Info();
|
||||
//获取时装管理器
|
||||
local Inven_AvartarMgr = InvemObj.GetAvatarItemMgr();
|
||||
|
||||
//获取时装插槽数据
|
||||
local Jewel_Socket_Data = WongWork_CAvatarItemMgr_getJewelSocketData(Inven_AvartarMgr, Avartar_AddInfo);
|
||||
if (!Jewel_Socket_Data) return;
|
||||
|
||||
//最多只支持3个插槽
|
||||
if (Emblem_Count <= 3) {
|
||||
local emblems = {};
|
||||
|
||||
for (local i = 0; i< Emblem_Count; i++) {
|
||||
//徽章所在的背包槽
|
||||
local emblem_inven_slot = Pack.GetShort();
|
||||
//徽章item_id
|
||||
local emblem_item_id = Pack.GetInt();
|
||||
//该徽章镶嵌的时装插槽id
|
||||
local avartar_socket_slot = Pack.GetByte();
|
||||
|
||||
//获取徽章道具
|
||||
local EmblemObje = InvemObj.GetSlot(1, emblem_inven_slot);
|
||||
|
||||
//校验徽章及插槽数据是否合法
|
||||
if (!EmblemObje || EmblemObje.IsEmpty || (EmblemObje.GetIndex() != emblem_item_id) || (avartar_socket_slot >= 3)) return;
|
||||
|
||||
//校验徽章是否满足时装插槽颜色要求
|
||||
//获取徽章pvf数据
|
||||
local citem = PvfItem.GetPvfItemById(emblem_item_id);
|
||||
if (!citem) return;
|
||||
|
||||
//校验徽章类型
|
||||
if (!citem.IsStackable() || citem.GetItemType() != 20) return;
|
||||
|
||||
//获取徽章支持的插槽
|
||||
local emblem_socket_type = CStackableItem_getJewelTargetSocket(citem.C_Object);
|
||||
|
||||
//获取要镶嵌的时装插槽类型
|
||||
local avartar_socket_type = NativePointer(Jewel_Socket_Data).add(avartar_socket_slot * 6).readShort();
|
||||
|
||||
if (!(emblem_socket_type & avartar_socket_type)) return;
|
||||
|
||||
emblems[avartar_socket_slot] <- [emblem_inven_slot, emblem_item_id];
|
||||
}
|
||||
|
||||
//开始镶嵌
|
||||
foreach(avartar_socket_slot, emblemObject in emblems) {
|
||||
//删除徽章
|
||||
local emblem_inven_slot = emblemObject[0];
|
||||
CInventory_delete_item(InvemObj.C_Object, 1, emblem_inven_slot, 1, 8, 1);
|
||||
//设置时装插槽数据
|
||||
local emblem_item_id = emblemObject[1];
|
||||
api_set_JewelSocketData(Jewel_Socket_Data, avartar_socket_slot, emblem_item_id);
|
||||
}
|
||||
|
||||
//时装插槽数据存档
|
||||
DB_UpdateAvatarJewelSlot_makeRequest(SUser.GetCID(), api_get_avartar_ui_id(AvatarObj.C_Object), Jewel_Socket_Data);
|
||||
|
||||
//通知客户端时装数据已更新
|
||||
SUser.SendUpdateItemList(1, 1, Inven_Slot);
|
||||
|
||||
//回包给客户端
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 204);
|
||||
Pack.Put_Int(1);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -489,8 +583,4 @@ class EquimentUseJewel {
|
||||
|
||||
FixFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getroottable().RRR <- EquimentUseJewel();
|
||||
}
|
||||
Reference in New Issue
Block a user