Skip to content

Commit 0dccf76

Browse files
committed
Art Attack Hitboxes bug fix
Fixed the Z coordinate for the hitboxes not being set correctly.
1 parent a000e5e commit 0dccf76

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

ttyd-tools/rel/source/codes.cpp

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -158,75 +158,77 @@ void displayArtAttackHitboxes()
158158
float DrawHitboxAdjustPosX = (ActorHitboxWidth * ActorSizeScale) * 0.5;
159159
float DrawHitboxAdjustPosY = (ActorHitboxHeight * ActorSizeScale) * 0.5;
160160

161-
// Set up 2 sets of points; One for the start of a line and one for the end of a line
162-
float ScreenPoint1[3];
163-
float ScreenPoint2[3];
161+
// Set up a set of points, used to get the starts and ends of lines
162+
float ScreenPoint[3];
163+
164+
// Set the Z coordinate for all calculated points, as it will not change
165+
ScreenPoint[2] = ActorPos[2];
164166

165-
// Set the Z coordinate for both screen points, as it will not change
166-
ScreenPoint1[2] = ActorPos[2];
167-
ScreenPoint2[2] = ActorPos[2];
167+
// Set up 2 sets of points; One for the start of a line and one for the end of a line
168+
float ScreenPointOut1[3];
169+
float ScreenPointOut2[3];
168170

169171
// Draw the 4 lines that show the hitbox
170172
for (uint32_t i = 0; i < 4; i++)
171173
{
172174
if (i == 0)
173175
{
174176
// Get the top-left corner of the hitbox
175-
ScreenPoint1[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
176-
ScreenPoint1[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
177-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint1, ScreenPoint1);
177+
ScreenPoint[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
178+
ScreenPoint[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
179+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut1);
178180

179181
// Get the top-right corner of the hitbox
180-
ScreenPoint2[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
181-
ScreenPoint2[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
182-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint2, ScreenPoint2);
182+
ScreenPoint[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
183+
ScreenPoint[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
184+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut2);
183185
}
184186
else if (i == 1)
185187
{
186188
// Get the top-right corner of the hitbox
187-
ScreenPoint1[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
188-
ScreenPoint1[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
189-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint1, ScreenPoint1);
189+
ScreenPoint[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
190+
ScreenPoint[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
191+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut1);
190192

191193
// Get the bottom-right corner of the hitbox
192-
ScreenPoint2[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
193-
ScreenPoint2[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
194-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint2, ScreenPoint2);
194+
ScreenPoint[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
195+
ScreenPoint[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
196+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut2);
195197
}
196198
else if (i == 2)
197199
{
198200
// Get the bottom-right corner of the hitbox
199-
ScreenPoint1[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
200-
ScreenPoint1[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
201-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint1, ScreenPoint1);
201+
ScreenPoint[0] = DrawHitboxPosXStart + DrawHitboxAdjustPosX;
202+
ScreenPoint[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
203+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut1);
202204

203205
// Get the bottom-left corner of the hitbox
204-
ScreenPoint2[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
205-
ScreenPoint2[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
206-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint2, ScreenPoint2);
206+
ScreenPoint[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
207+
ScreenPoint[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
208+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut2);
207209
}
208210
else // if (i == 3)
209211
{
210212
// Get the bottom-left corner of the hitbox
211-
ScreenPoint1[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
212-
ScreenPoint1[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
213-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint1, ScreenPoint1);
213+
ScreenPoint[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
214+
ScreenPoint[1] = DrawHitboxPosYStart - DrawHitboxAdjustPosY;
215+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut1);
214216

215217
// Get the top-left corner of the hitbox
216-
ScreenPoint2[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
217-
ScreenPoint2[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
218-
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint2, ScreenPoint2);
218+
ScreenPoint[0] = DrawHitboxPosXStart - DrawHitboxAdjustPosX;
219+
ScreenPoint[1] = DrawHitboxPosYStart + DrawHitboxAdjustPosY;
220+
ttyd::battle_disp::btlGetScreenPoint(ScreenPoint, ScreenPointOut2);
219221
}
220222

221223
// Draw the line from corner 1 to corner 2
222224
gc::gx::GXBegin(static_cast<gc::gx::GXPrimitive>(168), gc::gx::GX_VTXFMT0, 2);
223225

224-
*WriteGatherPipe = ScreenPoint1[0];
225-
*WriteGatherPipe = ScreenPoint1[1];
226+
*WriteGatherPipe = ScreenPointOut1[0];
227+
*WriteGatherPipe = ScreenPointOut1[1];
226228
*WriteGatherPipe = 0;
227229

228-
*WriteGatherPipe = ScreenPoint2[0];
229-
*WriteGatherPipe = ScreenPoint2[1];
230+
*WriteGatherPipe = ScreenPointOut2[0];
231+
*WriteGatherPipe = ScreenPointOut2[1];
230232
*WriteGatherPipe = 0;
231233
}
232234
}

0 commit comments

Comments
 (0)