From 13cf365ab7f3398e59ea3b464c8ffce4f13273e6 Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Sat, 16 Dec 2023 20:13:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hook.cpp | 110 ++++++++++++++++++++++++++-------- src/il2cpp/il2cpp_symbols.cpp | 8 +++ src/main.cpp | 1 + src/umadb/umadb.cpp | 76 ++++++++++++++++++++++- src/umadb/umadb.hpp | 4 ++ src/umagui/guiLanguage.hpp | 48 +++++++++++++++ src/umagui/guiShowData.cpp | 11 ++-- src/umagui/guiShowData.hpp | 9 +-- src/umagui/umaguiMain.cpp | 44 ++++++++++++-- 9 files changed, 272 insertions(+), 39 deletions(-) diff --git a/src/hook.cpp b/src/hook.cpp index 391ddbe4..6e9750ab 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -2637,7 +2637,6 @@ namespace float(*get_Wiz)(void*); float(*get_DeltaTime)(); bool(*get_IsStartDash)(void*); - int(*GetActivateSkillCount)(void*); int(*get_FinishOrder)(void*); // int(*CalcChallengeMatchPointTotal)(void*); float(*get_MoveDistance)(void*); @@ -2681,8 +2680,8 @@ namespace convertPtrType(&GetHp, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "GetHp", 0)); convertPtrType(&GetMaxHp, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "GetMaxHp", 0)); convertPtrType(&GetHpPer, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "GetHpPer", 0)); - convertPtrType(&get_NearHorseCount, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_NearHorseCount", 0)); - convertPtrType(&get_CongestionTime, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_CongestionTime", 0)); + // convertPtrType(&get_NearHorseCount, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_NearHorseCount", 0)); + // convertPtrType(&get_CongestionTime, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_CongestionTime", 0)); convertPtrType(&get_RawSpeed, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_RawSpeed", 0)); convertPtrType(&get_BaseSpeed, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_BaseSpeed", 0)); convertPtrType(&get_Speed, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_Speed", 0)); @@ -2699,7 +2698,6 @@ namespace convertPtrType(&get_BaseWiz, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_BaseWiz", 0)); convertPtrType(&get_Wiz, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_Wiz", 0)); convertPtrType(&get_IsStartDash, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_IsStartDash", 0)); - convertPtrType(&GetActivateSkillCount, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "GetActivateSkillCount", 0)); convertPtrType(&get_MoveDistance, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "HorseRaceInfo", "get_MoveDistance", 0)); convertPtrType(&get_DeltaTime, il2cpp_resolve_icall("UnityEngine.Time::get_unscaledDeltaTime()")); @@ -2717,6 +2715,7 @@ namespace void* get_RunMotionSpeed_orig; float get_RunMotionSpeed_hook(void* _this) { + // handle: 00007FF9C71B0000 raceStart = true; auto ret = reinterpret_cast(get_RunMotionSpeed_orig)(_this); if (enableRaceInfoTab || (g_race_free_camera && g_race_freecam_follow_umamusume)) { @@ -2726,20 +2725,32 @@ namespace bool isFinished = get_IsOverRun(_this); iter->second.UpdateMotionData(ret, get_RunMotionRate(_this), get_RaceBaseSpeed(_this), get_MinSpeed(_this), get_StartDashSpeedThreshold(_this), isFinished, GetHp(_this), GetMaxHp(_this), GetHpPer(_this), - get_NearHorseCount(_this), get_CongestionTime(_this), get_RawSpeed(_this), + 0, //get_NearHorseCount(_this), + 0, //get_CongestionTime(_this), + + get_RawSpeed(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_baseSpeedAdjusted), get_Speed(_this), - get_RawStamina(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_baseStaminaAdjusted), - get_Stamina(_this), get_RawPow(_this), + get_RawStamina(_this), + il2cpp_symbols::read_field(_this, HorseRaceInfo_baseStaminaAdjusted), + get_Stamina(_this), + get_RawPow(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_basePowAdjusted), - get_Pow(_this), get_RawGuts(_this), + get_Pow(_this), + get_RawGuts(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_baseGutsAdjusted), - get_Guts(_this), get_RawWiz(_this), + get_Guts(_this), + get_RawWiz(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_baseWizAdjusted), - get_Wiz(_this), get_IsStartDash(_this), GetActivateSkillCount(_this), + get_Wiz(_this), + get_IsStartDash(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_lastSpeed), - get_MoveDistance(_this), il2cpp_symbols::read_field(_this, HorseRaceInfo_distance), - get_DeltaTime(), get_LastSpurtStartDistance(_this), get_IsLastSpurt(_this)); + get_MoveDistance(_this), + il2cpp_symbols::read_field(_this, HorseRaceInfo_distance), + get_DeltaTime(), + get_LastSpurtStartDistance(_this), + get_IsLastSpurt(_this) + ); if (isFinished) iter->second.setFinallyRank(get_FinishOrder(_this) + 1); if (g_race_free_camera && g_race_freecam_follow_umamusume) { @@ -2806,7 +2817,7 @@ namespace bool isSkillManaInited = false; void initSkillManager() { - if (isSkillManaInited)return; + if (isSkillManaInited) return; isSkillManaInited = true; skillManager_klass = il2cpp_symbols::get_class("umamusume.dll", "Gallop", "SkillManager"); @@ -2815,16 +2826,52 @@ namespace convertPtrType(&GetSkillLevel, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillBase", "get_Level", 0)); convertPtrType(&GetSkilDetails, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillBase", "get_Details", 0)); convertPtrType(&get_SkillMaster, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillBase", "get_SkillMaster", 0)); - convertPtrType(&getSkill_Abilities, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillDetail", "get_Abilities", 0)); - convertPtrType(&get_SkillEffectName, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillDetail", "get_SkillEffectName", 0)); - convertPtrType(&SkillActivate, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillDetail", "Activate", 0)); - convertPtrType(&get_DefaultCoolDownTime, il2cpp_symbols::get_method_pointer("umamusume.dll", "Gallop", "SkillDetail", "get_DefaultCoolDownTime", 0)); + convertPtrType(&getSkill_Abilities, il2cpp_symbols::get_method_pointer("umamusume.dll", "StandaloneSimulator", "SkillDetail", "get_Abilities", 0)); + convertPtrType(&get_SkillEffectName, il2cpp_symbols::get_method_pointer("umamusume.dll", "StandaloneSimulator", "SkillDetail", "get_SkillEffectName", 0)); + // convertPtrType(&SkillActivate, il2cpp_symbols::get_method_pointer("umamusume.dll", "StandaloneSimulator", "SkillDetail", "Activate", 0)); + // convertPtrType(&get_DefaultCoolDownTime, il2cpp_symbols::get_method_pointer("umamusume.dll", "StandaloneSimulator", "SkillDetail", "get_DefaultCoolDownTime", 0)); + } + + struct MSkillAbility { + int AbilityType; + float AbilityValue; + int targetType; + float CooldownTime; + }; + + std::vector getMSkillAbilitiesByMasterData(int skillId) { + static std::vector abilityEnds = { "1_1", "1_2", "1_3", "2_1", "2_2", "2_3" }; + std::vector ret{}; + + if (auto iter = UmaDatabase::umaSkillInfo.find(skillId); iter != UmaDatabase::umaSkillInfo.end()) { + for (const auto& i : abilityEnds) { + const std::string AbilityTypeName = std::format("ability_type_{}", i); + const std::string AbilityValueName = std::format("float_ability_value_{}", i); + const std::string FloatCooldownTimeName = std::format("float_cooldown_time_{}", i[0]); + const std::string TargetTypeName = std::format("target_type_{}", i); + + const auto AbilityType = iter->second[AbilityTypeName]; + if (AbilityType <= 0) continue; + const auto AbilityValue = iter->second[AbilityValueName]; + const auto FloatCooldownTime = iter->second[FloatCooldownTimeName]; + const auto TargetType = iter->second[TargetTypeName]; + + MSkillAbility currRet{}; + currRet.AbilityType = AbilityType; + currRet.AbilityValue = (float)AbilityValue / 10000.0f; + currRet.targetType = TargetType; + currRet.CooldownTime = (float)FloatCooldownTime / 10000.0f; + // printf("AbilityType: %d, AbilityValue: %f, CooldownTime: %f, TargetType: %d\n", currRet.AbilityType, currRet.AbilityValue, currRet.CooldownTime, TargetType); + ret.push_back(currRet); + } + } + // printf("\n"); + return ret; } void* AddUsedSkillId_orig; void AddUsedSkillId_hook(void* _this, int skillId) { reinterpret_cast(AddUsedSkillId_orig)(_this, skillId); - if (enableRaceInfoTab) { initSkillManager(); // Gallop.IHorseRaceInfo @@ -2855,13 +2902,29 @@ namespace skillData.SetSkillName(utility::conversions::to_utf8string(skillName->start_char)); } + bool updatedCool = false; + const auto mAbilities = getMSkillAbilitiesByMasterData(skillId); + for (const auto& skillAbility : mAbilities) { + const auto abilityType = skillAbility.AbilityType; + const auto effValue = skillAbility.AbilityValue; + if (!updatedCool) { + updatedCool = true; + skillData.updateCoolDownTime(skillAbility.CooldownTime); + } + UmaGUiShowData::SkillAbility mSkillability(abilityType, effValue); + mSkillability.setTargetType(skillAbility.targetType); + skillData.addSkillAbilities(mSkillability); + } + + /* il2cpp_symbols::iterate_list(skilDetails, [&](int32_t index, void* skillDetail) { - SkillActivate(skillDetail); + // SkillActivate(skillDetail); auto abilities = getSkill_Abilities(skillDetail); // List`1 - auto defCooldownTime = get_DefaultCoolDownTime(skillDetail); + // auto defCooldownTime = get_DefaultCoolDownTime(skillDetail); + auto defCooldownTime = 1200.0f; skillData.updateCoolDownTime(defCooldownTime); - + il2cpp_symbols::iterate_list(abilities, [&](int32_t cIndex, void* skillAbility) { int (*get_AbilityType)(void*); float (*get_AbilityValueOnActivate)(void*); @@ -2889,13 +2952,11 @@ namespace // printf("abilityType: 0x%x, effValue: %f\n", abilityType, effValue); skillData.addSkillAbilities(mSkillability); }); - }); - + */ umaUsedSkillList.emplace_back(skillData); } } - } void* AlterUpdate_CameraLayer_orig; @@ -4833,7 +4894,6 @@ namespace ADD_HOOK(WWWRequest_Post, "WWWRequest_Post at %p\n"); } #pragma endregion - // hook UnityEngine.TextGenerator::PopulateWithErrors to modify text ADD_HOOK(populate_with_errors, "UnityEngine.TextGenerator::PopulateWithErrors at %p\n"); diff --git a/src/il2cpp/il2cpp_symbols.cpp b/src/il2cpp/il2cpp_symbols.cpp index 3d1f6163..97b7c4db 100644 --- a/src/il2cpp/il2cpp_symbols.cpp +++ b/src/il2cpp/il2cpp_symbols.cpp @@ -81,8 +81,16 @@ namespace il2cpp_symbols const char* klassName, const char* name, int argsCount) { auto assembly = il2cpp_domain_assembly_open(il2cpp_domain, assemblyName); + if (!assembly) { + printf("assembly: %s not found!\n", assemblyName); + return NULL; + } auto image = il2cpp_assembly_get_image(assembly); auto klass = il2cpp_class_from_name(image, namespaze, klassName); + if (!klass) { + printf("class %s::%s not found!\n", namespaze, klassName); + return NULL; + } auto ret = il2cpp_class_get_method_from_name(klass, name, argsCount); if (ret) { return ret->methodPointer; diff --git a/src/main.cpp b/src/main.cpp index e9af385e..bc8c84aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1828,6 +1828,7 @@ int __stdcall DllMain(HINSTANCE dllModule, DWORD reason, LPVOID) } auto dicts = read_config(); + UmaDatabase::executeQuerySkillData(); if (g_enable_console) create_debug_console(); diff --git a/src/umadb/umadb.cpp b/src/umadb/umadb.cpp index 09b31707..2d08eaa4 100644 --- a/src/umadb/umadb.cpp +++ b/src/umadb/umadb.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace UmaDatabase { @@ -10,7 +11,7 @@ namespace UmaDatabase { void* AssetBundle_Unload = nullptr; void* Object_IsNativeObjectAlive = nullptr; - const auto basePath = std::format("{}/AppData/LocalLow/Cygames/umamusume", getenv("UserProfile")); + const auto basePath = g_enable_custom_PersistentDataPath ? g_custom_PersistentDataPath : std::format("{}/AppData/LocalLow/Cygames/umamusume", getenv("UserProfile")); std::unordered_map umaFileAssetHash{}; // dbPath: bundleName // std::unordered_map> bundleNames{}; // dbName: [bundlePath1, bundlePath2, ...] std::map pathBundle{}; // bundlePath: bundleName @@ -18,6 +19,7 @@ namespace UmaDatabase { std::unordered_map umaDressHeadId{}; std::unordered_map umaDressHasMini{}; } + std::unordered_map> umaSkillInfo{}; void initPtr() { AssetBundle_GetAllAssetNames = reinterpret_cast( @@ -228,7 +230,6 @@ namespace UmaDatabase { int nRow; int nCol; - // rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg); rc = sqlite3_get_table(db, sql, &pResult, &nRow, &nCol, &zErrMsg); if (rc != SQLITE_OK) { printf("SQL error: %s\n", zErrMsg); @@ -274,6 +275,77 @@ namespace UmaDatabase { sqlite3_close(db); } + void executeQuerySkillData() + { + sqlite3* db; + char* zErrMsg = 0; + const char* data = "Getting MasterSkillData..."; + + const auto dbPath = std::format("{}/master/master.mdb", basePath); + int rc = sqlite3_open(dbPath.c_str(), &db); + if (rc) { + printf("Can't open database: %s\n", sqlite3_errmsg(db)); + return; + } + + static std::vector tableHeads = { "id", + "ability_type_1_1", "ability_type_1_2", "ability_type_1_3", "ability_type_2_1", "ability_type_2_2", "ability_type_2_3", + "float_ability_value_1_1", "float_ability_value_1_2", "float_ability_value_1_3", + "float_ability_value_2_1", "float_ability_value_2_2", "float_ability_value_2_3", + "float_cooldown_time_1", "float_cooldown_time_2", + "target_type_1_1", "target_type_1_2", "target_type_1_3", + "target_type_2_1", "target_type_2_2", "target_type_2_3" }; + + const auto joinedRows = boost::algorithm::join(tableHeads, ","); + auto sql = std::format("SELECT {} FROM skill_data", joinedRows); + + char** pResult; + char* errmsg; + int nRow; + int nCol; + + rc = sqlite3_get_table(db, sql.c_str(), &pResult, &nRow, &nCol, &zErrMsg); + if (rc != SQLITE_OK) { + printf("SQL error: %s\n", zErrMsg); + sqlite3_free(zErrMsg); + return; + } + umaSkillInfo.clear(); + + int index = 0; + for (int n = 0; n < nRow; n++) + { + int currId = 0; + bool hasErr = false; + for (int j = 0; j < nCol; j++) + { + try { + auto value = pResult[index]; + switch (j) { + case 0: { // id + currId = std::stoi(value); + std::unordered_map dic{}; + umaSkillInfo.emplace(currId, std::move(dic)); + }; break; + default: { + const auto& headName = tableHeads[j]; + umaSkillInfo[currId].emplace(headName, std::stoi(value)); + } + } + } + catch (std::exception& e) { + printf("executeQuerySkillData err: %s\n", e.what()); + hasErr = true; + } + index++; + } + if (hasErr) continue; + } + sqlite3_free_table(pResult); + sqlite3_close(db); + } + + int get_head_id_from_dress_id(int dressId) { if (umaDressHeadId.empty()) { executeQueryDress(); diff --git a/src/umadb/umadb.hpp b/src/umadb/umadb.hpp index 668c1900..6dddbcc6 100644 --- a/src/umadb/umadb.hpp +++ b/src/umadb/umadb.hpp @@ -11,4 +11,8 @@ namespace UmaDatabase { void* getBundleHandleTargetCache(std::wstring bundlePath, bool isDbPath=false); int get_head_id_from_dress_id(int dressId); bool get_dress_have_mini(int dressId); + + void executeQuerySkillData(); + + extern std::unordered_map> umaSkillInfo; } \ No newline at end of file diff --git a/src/umagui/guiLanguage.hpp b/src/umagui/guiLanguage.hpp index edf99069..e547cfe3 100644 --- a/src/umagui/guiLanguage.hpp +++ b/src/umagui/guiLanguage.hpp @@ -77,6 +77,30 @@ namespace GuiTrans { {"DebuffCancel", "消除 Debuff"}, {"DebuffAbilityValueMultiply", "Debuff 数值加倍"}, {"DebuffAbilityValueMultiplyOtherActivate", "DebuffAbilityValueMultiplyOtherActivate"}, // 不会翻( + + {"Self", "自身"}, + {"All", "所有角色"}, + {"AllOtherSelf", "所有除自身以外的"}, + {"Visible", "可见的"}, + {"RandomOtherSelf", "随机除自身以外的"}, + {"Order", "指定排名"}, + {"OrderInfront", "排名在自身之前的"}, + {"OrderBehind", "排名在自身之后的"}, + {"SelfInfront", "在自身前面的"}, + {"SelfBehind", "在自身后面的"}, + {"TeamMember", "队友"}, + {"Near", "附近的"}, + {"SelfAndBlockFront", "自身和在前方阻挡的"}, + {"BlockSide", "侧方阻挡的"}, + {"NearInfront", "靠近自身前面的"}, + {"NearBehind", "靠近自身后面的俄"}, + {"RunningStyle", "指定跑法的"}, + {"RunningStyleOtherSelf", "其他角色指定跑法的"}, + {"SelfInfrontTemptation", "SelfInfrontTemptation"}, + {"SelfBehindTemptation", "SelfBehindTemptation"}, + {"RunningStyleTemptationOtherSelf", "RunningStyleTemptationOtherSelf"}, + {"CharaId", "指定角色 ID"}, + {"ActivateHealSkill", "激活治疗技能"}, }; const std::unordered_map guiTChineseTrans{ @@ -143,6 +167,30 @@ namespace GuiTrans { {"DebuffCancel", "消除 Debuff"}, {"DebuffAbilityValueMultiply", "Debuff 數值加倍"}, {"DebuffAbilityValueMultiplyOtherActivate", "DebuffAbilityValueMultiplyOtherActivate"}, // 不會翻( + + {"Self", "自身"}, + {"All", "所有角色"}, + {"AllOtherSelf", "所有除自身以外的"}, + {"Visible", "可見的"}, + {"RandomOtherSelf", "隨機除自身以外的"}, + {"Order", "指定排名"}, + {"OrderInfront", "排名在自身之前的"}, + {"OrderBehind", "排名在自身之後的"}, + {"SelfInfront", "在自身前面的"}, + {"SelfBehind", "在自身後面的"}, + {"TeamMember", "隊友"}, + {"Near", "附近的"}, + {"SelfAndBlockFront", "自身和在前方阻擋的"}, + {"BlockSide", "側方阻擋的"}, + {"NearInfront", "靠近自身前面的"}, + {"NearBehind", "靠近自身後面的"}, + {"RunningStyle", "指定跑法的"}, + {"RunningStyleOtherSelf", "其他角色指定跑法的"}, + {"SelfInfrontTemptation", "SelfInfrontTemptation"}, + {"SelfBehindTemptation", "SelfBehindTemptation"}, + {"RunningStyleTemptationOtherSelf", "RunningStyleTemptationOtherSelf"}, + {"CharaId", "指定角色 ID"}, + {"ActivateHealSkill", "激活治療技能"}, }; const char* GetTrans(const char* text) { diff --git a/src/umagui/guiShowData.cpp b/src/umagui/guiShowData.cpp index 66a567cb..6706952b 100644 --- a/src/umagui/guiShowData.cpp +++ b/src/umagui/guiShowData.cpp @@ -61,7 +61,7 @@ UmaGUiShowData::UmaRaceMotionData::UmaRaceMotionData(int gateNo, std::wstring ch void UmaGUiShowData::UmaRaceMotionData::UpdateMotionData(float speed, float rate, float RaceBaseSpeed, float MinSpeed, float StartDashSpeedThreshold, bool IsOverRun, float Hp, float MaxHp, float HpPer, int NearHorseCount, float CongestionTime, int RawSpeed, float BaseSpeed, float Speed, int RawStamina, float BaseStamina, float Stamina, int RawPow, float BasePow, float Pow, - int RawGuts, float BaseGuts, float Guts, int RawWiz, float BaseWiz, float Wiz, bool IsStartDash, int ActivateSkillCount, + int RawGuts, float BaseGuts, float Guts, int RawWiz, float BaseWiz, float Wiz, bool IsStartDash, float lastSpeed, float MoveDistance, float distance, float deltatime, float LastSpurtStartDistance, bool isLastSpurt) { this->speed = speed; @@ -91,7 +91,6 @@ void UmaGUiShowData::UmaRaceMotionData::UpdateMotionData(float speed, float rate this->BaseWiz = BaseWiz; this->Wiz = Wiz; this->IsStartDash = IsStartDash; - this->ActivateSkillCount = ActivateSkillCount; this->lastSpeed = lastSpeed; if (!(ignoreNegativeSpeed && (MoveDistance < 0))) { this->MoveDistance = MoveDistance; @@ -148,8 +147,12 @@ UmaGUiShowData::SkillAbility::SkillAbility(int abilityType, float effValue) { this->effValue = effValue; } -void UmaGUiShowData::SkillAbility::addTargets(UmaRaceMotionData target) { - this->targets.emplace_back(target); +// void UmaGUiShowData::SkillAbility::addTargets(UmaRaceMotionData target) { +// this->targets.emplace_back(target); +// } + +void UmaGUiShowData::SkillAbility::setTargetType(int targetType) { + this->targetType = targetType; } void UmaGUiShowData::initGuiGlobalData() { diff --git a/src/umagui/guiShowData.hpp b/src/umagui/guiShowData.hpp index 399f23cb..c53c747a 100644 --- a/src/umagui/guiShowData.hpp +++ b/src/umagui/guiShowData.hpp @@ -131,7 +131,6 @@ namespace UmaGUiShowData { int RawWiz = 0; float BaseWiz = 0; float Wiz = 0; - int ActivateSkillCount = 0; bool IsStartDash = false; float lastSpeed = 0; float MoveDistance = 0.0f; @@ -150,7 +149,7 @@ namespace UmaGUiShowData { void UpdateMotionData(float speed, float rate, float RaceBaseSpeed, float MinSpeed, float StartDashSpeedThreshold, bool IsOverRun, float Hp, float MaxHp, float HpPer, int NearHorseCount, float CongestionTime, int RawSpeed, float BaseSpeed, float Speed, int RawStamina, float BaseStamina, float Stamina, int RawPow, float BasePow, float Pow, - int RawGuts, float BaseGuts, float Guts, int RawWiz, float BaseWiz, float Wiz, bool IsStartDash, int ActivateSkillCount, + int RawGuts, float BaseGuts, float Guts, int RawWiz, float BaseWiz, float Wiz, bool IsStartDash, float lastSpeed, float MoveDistance, float distance, float deltatime, float LastSpurtStartDistance, bool isLastSpurt); void setRank(int rank); @@ -163,10 +162,12 @@ namespace UmaGUiShowData { public: int abilityType; float effValue; - std::vector targets; + // std::vector targets; + int targetType; SkillAbility(int abilityType, float effValue); - void addTargets(UmaRaceMotionData target); + // void addTargets(UmaRaceMotionData target); + void setTargetType(int targetType); }; diff --git a/src/umagui/umaguiMain.cpp b/src/umagui/umaguiMain.cpp index fba5fd18..8dc98d87 100644 --- a/src/umagui/umaguiMain.cpp +++ b/src/umagui/umaguiMain.cpp @@ -584,7 +584,33 @@ std::unordered_map abilityTypes{ {0x28, "DebuffAbilityValueMultiplyOtherActivate"}, {0x1f5, "ChallengeMatchBonus_Old"}, {0x1f6, "ChallengeMatchBonusStatus"}, - {0x1f7, "ChallengeMatchBonusMotivation"} + {0x1f7, "ChallengeMatchBonusMotivation"}, +}; + +std::unordered_map skillTargetType { + {0x1, "Self"}, + {0x2, "All"}, + {0x3, "AllOtherSelf"}, + {0x4, "Visible"}, + {0x5, "RandomOtherSelf"}, + {0x6, "Order"}, + {0x7, "OrderInfront"}, + {0x8, "OrderBehind"}, + {0x9, "SelfInfront"}, + {0xa, "SelfBehind"}, + {0xb, "TeamMember"}, + {0xc, "Near"}, + {0xd, "SelfAndBlockFront"}, + {0xe, "BlockSide"}, + {0xf, "NearInfront"}, + {0x10, "NearBehind"}, + {0x11, "RunningStyle"}, + {0x12, "RunningStyleOtherSelf"}, + {0x13, "SelfInfrontTemptation"}, + {0x14, "SelfBehindTemptation"}, + {0x15, "RunningStyleTemptationOtherSelf"}, + {0x16, "CharaId"}, + {0x17, "ActivateHealSkill"}, }; std::string transSkillAbilityType(int abilityType) { @@ -593,6 +619,12 @@ std::string transSkillAbilityType(int abilityType) { } return std::format("0x{:x}", abilityType); } +std::string transSkillTargetType(int targetType) { + if (const auto iter = skillTargetType.find(targetType); iter != skillTargetType.end()) { + return GetTrans(iter->second.c_str()); + } + return std::format("0x{:x}", targetType); +} void imGuiRaceSkillInfoMainLoop() { if (!showRaceWnd) return; @@ -643,7 +675,7 @@ void imGuiRaceSkillInfoMainLoop() { ImGui::Text("%.6f", ability.effValue); ImGui::TableSetColumnIndex(2); - + /* std::stringstream ss; int fCount = 0; for (const auto& target : ability.targets) { @@ -655,7 +687,9 @@ void imGuiRaceSkillInfoMainLoop() { ss << "\n"; } } - ImGui::Text("%s", ss.str().c_str()); + ImGui::Text("%s", ss.str().c_str());*/ + ImGui::Text("%s", transSkillTargetType(ability.targetType).c_str()); + } ImGui::EndTable(); @@ -703,10 +737,12 @@ void imGuiRaceSkillInfoMainLoop() { ImGui::TableSetColumnIndex(4); for (const auto& iab : it.skillAbilities) { + ss << transSkillTargetType(iab.targetType); + /* for (const auto& target : iab.targets) { ss << std::format("{}. {}{} ", target.gateNo, target.charaName, target.trainerName.empty() ? "" : std::format(" ({})", target.trainerName)); - } + }*/ ss << "\n"; } ImGui::Text(ss.str().c_str()); From fead0b45ce15e4333145f4642ea91d07e5314040 Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Sun, 17 Dec 2023 12:54:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8C=E8=A7=81?= =?UTF-8?q?=E7=9A=87=E5=86=A0=E6=95=85=E4=BA=8B=E5=AD=97=E4=BD=93BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hook.cpp | 25 +++++++++++++++++++++---- src/mhotkey.cpp | 24 +++++++++++------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/hook.cpp b/src/hook.cpp index 6e9750ab..adbd1613 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -1488,6 +1488,17 @@ namespace return replaceFont; } + void* Text_set_font_orig; + void Text_set_font_hook(void* _this, void* font) { + if (font) { + auto replaceFont = getReplaceFont(); + if (replaceFont) { + font = replaceFont; + } + } + return reinterpret_cast(Text_set_font_orig)(_this, font); + } + void* TextCommon_Awake_orig; void TextCommon_Awake_hook(void* _this) { @@ -4359,11 +4370,9 @@ namespace "AnGlobalData", "_GetFontFromCommon", 1 ); - Text_set_font = reinterpret_cast( - il2cpp_symbols::get_method_pointer( + auto Text_set_font_addr = il2cpp_symbols::get_method_pointer( "UnityEngine.UI.dll", "UnityEngine.UI", - "Text", "set_font", 1) - ); + "Text", "set_font", 1); Text_set_horizontalOverflow = reinterpret_cast( il2cpp_symbols::get_method_pointer( @@ -5008,6 +5017,8 @@ namespace if (!std::holds_alternative(g_replace_font)) { ADD_HOOK(TextCommon_Awake, "Gallop.TextCommon::Awake at %p\n"); + ADD_HOOK(Text_set_font, "Text_set_font at %p\n"); + Text_set_font = reinterpret_cast(Text_set_font_orig); ADD_HOOK(TextMeshProUguiCommon_Awake, "TextMeshProUguiCommon_Awake at %p\n"); ADD_HOOK(AnText_UpdateText, "AnText_UpdateText at %p\n"); ADD_HOOK(AnText_Destroy, "AnText_Destroy at %p\n"); @@ -5020,6 +5031,12 @@ namespace AssetBundle_LoadAsset_orig = reinterpret_cast(AssetBundle_LoadAsset_addr); } } + else + { + Text_set_font = reinterpret_cast(il2cpp_symbols::get_method_pointer( + "UnityEngine.UI.dll", "UnityEngine.UI", + "Text", "set_font", 1)); + } if (g_replace_assets) { diff --git a/src/mhotkey.cpp b/src/mhotkey.cpp index 37873bbe..b35280ed 100644 --- a/src/mhotkey.cpp +++ b/src/mhotkey.cpp @@ -7,6 +7,7 @@ #include #include #include +#include extern void (*testFunction)(); @@ -39,11 +40,6 @@ namespace MHotkey{ void SetKeyCallBack(std::function callbackfun) { mKeyBoardCallBack = callbackfun; } - - bool check_file_exist(const std::string& name) { - struct stat buffer; - return (stat(name.c_str(), &buffer) == 0); - } void fopenExternalPlugin(int tlgPort) { std::thread([tlgPort](){ @@ -59,13 +55,15 @@ namespace MHotkey{ printf("\"externalPlugin\" not found\n"); return; } - - if (check_file_exist(file_check_name)) { - if (check_file_exist(extPluginPath)) { - remove(extPluginPath.c_str()); + if (std::filesystem::exists(file_check_name)) { + try { + if (std::filesystem::exists(extPluginPath)) { + std::filesystem::remove(extPluginPath); + } + std::filesystem::rename(file_check_name, extPluginPath); } - if (rename(file_check_name.c_str(), extPluginPath.c_str()) != 0) { - printf("update external plugin failed\n"); + catch (std::exception& e) { + printf("update external plugin failed: %s\n", e.what()); } } @@ -94,8 +92,8 @@ namespace MHotkey{ } void closeExternalPlugin() { - if (check_file_exist("dontcloseext.lock")) { - remove("dontcloseext.lock"); + if (std::filesystem::exists("dontcloseext.lock")) { + std::filesystem::remove("dontcloseext.lock"); return; } if (openPluginSuccess && pluginPID != -1) { From 4770942ef2ae859d394e865d9289438f523fbcd5 Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Sun, 17 Dec 2023 21:48:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E8=A2=AB=E9=94=99=E8=AF=AF=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hook.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/src/hook.cpp b/src/hook.cpp index adbd1613..262a4109 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -1490,13 +1490,44 @@ namespace void* Text_set_font_orig; void Text_set_font_hook(void* _this, void* font) { - if (font) { - auto replaceFont = getReplaceFont(); - if (replaceFont) { - font = replaceFont; + return reinterpret_cast(Text_set_font_orig)(_this, font); + } + + bool settingSubText = false; + + void* SubTextCommon_Setup_orig; + void SubTextCommon_Setup_hook(void* _this, int fontType, bool isChangeLine) { + settingSubText = true; + reinterpret_cast(SubTextCommon_Setup_orig)(_this, fontType, isChangeLine); + settingSubText = false; + } + + void* TextCommon_UpdateBaseText_orig; + void TextCommon_UpdateBaseText_hook(void* _this, Il2CppString* value) { + settingSubText = true; + reinterpret_cast(TextCommon_UpdateBaseText_orig)(_this, value); + settingSubText = false; + } + + void* GetChineseFont_orig; + void* GetChineseFont_hook(void* _this) { + auto ret = getReplaceFont(); + if (ret) return ret; + return reinterpret_cast(GetChineseFont_orig)(_this); + } + + void* LoadResourcesFolderFont_orig; + void* LoadResourcesFolderFont_hook(void* _this, int fontType) { + if (settingSubText) { + switch (fontType) { + case 0x0: // Dynamic01 + case 0x3: { // Chinese_Font01 + auto ret = getReplaceFont(); + if (ret) return ret; + }; break; } } - return reinterpret_cast(Text_set_font_orig)(_this, font); + return reinterpret_cast(LoadResourcesFolderFont_orig)(_this, fontType); } void* TextCommon_Awake_orig; @@ -4374,6 +4405,26 @@ namespace "UnityEngine.UI.dll", "UnityEngine.UI", "Text", "set_font", 1); + auto GetChineseFont_addr = il2cpp_symbols::get_method_pointer( + "umamusume.dll", "Gallop", + "TextFontManager", "GetChineseFont", 0); + + auto SubTextCommon_Setup_addr = il2cpp_symbols::get_method_pointer( + "umamusume.dll", "Gallop", + "SubTextCommon", "Setup", 2); + auto TextCommon_UpdateBaseText_addr = il2cpp_symbols::get_method_pointer( + "umamusume.dll", "Gallop", + "TextCommon", "UpdateBaseText", 1); + + auto LoadResourcesFolderFont_addr = il2cpp_symbols::find_method("umamusume.dll", "Gallop", "TextFontManager", [](const MethodInfo* method) { + if (strcmp(method->name, "LoadResourcesFolderFont") == 0) { + if (method->parameters->parameter_type->type == Il2CppTypeEnum::IL2CPP_TYPE_VALUETYPE) { + return true; + } + } + return false; + }); + Text_set_horizontalOverflow = reinterpret_cast( il2cpp_symbols::get_method_pointer( "UnityEngine.UI.dll", "UnityEngine.UI", @@ -5018,6 +5069,10 @@ namespace { ADD_HOOK(TextCommon_Awake, "Gallop.TextCommon::Awake at %p\n"); ADD_HOOK(Text_set_font, "Text_set_font at %p\n"); + ADD_HOOK(GetChineseFont, "GetChineseFont at %p\n"); + ADD_HOOK(SubTextCommon_Setup, "SubTextCommon_Setup at %p\n"); + ADD_HOOK(TextCommon_UpdateBaseText, "TextCommon_UpdateBaseText at %p\n"); + ADD_HOOK(LoadResourcesFolderFont, "LoadResourcesFolderFont at %p\n"); Text_set_font = reinterpret_cast(Text_set_font_orig); ADD_HOOK(TextMeshProUguiCommon_Awake, "TextMeshProUguiCommon_Awake at %p\n"); ADD_HOOK(AnText_UpdateText, "AnText_UpdateText at %p\n");