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

bxt_ch_checkpoint: fix stamina for CS 1.6 and restore gravity #526

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ void HwDLL::Clear()
ch_checkpoint_vel.clear();
ch_checkpoint_viewangles.clear();
ch_checkpoint_is_duck.clear();
ch_checkpoint_gravity.clear();


tas_editor_mode = TASEditorMode::DISABLED;
Expand Down Expand Up @@ -3314,6 +3315,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Create
static void handler()
{
auto &hw = HwDLL::GetInstance();
auto &cl = ClientDLL::GetInstance();

auto pl = hw.GetPlayerEdict();

Expand All @@ -3340,7 +3342,10 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Create
hw.ch_checkpoint_vel.emplace_back(pl->v.velocity);
hw.ch_checkpoint_viewangles.emplace_back(pl->v.v_angle);
hw.ch_checkpoint_is_duck.emplace_back(is_duck);
hw.ch_checkpoint_gravity.emplace_back(pl->v.gravity);
hw.ch_checkpoint_is_set = true;

hw.is_cstrike_dir = cl.DoesGameDirMatch("cstrike") || cl.DoesGameDirMatch("czero");
YaLTeR marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand Down Expand Up @@ -3377,13 +3382,15 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo
Vector cp_vel;
Vector cp_viewangles;
bool cp_is_duck;
float cp_gravity;

if ((id > 0) && (hw.ch_checkpoint_is_duck.size() >= id)) // If ID is more than 0 and the size of std::vector is not less than the specified ID, we are fine!
{
cp_origin = hw.ch_checkpoint_origin[id - 1];
cp_vel = hw.ch_checkpoint_vel[id - 1];
cp_viewangles = hw.ch_checkpoint_viewangles[id - 1];
cp_is_duck = hw.ch_checkpoint_is_duck[id - 1];
cp_gravity = hw.ch_checkpoint_gravity[id - 1];
hw.ch_checkpoint_current = id;
}
else // Otherwise we will use the last element
Expand All @@ -3392,6 +3399,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo
cp_vel = hw.ch_checkpoint_vel.back();
cp_viewangles = hw.ch_checkpoint_viewangles.back();
cp_is_duck = hw.ch_checkpoint_is_duck.back();
cp_gravity = hw.ch_checkpoint_gravity.back();
hw.ch_checkpoint_current = hw.ch_checkpoint_total;
}

Expand All @@ -3416,6 +3424,8 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo
// for CS 1.6 stamina reset
if (hw.is_cstrike_dir)
pl->v.fuser2 = 0;

pl->v.gravity = cp_gravity;
}
};

Expand Down Expand Up @@ -3443,6 +3453,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Reset
hw.ch_checkpoint_vel.clear();
hw.ch_checkpoint_viewangles.clear();
hw.ch_checkpoint_is_duck.clear();
hw.ch_checkpoint_gravity.clear();
hw.ch_checkpoint_total = hw.ch_checkpoint_current = 0;
hw.ORIG_Con_Printf("Cleared the checkpoints.\n");
}
Expand Down Expand Up @@ -3479,6 +3490,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove
hw.ch_checkpoint_vel.erase(hw.ch_checkpoint_vel.begin() + (id - 1));
hw.ch_checkpoint_viewangles.erase(hw.ch_checkpoint_viewangles.begin() + (id - 1));
hw.ch_checkpoint_is_duck.erase(hw.ch_checkpoint_is_duck.begin() + (id - 1));
hw.ch_checkpoint_gravity.erase(hw.ch_checkpoint_gravity.begin() + (id - 1));
hw.ORIG_Con_Printf("Removed the checkpoint with %lu id.\n", id);
}
else
Expand Down Expand Up @@ -3506,6 +3518,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove_After
hw.ch_checkpoint_vel.erase(hw.ch_checkpoint_vel.begin() + id, hw.ch_checkpoint_vel.end());
hw.ch_checkpoint_viewangles.erase(hw.ch_checkpoint_viewangles.begin() + id, hw.ch_checkpoint_viewangles.end());
hw.ch_checkpoint_is_duck.erase(hw.ch_checkpoint_is_duck.begin() + id, hw.ch_checkpoint_is_duck.end());
hw.ch_checkpoint_gravity.erase(hw.ch_checkpoint_gravity.begin() + id, hw.ch_checkpoint_gravity.end());
hw.ch_checkpoint_total = id;
hw.ORIG_Con_Printf("Removed the checkpoints following %lu id.\n", id);
}
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ class HwDLL : public IHookableNameFilterOrdered
std::vector<Vector> ch_checkpoint_vel;
std::vector<Vector> ch_checkpoint_viewangles;
std::vector<bool> ch_checkpoint_is_duck;
std::vector<float> ch_checkpoint_gravity;

public:
bool is_big_map = false;
Expand Down
Loading