-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "ShootTool.hpp" | ||
|
||
#include "Modules/Engine.hpp" | ||
#include "Modules/Server.hpp" | ||
#include "Features/EntityList.hpp" | ||
#include "Features/Tas/TasParser.hpp" | ||
#include "Features/Tas/TasPlayer.hpp" | ||
|
||
ShootTool tasShootTool[2] = { {0}, {1} }; | ||
|
||
void ShootTool::Apply(TasFramebulk &bulk, const TasPlayerInfo &pInfo) { | ||
if (params.enabled) { | ||
|
||
void *player = server->GetPlayer(pInfo.slot + 1); | ||
|
||
if (player == nullptr || (int)player == -1) return; | ||
|
||
uintptr_t portalgun = (uintptr_t)entityList->LookupEntity(SE(player)->active_weapon()); | ||
if (!portalgun) return; | ||
|
||
float nextPrimaryAttack = SE(portalgun)->field<float>("m_flNextPrimaryAttack"); | ||
|
||
float currTime = pInfo.tick * pInfo.ticktime; | ||
|
||
bool canShoot = (nextPrimaryAttack <= currTime) || params.hold; | ||
bulk.buttonStates[params.shotPortal] = canShoot; | ||
|
||
if (!params.spam && !params.hold) { | ||
Reset(); | ||
} | ||
} | ||
} | ||
|
||
std::shared_ptr<TasToolParams> ShootTool::ParseParams(std::vector<std::string> vp) { | ||
if (vp.size() < 1 || vp.size() > 2) | ||
throw TasParserException(Utils::ssprintf("Wrong argument count for tool %s: %d", this->GetName(), vp.size())); | ||
|
||
bool enabled = true; | ||
TasControllerInput button; | ||
bool hold = false; | ||
bool spam = false; | ||
|
||
for (std::string param : vp) { | ||
if (param == "off" || param == "stop") { | ||
enabled = false; | ||
} | ||
else if (param == "blue") { | ||
button = TasControllerInput::FireBlue; | ||
} | ||
else if (param == "orange") { | ||
button = TasControllerInput::FireOrange; | ||
} | ||
else if (param == "hold") { | ||
hold = true; | ||
} | ||
else if (param == "spam") { | ||
spam = true; | ||
} | ||
else { | ||
throw TasParserException(Utils::ssprintf("Incorrect parameter for tool %s: %s", this->GetName(), param.c_str())); | ||
} | ||
} | ||
|
||
return std::make_shared<ShootToolParams>(enabled, button, spam, hold); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "../TasTool.hpp" | ||
#include "../TasController.hpp" | ||
|
||
struct ShootToolParams : public TasToolParams { | ||
|
||
TasControllerInput shotPortal; | ||
bool spam; | ||
bool hold; | ||
|
||
ShootToolParams() | ||
: TasToolParams() { | ||
} | ||
ShootToolParams(bool enabled, TasControllerInput shotPortal, bool spam, bool hold) | ||
: TasToolParams(enabled) | ||
, shotPortal(shotPortal) | ||
, spam(spam) | ||
, hold(hold) { | ||
} | ||
}; | ||
|
||
class ShootTool : public TasToolWithParams<ShootToolParams> { | ||
public: | ||
ShootTool(int slot) : TasToolWithParams("shoot", slot) {} | ||
|
||
virtual std::shared_ptr<TasToolParams> ParseParams(std::vector<std::string>); | ||
virtual void Apply(TasFramebulk &bulk, const TasPlayerInfo &pInfo); | ||
}; | ||
|
||
extern ShootTool tasShootTool[2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters