This commit is contained in:
lenheart
2024-10-27 15:32:44 +08:00
parent e82c5ceee3
commit 6c71c79563
21 changed files with 846 additions and 253 deletions

View File

@@ -688,6 +688,25 @@ class ServerControl {
Socket.SendGateway(T);
}
};
Cb_GetUserInfo_Leave_Func.ServerControl <- function(args) {
if (args.pop() >= 0) {
local SUser = User(args[1]);
local Unid = NativePointer(args[2]).add(13).readShort();
local OtherUser = World.GetUserBySession(Unid);
if (OtherUser && SUser) {
local Jso = {
seeUid = SUser.GetUID(),
seeCid = SUser.GetCID(),
viewedUid = OtherUser.GetUID(),
viewedCid = OtherUser.GetCID(),
op = 20069009
}
Socket.SendGateway(Jso);
}
}
}
}
}

View File

@@ -57,7 +57,7 @@ class AvatarUseJewel {
local AvatarObj = InvemObj.GetSlot(2, Inven_Slot);
//校验时装 数据是否合法
if (!AvatarObj || AvatarObj.IsEmpty() || (AvatarObj.GetIndex() != Item_Id) || SUser.CheckItemLock(2, Inven_Slot)) return;
if (!AvatarObj || AvatarObj.IsEmpty || (AvatarObj.GetIndex() != Item_Id) || SUser.CheckItemLock(2, Inven_Slot)) return;
local Avartar_AddInfo = AvatarObj.GetAdd_Info();
@@ -85,7 +85,7 @@ class AvatarUseJewel {
local EmblemObje = InvemObj.GetSlot(1, emblem_inven_slot);
//校验徽章及插槽数据是否合法
if (!EmblemObje || EmblemObje.IsEmpty() || (EmblemObje.GetIndex() != emblem_item_id) || (avartar_socket_slot >= 3)) return;
if (!EmblemObje || EmblemObje.IsEmpty || (EmblemObje.GetIndex() != emblem_item_id) || (avartar_socket_slot >= 3)) return;
//校验徽章是否满足时装插槽颜色要求
//获取徽章pvf数据

View File

@@ -6,8 +6,94 @@
*/
class defaultJobItemId {
/**
* 头发
*/
hat = 0;
/**
* 帽子
*/
hair = 0;
/**
*脸
*/
face = 0;
/**
* 披风
*/
breast = 0;
/**
* 上衣
*/
coat = 0;
/**
* 下装
*/
pants = 0;
/**
* 腰部
*/
waist = 0;
/**
* 鞋子
*/
shoes = 0;
/**
* 皮肤
*/
skin = 0;
index = null;
constructor(hat, hair, face, breast, coat, pants, waist, shoes, skin) {
index = [];
this.hat = hat;
this.hair = hair;
this.face = face;
this.breast = breast;
this.coat = coat;
this.pants = pants;
this.waist = waist;
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(waist);
index.push(shoes);
index.push(skin);
index.push(0);
index.push(0);
}
}
//默认时装
if (!(getroottable().rawin("defaultJobItemIdMap"))) {
getroottable().defaultJobItemIdMap <- {};
defaultJobItemIdMap.rawset(0, defaultJobItemId(39278, 39400, 0, 0, 40600, 41000, 0, 41800, 42200));
defaultJobItemIdMap.rawset(1, defaultJobItemId(0, 43400, 0, 0, 44600, 45000, 0, 45800, 46200));
defaultJobItemIdMap.rawset(2, defaultJobItemId(0, 47400, 0, 48426, 48600, 49000, 0, 49800, 50200));
defaultJobItemIdMap.rawset(3, defaultJobItemId(51265, 51400, 0, 0, 52600, 53000, 0, 53800, 54200));
defaultJobItemIdMap.rawset(4, defaultJobItemId(0, 55400, 55820, 0, 56600, 57000, 0, 57800, 58200));
defaultJobItemIdMap.rawset(5, defaultJobItemId(1600000, 1610000, 0, 0, 1640000, 1650000, 0, 1670000, 1680000));
defaultJobItemIdMap.rawset(6, defaultJobItemId(1720000, 1730000, 0, 1750000, 1760000, 1770000, 0, 1790000, 1800000));
defaultJobItemIdMap.rawset(7, defaultJobItemId(0, 29201, 0, 0, 29202, 29203, 0, 29204, 29205));
defaultJobItemIdMap.rawset(8, defaultJobItemId(0, 2090000, 0, 0, 2120000, 2130000, 0, 2140000, 2150000));
defaultJobItemIdMap.rawset(9, defaultJobItemId(39278, 39400, 0, 0, 40600, 41000, 0, 41800, 42200));
defaultJobItemIdMap.rawset(10, defaultJobItemId(51265, 51400, 0, 0, 52600, 53000, 0, 53800, 54200));
}
class Marry {
@@ -27,6 +113,8 @@ class Marry {
//角色时装信息
UserAvaList = {};
//礼堂id 对应礼堂的宾客信息
AuditoriumUserInfoNewPeople = {};
//数据库操作集
Mysql_Operate_Func = {
@@ -78,6 +166,19 @@ class Marry {
//把连接还池子
MysqlPool.GetInstance().PutConnect(SqlObj);
}
//清空礼堂信息列表
RomoveRoom = function(Cid) {
local delete_sql = format(MARRY_SQL_LIST.RomoveRoom);
//从池子拿连接
local SqlObj = MysqlPool.GetInstance().GetConnect();
SqlObj.Exec_Sql(delete_sql);
//把连接还池子
MysqlPool.GetInstance().PutConnect(SqlObj);
}
//查询结婚对象名字
CheckMarryTargetName = function(Cid) {
local CheckSql = format(MARRY_SQL_LIST.CheckMarryTargetName, Cid);
@@ -157,19 +258,58 @@ class Marry {
return Ret[0][0];
}
}
//根据cid查询2个人的姓名
GetAuditoriumName2ById = function(cid) {
local Sql = format(MARRY_SQL_LIST.GetAuditoriumName2ById, cid, cid);
//从池子拿连接
local SqlObj = MysqlPool.GetInstance().GetConnect();
local Ret = SqlObj.Select(Sql, ["int"]);
//把连接还池子
MysqlPool.GetInstance().PutConnect(SqlObj);
if (Ret.len()< 1 || Ret[0][0] == null) {
return null;
} else {
return Ret[0];
}
}
}
//获取角色身上的显示时装
function GetAva(SUser) {
//获取背包对象
local InvenObj = SUser.GetInven();
if (!InvenObj) return;
local re = [];
local job = SUser.GetCharacJob();
//遍历身上的每一件装备
for (local u = 0; u <= 11; 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"], InvenObj.C_Object, u)
local EquObjId = EquObj.GetIndex();
//如果这个是克隆
if (clearId > 0) {
re.push(clearId);
} else { //不是克隆 直接把id放上去
re.push(EquObjId);
}
} else { //如果这个部位没东西 直接放默认时装上去
re.push(defaultJobItemIdMap[job].index[u]);
}
}
return re;
}
//查看是否结婚包
@@ -333,8 +473,8 @@ class Marry {
//获得婚礼仪式开始时间
local Index = time() + (Time + 1) * 10 * 60;
//注册婚礼礼堂信息
Mysql_Operate_Func.InsertMarryRoom(SUser.GetCID(), SUser.GetCharacName(), Time, Level, Target_CId, Mysql_Operate_Func.CheckMarryTargetName(Target_CId), 1, Index);
Mysql_Operate_Func.InsertMarryRoom(Target_CId, Mysql_Operate_Func.CheckMarryTargetName(Target_CId), Time, Level, SUser.GetCID(), SUser.GetCharacName(), 1, Index);
Mysql_Operate_Func.InsertMarryRoom(SUser.GetCID(), SUser.GetCharacName(), Time, Level, Target_CId, Mysql_Operate_Func.CheckMarryTargetName(Target_CId), Time, Index);
Mysql_Operate_Func.InsertMarryRoom(Target_CId, Mysql_Operate_Func.CheckMarryTargetName(Target_CId), Time, Level, SUser.GetCID(), SUser.GetCharacName(), Time, Index);
AuditoriumUserInfo.rawset(SUser.GetCID(), {});
@@ -348,6 +488,28 @@ class Marry {
}
//这里放2个新人的信息
local avatra = [];
local infore = {};
infore.rawset("job", SUser.GetCharacJob());
infore.rawset("growjob", SUser.GetCharacGrowType());
infore.rawset("avatar", Config["职业对应的结婚礼服"][SUser.GetCharacJob().tostring()]);
infore.rawset("name", SUser.GetCharacName());
infore.rawset("uid", SUser.GetUID());
local Muser = World.GetUserByUid(Target_CId);
local infore2 = {};
infore2.rawset("job", Muser.GetCharacJob());
infore2.rawset("growjob", Muser.GetCharacGrowType());
infore2.rawset("avatar", Config["职业对应的结婚礼服"][Muser.GetCharacJob().tostring()]);
infore2.rawset("name", Muser.GetCharacName());
infore2.rawset("uid", Muser.GetUID());
avatra.push(infore);
avatra.push(infore2);
AuditoriumUserInfoNewPeople.rawset(SUser.GetCID(), avatra);
local WorldMap = World.GetOnlinePlayer();
foreach(W_User in WorldMap) {
@@ -356,54 +518,108 @@ class Marry {
W_User.SendNotiBox(format("婚礼将在%d分钟后举行!\n点击大司祭可进入礼堂。", (Time + 1) * 10), 1);
}
}
SUser.SendJso(T);
SUser.SendNotiBox(format("婚礼将在%d分钟后举行!\n点击大司祭可进入礼堂。", (Time + 1) * 10), 1);
print(time());
Timer.SetTimeOut(OpenAuditorium.bindenv(this), (Time + 1) * 10 * 1000, SUser.GetCID());
}
}
//婚礼前的准备 把2个新人先传进去
function OpenPreparation(index) {
//拿到两个新人的信息
local uidsInfo = AuditoriumUserInfoNewPeople[index];
local uid1 = uidsInfo[0].rawget("uid");
local uid2 = uidsInfo[1].rawget("uid");
//拿到礼堂所有宾客的信息
local userlist = AuditoriumUserInfo[index];
//如果不在里面就传送进来
if (!(userlist.rawin(uid1))) {
EnterAuditorium(World.GetUserByUid(uid1), {
room = -1
});
}
if (!(userlist.rawin(uid2))) {
EnterAuditorium(World.GetUserByUid(uid2), {
room = -1
});
}
}
//开启婚礼 参数为礼堂编号 也就是其中一个人的cid
function OpenAuditorium(index) {
print(time());
//婚礼准备
OpenPreparation(index);
//通知所有在这个礼堂里的人 婚礼开始了
local userlist = AuditoriumUserInfo[RoomId];
local userlist = AuditoriumUserInfo[index];
local dxcid = Mysql_Operate_Func.CheckMarryTarget(index);
foreach(uid in userlist) {
//先拿到新人存的信息
local info = AuditoriumUserInfoNewPeople[index];
local uid1 = info[0].rawget("uid");
local uid2 = info[1].rawget("uid");
//比那里礼堂所有人信息
foreach(uid, v in userlist) {
local user = World.GetUserByUid(uid);
//todo 这里要判断 如果是结婚的人就不加到宾客里
if (!user) {
//发包通知 如果是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);
local infore = {
job = user.GetCharacJob(),
growjob = user.GetCharacGrowType(),
avatar = GetAva(user),
name = user.GetCharacName(),
};
info.push(infore);
if (info.len() >= 8) {
break;
}
}
foreach(uid, v in userlist) {
local user = World.GetUserByUid(uid);
//发包通知 普通宾客的包
local T = {
op = OP + 34,
info = info
}
user.SendJso(T);
}
//删除礼堂信息
AuditoriumUserInfo.rawdelete(RoomId);
AuditoriumUserInfo.rawdelete(index);
//删除数据库信息
Mysql_Operate_Func.DeleteMarryInfo(index);
Mysql_Operate_Func.DeleteMarryInfo(dxcid);
//Mysql_Operate_Func.RomoveRoom();
}
//进入礼堂
function EnterAuditorium(SUser, Jso) {
local RoomId = Jso.room;
local location = SUser.GetLocation();
//进入自己的礼堂
// //进入自己的礼堂
if (RoomId == -1) {
local MyState = Mysql_Operate_Func.CheckMarryState(SUser.GetCID());
if (MyState != 2) {
@@ -420,6 +636,7 @@ class Marry {
location.rawset("所在礼堂编号", RoomId);
//向缓存写入进入时的坐标
EnterAuditoriumPosList.rawset(SUser.GetCID(), location);
//移动到礼堂
World.MoveArea(SUser, Config["礼堂城镇编号"], Config["礼堂区域编号"], 55, 349);
} else {
@@ -433,21 +650,47 @@ class Marry {
AuditoriumUserInfo[RoomId].rawset(SUser.GetUID(), GetAva(SUser));
local infore = {};
infore.rawset("job", SUser.GetCharacJob());
infore.rawset("growjob", SUser.GetCharacGrowType());
infore.rawset("avatar", GetAva(SUser));
infore.rawset("name", SUser.GetCharacName());
AuditoriumUserInfo[RoomId].rawset(SUser.GetUID(), infore);
//遍历这个礼堂里的人 给他们发送可见列表
local UserCanSee = [];
foreach(cid in AuditoriumUserInfo[RoomId]) {
UserCanSee.push(cid);
foreach(uid, info in AuditoriumUserInfo[RoomId]) {
UserCanSee.push(uid);
}
MarryUserCallBack(UserCanSee, SUser)
local T = {
op = OP + 22,
time = Mysql_Operate_Func.GetAuditoriumTimeById(RoomId) - time()
}
SUser.SendJso(T);
}
//服务端区域移动添加玩家HOOK 让大家不可见
function Marry_insert_user_hook(C_Area, C_User) {
//如果有城镇配置
if (Config) {
local SUser = User(C_User);
if (SUser.GetLocation().Town == Config["礼堂城镇编号"]) {
if (SUser.GetLocation().Area == Config["礼堂区域编号"]) Sq_WriteAddress(C_Area, 0x68, 1);
}
}
}
//离开礼堂
function LeaveAuditorium(SUser, Jso) {
if (EnterAuditoriumPosList.rawin(SUser.GetCID())) {
@@ -455,11 +698,15 @@ class Marry {
//离开礼堂回到进入时的位置
World.MoveArea(SUser, Info.Town, Info.Area, Info.Pos.X, Info.Pos.Y);
//给这个礼堂的人发送退出可见列表的包
foreach(uid in AuditoriumUserInfo[Info["所在礼堂编号"]]) {
UserCanSee.push(uid);
}
MarryUserDeleteCallBack(UserCanSee, SUser)
AuditoriumUserInfo[Info["所在礼堂编号"]].rawdelete(SUser.GetUID());
}
}
@@ -500,13 +747,18 @@ class Marry {
}
//表示是否可见 参数为用户数组
function MarryUserCallBack(RealList, MUser) {
//加入到可见列表
function MarryUserCallBack(CUserList, MUser) {
local RealList = [];
foreach(uid in CUserList) {
local SUser = World.GetUserByUid(uid);
if (SUser && SUser.GetState() >= 3) RealList.append(SUser);
}
foreach(_Index, Value in RealList) {
local SUser = Value;
if (!SUser || !SUser.GetState() >= 3) continue;
if (SUser.GetUID() == MUser.GetUID()) continue;
local Pack = Packet();
Pack.Put_Header(0, 24);
Pack.Put_Byte(SUser.GetLocation().Town); //城镇
@@ -522,7 +774,6 @@ class Marry {
}
Pack.Put_Byte(1); //是否可见
Pack.Finalize(true);
SUser.Send(Pack);
Pack.Delete();
}
@@ -550,7 +801,7 @@ class Marry {
Pack.Put_Byte(MUser.GetDirections()); //朝向
Pack.Put_Byte(MUser.GetVisibleValues()); //是否可见
Pack.Finalize(true);
print(111);
SUser.Send(Pack);
Pack.Delete();
}
@@ -561,6 +812,7 @@ class Marry {
constructor() {
Config = dofile("/root/娱心插件配置/结婚系统配置.dat");
local ConfigPath = Sq_Game_GetConfig();
Channel = ConfigPath.slice(-6).slice(0, 2);
@@ -575,53 +827,24 @@ class Marry {
ClientSocketPackFuncMap.rawset(OP + 17, LeaveAuditorium.bindenv(this));
ClientSocketPackFuncMap.rawset(OP + 19, GetAuditoriumList.bindenv(this));
ClientSocketPackFuncMap.rawset(OP + 777, GetConfig.bindenv(this));
//每次加载的时候都注册礼堂信息
AuditoriumUserInfo.rawset(1, {});
//注册结婚回调函数
Cb_Insert_User_Func.Marry <- Marry_insert_user_hook.bindenv(this); //区域添加角色
//玩家重新上线的时候自动给他退出礼堂
Cb_reach_game_world_Func.Auditorium <- function(SUser) {
if (EnterAuditoriumPosList.rawin(SUser.GetUID())) {
local Info = EnterAuditoriumPosList[SUser.GetCID()];
//给这个礼堂的人发送退出可见列表的包
foreach(cid in AuditoriumUserInfo[Info["所在礼堂编号"]]) {
UserCanSee.push(cid);
}
MarryUserDeleteCallBack(UserCanSee, SUser)
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());
// }
// }
//从池子拿连接
local SqlObj = MysqlPool.GetInstance().GetConnect();
local query = "SELECT COUNT(*) AS table_exists FROM information_schema.tables WHERE table_schema = 'zyk' AND table_name = 'marry';"
@@ -636,123 +859,31 @@ 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 = [];
Timer.SetTimeOut(function() {
ProjectInitFuncMap.P_Marry <- Marry();
}, 0)
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);
Gm_InputFunc_Handle.ss <- function(SUser, CmdString) {
}
} else { //如果这个部位没东西 直接放默认时装上去
re.push(defaultJobItemIdMap[job].index[u]);
}
}
return re;
}
//默认时装
defaultJobItemIdMap <- {};
local aa = Marry.GetAva(SUser);
printT(aa);
class defaultJobItemId {
/**
* 头发
*/
hat = 0;
}.bindenv(this);
/**
* 帽子
*/
hair = 0;
print("-----------------------")
print(time());
/**
*脸
*/
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();
Timer.SetTimeOut(function() {
print(time());
}, 5000);

View File

@@ -36,4 +36,9 @@ MARRY_SQL_LIST.GetAuditoriumList <- @"SELECT * FROM zyk.marry_room";
MARRY_SQL_LIST.GetAuditoriumIndexById <- @"SELECT target_cid FROM zyk.marry_room WHERE cid = %d";
//根据cid查询自己的礼堂编号
MARRY_SQL_LIST.GetAuditoriumTimeById <- @"SELECT rindex FROM zyk.marry_room WHERE cid = %d";
MARRY_SQL_LIST.GetAuditoriumTimeById <- @"SELECT rindex FROM zyk.marry_room WHERE cid = %d";
MARRY_SQL_LIST.GetAuditoriumName2ById <- @"SELECT name, FROM zyk.marry_room WHERE cid = %d or target_cid = %d";
MARRY_SQL_LIST.RomoveRoom <- @"DELETE FROM marry_room where rindex < UNIX_TIMESTAMP();";