Skip to content

Commit

Permalink
bxt_ch_checkpoint: fix stamina for CS 1.6 and restore gravity
Browse files Browse the repository at this point in the history
  • Loading branch information
khanghugo committed Apr 30, 2024
1 parent 0fcd61e commit 572ccf4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,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 @@ -3330,6 +3331,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 @@ -3356,7 +3358,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");
}
};

Expand Down Expand Up @@ -3393,13 +3398,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 @@ -3408,6 +3415,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 @@ -3432,6 +3440,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 @@ -3459,6 +3469,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 @@ -3495,6 +3506,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 @@ -3522,6 +3534,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

0 comments on commit 572ccf4

Please sign in to comment.