//建表 frida.robot_message
api_MySQL_exec(mysql_frida, `
CREATE TABLE frida.robot_message (
id int(20) NOT NULL AUTO_INCREMENT,
\`type\` int(5) NULL,
chara_no int(20) NULL,
message varchar(600) NULL,
create_time datetime NULL,
send_flag int(5) DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
`);//机器人组合消息传输到robot_message表
function sendRobot(type,user,msg){
log(msg);
if(type == 1){
//获取用户
var charNo = CUserCharacInfo_getCurCharacNo(user);
api_MySQL_exec(mysql_frida, "insert into frida.robot_message (type,chara_no,message,send_flag) values (" + type + "," + charNo + ",'" + msg + "',0);");
}else{
api_MySQL_exec(mysql_frida, "insert into frida.robot_message (type,message,send_flag) values (" + type + ",'" + msg + "',0);");
}
}在第11行位置 新增了var msg = ""; //意思就是 增加了一个msg的变量 并且将其初始化为空的
在第17行位置 新增了msg = msg + msgstr; //意思就是消息内容 = 消息内容 + msgstr
在最后一行 新增了return msg; //意思就是结束执行 将结果返回到msg中
function api_SendHyperLinkChatMsg_emoji(user, strarr, msgtype, type, Symbol) {
const bufferSize = 255;
const strptr = Memory.alloc(bufferSize);
let startlen = 0;
let cnt = 0;
// 准备表情符号数据
const emojiBytes = Symbol >= 1 ? [0xc2, 0x80, 0x20, 0x1e, 0x20, Symbol, 0x1f] : [0xc2, 0x80, 0x20];
strptr.add(startlen).writeByteArray(emojiBytes);
startlen += emojiBytes.length;
// 处理消息字符串数组
var msg = ""; //意思就是 增加了一个msg的变量 并且将其初始化为空的
for (const item of strarr) {
const [strtype, msgContent, flags] = item;
strptr.add(startlen).writeByteArray([0xc2, 0x80]);
startlen += 2; // 更新起始长度
const msgstr = (strtype === 'str') ? msgContent : '[' + api_CItem_getItemName(msgContent) + ']';
msg = msg + msgstr; //意思就是消息内容 = 消息内容 + msgstr
const str_ptr = Memory.allocUtf8String(msgstr);
const str_len = strlen(str_ptr);
strptr.add(startlen).writeByteArray(str_ptr.readByteArray(str_len));
startlen += str_len;
// 检查是否需要添加额外的字节
if (flags[3] === 255) {
strptr.add(startlen).writeByteArray([0xc2, 0x80]);
startlen += 2;
cnt++;
}
}
// 结束字符串并准备数据包
strptr.add(startlen).writeByteArray([0xc2, 0x80]);
startlen += 2;
const packet_guard = api_PacketGuard_PacketGuard();
InterfacePacketBuf_put_header(packet_guard, 0, 370);
InterfacePacketBuf_put_byte(packet_guard, msgtype);
InterfacePacketBuf_put_short(packet_guard, 0);
InterfacePacketBuf_put_byte(packet_guard, 0);
InterfacePacketBuf_put_int(packet_guard, startlen);
InterfacePacketBuf_put_str(packet_guard, strptr, startlen);
InterfacePacketBuf_put_byte(packet_guard, cnt);
// 处理附加信息
for (const item of strarr) {
const [_, msgtype, flags] = item;
if (flags[3] === 255) {
const RbgInfoptr = Memory.alloc(104);
RbgInfoptr.writeByteArray(flags);
// 处理消息类型
if (typeof msgtype === 'number') {
RbgInfoptr.add(0x4).writeU32(msgtype);
const Citem = CDataManager_find_item(G_CDataManager(), msgtype);
if (!CItem_is_stackable(Citem)) {
RbgInfoptr.add(0x8).writeU32(get_rand_int(0));
RbgInfoptr.add(0xe).writeU16(CEquipItem_get_endurance(Citem));
}
}
InterfacePacketBuf_put_binary(packet_guard, RbgInfoptr, 104);
}
}
// 完成数据包
InterfacePacketBuf_finalize(packet_guard, 1);
// 根据类型发送数据包
if (type === 1) {
CUser_SendPacket(user, 1, packet_guard);
}
else {
GameWorld_send_all_with_state(G_gameWorld(), packet_guard, 3); // 只给状态 >= 3 的玩家发送公告
}
// 清理数据包
Destroy_PacketGuard_PacketGuard(packet_guard);
return msg; //意思就是结束执行 将结果返回到msg中
}function api_CUser_Rarity_Item(user, args, item_id, item_nu) {
var itemData = CDataManager_find_item(G_CDataManager(), item_id);
var needLevel = CItem_getUsableLevel(itemData); //等级
var Rarity = CItem_getRarity(itemData); // 稀有度
var msg = "";
if (Rarity == 0) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [230, 200, 156,255]],
['item', item_id, [255, 255, 255, 255]],
['str', '' + item_nu + '个', [230, 200, 156,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
if (Rarity == 1) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [255, 255, 0,255]],
['item', item_id, [255, 255, 0, 255]],
['str', '' + item_nu + '个', [255, 255, 0,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
if (Rarity == 2) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [255, 255, 0,255]],
['item', item_id, [255, 255, 0, 255]],
['str', '' + item_nu + '个', [255, 255, 0,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
if (Rarity == 3) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [255, 255, 0,255]],
['item', item_id, [255, 255, 0, 255]],
['str', '' + item_nu + '个', [255, 255, 0,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
if (Rarity == 4) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [255, 255, 0,255]],
['item', item_id, [255, 255, 0, 255]],
['str', '' + item_nu + '个', [255, 255, 0,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
if (Rarity == 5) {
msg = api_SendHyperLinkChatMsg_emoji(user,
[
['str', args, [255, 255, 0,255]],
['item', item_id, [255, 255, 0, 255]],
['str', '' + item_nu + '个', [255, 255, 0,255]],
], 14, 0, 0);
api_CUser_AddItem(user, item_id, item_nu)
}
return msg;
}function Prompt_end_of_dungeon(user) {
var charac_no = CUserCharacInfo_getCurCharacNo(user); // 获取当前角色编号
var hasAcquiredItems = globalData.acquiredItems[charac_no] && Object.keys(globalData.acquiredItems[charac_no]).length > 0;
var totalEpicCount = 0;
if (globalData.epicItems[charac_no]) {
for (var epicItemName in globalData.epicItems[charac_no]) {
if (globalData.epicItems[charac_no].hasOwnProperty(epicItemName)) {
totalEpicCount += globalData.epicItems[charac_no][epicItemName];
}
}
}
var hasEpicItems = totalEpicCount >= 1;
var msg = "";
if (hasAcquiredItems || hasEpicItems) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '玩家 : ', [255, 255, 0, 255]],
['str', '[' + api_CUserCharacInfo_getCurCharacName(user) + ']', [255, 0, 255, 255]],
['str', ' 在 ', [255, 255, 0, 255]],
['str', '[' + api_CDungeon_getDungeonName(DGN_ID[charac_no]) + ']', [255, 0, 128, 255]],
], 14, 0, 0);
msg += "\n";
if (hasAcquiredItems) {
var firstItem = true;
for (var item_id in globalData.acquiredItems[charac_no]) {
if (globalData.acquiredItems[charac_no].hasOwnProperty(item_id)) {
if (firstItem) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '爆出 : ', [255, 255, 0, 255]],
['item', parseInt(item_id), [255, 170, 0, 255]],
['str', ' x' + globalData.acquiredItems[charac_no][item_id] + '', [255, 255, 0, 255]]
], 14, 0, 0);
firstItem = false;
msg += "\n";
}
else {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', ' - ', [255, 255, 0, 255]],
['item', parseInt(item_id), [255, 170, 0, 255]],
['str', ' x' + globalData.acquiredItems[charac_no][item_id] + '', [255, 255, 0, 255]]
], 14, 0, 0);
msg += "\n";
}
}
}
}
if (hasEpicItems) {
//史诗大比拼
writeEpicNum(user,totalEpicCount);
if (totalEpicCount == 2) //SS数量
{
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 0, 255]],
['str', '点卷', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 1);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 3) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点卷', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 2);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 4) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点券', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 3);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 5) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点券', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 4);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 6) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点券', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 5);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 7) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点券', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 6);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
if (totalEpicCount == 8) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点券', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))//点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 7);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}
}
}
} if (totalEpicCount == 3) {
msg += api_SendHyperLinkChatMsg_emoji(user,
[
['str', '奖励', [230, 200, 156,255]],
['str', '' + (totalEpicCount * 50) + '', [255, 255, 255, 255]],
['str', '点卷', [230, 200, 156,255]]
], 14, 0, 0);
msg += "\n";
api_recharge_cash_cera(user, (totalEpicCount * 50))// 点卷数量
//奖励道具
msg += api_CUser_Rarity_Item(user, '奖励', 2023889182, 2);
msg += "\n";
totalEpicCount = 0;
//发送到机器人
sendRobot(0,null,msg);
}