fixed quest id

This commit is contained in:
sin365 2023-07-11 14:28:02 +08:00
parent 56262609e1
commit 36be61bfc5
16 changed files with 490 additions and 32 deletions

Binary file not shown.

View File

@ -15,6 +15,464 @@ namespace MHFQuestToMH2Dos
/// </summary> /// </summary>
static List<int> MapAreaCount = new List<int> { 0, 7, 13, 12, 11, 10, 11, 2, 2, 2, 2, 10, 4, 9, 0, 11, 13, 12, 11, 10, 11, 10, 4, 7, 2, 2 }; static List<int> MapAreaCount = new List<int> { 0, 7, 13, 12, 11, 10, 11, 2, 2, 2, 2, 10, 4, 9, 0, 11, 13, 12, 11, 10, 11, 10, 4, 7, 2, 2 };
public static List<int> UnUseQuestID = new List<int>
{60054,
60100,
60117,
60118,
60119,
60120,
60121,
60144,
60145,
60146,
60147,
60148,
60149,
60150,
60151,
60152,
60153,
60154,
60155,
60156,
60157,
60158,
60159,
60160,
60161,
60162,
60163,
60164,
60165,
60166,
60167,
60168,
60169,
60170,
60171,
60172,
60173,
60174,
60175,
60176,
60177,
60178,
60179,
60180,
60181,
60182,
60183,
60184,
60185,
60186,
60187,
60188,
60189,
60190,
60191,
60192,
60193,
60194,
60195,
60196,
60197,
60198,
60199,
60200,
60205,
60206,
60209,
60210,
60224,
60225,
60226,
60227,
60228,
60229,
60250,
60251,
60252,
60253,
60254,
60255,
60256,
60257,
60258,
60259,
60260,
60261,
60262,
60263,
60264,
60265,
60266,
60267,
60268,
60269,
60270,
60271,
60272,
60273,
60274,
60275,
60276,
60277,
60278,
60279,
60280,
60281,
60282,
60283,
60284,
60285,
60286,
60287,
60288,
60289,
60290,
60291,
60292,
60293,
60294,
60295,
60296,
60297,
60298,
60299,
60300,
60329,
60330,
60331,
60332,
60333,
60334,
60335,
60336,
60337,
60338,
60339,
60340,
60341,
60342,
60343,
60344,
60345,
60346,
60347,
60348,
60349,
60350,
60351,
60352,
60353,
60354,
60355,
60356,
60357,
60358,
60359,
60360,
60361,
60362,
60363,
60364,
60365,
60366,
60367,
60368,
60369,
60370,
60371,
60372,
60373,
60374,
60375,
60376,
60377,
60378,
60379,
60380,
60381,
60382,
60383,
60384,
60385,
60386,
60387,
60388,
60389,
60390,
60391,
60392,
60393,
60394,
60395,
60396,
60397,
60398,
60399,
60400,
60450,
60451,
60452,
60453,
60454,
60455,
60456,
60457,
60458,
60459,
60460,
60461,
60462,
60463,
60464,
60465,
60466,
60467,
60468,
60469,
60470,
60471,
60472,
60473,
60474,
60475,
60476,
60477,
60478,
60479,
60480,
60481,
60482,
60483,
60484,
60485,
60486,
60487,
60488,
60489,
60490,
60491,
60492,
60500,
60536,
60537,
60538,
60539,
60600,
60666,
60692,
60693,
60694,
60695,
60696,
60697,
60698,
60699,
60700,
60729,
60730,
60731,
60732,
60733,
60734,
60735,
60736,
60737,
60738,
60739,
60740,
60741,
60742,
60743,
60744,
60745,
60746,
60747,
60748,
60749,
60750,
60751,
60752,
60753,
60754,
60755,
60756,
60757,
60758,
60759,
60760,
60761,
60762,
60763,
60764,
60765,
60766,
60767,
60768,
60769,
60770,
60771,
60772,
60773,
60774,
60775,
60776,
60777,
60778,
60779,
60780,
60781,
60782,
60783,
60784,
60785,
60786,
60787,
60788,
60789,
60790,
60791,
60792,
60793,
60794,
60795,
60796,
60797,
60798,
60799,
60800,
60811,
60813,
60825,
60826,
60827,
60828,
60829,
60830,
60831,
60832,
60833,
60834,
60835,
60836,
60837,
60838,
60839,
60840,
60841,
60842,
60843,
60844,
60845,
60846,
60847,
60848,
60849,
60850,
60851,
60852,
60853,
60854,
60855,
60856,
60857,
60858,
60859,
60860,
60861,
60862,
60863,
60864,
60865,
60866,
60867,
60868,
60869,
60870,
60871,
60872,
60873,
60874,
60875,
60876,
60877,
60878,
60879,
60880,
60881,
60882,
60883,
60884,
60885,
60886,
60887,
60888,
60889,
60890,
60891,
60892,
60893,
60894,
60895,
60896,
60897,
60898,
60899,
60900,
60946,
60951,
60952,
60953,
60954,
60955,
60956,
60957,
60958,
60959,
60960,
60961,
60962,
60963,
60964,
60965,
60966,
60967,
60968,
60969,
60970,
60971,
60972,
60973,
60974,
60975,
60976,
60977,
60978,
60979,
60980,
60981,
60982,
60983,
60984,
60985,
60986,
60987,
60988,
60989,
60990,
60991,
60992,
60993,
60994,
60995,
60996,
60997,
60998,
60999,};
public static int GetMapAreaCount(int MapId) public static int GetMapAreaCount(int MapId)
{ {
return MapAreaCount[MapId]; return MapAreaCount[MapId];

View File

@ -17,7 +17,8 @@ namespace MHFQuestToMH2Dos
public const int cMax_GuTi = 0x16; public const int cMax_GuTi = 0x16;
public const int cMax_QuestStar = 8; public const int cMax_QuestStar = 8;
public const int cModify_QuestID = 0xEA74; //public const int cModify_QuestID = 0xEA74;
public static int cModify_QuestID = 0xEA60;
/// <summary> /// <summary>
/// 道具ID超出最大限制时修改为【不可燃烧的废物】 /// 道具ID超出最大限制时修改为【不可燃烧的废物】
@ -110,8 +111,9 @@ namespace MHFQuestToMH2Dos
/// </summary> /// </summary>
public const int cQuestInfo_QuestID_Lenght = 2; public const int cQuestInfo_QuestID_Lenght = 2;
public static bool ModifyQuset(byte[] src, out byte[] target) public static bool ModifyQuset(byte[] src, out byte[] target, out int targetQuestID)
{ {
targetQuestID = 0;
target = HexHelper.CopyByteArr(src);//加载数据 target = HexHelper.CopyByteArr(src);//加载数据
if (ModifyFileOffset(target, out byte[] out_ModifyFileOffset)) if (ModifyFileOffset(target, out byte[] out_ModifyFileOffset))
@ -122,9 +124,10 @@ namespace MHFQuestToMH2Dos
target = out_ModifyTextOffset; target = out_ModifyTextOffset;
else { return false; } else { return false; }
if (ModifyQuestMap(target, out byte[] out_ModifyQuestMap)) if (ModifyQuestMap(target, out byte[] out_ModifyQuestMap, out int _targetQuestID))
target = out_ModifyQuestMap; target = out_ModifyQuestMap;
else { return false; } else { return false; }
targetQuestID = _targetQuestID;
if (ModifyQuestBOSS(target, out byte[] out_ModifyQuestBOSS)) if (ModifyQuestBOSS(target, out byte[] out_ModifyQuestBOSS))
target = out_ModifyQuestBOSS; target = out_ModifyQuestBOSS;
@ -153,6 +156,22 @@ namespace MHFQuestToMH2Dos
return true; return true;
} }
public static Dictionary<int, int> SrcQuestID2FixID = new Dictionary<int, int>();
public static int UnUseQuestID_Index = 0;
public static int GetNextFixQuestID(int Id)
{
if (!SrcQuestID2FixID.ContainsKey(Id))
{
int idx = ++UnUseQuestID_Index;
if (idx > MHHelper.UnUseQuestID.Count - 1)
{
idx = UnUseQuestID_Index = 0;
}
SrcQuestID2FixID[Id] = MHHelper.UnUseQuestID[idx];
}
return SrcQuestID2FixID[Id];
}
public static bool ModifyFileOffset(byte[] src, out byte[] target) public static bool ModifyFileOffset(byte[] src, out byte[] target)
{ {
try try
@ -387,7 +406,7 @@ namespace MHFQuestToMH2Dos
} }
} }
public static bool ModifyQuestMap(byte[] src, out byte[] target) public static bool ModifyQuestMap(byte[] src, out byte[] target,out int targetQuestID)
{ {
try try
{ {
@ -472,11 +491,14 @@ namespace MHFQuestToMH2Dos
uint _QuestID = HexHelper.bytesToUInt(target, cQuestInfo_QuestID_Lenght, _QuestInfoPtr + cQuestInfo_QuestID_Offset); uint _QuestID = HexHelper.bytesToUInt(target, cQuestInfo_QuestID_Lenght, _QuestInfoPtr + cQuestInfo_QuestID_Offset);
targetQuestID = (int)_QuestID;
Log.HexTips(_QuestInfoPtr + cQuestInfo_QuestID_Offset, "任务编号【{0}】", _QuestID); Log.HexTips(_QuestInfoPtr + cQuestInfo_QuestID_Offset, "任务编号【{0}】", _QuestID);
if (_QuestID < 60000) if (_QuestID < 60000)
{ {
HexHelper.ModifyIntHexToBytes(target, cModify_QuestID, _QuestInfoPtr + cQuestInfo_QuestID_Offset, cQuestInfo_QuestID_Lenght); int targetID = GetNextFixQuestID((int)_QuestID);
Log.HexTips(_QuestInfoPtr + cQuestInfo_QuestID_Offset, "任务编号【{0}】小于60000修正为【{1}】,使其可下载", _QuestID, cModify_QuestID); targetQuestID = targetID;
HexHelper.ModifyIntHexToBytes(target, targetID, _QuestInfoPtr + cQuestInfo_QuestID_Offset, cQuestInfo_QuestID_Lenght);
Log.HexTips(_QuestInfoPtr + cQuestInfo_QuestID_Offset, "任务编号【{0}】小于60000修正为【{1}】,使其可下载", _QuestID, targetID);
} }
//从前4字节取出指针 定位任务信息位置 //从前4字节取出指针 定位任务信息位置
@ -508,6 +530,7 @@ namespace MHFQuestToMH2Dos
{ {
Console.WriteLine(ex); Console.WriteLine(ex);
target = null; target = null;
targetQuestID = 0;
return false; return false;
} }
} }

View File

@ -10,7 +10,7 @@ namespace MHFQuestToMH2Dos
const string InDir = "Input"; const string InDir = "Input";
const string OutDir = "Out"; const string OutDir = "Out";
const string PosFile2DosDir = "PosFile2Dos"; const string PosFile2DosDir = "PosFile2Dos";
const string Ver = "0.3.1"; const string Ver = "0.3.2";
static void Main(string[] args) static void Main(string[] args)
{ {
@ -110,9 +110,9 @@ namespace MHFQuestToMH2Dos
Console.WriteLine($">>>>>>>>>>>>>>开始处理 第{index}个文件 {FileName}<<<<<<<<<<<<<<<<<<<"); Console.WriteLine($">>>>>>>>>>>>>>开始处理 第{index}个文件 {FileName}<<<<<<<<<<<<<<<<<<<");
FileHelper.LoadFile(files[i], out byte[] data); FileHelper.LoadFile(files[i], out byte[] data);
if (ModifyQuest.ModifyQuset(data, out byte[] targetdata)) if (ModifyQuest.ModifyQuset(data, out byte[] targetdata, out int targetQuestID))
{ {
string newfileName = FileName + "_fix"; string newfileName = FileName + "_fix_toid_"+ targetQuestID;
string outstring = loc + OutDir + "\\" + newfileName; string outstring = loc + OutDir + "\\" + newfileName;
//LoadToSaveTemplate.GetModeType(targetdata, FileName); //LoadToSaveTemplate.GetModeType(targetdata, FileName);

View File

@ -1,23 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MHFQuestToMH2Dos")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("MHFQuestToMH2Dos")]
[assembly: System.Reflection.AssemblyTitleAttribute("MHFQuestToMH2Dos")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。