Skip to content

Commit a71c8a6

Browse files
committed
Added in options to change actor held items in battle
1 parent 8976eeb commit a71c8a6

File tree

7 files changed

+186
-16
lines changed

7 files changed

+186
-16
lines changed

USER_MANUAL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copy the GCI containing the Practice Codes to the memory card. (This file contains only code required to run the Practice codes. It has no relation to the standard TTYD save file.)
1717
* For **Dolphin** users:
1818
* Use the memcard manager located in **Tools > Memcard Manager (GC)** to import the GCI into the file Dolphin is using for a memory card.
19-
* Alternatively, select "GCI Folder" for the format of the memory card in Slot A (in **Config dialog > GameCube > Device settings**), and copy the .gci file directly into the folder, located by default at **{Dolphin directory}/GC/<Region>/Card A**. *<Region>* will either be USA, JAP, or EUR depending on the region of the game that you're using.
19+
* Alternatively, select "GCI Folder" for the format of the memory card in Slot A (in **Config dialog > GameCube > Device settings**), and copy the .gci file directly into the folder, located by default at **{Dolphin directory}/GC/{Region}/Card A**. **{Region}** will either be USA, JAP, or EUR depending on the region of the game that you're using.
2020
* For **Nintendont** or other console users:
2121
* Use the appropriate homebrew apps / folders, etc. to copy the file from your SD card to your GC memory card or virtual memory card.
2222
* Use the Gecko loader cheat code in the "relloader-ttyd" directory to make the game load the Practice Codes GCI.
@@ -59,8 +59,9 @@ This menu allows you to modify your entire inventory, including standard items,
5959
This menu allows you to modify Mario's stats, all of your partner's stats, whether or not partners are enabled or not, whether a partner is out or not, and whether or not a follower is out or not.
6060

6161
### Battles
62-
This menu allows you to change the HP, Max HP, FP, Max FP, and statuses of anyone in a battle (refered to as Actors).
62+
This menu allows you to change the HP, Max HP, FP, Max FP, held items, and statuses of anyone in a battle (refered to as Actors).
6363
* Note: This menu can only be used while in a battle.
64+
* Note 2: Under certain circumstances, it is possible that having an actor recover using a Life Shroom can cause the game to softlock. It is believed that this only occurs when a textbox is supposed to occur, but the Life Shroom interrupts it. One example of where this happens is with Bowser in Chapter 8.
6465

6566
### Displays
6667
1. **On-Screen Timer** displays a timer at the bottom-right of the screen. This timer is set to run at the current FPS, and therefore will count from 0 to 59 (0 to 49 for EU at 50hz) before reaching one second.

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void drawFollowersOptions();
4444
void drawMarioStats();
4545
void drawPartnerStats();
4646
void drawBattlesActorStats();
47+
void drawBattlesActorsHeldItem();
4748
void drawCurrentFollowerOut();
4849
void drawBattlesActorsList();
4950
void drawBattlesStatusesList();

ttyd-tools/rel/include/global.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ enum BATTLES_CURRENT_ACTOR_STATS_SELECTION
172172
CHANGE_ACTOR_MAX_HP,
173173
CHANGE_ACTOR_FP,
174174
CHANGE_ACTOR_MAX_FP,
175+
CHANGE_HELD_ITEM,
176+
CLEAR_HELD_ITEM,
175177
CHANGE_ACTOR_STATUSES,
176178
};
177179

ttyd-tools/rel/source/draw.cpp

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,79 @@ void drawBattlesActorStats()
10991099
}
11001100
}
11011101

