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

Touchups to spellcasting behavior and UI #2598

Merged
merged 1 commit into from
Apr 15, 2023

Conversation

chaosvolt
Copy link
Member

Summary

SUMMARY: Bugfixes "Spellcasting menu cancels out early if all spells out of energy, don't show max mana unless you actually know a mana-casting spell"

Purpose of change

This fixes two bits of weirdness with spellcasting and associated UI.

Describe the solution

  1. In handle_action.cpp, changed cast_spell so that the "check if you're too out of energy to cast any spells" check to properly return out of the function instead of continuing, fixing the issue where it would say "you can't cast any of the spells you know" but still open to a menu of currently-uncastable spells.
  2. In panels.cpp, changed spell_panel to check the player's known spells for any mana-casting spells to determine if it returns true. This fixes it so that mana and max mana only shows on your sidebar if one of your spells actually costs mana.

Describe alternatives you've considered

I'm not 100% sure if vector-ifying avatar's known spells and running some for logic on them will have any performance impact over the previous "check a bool on the avatar that will in turn check their known spells" method.

Testing

  1. Compiled and load-tested.
  2. Started up a world with Magiclysm.
  3. Tried to cast with no spells available, same message as usual shows up.
  4. Read up a scroll of Megablast, confirmed mana display did not show up since it costs stamina.
  5. Rigged my stats and skills so I could actually cast it, confirmed it prevents opening the spell menu after I drain my stamina.
  6. Read a scroll of Mana Beam, confirmed that now the mana display pops up.
  7. Spammed my way through my mana reserves and depleted stamina again, confirmed that spell menu only cancels early when I don't have the resources for any of my spells.
  8. Checked affected files for astyle.

Additional context

@github-actions github-actions bot added the src PR changes related to source code. label Apr 8, 2023
@chaosvolt chaosvolt merged commit ca7c4f3 into cataclysmbnteam:upload Apr 15, 2023
@chaosvolt chaosvolt deleted the smol-magic-fixes branch April 15, 2023 11:20
@DarianLStephens
Copy link

Oh, I'm not sure how I feel about not opening the spell list when none of your spells have the mana needed to cast.
I might still like to look at the list to know how close I am to being able to use something, even if I can't right now, instead of needing to guess or remember the value.
It'd be like hiding all guns in your inventory if you didn't have the ammo for any of them. You could easily forget what you have available, and what you need to use them.

I could be misunderstanding this change, though, and that's not what's actually happening?

@chaosvolt
Copy link
Member Author

Hmm. That's...a good point actually. The problem this fixed was it printing a useless message that doesn't matter until after you've closed the spell menu (by which time you already know you can't cast any of the spells on your menu), but just eliminating the message outright and letting you view your spell menu would work as an alternative solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src PR changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants