321 lines
12 KiB
Plaintext
321 lines
12 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) {
|
||
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_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) {
|
||
print("拍卖HOOK");
|
||
local username = User(args[1]).GetCharacName();
|
||
local id = NativePointer(args[2]).add(14).readInt();
|
||
NativePointer(args[2]).Output(50);
|
||
print("拍卖id: " + id);
|
||
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) {
|
||
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()) {
|
||
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 num = price / unitPrice;
|
||
|
||
|
||
|
||
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]物品[%d]个", username, price, mjname, PvfItem.GetNameById(itemId), num), 14);
|
||
|
||
}
|
||
|
||
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);
|
||
CntMsgObj.PutColorString("玩家[" + SUser.GetCharacName() + "]于", [255, 20, 0]);
|
||
CntMsgObj.PutColorString(getSFMTime(), [255, 20, 0]);
|
||
CntMsgObj.PutColorString("在[" + Dungeon_Name + "]" + "获得史诗装备", [255, 20, 0]);
|
||
MsgObj.PutEquipment("[" + PvfItem.GetNameById(item_id) + "]", ItemObj, [255, 180, 0]);
|
||
CntMsgObj.PutColorString("一件", [255, 20, 0]);
|
||
MsgObj.Finalize();
|
||
World.SendAll(MsgObj.MakePack());
|
||
MsgObj.Delete();
|
||
}
|
||
}
|
||
|
||
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);
|
||
}
|
||
|
||
|
||
|
||
|
||
Timer.SetTimeOut(function() {
|
||
|
||
getroottable()._DreamDestroyerCustomizedCombatPowerSystemC_ <- DreamDestroyerCustomizedCombatPowerSystemC();
|
||
_Dps_JYYJBB2_Main_();
|
||
|
||
print("双端插件·毁梦定制战力系统 - 已加载");
|
||
}, 1); |