1102+
void drawBattlesActorsHeldItem()
1103+
{
1104+
// Get the starting address for the current actor
1105+
uint32_t ActorAddress = reinterpret_cast<uint32_t>(getActorPointer(MenuSelectedOption));
1106+
if (ActorAddress == 0)
1107+
{
1108+
return;
1109+
}
1110+
1111+
// Only run when not displaying for Mario or the partners
1112+
/*uint32_t CurrentActorId = *reinterpret_cast<uint32_t *>(ActorAddress + 0x8);
1113+
const uint32_t MarioId = 222;
1114+
const uint32_t GoombellaId = 224;
1115+
const uint32_t MowzId = 230;
1116+
1117+
if ((CurrentActorId == MarioId) ||
1118+
((CurrentActorId >= GoombellaId) &&
1119+
(CurrentActorId <= MowzId)))
1120+
{
1121+
return;
1122+
}*/
1123+
1124+
uint8_t Alpha = 0xFF;
1125+
uint32_t Color = 0xFFFFFFFF;
1126+
int32_t PosX = -50;
1127+
int32_t PosY = 80;
1128+
float Scale = 0.6;
1129+
1130+
// Draw the text for showing what the current item is
1131+
const char *CurrentLine = "Current Held Item";
1132+
drawText(CurrentLine, PosX, PosY, Alpha, Color, Scale);
1133+
1134+
// Draw the current item icon
1135+
// Make sure the actor is actually holding an item
1136+
#ifdef TTYD_US
1137+
uint32_t offset = 0x308;
1138+
#elif defined TTYD_JP
1139+
uint32_t offset = 0x304;
1140+
#elif defined TTYD_EU
1141+
uint32_t offset = 0x30C;
1142+
#endif
1143+
1144+
int32_t tempitem = *reinterpret_cast<uint32_t *>(ActorAddress + offset);
1145+
if (tempitem > 0)
1146+
{
1147+
PosX += 10;
1148+
PosY -= 45;
1149+
1150+
// Set up array to use for displaying icons
1151+
int32_t IconPosition[3];
1152+
const int32_t IconPositionX = 0;
1153+
const int32_t IconPositionY = 1;
1154+
IconPosition[IconPositionX] = PosX;
1155+
IconPosition[IconPositionY] = PosY;
1156+
IconPosition[2] = 0;
1157+
1158+
drawIconFromItem(IconPosition, tempitem, Scale);
1159+
1160+
// Draw the text for the item
1161+
PosX += 17;
1162+
PosY += 18;
1163+
const char *ItemName = getItemName(tempitem);
1164+
1165+
drawText(ItemName, PosX, PosY, Alpha, Color, Scale);
1166+
}
1167+
else
1168+
{
1169+
PosY -= 20;
1170+
1171+
drawText("None", PosX, PosY, Alpha, Color, Scale);
1172+
}
1173+
}
1174+
11021175
void drawCurrentFollowerOut()
11031176
{
11041177
// Draw the text for the current follower out
@@ -2658,7 +2731,7 @@ void drawTitleScreenInfo()
26582731
PosX += 113;
26592732
PosY -= 14;
26602733

2661-
const char *String = "Practice Codes v3.0.3\nCreated by Zephiles";
2734+
const char *String = "Practice Codes v3.0.4\nCreated by Zephiles";
26622735
drawText(String, PosX, PosY, Alpha, TextColor, Scale);
26632736
}
26642737

ttyd-tools/rel/source/global.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ const char *BattlesCurrentActorLines[] =
523523
"Change Max HP",
524524
"Change FP",
525525
"Change Max FP",
526+
"Change Held Item",
527+
"Clear Held Item",
526528
"Change Statuses",
527529
};
528530

