⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sell_books2.c

📁 百宝箱3.27传奇3GQ外挂.支持私服.
💻 C
字号:
// Written by BBX workgroup
// Release: 2004/6/2

// 功能:自动买书卖书
//
// 设置说明:
// 首先指明购买销售书商所在的位置
// 然后指明需要购买的书籍
// 然后指明鉴定者所在的位置
//
// 注1:这个例子比较简单,没有根据物品的耐久购买,如果有需要,
// 可以自行修改。修改时注意,只刷新第一面的书籍是不够的。
//
// 注2:因为鉴定的爆率已经调整过,刷某些书时会亏钱,该例子主
// 要供大家参考使用,使用时务必谨慎小心。

// 书商的名字,对话坐标
string b_npc_name = "店员";
string b_npc_city = "比奇县";
int    b_npc_x = 463, b_npc_y = 427;

// 购买的书籍信息
array  b_books = ({ "大火球", "雷电术",   "击风",   "冰月震天",
                    "地狱火", "疾光电影", "风震天", "冰沙掌" });

// 鉴定者的名字,对话坐标
string i_npc_name = "华龙断珠";
int    i_npc_city = "比奇县";
int    i_npc_x = 463, i_npc_y = 427; // 对话华龙断珠位置
//int    i_npc_x = 457, i_npc_y = 431; // 同时对话华龙断珠、比奇道长位置(如果想销售道士书籍有必要用这个坐标)

mixed get_menu_action(string msg)
{
    int i;

    /* Select menu by string (link or action) */
    for (i = 1; i <= current_menu["count"]; i++)
    {
        if (! current_menu[i]["action"])
            /* Non-link */
            continue;

        if (strsrch(current_menu[i]["link"], msg) >= 0 ||
            strsrch(current_menu[i]["action"], msg) >= 0)
        {
            return current_menu[i]["action"];
        }
    }

    return 0;
}

void start()
{
    mapping mc;
    mapping ob;
    string  book_name;
    string  action1, action2, action3;
    int     total;
    int     count;
    int     i;

    // 首先设定所有的秘籍可卖,不优先,以免鉴定后无法出售
    for (i = 0; i < sizeof(b_books); i++)
    {
        all_item_list[b_books[i] + "(秘籍)"]["storage"] = 0;
        all_item_list[b_books[i] + "(秘籍)"]["manage"]  = 1;
    }

    printf("开始自动鉴定书籍。\n");
    for (;;)
    {
        book_name = b_books[0];
        total = 0;

        mc = me()["carry"];
        for (i = sizeof(mc) - 1; i >= 0; i--)
            if (mc[i]["name"] == book_name)
                total++;

        if (total > 0)
            // 现在有还没有鉴定的书籍,直接前往鉴定
            goto start_identify;

        // 跑到书商处
        printf("前往销售、购买书籍。\n");
        goto_city_ex(b_npc_city, b_npc_x, b_npc_y, 10);
    
        // 快速销售现有书籍
        sell_item(({ ITEM_BOOK }), b_npc_name, 0, 1);
    
        // 一次最多购买 30 本书籍
        total = 0;
        while (total < 30)
        {
            if (! sizeof(b_books))
            {
                printf("所有书籍销售一空,停止自动鉴定。\n");
                return;
            }
    
            // 选定书籍
            book_name = b_books[0];
    
            // 购买书籍
            talk_to(b_npc_name);
            talk_to(b_npc_name, "@buy");
            show_inv(book_name, 0);
            count = current_npc_inv_page["count"];
            if (! count)
            {
                // 这种书已经销售光了
                printf("书籍 %s 已经销售一空了。\n", book_name);
        
                // 取消购买这种书
                b_books -= ({ book_name });
    
                if (count_item_amount(book_name) > 0)
                    // 已经购买了一些,前去鉴定
                    break;
    
                // 还没有购买到任何书,继续购买下一种
            }

            // 购买书籍
            while (count-- > 0)
            {
                buy(book_name, 1, b_npc_name);
                total++;
            }
        }

start_identify:;
        // 购买完毕,前往鉴定
        printf("前往鉴定书籍。\n");
        goto_city_ex(i_npc_city, i_npc_x, i_npc_y, 10);

        // Wait for NPC appeared
        while (! select_object(i_npc_name))
            sleep(0.25);

        if (total-- > 0)
        {
            talk_to(i_npc_name);

            action1 = get_menu_action("查看");
            talk_to(i_npc_name, "查看");

            action2 = get_menu_action(book_name);
            talk_to(i_npc_name, book_name);

            action3 = get_menu_action("学武功");
            talk_to(i_npc_name, "学武功");
        }

        ob = select_object(i_npc_name);
        while (total-- > 0)
        {
            xsend(make32(ob["id"]), 0x3F2, 0, 0, 0);
            xsend(make32(ob["id"]), 0x3F3, 0, 0, 0, action1); // 察看
            xsend(make32(ob["id"]), 0x3F3, 0, 0, 0, action2); // 书名
            xsend(make32(ob["id"]), 0x3F3, 0, 0, 0, action3); // 学武功
        }

        // 走动两步,等待应答完毕
        sleep(2);
        walk(0, 1);
        walk(180, 1);

        // 鉴定完毕,继续销售、购买
    }
}

// 启动时自动开始买书鉴定
create_thread(QUEST_THREAD, "start");

// 卸载时停止
private void destruct()
{
    printf("停止。\n");
    delete_thread(QUEST_THREAD);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -