Skip to content

Commit

Permalink
Tagging in T&S
Browse files Browse the repository at this point in the history
  • Loading branch information
theballaam96 committed Apr 10, 2022
1 parent 026bc3b commit 298ddd4
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 7 deletions.
1 change: 1 addition & 0 deletions base-hack/.avoid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cross_kong
7 changes: 7 additions & 0 deletions base-hack/Build/adjust_exits.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"y": 115,
"z": 2026,
},
{
# Mill Rear PPunch Door
"exit_index": 5,
"x": 4550,
"y": 162,
"z": 3646,
},
],
},
{
Expand Down
4 changes: 3 additions & 1 deletion base-hack/include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ typedef struct playerData {
/* 0x0E8 */ short skew_angle;
/* 0x0EA */ char unk_EA[0xEE - 0xEA];
/* 0x0EE */ short next_facing_angle;
/* 0x0F0 */ char unk_F0[0x110 - 0xF0];
/* 0x0F0 */ char unk_F0[0x10C - 0xF0];
/* 0x10C */ short standing_on_index;
/* 0x10E */ char unk_10E[0x110-0x10C];
/* 0x110 */ char touching_object;
/* 0x111 */ char unk_111[0x128 - 0x111];
/* 0x128 */ short strong_kong_value;
Expand Down
1 change: 1 addition & 0 deletions base-hack/src/fixes/quality_fixes.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void qualityOfLife_fixes(void) {
}
setPermFlag(0x309); // Cranky FTT
setPermFlag(0x17F); // Training Barrels Spawned
setPermFlag(300); // Giant Kosha Dead
fixkey8();
}
}
Expand Down
40 changes: 34 additions & 6 deletions base-hack/src/fixes/tag_anywhere.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ static const unsigned char banned_maps[] = {
35, // K. Rool Barrel: DK's Target Game
37, // Jungle Japes: Barrel Blast // Note: The barrels don't work as other kongs so not much point enabling it on this map
41, // Angry Aztec: Barrel Blast
42, // Troff 'n' Scoff
50, // K. Rool Barrel: Tiny's Mushroom Game
54, // Gloomy Galleon: Barrel Blast
55, // Fungi Forest: Minecart
Expand Down Expand Up @@ -159,15 +158,31 @@ static const unsigned char bad_movement_states[] = {
};

static const short kong_flags[] = {0x181,0x6,0x46,0x42,0x75};
static unsigned char tag_countdown = 0;

void tagAnywhere(int prev_crystals) {
if (Rando.tag_anywhere) {
if (Player) {
char hud_items[] = {0,1,5,8,10,12,13,14};
if (HUD) {
for (int i = 0; i < sizeof(hud_items); i++) {
if (HUD->item[(int)hud_items[i]].hud_state) {
return;
if (tag_countdown > 0) {
tag_countdown -= 1;
}
if (CurrentMap == 0x2A) {
if (tag_countdown == 1) {
int next_hud_state = 1;
if (Player->touching_object) {
if (Player->standing_on_index == 0) { // Standing on feed pad
next_hud_state = 0;
}
}
HUD->item[0].hud_state = next_hud_state;
}
} else {
char hud_items[] = {0,1,5,8,10,12,13,14};
if (HUD) {
for (int i = 0; i < sizeof(hud_items); i++) {
if (HUD->item[(int)hud_items[i]].hud_state) {
return;
}
}
}
}
Expand All @@ -183,8 +198,16 @@ void tagAnywhere(int prev_crystals) {
if (CutsceneActive) {
return;
}
if (CurrentMap == 0x2A) {
if (MapState & 0x10) {
return;
}
}
if (TBVoidByte & 3) {
return;
}
if (tag_countdown != 0) {
return;
}
if (Character < TAG_ANYWHERE_KONG_LIMIT) {
int change = 0;
Expand All @@ -196,6 +219,11 @@ void tagAnywhere(int prev_crystals) {
return;
}
if (change != 0) {
if (CurrentMap == 0x2A) {
tag_countdown = 2;
HUD->item[0].hud_state_timer = 0x100;
HUD->item[0].hud_state = 0;
}
for (int i = 0; i < sizeof(banned_maps); i++) {
if (banned_maps[i] == CurrentMap) {
return;
Expand Down
62 changes: 62 additions & 0 deletions base-hack/src/randomizers/cross_kong.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "../../include/common.h"
/*
Kong is going to be stored in the 0x4 slot of the purchase struct
Price is changed to a byte, changed to 0x5 slot
struct {
short type;
short value
unsigned char kong;
unsigned char price;
}
*/

void crossKongInit(void) {
// Change target kong (Progressive)
*(int*)(0x80025EA0) = 0x90850004; // LBU a1, 0x4 (a0)
// Change target kong (Bitfield)
*(int*)(0x80025E80) = 0x90850004; // LBU a1, 0x4 (a0)
// Change price check
*(int*)(0x80026200) = 0x90CF0005; // LBU t7, 0x5 (a2)
}

/*
HOOKCODE
Placement_80026140:
// Stores price & kong correctly
LH v0, 0x4 (a1)
SH v0, 0x4 (s2)
ANDI t8, v0, 0xFF
J 0x8002614C
SH t8, 0x0 (t2)
Placement_80025FC0:
// Replaces param2 with the start of the character collectable base
OR s2, a0, r0
LUI a1, hi(MovesBase)
ADDIU a1, a1, lo(MovesBase)
J 0x80025FC8
OR s3, a1, r0
Placement_800260F0:
// Sets the move base to the correct kong (Bitfield)
LH t4, 0x2 (a1)
ADDU t8, s3, a0
LBU t9, 0x4 (a1)
ADDIU t6, r0, 0x5E
MULT t9, t6
MFLO t9
J 0x800260F8
ADDU t8, t8, t9
Placement_8002611C:
// Sets the move base to the correct kong (Progressive)
LBU t6, 0x4 (a1)
ADDIU t5, r0, 0x5E
MULT t6, t5
MFLO t6
ADDU t4, t4, t6
LBU t6, 0x0 (t4)
J 0x80026124
LH t5, 0x2 (a1)
*/

0 comments on commit 298ddd4

Please sign in to comment.