ttyd-tools/rel/source/menu.cpp

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,8 +1478,29 @@ void menuCheckButton()
14781478
{
14791479
if (tempSelectedOption == 0)
14801480
{
1481+
uint32_t ActorAddress = reinterpret_cast<uint32_t>(
1482+
getActorPointer(tempMenuSelectedOption));
1483+
14811484
switch (tempCurrentMenuOption)
14821485
{
1486+
case CLEAR_HELD_ITEM:
1487+
{
1488+
if (ActorAddress == 0)
1489+
{
1490+
break;
1491+
}
1492+
1493+
#ifdef TTYD_US
1494+
uint32_t offset = 0x308;
1495+
#elif defined TTYD_JP
1496+
uint32_t offset = 0x304;
1497+
#elif defined TTYD_EU
1498+
uint32_t offset = 0x30C;
1499+
#endif
1500+
1501+
*reinterpret_cast<uint32_t *>(ActorAddress + offset) = 0;
1502+
break;
1503+
}
14831504
case CHANGE_ACTOR_STATUSES:
14841505
{
14851506
// Go to the next menu
@@ -1492,8 +1513,6 @@ void menuCheckButton()
14921513
SelectedOption = tempCurrentMenuOption;
14931514
SecondaryMenuOption = getHighestAdjustableValueDigit(tempCurrentMenu) - 1;
14941515

1495-
uint32_t ActorAddress = reinterpret_cast<uint32_t>(
1496-
getActorPointer(tempMenuSelectedOption));
14971516
if (ActorAddress == 0)
14981517
{
14991518
break;
@@ -1525,6 +1544,20 @@ void menuCheckButton()
15251544
ActorAddress + 0x10E);
15261545
break;
15271546
}
1547+
case CHANGE_HELD_ITEM:
1548+
{
1549+
#ifdef TTYD_US
1550+
uint32_t offset = 0x308;
1551+
#elif defined TTYD_JP
1552+
uint32_t offset = 0x304;
1553+
#elif defined TTYD_EU
1554+
uint32_t offset = 0x30C;
1555+
#endif
1556+
1557+
MenuSecondaryValue = *reinterpret_cast<int32_t *>(
1558+
ActorAddress + offset);
1559+
break;
1560+
}
15281561
default:
15291562
{
15301563
break;
@@ -2347,9 +2380,22 @@ void drawMenu()
23472380
// Draw the HP/FP values
23482381
drawBattlesActorStats();
23492382

2383+
// Draw the current held item
2384+
drawBattlesActorsHeldItem();
2385+
23502386
if (tempSelectedOption > 0)
23512387
{
2352-
drawAdjustableValue(false, tempCurrentMenu);
2388+
bool ChangingItem;
2389+
if (tempSelectedOption == CHANGE_HELD_ITEM)
2390+
{
2391+
ChangingItem = true;
2392+
}
2393+
else
2394+
{
2395+
ChangingItem = false;
2396+
}
2397+
2398+
drawAdjustableValue(ChangingItem, tempCurrentMenu);
23532399
}
23542400
}
23552401

ttyd-tools/rel/source/menufunctions.cpp

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ int32_t *getUpperAndLowerBounds(int32_t *tempArray, uint32_t currentMenu)
374374
UpperBound = *reinterpret_cast<int16_t *>(ActorAddress + 0x10E); // Max FP
375375
break;
376376
}
377+
case CHANGE_HELD_ITEM:
378+
{
379+
LowerBound = ThunderBolt;
380+
UpperBound = Cake;
381+
break;
382+
}
377383
default:
378384
{
379385
UpperBound = 999;
@@ -1429,22 +1435,48 @@ void adjustMenuItemBoundsMain(int32_t valueChangedBy, int32_t lowerBound, int32_
14291435

14301436
void adjustMenuItemBounds(int32_t valueChangedBy, uint32_t currentMenu)
14311437
{
1432-
if (currentMenu == CHEATS_NPC_FORCE_DROP)
1438+
int32_t tempMenuSecondaryValue = MenuSecondaryValue + valueChangedBy;
1439+
switch (currentMenu)
14331440
{
1434-
int32_t tempMenuSecondaryValue = MenuSecondaryValue + valueChangedBy;
1435-
1436-
if ((tempMenuSecondaryValue > FreshJuice) &&
1437-
(tempMenuSecondaryValue < PowerJump))
1441+
case CHEATS_NPC_FORCE_DROP:
14381442
{
1439-
if (valueChangedBy > 0)
1443+
if ((tempMenuSecondaryValue > FreshJuice) &&
1444+
(tempMenuSecondaryValue < PowerJump))
14401445
{
1441-
MenuSecondaryValue = PowerJump;
1446+
if (valueChangedBy > 0)
1447+
{
1448+
MenuSecondaryValue = PowerJump;
1449+
}
1450+
else
1451+
{
1452+
MenuSecondaryValue = FreshJuice;
1453+
}
1454+
return;
14421455
}
1443-
else
1456+
break;
1457+
}
1458+
case BATTLES_CURRENT_ACTOR:
1459+
{
1460+
if (SelectedOption == CHANGE_HELD_ITEM)
14441461
{
1445-
MenuSecondaryValue = FreshJuice;
1462+
if (tempMenuSecondaryValue == TradeOff)
1463+
{
1464+
if (valueChangedBy > 0)
1465+
{
1466+
MenuSecondaryValue = tempMenuSecondaryValue + 1;
1467+
}
1468+
else
1469+
{
1470+
MenuSecondaryValue = tempMenuSecondaryValue - 1;
1471+
}
1472+
return;
1473+
}
14461474
}
1447-
return;
1475+
break;
1476+
}
1477+
default:
1478+
{
1479+
break;
14481480
}
14491481
}
14501482

@@ -1732,6 +1764,19 @@ void setBattlesActorValue(uint32_t currentMenuOption)
17321764
static_cast<int16_t>(tempMenuSecondaryValue);
17331765
break;
17341766
}
1767+
case CHANGE_HELD_ITEM:
1768+
{
1769+
#ifdef TTYD_US
1770+
uint32_t offset = 0x308;
1771+
#elif defined TTYD_JP
1772+
uint32_t offset = 0x304;
1773+
#elif defined TTYD_EU
1774+
uint32_t offset = 0x30C;
1775+
#endif
1776+
1777+
*reinterpret_cast<int32_t *>(ActorAddress + offset) = tempMenuSecondaryValue;
1778+
break;
1779+
}
17351780
default:
17361781
{
17371782
break;

0 commit comments

Comments
 (0)