diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 45327903..f0319b89 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -80188,8 +80188,8 @@ 0x0000007100edd26c,sub_7100EDD26C,156, 0x0000007100edd308,sub_7100EDD308,136, 0x0000007100edd390,_ZNK4gsys16ModelSceneBuffer27isOutlineSilhouetteEnabled_Ev,36, -0x0000007100edd3b4,_ZN3act12hasTagByNameEP5ActorRKN4sead10SafeStringE,76, -0x0000007100edd400,_ZN3act12hasTagByNameERKN4sead10SafeStringES3_,124, +0x0000007100edd3b4,_ZN3act12hasTagByNameEP5ActorRKN4sead10SafeStringE,76,_ZN4ksys3act6hasTagEPNS0_5ActorERKN4sead14SafeStringBaseIcEE +0x0000007100edd400,_ZN3act12hasTagByNameERKN4sead10SafeStringES3_,124,_ZN4ksys3act6hasTagERKN4sead14SafeStringBaseIcEES5_ 0x0000007100edd47c,_ZN3act6hasTagEP5ActorNS_3TagE,20, 0x0000007100edd490,_ZN3act6hasTagER12BaseProcLinkNS_3TagE,84, 0x0000007100edd4e4,_ZN3act6hasTagERKN4sead10SafeStringENS_3TagE,104, diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index 05aff8cd..dfd43084 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -16,6 +16,8 @@ target_sources(uking PRIVATE actActorParamMgr.h actActorTemplate.cpp actActorTemplate.h + actActorUtil.cpp + actActorUtil.h actAiAction.cpp actAiAction.h actAiClass.cpp diff --git a/src/KingSystem/ActorSystem/actActorUtil.cpp b/src/KingSystem/ActorSystem/actActorUtil.cpp new file mode 100644 index 00000000..69f6f51f --- /dev/null +++ b/src/KingSystem/ActorSystem/actActorUtil.cpp @@ -0,0 +1,20 @@ +#include "KingSystem/ActorSystem/actActorUtil.h" +#include "KingSystem/ActorSystem/actActor.h" +#include "KingSystem/ActorSystem/actActorParam.h" +#include "KingSystem/ActorSystem/actInfoData.h" +#include "KingSystem/Resource/resResourceActorLink.h" + +namespace ksys::act { + +bool hasTag(Actor* actor, const sead::SafeString& tag) { + if (!actor) + return false; + return actor->getParam()->getRes().mActorLink->hasTag(tag.cstr()); +} + +bool hasTag(const sead::SafeString& actor, const sead::SafeString& tag) { + auto* data = InfoData::instance(); + return data && data->hasTag(actor.cstr(), tag.cstr()); +} + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorUtil.h b/src/KingSystem/ActorSystem/actActorUtil.h new file mode 100644 index 00000000..6a312e45 --- /dev/null +++ b/src/KingSystem/ActorSystem/actActorUtil.h @@ -0,0 +1,154 @@ +#pragma once + +#include + +namespace al { +class ByamlIter; +} + +namespace ksys::map { +class Object; +} + +namespace ksys::act { + +class Actor; +class ActorConstDataAccess; +class BaseProcLink; + +enum class ArrowType { + /// Wooden arrows. + Normal = 0, + /// Bomb arrows. + Bomb = 1, + /// Ancient arrows. + Ancient = 2, + /// Fire arrows. + Fire = 3, + /// Ice arrows. + Ice = 4, + /// Shock arrows. + Electric = 5, + + Invalid = -1, +}; + +/// Compendium type (図鑑 type). +enum class ZukanType { + Animal = 0, + Enemy = 1, + /// Materials (素材). + Sozai = 2, + Weapon = 3, + Other = 4, + Invalid = 5, +}; + +bool hasTag(Actor* actor, const sead::SafeString& tag); +bool hasTag(const sead::SafeString& actor, const sead::SafeString& tag); + +bool hasTag(Actor* actor, u32 tag); +bool hasTag(BaseProcLink* link, u32 tag); +bool hasTag(const sead::SafeString& actor, u32 tag); + +/// Checks whether the actor has at least one of the specified tags. +/// @param tags A comma separated list of tags. +bool hasOneTagAtLeast(Actor* actor, const sead::SafeString& tags); +bool hasOneTagAtLeast(BaseProcLink* link, const sead::SafeString& tags); +bool hasOneTagAtLeast(ActorConstDataAccess* accessor, const sead::SafeString& tags); + +bool shouldSkipSpawnForWeatherReasons(map::Object* obj); +bool isAnimalMasterAppearance(map::Object* obj); +bool shouldSkipSpawnGodForestActor(map::Object* obj); +bool shouldSkipSpawnFairy(map::Object* obj); +bool shouldSkipSpawnFairy(const sead::SafeString& actor); + +/// Must be called before using any of the "should skip" functions above + isAnimalMasterAppearance. +void initSpawnConditionGameDataFlags(); + +bool hasAnyRevivalTag(const sead::SafeString& actor); + +bool hasStopTimerMiddleTag(Actor* actor); +bool hasStopTimerShortTag(Actor* actor); +bool canBeStasised(Actor* actor); + +void highlightStasisableActors(bool on); + +const char* arrowTypeToString(ArrowType idx); +ArrowType arrowTypeFromString(const sead::SafeString& name); + +ZukanType getZukanType(al::ByamlIter* iter); +ZukanType getZukanType(Actor* actor); + +bool isPlayerProfile(const ActorConstDataAccess& accessor); +bool isPlayerProfile(Actor* actor); +bool isPlayerProfile(BaseProcLink* link); + +bool isCameraProfile(Actor* actor); + +bool isNPCProfile(const ActorConstDataAccess& accessor); +bool isNPCProfile(Actor* actor); +bool isNPCProfile(BaseProcLink* link); +bool isNPCOffPodFromWeapon(Actor* actor); + +bool isDemoNPCProfile(Actor* actor); + +bool isEnemyProfile(const ActorConstDataAccess& accessor); +bool isEnemyProfile(Actor* actor); +bool isEnemyProfile(BaseProcLink* link); + +bool isGuardianProfile(BaseProcLink* link); + +bool isLargeEnemy(const ActorConstDataAccess& accessor); +bool isLargeEnemy(Actor* actor); + +bool isGanonBeast(const ActorConstDataAccess& accessor); +bool isGanonBeast(BaseProcLink* link); + +bool isHumanOrOtherAnimal(Actor* actor); +bool isHumanOrOtherAnimal(const ActorConstDataAccess& accessor); +bool isHumanOrOtherAnimal(BaseProcLink* link); + +bool isWeaponName(const ActorConstDataAccess& accessor); +bool isWeaponName(const sead::SafeString& actor); +bool isWeaponName(Actor* actor); +bool isWeaponName(BaseProcLink* link); + +bool isWeaponOrArmor(const ActorConstDataAccess& accessor); +bool isWeaponOrArmor(Actor* actor); + +bool isBulletProfile(const ActorConstDataAccess& accessor); +bool isBulletProfile(Actor* actor); +bool isBulletProfile(BaseProcLink* link); + +bool isHorseProfile(const ActorConstDataAccess& accessor); +bool isHorseProfile(Actor* actor); +bool isHorseProfile(BaseProcLink* link); + +bool isAttClientEnabled(Actor* actor, const sead::SafeString& client); +bool isGrabAttClientEnabled(void* x, BaseProcLink* link); + +bool isStalfosParts(BaseProcLink* link); + +bool isDoor(Actor* actor); +bool isDoor(BaseProcLink* link); + +bool isPreyOrSwarm(const ActorConstDataAccess& accessor); +bool isPreyOrSwarm(Actor* actor); +bool isPreyOrSwarm(BaseProcLink* link); + +bool isWolfOrBear(const ActorConstDataAccess& accessor); +bool isWolfOrBear(Actor* actor); +bool isWolfOrBear(BaseProcLink* link); + +bool isRope(Actor* actor); +bool isRope(BaseProcLink* link); + +bool isTreeOrScaffoldOrSignboard(Actor* actor); + +bool isAlive(BaseProcLink* link); + +bool isAirOctaPlatform(const sead::SafeString& name); +bool isAirOctaPlatformDlc(const sead::SafeString& name); + +} // namespace ksys::act