594 lines
23 KiB
Plaintext
594 lines
23 KiB
Plaintext
/*
|
||
文件名:毁梦定制战力系统.nut
|
||
路径:MyProject/毁梦定制战力系统.nut
|
||
创建日期:2025-12-25 22:54
|
||
文件用途:
|
||
*/
|
||
|
||
class DreamDestroyerCustomizedCombatPowerSystemC {
|
||
|
||
MysqlObject = null;
|
||
|
||
|
||
constructor() {
|
||
MysqlObject = Mysql(Str_Ptr("127.0.0.1"), 3306, Str_Ptr("taiwan_cain"), Str_Ptr("game"), Str_Ptr("uu5!^%jg"));
|
||
MysqlObject.Exec_Sql(format("SET NAMES %s", "latin1"));
|
||
|
||
|
||
|
||
Cb_reach_game_world_Func["HM_reach_game_world"] <- function(SUser) {
|
||
local cid = SUser.GetCID();
|
||
local Ranking = CheckCidIsRankingTop(cid);
|
||
if (Ranking != -1) {
|
||
WorldNoti(SUser, Ranking);
|
||
} else {
|
||
local InvenObj = SUser.GetInven();
|
||
local Weapon = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, 10);
|
||
local Upgrade = Weapon.GetUpgrade();
|
||
if (Upgrade >= 15 && Upgrade <= 31) {
|
||
WorldNoti(SUser, -1);
|
||
}
|
||
}
|
||
}.bindenv(this);
|
||
}
|
||
|
||
function CheckCidIsRankingTop(cid) {
|
||
local Rank = MysqlObject.Select("SELECT cid FROM zyk.phb2 ORDER BY zdl DESC LIMIT 3", ["int"]);
|
||
local List = {};
|
||
if (Rank && Rank.len() > 0) {
|
||
List.rawset(Rank[0][0], 1);
|
||
List.rawset(Rank[1][0], 2);
|
||
List.rawset(Rank[2][0], 3);
|
||
}
|
||
if (List.rawin(cid)) return List[cid];
|
||
return -1;
|
||
}
|
||
|
||
|
||
function WorldNoti(SUser, Ranking) {
|
||
local InvenObj = SUser.GetInven();
|
||
local Weapon = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, 10);
|
||
local Upgrade = Weapon.GetUpgrade();
|
||
local UpgradeStr = Upgrade > 0 ? ("+" + Upgrade) : "";
|
||
local WeaponName = PvfItem.GetNameById(Weapon.GetIndex());
|
||
local PvfItem = PvfItem.GetPvfItemById(Weapon.GetIndex());
|
||
local Rarity = PvfItem.GetRarity();
|
||
|
||
local HeaderStr = "战力榜第" + Ranking + "名";
|
||
if (Ranking == -1) HeaderStr = "玩家";
|
||
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
// LoginMsgObj.PutImoticon(63);
|
||
LoginMsgObj.PutColorString(HeaderStr, [255, 191, 0]);
|
||
LoginMsgObj.PutColorString(" [" + SUser.GetCharacName() + "] ", [255, 107, 101]);
|
||
LoginMsgObj.PutColorString("携带", [255, 191, 0]);
|
||
LoginMsgObj.PutEquipment(" [" + UpgradeStr + WeaponName + "] ", Weapon, AdMsg.RarityColor[Rarity]);
|
||
LoginMsgObj.PutColorString("上线了!", [255, 191, 0]);
|
||
LoginMsgObj.Finalize();
|
||
local PackObject = LoginMsgObj.MakePack();
|
||
World.SendAll(PackObject);
|
||
SUser.Send(PackObject);
|
||
LoginMsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// 下面是 毁梦的播报
|
||
|
||
|
||
|
||
|
||
|
||
|
||
_HM_DQJY_ <- ["0", "0"]
|
||
_HM_DQJYHD_ <- "0"
|
||
|
||
function _Dps_JYYJBB2_Main_() {
|
||
|
||
Cb_Use_Item_Sp_Func[999594696] <- function(SUser, ItemId) {
|
||
|
||
// 获取背包对象
|
||
local InvenObj = SUser.GetInven();
|
||
|
||
// 获取宠物装备栏第一格(slot 0)的物品
|
||
local PetEquipItem = InvenObj.GetSlot(Inven.INVENTORY_TYPE_CREATURE, 140);
|
||
|
||
// 检查第一格是否有物品
|
||
if (PetEquipItem == null) {
|
||
SUser.SendNotiPacketMessage("宠物装备栏第一格没有装备!", 8);
|
||
return;
|
||
}
|
||
|
||
// 获取第一格物品的编号
|
||
local EquipItemId = PetEquipItem.GetIndex();
|
||
|
||
// 根据物品编号给予对应奖励
|
||
local RewardItemId = null;
|
||
|
||
if (EquipItemId == 11808) {
|
||
RewardItemId = 2112115;
|
||
} else if (EquipItemId == 11809) {
|
||
RewardItemId = 2112116;
|
||
} else if (EquipItemId == 11810) {
|
||
RewardItemId = 2112117;
|
||
} else {
|
||
SUser.SendNotiPacketMessage("宠物装备栏第一格的装备不支持回收!", 8);
|
||
}
|
||
|
||
|
||
if (!RewardItemId) return;
|
||
|
||
// 删除宠物装备栏第一格的装备
|
||
PetEquipItem.Delete();
|
||
|
||
// 刷新宠物装备栏
|
||
SUser.SendUpdateItemList(1, Inven.INVENTORY_TYPE_CREATURE, 140);
|
||
|
||
SUser.GiveItemEx([{
|
||
id = RewardItemId,
|
||
count = 1
|
||
}]);
|
||
|
||
SUser.SendItemSpace(3);
|
||
SUser.SendItemSpace(7);
|
||
}
|
||
|
||
Cb_History_ItemUp_Func["交易邮件播报"] <- function(SUser, args) {
|
||
local reason = args[18];
|
||
if (reason == "1") {
|
||
local pvfitem = PvfItem.GetNameById(args[15].tointeger());
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [255, 0, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("获得", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + args[20] + "]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("交易的道具", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(pvfitem, [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(args[17] + "个", [255, 255, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
Cb_History_MoneyUp_Func["交易邮件播报"] <- function(SUser, args) {
|
||
local reason = args[16];
|
||
if (reason == "1") {
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [255, 0, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("获得", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + getFirstBracketContent(args[17]) + "]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("交易的", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(args[15], [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("金币", [255, 255, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
Cb_MailBox11_Send_Leave_Func["交易邮件播报"] <- function(args) {
|
||
local jewelSocketID = NativePointer(args[0]).readPointer();
|
||
local SUser = User(jewelSocketID);
|
||
local name = SUser.GetCharacName();
|
||
local receive_name = NativePointer(args[1]).add(17).readUtf8String();
|
||
local send_gold_count = NativePointer(args[1]).add(46).readU32();
|
||
local send_item_id = NativePointer(args[1]).add(57).readU32();
|
||
local send_item_count = NativePointer(args[1]).add(61).readU32(); //发送道具数量
|
||
local item_name;
|
||
if (send_item_id > 0) {
|
||
item_name = PvfItem.GetNameById(send_item_id);
|
||
}
|
||
// 发送世界公告播报
|
||
if (send_gold_count > 0 && send_item_id > 0) {
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("刚刚通过邮件向", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + receive_name + "]", [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("发送了", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("金币*" + send_gold_count, [255, 170, 0]);
|
||
LoginMsgObj.PutColorString("和", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(send_item_count + "个", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(item_name, [255, 255, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
} else if (send_gold_count > 0) {
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("刚刚通过邮件向", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + receive_name + "]", [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("发送了", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("金币*" + send_gold_count, [255, 170, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
} else if (send_item_id > 0) {
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("刚刚通过邮件向", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + receive_name + "]", [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("发送了", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(send_item_count + "个", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(item_name, [255, 255, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
} else {
|
||
local LoginMsgObj = AdMsg();
|
||
LoginMsgObj.PutType(14);
|
||
LoginMsgObj.PutColorString("玩家[", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString(SUser.GetCharacName(), [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("]", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("刚刚通过邮件向", [255, 255, 0]);
|
||
LoginMsgObj.PutColorString("[" + receive_name + "]", [0, 255, 0]);
|
||
LoginMsgObj.PutColorString("发送了一封邮件", [255, 255, 0]);
|
||
LoginMsgObj.Finalize();
|
||
World.SendAll(LoginMsgObj.MakePack());
|
||
LoginMsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
|
||
Cb_History_ItemUp_Func["交易邮件播报"] <- function(SUser, args) {
|
||
local reason = args[18];
|
||
if (reason == "1" || reason == "17") {
|
||
local username = SUser.GetCharacName();
|
||
local username2 = getContentBetweenDelimiters(args[20]);
|
||
local pvfitem = PvfItem.GetNameById(args[15].tointeger());
|
||
if (reason == "17") {
|
||
username = getContentBetweenDelimiters(args[20]);
|
||
username2 = getContentBetweenDelimiters(args[19]);
|
||
}
|
||
if ((_HM_DQJY_[0] == username && _HM_DQJY_[1] == username2) || (_HM_DQJY_[1] == username && _HM_DQJY_[0] == username2)) { //这里就不用播报谁和谁交易 谁拿到什么就行了
|
||
if (_HM_DQJYHD_ != username) {
|
||
World.SendNotiPacketMessage(format("[%s]得到以下物品", username), 14);
|
||
_HM_DQJYHD_ = username;
|
||
}
|
||
World.SendNotiPacketMessage(format("[%s]数量[%s]", pvfitem, args[17]), 14);
|
||
} else {
|
||
_HM_DQJY_[0] = username;
|
||
_HM_DQJY_[1] = username2;
|
||
World.SendNotiPacketMessage(format("玩家[%s]与[%s]交易信息", username, username2), 14);
|
||
World.SendNotiPacketMessage(format("[%s]得到以下物品", username), 14);
|
||
World.SendNotiPacketMessage(format("[%s]数量[%s]", pvfitem, args[17]), 14);
|
||
_HM_DQJYHD_ = username;
|
||
}
|
||
}
|
||
|
||
Timer.SetTimeOut(function() {
|
||
_HM_DQJY_[0] = "0";
|
||
_HM_DQJY_[1] = "0";
|
||
_HM_DQJYHD_ = "0";
|
||
}, 50);
|
||
}
|
||
|
||
|
||
Cb_History_MoneyUp_Func["交易邮件播报"] <- function(SUser, args) {
|
||
local reason = args[16];
|
||
if (reason == "1" || reason == "11") {
|
||
local username = SUser.GetCharacName();
|
||
local username2 = "";
|
||
if (reason == "11") {
|
||
username2 = _HM_DQJY_[0];
|
||
} else {
|
||
username2 = getFirstBracketContent(args[17]);
|
||
}
|
||
if ((_HM_DQJY_[0] == username && _HM_DQJY_[1] == username2) || (_HM_DQJY_[1] == username && _HM_DQJY_[0] == username2)) { //这里就不用播报谁和谁交易 谁拿到什么就行了
|
||
if (_HM_DQJYHD_ != username) {
|
||
World.SendNotiPacketMessage(format("[%s]得到以下物品", username), 14);
|
||
_HM_DQJYHD_ = username;
|
||
|
||
}
|
||
World.SendNotiPacketMessage(format("[金钱]数量[%s]", args[15]), 14);
|
||
} else {
|
||
_HM_DQJY_[0] = username;
|
||
_HM_DQJY_[1] = username2;
|
||
World.SendNotiPacketMessage(format("玩家[%s]与[%s]交易信息", SUser.GetCharacName(), username2), 14);
|
||
World.SendNotiPacketMessage(format("[%s]得到以下物品", SUser.GetCharacName()), 14);
|
||
World.SendNotiPacketMessage(format("[金钱]数量[%s]", args[15]), 14);
|
||
_HM_DQJYHD_ = username;
|
||
}
|
||
}
|
||
|
||
Timer.SetTimeOut(function() {
|
||
_HM_DQJY_[0] = "0";
|
||
_HM_DQJY_[1] = "0";
|
||
}, 50);
|
||
}
|
||
|
||
|
||
Cb_Inter_AuctionResultBidding_Leave_Func["交易播报2"] <- function(args) {
|
||
|
||
Timer.SetTimeOut(function() {
|
||
|
||
local username = User(args[1]).GetCharacName();
|
||
local id = NativePointer(args[2]).add(14).readInt();
|
||
|
||
local CheckSql = "SELECT item_id,unit_price,owner_id FROM taiwan_cain_auction_gold.auction_history_" + getYearMonth() + " where auction_id = " + id + ";";
|
||
//从池子拿连接
|
||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||
local Ret = SqlObj.Select(CheckSql, ["int", "int", "int"]);
|
||
|
||
|
||
if (Ret == null || Ret.len() == 0) {
|
||
print(123);
|
||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||
return;
|
||
|
||
}
|
||
|
||
|
||
local itemId = Ret[0][0];
|
||
local unitPrice = Ret[0][1];
|
||
local maijiacid = Ret[0][2];
|
||
|
||
if (maijiacid == User(args[1]).GetCID()) {
|
||
print(321);
|
||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||
return;
|
||
|
||
}
|
||
|
||
|
||
local CheckSql2 = "SELECT price FROM taiwan_cain_auction_gold.auction_history_buyer_" + getYearMonth() + " ORDER BY occ_time DESC LIMIT 1;";
|
||
|
||
local Ret2 = SqlObj.Select(CheckSql2, ["int"]);
|
||
|
||
local price = Ret2[0][0];
|
||
|
||
|
||
|
||
local CheckSql3 = "SELECT charac_name FROM taiwan_cain.charac_info where charac_no = " + maijiacid;
|
||
|
||
local Ret3 = SqlObj.Select(CheckSql3, ["string"]);
|
||
|
||
local mjname = Ret3[0][0];
|
||
|
||
|
||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||
|
||
World.SendNotiPacketMessage(format("玩家[%s]在拍卖行用[%d]金币从[%s]手里购得[%s]物品", username, price, mjname, PvfItem.GetNameById(itemId)), 14);
|
||
|
||
}, 100);
|
||
|
||
|
||
}
|
||
|
||
Cb_User_Vend_Item_Leave_Func["交易播报2"] <- function(args) {
|
||
Timer.SetTimeOut(function() {
|
||
local username = User(args[1]).GetCharacName();
|
||
local id = NativePointer(args[2]).add(10).readInt();
|
||
local CheckSql = "SELECT item_id,unit_price,owner_id FROM taiwan_cain_auction_gold.auction_history_" + getYearMonth() + " where auction_id = " + id + ";";
|
||
//从池子拿连接
|
||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||
local Ret = SqlObj.Select(CheckSql, ["int", "int", "int"]);
|
||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||
local itemId = Ret[0][0];
|
||
local unitPrice = Ret[0][1];
|
||
local maijiacid = Ret[0][2];
|
||
if (maijiacid == User(args[1]).GetCID()) return;
|
||
local CheckSql2 = "SELECT price FROM taiwan_cain_auction_gold.auction_history_buyer_" + getYearMonth() + " ORDER BY occ_time DESC LIMIT 1;";
|
||
//从池子拿连接
|
||
local SqlObj2 = MysqlPool.GetInstance().GetConnect();
|
||
local Ret = SqlObj2.Select(CheckSql2, ["int"]);
|
||
MysqlPool.GetInstance().PutConnect(SqlObj2);
|
||
local price = Ret[0][0];
|
||
local num = price / unitPrice;
|
||
local CheckSql3 = "SELECT charac_name FROM taiwan_cain.charac_info where charac_no = " + maijiacid;
|
||
//从池子拿连接
|
||
local SqlObj3 = MysqlPool.GetInstance().GetConnect();
|
||
local Ret = SqlObj3.Select(CheckSql3, ["string"]);
|
||
MysqlPool.GetInstance().PutConnect(SqlObj3);
|
||
local mjname = Ret[0][0];
|
||
World.SendNotiPacketMessage(format("玩家[%s]在拍卖行用[%d]金币从[%s]手里购得[%s]物品[%d]个", username, price, mjname, PvfItem.GetNameById(itemId), num), 14);
|
||
}, 100);
|
||
}
|
||
|
||
Cb_UserHistoryLog_ItemAdd_Enter_Func["史诗掉落播报"] <- function(args) {
|
||
local SUser = User(NativePointer(args[0]).readPointer());
|
||
local InvenObj = SUser.GetInven();
|
||
local ItemObj = Item(args[4]);
|
||
local type = args[5];
|
||
local PartyObj = SUser.GetParty();
|
||
if (!PartyObj) return;
|
||
local Bfobj = PartyObj.GetBattleField();
|
||
local DgnObj = Bfobj.GetDgn();
|
||
if (!DgnObj) return;
|
||
local Dungeon_Name = DgnObj.GetName();
|
||
if (!ItemObj) return;
|
||
local item_id = ItemObj.GetIndex();
|
||
local ItemType = Sq_CallFunc(S_Ptr("0x085018D2"), "int", ["pointer", "int"], InvenObj.C_Object, item_id);
|
||
local pvfitem = PvfItem.GetPvfItemById(item_id);
|
||
// 史诗装备记录
|
||
if (pvfitem.GetRarity() == 4 /*&& type == 4 */ && ItemType == 1) {
|
||
local MsgObj = AdMsg();
|
||
MsgObj.PutType(14);
|
||
MsgObj.PutColorString("玩家[" + SUser.GetCharacName() + "]于", [255, 220, 0]);
|
||
MsgObj.PutColorString(getSFMTime(), [255, 220, 0]);
|
||
MsgObj.PutColorString("在[" + Dungeon_Name + "]" + "获得史诗装备", [255, 220, 0]);
|
||
MsgObj.PutEquipment("[" + PvfItem.GetNameById(item_id) + "]", ItemObj, [255, 180, 0]);
|
||
MsgObj.PutColorString("一件", [255, 220, 0]);
|
||
MsgObj.Finalize();
|
||
World.SendAll(MsgObj.MakePack());
|
||
MsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
ClientSocketPackFuncMap.rawset(21091001, function(SUser, Jso) {
|
||
MoveToCargo(SUser, Jso.type);
|
||
});
|
||
|
||
function getYearMonth() {
|
||
local now = date();
|
||
return format("%d%02d", now.year, now.month + 1);
|
||
}
|
||
|
||
function getSFMTime() {
|
||
local now = date();
|
||
return format("%02d:%02d:%02d", now.hour, now.min, now.sec);
|
||
}
|
||
}
|
||
|
||
function getFirstBracketContent(str) {
|
||
local startPos = str.find("(");
|
||
if (startPos == null) return null;
|
||
local endPos = str.find(")", startPos + 1);
|
||
if (endPos == null) return null;
|
||
// 提取括号内的内容(不包括括号本身)
|
||
return str.slice(startPos + 1, endPos);
|
||
}
|
||
|
||
|
||
function getContentBetweenDelimiters(str, delimiter = "\"") {
|
||
// 检查输入有效性
|
||
if (typeof str != "string" || str.len() == 0) return null;
|
||
if (typeof delimiter != "string" || delimiter.len() == 0) return null;
|
||
|
||
// 查找第一个分隔符的位置
|
||
local firstPos = str.find(delimiter);
|
||
if (firstPos == null) return null;
|
||
|
||
// 从第一个分隔符后开始查找第二个分隔符
|
||
local secondPos = str.find(delimiter, firstPos + delimiter.len());
|
||
if (secondPos == null) return null;
|
||
|
||
// 提取两个分隔符之间的内容
|
||
return str.slice(firstPos + delimiter.len(), secondPos);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// 移动物品到仓库的Hook实现
|
||
// type: 0-个人仓库 1-账号仓库
|
||
function MoveToCargo(SUser, type) {
|
||
// slot: 3-8快捷栏 9-56线名栏 57-104消耗品栏 105-152材料栏 153-200任务栏 201-248副职业栏 249-311徽章栏
|
||
local Cargo = null;
|
||
local InvenObj = SUser.GetInven();
|
||
if (!InvenObj) return;
|
||
|
||
// 根据类型选择仓库
|
||
if (type == 0) {
|
||
// 获取个人仓库
|
||
local CargoPtr = Sq_CallFunc(S_Ptr("0x8151A94"), "pointer", ["pointer"], SUser.C_Object);
|
||
if (!CargoPtr) return;
|
||
Cargo = NativePointer(CargoPtr);
|
||
} else if (type == 1) {
|
||
// 获取账号仓库
|
||
local CargoObj = SUser.GetAccountCargo();
|
||
if (!CargoObj) return;
|
||
Cargo = NativePointer(CargoObj.C_Object);
|
||
} else {
|
||
return;
|
||
}
|
||
|
||
// 遍历 57-152 槽位(消耗品栏和材料栏)
|
||
for (local slot = 57; slot <= 152; slot++) {
|
||
// 获取背包对应slot的物品
|
||
local SlotItem = InvenObj.GetSlot(1, slot);
|
||
if (!SlotItem || SlotItem.IsEmpty) continue;
|
||
|
||
// 获取物品ID
|
||
local ItemId = SlotItem.GetIndex();
|
||
if (ItemId <= 0) continue;
|
||
|
||
local IsExist = -1;
|
||
local CargoInvenItemPtr = null;
|
||
local CargoItemId = 0;
|
||
|
||
// 根据仓库类型检查物品是否存在
|
||
if (type == 0) {
|
||
// 个人仓库检查
|
||
IsExist = Sq_CallFunc(S_Ptr("0x850BC14"), "int", ["pointer", "int"], Cargo.C_Object, ItemId);
|
||
if (IsExist == -1) continue;
|
||
|
||
// 获取个人仓库中物品的指针
|
||
local CargoItemListPtr = NativePointer(Cargo.add(4).readPointer());
|
||
CargoInvenItemPtr = CargoItemListPtr.add(61 * IsExist);
|
||
CargoItemId = CargoItemListPtr.add(61 * IsExist + 2).readU32();
|
||
} else {
|
||
// 账号仓库检查
|
||
IsExist = Sq_CallFunc(S_Ptr("0x828A61A"), "int", ["pointer", "int"], Cargo.C_Object, ItemId);
|
||
if (IsExist == -1) continue;
|
||
|
||
// 获取账号仓库中物品的指针
|
||
CargoInvenItemPtr = Cargo.add(61 * IsExist);
|
||
CargoItemId = CargoInvenItemPtr.add(6).readU32();
|
||
}
|
||
|
||
// 获取物品数量
|
||
local CargoItemCount = Sq_CallFunc(S_Ptr("0x80F783A"), "int", ["pointer"], CargoInvenItemPtr.C_Object);
|
||
local SlotItemCount = SlotItem.GetAdd_Info();
|
||
|
||
print("CargoItemCount: " + CargoItemCount + " SlotItemCount: " + SlotItemCount);
|
||
// 检查是否超过物品堆叠上限 0 超过 1没超过
|
||
local IsMax = Sq_CallFunc(S_Ptr("0x8501A79"), "int", ["int", "int"], CargoItemId, CargoItemCount + SlotItemCount);
|
||
if (IsMax == 0) {
|
||
// 超过堆叠上限,跳过
|
||
continue;
|
||
}
|
||
|
||
// 移动物品到仓库
|
||
local Result = -1;
|
||
if (type == 0) {
|
||
// 个人仓库插入
|
||
Result = Sq_CallFunc(S_Ptr("0x850B400"), "int", ["pointer", "pointer"], Cargo.C_Object, SlotItem.C_Object);
|
||
} else {
|
||
// 账号仓库插入
|
||
Result = Sq_CallFunc(S_Ptr("0x8289c82"), "int", ["pointer", "pointer", "int"], Cargo.C_Object, SlotItem.C_Object, IsExist);
|
||
}
|
||
|
||
if (Result >= 0) {
|
||
// 删除背包物品
|
||
Sq_CallFunc(S_Ptr("0x080CB7D8"), "int", ["pointer"], SlotItem.C_Object);
|
||
// 更新背包
|
||
SUser.SendUpdateItemList(1, 0, slot);
|
||
|
||
// 更新仓库显示
|
||
if (type == 0) {
|
||
// 更新个人仓库
|
||
Sq_CallFunc(S_Ptr("0x865DB6C"), "int", ["pointer", "int"], SUser.C_Object, 2);
|
||
} else {
|
||
// 更新账号仓库
|
||
local CargoObj = SUser.GetAccountCargo();
|
||
if (CargoObj) {
|
||
CargoObj.SendItemList();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
Timer.SetTimeOut(function() {
|
||
|
||
getroottable()._DreamDestroyerCustomizedCombatPowerSystemC_ <- DreamDestroyerCustomizedCombatPowerSystemC();
|
||
_Dps_JYYJBB2_Main_();
|
||
|
||
print("双端插件·毁梦定制战力系统 - 已加载");
|
||
}, 1); |