Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BUGFIX to ExecuteScriptCommand #224

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ground_script_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,17 @@ s32 ExecuteScriptCommand(Action *action) {
s32 cap1 = curCmd.arg1 * 2 - 1;
s32 cap2 = curCmd.arg2 * 2 - 1;
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
// BUG: (or two): these lines use the wrong script command arguments to calculate the position offset
// making the target position nonsense. But even if they were correct,
// the way the cap is calculated would make the random offset biased off-center.
// This doesn't affect the released version because these script commands are never used.
#ifndef BUGFIX
scriptData->pos2.x = scriptData->pos1.x + ((OtherRandInt(cap1) - curCmd.argShort) << 8);
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(cap2) - curCmd.arg1) << 8);
#else
scriptData->pos2.x = scriptData->pos1.x + ((OtherRandInt(curCmd.arg1 * 2 + 1) - curCmd.arg1) << 8);
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(curCmd.arg2 * 2 + 1) - curCmd.arg2) << 8);
#endif
if (curCmd.op == 0x7f || curCmd.op == 0x85) {
scriptData->unk2A = sub_8009FB8(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
Expand Down