Skip to content

Commit

Permalink
feat: add duck parameter to autojump
Browse files Browse the repository at this point in the history
also make autojump parameter more strict
  • Loading branch information
Krzyhau committed Nov 4, 2023
1 parent 405a497 commit f56d5c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/Features/Tas/TasTools/AutoJumpTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ void AutoJumpTool::Apply(TasFramebulk &bulk, const TasPlayerInfo &pInfo) {
if (params.enabled) {
if (pInfo.grounded && !pInfo.ducked && !hasJumpedLastTick) {
bulk.buttonStates[TasControllerInput::Jump] = true;
if (params.ducked) {
bulk.buttonStates[TasControllerInput::Crouch] = true;
}
hasJumpedLastTick = true;
} else {
bulk.buttonStates[TasControllerInput::Jump] = false;
if (params.ducked) {
bulk.buttonStates[TasControllerInput::Crouch] = false;
}
hasJumpedLastTick = false;
}
} else {
Expand All @@ -29,7 +35,17 @@ std::shared_ptr<TasToolParams> AutoJumpTool::ParseParams(std::vector<std::string
if (vp.size() != 1)
throw TasParserException(Utils::ssprintf("Wrong argument count for tool %s: %d", this->GetName(), vp.size()));

bool arg = vp[0] == "on";
bool ducked = false;
bool enabled = false;

return std::make_shared<AutoJumpToolParams>(arg);
if (vp[0] == "on") {
enabled = true;
} else if (vp[0] == "ducked" || vp[0] == "duck") {
enabled = true;
ducked = true;
} else if (vp[0] != "off") {
throw TasParserException(Utils::ssprintf("Bad parameter for tool %s: %s", this->GetName(), vp[0].c_str()));
}

return std::make_shared<AutoJumpToolParams>(enabled, ducked);
}
7 changes: 5 additions & 2 deletions src/Features/Tas/TasTools/AutoJumpTool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ struct AutoJumpToolParams : public TasToolParams {
AutoJumpToolParams()
: TasToolParams() {
}
AutoJumpToolParams(bool enabled)
: TasToolParams(enabled) {
AutoJumpToolParams(bool enabled, bool ducked)
: TasToolParams(enabled)
, ducked(ducked) {
}

bool ducked = false;
};

class AutoJumpTool : public TasToolWithParams<AutoJumpToolParams> {
Expand Down

0 comments on commit f56d5c2

Please sign in to comment.