/*
文件名:史诗药剂.nut
路径:MyProject/史诗药剂.nut
创建日期:2025-03-28	10:21
文件用途:史诗药剂
*/

//➢SS药剂的ID
EpicPotionID <- 2600006;
//➢默认的药剂增加倍率
EpicPotionOdds <- 0.1;
//➢指定玩家增加深渊爆率
EpicPotionlist <- {};
//角色ID：增加个人深渊爆率
EpicPotionlist[1] <- 1;


Cb_GetItemRarity_Enter_Func["史诗药剂_逻辑"] <- function(args) {
    local Addr = NativePointer(args[0]);
    local VectorSize = (Addr.add(4).readU32() - Addr.readU32()) / 4;
    // 遍历队伍成员，找到使用了史诗药剂的玩家
    local userWithPotion = null;
    for (local i = 0; i< VectorSize; i++) {
        local elementAddr = NativePointer(Addr.readPointer()).add(i * 4);
        local user = elementAddr.readPointer();
        if (user && Sq_CallFunc(S_Ptr("0x865E994"), "int", ["pointer", "int", ], user, EpicPotionID) ) {
            userWithPotion = User(user);
            break;
        }
    }
    if (userWithPotion && Haker.NextReturnAddress == "0x853583a") {
        local partyobj = userWithPotion.GetParty();
        // 检查是否单人
        if (Sq_CallFunc(S_Ptr("0x0859A16A"), "int", ["pointer"], partyobj.C_Object) == 1) {
            local MaxRoll = NativePointer(args[1]).add(16).readU32();
            local odds = EpicPotionOdds; // 默认药剂的增加几率
            // 检查是否VIP玩家
            local charac_no = userWithPotion.GetCID();
            if (EpicPotionlist.rawin(charac_no)) {
                odds = EpicPotionlist[charac_no];
            }
            // 计算新的roll值
            args[2] = MathClass.getMin(args[2] + args[2] * odds, MaxRoll);
        }
    }
    return args;
}



Gm_InputFunc_Handle["okok"] <- function(SUser, cmd) {

    SUser.SendNotiPacketMessage("出纳上asdasdasda到几点方柏霓撒娇扩大年级卡萨", 7);
}