-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
0622366
commit 90eca6d
Showing
37 changed files
with
309 additions
and
453 deletions.
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
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
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
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
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
73 changes: 73 additions & 0 deletions
73
extension/bot/tf2/tasks/engineer/tf2bot_engineer_speedup_object.cpp
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,73 @@ | ||
#include <extension.h> | ||
#include <util/helpers.h> | ||
#include <entities/tf2/tf_entities.h> | ||
#include <mods/tf2/tf2lib.h> | ||
#include <bot/tf2/tf2bot.h> | ||
#include "tf2bot_engineer_speedup_object.h" | ||
|
||
CTF2BotEngineerSpeedUpObjectTask::CTF2BotEngineerSpeedUpObjectTask(CBaseEntity* object) : | ||
m_object(object) | ||
{ | ||
} | ||
|
||
TaskResult<CTF2Bot> CTF2BotEngineerSpeedUpObjectTask::OnTaskStart(CTF2Bot* bot, AITask<CTF2Bot>* pastTask) | ||
{ | ||
if (m_object.Get() == nullptr) | ||
{ | ||
return Done("Goal object is no longer valid"); | ||
} | ||
|
||
return Continue(); | ||
} | ||
|
||
TaskResult<CTF2Bot> CTF2BotEngineerSpeedUpObjectTask::OnTaskUpdate(CTF2Bot* bot) | ||
{ | ||
if (m_object.Get() == nullptr) | ||
{ | ||
return Done("Goal object is no longer valid"); | ||
} | ||
|
||
tfentities::HBaseObject object(m_object.Get()); | ||
|
||
if (object.GetPercentageConstructed() > 0.99f) | ||
{ | ||
return Done("Object is fully constructed!"); | ||
} | ||
|
||
/* TODO position behind sentry if under attack by enemy */ | ||
|
||
auto myweapon = bot->GetActiveBotWeapon(); | ||
|
||
if (myweapon && myweapon->GetModWeaponID<TeamFortress2::TFWeaponID>() != TeamFortress2::TFWeaponID::TF_WEAPON_WRENCH) | ||
{ | ||
CBaseEntity* wrench = bot->GetWeaponOfSlot(TeamFortress2::TFWeaponSlot::TFWeaponSlot_Melee); | ||
|
||
if (wrench) | ||
{ | ||
bot->SelectWeapon(wrench); | ||
} | ||
} | ||
|
||
if (bot->GetRangeTo(object.WorldSpaceCenter()) > get_object_melee_range()) | ||
{ | ||
if (!m_nav.IsValid() || m_nav.GetAge() > 3.0f) | ||
{ | ||
CTF2BotPathCost cost(bot); | ||
|
||
if (!m_nav.ComputePathToPosition(bot, object.GetAbsOrigin(), cost)) | ||
{ | ||
return Done("No path to object."); | ||
} | ||
} | ||
|
||
m_nav.Update(bot); | ||
} | ||
else | ||
{ | ||
bot->GetControlInterface()->AimAt(object.WorldSpaceCenter(), IPlayerController::LOOK_VERY_IMPORTANT, 0.5f, "Looking at object to construct it."); | ||
bot->GetControlInterface()->PressAttackButton(0.5f); | ||
bot->GetControlInterface()->PressCrouchButton(0.5f); | ||
} | ||
|
||
return Continue(); | ||
} |
26 changes: 26 additions & 0 deletions
26
extension/bot/tf2/tasks/engineer/tf2bot_engineer_speedup_object.h
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,26 @@ | ||
#ifndef NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ | ||
#define NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ | ||
|
||
#include <sdkports/sdk_ehandle.h> | ||
#include <bot/interfaces/path/meshnavigator.h> | ||
|
||
class CTF2Bot; | ||
|
||
class CTF2BotEngineerSpeedUpObjectTask : public AITask<CTF2Bot> | ||
{ | ||
public: | ||
CTF2BotEngineerSpeedUpObjectTask(CBaseEntity* object); | ||
|
||
TaskResult<CTF2Bot> OnTaskStart(CTF2Bot* bot, AITask<CTF2Bot>* pastTask) override; | ||
TaskResult<CTF2Bot> OnTaskUpdate(CTF2Bot* bot) override; | ||
|
||
const char* GetName() const override { return "SpeedUpConstruction"; } | ||
|
||
private: | ||
CHandle<CBaseEntity> m_object; | ||
CMeshNavigator m_nav; | ||
|
||
static constexpr auto get_object_melee_range() { return 64.0f; } | ||
}; | ||
|
||
#endif // !NAVBOT_TF2BOT_TASKS_ENGINEER_SPEEDUP_OBJECT_H_ |
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
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
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
Oops, something went wrong.