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

Add conditional camera offset based on cursor - Hristov Rework, Part 1 #31626

Merged
merged 9 commits into from
Jan 27, 2025

Conversation

SlamBamActionman
Copy link
Member

About the PR

This PR focuses on the implementation of cursor-based camera offset for entities, which is intended to be used to simulate a scope for the Hristov. This is part 1 of a two-part Hristov rework; part 2 will focus on bullet behavior, damage and balance tweaks.

When active, the cursor offset feature causes the player camera to be offset by a dynamic amount based on how far away the cursor is from the middle of the game window. This effectively makes it so that you see further in one direction and less in the opposite.

The main system that handles this is EyeCursorOffsetSystem; to activate this, a component CursorOffsetRequiresWieldComponent is also added. Systems are refactored to facilitate these (more under Technical Details).

Why / Balance

The Hristov rework is split up in two parts as they implement different features and it would be fairly overwhelming to do both at once. The two parts are also fairly disconnected from each other codewise, so it's easier to implement.

The cursor offset is set at a max of 3 tiles, which makes the Hristov a much more valuable weapon as a sniper since it now allows ranged shots from outside a normal player's view. The tradeoff of not being able to see as much behind you is relatively minor (more downsides will be introduced in Part 2) but keeps the gun from just being "zoom out" functionality.

The gun requires wielding for the offset to be applied, which is suitable since one-handing it would allow the added range to be used by other one-handed guns.

Technical details

The offset is calculated to be set between 0 and a max distance based on the mouse cursor's position around the player. This is based on a circle radius from the middle of the screen which reaches out to 90% of either the width or height of the game window, whichever is lowest (which is going to be the height most of the time). If the distance between the point the offset currently to where the mouse cursor has moved is greater than a set value, the movement is capped to prevent instant snapping which didn't feel great.

The camera offset behavior has been mildly refactored; it's now run in a central update loop instead of being spread out across multiple systems(SharedCameraRecoilSystem) and risking triggering multiple times in one frame.

WieldableSystem in Shared has been turned into SharedWieldableSystem. This is to allow the Client system to interact with EyeCursorOffsetSystem, which must be in Client due to using mouse cursor input.

Media

2024-08-29.21-01-27.mp4

Requirements

  • I have read and I am following the Pull Request Guidelines. I understand that not doing so may get my pr closed at maintainer’s discretion
  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Changelog

🆑

  • tweak: Hristov now provides an increased view range of 3 tiles when wielded.

@github-actions github-actions bot added the S: Needs Review Status: Requires additional reviews before being fully accepted label Aug 29, 2024
@Hanzdegloker
Copy link
Contributor

It would be so nice to look 4 or so tiles farther in any direction in exchange for being way easier to sneak up behind. Make gunfights allot more dynamic in general. In a vein similiar to what is shown here.

@SlamBamActionman
Copy link
Member Author

It would be so nice to look 4 or so tiles farther in any direction in exchange for being way easier to sneak up behind. Make gunfights allot more dynamic in general. In a vein similiar to what is shown here.

There's a soft limit involving the PVS range that makes it so you can't extend the offset too much. 3 is a decent number for general balance but it also keeps you from seeing pop-in

@slarticodefast
Copy link
Member

Looks really cool. We also need binoculars as an item now. Any way to make it so that it is not bound to being wielded?

@Hanzdegloker
Copy link
Contributor

It would be so nice to look 4 or so tiles farther in any direction in exchange for being way easier to sneak up behind. Make gunfights allot more dynamic in general. In a vein similiar to what is shown here.

There's a soft limit involving the PVS range that makes it so you can't extend the offset too much. 3 is a decent number for general balance but it also keeps you from seeing pop-in

Sounds about right, still any extra sight makes gun battles less shooting at the edge of your screen

@SlamBamActionman
Copy link
Member Author

Looks really cool. We also need binoculars as an item now. Any way to make it so that it is not bound to being wielded?

Yes - you need a system that hooks up for when it should activate/deactivate, but the event for checking it has the boilerplate for both the hands system and the equip system. I haven't tried it but theoretically the effect is additative, so should be able to use two binoculars and get the effect of both!

@Everturning
Copy link

Looks really cool. We also need binoculars as an item now. Any way to make it so that it is not bound to being wielded?

Yes - you need a system that hooks up for when it should activate/deactivate, but the event for checking it has the boilerplate for both the hands system and the equip system. I haven't tried it but theoretically the effect is additative, so should be able to use two binoculars and get the effect of both!

but that is also - stupid, and dumb. is there any way you'd be able to make the system NOT require that?

@SlamBamActionman
Copy link
Member Author

Yes - you need a system that hooks up for when it should activate/deactivate, but the event for checking it has the boilerplate for both the hands system and the equip system. I haven't tried it but theoretically the effect is additative, so should be able to use two binoculars and get the effect of both!

