From d35fb6db76536528c5bfd314dca026a7f066dadb Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 28 Sep 2024 02:01:18 +0200 Subject: [PATCH] Attention (#35) * attention * Header * These were meant to be public * fixup merge --------- Co-authored-by: elijah-thomas774 --- config/SOUE01/splits.txt | 8 + config/SOUE01/symbols.txt | 144 ++--- configure.py | 1 + include/c/c_lib.h | 13 + include/d/a/d_a_player.h | 8 + include/d/d_pad.h | 11 + .../toBeSorted/arc_managers/oarc_manager.h | 4 +- include/toBeSorted/attention.h | 236 +++++++- include/toBeSorted/event_manager.h | 13 + src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp | 12 +- src/toBeSorted/attention.cpp | 569 ++++++++++++++++++ tools/rel_sieve.py | 2 - 12 files changed, 934 insertions(+), 87 deletions(-) create mode 100644 include/c/c_lib.h create mode 100644 include/d/d_pad.h create mode 100644 src/toBeSorted/attention.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index fc0eb072..a9b859b9 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -146,6 +146,14 @@ toBeSorted/arc_managers/layout_arc_manager.cpp: .sdata start:0x80571D68 end:0x80571D70 .sbss start:0x80575288 end:0x80575290 +toBeSorted/attention.cpp: + .text start:0x80093A80 end:0x80096EAC + .ctors start:0x804DB6B8 end:0x804DB6BC + .rodata start:0x804E3560 end:0x804E3580 + .data start:0x8050F1C8 end:0x8050F540 + .sdata2 start:0x80579600 end:0x80579638 + .bss start:0x805A2F58 end:0x805A2FB0 + toBeSorted/dowsing_target.cpp: .text start:0x80097570 end:0x80098574 .ctors start:0x804DB6BC end:0x804DB6C0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c47e5690..a7f584d7 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1257,8 +1257,8 @@ fn_800337D0 = .text:0x800337D0; // type:function size:0xB4 fn_80033890 = .text:0x80033890; // type:function size:0xAC fn_80033940 = .text:0x80033940; // type:function size:0x14 fn_80033960 = .text:0x80033960; // type:function size:0x284 -fn_80033BF0 = .text:0x80033BF0; // type:function size:0x14 -fn_80033C10 = .text:0x80033C10; // type:function size:0x58 +__ct__24dAcRef_c<12dAcObjBase_c>Fv = .text:0x80033BF0; // type:function size:0x14 +__dt__24dAcRef_c<12dAcObjBase_c>Fv = .text:0x80033C10; // type:function size:0x58 fn_80033C70 = .text:0x80033C70; // type:function size:0x74 fn_80033CF0 = .text:0x80033CF0; // type:function size:0x5C fn_80033D50 = .text:0x80033D50; // type:function size:0x9C @@ -2360,7 +2360,7 @@ fn_80059660 = .text:0x80059660; // type:function size:0x18 fn_80059680 = .text:0x80059680; // type:function size:0x18 fn_800596A0 = .text:0x800596A0; // type:function size:0x18 fn_800596C0 = .text:0x800596C0; // type:function size:0x18 -fn_800596E0 = .text:0x800596E0; // type:function size:0x18 +checkButtonZPressed__4dPadFv = .text:0x800596E0; // type:function size:0x18 fn_80059700 = .text:0x80059700; // type:function size:0x18 fn_80059720 = .text:0x80059720; // type:function size:0x18 fn_80059740 = .text:0x80059740; // type:function size:0x18 @@ -2375,7 +2375,7 @@ isAllPressed__Q23EGG14CoreControllerFv = .text:0x80059840; // type:function size fn_80059860 = .text:0x80059860; // type:function size:0x18 fn_80059880 = .text:0x80059880; // type:function size:0x18 fn_800598A0 = .text:0x800598A0; // type:function size:0x18 -fn_800598C0 = .text:0x800598C0; // type:function size:0x18 +checkButtonZHeld__4dPadFv = .text:0x800598C0; // type:function size:0x18 fn_800598E0 = .text:0x800598E0; // type:function size:0x18 fn_80059900 = .text:0x80059900; // type:function size:0x18 fn_80059920 = .text:0x80059920; // type:function size:0x18 @@ -3329,60 +3329,61 @@ fn_800937D0 = .text:0x800937D0; // type:function size:0x98 fn_80093870 = .text:0x80093870; // type:function size:0xA4 fn_80093920 = .text:0x80093920; // type:function size:0xA4 fn_800939D0 = .text:0x800939D0; // type:function size:0xA4 -fn_80093A80 = .text:0x80093A80; // type:function size:0x1C -fn_80093AA0 = .text:0x80093AA0; // type:function size:0x40 -fn_80093AE0 = .text:0x80093AE0; // type:function size:0x4 -fn_80093AF0 = .text:0x80093AF0; // type:function size:0x4 -fn_80093B00 = .text:0x80093B00; // type:function size:0x44 -fn_80093B50 = .text:0x80093B50; // type:function size:0x98 -fn_80093BF0 = .text:0x80093BF0; // type:function size:0x48 -fn_80093C40 = .text:0x80093C40; // type:function size:0x68 -fn_80093CB0 = .text:0x80093CB0; // type:function size:0x4 -fn_80093CC0 = .text:0x80093CC0; // type:function size:0x40 -fn_80093D00 = .text:0x80093D00; // type:function size:0x80 -fn_80093D80 = .text:0x80093D80; // type:function size:0x64 -fn_80093DF0 = .text:0x80093DF0; // type:function size:0x98 -fn_80093E90 = .text:0x80093E90; // type:function size:0xA8 -fn_80093F40 = .text:0x80093F40; // type:function size:0xCC -fn_80094010 = .text:0x80094010; // type:function size:0x19C -fn_800941B0 = .text:0x800941B0; // type:function size:0x204 -fn_800943C0 = .text:0x800943C0; // type:function size:0x98 -fn_80094460 = .text:0x80094460; // type:function size:0x4 -fn_80094470 = .text:0x80094470; // type:function size:0x4 -fn_80094480 = .text:0x80094480; // type:function size:0x8 -fn_80094490 = .text:0x80094490; // type:function size:0x4C -fn_800944E0 = .text:0x800944E0; // type:function size:0xB4 -fn_800945A0 = .text:0x800945A0; // type:function size:0x284 -fn_80094830 = .text:0x80094830; // type:function size:0xCA4 -fn_800954E0 = .text:0x800954E0; // type:function size:0x50 -fn_80095530 = .text:0x80095530; // type:function size:0x654 -fn_80095B90 = .text:0x80095B90; // type:function size:0xBC +getPosCopy3__FRC12dAcObjBase_c = .text:0x80093A80; // type:function size:0x1C +__dt__12UnkAttnClassFv = .text:0x80093AA0; // type:function size:0x40 +init__12UnkAttnClassFv = .text:0x80093AE0; // type:function size:0x4 +remove__12UnkAttnClassFv = .text:0x80093AF0; // type:function size:0x4 +__ct__12UnkAttnClassFv = .text:0x80093B00; // type:function size:0x44 +__ct__16AttentionManagerFv = .text:0x80093B50; // type:function size:0x98 +__ct__14AttentionGroupFv = .text:0x80093BF0; // type:function size:0x48 +__ct__13AttentionPoolFv = .text:0x80093C40; // type:function size:0x68 +__ct__13AttentionInfoFv = .text:0x80093CB0; // type:function size:0x4 +__dt__13AttentionInfoFv = .text:0x80093CC0; // type:function size:0x40 +__dt__13AttentionPoolFv = .text:0x80093D00; // type:function size:0x80 +__dt__14AttentionGroupFv = .text:0x80093D80; // type:function size:0x64 +__ct__14InteractionMdlFv = .text:0x80093DF0; // type:function size:0x98 +__dt__14InteractionMdlFv = .text:0x80093E90; // type:function size:0xA8 +__dt__16AttentionManagerFv = .text:0x80093F40; // type:function size:0xCC +create__16AttentionManagerFv = .text:0x80094010; // type:function size:0x19C +createHeap__16AttentionManagerFv = .text:0x800941B0; // type:function size:0x204 +isInNormalGameState__16AttentionManagerCFv = .text:0x800943C0; // type:function size:0x98 +isZButtonPressed__16AttentionManagerCFv = .text:0x80094460; // type:function size:0x4 +isZButtonHeld__16AttentionManagerCFv = .text:0x80094470; // type:function size:0x4 +checkUnknown__16AttentionManagerCFv = .text:0x80094480; // type:function size:0x8 +checkLink1__16AttentionManagerCFv = .text:0x80094490; // type:function size:0x4C +checkLink2__16AttentionManagerCFv = .text:0x800944E0; // type:function size:0xB4 +execute__16AttentionManagerFv = .text:0x800945A0; // type:function size:0x284 +switchTarget__16AttentionManagerFl = .text:0x80094830; // type:function size:0xCA4 +debugPrint8__FPCce = .text:0x800954E0; // type:function size:0x50 +playTargetAnim__16AttentionManagerFl = .text:0x80095530; // type:function size:0x654 +draw__16AttentionManagerFv = .text:0x80095B90; // type:function size:0xBC fn_80095C50 = .text:0x80095C50; // type:function size:0x70 fn_80095CC0 = .text:0x80095CC0; // type:function size:0x70 fn_80095D30 = .text:0x80095D30; // type:function size:0x70 -fn_80095DA0 = .text:0x80095DA0; // type:function size:0x3E8 -fn_80096190 = .text:0x80096190; // type:function size:0xEC -fn_80096280 = .text:0x80096280; // type:function size:0x230 -fn_800964B0 = .text:0x800964B0; // type:function size:0xBC +addTarget__16AttentionManagerFR12dAcObjBase_cRC20InteractionTargetDefUlP7mVec3_c = .text:0x80095DA0; // type:function size:0x3E8 +fn_80096190__13AttentionPoolFP12dAcObjBase_cUc15InteractionType = .text:0x80096190; // type:function size:0xEC +insertTarget__13AttentionPoolFP12dAcObjBase_cUlP7mVec3_c15InteractionTypeUcf = .text:0x80096280; // type:function size:0x230 +fn_800964B0__14AttentionGroupFv = .text:0x800964B0; // type:function size:0xBC fn_80096570 = .text:0x80096570; // type:function size:0x10C fn_80096680 = .text:0x80096680; // type:function size:0x3DC fn_80096A60 = .text:0x80096A60; // type:function size:0x50 -fn_80096AB0 = .text:0x80096AB0; // type:function size:0x88 -fn_80096B40 = .text:0x80096B40; // type:function size:0x80 -fn_80096BC0 = .text:0x80096BC0; // type:function size:0x18 -fn_80096BE0 = .text:0x80096BE0; // type:function size:0x20 -addTarget__12dAttention_cFP9dAcBase_clffff = .text:0x80096C00; // type:function size:0x28 -addTarget__12dAttention_cFP9dAcBase_clfff = .text:0x80096C30; // type:function size:0x28 -fn_80096C60 = .text:0x80096C60; // type:function size:0x30 -fn_80096C90 = .text:0x80096C90; // type:function size:0x34 -fn_80096CD0 = .text:0x80096CD0; // type:function size:0x30 -fn_80096D00 = .text:0x80096D00; // type:function size:0x50 -fn_80096D50 = .text:0x80096D50; // type:function size:0x28 -fn_80096D80 = .text:0x80096D80; // type:function size:0x38 -fn_80096DC0 = .text:0x80096DC0; // type:function size:0x28 -fn_80096DF0 = .text:0x80096DF0; // type:function size:0x28 -fn_80096E20 = .text:0x80096E20; // type:function size:0x68 -fn_80096E90 = .text:0x80096E90; // type:function size:0x1C +targetScore__16AttentionManagerFP12dAcObjBase_cP12dAcObjBase_c = .text:0x80096AB0; // type:function size:0x88 +fn_80096B40__16AttentionManagerFP12dAcObjBase_c = .text:0x80096B40; // type:function size:0x80 +addPickUpTarget__16AttentionManagerFR12dAcObjBase_cf = .text:0x80096BC0; // type:function size:0x18 +addSitTarget__16AttentionManagerFR12dAcObjBase_cUlf = .text:0x80096BE0; // type:function size:0x20 +addExamineTalkTarget__16AttentionManagerFR12dAcObjBase_cUlffff = .text:0x80096C00; // type:function size:0x28 +addExamineTalkTarget__16AttentionManagerFR12dAcObjBase_cUlfff = .text:0x80096C30; // type:function size:0x28 +addCatchTarget__16AttentionManagerFR12dAcObjBase_cUlfff = .text:0x80096C60; // type:function size:0x30 +addCatchLikeTarget__16AttentionManagerFR12dAcObjBase_c15InteractionTypeUlfff = .text:0x80096C90; // type:function size:0x34 +addUnk3Target__16AttentionManagerFR12dAcObjBase_cUlfff = .text:0x80096CD0; // type:function size:0x30 +addUnk3Target__16AttentionManagerFR12dAcObjBase_cUlffff = .text:0x80096D00; // type:function size:0x10 +addUnk3Target__16AttentionManagerFR12dAcObjBase_cUlP7mVec3_cUlffff = .text:0x80096D10; // type:function size:0x40 +addNpcTalkTarget__16AttentionManagerFR12dAcObjBase_cUlffff = .text:0x80096D50; // type:function size:0x28 +addUnk7Target__16AttentionManagerFR12dAcObjBase_cUlffff = .text:0x80096D80; // type:function size:0x38 +addReadTarget__16AttentionManagerFR12dAcObjBase_cUlffff = .text:0x80096DC0; // type:function size:0x28 +addReadTarget2__16AttentionManagerFR12dAcObjBase_cUlfff = .text:0x80096DF0; // type:function size:0x28 +__sinit_\attention_cpp = .text:0x80096E20; // type:function size:0x68 +__arraydtor$6436 = .text:0x80096E90; // type:function size:0x1C fn_80096EB0 = .text:0x80096EB0; // type:function size:0x154 fn_80097010 = .text:0x80097010; // type:function size:0x8 fn_80097020 = .text:0x80097020; // type:function size:0x14C @@ -17273,7 +17274,7 @@ fn_802E0190 = .text:0x802E0190; // type:function size:0x13C fn_802E02D0 = .text:0x802E02D0; // type:function size:0xF8 fn_802E03D0 = .text:0x802E03D0; // type:function size:0x174 fn_802E0550 = .text:0x802E0550; // type:function size:0x124 -fn_802E0680 = .text:0x802E0680; // type:function size:0x1C +targetAngleY__4cLibFRC7mVec3_cRC7mVec3_c = .text:0x802E0680; // type:function size:0x1C fn_802E06A0 = .text:0x802E06A0; // type:function size:0x68 fn_802E0710 = .text:0x802E0710; // type:function size:0xD8 fn_802E07F0 = .text:0x802E07F0; // type:function size:0x24 @@ -28205,7 +28206,7 @@ lbl_804E3458 = .rodata:0x804E3458; // type:object size:0x38 data:4byte lbl_804E3490 = .rodata:0x804E3490; // type:object size:0x3C data:4byte lbl_804E34CC = .rodata:0x804E34CC; // type:object size:0x3C data:4byte lbl_804E3508 = .rodata:0x804E3508; // type:object size:0x58 data:4byte -lbl_804E3560 = .rodata:0x804E3560; // type:object size:0x20 data:4byte +s_Cursors = .rodata:0x804E3560; // type:object size:0x20 scope:local data:4byte lbl_804E3580 = .rodata:0x804E3580; // type:object size:0x118 data:4byte DOWSING_TARGET_STORY_FLAGS = .rodata:0x804E3698; // type:object size:0x20 lbl_804E36B8 = .rodata:0x804E36B8; // type:object size:0x10 data:4byte @@ -30855,20 +30856,21 @@ lbl_8050F208 = .data:0x8050F208; // type:object size:0xC lbl_8050F214 = .data:0x8050F214; // type:object size:0x14 lbl_8050F228 = .data:0x8050F228; // type:object size:0x10 data:string lbl_8050F238 = .data:0x8050F238; // type:object size:0x80 -lbl_8050F2B8 = .data:0x8050F2B8; // type:object size:0x30 -lbl_8050F2E8 = .data:0x8050F2E8; // type:object size:0x60 -lbl_8050F348 = .data:0x8050F348; // type:object size:0x30 -lbl_8050F378 = .data:0x8050F378; // type:object size:0x30 -lbl_8050F3A8 = .data:0x8050F3A8; // type:object size:0x30 -lbl_8050F3D8 = .data:0x8050F3D8; // type:object size:0x30 -lbl_8050F408 = .data:0x8050F408; // type:object size:0x30 -lbl_8050F438 = .data:0x8050F438; // type:object size:0x30 -lbl_8050F468 = .data:0x8050F468; // type:object size:0x30 -lbl_8050F498 = .data:0x8050F498; // type:object size:0x30 -lbl_8050F4C8 = .data:0x8050F4C8; // type:object size:0x30 -lbl_8050F4F8 = .data:0x8050F4F8; // type:object size:0x30 -lbl_8050F528 = .data:0x8050F528; // type:object size:0xC -lbl_8050F534 = .data:0x8050F534; // type:object size:0xC +@LOCAL@addPickUpTarget__16AttentionManagerFR12dAcObjBase_cf@pickUpTarget = .data:0x8050F2B8; // type:object size:0x30 +@LOCAL@addSitTarget__16AttentionManagerFR12dAcObjBase_cUlf@sitTarget = .data:0x8050F2E8; // type:object size:0x30 +@LOCAL@addTalkTarget_unused__16AttentionManagerFR12dAcObjBase_c@talkTarget = .data:0x8050F318; // type:object size:0x30 +@LOCAL@addExamineTalkTarget__16AttentionManagerFR12dAcObjBase_cUlffff@examineTalkTarget = .data:0x8050F348; // type:object size:0x30 +@LOCAL@addExamineTalkTarget__16AttentionManagerFR12dAcObjBase_cUlfff@examineTalkTarget2 = .data:0x8050F378; // type:object size:0x30 +@LOCAL@addCatchTarget__16AttentionManagerFR12dAcObjBase_cUlfff@catchTarget = .data:0x8050F3A8; // type:object size:0x30 +@LOCAL@addCatchLikeTarget__16AttentionManagerFR12dAcObjBase_c15InteractionTypeUlfff@catchTarget2 = .data:0x8050F3D8; // type:object size:0x30 +@LOCAL@addUnk3Target__16AttentionManagerFR12dAcObjBase_cUlfff@unk3Target = .data:0x8050F408; // type:object size:0x30 +@LOCAL@addUnk3Target__16AttentionManagerFR12dAcObjBase_cUlP7mVec3_cUlffff@unk3Target2 = .data:0x8050F438; // type:object size:0x30 +@LOCAL@addNpcTalkTarget__16AttentionManagerFR12dAcObjBase_cUlffff@talkTarget = .data:0x8050F468; // type:object size:0x30 +@LOCAL@addUnk7Target__16AttentionManagerFR12dAcObjBase_cUlffff@unk7Target = .data:0x8050F498; // type:object size:0x30 +@LOCAL@addReadTarget__16AttentionManagerFR12dAcObjBase_cUlffff@readTarget = .data:0x8050F4C8; // type:object size:0x30 +@LOCAL@addReadTarget2__16AttentionManagerFR12dAcObjBase_cUlfff@readTarget2 = .data:0x8050F4F8; // type:object size:0x30 +__vt__12UnkAttnClass = .data:0x8050F528; // type:object size:0xC +__vt__16AttentionManager = .data:0x8050F534; // type:object size:0xC lbl_8050F540 = .data:0x8050F540; // type:object size:0x10 data:4byte __vt__13DowsingTarget = .data:0x8050F550; // type:object size:0x10 lbl_8050F560 = .data:0x8050F560; // type:object size:0xC data:string @@ -39885,7 +39887,7 @@ lbl_8057535C = .sbss:0x8057535C; // type:object size:0x4 data:4byte lbl_80575360 = .sbss:0x80575360; // type:object size:0x4 data:4byte lbl_80575364 = .sbss:0x80575364; // type:object size:0x4 data:4byte lbl_80575368 = .sbss:0x80575368; // type:object size:0x8 data:4byte -sInstance__12dAttention_c = .sbss:0x80575370; // type:object size:0x8 data:4byte +sInstance__16AttentionManager = .sbss:0x80575370; // type:object size:0x8 data:4byte lbl_80575378 = .sbss:0x80575378; // type:object size:0x4 data:4byte lbl_8057537C = .sbss:0x8057537C; // type:object size:0xC data:byte lbl_80575388 = .sbss:0x80575388; // type:object size:0x8 data:byte @@ -48265,8 +48267,8 @@ lbl_805A2DE8 = .bss:0x805A2DE8; // type:object size:0xA8 data:byte lbl_805A2E90 = .bss:0x805A2E90; // type:object size:0x88 data:byte lbl_805A2F18 = .bss:0x805A2F18; // type:object size:0x40 lbl_805A2F58 = .bss:0x805A2F58; // type:object size:0x10 -lbl_805A2F68 = .bss:0x805A2F68; // type:object size:0x30 -lbl_805A2F98 = .bss:0x805A2F98; // type:object size:0x18 +attnVectors = .bss:0x805A2F68; // type:object size:0x30 +attnClass = .bss:0x805A2F98; // type:object size:0x18 DOWSING_LISTS = .bss:0x805A2FB0; // type:object size:0x60 lbl_805A3010 = .bss:0x805A3010; // type:object size:0x18 lbl_805A3028 = .bss:0x805A3028; // type:object size:0xF78 data:byte diff --git a/configure.py b/configure.py index bddfee25..b0c6934c 100644 --- a/configure.py +++ b/configure.py @@ -333,6 +333,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Object(Matching, "toBeSorted/arc_managers/current_stage_arc_manager.cpp"), Object(Matching, "toBeSorted/arc_managers/oarc_manager.cpp"), Object(Matching, "toBeSorted/arc_managers/layout_arc_manager.cpp"), + Object(NonMatching, "toBeSorted/attention.cpp"), Object(NonMatching, "toBeSorted/dowsing_target.cpp"), Object(NonMatching, "toBeSorted/time_area_mgr.cpp"), Object(Matching, "toBeSorted/save_file.cpp"), diff --git a/include/c/c_lib.h b/include/c/c_lib.h new file mode 100644 index 00000000..823955aa --- /dev/null +++ b/include/c/c_lib.h @@ -0,0 +1,13 @@ +#ifndef C_CLIB_H +#define C_CLIB_H + +#include +#include + +namespace cLib { + +s32 targetAngleY(const mVec3_c& target, const mVec3_c& source); + +} // namespace cLib + +#endif diff --git a/include/d/a/d_a_player.h b/include/d/a/d_a_player.h index 65fda5ce..719ebe4c 100644 --- a/include/d/a/d_a_player.h +++ b/include/d/a/d_a_player.h @@ -182,5 +182,13 @@ class dAcPy_c : public dAcObjBase_c { /* 0x360 */ UNKWORD field_0x360; /* 0x364 */ u32 mActionFlags; + inline bool checkFlags0x340(u32 mask) const { + return (someFlags_0x340 & mask) != 0; + } + + inline bool checkFlags0x350(u32 mask) const { + return (someFlags_0x350 & mask) != 0; + } + static dAcPy_c *LINK; }; diff --git a/include/d/d_pad.h b/include/d/d_pad.h new file mode 100644 index 00000000..e158fafb --- /dev/null +++ b/include/d/d_pad.h @@ -0,0 +1,11 @@ +#ifndef D_PAD_H +#define D_PAD_H + +class dPad { +public: + + static bool checkButtonZPressed(); + static bool checkButtonZHeld(); +}; + +#endif diff --git a/include/toBeSorted/arc_managers/oarc_manager.h b/include/toBeSorted/arc_managers/oarc_manager.h index 96c7e0d7..643dc000 100644 --- a/include/toBeSorted/arc_managers/oarc_manager.h +++ b/include/toBeSorted/arc_managers/oarc_manager.h @@ -6,10 +6,10 @@ #include class OarcManager { +public: OarcManager(); virtual ~OarcManager(); - dRawArcTable_c mArcTable; static OarcManager *sInstance; @@ -31,6 +31,8 @@ class OarcManager { void *getDzbFromArc(const char *oarcName, const char *fileName); void *getPlcFromArc(const char *oarcName, const char *fileName); void *getSubEntryData(const char *oarcName, const char *fileName); +private: + dRawArcTable_c mArcTable; }; #endif diff --git a/include/toBeSorted/attention.h b/include/toBeSorted/attention.h index 5c09489f..029194d1 100644 --- a/include/toBeSorted/attention.h +++ b/include/toBeSorted/attention.h @@ -1,16 +1,238 @@ -#ifndef ATTENTION_H -#define ATTENTION_H +#ifndef TOBESORTED_ATTENTION_H +#define TOBESORTED_ATTENTION_H #include +#include +#include +#include +#include +#include +#include +#include -class dAcBase_c; +static const u32 OFF = 'off '; +static const u32 NONE = 'none'; +static const u32 KEEP = 'keep'; +static const u32 NEXT = 'next'; +static const u32 ON = 'on '; +static const u32 AWAY = 'away'; -class dAttention_c { +class UniquePtrLike { public: - static dAttention_c *sInstance; + m3d::anmChr_c *mPtr; - void addTarget(dAcBase_c *target, s32, f32, f32, f32); - void addTarget(dAcBase_c *target, s32, f32, f32, f32, f32); + UniquePtrLike() : mPtr(nullptr) {} + ~UniquePtrLike() { + if (mPtr != nullptr) { + delete mPtr; + mPtr = nullptr; + } + } +}; + +class InteractionMdl { +public: + m3d::smdl_c mMdl; + m3d::anmMatClr_c mAnmClr; + m3d::anmTexPat_c mAnmTex; + UniquePtrLike mAnmChr; + u8 field_0x78; + u8 field_0x79; + + InteractionMdl() {} + ~InteractionMdl() {} +}; + +enum InteractionType { + UNK_0, + PICK_UP, + OPEN, + UNK_3, + TALK, + EXAMINE_TALK, + EXAMINE_6, + UNK_7, + GET_IN, + READY_SWORD, + UNK_10, + UNK_11, + READ, + GRAB, + CATCH, + UNK_15, + UNK_16, + DIG, + UNK_18, + SIT, + UNK_20, +}; + +class AttentionInfo { +public: + AttentionInfo() {} + ~AttentionInfo() {} + + /* 0x00 */ u8 unk; + /* 0x01 */ u8 mActorIdx; + /* 0x02 */ u8 mInteractionType; + /* 0x03 */ u8 field_0x03; + /* 0x04 */ f32 field_0x04; + /* 0x08 */ mVec3_c field_0x08; +}; + +class AttentionPool { +public: + AttentionPool() {} + ~AttentionPool() {} + dAcRef_c mRefs[8]; + AttentionInfo mInfos[8]; + s32 mNumUsedRefs; + + int fn_80096190(dAcObjBase_c *actor, u8 unk, InteractionType interactionType); + bool insertTarget(dAcObjBase_c *actor, u32 unk1, mVec3_c *pos, InteractionType interactionType, u8 field_0x03, + f32 field_0x04); + + dAcObjBase_c *getActor(s32 i) { + return i < mNumUsedRefs && mInfos[i].mActorIdx != -1 ? mRefs[mInfos[i].mActorIdx].get() : nullptr; + } + + void clear() { + for (int i = 0; i < 8; i++) { + mInfos[i].unk = 0; + mInfos[i].mActorIdx = -1; + mInfos[i].field_0x04 = 0.0f; + mInfos[i].field_0x03 = 0; + mInfos[i].mInteractionType = 0; + mRefs[i].unlink(); + } + mNumUsedRefs = 0; + } +}; + +class AttentionGroup { +public: + AttentionGroup() {} + ~AttentionGroup() {} + + AttentionPool mPools[2]; + u32 mWhichPool; + + AttentionPool *getOtherPool() { + return &mPools[mWhichPool ^ 1]; + } + + AttentionPool *getPool() { + return &mPools[mWhichPool]; + } + + void fn_800964B0(); +}; + +struct InteractionTargetDef { + s32 field_0x00; + u32 field_0x04; + u32 field_0x08; + InteractionType interactType; + u32 interactFlags; + f32 field_0x14; + f32 field_0x18; + f32 field_0x1C; + f32 field_0x20; + f32 field_0x24; + f32 field_0x28; + f32 field_0x2C; +}; + +// TODO this may include more things from AttentionManager, see AttentionManager's dtor +class InteractionModels { +public: + /* 0x00 */ UNKWORD field_0xA5C; + /* 0x04 */ s32 mCurrentTargetInfoIdx; + /* 0x08 */ u32 mState; + /* 0x0C */ nw4r::g3d::ResFile mResFile; + /* 0x10 */ InteractionMdl mMdls[2]; +}; + +class AttentionManager { + mHeapAllocator_c mAllocator; + /* 0x01C */ AttentionGroup mGroups[5]; + /* 0xA58 */ bool mTargeted; + /* 0xA59 */ bool mHoldingZ; + /* 0xA5A */ u8 field_0xA58[0xA5C - 0xA5A]; + /* 0xA5C */ InteractionModels mModels; + /* 0xB64 */ u8 mHasTarget; + /* 0xB65 */ u8 field_0xB65[0xB68 - 0xB65]; + /* 0xB68 */ UNKWORD field_0xB68; + /* 0xB6C */ EffectsStruct mEffect1; + /* 0xBA0 */ EffectsStruct mEffect2; + /* 0xBD4 */ u8 field_0xBD4; + /* 0xBD5 */ u8 field_0xBD5; + +public: + AttentionManager(); + /* vt at 0xBDC */ virtual ~AttentionManager(); + +private: + /* 0xBDC */ u8 field_0xBDC; + +public: + bool create(); + bool createHeap(); + bool execute(); + bool draw(); + + void addTarget(dAcObjBase_c &actor, const InteractionTargetDef &def, u32, mVec3_c *); + + void addPickUpTarget(dAcObjBase_c &actor, f32 field_0x14); + void addSitTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14); + + void addTalkTarget_unused(dAcObjBase_c &actor); + + void addExamineTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, + f32 field_0x24); + void addExamineTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x20, f32 field_0x24); + + void addCatchTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x24_neg, f32 field_0x20_neg); + + void addCatchLikeTarget(dAcObjBase_c &actor, InteractionType interactionType, u32 flags, f32 field_0x14, + f32 field_0x24_neg, f32 field_0x20_neg); + + void addUnk3Target(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x24_neg, f32 field_0x20_neg); + + void addUnk3Target(dAcObjBase_c &actor, u32 flags, f32 arg5, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg); + void addUnk3Target(dAcObjBase_c &actor, u32 arg2, mVec3_c *arg3, u32 flags, f32 arg5, f32 field_0x14, + f32 field_0x24_neg, f32 field_0x20_neg); + + void addNpcTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, f32 field_0x24); + + void addUnk7Target(dAcObjBase_c &actor, u32 flags, f32 arg5, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg); + + void addReadTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, f32 field_0x24); + void addReadTarget2(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x20, f32 field_0x24); + + static AttentionManager *sInstance; + +private: + bool isInNormalGameState() const; + bool checkZButtonPressed() const; + bool checkZButtonHeld() const; + bool checkLink1() const; + bool checkLink2() const; + bool switchTarget(s32 target); + bool playTargetAnim(s32 target); + + bool isZButtonPressed() const; + bool isZButtonHeld() const; + bool checkUnknown() const; + + bool collisionCheck0(const mVec3_c &a, const mVec3_c &b); + bool collisionCheck1(const mVec3_c &a, const mVec3_c &b); + bool collisionCheck2(const mVec3_c &a, const mVec3_c &b); + + bool fn_80096B40(dAcObjBase_c *actor); + f32 targetScore(dAcObjBase_c *target, dAcObjBase_c *origin); }; #endif diff --git a/include/toBeSorted/event_manager.h b/include/toBeSorted/event_manager.h index e95d8db4..6f750068 100644 --- a/include/toBeSorted/event_manager.h +++ b/include/toBeSorted/event_manager.h @@ -1,3 +1,4 @@ + #ifndef EVENT_MANAGER_H #define EVENT_MANAGER_H @@ -11,6 +12,18 @@ class EventManager { static bool alsoSetAsCurrentEvent(dAcBase_c *actor, Event *event, void *unknown); static EventManager *sInstance; + + static bool isInEvent() { + return sInstance != nullptr && sInstance->mState != 0; + } + + static bool isInEventOtherThan7() { + return isInEvent() && sInstance != nullptr && sInstance->mState != 7; + } + +private: + u8 field_0x000[0x184 - 0x000]; + int mState; }; #endif diff --git a/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp b/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp index 898286d6..b032c0bc 100644 --- a/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp +++ b/src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include SPECIAL_ACTOR_PROFILE(OBJ_TOD3_STONE, dAcOtoD3StoneFigure_c, fProfile::OBJ_TOD3_STONE, 0x1B3, 0, 0); @@ -76,20 +76,20 @@ int dAcOtoD3StoneFigure_c::create() { } int dAcOtoD3StoneFigure_c::doDelete() { - return 1; + return SUCCEEDED; } int dAcOtoD3StoneFigure_c::actorExecute() { mStateMgr.executeState(); ColliderManager::getColliderManager()->addCollider(&mCollision); - return 1; + return SUCCEEDED; } int dAcOtoD3StoneFigure_c::draw() { if (ScGame::currentSpawnInfo.layer != 0x12) { drawModelType1(&mMdl); } - return 1; + return SUCCEEDED; } void dAcOtoD3StoneFigure_c::initializeState_OneEye() { @@ -107,8 +107,8 @@ void dAcOtoD3StoneFigure_c::executeState_OneEye() { if (hasStoneOfTrials() && ScGame::currentSpawnInfo.night != 1) { // These are interaction related -0.0f; - dAttention_c::sInstance->addTarget(this, 1, 300.0f, 50.0f, -100.0f, 100.0f); - dAttention_c::sInstance->addTarget(this, 1, 200.0f, -100.0f, 100.0f); + AttentionManager::sInstance->addExamineTalkTarget(*this, 1, 300.0f, 50.0f, -100.0f, 100.0f); + AttentionManager::sInstance->addExamineTalkTarget(*this, 1, 200.0f, -100.0f, 100.0f); } } } diff --git a/src/toBeSorted/attention.cpp b/src/toBeSorted/attention.cpp new file mode 100644 index 00000000..0093ae88 --- /dev/null +++ b/src/toBeSorted/attention.cpp @@ -0,0 +1,569 @@ +#include +#include +#include +#include +#include +#include + +mVec3_c attnVectors[4]; + +mVec3_c getPosCopy3(const dAcObjBase_c &actor) { + return actor.poscopy3; +} + +class UnkAttnClass { +public: + u8 field_0x00; + UnkAttnClass(); + virtual ~UnkAttnClass() {} + + void init(); + void remove(); + + u16 field_0x08; + u16 field_0x0A; + u16 field_0x0C; + u16 field_0x0E; + u16 field_0x10; + u16 field_0x12; + f32 field_0x14; +}; + +void UnkAttnClass::init() { + +} + +void UnkAttnClass::remove() { + +} + +UnkAttnClass::UnkAttnClass() + : field_0x00(0), field_0x08(field_0x00 | 8), field_0x0A(300), field_0x0C(30), field_0x10(30), field_0x12(10), + field_0x14(1.0f) {} + +UnkAttnClass attnClass; + +AttentionManager::AttentionManager() { + sInstance = this; +} + +AttentionManager::~AttentionManager() { + attnClass.remove(); + sInstance = nullptr; +} + +struct CursorStruct { + const char *mMdlName; + const char *mAnmClrName; + const char *mAnmTexPatName; + const char *anmChrName; +}; + +bool AttentionManager::create() { + for (int i = 0; i < 5; i++) { + mGroups[i].mWhichPool = 0; + mGroups[i].getPool()->clear(); + mGroups[i].getOtherPool()->clear(); + } + + + mModels.field_0xA5C = 0; + mModels.mCurrentTargetInfoIdx = 0; + mModels.mState = NONE; + mTargeted = false; + field_0xB68 = 0; + attnClass.init(); + field_0xBDC = 0; + field_0xBD5 = 0; + field_0xBD4 = 0; + + if (!mAllocator.createNewTempFrmHeap(-1, dHeap::work1Heap.heap, "Attention", 0x20, 0)) { + return 0; + } + mModels.mMdls[0].field_0x79 = 0; + mModels.mMdls[1].field_0x79 = 0; + mModels.mMdls[0].field_0x78 = 0; + mModels.mMdls[1].field_0x78 = 0; + bool success = createHeap(); + mAllocator.adjustFrmHeapRestoreCurrent(); + mHasTarget = 0; + return success; +} + +static const CursorStruct s_Cursors[2] = {{"ZcursorA", "ZcursorAInOut_00", "ZcursorALoop_00", nullptr}, + {"ZcursorB", "ZcursorBIn_00", "ZcursorBLoop_00", "ZcursorBIn_00"}}; + +bool AttentionManager::createHeap() { + mModels.mResFile = OarcManager::sInstance->getMdlFromArc2("UI_Data"); + + for (int i = 0; i < 2; i++) { + InteractionMdl *iMdl = &mModels.mMdls[i]; + nw4r::g3d::ResMdl m = mModels.mResFile.GetResMdl(s_Cursors[i].mMdlName); + if (!iMdl->mMdl.create(m, &mAllocator, 0, 1, nullptr)) { + return false; + } + iMdl->mMdl.setPriorityDraw(0x7F, 0x90); + nw4r::g3d::ResAnmClr anmClr = mModels.mResFile.GetResAnmClr(s_Cursors[i].mAnmClrName); + if (!iMdl->mAnmClr.create(m, anmClr, &mAllocator, 0, 1)) { + return false; + } + iMdl->mMdl.setAnm(iMdl->mAnmClr); + nw4r::g3d::ResAnmTexPat anmTexPat = mModels.mResFile.GetResAnmTexPat(s_Cursors[i].mAnmTexPatName); + if (!iMdl->mAnmTex.create(m, anmTexPat, &mAllocator, 0, 1)) { + return false; + } + iMdl->mMdl.setAnm(iMdl->mAnmTex); + if (s_Cursors[i].anmChrName != nullptr) { + m3d::anmChr_c *anm = iMdl->mAnmChr.mPtr = new m3d::anmChr_c(); + if (!anm) { + return false; + } + nw4r::g3d::ResAnmChr anmChr = mModels.mResFile.GetResAnmChr(s_Cursors[i].anmChrName); + if (!iMdl->mAnmChr.mPtr->create(m, anmChr, &mAllocator, nullptr)) { + return false; + } + iMdl->mMdl.setAnm(*iMdl->mAnmChr.mPtr); + } + } + + return true; +} + +bool AttentionManager::isInNormalGameState() const { + return false; +} + +bool AttentionManager::isZButtonPressed() const { + return dPad::checkButtonZPressed(); +} + +bool AttentionManager::isZButtonHeld() const { + return dPad::checkButtonZHeld(); +} + +bool AttentionManager::checkUnknown() const { + return false; +} + +bool AttentionManager::checkLink1() const { + dAcPy_c *link = dAcPy_c::LINK; + if (!isInNormalGameState() || !link->checkFlags0x350(0x40000)) { + return false; + } + return true; +} + +bool AttentionManager::checkLink2() const {} + +bool AttentionManager::execute() { + field_0xBDC = 0; + if (!isInNormalGameState() && !field_0xBD5) { + if (!EventManager::isInEvent() && !EventManager::isInEventOtherThan7()) { + return false; + } + + mModels.mState = NONE; + mTargeted = false; + return false; + } + + for (int i = 0; i < 5; i++) { + if (i != 1) { + mGroups[i].mWhichPool %= 2; + } + } + + switchTarget(1); + playTargetAnim(1); + return true; +} + +void debugPrint8(const char *msg, ...); + +bool AttentionManager::switchTarget(s32 idx) { + if (field_0xBD5) { + mGroups[idx].getPool()->clear(); + return true; + } else { + if (!checkLink1()) { + mGroups[idx].mWhichPool = 0; + mGroups[idx].getPool()->clear(); + mGroups[idx].getOtherPool()->clear(); + } else { + bool zPressed = checkZButtonPressed(); + mHoldingZ = checkZButtonHeld(); + AttentionPool *left = mGroups[idx].getPool(); + AttentionPool *right = mGroups[idx].getOtherPool(); + if ((attnClass.field_0x08 & 8) != 0 && (mModels.mState == OFF || mModels.mState == NONE) && checkLink2() && right->mNumUsedRefs != 0) { + zPressed = true; + } + + if (checkUnknown() && mModels.mState != AWAY) { + mModels.mState = OFF; + mTargeted = false; + } + } + } + + + debugPrint8("%4.4s -> %4.4s (%c pos=%d, cnt=%d)"); +} + +void debugPrint8(const char *msg, ...) {} + +bool AttentionManager::playTargetAnim(s32 idx) { + if (mModels.mMdls[1].field_0x79) { + mModels.mMdls[1].mMdl.play(); + mModels.mMdls[1].mAnmTex.play(); + if (mModels.mMdls[1].mAnmChr.mPtr != nullptr) { + if (mModels.mMdls[1].mAnmChr.mPtr->isStop()) { + nw4r::g3d::ResAnmChr anmChr = mModels.mResFile.GetResAnmChr("ZcursorBLoop_00"); + mModels.mMdls[1].mAnmChr.mPtr->setAnm(mModels.mMdls[1].mMdl, anmChr, m3d::PLAY_MODE_4); + mModels.mMdls[1].mMdl.setAnm(*mModels.mMdls[1].mAnmChr.mPtr); + } else { + mModels.mMdls[1].mAnmChr.mPtr->play(); + } + } + } + + if (mModels.mMdls[0].field_0x79) { + mModels.mMdls[0].mMdl.play(); + mModels.mMdls[0].mAnmTex.play(); + if (mModels.mMdls[0].field_0x78 && mModels.mMdls[0].mAnmChr.mPtr->isStop()) { + nw4r::g3d::ResAnmClr anmClr = mModels.mResFile.GetResAnmClr("ZcursorALoop_00"); + mModels.mMdls[0].mAnmClr.setAnm(mModels.mMdls[1].mMdl, anmClr, 0, m3d::PLAY_MODE_4); + } + } + + bool doSomething = false; + + dAcObjBase_c *actor = mGroups[idx].getOtherPool()->getActor(mModels.mCurrentTargetInfoIdx); + if (actor != nullptr) { + AttentionPool *pool = mGroups[idx].getOtherPool(); + dAcObjBase_c *actor = pool->getActor(mModels.mCurrentTargetInfoIdx); + mMtx_c mtx; + mVec3_c v = pool->mInfos[mModels.mCurrentTargetInfoIdx].field_0x08; + PSMTXTrans(mtx, v.x, v.y, v.z); + + mModels.mMdls->mMdl.setLocalMtx(mtx); + mModels.mMdls->mMdl.setScale(attnClass.field_0x14, attnClass.field_0x14, attnClass.field_0x14); + doSomething = true; + } + + if (mModels.mState != NONE) {} + + // TODO this is just temporarily here for data segments + nw4r::g3d::ResAnmClr anmClr = mModels.mResFile.GetResAnmClr("ZcursorBIn_00"); + anmClr = mModels.mResFile.GetResAnmClr("ZcursorBOut_00"); + + if (doSomething) { + if (mModels.mMdls[0].field_0x79 == 0 || mModels.mMdls[0].field_0x78 != 0) { + nw4r::g3d::ResAnmClr anmClr = mModels.mResFile.GetResAnmClr("ZcursorAInOut_00"); + mModels.mMdls[0].mAnmClr.setAnm(mModels.mMdls[0].mMdl, anmClr, 0, m3d::PLAY_MODE_4); + mModels.mMdls[0].field_0x78 = 0; + } + mModels.mMdls[0].field_0x79 = 1; + } else if (mModels.mMdls[0].field_0x79 != 0) { + if (mModels.mMdls[0].field_0x78 != 0) { + if (mModels.mMdls[0].mAnmClr.isStop(0)) { + mModels.mMdls[0].field_0x79 = 0; + } + } else { + nw4r::g3d::ResAnmClr anmClr = mModels.mResFile.GetResAnmClr("ZcursorAInOut_00"); + mModels.mMdls[0].mAnmClr.setAnm(mModels.mMdls[0].mMdl, anmClr, 0, m3d::PLAY_MODE_3); + mModels.mMdls[0].field_0x78 = 1; + } + } + + return true; +} + +bool AttentionManager::draw() { + if (mHasTarget || !(isInNormalGameState() || field_0xBD5)) { + mHasTarget = 0; + mModels.mMdls[0].field_0x79 = 0; + mModels.mMdls[1].field_0x79 = 0; + return true; + } else { + mHasTarget = 0; + if (mModels.mMdls[1].field_0x79 && !field_0xBD4) { + mModels.mMdls[1].mMdl.entry(); + } + if (mModels.mMdls[0].field_0x79 != 0) { + mModels.mMdls[0].mMdl.entry(); + } + return true; + } +} + +void AttentionManager::addTarget(dAcObjBase_c &, const InteractionTargetDef &, u32, mVec3_c *) {} + +int AttentionPool::fn_80096190(dAcObjBase_c *actor, u8 arg, InteractionType arg2) { + s32 interactType = (s32)arg2 != UNK_16 ? arg2 : -1; + + for (int i = 0; i < mNumUsedRefs; i++) { + s32 bVar4 = i < mNumUsedRefs ? mInfos[i].mInteractionType : UNK_0; + + s32 IVar4 = bVar4 == UNK_16 ? interactType : i < mNumUsedRefs ? mInfos[i].mInteractionType : UNK_0; + + dAcObjBase_c *existingActor = getActor(i); + if (existingActor == actor) { + s32 unk; + if (i < mNumUsedRefs) { + unk = mInfos[i].unk; + } else { + unk = -1; + } + if (arg == unk && (IVar4 == interactType || interactType == -1)) { + return i; + } + } + } + + return -1; +} + +bool AttentionPool::insertTarget(dAcObjBase_c *actor, u32 unk1, mVec3_c *pos, InteractionType interactionType, + u8 field_0x03, f32 field_0x04) { + // Bunch of regshuffles + for (s32 i = 0; i < 8; i++) { + if (i >= mNumUsedRefs) { + // Free slot, just use that + mRefs[mNumUsedRefs].link(actor); + mInfos[i].unk = unk1; + mInfos[i].mActorIdx = i; + mInfos[i].field_0x04 = field_0x04; + mInfos[i].mInteractionType = interactionType; + mInfos[i].field_0x08 = *pos; + mInfos[i].field_0x03 = field_0x03; + mNumUsedRefs++; + break; + } + + if (field_0x04 > mInfos[i].field_0x04) { + s32 idx = mNumUsedRefs; + if (mNumUsedRefs < 8) { + mNumUsedRefs = mNumUsedRefs + 1; + } else { + s32 oldSlot = mNumUsedRefs - 1; + idx = mInfos[oldSlot].mActorIdx; + mRefs[mInfos[oldSlot].mActorIdx].unlink(); + } + + s32 y = mNumUsedRefs - 1; + s32 end = y; + s32 target = y; + s32 x = target; + // For some reason the comparison happens in reverse here lol + for (s32 j = i; j < end; j++) { + s32 vec_idx = y - 1; + mInfos[target].unk = mInfos[x - 1].unk; + s32 actorIdx = mInfos[x - 1].mActorIdx; + mInfos[target].mActorIdx = mInfos[x - 1].mActorIdx; + mInfos[target].mInteractionType = mInfos[x - 1].mInteractionType; + mInfos[target].field_0x03 = mInfos[x - 1].field_0x03; + mInfos[target].field_0x04 = mInfos[x - 1].field_0x04; + mInfos[target].field_0x08 = mInfos[vec_idx].field_0x08; + + if (actorIdx != -1 && (actor != mRefs[actorIdx].get() || (s32)unk1 != mInfos[target].unk)) { + target--; + } + + x--; + y--; + } + + mRefs[idx].link(actor); + mInfos[i].mActorIdx = i; + mInfos[i].unk = unk1; + mInfos[i].field_0x04 = field_0x04; + mInfos[i].mInteractionType = interactionType; + mInfos[i].field_0x08 = *pos; + mInfos[i].field_0x03 = field_0x03; + break; + } + + if (actor == mRefs[mInfos[i].mActorIdx].get() && (s32)unk1 == mInfos[i].unk) { + // Actor and unk already present, bail + return false; + } + } + return true; +} + +void AttentionGroup::fn_800964B0() { + AttentionPool *left = getPool(); + AttentionPool *right = getOtherPool(); + for (int i = 0; i < left->mNumUsedRefs; i++) { + // This effectively copies a position vector from "left" to "right", + // where left and right are swapped sometimes. So this is effectively + // a double-buffered object pool? + int target = right->fn_80096190(left->mRefs[left->mInfos[i].mActorIdx].get(), left->mInfos[i].unk, + (InteractionType)left->mInfos[i].mInteractionType); + if (target != -1) { + right->mInfos[target].field_0x08 = left->mInfos[i].field_0x08; + } + } +} + +extern "C" f32 lbl_8057CD9C; + +f32 AttentionManager::targetScore(dAcObjBase_c *target, dAcObjBase_c *origin) { + s32 angle = cLib::targetAngleY(target->position, origin->position); + f32 viewAngle = fabsf(lbl_8057CD9C * (s16)(angle - origin->rotation.y.mVal)); + if (viewAngle > 0.5f) { + return viewAngle; + } + return viewAngle * 0.5f + 0.25f; +} + +// Maybe checks if actor is currently targeted +bool AttentionManager::fn_80096B40(dAcObjBase_c *actor) { + AttentionPool *refs = mGroups[1].getOtherPool(); + dAcObjBase_c *ac = refs->getActor(mModels.mCurrentTargetInfoIdx); + if (ac == actor) { + mHasTarget = 1; + } + return true; +} + +void AttentionManager::addPickUpTarget(dAcObjBase_c &actor, f32 field_0x14) { + static InteractionTargetDef pickUpTarget = {0, 2, 1, PICK_UP, 0x100, 0.0f, 60.0f, 0.0f, -50.0f, 70.0f, 20.0f, 1.0f}; + pickUpTarget.field_0x14 = field_0x14; + addTarget(actor, pickUpTarget, 0, nullptr); +} + +void AttentionManager::addSitTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14) { + static InteractionTargetDef sitTarget = {0, 2, 0, SIT, 2, 0.0f, 60.0f, 0.0f, -75.0f, 75.0f, 20.0f, 1.0f}; + sitTarget.interactFlags = flags; + sitTarget.field_0x14 = field_0x14; + addTarget(actor, sitTarget, 0, nullptr); +} + +void AttentionManager::addTalkTarget_unused(dAcObjBase_c &actor) { + static InteractionTargetDef talkTarget = {0, 3, 0, TALK, 0, 0.0f, 45.0f, 45.0f, 0.0f, 0.0f, 50.0f, 1.0f}; + + addTarget(actor, talkTarget, 0, nullptr); +} + +void AttentionManager::addExamineTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, + f32 field_0x20, f32 field_0x24) { + static InteractionTargetDef examineTalkTarget = {1, 3, 0, EXAMINE_TALK, 0, 0.0f, 60.0f, 60.0f, 0.0f, 0.0f, 50.0f, + 1.0f}; + examineTalkTarget.interactFlags = flags; + examineTalkTarget.field_0x14 = field_0x14; + examineTalkTarget.field_0x20 = field_0x20; + examineTalkTarget.field_0x24 = field_0x24; + + addTarget(actor, examineTalkTarget, 0, nullptr); +} + +void AttentionManager::addExamineTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x20, + f32 field_0x24) { + static InteractionTargetDef examineTalkTarget2 = {0, 3, 0, EXAMINE_TALK, 0, 0.0f, 60.0f, 60.0f, 0.0f, 0.0f, 50.0f, + 1.0f}; + examineTalkTarget2.interactFlags = flags; + examineTalkTarget2.field_0x14 = field_0x14; + examineTalkTarget2.field_0x20 = field_0x20; + examineTalkTarget2.field_0x24 = field_0x24; + + addTarget(actor, examineTalkTarget2, 0, nullptr); +} + +void AttentionManager::addCatchTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg) { + static InteractionTargetDef catchTarget = {3, 2, 1, CATCH, 0, 0.0f, 60.0f, 0.0f, 0.0f, 0.0f, 100.0f, 1.0f}; + catchTarget.interactFlags = flags; + catchTarget.field_0x14 = field_0x14; + catchTarget.field_0x20 = -field_0x20_neg; + catchTarget.field_0x24 = -field_0x24_neg; + + addTarget(actor, catchTarget, 0, nullptr); +} + +void AttentionManager::addCatchLikeTarget(dAcObjBase_c &actor, InteractionType interactionType, u32 flags, + f32 field_0x14, f32 field_0x24_neg, f32 field_0x20_neg) { + static InteractionTargetDef catchTarget2 = {4, 2, 1, CATCH, 0, 0.0f, 60.0f, 0.0f, 0.0f, 0.0f, 100.0f, 1.0f}; + + catchTarget2.interactFlags = flags; + catchTarget2.interactType = interactionType; + catchTarget2.field_0x14 = field_0x14; + catchTarget2.field_0x20 = -field_0x20_neg; + catchTarget2.field_0x24 = -field_0x24_neg; + + addTarget(actor, catchTarget2, 0, nullptr); +} + +void AttentionManager::addUnk3Target(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg) { + static InteractionTargetDef unk3Target = {2, 2, 1, UNK_3, 0, 0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 50.0f, 1.0f}; + + unk3Target.interactFlags = flags; + unk3Target.field_0x14 = field_0x14; + unk3Target.field_0x20 = -field_0x20_neg; + unk3Target.field_0x24 = -field_0x24_neg; + + addTarget(actor, unk3Target, 0, nullptr); +} + +void AttentionManager::addUnk3Target(dAcObjBase_c &actor, u32 flags, f32 arg5, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg) { + addUnk3Target(actor, 0, nullptr, flags, arg5, field_0x14, field_0x24_neg, field_0x20_neg); +} + +void AttentionManager::addUnk3Target(dAcObjBase_c &actor, u32 arg2, mVec3_c *arg3, u32 flags, f32 arg5, + f32 field_0x14, f32 field_0x24_neg, f32 field_0x20_neg) { + static InteractionTargetDef unk3Target2 = {1, 1, 1, UNK_3, 0, 0.0f, 60.0f, 60.0f, 0.0f, 0.0f, 50.0f, 1.2f}; + unk3Target2.interactFlags = flags; + unk3Target2.field_0x18 = arg5 - field_0x14; + unk3Target2.field_0x14 = field_0x14; + unk3Target2.field_0x20 = -field_0x20_neg; + unk3Target2.field_0x24 = -field_0x24_neg; + + addTarget(actor, unk3Target2, arg2, arg3); +} + +void AttentionManager::addNpcTalkTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, + f32 field_0x24) { + static InteractionTargetDef talkTarget = {1, 3, 0, TALK, 0, 0.0f, 45.0f, 45.0f, 0.0f, 0.0f, 50.0f, 1.0f}; + talkTarget.interactFlags = flags; + talkTarget.field_0x14 = field_0x14; + talkTarget.field_0x20 = field_0x20; + talkTarget.field_0x24 = field_0x24; + + addTarget(actor, talkTarget, 0, nullptr); +} + +void AttentionManager::addUnk7Target(dAcObjBase_c &actor, u32 flags, f32 arg5, f32 field_0x14, f32 field_0x24_neg, + f32 field_0x20_neg) { + static InteractionTargetDef unk7Target = {1, 1, 1, UNK_7, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 50.0f, 0.5f}; + unk7Target.interactFlags = flags; + unk7Target.field_0x18 = arg5 - field_0x14; + unk7Target.field_0x14 = field_0x14; + unk7Target.field_0x20 = -field_0x20_neg; + unk7Target.field_0x24 = -field_0x24_neg; + + addTarget(actor, unk7Target, 0, nullptr); +} + +void AttentionManager::addReadTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, + f32 field_0x24) { + static InteractionTargetDef readTarget = {1, 3, 0, READ, 0, 0.0f, 60.0f, 60.0f, 0.0f, 0.0f, 50.0f, 1.0f}; + readTarget.interactFlags = flags; + readTarget.field_0x14 = field_0x14; + readTarget.field_0x20 = field_0x20; + readTarget.field_0x24 = field_0x24; + + addTarget(actor, readTarget, 0, nullptr); +} + +void AttentionManager::addReadTarget2(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x20, + f32 field_0x24) { + static InteractionTargetDef readTarget2 = {0, 3, 0, READ, 0, 0.0f, 60.0f, 60.0f, 0.0f, 0.0f, 50.0f, 1.0f}; + readTarget2.interactFlags = flags; + readTarget2.field_0x14 = field_0x14; + readTarget2.field_0x20 = field_0x20; + readTarget2.field_0x24 = field_0x24; + + addTarget(actor, readTarget2, 0, nullptr); +} diff --git a/tools/rel_sieve.py b/tools/rel_sieve.py index e9d62617..db094b56 100644 --- a/tools/rel_sieve.py +++ b/tools/rel_sieve.py @@ -30,10 +30,8 @@ ['fn_800C3EC0', 'ActorEventFlowManagerRelated::checkEventFinished'], ['fn_800275C0', 'EffectsStruct::ctor'], ['fn_80027610', 'EffectsStruct::ctor'], - ['fn_803465D0', 'ActorCollision::ctor'], ['fn_80341A70', 'checkCollision'], ['fn_80016C10', 'AnimModelWrapper::ctor'], - ['fn_8009C910', 'ActorEventRelated::ctor'], ['fn_802E32B0', 'm2d::FrameCtrl_c::setFrame'], ['fn_802F04A0', 'mFader_c::draw'], ['fn_801695F0', 'LytCommonTitle::ctor'],