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

raidboss: Lunar Subterrane--Add Ruinous Hex calls #5944

Merged
merged 5 commits into from
Nov 24, 2023
Merged

raidboss: Lunar Subterrane--Add Ruinous Hex calls #5944

merged 5 commits into from
Nov 24, 2023

Conversation

JLGarber
Copy link
Collaborator

This would probably be a lot simpler with matrix math, but I don't know matrices enough to implement them here, so this is what we get instead. It should be largely self-explanatory with the in-line comments, but please criticize away, since this isn't necessarily the nicest implementation.

@cactbotbot
Copy link
Collaborator

cactbotbot commented Nov 23, 2023

@JLGarber Thanks for your contribution! 🌵🚀

@JLGarber JLGarber changed the title Add Ruinous Hex calls raidboss: Lunar Subterrane--Add Ruinous Hex calls Nov 23, 2023
kshman added a commit to kshman/cactbot-build that referenced this pull request Nov 23, 2023
Copy link
Owner

@quisquous quisquous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably be a lot simpler with matrix math, but I don't know matrices enough to implement them here, so this is what we get instead. It should be largely self-explanatory with the in-line comments, but please criticize away, since this isn't necessarily the nicest implementation.

I don't know what you mean by matrix math.

I think my only concern here is that this seems a little fragile to make assumptions about safe spot based on patterns, but if you feel convinced from your data, then I'm fine to merge it.

If you wanted an optional alternate implementation suggestion, then I'd suggest something like this approach:

let safeX = [0, 1, 2, 3];
let safeY = [0, 1, 2, 3];

for (const staff of staffs) {
  // map staff positions into 0-3 row/col coordinates
  const col = Math.round((staff.x - centerX) / something + something);
  const row = Math.round((staff.y - centerY) / something + something);
  
  safeX = safeX.filter((x) => x !== col);
  safeY = safeY.filter((y) => y !== row);
}

const [finalX] = safeX;
const [finalY] = safeY;
if (finalX == undefined || finalY === undefined || safeX.length !== 1 || safeY.length !== 1)
  return;

// use safeX and safe Y to return a square

ui/raidboss/data/06-ew/dungeon/the_lunar_subterrane.ts Outdated Show resolved Hide resolved
@JLGarber
Copy link
Collaborator Author

Okay, thank you, that's a much better approach. I know the implementation I'm using here involves comparisons against numeric positions, but I think it's safe enough given that we know these positions are accurate, and that we're rounding everything. This worked perfectly in testing, and it should handle any possible staff setup regardless of whether we have seen it before.

@quisquous quisquous merged commit 5044892 into quisquous:main Nov 24, 2023
6 checks passed
@quisquous
Copy link
Owner

Thanks! Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants