Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Added LockMouseAimInput as an explicit parameter, to make crabs less …
Browse files Browse the repository at this point in the history
…clunky unless they explicitly want it
  • Loading branch information
Causeless committed Nov 20, 2023
1 parent 153465b commit fdd94f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Entities/ACrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void ACrab::Clear()
m_JumpTimer.Reset();
m_AimRangeUpperLimit = -1;
m_AimRangeLowerLimit = -1;
m_LockMouseAimInput = false;
}


Expand Down Expand Up @@ -246,6 +247,7 @@ int ACrab::Create(const ACrab &reference) {
m_SweepRange = reference.m_SweepRange;
m_AimRangeUpperLimit = reference.m_AimRangeUpperLimit;
m_AimRangeLowerLimit = reference.m_AimRangeLowerLimit;
m_LockMouseAimInput = reference.m_LockMouseAimInput;

return 0;
}
Expand Down Expand Up @@ -347,6 +349,7 @@ int ACrab::ReadProperty(const std::string_view &propName, Reader &reader)
MatchForwards("RDislodgeLimbPath") MatchProperty("RightDislodgeLimbPath", { reader >> m_Paths[RIGHTSIDE][FGROUND][DISLODGE]; });
MatchProperty("AimRangeUpperLimit", { reader >> m_AimRangeUpperLimit; });
MatchProperty("AimRangeLowerLimit", { reader >> m_AimRangeLowerLimit; });
MatchProperty("LockMouseAimInput", { reader >> m_LockMouseAimInput; });

EndPropertyList;
}
Expand Down Expand Up @@ -402,6 +405,8 @@ int ACrab::Save(Writer &writer) const
writer << m_AimRangeUpperLimit;
writer.NewProperty("AimRangeLowerLimit");
writer << m_AimRangeLowerLimit;
writer.NewProperty("LockMouseAimInput");
writer << m_LockMouseAimInput;

return 0;
}
Expand Down Expand Up @@ -1133,7 +1138,7 @@ void ACrab::PreControllerUpdate()
m_AimAngle = FacingAngle(m_AimAngle);

// Clamp the analog aim too, so it doesn't feel "sticky" at the edges of the aim limit
if (m_Controller.IsPlayerControlled()) {
if (m_Controller.IsPlayerControlled() && m_LockMouseAimInput) {
float mouseAngle = g_UInputMan.AnalogAimValues(m_Controller.GetPlayer()).GetAbsRadAngle();
Clamp(mouseAngle, FacingAngle(adjustedAimRangeUpperLimit), FacingAngle(adjustedAimRangeLowerLimit));
g_UInputMan.SetMouseValueAngle(mouseAngle, m_Controller.GetPlayer());
Expand Down
2 changes: 2 additions & 0 deletions Entities/ACrab.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ int FirearmActivationDelay() const;
Timer m_PatrolTimer;
// Timer for how long to be firing the jetpack in a direction
Timer m_JumpTimer;
// Whether mouse input should be locked to the aim range, or whether we can "wander" out. For static emplacements like turrets, this is good, but for moving things it's a bit sticky.
bool m_LockMouseAimInput;

#pragma region Event Handling
/// <summary>
Expand Down

0 comments on commit fdd94f7

Please sign in to comment.