Skip to content

Commit 100f5b5

Browse files
committed
Added the AttackParams struct
1 parent 56ea51f commit 100f5b5

File tree

5 files changed

+144
-8
lines changed

5 files changed

+144
-8
lines changed

ttyd-tools/rel/include/global.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <ttyd/item_data.h>
4+
#include <ttyd/battle_unit.h>
45

56
#include <cstdint>
67

@@ -630,7 +631,7 @@ struct OnScreenTimerDisplay
630631

631632
struct DisplayActionCommandTiming
632633
{
633-
int32_t (*Trampoline)(void *, void *);
634+
int32_t (*Trampoline)(void *, ttyd::battle_unit::AttackParams *);
634635
uint16_t DisplayTimer;
635636
uint8_t TypeToDraw;
636637
int8_t Last_A_Frame;

ttyd-tools/rel/include/ttyd/battle_ac.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <ttyd/battle_unit.h>
4+
35
#include <cstdint>
46

57
namespace ttyd::battle_ac {
@@ -17,7 +19,7 @@ uint8_t BattleActionCommandGetDifficulty(void *battleWorkPtr);
1719
// BattleActionCommandResetDefenceResult
1820
// BattleActionCommandGetDefenceResult
1921
uint32_t BattleACPadCheckRecordTrigger(uint32_t frame, uint32_t button);
20-
int32_t BattleActionCommandCheckDefence(void *battleUnitPtr, void *attackParams);
22+
int32_t BattleActionCommandCheckDefence(void *battleUnitPtr, ttyd::battle_unit::AttackParams *attackParams);
2123
// BattleActionCommandStop
2224
// BattleActionCommandStart
2325
// BattleActionCommandSetup

ttyd-tools/rel/include/ttyd/battle_unit.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,137 @@ enum class ActorGroupBelong : uint8_t
1212
kExtra,
1313
};
1414

15+
// Some of these entries may be different for JP and/or EU
16+
struct AttackParams
17+
{
18+
const char *nameMsg;
19+
uint16_t iconId;
20+
uint16_t unk_0x06;
21+
uint16_t unk_0x08;
22+
int16_t itemId;
23+
char *unk_0x0c;
24+
uint8_t unk_0x10; // Always 0x64?
25+
int8_t baseFpCost;
26+
int8_t baseSpCost;
27+
int8_t guardTypesAllowed; // 0 = none, 2 = both; ? = guard only
28+
float unk_0x14;
29+
uint32_t unk_0x18; // Possibly separate 8-bit values, or flags?
30+
31+
char *baseDamageFn;
32+
// Parameters for damage function.
33+
int32_t baseDamage1;
34+
int32_t baseDamage2;
35+
int32_t baseDamage3;
36+
int32_t baseDamage4;
37+
int32_t baseDamage5;
38+
int32_t baseDamage6;
39+
uint32_t unk_0x38;
40+
uint32_t unk_0x3c;
41+
42+
char *baseFpDamageFn;
43+
// Parameters for FP damage function.
44+
int32_t baseFpDamage;
45+
uint32_t unk_0x48;
46+
uint32_t unk_0x4c;
47+
uint32_t unk_0x50;
48+
uint32_t unk_0x54;
49+
uint32_t unk_0x58;
50+
uint32_t unk_0x5c;
51+
uint32_t unk_0x60;
52+
53+
int8_t numTargets; // 1 for single-target, 2 for multi-target
54+
uint8_t unk_0x65;
55+
uint8_t unk_0x66;
56+
uint8_t unk_0x67;
57+
uint8_t allowedTargetTypes;
58+
uint8_t unk_0x69; // Used for enemy-knockback attacks (like Gulp)?
59+
uint8_t unk_0x6a; // Seems to correlate with allowed targets?
60+
uint8_t unk_0x6b; // Seems to indicate effects like flip, quake...
61+
int8_t element;
62+
uint8_t unk_0x6d;
63+
uint8_t unk_0x6e; // Always 0x03?
64+
uint8_t unk_0x6f; // Always 0x02?
65+
const char *acMsg;
66+
uint32_t unk_0x74_flags;
67+
uint32_t unk_0x78_flags;
68+
uint32_t unk_0x7c_flags; // May be flags; generally similar values.
69+
70+
int8_t sleepChance;
71+
int8_t sleepTime;
72+
int8_t stopChance;
73+
int8_t stopTime;
74+
75+
int8_t dizzyChance;
76+
int8_t dizzyTime;
77+
int8_t poisonChance;
78+
int8_t poisonTime;
79+
80+
int8_t poisonStrength;
81+
int8_t confuseChance;
82+
int8_t confuseTime;
83+
int8_t electricChance;
84+
85+
int8_t electricTime;
86+
int8_t dodgyChance;
87+
int8_t dodgyTime;
88+
int8_t burnChance;
89+
90+
int8_t burnTime;
91+
int8_t freezeChance;
92+
int8_t freezeTime;
93+
int8_t sizeChangeChance;
94+
95+
int8_t sizeChangeTime;
96+
int8_t sizeChangeStrength;
97+
int8_t attackChangeChance;
98+
int8_t attackChangeTime;
99+
100+
int8_t attackChangeStrength;
101+
int8_t defenseChangeChance;
102+
int8_t defenseChangeTime;
103+
int8_t defenseChangeStrength;
104+
105+
int8_t allergicChance;
106+
int8_t allergicTime;
107+
int8_t ohkoChance;
108+
int8_t chargeStrength;
109+
110+
int8_t fastChance;
111+
int8_t fastTime;
112+
int8_t slowChance;
113+
int8_t slowTime;
114+
115+
int8_t frightChance;
116+
int8_t galeForceChance;
117+
int8_t paybackTime;
118+
int8_t holdFastTime;
119+
120+
int8_t invisibleChance;
121+
int8_t invisibleTime;
122+
int8_t hpRegenTime;
123+
int8_t hpRegenStrength;
124+
125+
int8_t fpRegenTime;
126+
int8_t fpRegenStrength;
127+
uint8_t unk_0xae;
128+
uint8_t unk_0xaf;
129+
130+
char *itemScriptPtr;
131+
132+
int8_t backgroundA1A2FallWeight;
133+
int8_t backgroundA1FallWeight;
134+
int8_t backgroundA2FallWeight;
135+
int8_t backgroundNoFallWeight;
136+
int8_t backgroundBFallChance;
137+
int8_t nozzleChangeDirectionChance;
138+
int8_t nozzleFireChance;
139+
int8_t ironFrameFallChance;
140+
int8_t objectFallChance;
141+
uint8_t unk_0xbd;
142+
uint8_t unk_0xbe;
143+
uint8_t unk_0xbf;
144+
} __attribute__((__packed__));
145+
15146
extern "C" {
16147

17148
// BtlUnit_CheckShadowGuard

ttyd-tools/rel/include/ttyd/item_data.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <ttyd/battle_unit.h>
4+
35
#include <cstdint>
46

57
namespace ttyd::item_data {
@@ -348,7 +350,7 @@ enum Item : int16_t
348350

349351
struct ItemData
350352
{
351-
const char *itemStringId; // Used for recipe lookups, etc.
353+
const char *itemStringId; // Used for recipe lookups, etc.
352354
const char *itemNameMsg;
353355
const char *itemDescMsg;
354356
const char *itemDescMenuMsg;
@@ -364,7 +366,7 @@ struct ItemData
364366
uint8_t unk_0x1f;
365367
int16_t iconId;
366368
uint16_t unk_0x22;
367-
void *attackParams;
369+
ttyd::battle_unit::AttackParams *attackParams;
368370
} __attribute__((__packed__));
369371

370372
extern "C" {

ttyd-tools/rel/source/codes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <ttyd/win_main.h>
2424
#include <ttyd/itemdrv.h>
2525
#include <ttyd/battle_ac.h>
26+
#include <ttyd/battle_unit.h>
2627

2728
#include <cstring>
2829
#include <cstdio>
@@ -1241,7 +1242,7 @@ void actionCommandsTimingsInit()
12411242
// Credits to Jdaster64 for writing the original code for this
12421243
DisplayActionCommands.Trampoline = patch::hookFunction(
12431244
ttyd::battle_ac::BattleActionCommandCheckDefence, [](
1244-
void *battleUnitPtr, void *attackParams)
1245+
void *battleUnitPtr, ttyd::battle_unit::AttackParams *attackParams)
12451246
{
12461247
if (!Displays[GUARD_SUPERGUARD_TIMINGS])
12471248
{
@@ -1329,10 +1330,9 @@ void actionCommandsTimingsInit()
13291330
else if (Last_B_Frame > -1)
13301331
{
13311332
// Check if the attack can be superguarded or not
1332-
uint8_t SuperguardCheck = *reinterpret_cast<uint8_t *>(
1333-
reinterpret_cast<uint32_t>(attackParams) + 0x13);
1333+
int8_t GuardTypesCheck = attackParams->guardTypesAllowed;
13341334

1335-
if (SuperguardCheck > 0)
1335+
if (GuardTypesCheck > 0)
13361336
{
13371337
// Print how many frames early the player pressed B
13381338
DisplayActionCommands.Last_B_Frame = Last_B_Frame;

0 commit comments

Comments
 (0)