124 lines
5.1 KiB
Plaintext
124 lines
5.1 KiB
Plaintext
class _evilDgnBynangua {
|
|
function get_required_gradeBynangua(dgn_id, dgn_diff) {
|
|
local Config = GlobalConfig.Get("抗魔值进入副本配置_Nangua.json");
|
|
if (Config["抗魔值进入副本"]["副本配置"].rawin(dgn_id.tostring())) {
|
|
local requirements = Config["抗魔值进入副本"]["副本配置"][dgn_id.tostring()];
|
|
for (local i = 0; i < requirements.len(); i += 2) {
|
|
if (requirements[i] == dgn_diff) {
|
|
return requirements[i + 1];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function api_CDungeon_getDungeonName(dungeon_id) {
|
|
local G_CDataManager = Sq_CallFunc(S_Ptr("0x80CC19B"), "pointer", []);
|
|
local cdungeon = Sq_CallFunc(S_Ptr("0x835F9F8"), "pointer", ["pointer", "int"], G_CDataManager, dungeon_id);
|
|
if (!cdungeon) {
|
|
return;
|
|
}
|
|
if (cdungeon) {
|
|
local dgnobj = Sq_CallFunc(S_Ptr("0x81455A6"), "pointer", ["pointer"], cdungeon);
|
|
local name = NativePointer(dgnobj).readUtf8String();
|
|
return name;
|
|
}
|
|
return null;
|
|
}
|
|
function join(array, delimiter) {
|
|
local result = "";
|
|
for (local i = 0; i < array.len(); ++i) {
|
|
if (i > 0) {
|
|
result += delimiter;
|
|
}
|
|
result += array[i];
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
getroottable()._Nangua_EquipmentData_List_ <- {};
|
|
getroottable()._Nangua_EquipmentData_Anti_ <- {};
|
|
function _Nangua_GetEquipmentData_Anti_(Equipment_id) {
|
|
try {
|
|
//如果数据存在 返回数据
|
|
if (getroottable()._Nangua_EquipmentData_Anti_.rawin(Equipment_id))return getroottable()._Nangua_EquipmentData_Anti_[Equipment_id];
|
|
//通过装备ID获取装备路径
|
|
local Path = getroottable()._Nangua_EquipmentData_List_[Equipment_id];
|
|
Path = "equipment/" + Path;
|
|
//读取装备数据
|
|
local Data = ScriptData.GetFileData(Path, function(DataTable, Data) {
|
|
while (!Data.Eof()) {
|
|
local Key = Data.Get();
|
|
if (Key == "[anti evil]") {
|
|
getroottable()._Nangua_EquipmentData_Anti_[Equipment_id] <- Data.Get();
|
|
return getroottable()._Nangua_EquipmentData_Anti_[Equipment_id];
|
|
}
|
|
}
|
|
});
|
|
} catch (exception){
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
function _Dps_anti_evilDgnBynangua_Main_() {
|
|
local Config = GlobalConfig.Get("抗魔值进入副本配置_Nangua.json");
|
|
Script(Config["PVF储存路径_没有更改的话不要改动此配置"]);
|
|
//if (Config["PVF储存路径_没有更改的话不要改动此配置"].len() > 0) Script(Config["PVF储存路径_没有更改的话不要改动此配置"]);
|
|
//else Script();
|
|
|
|
//读取装备列表
|
|
getroottable()._Nangua_EquipmentData_List_ = ScriptData.GetFileData("equipment/equipment.lst", function(DataTable, Data) {
|
|
while (!Data.Eof()) {
|
|
local Key = Data.Get();
|
|
//注册装备列表 路径写入 数据未读取
|
|
DataTable.rawset(Key, Data.Get());
|
|
}
|
|
});
|
|
|
|
Cb_SelectDungeon_Check_Error_Leave_Func.Check_anti_evilByNangua <- function(args) {
|
|
local Config = GlobalConfig.Get("抗魔值进入副本配置_Nangua.json");
|
|
local SUser = User(args[1]);
|
|
local msg_base = args[2];
|
|
local PartyObj = SUser.GetParty();
|
|
local dgn_id = NativePointer(msg_base).add(13).readU16(); // 获取副本ID
|
|
local dgn_diff = NativePointer(msg_base).add(15).readU8(); // 获取副本难度
|
|
local required_grade = _evilDgnBynangua.get_required_gradeBynangua(dgn_id, dgn_diff);
|
|
local diff_name = Config["副本难度命名"][(dgn_diff).tostring()];
|
|
local Dungeon_Name = _evilDgnBynangua.api_CDungeon_getDungeonName(dgn_id);
|
|
|
|
if (PartyObj && Config["抗魔值进入副本"]["抗魔值进入副本开关(true为开启,false为关闭)"]) {
|
|
local not_enough_users = [];
|
|
for (local i = 0; i < 4; ++i) {
|
|
local Tuser = PartyObj.GetUser(i);
|
|
if (Tuser) {
|
|
local total_grade = 0;
|
|
local InvenObj = Tuser.GetInven();
|
|
if (InvenObj) {
|
|
for (local j = 0; j <= 25; j++) {
|
|
local ItemObj = InvenObj.GetSlot(0, j);
|
|
if (!ItemObj.IsEmpty) {
|
|
local item_id = ItemObj.GetIndex();
|
|
print(item_id);
|
|
local Anti = _Nangua_GetEquipmentData_Anti_(item_id);
|
|
total_grade += Anti;
|
|
}
|
|
}
|
|
}
|
|
// 比对抗魔值是否足够
|
|
if (total_grade < required_grade) {
|
|
not_enough_users.push(Tuser.GetCharacName());
|
|
}
|
|
}
|
|
}
|
|
|
|
// 处理未达到抗魔值要求的用户
|
|
if (not_enough_users.len() > 0) {
|
|
local joinedNames = _evilDgnBynangua.join(not_enough_users, ", ");
|
|
SUser.SendNotiBox("队伍中玩家[" + joinedNames + "] 抗魔值低于 " + required_grade + " ,无法进入 [" + Dungeon_Name + " - " + diff_name + "]", 2)
|
|
return 1; // 禁止进入副本
|
|
}
|
|
}
|
|
}
|
|
}
|