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 pitch_override #518

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BunnymodXT/modules/ClientDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,10 @@ HOOK_DEF_1(ClientDLL, void, __cdecl, V_CalcRefdef, ref_params_t*, pparams)
pparams->viewangles[1] = hwDLL.RenderYawOverrides[hwDLL.RenderYawOverrideIndex - 1];
}

if (hwDLL.RenderPitchOverrideIndex != 0 && hwDLL.RenderPitchOverrideIndex <= hwDLL.RenderPitchOverrides.size()) {
pparams->viewangles[0] = hwDLL.RenderPitchOverrides[hwDLL.RenderPitchOverrideIndex - 1];
}

float forward_offset = CVars::bxt_viewmodel_ofs_forward.GetFloat();
float right_offset = CVars::bxt_viewmodel_ofs_right.GetFloat();
float up_offset = CVars::bxt_viewmodel_ofs_up.GetFloat();
Expand Down
39 changes: 39 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,10 @@ void HwDLL::Clear()
TargetYawOverrides.clear();
RenderYawOverrideIndex = 0;
RenderYawOverrides.clear();
PitchOverrideIndex = 0;
PitchOverrides.clear();
RenderPitchOverrideIndex = 0;
RenderPitchOverrides.clear();
lastLoadedMap.clear();
isOverridingCamera = false;
isOffsettingCamera = false;
Expand Down Expand Up @@ -2541,6 +2545,10 @@ void HwDLL::ResetTASPlaybackState()
TargetYawOverrides.clear();
RenderYawOverrideIndex = 0;
RenderYawOverrides.clear();
PitchOverrideIndex = 0;
PitchOverrides.clear();
RenderPitchOverrideIndex = 0;
RenderPitchOverrides.clear();
}

void HwDLL::StartTASPlayback()
Expand Down Expand Up @@ -5639,6 +5647,8 @@ void HwDLL::SetTASEditorMode(TASEditorMode mode)
}
RenderYawOverrides.clear();
RenderYawOverrideIndex = 0;
RenderPitchOverrides.clear();
RenderPitchOverrideIndex = 0;

assert(movementFrameCounter >= 1);
tas_editor_input.first_frame_counter_value = movementFrameCounter - 1;
Expand Down Expand Up @@ -6169,6 +6179,25 @@ void HwDLL::InsertCommands()
RenderYawOverrideIndex += 1;
}

if (PitchOverrideIndex == PitchOverrides.size()) {
PitchOverrides.clear();
PitchOverrideIndex = 0;
}

if (PitchOverrides.empty()) {
StrafeState.PitchOverrideActive = false;
} else {
StrafeState.PitchOverride = PitchOverrides[PitchOverrideIndex++];
StrafeState.PitchOverrideActive = true;
}

if (RenderPitchOverrideIndex == RenderPitchOverrides.size()) {
RenderPitchOverrides.clear();
RenderPitchOverrideIndex = 0;
} else {
RenderPitchOverrideIndex += 1;
}

f.ResetAutofuncs();

resulting_frame.SetPitch(p.Pitch);
Expand Down Expand Up @@ -6589,6 +6618,14 @@ void HwDLL::InsertCommands()
} else if (!f.RenderYawOverride.empty()) {
RenderYawOverrides = f.RenderYawOverride;
RenderYawOverrideIndex = 0;
} else if (!f.PitchOverride.empty()) {
PitchOverrides = f.PitchOverride;
StrafeState.PitchOverrideActive = true;
StrafeState.PitchOverride = PitchOverrides[0];
PitchOverrideIndex = 1;
} else if (!f.RenderPitchOverride.empty()) {
RenderPitchOverrides = f.RenderPitchOverride;
RenderPitchOverrideIndex = 0;
}

currentFramebulk++;
Expand Down Expand Up @@ -6621,6 +6658,8 @@ void HwDLL::InsertCommands()
if (resetState == ResetState::NORMAL) {
RenderYawOverrides.clear();
RenderYawOverrideIndex = 0;
RenderPitchOverrides.clear();
RenderPitchOverrideIndex = 0;

if (bxt_on_tas_playback_frame) {
// We don't use the return value here because we stop anyway.
Expand Down
4 changes: 4 additions & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,14 @@ class HwDLL : public IHookableNameFilterOrdered
unsigned LoadingSeedCounter;
size_t TargetYawOverrideIndex;
std::vector<float> TargetYawOverrides;
size_t PitchOverrideIndex;
std::vector<float> PitchOverrides;
float sensitivityToRestore = 0;
public:
size_t RenderYawOverrideIndex;
std::vector<float> RenderYawOverrides;
size_t RenderPitchOverrideIndex;
std::vector<float> RenderPitchOverrides;
bool ButtonsPresent;
HLTAS::StrafeButtons Buttons;
HLStrafe::CurrentState StrafeState;
Expand Down