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

Creatures above cast shadows onto tiles below #66730

Merged
merged 11 commits into from
Jul 10, 2023

Conversation

Rewryte
Copy link
Contributor

@Rewryte Rewryte commented Jul 7, 2023

Summary

Features "Creatures above cast shadows onto tiles below"

Purpose of change

Creatures above the z-level of the player can be difficult to detect due to the lack of visual indications of their presence.
Fixes #66657

Describe the solution

Make creatures cast shadows unto tiles below. Image used for the shadow is determined by each tileset via the new shadow sprite id. The hostility indicator will also be drawn when applicable. Naturally, this feature will not be functional until a shadow sprite is assigned to the tilesets and the next tileset update takes place. I will work on that unless someone else wants to.

shadowtest

A simpler version is used in curses which mimics how critters below the current z-level are currently drawn. Because the "critter above" indicator has the potential to obscure the underlying tile, both the "critter above" and "critter below" indicator were made to blink. These are affected by the "Blinking effects speed" setting.

curses

Describe alternatives you've considered

Testing

Builds ok in both tiles and curses.
Tested in both isometric and non-isometric mode by assigning a shadow sprite using a mod
Both shadow and hostility indicators are drawn correctly.
Performance impact is negligible.

Additional context

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [C++] Changes (can be) made in C++. Previously named `Code` [Markdown] Markdown issues and PRs [Python] Code made in Python Code: Tooling Tooling that is not part of the main game but is part of the repo. <Enhancement / Feature> New features, or enhancements on existing json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jul 7, 2023
@GuardianDll
Copy link
Member

I guess it should resolve #66657

@Rewryte
Copy link
Contributor Author

Rewryte commented Jul 7, 2023

I guess it should resolve #66657

Thanks. Updated main comment.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jul 7, 2023
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
Rewryte and others added 2 commits July 8, 2023 01:36
Co-Authored-By: Jianxiang Wang (王健翔) <[email protected]>
@Rewryte Rewryte marked this pull request as ready for review July 7, 2023 17:43
@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Jul 7, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Auto-requesting reviews from non-collaborators: @jbytheway

@RenechCDDA
Copy link
Member

I hope you don't mind some questions

How does it handle if a creature(with its own sprite) is occupying the tile where the shadow would be placed? (Looking at the changes, seems it just doesn't draw the shadow?)

What if the creature on z=0 does not have a sprite defined (or is using ASCII fallback), does it still cancel out drawing the shadow sprite?

Does it draw the shadow if the shadow would be placed on an 'impassable' tile (e.g. the walled edge of a building)?

@Rewryte
Copy link
Contributor Author

Rewryte commented Jul 7, 2023

How does it handle if a creature(with its own sprite) is occupying the tile where the shadow would be placed? (Looking at the changes, seems it just doesn't draw the shadow?)

Yup. Tilesets like Ultica give creatures their own shadows so I didn't think it necessary.

What if the creature on z=0 does not have a sprite defined (or is using ASCII fallback), does it still cancel out drawing the shadow sprite?

Any draw function with a fallback should still return true which should stop the shadow drawing. If nothing is drawn, such as in the case of an invisible creature, then the shadow function will run.

Does it draw the shadow if the shadow would be placed on an 'impassable' tile (e.g. the walled edge of a building)?

Nope. Both walls and the ceiling above them should return true on dont_draw_lower_floor. This stops the function from scanning for creatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tooling Tooling that is not part of the main game but is part of the repo. <Documentation> Design documents, internal info, guides and help. <Enhancement / Feature> New features, or enhancements on existing json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs [Python] Code made in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The ability to see flying creatures as well as those under the ground
5 participants