From 1cc0b1e6be481a1981d5ccea50f1a912331011d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 17 Sep 2020 00:47:23 +0200 Subject: [PATCH] Implement aoc2::rankUpEnemy It's a pretty large function and I wanted to see how difficult it would be to match it. Not very hard :D --- CMakeLists.txt | 3 + data/uking_functions.csv | 2 +- lib/sead | 2 +- src/Game/DLC/aoc2.cpp | 145 +++++++++++++++++++++++++++++++++++++++ src/Game/DLC/aoc2.h | 25 +++++++ 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 src/Game/DLC/aoc2.cpp create mode 100644 src/Game/DLC/aoc2.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d349bb4e..db45f865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ add_executable(uking src/Game/AI/Action/actionSetLinkTagBasic.cpp src/Game/AI/Action/actionSetLinkTagBasic.h + src/Game/DLC/aoc2.cpp + src/Game/DLC/aoc2.h + src/KingSystem/ActorSystem/actActor.h src/KingSystem/ActorSystem/actActorCreator.cpp src/KingSystem/ActorSystem/actActorCreator.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index ceecf691..a74800a9 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -72755,7 +72755,7 @@ 0x0000007100d6ef10,aoc2::setIsLastPlayHardModeToFalse,76, 0x0000007100d6ef5c,aoc2::isTestOfStrengthDungeon,396, 0x0000007100d6f0e8,aoc2::calc,20, -0x0000007100d6f0fc,aoc2::rankUpEnemy,7780, +0x0000007100d6f0fc,aoc2::rankUpEnemy,7780,_ZN5uking4aoc211rankUpEnemyERKN4sead14SafeStringBaseIcEERKN4ksys3map6ObjectEPPKc 0x0000007100d70f60,sub_7100D70F60,48, 0x0000007100d70f90,sub_7100D70F90,92, 0x0000007100d70fec,sub_7100D70FEC,48, diff --git a/lib/sead b/lib/sead index 26b88aa2..ad85ebd3 160000 --- a/lib/sead +++ b/lib/sead @@ -1 +1 @@ -Subproject commit 26b88aa2275b7c39d8b0898f0c77567b37ad6c11 +Subproject commit ad85ebd3bf275f35c8ed16383ab66ff736ea7d6f diff --git a/src/Game/DLC/aoc2.cpp b/src/Game/DLC/aoc2.cpp new file mode 100644 index 00000000..22fbdad9 --- /dev/null +++ b/src/Game/DLC/aoc2.cpp @@ -0,0 +1,145 @@ +#include "Game/DLC/aoc2.h" + +namespace uking { + +using namespace ksys; + +bool aoc2::rankUpEnemy(const sead::SafeString& actor_name, const ksys::map::Object& obj, + const char** new_name) { + if (obj.getFlags().isOn(ksys::map::Object::Flag::HasUniqueName) || + obj.getHardModeFlags().isOn(ksys::map::Object::HardModeFlag::DisableRankup)) { + return false; + } + + if (!actor_name.startsWith("Enemy")) + return false; + + if (isTestOfStrengthShrine()) + return false; + + sead::SafeString next = ""; + + /// @bug Yes, this is duplicated and shouldn't exist. + if (!actor_name.startsWith("Enemy")) + return false; + + if (actor_name == "Enemy_Assassin_Junior") + next = "Enemy_Assassin_Middle"; + else if (actor_name == "Enemy_Assassin_Middle") + next = "Enemy_Assassin_Senior"; + else if (actor_name == "Enemy_Assassin_Shooter_Junior") + next = "Enemy_Assassin_Shooter_Azito_Junior"; + + else if (actor_name == "Enemy_Bokoblin_Junior") + next = "Enemy_Bokoblin_Middle"; + else if (actor_name == "Enemy_Bokoblin_Middle") + next = "Enemy_Bokoblin_Senior"; + else if (actor_name == "Enemy_Bokoblin_Senior") + next = "Enemy_Bokoblin_Dark"; + else if (actor_name == "Enemy_Bokoblin_Dark") + next = "Enemy_Bokoblin_Gold"; + + else if (actor_name == "Enemy_Bokoblin_Guard_Junior") + next = "Enemy_Bokoblin_Guard_Middle"; + + else if (actor_name == "Enemy_Bokoblin_Guard_Junior_Ambush") + next = "Enemy_Bokoblin_Guard_Middle_Ambush"; + + else if (actor_name == "Enemy_Bokoblin_Guard_Junior_TreeHouseTop") + next = "Enemy_Bokoblin_Guard_Middle_TreeHouseTop"; + + /// @bug Yes, this is duplicated and shouldn't exist. + else if (actor_name == "Enemy_Bokoblin_Guard_Junior_Ambush") + next = "Enemy_Bokoblin_Guard_Middle_Ambush"; + + else if (actor_name == "Enemy_Chuchu_Electric_Junior") + next = "Enemy_Chuchu_Electric_Middle"; + else if (actor_name == "Enemy_Chuchu_Electric_Middle") + next = "Enemy_Chuchu_Electric_Senior"; + + else if (actor_name == "Enemy_Chuchu_Fire_Junior") + next = "Enemy_Chuchu_Fire_Middle"; + else if (actor_name == "Enemy_Chuchu_Fire_Middle") + next = "Enemy_Chuchu_Fire_Senior"; + + else if (actor_name == "Enemy_Chuchu_Ice_Junior") + next = "Enemy_Chuchu_Ice_Middle"; + else if (actor_name == "Enemy_Chuchu_Ice_Middle") + next = "Enemy_Chuchu_Ice_Senior"; + + else if (actor_name == "Enemy_Chuchu_Junior") + next = "Enemy_Chuchu_Middle"; + else if (actor_name == "Enemy_Chuchu_Middle") + next = "Enemy_Chuchu_Senior"; + + else if (actor_name == "Enemy_Giant_Junior") + next = "Enemy_Giant_Middle"; + else if (actor_name == "Enemy_Giant_Middle") + next = "Enemy_Giant_Senior"; + + else if (actor_name == "Enemy_Golem_Junior") + next = "Enemy_Golem_Middle"; + else if (actor_name == "Enemy_Golem_Middle") + next = "Enemy_Golem_Senior"; + + else if (actor_name == "Enemy_Guardian_Mini_Baby") + next = "Enemy_Guardian_Mini_Junior"; + else if (actor_name == "Enemy_Guardian_Mini_Junior") + next = "Enemy_Guardian_Mini_Middle"; + else if (actor_name == "Enemy_Guardian_Mini_Middle") + next = "Enemy_Guardian_Mini_Senior"; + + else if (actor_name == "Enemy_Guardian_Mini_Junior_DetachLineBeam") + next = "Enemy_Guardian_Mini_Middle_DetachLineBeam"; + + else if (actor_name == "Enemy_Lizalfos_Junior") + next = "Enemy_Lizalfos_Middle"; + else if (actor_name == "Enemy_Lizalfos_Middle") + next = "Enemy_Lizalfos_Senior"; + else if (actor_name == "Enemy_Lizalfos_Senior") + next = "Enemy_Lizalfos_Dark"; + else if (actor_name == "Enemy_Lizalfos_Dark") + next = "Enemy_Lizalfos_Gold"; + + else if (actor_name == "Enemy_Lizalfos_Guard_Junior") + next = "Enemy_Lizalfos_Guard_Middle"; + + else if (actor_name == "Enemy_Lizalfos_Guard_Junior_LongVisibility") + next = "Enemy_Lizalfos_Guard_Middle_LongVisibility"; + + else if (actor_name == "Enemy_Lizalfos_Junior_Guard_Ambush") + next = "Enemy_Lizalfos_Middle_Guard_Ambush"; + + else if (actor_name == "Enemy_Lynel_Junior") + next = "Enemy_Lynel_Middle"; + else if (actor_name == "Enemy_Lynel_Middle") + next = "Enemy_Lynel_Senior"; + else if (actor_name == "Enemy_Lynel_Senior") + next = "Enemy_Lynel_Dark"; + else if (actor_name == "Enemy_Lynel_Dark") + next = "Enemy_Lynel_Gold"; + + else if (actor_name == "Enemy_Moriblin_Junior") + next = "Enemy_Moriblin_Middle"; + else if (actor_name == "Enemy_Moriblin_Middle") + next = "Enemy_Moriblin_Senior"; + else if (actor_name == "Enemy_Moriblin_Senior") + next = "Enemy_Moriblin_Dark"; + else if (actor_name == "Enemy_Moriblin_Dark") + next = "Enemy_Moriblin_Gold"; + + else if (actor_name == "Enemy_Wizzrobe_Electric") + next = "Enemy_Wizzrobe_Electric_Senior"; + else if (actor_name == "Enemy_Wizzrobe_Fire") + next = "Enemy_Wizzrobe_Fire_Senior"; + else if (actor_name == "Enemy_Wizzrobe_Ice") + next = "Enemy_Wizzrobe_Ice_Senior"; + + if (next.isEmpty()) + return false; + + *new_name = next.cstr(); + return true; +} + +} // namespace uking diff --git a/src/Game/DLC/aoc2.h b/src/Game/DLC/aoc2.h new file mode 100644 index 00000000..e903079c --- /dev/null +++ b/src/Game/DLC/aoc2.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include "KingSystem/Map/mapObject.h" + +namespace uking { + +// FIXME: incomplete +class aoc2 { + SEAD_SINGLETON_DISPOSER(aoc2) + + aoc2(); + virtual ~aoc2(); + +public: + void init(sead::Heap* heap); + + bool isTestOfStrengthShrine() const; + + bool rankUpEnemy(const sead::SafeString& actor_name, const ksys::map::Object& obj, + const char** new_name); +}; + +} // namespace uking