融合装备

This commit is contained in:
lenheart 2025-12-09 00:38:18 +08:00
parent 19a6add83e
commit c9e3f3ad06
6 changed files with 203 additions and 6 deletions

View File

@ -2,7 +2,7 @@ function sqr_main() {
GameManager.OpenHotFix("/dp_s/OfficialConfig"); GameManager.OpenHotFix("/dp_s/OfficialConfig");
GameManager.OpenHotFix("/dp_s/_DPS_/_Core"); GameManager.OpenHotFix("/dp_s/_DPS_/_Core");
GameManager.OpenHotFix("/dp_s/MyProject"); GameManager.OpenHotFix("/dp_s/MyProject");
// GameManager.SetGameMaxLevel(70); GameManager.SetGameMaxLevel(86);
// Cb_History_MileageSet_Func["TW_reach_game_world"] <- function(SUser, Data) { // Cb_History_MileageSet_Func["TW_reach_game_world"] <- function(SUser, Data) {
// //第一次上线 // //第一次上线
// if (SUser.GetCharacLevel() > 70) { // if (SUser.GetCharacLevel() > 70) {

View File

@ -266,9 +266,11 @@ Gm_InputFunc_Handle["test"] <- function(SUser, CmdString) {
// }, 1) // }, 1)
Timer.SetTimeOut(function () Timer.SetTimeOut(function ()
{ {
print(12313);
GameManager.SetGameMaxLevel(85); print("111");
}, 1); }, 1);

View File

@ -87,6 +87,11 @@
"Script": [ "Script": [
"NPC交易/NpcTransaction.nut" "NPC交易/NpcTransaction.nut"
] ]
},
"融合装备": {
"Script": [
"融合装备/融合装备.nut"
]
} }
} }
} }

View File

@ -0,0 +1,174 @@
/*
文件名:装备融合.nut
路径:MyProject/装备融合/装备融合.nut
创建日期:2025-12-06 19:34
文件用途:
*/
class ItemFusionC {
//配置表
Info = null;
//用户状态表
UserState = null;
constructor() {
Info = {};
UserState = {};
//读取PVF
InitPvf();
//注册客户端收包
RegisterClient();
}
function RegisterClient() {
ClientSocketPackFuncMap.rawset(21006001, function(SUser, Jso) {
local ItemInfo1 = Jso.item1;
local ItemInfo2 = Jso.item2;
local Key = ItemInfo1.itemId + "_" + ItemInfo2.itemId;
local Key2 = ItemInfo2.itemId + "_" + ItemInfo1.itemId;
local CheckFlag1 = Info.rawin(Key);
local CheckFlag2 = Info.rawin(Key2);
if (CheckFlag1 || CheckFlag2) {
SUser.SendJso({
op = 21006002,
msg = 1,
value = Info[CheckFlag1 ? Key : Key2]
});
local Cid = SUser.GetCID();
UserState.rawset(Cid, {
time = Sq_GetTimestampString().slice(-9).tointeger(),
info = Jso
reward = Info[CheckFlag1 ? Key : Key2]
});
} else {
SUser.SendJso({
op = 21006002,
msg = 2,
});
}
}.bindenv(this));
ClientSocketPackFuncMap.rawset(21006003, function(SUser, Jso) {
local Cid = SUser.GetCID();
if (!UserState.rawin(Cid)) {
SUser.SendNotiBox(" 融合失败 请放入两个可融合的装备 并且融合时请不要操作背包", 1);
SUser.SendJso({
op = 21006004,
error = true,
});
} else {
//获取存储的融合信息
local UserInfo = UserState[Cid].info;
local ItemInfo1 = UserInfo.item1;
local ItemInfo2 = UserInfo.item2;
//获取需要融合的两件装备
local InvenObj = SUser.GetInven();
local Equ1 = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + ItemInfo1.pos);
local Equ2 = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + ItemInfo2.pos);
//判断ID 以免被移动
if (Equ1.GetIndex() != ItemInfo1.itemId || Equ2.GetIndex() != ItemInfo2.itemId) {
SUser.SendNotiBox(" 融合失败 请放入两个可融合的装备 并且融合时请不要操作背包", 1);
SUser.SendJso({
op = 21006004,
error = true,
});
} else {
//告诉客户端播放动画
SUser.SendJso({
op = 21006004,
});
//获取信息
local forging = Equ1.GetForging(); //锻造
local upgrade = Equ1.GetUpgrade(); //强化
local amplification = Equ1.GetAmplification(); //增幅
local enchanting = Equ1.GetEnchanting(); //附魔
//销毁融合的两件装备
Equ1.Delete();
Equ2.Delete();
SUser.SendUpdateItemList(1, 0, 9 + ItemInfo1.pos);
SUser.SendUpdateItemList(1, 0, 9 + ItemInfo2.pos);
//获取融合后的装备ID
local reward1 = UserState[Cid].reward[0];
local reward2 = UserState[Cid].reward[1];
Timer.SetTimeOut(function() {
local RewardNotiList = [
[reward1, 1]
];
//发送奖励
local Info = SUser.GiveItem(reward1, 1);
if (reward2 != 0) {
SUser.GiveItem(reward2, 1);
RewardNotiList.append([reward2, 1]);
}
SUser.SendItemWindowNotification(RewardNotiList);
//获取装备 并设置继承属性
local InvenObj = SUser.GetInven();
if (InvenObj) {
local ItemObj1 = InvenObj.GetSlot(1, Info[1])
if (ItemObj1) {
if (forging > 0) {
ItemObj1.SetForging(forging);
}
if (upgrade > 0) {
ItemObj1.SetUpgrade(upgrade);
}
if (amplification != 0) {
ItemObj1.SetAmplification(amplification);
}
ItemObj1.SetEnchanting(enchanting);
ItemObj1.Flush();
SUser.SendUpdateItemList(1, 0, Info[1]);
}
}
}.bindenv(this), 2400);
UserState.rawdelete(Cid);
}
}
}.bindenv(this));
};
function InitPvf() {
// Script();
ScriptData.GetFileData("etc/rindro/itemtool/itemfusion/itemfusion.etc", function(DataTable, Data) {
while (!Data.Eof()) {
local Fragment = Data.Get();
if (Fragment == "[ITEM]") {
while (true) {
local Fbuf = Data.Get();
if (Fbuf == "[/ITEM]") {
break;
}
local Item1 = Fbuf;
local Item2 = Data.Get();
local GiveItem1 = Data.Get();
local GiveItem2 = Data.Get();
local Key = Item1 + "_" + Item2;
local Value = [GiveItem1, GiveItem2];
Info.rawset(Key, Value);
}
}
}
}.bindenv(this));
}
}
Timer.SetTimeOut(function() {
getroottable()._ItemFusion_ <- ItemFusionC();
print("融合装备已加载");
}, 1);

View File

@ -244,12 +244,12 @@ class User extends Base_C_Object {
//发送字节包 //发送字节包
function SendBlob(Np) { function SendBlob(Np) {
if(!Np || Np.Size == -1)return; if (!Np || Np.Size == -1) return;
local Pack = Packet(); local Pack = Packet();
Pack.Put_Header(1, 131); Pack.Put_Header(1, 131);
Pack.Put_Byte(1); Pack.Put_Byte(1);
Pack.Put_Int(Np.Size); Pack.Put_Int(Np.Size);
Pack.Put_BinaryEx(Np.C_Object,Np.Size); Pack.Put_BinaryEx(Np.C_Object, Np.Size);
Pack.Finalize(true); Pack.Finalize(true);
Send(Pack); Send(Pack);
Pack.Delete(); Pack.Delete();
@ -857,4 +857,21 @@ function User::ReqDBSendMultiMail(title, text, gold, item_list) {
} }
} }
}, 1, this, title, text, gold, item_list); }, 1, this, title, text, gold, item_list);
}
function User::SendItemWindowNotification(item_list) {
local Pack = Packet();
Pack.Put_Header(1, 163); //协议
Pack.Put_Byte(1); //默认1
Pack.Put_Short(0); //槽位id 填入0即可
Pack.Put_Int(0); //未知 0以上即可
Pack.Put_Short(item_list.len()); //道具组数
//写入道具代码和道具数量
for (local i = 0; i< item_list.len(); i++) {
Pack.Put_Int(item_list[i][0]); //道具代码
Pack.Put_Int(item_list[i][1]); //道具数量 装备/时装时 任意均可
}
Pack.Finalize(true); //确定发包内容
Send(Pack); //发包
Pack.Delete(); //清空buff区
} }

View File

@ -94,7 +94,6 @@ class ServerControl {
//获得本服务器的IP //获得本服务器的IP
GatewaySocketPackFuncMap.rawset(10002, function(Jso) { GatewaySocketPackFuncMap.rawset(10002, function(Jso) {
print("记录Ip");
Dps_Self_Ip = Jso.myip; Dps_Self_Ip = Jso.myip;
}.bindenv(this)); }.bindenv(this));