@@ -69,180 +69,6 @@ int32_t forceNPCItemDrop(void *ptr)
69
69
return *reinterpret_cast <int32_t *>(
70
70
reinterpret_cast <uint32_t >(ptr) + 0x23C );
71
71
}
72
-
73
- void displayArtAttackHitboxes ()
74
- {
75
- if (!Displays[ART_ATTACK_HITBOXES])
76
- {
77
- return ;
78
- }
79
-
80
- // Set the initial color to use for the lines of the hitboxes
81
- uint8_t HSVA[4 ];
82
- *reinterpret_cast <uint32_t *>(&HSVA) = 0x00FFCCFF ; // RGBA value is 0xCC0000FF
83
-
84
- // Get the address of the write gather pipe, and handle the value at the address as a float
85
- volatile float *WriteGatherPipe = reinterpret_cast <float *>(0xCC008000 );
86
-
87
- for (uint32_t Slot = 0 ; Slot < 64 ; Slot++)
88
- {
89
- void *BattleUnitPtr = getActorPointer (Slot);
90
- if (!BattleUnitPtr)
91
- {
92
- continue ;
93
- }
94
-
95
- // Check if the current actor is a normal enemy that can be attacked
96
- ttyd::battle_unit::ActorGroupBelong BattleUnitBelong = ttyd::battle_unit::BtlUnit_GetBelong (BattleUnitPtr);
97
- if (BattleUnitBelong != ttyd::battle_unit::ActorGroupBelong::kEnemy )
98
- {
99
- // The current actor is not a normal enemy that can be attacked, so don't draw the hitbox
100
- continue ;
101
- }
102
-
103
- // Check if the defeated flag is set for the current actor
104
- const uint32_t DefeatedFlag = 27 ;
105
- bool DefeatedFlagIsOn = ttyd::battle_unit::BtlUnit_CheckStatus (BattleUnitPtr, DefeatedFlag);
106
- if (DefeatedFlagIsOn)
107
- {
108
- // The defeated flag is set for the current actor, so don't draw the hitbox
109
- continue ;
110
- }
111
-
112
- // Check if the current actor can be attacked
113
- int32_t BodyPartsId = ttyd::battle_unit::BtlUnit_GetBodyPartsId (BattleUnitPtr);
114
- void *BodyPartsPtr = ttyd::battle_unit::BtlUnit_GetPartsPtr (BattleUnitPtr, BodyPartsId);
115
-
116
- uint32_t BodyPartsFlags = *reinterpret_cast <uint32_t *>(
117
- reinterpret_cast <uint32_t >(BodyPartsPtr) + 0x1AC );
118
-
119
- if (BodyPartsFlags & (1 << 16 )) // Check if 16 bit is on
120
- {
121
- // The current actor cannot be attacked, so don't draw the hitbox
122
- continue ;
123
- }
124
-
125
- // Get the RGBA equivalent of the HSVA value
126
- uint32_t HitboxLineColor = ttyd::fontmgr::HSV2RGB (HSVA);
127
-
128
- // Set the color of the lines of the current hitbox
129
- gc::gx::GXSetChanMatColor (gc::gx::GX_COLOR0A0, reinterpret_cast <uint8_t *>(&HitboxLineColor));
130
-
131
- uint32_t BattleUnitPtrUint = reinterpret_cast <uint32_t >(BattleUnitPtr);
132
-
133
- // Check if the current actor is hanging from the ceiling
134
- uint32_t ActorFlags = *reinterpret_cast <uint32_t *>(BattleUnitPtrUint + 0x104 );
135
- float DrawHitboxDirection;
136
-
137
- if (ActorFlags & (1 << 1 )) // Check if 1 bit is on
138
- {
139
- // The current actor is hanging from the ceiling
140
- DrawHitboxDirection = -1 ; // Draw down
141
- }
142
- else
143
- {
144
- // The current actor is not hanging from the ceiling
145
- DrawHitboxDirection = 1 ; // Draw up
146
- }
147
-
148
- // Get the variables used to calculate the position of the hitbox
149
- float ActorHitboxWidth = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xE4 );
150
- float ActorHitboxHeight = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xE8 );
151
- float ActorHitboxPosOffsetX = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xD8 );
152
- float ActorHitboxPosOffsetY = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xDC );
153
- float ActorSizeScale = *reinterpret_cast <float *>(BattleUnitPtrUint + 0x114 );
154
-
155
- // Get the position of the current actor
156
- float ActorPos[3 ];
157
- ttyd::battle_unit::BtlUnit_GetPos (BattleUnitPtr,
158
- &ActorPos[0 ], &ActorPos[1 ], &ActorPos[2 ]);
159
-
160
- // Get the X and Y coordinate starting positions
161
- float DrawHitboxPosXStart = (ActorHitboxPosOffsetX * ActorSizeScale) + ActorPos[0 ];
162
- float DrawHitboxPosYStart = (DrawHitboxDirection * ActorHitboxPosOffsetY * ActorSizeScale) + ActorPos[1 ];
163
-
164
- // Get the amount to adjust the starting positions by
165
- float DrawHitboxAdjustPosX = (ActorHitboxWidth * ActorSizeScale) * 0.5 ;
166
- float DrawHitboxAdjustPosY = (ActorHitboxHeight * ActorSizeScale) * 0.5 ;
167
-
168
- // Set up a set of points, used to get the starts and ends of lines
169
- float ScreenPoint[3 ];
170
-
171
- // Set the Z coordinate for all calculated points, as it will not change
172
- ScreenPoint[2 ] = ActorPos[2 ];
173
-
174
- // Set up 2 sets of points; One for the start of a line and one for the end of a line
175
- float ScreenPointOut1[3 ];
176
- float ScreenPointOut2[3 ];
177
-
178
- // Draw the 4 lines that show the hitbox
179
- for (uint32_t i = 0 ; i < 4 ; i++)
180
- {
181
- if (i == 0 )
182
- {
183
- // Get the top-left corner of the hitbox
184
- ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
185
- ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
186
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
187
-
188
- // Get the top-right corner of the hitbox
189
- ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
190
- ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
191
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
192
- }
193
- else if (i == 1 )
194
- {
195
- // Get the top-right corner of the hitbox
196
- ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
197
- ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
198
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
199
-
200
- // Get the bottom-right corner of the hitbox
201
- ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
202
- ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
203
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
204
- }
205
- else if (i == 2 )
206
- {
207
- // Get the bottom-right corner of the hitbox
208
- ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
209
- ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
210
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
211
-
212
- // Get the bottom-left corner of the hitbox
213
- ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
214
- ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
215
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
216
- }
217
- else // if (i == 3)
218
- {
219
- // Get the bottom-left corner of the hitbox
220
- ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
221
- ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
222
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
223
-
224
- // Get the top-left corner of the hitbox
225
- ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
226
- ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
227
- ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
228
- }
229
-
230
- // Draw the line from corner 1 to corner 2
231
- gc::gx::GXBegin (static_cast <gc::gx::GXPrimitive>(168 ), gc::gx::GX_VTXFMT0, 2 );
232
-
233
- *WriteGatherPipe = ScreenPointOut1[0 ];
234
- *WriteGatherPipe = ScreenPointOut1[1 ];
235
- *WriteGatherPipe = 0 ;
236
-
237
- *WriteGatherPipe = ScreenPointOut2[0 ];
238
- *WriteGatherPipe = ScreenPointOut2[1 ];
239
- *WriteGatherPipe = 0 ;
240
- }
241
-
242
- // Adjust the hue for the lines of the next hitbox
243
- HSVA[0 ] += 45 ;
244
- }
245
- }
246
72
}
247
73
248
74
void Mod::performBattleChecks ()
@@ -1343,6 +1169,180 @@ void displayActionCommandsTiming()
1343
1169
}
1344
1170
}
1345
1171
1172
+ void displayArtAttackHitboxes ()
1173
+ {
1174
+ if (!Displays[ART_ATTACK_HITBOXES])
1175
+ {
1176
+ return ;
1177
+ }
1178
+
1179
+ // Set the initial color to use for the lines of the hitboxes
1180
+ uint8_t HSVA[4 ];
1181
+ *reinterpret_cast <uint32_t *>(&HSVA) = 0x00FFCCFF ; // RGBA value is 0xCC0000FF
1182
+
1183
+ // Get the address of the write gather pipe, and handle the value at the address as a float
1184
+ volatile float *WriteGatherPipe = reinterpret_cast <float *>(0xCC008000 );
1185
+
1186
+ for (uint32_t Slot = 0 ; Slot < 64 ; Slot++)
1187
+ {
1188
+ void *BattleUnitPtr = getActorPointer (Slot);
1189
+ if (!BattleUnitPtr)
1190
+ {
1191
+ continue ;
1192
+ }
1193
+
1194
+ // Check if the current actor is a normal enemy that can be attacked
1195
+ ttyd::battle_unit::ActorGroupBelong BattleUnitBelong = ttyd::battle_unit::BtlUnit_GetBelong (BattleUnitPtr);
1196
+ if (BattleUnitBelong != ttyd::battle_unit::ActorGroupBelong::kEnemy )
1197
+ {
1198
+ // The current actor is not a normal enemy that can be attacked, so don't draw the hitbox
1199
+ continue ;
1200
+ }
1201
+
1202
+ // Check if the defeated flag is set for the current actor
1203
+ const uint32_t DefeatedFlag = 27 ;
1204
+ bool DefeatedFlagIsOn = ttyd::battle_unit::BtlUnit_CheckStatus (BattleUnitPtr, DefeatedFlag);
1205
+ if (DefeatedFlagIsOn)
1206
+ {
1207
+ // The defeated flag is set for the current actor, so don't draw the hitbox
1208
+ continue ;
1209
+ }
1210
+
1211
+ // Check if the current actor can be attacked
1212
+ int32_t BodyPartsId = ttyd::battle_unit::BtlUnit_GetBodyPartsId (BattleUnitPtr);
1213
+ void *BodyPartsPtr = ttyd::battle_unit::BtlUnit_GetPartsPtr (BattleUnitPtr, BodyPartsId);
1214
+
1215
+ uint32_t BodyPartsFlags = *reinterpret_cast <uint32_t *>(
1216
+ reinterpret_cast <uint32_t >(BodyPartsPtr) + 0x1AC );
1217
+
1218
+ if (BodyPartsFlags & (1 << 16 )) // Check if 16 bit is on
1219
+ {
1220
+ // The current actor cannot be attacked, so don't draw the hitbox
1221
+ continue ;
1222
+ }
1223
+
1224
+ // Get the RGBA equivalent of the HSVA value
1225
+ uint32_t HitboxLineColor = ttyd::fontmgr::HSV2RGB (HSVA);
1226
+
1227
+ // Set the color of the lines of the current hitbox
1228
+ gc::gx::GXSetChanMatColor (gc::gx::GX_COLOR0A0, reinterpret_cast <uint8_t *>(&HitboxLineColor));
1229
+
1230
+ uint32_t BattleUnitPtrUint = reinterpret_cast <uint32_t >(BattleUnitPtr);
1231
+
1232
+ // Check if the current actor is hanging from the ceiling
1233
+ uint32_t ActorFlags = *reinterpret_cast <uint32_t *>(BattleUnitPtrUint + 0x104 );
1234
+ float DrawHitboxDirection;
1235
+
1236
+ if (ActorFlags & (1 << 1 )) // Check if 1 bit is on
1237
+ {
1238
+ // The current actor is hanging from the ceiling
1239
+ DrawHitboxDirection = -1 ; // Draw down
1240
+ }
1241
+ else
1242
+ {
1243
+ // The current actor is not hanging from the ceiling
1244
+ DrawHitboxDirection = 1 ; // Draw up
1245
+ }
1246
+
1247
+ // Get the variables used to calculate the position of the hitbox
1248
+ float ActorHitboxWidth = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xE4 );
1249
+ float ActorHitboxHeight = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xE8 );
1250
+ float ActorHitboxPosOffsetX = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xD8 );
1251
+ float ActorHitboxPosOffsetY = *reinterpret_cast <float *>(BattleUnitPtrUint + 0xDC );
1252
+ float ActorSizeScale = *reinterpret_cast <float *>(BattleUnitPtrUint + 0x114 );
1253
+
1254
+ // Get the position of the current actor
1255
+ float ActorPos[3 ];
1256
+ ttyd::battle_unit::BtlUnit_GetPos (BattleUnitPtr,
1257
+ &ActorPos[0 ], &ActorPos[1 ], &ActorPos[2 ]);
1258
+
1259
+ // Get the X and Y coordinate starting positions
1260
+ float DrawHitboxPosXStart = (ActorHitboxPosOffsetX * ActorSizeScale) + ActorPos[0 ];
1261
+ float DrawHitboxPosYStart = (DrawHitboxDirection * ActorHitboxPosOffsetY * ActorSizeScale) + ActorPos[1 ];
1262
+
1263
+ // Get the amount to adjust the starting positions by
1264
+ float DrawHitboxAdjustPosX = (ActorHitboxWidth * ActorSizeScale) * 0.5 ;
1265
+ float DrawHitboxAdjustPosY = (ActorHitboxHeight * ActorSizeScale) * 0.5 ;
1266
+
1267
+ // Set up a set of points, used to get the starts and ends of lines
1268
+ float ScreenPoint[3 ];
1269
+
1270
+ // Set the Z coordinate for all calculated points, as it will not change
1271
+ ScreenPoint[2 ] = ActorPos[2 ];
1272
+
1273
+ // Set up 2 sets of points; One for the start of a line and one for the end of a line
1274
+ float ScreenPointOut1[3 ];
1275
+ float ScreenPointOut2[3 ];
1276
+
1277
+ // Draw the 4 lines that show the hitbox
1278
+ for (uint32_t i = 0 ; i < 4 ; i++)
1279
+ {
1280
+ if (i == 0 )
1281
+ {
1282
+ // Get the top-left corner of the hitbox
1283
+ ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
1284
+ ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
1285
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
1286
+
1287
+ // Get the top-right corner of the hitbox
1288
+ ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
1289
+ ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
1290
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
1291
+ }
1292
+ else if (i == 1 )
1293
+ {
1294
+ // Get the top-right corner of the hitbox
1295
+ ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
1296
+ ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
1297
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
1298
+
1299
+ // Get the bottom-right corner of the hitbox
1300
+ ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
1301
+ ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
1302
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
1303
+ }
1304
+ else if (i == 2 )
1305
+ {
1306
+ // Get the bottom-right corner of the hitbox
1307
+ ScreenPoint[0 ] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
1308
+ ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
1309
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
1310
+
1311
+ // Get the bottom-left corner of the hitbox
1312
+ ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
1313
+ ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
1314
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
1315
+ }
1316
+ else // if (i == 3)
1317
+ {
1318
+ // Get the bottom-left corner of the hitbox
1319
+ ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
1320
+ ScreenPoint[1 ] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
1321
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut1);
1322
+
1323
+ // Get the top-left corner of the hitbox
1324
+ ScreenPoint[0 ] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
1325
+ ScreenPoint[1 ] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
1326
+ ttyd::battle_disp::btlGetScreenPoint (ScreenPoint, ScreenPointOut2);
1327
+ }
1328
+
1329
+ // Draw the line from corner 1 to corner 2
1330
+ gc::gx::GXBegin (static_cast <gc::gx::GXPrimitive>(168 ), gc::gx::GX_VTXFMT0, 2 );
1331
+
1332
+ *WriteGatherPipe = ScreenPointOut1[0 ];
1333
+ *WriteGatherPipe = ScreenPointOut1[1 ];
1334
+ *WriteGatherPipe = 0 ;
1335
+
1336
+ *WriteGatherPipe = ScreenPointOut2[0 ];
1337
+ *WriteGatherPipe = ScreenPointOut2[1 ];
1338
+ *WriteGatherPipe = 0 ;
1339
+ }
1340
+
1341
+ // Adjust the hue for the lines of the next hitbox
1342
+ HSVA[0 ] += 45 ;
1343
+ }
1344
+ }
1345
+
1346
1346
int32_t warpToMap (uint32_t value)
1347
1347
{
1348
1348
// Make sure the player is currently in the game
0 commit comments