but that is also - stupid, and dumb. is there any way you'd be able to make the system NOT require that?

I am not sure what you mean? If you want to make the camera offset work for when you hold an item in your hand without wielding, you need to code a component that calls the camera offset code when not wielding. It's not difficult, but since I am not implementing that functionality I don't have a reason to take time to include that in this PR.

@metalgearsloth metalgearsloth added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted labels Oct 14, 2024
@KaiserMaus
Copy link

Still progressing?

@SlamBamActionman
Copy link
Member Author

I've made some fairly major changes;
EyeCursorOffsetComponent have been split into a client and server component. This is to help split the functionalities of changing camera offset and camera PVS distance, which it now supports. This helps avoid situations where the offset extends beyond the PVS limit, which would cause pop-in.

@KaiserMaus
Copy link

Bulet .60 fly so slow(standard 25) if you zoom on enemy

@KaiserMaus
Copy link

I've made some fairly major changes; EyeCursorOffsetComponent have been split into a client and server component. This is to help split the functionalities of changing camera offset and camera PVS distance, which it now supports. This helps avoid situations where the offset extends beyond the PVS limit, which would cause pop-in.

Now i can increase distance "zoom" on rifle?

@SlamBamActionman
Copy link
Member Author

I've made some fairly major changes; EyeCursorOffsetComponent have been split into a client and server component. This is to help split the functionalities of changing camera offset and camera PVS distance, which it now supports. This helps avoid situations where the offset extends beyond the PVS limit, which would cause pop-in.

Now i can increase distance "zoom" on rifle?

Yes, this should be possible now. Previously it was gated by the default PVS, but now that can be increased. Be aware that too much zoom may impact performance due to the amount of entities being loaded!

@KaiserMaus
Copy link

I've made some fairly major changes; EyeCursorOffsetComponent have been split into a client and server component. This is to help split the functionalities of changing camera offset and camera PVS distance, which it now supports. This helps avoid situations where the offset extends beyond the PVS limit, which would cause pop-in.

Now i can increase distance "zoom" on rifle?

Yes, this should be possible now. Previously it was gated by the default PVS, but now that can be increased. Be aware that too much zoom may impact performance due to the amount of entities being loaded!

You already finished required changes? Label on pr still "awaiting changes"

@SlamBamActionman SlamBamActionman removed the S: Awaiting Changes Status: Changes are required before another review can happen label Nov 2, 2024
@github-actions github-actions bot added the S: Needs Review Status: Requires additional reviews before being fully accepted label Nov 2, 2024
Copy link
Contributor

github-actions bot commented Nov 3, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the S: Merge Conflict Status: Needs to resolve merge conflicts before it can be accepted label Nov 3, 2024
@SlamBamActionman SlamBamActionman added the S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. label Nov 14, 2024
@eoineoineoin eoineoineoin removed the S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. label Nov 20, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added size/M Denotes a PR that changes 100-999 lines. and removed S: Merge Conflict Status: Needs to resolve merge conflicts before it can be accepted labels Dec 19, 2024
@github-actions github-actions bot added the S: Merge Conflict Status: Needs to resolve merge conflicts before it can be accepted label Jan 5, 2025
Copy link
Contributor

github-actions bot commented Jan 5, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

# Conflicts:
#	Content.Shared/Wieldable/ItemWieldedEvent.cs
#	Content.Shared/Wieldable/SharedWieldableSystem.cs
@github-actions github-actions bot removed the S: Merge Conflict Status: Needs to resolve merge conflicts before it can be accepted label Jan 27, 2025
@github-actions github-actions bot added S: Needs Review Status: Requires additional reviews before being fully accepted and removed S: Awaiting Changes Status: Changes are required before another review can happen labels Jan 27, 2025
@Simyon264 Simyon264 added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted labels Jan 27, 2025
@slarticodefast
Copy link
Member

slarticodefast commented Jan 27, 2025

Keep the base calls
grafik

@Simyon264
Copy link
Member

Ah. Noted. Weird, but makes sense.

@github-actions github-actions bot added S: Needs Review Status: Requires additional reviews before being fully accepted and removed S: Awaiting Changes Status: Changes are required before another review can happen labels Jan 27, 2025
@Simyon264 Simyon264 merged commit 5c782d3 into space-wizards:master Jan 27, 2025
13 checks passed
@KaiserMaus
Copy link

Finally!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: Combat Area: Combat features and changes, balancing, feel A: General Interactions Area: General in-game interactions that don't relate to another area. D2: Medium Difficulty: A good amount of codebase knowledge required. Merge Conflict P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. S: Needs Review Status: Requires additional reviews before being fully accepted size/M Denotes a PR that changes 100-999 lines. T: Balance Change Type: Balance changes through direct value changes, or changes to mechanics that affect it T: New Feature Type: New feature or content, or extending existing content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants