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

make the health indicator blink if low #267

Merged
merged 2 commits into from
Feb 15, 2017

Conversation

snshn
Copy link

@snshn snshn commented Feb 11, 2017

There's no game->getSecond(), so currently made it disappear once every two game-minutes, even though the vanilla engine makes it blink exactly twice in a single game-minute.
The time runs slightly faster in the original game than so I thought it's okay for now.

@JayFoxRox
Copy link
Collaborator

JayFoxRox commented Feb 11, 2017

I'd suggest introducing a new variable in void IngameState::tick(float dt) to at least get the right behaviour.

Ideally we'll replace all of that with better code in the future? (I don't really like the autolook timer or my money hack either)

//Edit: Also please don't upate submodules unless necessary

@danhedron
Copy link
Member

There's a floating point game timer GameState::gameTime, that will give sub-second accuracy.

@snshn
Copy link
Author

snshn commented Feb 12, 2017

Taken care of accidentally including the submodules in the commit.

The ::tick(float dt) way of doing it is probably more correct, but might be a bit too complex for my current level of understanding of the codebase.

Seems like using gameTime here worked quite well. It blinks with a pretty similar frequency to the original engine.

I agree with JayFoxRox and think that the code I'm committing here will eventually be replaced with the introduction of librw or just during one of code refactors in the future. I'm not too proud of this commit, but still feel like it's worth including just to make the UI behavior more complete at this stage.

@danhedron
Copy link
Member

If blinking twice is the correct behaviour (it looks like it is) could you make this blink twice per in-game minute. That way we can have the correct behaviour in place when comparing behaviour before & after if this code gets refactored.

Besides that, looks good to me.

@snshn
Copy link
Author

snshn commented Feb 13, 2017

Sure. Could you please hint me at what the multiplier for gameMinute is, relative to gameTime?
I'm currently using 6.0 (42dbdb7#diff-dc88e3c6f116fe7ce03ca1b2e3bf3668R107) but it's likely not half of an in-game minute.

@JayFoxRox
Copy link
Collaborator

@vflyson I'm assuming the health blink is not tied to the game clock (gameMinute) but instead to a global timer (gameTime) (which may or may not pause in certain situations [pause menu etc.]). Did you try running the original game with cheats (do those exist) to advance the clock faster or something?

I'm not sure how fast any of these timers advance (but assume frames or seconds), so we still need @danhedron or you'll have to figure this out yourself :)

@snshn
Copy link
Author

snshn commented Feb 13, 2017

@JayFoxRox I've used adrenaline today (which on my 20th anniversary version freezes the in-game time completely) and the health indicator continued to blink with exactly the same frequency. It is most likely tied to the computer's clock in vanilla, not to in-game seconds of sorts.

Found a video on youtube where the health is low. The health indicator goes off 2 times and on 2 times as well in a single in-game minute, which makes it 1/4 of a game minute. I've updated the multiplier here, should be good to go.

@@ -102,19 +103,20 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world,

infoTextY += ui_textHeight;

{
if (player->getCharacter()->getCurrentState().health > ui_lowHealth
|| (int)(world->getGameTime() * 4.f) % 2) {
Copy link
Collaborator

@JayFoxRox JayFoxRox Feb 13, 2017

Choose a reason for hiding this comment

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

how about fmod?
I'm totally against float pointers in general because they easily become inprecise due to float precision.
However, while we have them it looks like an even worse idea to convert them to integer.

//Edit: Also a comment what this math does wouldn't hurt (like: // UI: Blinking health indicator if health is low)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the tip!

@danhedron
Copy link
Member

LGTM

@danhedron danhedron merged commit 481a705 into rwengine:master Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants