Skip to content

Commit

Permalink
Gives Screenshake an actual smoothing value versus just jumping over …
Browse files Browse the repository at this point in the history
…a single frame (#6524)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->

# About the pull request

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->


![image](https://github.com/cmss13-devs/cmss13/assets/158611449/58503bfd-0c2e-42b9-8534-8d2d01281d28)

![image](https://github.com/cmss13-devs/cmss13/assets/158611449/226062a7-0e76-40c0-b488-1a0481125ca6)

Basically in game rn, screenshake uses jump easing, which over the span
of a single frame sends you from your current screen position to the
location of the screenshake. This PR gives it cubic easing, which while
being one of the more 'rough' easing options, makes it look like your
FPS arent dropping.


# Explain why it's good for the game

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding, and may discourage maintainers from reviewing or merging
your PR. This section is not strictly required for (non-controversial)
fix PRs or backend PRs. -->

Screenshake looked extremely low FPS/jumpy and honestly over long
periods of screenshake like queen screech kinda made your eyes hurt.
CM's screenshake was one of the worst of any SS13 servers and had us
looking extremely dated.

Screenshake should be Screenshake,not give players motion sickness 

This PR fixes that, now with screenshake being heavily dependent on your
personal FPS choice, with those who choose to play on the server
FPS/lower FPS having whats more similarly to the older 'jumpy'
screenshake, while those on higher FPS have to deal with random low FPS
screenshake

The vids speak for themselves

# Testing Photographs and Procedure
<!-- Include any screenshots/videos/debugging steps of the modified code
functioning successfully, ideally including edge cases. -->

<!-- !! If you are modifying sprites, you **must** include one or more
in-game screenshots or videos of the new sprites. !! -->

<details>
<summary>Screenshots & Videos</summary>

I have vids of what it looks like too for gun recoil but photoshop
refuses to render my videos so theyll come later

What it used to look like:
https://streamable.com/c4wk97

One of the worst examples of old screenshake (at 48fps)
https://streamable.com/iyj8d7

What it looks like now (note I use 48 FPS for first one, then server FPS
for low fps ones)
https://streamable.com/5nd11l

</details>

Like the stuff I make?

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/J3J6102QI0)

# Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
label your changes in the changelog. Please note that maintainers freely
reserve the right to remove and add tags should they deem it
appropriate. You can attempt to finagle the system all you want, but
it's best to shoot for clear communication right off the bat. -->
<!-- If you add a name after the ':cl', that name will be used in the
changelog. You must add your CKEY after the CL if your GitHub name
doesn't match. Maintainers freely reserve the right to remove and add
tags should they deem it appropriate. -->

:cl:

qol: Makes screenshake look less low FPS/jumpy
/:cl:

<!-- Both :cl:'s are required for the changelog to work! -->
  • Loading branch information
GrrrKitten committed Jul 4, 2024
1 parent 0a0c34f commit 304358b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ GLOBAL_LIST_INIT(limb_types_by_name, list(
message = replace_X.Replace(message, "CKTH")
return message

#define PIXELS_PER_STRENGTH_VAL 24
#define PIXELS_PER_STRENGTH_VAL 28

/proc/shake_camera(mob/M, steps = 1, strength = 1, time_per_step = 1)
if(!M?.client || (M.shakecamera > world.time))
Expand All @@ -326,10 +326,10 @@ GLOBAL_LIST_INIT(limb_types_by_name, list(
var/old_X = M.client.pixel_x
var/old_y = M.client.pixel_y

animate(M.client, pixel_x = old_X + rand(-(strength), strength), pixel_y = old_y + rand(-(strength), strength), easing = JUMP_EASING, time = time_per_step, flags = ANIMATION_PARALLEL)
animate(M.client, pixel_x = old_X + rand(-(strength), strength), pixel_y = old_y + rand(-(strength), strength), easing = CUBIC_EASING | EASE_IN, time = time_per_step, flags = ANIMATION_PARALLEL)
var/i = 1
while(i < steps)
animate(pixel_x = old_X + rand(-(strength), strength), pixel_y = old_y + rand(-(strength), strength), easing = JUMP_EASING, time = time_per_step)
animate(pixel_x = old_X + rand(-(strength), strength), pixel_y = old_y + rand(-(strength), strength), easing = CUBIC_EASING | EASE_IN, time = time_per_step)
i++
animate(pixel_x = old_X, pixel_y = old_y,time = clamp(floor(strength/PIXELS_PER_STRENGTH_VAL),2,4))//ease it back

Expand Down

0 comments on commit 304358b

Please sign in to comment.