添加示例项目

This commit is contained in:
2026-04-16 16:27:53 +08:00
parent 69a2141804
commit 721fb5a992
192 changed files with 10148 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
{
"ProjectName": "副本播报",
"ProjectDescribe": "通关及未通关时播报耗时时长",
"ProjectAuthor": "南瓜",
"ProjectVersion": 1.3,
"ProjectConfig": "副本播报配置_Nangua.json",
"ProjectFiles": [
"副本播报.nut"
],
"ProjectRunFunc": "_Dps_send_dungeon_msg_Main_"
}

View File

@@ -0,0 +1,227 @@
dungeon_cleared <- {};
dungeon_cache <- {};
function _Dps_send_dungeon_msg_Main_() {
//进入副本加载完毕时
Cb_Party_OnStartMapFinishLoading_Enter_Func.EnterStartMapByNangua <- function(args) {
local Cofig = GlobalConfig.Get("副本播报配置_Nangua.json");
local PartyObj = Party(args[0]);
if(!PartyObj || !Cofig["副本播报开关(true开启,false关闭)"])
return
for (local i = 0; i < 4; ++i) {
local SUser = PartyObj.GetUser(i);
if (SUser) {
if (Cofig["指定角色CID不播报"].find(SUser.GetCID()) != null && _clear_dgn_Bynangua.CParty_get_member_count(PartyObj.C_Object) < 2) {
return;
}
if(SUser.GetCID() in dungeon_cache){
dungeon_cache.rawdelete(SUser.GetCID());
}
dungeon_cleared[SUser.GetCID()] <- false; // 进入副本时初始化标志为未通关
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
local DgnID = DgnObj.GetId();
local Dungeon_Name = DgnObj.GetName();
local dungeon_type = NativePointer(Bfobj.C_Object).add(460).readU8(); // 0 为普通副本1 为非常困难深渊2 为困难深渊
local dungeon_diff = Sq_CallFunc(S_Ptr("0x080F981C"), "int", ["pointer"], Bfobj.C_Object); // 获取副本难度
local diff_name = Cofig["副本难度命名"][(dungeon_diff).tostring()]; // 获取副本难度名称
local dgntypeName = _clear_dgn_Bynangua.DungeonType[(dungeon_type).tostring()];
local DgnData = {
"entered": true,
"Dungeon_Name": Dungeon_Name,
"dgntypeName": dgntypeName,
"diff_name": diff_name,
"totalTime": 0,
"HellParty_time_recorded": false,
"last_HellParty_time": 0,
"is_HellParty_room": false
};
//以角色ID为键记录副本信息
dungeon_cache[SUser.GetCID()] <- DgnData;
}
}
}
//清理房间完毕时
Cb_Battle_Field_onClearMap_Leave_Func.onClearMapByNangua <- function(args) {
local Cofig = GlobalConfig.Get("副本播报配置_Nangua.json");
local retval = args.pop();
local CBattle_Field = args[0];
local PartyObj = Party(NativePointer(CBattle_Field).add(-2852).C_Object);
if(!PartyObj)
return
local DgnId = NativePointer(args[0]).add(404).readInt();
if (!Cofig["副本播报开关(true开启,false关闭)"]) {
return;
}
if (retval == DgnId) {
for (local i = 0; i < 4; ++i) {
local SUser = PartyObj.GetUser(i);
if (SUser) {
if (dungeon_cache.rawin(SUser.GetCID()) && dungeon_cache[SUser.GetCID()].rawin("entered")) {
local time = Sq_CallFunc(S_Ptr("0x085B6768"), "int", ["pointer"], PartyObj.C_Object);
if (!dungeon_cache[SUser.GetCID()]["is_HellParty_room"]) {
dungeon_cache[SUser.GetCID()]["totalTime"] += time;
} else {
dungeon_cache[SUser.GetCID()]["is_HellParty_room"] = false;
}
}
}
}
}
}
//放弃副本或未通关副本时
Cb_Party_giveup_game_Enter_Func.giveupByNangua <- function(args) {
local Cofig = GlobalConfig.Get("副本播报配置_Nangua.json");
local PartyObj = Party(args[0]);
local killcount = Sq_CallFunc(S_Ptr("0x085BF456"), "int", ["pointer"], NativePointer(args[0]).add(812).C_Object);
if (!PartyObj) return;
if (!Cofig["副本播报开关(true开启,false关闭)"]) return;
local SUser = User(args[1]);
local Party_Master = PartyObj.GetMaster();
local MasterName = Party_Master.GetCharacName();
local formattedTime = "";
local DgnId = NativePointer(args[0]).add(814 * 4).readInt();
local name = SUser.GetCharacName();
// 如果副本ID不在允许播报的数组内则跳出
if (Cofig["不需要播报的副本ID(实例中的ID为怪物攻城的副本ID尽量不要删)"].find(DgnId) != null) {
return;
}
if (SUser.GetCID() in dungeon_cache) {
local dungeonInfo = dungeon_cache[SUser.GetCID()];
local dgnTypeName = dungeonInfo["dgntypeName"];
local dungeonName = dungeonInfo["Dungeon_Name"];
local diffName = dungeonInfo["diff_name"];
local totalTime = 0;
if (dungeon_cache.rawin(SUser.GetCID()) && dungeon_cache[SUser.GetCID()].rawin("totalTime")) {
totalTime = dungeon_cache[SUser.GetCID()]["totalTime"];
formattedTime = _clear_dgn_Bynangua.formatMilliseconds(totalTime);
}
if (dungeon_cleared.rawin(SUser.GetCID()) && dungeon_cleared[SUser.GetCID()] == true) {
dungeon_cache.rawdelete(SUser.GetCID());
dungeon_cleared[SUser.GetCID()] <- false;
} else {
// 发送未通关信息
if (totalTime == 0) {
World.SendNotiPacketMessage(format(Cofig["未通过一个小地图播报信息"], name, dgnTypeName, dungeonName, diffName, killcount), Cofig["发送信息位置"]);
} else if (MasterName == SUser.GetCharacName()) {
World.SendNotiPacketMessage(format(Cofig["放弃副本"], name, dgnTypeName, dungeonName, diffName, formattedTime, killcount), Cofig["发送信息位置"]);
} else {
World.SendNotiPacketMessage(format(Cofig["在队伍中提前退出副本"], name, MasterName, dgnTypeName, dungeonName, diffName, formattedTime, killcount), Cofig["发送信息位置"])
}
dungeon_cache.rawdelete(SUser.GetCID());
}
}
}
Cb_Field_KillHellPartyGroupMonsterCnt_Leave_Func.KillHellPartyGroupMonsterCntByNangua <- function(args){
local Cofig = GlobalConfig.Get("副本播报配置_Nangua.json");
local CBattle_Field = args[0];
local PartyObj = Party(NativePointer(CBattle_Field).add(-2852).C_Object);
if(!PartyObj)
return
if (!Cofig["副本播报开关(true开启,false关闭)"]) {
return;
}
local time = Sq_CallFunc(S_Ptr("0x085B6768"), "int", ["pointer"], PartyObj.C_Object);
local CBattle_Field_IsKilledAllHellGruoups = Sq_CallFunc(S_Ptr("0x085BF250"), "int", ["pointer"], CBattle_Field);
for (local i = 0; i < 4; ++i) {
local SUser = PartyObj.GetUser(i);
if (SUser) {
if (dungeon_cache.rawin(SUser.GetCID()) && dungeon_cache[SUser.GetCID()].rawin("entered")) {
dungeon_cache[SUser.GetCID()]["is_HellParty_room"] = true;
if (CBattle_Field_IsKilledAllHellGruoups == 1) {
dungeon_cache[SUser.GetCID()]["HellParty_time_recorded"] <- true;
dungeon_cache[SUser.GetCID()]["last_HellParty_time"] = time;
dungeon_cache[SUser.GetCID()]["totalTime"] += time;
}
}
}
}
}
//通关副本时
Cb_CParty_SetBestClearTime_Enter_Func.ClearTimeByNangua <- function (args) {
local Cofig = GlobalConfig.Get("副本播报配置_Nangua.json");
local PartyObj = Party(args[0]);
local killcount = Sq_CallFunc(S_Ptr("0x085BF456"), "int", ["pointer"], NativePointer(args[0]).add(812).C_Object);
if(!PartyObj || !Cofig["副本播报开关(true开启,false关闭)"])
return
local dungeon_diff = args[2];
local clearTime = args[3];
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
local diff_name = Cofig["副本难度命名"][(dungeon_diff).tostring()];
if (DgnObj) {
local Dungeon_Name = DgnObj.GetName();
local MemberNames = [];
for (local i = 0; i < 4; ++i) {
local SUser = PartyObj.GetUser(i);
if (SUser) {
if (Cofig["指定角色CID不播报"].find(SUser.GetCID()) != null && _clear_dgn_Bynangua.CParty_get_member_count(PartyObj.C_Object) < 2) {
return;
}
local name = SUser.GetCharacName();
MemberNames.append(name);
dungeon_cleared[SUser.GetCID()] <- true;
}
}
local joinedNames = _clear_dgn_Bynangua.join(MemberNames, ", ");
local time = _clear_dgn_Bynangua.formatMilliseconds(clearTime);
World.SendNotiPacketMessage(format(Cofig["通关播报信息"], joinedNames, Dungeon_Name, diff_name, time, killcount), Cofig["发送信息位置"]);
for (local i = 0; i < 4; ++i) {
local TUser = PartyObj.GetUser(i);
if (TUser) {
local CID = TUser.GetCID();
if (CID) {
dungeon_cache.rawdelete(CID);
}
}
}
}
}
}
class _clear_dgn_Bynangua {
DungeonType = {
"0": "",
"1": "非常困难级深渊-",
"2": "困难级深渊-",
};
function join(array, delimiter) {
local result = "";
for (local i = 0; i < array.len(); ++i) {
if (i > 0) {
result += delimiter;
}
result += array[i];
}
return result;
}
function formatMilliseconds(ms) {
local str = "";
local minutes = ms / 60000;
local seconds = (ms % 60000) / 1000;
local milliseconds = (ms % 1000) / 10;
if (minutes > 0) {
str = minutes + "分" +
(seconds < 10 ? "0" : "") + seconds + "秒" +
(milliseconds < 10 ? "0" : "") + milliseconds;
} else {
str = seconds + "秒" +
(milliseconds < 10 ? "0" : "") + milliseconds;
}
return str;
}
function CParty_get_member_count(C_Object) {
return Sq_CallFunc(S_Ptr("0x0859A16A"), "int", ["pointer"], C_Object);
}
}

View File

@@ -0,0 +1,18 @@
{
"副本播报开关(true开启,false关闭)":true,
"不需要播报的副本ID(实例中的ID为怪物攻城的副本ID尽量不要删)":[20002, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20020, 20021, 20022, 20023, 20024],
"指定角色CID不播报":[1111111, 2222222],
"提示": "角色ID可以查看数据库中 taiwan_cain → charac_info → charac_no代表角色ID",
"通关播报信息":"玩家[%s]通关[%s - %s]用时:[%s],击杀怪物数量<%d>",
"未通过一个小地图播报信息":"玩家[%s]在[%s%s-%s]中连一个地图都没通过,击杀怪物数量<%d>",
"放弃副本":"很遗憾,玩家[%s]在[%s%s-%s]中被打的落荒而逃,用时: %s,击杀怪物数量<%d>",
"在队伍中提前退出副本":"玩家[%s]在<%s>的队伍中,提前退出了[%s%s-%s],用时: %s,击杀怪物数量<%d>",
"发送信息位置":14,
"副本难度命名" : {
"0": "普通级",
"1": "冒险级",
"2": "勇士级",
"3": "王者级",
"4": "地狱级"
}
}