BrogueCE icon indicating copy to clipboard operation
BrogueCE copied to clipboard

Refactor visibility checks

Open tmewett opened this issue 1 year ago • 2 comments

The whole cluster of revealed, hidden, and seen is very confusing. Practically all relevant parts of the code us a confusing combination which maps to an easily-describable meaning like "location known". We should refactor them around those relevant combinations.

Also, canSeeMonster is misnamed. No guarantee you can actually see it - not hidden and out-of-sight returns true.

tmewett avatar Sep 26 '23 16:09 tmewett

This is a contributor to the kinds of inconsistencies fixed by #540.

tmewett avatar Sep 26 '23 16:09 tmewett

So I ended up analyzing and rewriting the vision/aggression/attack logic from scratch. It's actually pretty clean!

WIP fork on my repo here

The WIP only includes the fixes for whip/pike/flail/axe.

I have the entire rewrite working locally with no issues (all monster behavior and player vision). There's 51 code points in the full rewrite, the WIP version only has the 6 needed to fix the player's weapons.

For the full rewrite, I'm not confident that I parsed the logic correctly for each case. However, it did bring up a LOT of questions that may need to be addressed before applying the entire rewrite:

  • Q: Can the player have inanimate allies?
  • Q: Should phantoms be visible in deep water?
  • Q: Should player attack entranced creature when bumping it?
  • Q: Should an entranced creature attack the player when bumping?
  • Q: Should confused player hit allies when stepping by them with a flail?
  • Q: Should confused player accidentally lunge-attack allies?
  • Q: Should confused player with armor of mutuality damage allies when triggered?
  • Q: Should confused monsters blink toward allies to attack them?
  • Q: Should confused monsters swarm at friends?
  • Q: Should confused monsters negate friends?
  • Q: Should confused casters target their enemies with buffs (heal, shield, etc)?
  • Q: Should confused casters target their friends with damaging spells?
  • Q: Should monsters avoid swarming futile enemies?
  • Q: Ally casters only cast when the player can see them - should they?
  • Q: Should non-teammate monsters who are not enemies cast spells to help each other?
  • Q: Should ally salamander light revenants on fire when attacking?
  • Q: Monsters ignore line-of-sight - should they?
  • Q: Apparently, cornered creatures can see invisible creatures?

brturn avatar May 13 '24 03:05 brturn