Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,9 @@ enum AnchorPuzzle {
ANCHOR_PUZZLE_BGS_TANKTUP = 1,
ANCHOR_PUZZLE_BGS_CROCTUS = 2,
ANCHOR_PUZZLE_BGS_PINKEGG = 3,
// CC clanker teeth: bits 0-2 = token tooth egg count, bits 3-5 = jiggy tooth.
ANCHOR_PUZZLE_CC_CLANKER_TEETH = 4,
ANCHOR_PUZZLE_GV_JINXY_DOOR = 5,
// MM Juju totem: bits 0-3, count of the 4 segments knocked off.
ANCHOR_PUZZLE_MM_JUJU = 6,
// TTC Nipper: bits 0-2, count of hits taken (all 3 = dead, shell open).
ANCHOR_PUZZLE_TTC_NIPPER = 7,
// TTC Blubber: bit 0 = first bullion delivered, bit 1 = second (jiggy spawned, Blubber leaves).
ANCHOR_PUZZLE_TTC_BLUBBER = 8,
// TTC treasure hunt: bits 0-5, count of beak-busted X steps (bit 5 = treasure dug up).
Expand All @@ -359,6 +355,9 @@ enum AnchorPuzzle {
enum AnchorPuzzleCount {
ANCHOR_COUNT_CCW_EYRIE_FED = 0,
ANCHOR_COUNT_CCW_NABNUT_ACORNS = 1,
ANCHOR_COUNT_TTC_NIPPER_HITS = 2,
ANCHOR_COUNT_CC_TOKEN_TOOTH_EGGS = 3,
ANCHOR_COUNT_CC_JIGGY_TOOTH_EGGS = 4,
};

// --- core2/dialog/progressDialog.c ---
Expand Down
2 changes: 1 addition & 1 deletion src/CC/ch/clankertoothext.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void maClankerTooth_update(Actor *this){
if(this->state == CLANKER_TOOTH_STATE_1_UPRIGHT && D_80389F80 == local->unk0){
D_80389F80 = 0;
local->egg_count++;
CALL_EVENT(OnPuzzleStep, ANCHOR_PUZZLE_CC_CLANKER_TEETH, ((1 << local->egg_count) - 1) << ((local->unk0 - 1) * 3)); // [port]
CALL_EVENT(OnPuzzleCountAdd, (local->unk0 == 1) ? ANCHOR_COUNT_CC_TOKEN_TOOTH_EGGS : ANCHOR_COUNT_CC_JIGGY_TOOTH_EGGS, 1); // [port]
if(local->egg_count == 3){
maClankerTooth_setNextState(this, CLANKER_TOOTH_STATE_2_FALLING_OVER);
}else{
Expand Down
2 changes: 1 addition & 1 deletion src/MM/ch/chimpystump.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void __chchimpystump_updateShaking(Actor *this) {
this->unk10_12 = 1;
// [port] Vanilla replays Chimpy's walk-off, and with it this rise, on every entry to MM
// once his jiggy has spawned. Both halves are muted for those replays.
if (EventSystem_Should(VB_MM_CHIMPY_STUMP_RUMBLE, true)) {
if (EventSystem_Should(VB_MM_CHIMPY_STUMP_RUMBLE, true, this)) {
func_802BB3DC(1, 3.0f, 1.0f);
core1_7090_initSfxSource(0, 0x6A, 0x7FF8, 0.2f);
}
Expand Down
6 changes: 3 additions & 3 deletions src/TTC/ch/nipper.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void __chNipper_dieFunc(ActorMarker *this_marker, ActorMarker *other_mark
func_8032B4DC(this, other_marker, 7);

if (this->lifetime_value == 40.0f) {
CALL_EVENT(OnPuzzleStep, ANCHOR_PUZZLE_TTC_NIPPER, 0x7); // [port]
CALL_EVENT(OnPuzzleCountAdd, ANCHOR_COUNT_TTC_NIPPER_HITS, 1); // [port]
subaddie_set_state_with_direction(this, CH_NIPPER_STATE_6_DEAD, 0.01f, 1);
actor_playAnimationOnce(this);
for(i = 0; i < 3; i++){
Expand All @@ -143,13 +143,13 @@ static void __chNipper_dieFunc(ActorMarker *this_marker, ActorMarker *other_mark
}

if (this->lifetime_value == 80.0f) {
CALL_EVENT(OnPuzzleStep, ANCHOR_PUZZLE_TTC_NIPPER, 0x3); // [port]
CALL_EVENT(OnPuzzleCountAdd, ANCHOR_COUNT_TTC_NIPPER_HITS, 1); // [port]
__chNipper_playDeathAnimation(this);
this->lifetime_value = 40.0f;
return;
}

CALL_EVENT(OnPuzzleStep, ANCHOR_PUZZLE_TTC_NIPPER, 0x1); // [port]
CALL_EVENT(OnPuzzleCountAdd, ANCHOR_COUNT_TTC_NIPPER_HITS, 1); // [port]
__chNipper_playDeathAnimation(this);
this->lifetime_value = 80.0f;
gcdialog_showDialog(VER_SELECT(ASSET_A10_DIALOG_NIPPER_HURT, 0x910, 0, 0), 4, NULL, NULL, NULL, NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/TTC/ma/castle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,8 @@ static void __maCastle_checkIfBannedCheatCodeEntered(s32 secret_cheat_code_index
}
for (i = 0; sBannedCheatCodeRanges[i].minId != 0; i++)
{
if ((sSecretsCheatCodes[secret_cheat_code_index].id >= sBannedCheatCodeRanges[i].minId) && (sBannedCheatCodeRanges[i].maxId >= sSecretsCheatCodes[secret_cheat_code_index].id))
// if ((sSecretsCheatCodes[secret_cheat_code_index].id >= sBannedCheatCodeRanges[i].minId) && (sBannedCheatCodeRanges[i].maxId >= sSecretsCheatCodes[secret_cheat_code_index].id))
if (EventSystem_Should(VB_SANDCASTLE_CODE_BANNED, (sSecretsCheatCodes[secret_cheat_code_index].id >= sBannedCheatCodeRanges[i].minId) && (sBannedCheatCodeRanges[i].maxId >= sSecretsCheatCodes[secret_cheat_code_index].id)))
{
switch (__maCastle_getNumberOfBannedCheatCodesEntered())
{
Expand Down
13 changes: 12 additions & 1 deletion src/port/Enhancements/Events/Hooks/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ typedef enum VBehaviorID {
// true
// ```
// #### `args`
// - None
// - `*Actor` (the stump)
VB_MM_CHIMPY_STUMP_RUMBLE,

// #### `result`
Expand Down Expand Up @@ -1208,6 +1208,17 @@ typedef enum VBehaviorID {
// - `*Actor` (the box)
VB_FP_TWINKLY_START,

// A secret sandcastle code in a banned range, which counts a strike toward erasing the game. Returning false
// applies its cheat without the strike.
// #### `result`
// ```c
// (sSecretsCheatCodes[secret_cheat_code_index].id >= sBannedCheatCodeRanges[i].minId) &&
// (sBannedCheatCodeRanges[i].maxId >= sSecretsCheatCodes[secret_cheat_code_index].id)
// ```
// #### `args`
// - None
VB_SANDCASTLE_CODE_BANNED,

// Romhack port gates

// #### `result`
Expand Down
7 changes: 5 additions & 2 deletions src/port/Enhancements/Fixes/GameFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ static bool IsChimpyWalkOffReplay() {
}

void RegisterChimpyStumpRumble_Init() {
COND_VB_SHOULD(VB_MM_CHIMPY_STUMP_RUMBLE, EVENT_PRIORITY_NORMAL, CVarGetInteger(CVAR_STUMP_RUMBLE, 1),
{ *should = !jiggyscore_isSpawned(JIGGY_9_MM_CHIMPY); });
COND_VB_SHOULD(VB_MM_CHIMPY_STUMP_RUMBLE, EVENT_PRIORITY_NORMAL, CVarGetInteger(CVAR_STUMP_RUMBLE, 1), {
if (jiggyscore_isSpawned(JIGGY_9_MM_CHIMPY)) {
*should = false;
}
});
COND_VB_SHOULD(VB_MM_CHIMPY_NOISE, EVENT_PRIORITY_NORMAL, CVarGetInteger(CVAR_STUMP_RUMBLE, 1), {
if (IsChimpyWalkOffReplay()) {
*should = false;
Expand Down
52 changes: 44 additions & 8 deletions src/port/Network/Anchor/HookHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ bool Anchor_ScopedFlagExcluded(s32 space, s32 index) {
(index == MM_SPECIFIC_FLAG_0_CHIMPY_STUMP_RAISED || index == MM_SPECIFIC_FLAG_3_CHIMPY_HAS_LEFT)) {
return true;
}
// First meeting dialogs.
if (space == ANCHOR_FLAGSPACE_MAP_SPECIFIC && gsworld_getMap() == MAP_2_MM_MUMBOS_MOUNTAIN &&
(index == MM_SPECIFIC_FLAG_8_HIT_WITH_ORANGE || index == MM_SPECIFIC_FLAG_CONGA_WARNED_BLOCKS)) {
return true;
}
if (space == ANCHOR_FLAGSPACE_MAP_SPECIFIC && gsworld_getMap() == MAP_C_MM_TICKERS_TOWER && index == 0) {
return true;
}
if (space == ANCHOR_FLAGSPACE_LEVEL_SPECIFIC &&
(s32)map_getLevel(gsworld_getMap()) == (s32)LEVEL_1_MUMBOS_MOUNTAIN &&
(index == LEVEL_FLAG_B_MM_UNKNOWN || index == LEVEL_FLAG_C_MM_UNKNOWN)) {
return true;
}
// Holds every mutie in its greeting while one player reads it (crab.c); each client sets its own.
if (space == ANCHOR_FLAGSPACE_LEVEL_SPECIFIC &&
(s32)map_getLevel(gsworld_getMap()) == (s32)LEVEL_3_CLANKERS_CAVERN &&
Expand All @@ -147,6 +160,12 @@ bool Anchor_ScopedFlagExcluded(s32 space, s32 index) {
index <= TTC_SPECIFIC_FLAG_3_BLUBBER_SHOW_JIGGY_SPAWNED_TEXT_FLAG) {
return true;
}
// First meeting dialogs.
if (space == ANCHOR_FLAGSPACE_MAP_SPECIFIC && gsworld_getMap() == MAP_7_TTC_TREASURE_TROVE_COVE &&
(index == TTC_SPECIFIC_FLAG_5_CLAM_FIRST_MEET_TEXT_SHOWN ||
index == TTC_SPECIFIC_FLAG_7_NIPPER_FIRST_MEET_TEXT_SHOWN || index == 8 || index == 9 || index == 0xA)) {
return true;
}
// FP xmas tree star minigame (flags 2/3): per-player, kept local; result syncs via ANCHOR_PUZZLE_FP_TREE_ICE.
if (space == ANCHOR_FLAGSPACE_MAP_SPECIFIC && gsworld_getMap() == MAP_27_FP_FREEZEEZY_PEAK &&
(index == 2 || index == 3)) {
Expand Down Expand Up @@ -257,14 +276,19 @@ static bool Anchor_LocalFlagClear(s32 space, s32 index) {

static bool sAttackTutorialMovesKnown = false;

// Whether the team has answered the SM tutorial offer, or knows a move.
static bool Anchor_SmTutorialAnswered() {
// By level, not map: a romhack's Spiral Mountain may be a different map id.
return __chSmBottles_isAnySpiralMountainAbilityLearned() ||
(PuzzleStep_GetBitsForLevel(LEVEL_B_SPIRAL_MOUNTAIN, ANCHOR_PUZZLE_SM_TUTORIAL) & 1);
}

// Whether the SM tutorial offer is ours to answer; claims it for us when it's free.
static bool Anchor_SmTutorialChoiceOpen() {
if (!Anchor_IsWorldSyncActive()) {
return true;
}
// By level, not map: a romhack's Spiral Mountain may be a different map id.
if (__chSmBottles_isAnySpiralMountainAbilityLearned() ||
(PuzzleStep_GetBitsForLevel(LEVEL_B_SPIRAL_MOUNTAIN, ANCHOR_PUZZLE_SM_TUTORIAL) & 1)) {
if (Anchor_SmTutorialAnswered()) {
return false;
}
if (NetAuthority_IsClaimed(NET_ACTIVITY_SM_TUTORIAL) && !NetAuthority_IsSelf(NET_ACTIVITY_SM_TUTORIAL)) {
Expand Down Expand Up @@ -662,6 +686,10 @@ void Anchor::RegisterHooks() {
return;
}
auto ev = reinterpret_cast<OnGameFlagSet*>(event);
// The banned codes' strike count is each player's, and a team state keeps ours.
if (ev->flagSpace == ANCHOR_FLAGSPACE_FILE_PROGRESS && ev->index == FILEPROG_FD_BANNED_CHEATCODES_ENTERED) {
return;
}
// A multi-bit field (a counter) goes as one packet. Sent a bit at a time, a receiver can
// apply part of it and see a count nobody set: a podium going 4 -> 3 passes 5 and 7.
if (ev->length > 1 && ev->flagSpace != ANCHOR_FLAGSPACE_MAP_SPECIFIC) {
Expand Down Expand Up @@ -807,12 +835,14 @@ void Anchor::RegisterHooks() {
}
});

// SM intro Bottles: the tutorial offer is first-answer-wins for the team. An offer a teammate holds or has
// answered sets SM_SPECIFIC_FLAG_1_TALKED_TO_BOTTLES on ours.
// SM intro Bottles: the tutorial offer is first-answer-wins for the team. An offer a teammate holds stays shut on
// ours until the claim drops; one the team has answered sets SM_SPECIFIC_FLAG_1_TALKED_TO_BOTTLES on ours.
COND_VB_SHOULD(VB_SM_TUTORIAL_CHOICE_OPEN, EVENT_PRIORITY_NORMAL, isConnected, {
Actor* bottles = va_arg(args, Actor*);
if (*should && bottles->actorTypeSpecificField == CH_SM_MOLE_ID_1_INTRO && !Anchor_SmTutorialChoiceOpen()) {
mapSpecificFlags_set(SM_SPECIFIC_FLAG_1_TALKED_TO_BOTTLES, true);
if (Anchor_SmTutorialAnswered()) {
mapSpecificFlags_set(SM_SPECIFIC_FLAG_1_TALKED_TO_BOTTLES, true);
}
*should = false;
}
});
Expand All @@ -832,6 +862,13 @@ void Anchor::RegisterHooks() {
}
});

// The banned sandcastle codes apply without a strike in a room, so nothing erases the game or stops it saving.
COND_VB_SHOULD(VB_SANDCASTLE_CODE_BANNED, EVENT_PRIORITY_NORMAL, isConnected, {
if (Anchor_IsWorldSyncActive()) {
*should = false;
}
});

// An answer to a choice a teammate owns folds a skip into the tutorial. Recorded team-wide as it lands, so a
// second pending offer folds before any move is learned.
COND_HOOK(OnBottlesTutorialAnswer, EVENT_PRIORITY_NORMAL, isConnected, [](IEvent* event) {
Expand All @@ -847,8 +884,7 @@ void Anchor::RegisterHooks() {
COND_VB_SHOULD(VB_SM_MOLEHILL_ACTIVE, EVENT_PRIORITY_NORMAL, isConnected, {
const s32 mole = va_arg(args, Actor*)->actorTypeSpecificField;
if (mole != CH_SM_MOLE_ID_1_INTRO && mole != CH_SM_MOLE_ID_8_BRIDGE && Anchor_IsWorldSyncActive() &&
!__chSmBottles_isAnySpiralMountainAbilityLearned() &&
!(PuzzleStep_GetBitsForLevel(LEVEL_B_SPIRAL_MOUNTAIN, ANCHOR_PUZZLE_SM_TUTORIAL) & 1)) {
!Anchor_SmTutorialAnswered()) {
*should = false;
}
});
Expand Down
2 changes: 0 additions & 2 deletions src/port/Network/Anchor/Packets/PuzzleStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ static const std::map<int32_t, PuzzleHome>& puzzleHomes() {
// The egg chain's map isn't pinned down in the decomp; its readback only drives
// actor state, so the whole level is safe.
{ ANCHOR_PUZZLE_BGS_PINKEGG, { {}, LEVEL_4_BUBBLEGLOOP_SWAMP } },
{ ANCHOR_PUZZLE_CC_CLANKER_TEETH, { { MAP_B_CC_CLANKERS_CAVERN } } },
{ ANCHOR_PUZZLE_GV_JINXY_DOOR, { { MAP_12_GV_GOBIS_VALLEY } } },
{ ANCHOR_PUZZLE_MM_JUJU, { { MAP_2_MM_MUMBOS_MOUNTAIN } } },
{ ANCHOR_PUZZLE_TTC_NIPPER, { { MAP_7_TTC_TREASURE_TROVE_COVE } } },
{ ANCHOR_PUZZLE_TTC_BLUBBER, { { MAP_7_TTC_TREASURE_TROVE_COVE } } },
{ ANCHOR_PUZZLE_TTC_XHUNT, { { MAP_7_TTC_TREASURE_TROVE_COVE } } },
{ ANCHOR_PUZZLE_FP_TREE_ICE, { { MAP_53_FP_CHRISTMAS_TREE } } },
Expand Down
3 changes: 3 additions & 0 deletions src/port/Network/Anchor/Packets/UpdateTeamState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ void Anchor::HandlePacket_UpdateTeamState(nlohmann::json& payload) {
auto& state = payload["state"];
// Direct byte copy bypasses the setters; no OnGameFlagSet / collectible events fire.
if (state.contains("fileProgressFlags")) {
// The banned codes' strike count stays each player's.
const s32 strikes = fileProgressFlag_getN(FILEPROG_FD_BANNED_CHEATCODES_ENTERED, 2);
ApplyTeamBytes(state["fileProgressFlags"], fileProgressFlag_getSizeAndPtr);
fileProgressFlag_setN(FILEPROG_FD_BANNED_CHEATCODES_ENTERED, strikes, 2);
}
if (state.contains("volatileFlags")) {
ApplyTeamBytes(state["volatileFlags"], volatileFlag_getSizeAndPtr);
Expand Down
2 changes: 1 addition & 1 deletion src/port/Network/Anchor/Packets/WaterRise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void Anchor::HandlePacket_WaterRise(nlohmann::json& payload) {
func_802F9F80(rumble, 0.0f, kLength[p1 - 1], kFade[p1 - 1]);
}
} else if (kind == WATERRISE_KIND_CC) {
// Only replay while in the water's map; on later entry func_80388104 snaps it on its own.
// Only replay while in the water's map; on later entry func_80387F80 snaps it on its own.
if ((s32)gsworld_getMap() == map) {
Struct70s* water = func_8034C5AC(p1);
if (water != nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions src/port/Network/Anchor/Puzzles/ClankersCavern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ static void CCGrateUpdate(IEvent* event) {
}
}

// A teammate's eggs in this tooth. Each tooth has three bits.
// A teammate's eggs in this tooth.
static void ClankerToothUpdate(IEvent* event) {
Actor* tooth = ((ShouldActorUpdate*)event)->actor;
auto* local = (ActorLocal_CC_BF0*)&tooth->local;
if (!tooth->volatile_initialized) {
return;
}
const s32 bits = (PuzzleStep_GetBits(ANCHOR_PUZZLE_CC_CLANKER_TEETH) >> ((local->unk0 - 1) * 3)) & 0x7;
const s32 eggs = (bits & 1) + ((bits >> 1) & 1) + ((bits >> 2) & 1);
const s32 eggs =
PuzzleStep_GetCount((local->unk0 == 1) ? ANCHOR_COUNT_CC_TOKEN_TOOTH_EGGS : ANCHOR_COUNT_CC_JIGGY_TOOTH_EGGS);
while (tooth->state == CLANKER_TOOTH_STATE_1_UPRIGHT && local->egg_count < eggs) {
local->egg_count++;
if (local->egg_count == 3) {
Expand Down
8 changes: 8 additions & 0 deletions src/port/Network/Anchor/Puzzles/MumbosMountain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ void AnchorPuzzles_RegisterMumbosMountain(bool connected) {
});
COND_HOOK(OnMapLoad, EVENT_PRIORITY_NORMAL, true, [](IEvent* event) { sJujuReplay = false; });

// Chimpy's thanks to a teammate shakes our camera and plays the stump's rumble only within earshot.
COND_VB_SHOULD(VB_MM_CHIMPY_STUMP_RUMBLE, EVENT_PRIORITY_NORMAL, connected, {
Actor* stump = va_arg(args, Actor*);
if (Anchor_WasMapFlagSetRemotely(MM_SPECIFIC_FLAG_4_SHAKE) && !Anchor_InEarshot(stump->position)) {
*should = false;
}
});

// A pad a teammate already hit stays hit.
COND_ID_HOOK(ShouldActorUpdate, ACTOR_57_ORANGE_PAD, EVENT_PRIORITY_NORMAL, connected, [](IEvent* event) {
Actor* pad = ((ShouldActorUpdate*)event)->actor;
Expand Down
5 changes: 2 additions & 3 deletions src/port/Network/Anchor/Puzzles/TreasureTroveCove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ static bool IsBlubberTeammateFinish(Actor* actor) {
return actor != NULL && actor->modelCacheIndex == ACTOR_115_BLUBBER && sBlubberTeammateFinish;
}

// The Nipper hits the team landed, one bit each.
// The Nipper hits the team landed.
static s32 NipperHits() {
const s32 bits = PuzzleStep_GetBits(ANCHOR_PUZZLE_TTC_NIPPER) & 0x7;
return (bits & 1) + ((bits >> 1) & 1) + ((bits >> 2) & 1);
return PuzzleStep_GetCount(ANCHOR_COUNT_TTC_NIPPER_HITS);
}

// The hits this Nipper shows: its lifetime drops from 120 to 80 to 40 as he's hit.
Expand Down
Loading