111
This commit is contained in:
146
Dps_A/ProjectClass/AvatarUseJewel/AvatarUseJewel.nut
Normal file
146
Dps_A/ProjectClass/AvatarUseJewel/AvatarUseJewel.nut
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
文件名:AvatarUseJewel.nut
|
||||
路径:Dps_A/ProjectClass/AvatarUseJewel/AvatarUseJewel.nut
|
||||
创建日期:2024-10-09 19:52
|
||||
文件用途:时装镶嵌
|
||||
*/
|
||||
class AvatarUseJewel {
|
||||
|
||||
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 FixFunction() {
|
||||
Haker.LoadHook("0x8217BD6", ["int", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
//角色
|
||||
local SUser = User(args[1]);
|
||||
//包数据
|
||||
local Pack = Packet(args[2]);
|
||||
|
||||
//校验角色状态是否允许镶嵌
|
||||
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 = AvatarUseJewel.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 = AvatarUseJewel.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];
|
||||
AvatarUseJewel.CInventory_delete_item(InvemObj.C_Object, 1, emblem_inven_slot, 1, 8, 1);
|
||||
//设置时装插槽数据
|
||||
local emblem_item_id = emblemObject[1];
|
||||
AvatarUseJewel.api_set_JewelSocketData(Jewel_Socket_Data, avartar_socket_slot, emblem_item_id);
|
||||
}
|
||||
|
||||
//时装插槽数据存档
|
||||
AvatarUseJewel.DB_UpdateAvatarJewelSlot_makeRequest(SUser.GetCID(), AvatarUseJewel.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;
|
||||
},
|
||||
|
||||
function(args) {
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
FixFunction();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,12 @@
|
||||
创建日期:2024-10-01 10:02
|
||||
文件用途:结婚系统
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Marry {
|
||||
//当前频道
|
||||
Channel = null;
|
||||
@@ -16,8 +22,10 @@ class Marry {
|
||||
//进入礼堂前的位置信息
|
||||
EnterAuditoriumPosList = {};
|
||||
|
||||
//礼堂id 对应的用户信息
|
||||
//礼堂id 对应的用户信息 结构为Map<cid,Map<uid , avatar[]>>
|
||||
AuditoriumUserInfo = {};
|
||||
//角色时装信息
|
||||
UserAvaList = {};
|
||||
|
||||
|
||||
//数据库操作集
|
||||
@@ -339,6 +347,8 @@ class Marry {
|
||||
Flag = 2
|
||||
}
|
||||
|
||||
|
||||
|
||||
local WorldMap = World.GetOnlinePlayer();
|
||||
foreach(W_User in WorldMap) {
|
||||
if (W_User.GetCID() == Target_CId) {
|
||||
@@ -351,6 +361,40 @@ class Marry {
|
||||
}
|
||||
}
|
||||
|
||||
//开启婚礼 参数为礼堂编号 也就是其中一个人的cid
|
||||
function OpenAuditorium(index) {
|
||||
//通知所有在这个礼堂里的人 婚礼开始了
|
||||
local userlist = AuditoriumUserInfo[RoomId];
|
||||
|
||||
local dxcid = Mysql_Operate_Func.CheckMarryTarget(index);
|
||||
foreach(uid in userlist) {
|
||||
local user = World.GetUserByUid(uid);
|
||||
|
||||
//发包通知 如果是2个结婚的人的cid 下发另外的包
|
||||
if (user.GetCID() == index || user.GetCID() == dxcid) {
|
||||
local T = {
|
||||
op = OP + 32,
|
||||
userlist = userlist
|
||||
}
|
||||
} else {
|
||||
//发包通知 普通宾客的包
|
||||
local T = {
|
||||
op = OP + 34,
|
||||
userlist = userlist
|
||||
}
|
||||
}
|
||||
user.SendJso(T);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//删除礼堂信息
|
||||
AuditoriumUserInfo.rawdelete(RoomId);
|
||||
//删除数据库信息
|
||||
Mysql_Operate_Func.DeleteMarryInfo(index);
|
||||
Mysql_Operate_Func.DeleteMarryInfo(dxcid);
|
||||
}
|
||||
|
||||
|
||||
//进入礼堂
|
||||
@@ -389,7 +433,7 @@ class Marry {
|
||||
|
||||
|
||||
|
||||
AuditoriumUserInfo[RoomId].rawset(SUser.GetCID(), 1);
|
||||
AuditoriumUserInfo[RoomId].rawset(SUser.GetUID(), GetAva(SUser));
|
||||
|
||||
local UserCanSee = [];
|
||||
foreach(cid in AuditoriumUserInfo[RoomId]) {
|
||||
@@ -412,11 +456,12 @@ class Marry {
|
||||
World.MoveArea(SUser, Info.Town, Info.Area, Info.Pos.X, Info.Pos.Y);
|
||||
|
||||
|
||||
AuditoriumUserInfo[Info["所在礼堂编号"]].rawdelete(SUser.GetCID());
|
||||
AuditoriumUserInfo[Info["所在礼堂编号"]].rawdelete(SUser.GetUID());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获得礼堂列表
|
||||
@@ -498,12 +543,14 @@ class Marry {
|
||||
Pack.Put_Byte(MUser.GetLocation().Town); //城镇
|
||||
|
||||
|
||||
Pack.Put_Byte(MUser.GetArea(1)); //区域
|
||||
Pack.Put_Byte(99); //区域
|
||||
Pack.Put_Short(MUser.GetAreaPos().X);
|
||||
|
||||
Pack.Put_Short(MUser.GetAreaPos().Y);
|
||||
Pack.Put_Byte(MUser.GetDirections()); //朝向
|
||||
Pack.Put_Byte(MUser.GetVisibleValues()); //是否可见
|
||||
Pack.Finalize(true);
|
||||
print(111);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
@@ -511,6 +558,7 @@ class Marry {
|
||||
|
||||
|
||||
|
||||
|
||||
constructor() {
|
||||
Config = dofile("/root/娱心插件配置/结婚系统配置.dat");
|
||||
local ConfigPath = Sq_Game_GetConfig();
|
||||
@@ -531,14 +579,48 @@ class Marry {
|
||||
//每次加载的时候都注册礼堂信息
|
||||
AuditoriumUserInfo.rawset(1, {});
|
||||
|
||||
local RealList = [];
|
||||
|
||||
RealList.push(World.GetUserByUid(1));
|
||||
RealList.push(World.GetUserByUid(2));
|
||||
|
||||
//玩家重新上线的时候自动给他退出礼堂
|
||||
Cb_reach_game_world_Func.Auditorium <- function(SUser) {
|
||||
if (EnterAuditoriumPosList.rawin(SUser.GetUID())) {
|
||||
local Info = EnterAuditoriumPosList[SUser.GetCID()];
|
||||
AuditoriumUserInfo[Info["所在礼堂编号"]].rawdelete(SUser.GetUID());
|
||||
}
|
||||
}.bindenv(this);
|
||||
|
||||
|
||||
// local RealList = [];
|
||||
|
||||
// RealList.push(World.GetUserByUid(1));
|
||||
// RealList.push(World.GetUserByUid(2));
|
||||
|
||||
|
||||
|
||||
// Timer.SetTimeOut(function() {
|
||||
// // Sq_CallFunc(S_Ptr("0x850d374"), "int", ["pointer", "int"], S_Ptr("0x1"), "sss")
|
||||
// // local S = Memory.alloc(100);
|
||||
// // Sq_Delete_Point(S.C_Object);
|
||||
// Sq_CallFunc(S_Ptr("0x08692af6"), "int", ["pointer", "int", "int"], 1, 1, 1);
|
||||
// }, 3000);
|
||||
|
||||
|
||||
// local Suser = World.GetUserByUid(2);
|
||||
// //获取背包对象
|
||||
// local InvenObj = Suser.GetInven();
|
||||
// //遍历身上的每一件装备
|
||||
// for (local u = 0; u <= 10; u++) {
|
||||
// //如果装备存在 并且存在于 加成表中 就给提升率加上对应的值
|
||||
// local EquObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, u);
|
||||
// if (EquObj && !EquObj.IsEmpty) {
|
||||
// local EquObjId = EquObj.GetIndex();
|
||||
// print(EquObj.Output());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Timer.SetTimeOut(MarryUserDeleteCallBack, 3000, RealList, World.GetUserByUid(1));
|
||||
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
@@ -553,7 +635,124 @@ class Marry {
|
||||
}
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
|
||||
defaultJobItemIdMap.rawset(0, defaultJobItemId(39278, 39400, 0, 0, 40600, 41000, 41800, 42200));
|
||||
defaultJobItemIdMap.rawset(1, defaultJobItemId(0, 43400, 0, 0, 44600, 45000, 45800, 46200));
|
||||
defaultJobItemIdMap.rawset(2, defaultJobItemId(0, 47400, 0, 48426, 48600, 49000, 49800, 50200));
|
||||
defaultJobItemIdMap.rawset(3, defaultJobItemId(51265, 51400, 0, 0, 52600, 53000, 53800, 54200));
|
||||
defaultJobItemIdMap.rawset(4, defaultJobItemId(0, 55400, 55820, 0, 56600, 57000, 57800, 58200));
|
||||
|
||||
defaultJobItemIdMap.rawset(5, defaultJobItemId(1600000, 1610000, 0, 0, 1640000, 1650000, 1670000, 1680000));
|
||||
defaultJobItemIdMap.rawset(6, defaultJobItemId(1720000, 1730000, 0, 1750000, 1760000, 1770000, 1790000, 1800000));
|
||||
defaultJobItemIdMap.rawset(7, defaultJobItemId(0, 29201, 0, 0, 29202, 29203, 29204, 29205));
|
||||
defaultJobItemIdMap.rawset(8, defaultJobItemId(0, 2090000, 0, 0, 2120000, 2130000, 2140000, 2150000));
|
||||
defaultJobItemIdMap.rawset(9, defaultJobItemId(39278, 39400, 0, 0, 40600, 41000, 41800, 42200));
|
||||
defaultJobItemIdMap.rawset(10, defaultJobItemId(51265, 51400, 0, 0, 52600, 53000, 53800, 54200));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取角色身上的显示时装
|
||||
function GetAva(SUser) {
|
||||
//获取背包对象
|
||||
local InvenObj = SUser.GetInven();
|
||||
|
||||
local re = [];
|
||||
|
||||
|
||||
local job = SUser.GetCharacJob();
|
||||
//遍历身上的每一件装备
|
||||
for (local u = 0; u <= 2; u++) {
|
||||
local EquObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, u);
|
||||
if (EquObj && !EquObj.IsEmpty) {
|
||||
//先拿克隆id 如果这个值有 那说明带的克隆 直接用这个
|
||||
local clearId = Sq_CallFunc(S_Ptr("0x850d374"), "int", ["pointer", "int"], 1, u)
|
||||
// print(clearId);
|
||||
local EquObjId = EquObj.GetIndex();
|
||||
// print(EquObjId);
|
||||
//如果这个是克隆
|
||||
if (clearId > 0) {
|
||||
re.push(clearId);
|
||||
} else { //不是克隆 直接把id放上去
|
||||
|
||||
re.push(EquObjId);
|
||||
|
||||
}
|
||||
} else { //如果这个部位没东西 直接放默认时装上去
|
||||
re.push(defaultJobItemIdMap[job].index[u]);
|
||||
}
|
||||
|
||||
}
|
||||
return re;
|
||||
}
|
||||
//默认时装
|
||||
defaultJobItemIdMap <- {};
|
||||
|
||||
|
||||
class defaultJobItemId {
|
||||
|
||||
/**
|
||||
* 头发
|
||||
*/
|
||||
hat = 0;
|
||||
|
||||
/**
|
||||
* 帽子
|
||||
*/
|
||||
hair = 0;
|
||||
|
||||
/**
|
||||
*脸
|
||||
*/
|
||||
face = 0;
|
||||
/**
|
||||
* 披风
|
||||
*/
|
||||
breast = 0;
|
||||
/**
|
||||
* 上衣
|
||||
*/
|
||||
coat = 0;
|
||||
|
||||
/**
|
||||
* 下装
|
||||
*/
|
||||
pants = 0;
|
||||
|
||||
/**
|
||||
* 鞋子
|
||||
*/
|
||||
shoes = 0;
|
||||
|
||||
/**
|
||||
* 皮肤
|
||||
*/
|
||||
skin = 0;
|
||||
|
||||
index = [];
|
||||
|
||||
constructor(hat, hair, face, breast, coat, pants, shoes, skin) {
|
||||
this.hat = hat;
|
||||
this.hair = hair;
|
||||
this.face = face;
|
||||
this.breast = breast;
|
||||
this.coat = coat;
|
||||
this.pants = pants;
|
||||
this.shoes = shoes;
|
||||
this.skin = skin;
|
||||
index.push(hat);
|
||||
index.push(hair);
|
||||
index.push(face);
|
||||
|
||||
index.push(breast);
|
||||
index.push(coat);
|
||||
index.push(pants);
|
||||
index.push(shoes);
|
||||
index.push(skin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ProjectInitFuncMap.P_Marry <- Marry();
|
||||
Reference in New Issue
Block a user