fix some more glitchy stuff
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -869,8 +869,8 @@ Size=240,520
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[WORLD INFO [33 FPS]]
|
[WORLD INFO [33 FPS]]
|
||||||
Pos=651,10
|
Pos=710,10
|
||||||
Size=240,431
|
Size=240,520
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[WORLD INFO [315 FPS]]
|
[WORLD INFO [315 FPS]]
|
||||||
@@ -2123,3 +2123,68 @@ Pos=710,10
|
|||||||
Size=240,520
|
Size=240,520
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [735 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [30 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [28 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [26 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [24 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [777 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [31 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [776 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [774 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [710 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [769 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [763 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[WORLD INFO [748 FPS]]
|
||||||
|
Pos=710,10
|
||||||
|
Size=240,520
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
|||||||
BIN
_DEMO_RELEASE/GPP_Plugin.dll
Normal file
BIN
_DEMO_RELEASE/GPP_Plugin.dll
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,6 @@
|
|||||||
# ./lib CMakeLists.txt
|
# ./lib CMakeLists.txt
|
||||||
|
|
||||||
set(EXAM_LIB_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/GPP_PluginBase_d.lib" PARENT_SCOPE)
|
#set(EXAM_LIB_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/GPP_PluginBase_d.lib" PARENT_SCOPE)
|
||||||
|
set(EXAM_LIB_DEBUG
|
||||||
|
"$<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/GPP_PluginBase_d.lib,${CMAKE_CURRENT_SOURCE_DIR}/GPP_PluginBase.lib>"
|
||||||
|
PARENT_SCOPE)
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#define TO_RAD(i) i * (M_PI / 180)
|
#define TO_RAD(i) i * (M_PI / 180)
|
||||||
|
|
||||||
|
#define PRINT_FUNCTION_NAME() std::cout << __func__ << std::endl
|
||||||
|
|
||||||
static int randNumRange(int minRange, int maxRange) {
|
static int randNumRange(int minRange, int maxRange) {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 seed(rd());
|
std::mt19937 seed(rd());
|
||||||
@@ -17,6 +19,7 @@ static int randNumRange(int minRange, int maxRange) {
|
|||||||
namespace BT_Action
|
namespace BT_Action
|
||||||
{
|
{
|
||||||
BT::State SetTimer(Blackboard* blackboardPtr, const std::string& timerName, bool doOnce) {
|
BT::State SetTimer(Blackboard* blackboardPtr, const std::string& timerName, bool doOnce) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
bool didOnce{};
|
bool didOnce{};
|
||||||
blackboardPtr->GetData("Timer" + timerName + "DoOnce", didOnce);
|
blackboardPtr->GetData("Timer" + timerName + "DoOnce", didOnce);
|
||||||
|
|
||||||
@@ -32,18 +35,21 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State UnlockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
BT::State UnlockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
blackboardPtr->ChangeData("TimerLock" + timerName, false);
|
blackboardPtr->ChangeData("TimerLock" + timerName, false);
|
||||||
|
|
||||||
return BT::State::Success;
|
return BT::State::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT::State LockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
BT::State LockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
blackboardPtr->ChangeData("TimerLock" + timerName, true);
|
blackboardPtr->ChangeData("TimerLock" + timerName, true);
|
||||||
|
|
||||||
return BT::State::Success;
|
return BT::State::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT::State GoToTarget(Blackboard* blackboardPtr) {
|
BT::State GoToTarget(Blackboard* blackboardPtr) {
|
||||||
|
//PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Elite::Vector2 target{};
|
Elite::Vector2 target{};
|
||||||
SteeringPlugin_Output steering{};
|
SteeringPlugin_Output steering{};
|
||||||
@@ -71,7 +77,7 @@ namespace BT_Action
|
|||||||
|
|
||||||
steering.LinearVelocity = nextTargetPos - agentInfo.Position;
|
steering.LinearVelocity = nextTargetPos - agentInfo.Position;
|
||||||
steering.LinearVelocity.Normalize();
|
steering.LinearVelocity.Normalize();
|
||||||
steering.LinearVelocity *= agentInfo.MaxLinearSpeed * 100;
|
steering.LinearVelocity *= agentInfo.MaxLinearSpeed;
|
||||||
|
|
||||||
const std::chrono::steady_clock::time_point currentTime{ std::chrono::steady_clock::now() };
|
const std::chrono::steady_clock::time_point currentTime{ std::chrono::steady_clock::now() };
|
||||||
const std::chrono::duration<float> elapsedSec{ currentTime - timer };
|
const std::chrono::duration<float> elapsedSec{ currentTime - timer };
|
||||||
@@ -81,7 +87,7 @@ namespace BT_Action
|
|||||||
return BT::State::Success;
|
return BT::State::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Distance(target, agentInfo.Position) < 2.f) {
|
if (Distance(target, agentInfo.Position) < 3.f) {
|
||||||
blackboardPtr->ChangeData("FailSafeDoOnce", false);
|
blackboardPtr->ChangeData("FailSafeDoOnce", false);
|
||||||
|
|
||||||
return BT::State::Success;
|
return BT::State::Success;
|
||||||
@@ -93,6 +99,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State EnableSpin(Blackboard* blackboardPtr) {
|
BT::State EnableSpin(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
SteeringPlugin_Output steering{};
|
SteeringPlugin_Output steering{};
|
||||||
|
|
||||||
@@ -109,6 +116,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State DisableSpin(Blackboard* blackboardPtr) {
|
BT::State DisableSpin(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
blackboardPtr->ChangeData("Spin", false);
|
blackboardPtr->ChangeData("Spin", false);
|
||||||
|
|
||||||
return BT::State::Success;
|
return BT::State::Success;
|
||||||
@@ -116,6 +124,7 @@ namespace BT_Action
|
|||||||
|
|
||||||
|
|
||||||
BT::State FindClosestEdge(Blackboard* blackboardPtr, int degree) {
|
BT::State FindClosestEdge(Blackboard* blackboardPtr, int degree) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
|
|
||||||
@@ -150,6 +159,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State SetZombieTarget(Blackboard* blackboardPtr) {
|
BT::State SetZombieTarget(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
|
|
||||||
@@ -176,6 +186,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State AvoidingZombie(Blackboard* blackboardPtr) {
|
BT::State AvoidingZombie(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
SteeringPlugin_Output steering{};
|
SteeringPlugin_Output steering{};
|
||||||
|
|
||||||
@@ -201,6 +212,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State RotateToZombie(Blackboard* blackboardPtr) {
|
BT::State RotateToZombie(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
EnemyInfo zombieInfo{};
|
EnemyInfo zombieInfo{};
|
||||||
SteeringPlugin_Output steering{};
|
SteeringPlugin_Output steering{};
|
||||||
@@ -222,6 +234,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State ReadyToShoot(Blackboard* blackboardPtr, float minAngleDiff) {
|
BT::State ReadyToShoot(Blackboard* blackboardPtr, float minAngleDiff) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
float angleDiff{};
|
float angleDiff{};
|
||||||
|
|
||||||
blackboardPtr->GetData("angleDiff", angleDiff);
|
blackboardPtr->GetData("angleDiff", angleDiff);
|
||||||
@@ -230,6 +243,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State Shoot(Blackboard* blackboardPtr, eItemType type) {
|
BT::State Shoot(Blackboard* blackboardPtr, eItemType type) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
|
|
||||||
@@ -250,6 +264,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State SetItemAsTarget(Blackboard* blackboardPtr) {
|
BT::State SetItemAsTarget(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
|
|
||||||
@@ -277,6 +292,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State DestroyItemOnFloor(Blackboard* blackboardPtr) {
|
BT::State DestroyItemOnFloor(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
ItemInfo targetItem{};
|
ItemInfo targetItem{};
|
||||||
|
|
||||||
@@ -290,6 +306,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State PickUpItem(Blackboard* blackboardPtr) {
|
BT::State PickUpItem(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
ItemInfo targetItem{};
|
ItemInfo targetItem{};
|
||||||
@@ -312,6 +329,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State SwapItem(Blackboard* blackboardPtr) {
|
BT::State SwapItem(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
ItemInfo targetItem{};
|
ItemInfo targetItem{};
|
||||||
@@ -332,6 +350,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State CheckItem(Blackboard* blackboardPtr) {
|
BT::State CheckItem(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
ItemInfo targetItem{};
|
ItemInfo targetItem{};
|
||||||
@@ -372,6 +391,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State UseItem(Blackboard* blackboardPtr, eItemType type) {
|
BT::State UseItem(Blackboard* blackboardPtr, eItemType type) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
|
|
||||||
@@ -392,6 +412,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State TryFindHouse(Blackboard* blackboardPtr, float searchRadius, int degree) {
|
BT::State TryFindHouse(Blackboard* blackboardPtr, float searchRadius, int degree) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
|
|
||||||
@@ -416,8 +437,9 @@ namespace BT_Action
|
|||||||
const Elite::Vector2 target = interfacePtr->NavMesh_GetClosestPathPoint(pointOnCircle);
|
const Elite::Vector2 target = interfacePtr->NavMesh_GetClosestPathPoint(pointOnCircle);
|
||||||
|
|
||||||
|
|
||||||
if (target == Elite::Vector2(400, 400)) {
|
const float worldDimensions{ interfacePtr->World_GetInfo().Dimensions.x / 2 };
|
||||||
std::cout << pointOnCircle << std::endl;
|
if (std::abs(target.x) >= worldDimensions || std::abs(target.y) >= worldDimensions) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pointOnCircle != target) {
|
if (pointOnCircle != target) {
|
||||||
@@ -444,12 +466,17 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State FindRandomLocation(Blackboard* blackboardPtr, float randomRadius) {
|
BT::State FindRandomLocation(Blackboard* blackboardPtr, float randomRadius) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
|
|
||||||
const Elite::Vector2 playerPos{ interfacePtr->Agent_GetInfo().Position };
|
const Elite::Vector2 playerPos{ interfacePtr->Agent_GetInfo().Position };
|
||||||
Elite::Vector2 target = Elite::Vector2(playerPos.x + randNumRange(-randomRadius, randomRadius),
|
|
||||||
playerPos.y + randNumRange(-randomRadius, randomRadius));
|
const float randomAngle = Elite::ToRadians(randNumRange(0.0f, 360.0f));
|
||||||
|
|
||||||
|
const Elite::Vector2 offset = Elite::Vector2{ cosf(randomAngle), sinf(randomAngle) } *randomRadius;
|
||||||
|
|
||||||
|
const Elite::Vector2 target = playerPos + offset;
|
||||||
|
|
||||||
blackboardPtr->ChangeData("Target", target);
|
blackboardPtr->ChangeData("Target", target);
|
||||||
|
|
||||||
@@ -457,6 +484,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State GetHouseAsTarget(Blackboard* blackboardPtr, float maxTravelDistance) {
|
BT::State GetHouseAsTarget(Blackboard* blackboardPtr, float maxTravelDistance) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
|
|
||||||
@@ -476,6 +504,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State CheckHouses(Blackboard* blackboardPtr) {
|
BT::State CheckHouses(Blackboard* blackboardPtr) {
|
||||||
|
//PRINT_FUNCTION_NAME();
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
|
|
||||||
@@ -490,6 +519,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State SetExpireDate(Blackboard* blackboardPtr) {
|
BT::State SetExpireDate(Blackboard* blackboardPtr) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
HouseInfo targetHouse{};
|
HouseInfo targetHouse{};
|
||||||
|
|
||||||
@@ -502,6 +532,7 @@ namespace BT_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::State GetInsideTarget(Blackboard* blackboardPtr, float offset) {
|
BT::State GetInsideTarget(Blackboard* blackboardPtr, float offset) {
|
||||||
|
PRINT_FUNCTION_NAME();
|
||||||
HouseInfo targetHouse{};
|
HouseInfo targetHouse{};
|
||||||
blackboardPtr->GetData("TargetHouse", targetHouse);
|
blackboardPtr->GetData("TargetHouse", targetHouse);
|
||||||
|
|
||||||
@@ -546,6 +577,28 @@ namespace BT_Condition
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InPurgeZone(Blackboard* blackboardPtr) {
|
||||||
|
IExamInterface* interfacePtr{};
|
||||||
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
|
|
||||||
|
const Elite::Vector2 playerPos{ interfacePtr->Agent_GetInfo().Position };
|
||||||
|
|
||||||
|
for (const auto purgeZone : interfacePtr->GetPurgeZonesInFOV()) {
|
||||||
|
const Elite::Vector2 purgeCenter{ purgeZone.Center };
|
||||||
|
const float purgeRadius{ purgeZone.Radius };
|
||||||
|
|
||||||
|
const float x{ playerPos.x - purgeCenter.x };
|
||||||
|
const float y{ playerPos.y - purgeCenter.y };
|
||||||
|
|
||||||
|
const float result{ x * x + y * y - purgeRadius * purgeRadius };
|
||||||
|
|
||||||
|
if (result <= 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool SeeZombie(Blackboard* blackboardPtr) {
|
bool SeeZombie(Blackboard* blackboardPtr) {
|
||||||
IExamInterface* interfacePtr{};
|
IExamInterface* interfacePtr{};
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
blackboardPtr->GetData("Interface", interfacePtr);
|
||||||
@@ -569,13 +622,6 @@ namespace BT_Condition
|
|||||||
return dist2 <= maxRange * maxRange;
|
return dist2 <= maxRange * maxRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SeePurgeZone(Blackboard* blackboardPtr) {
|
|
||||||
IExamInterface* interfacePtr{};
|
|
||||||
blackboardPtr->GetData("Interface", interfacePtr);
|
|
||||||
|
|
||||||
return interfacePtr->GetPurgeZonesInFOV().capacity() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ItemInInv(Blackboard* blackboardPtr, eItemType type) {
|
bool ItemInInv(Blackboard* blackboardPtr, eItemType type) {
|
||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
blackboardPtr->GetData("Brain", thinkerPtr);
|
blackboardPtr->GetData("Brain", thinkerPtr);
|
||||||
@@ -626,10 +672,6 @@ namespace BT_Condition
|
|||||||
Thinker* thinkerPtr{};
|
Thinker* thinkerPtr{};
|
||||||
blackboardPtr->GetData("Brain", thinkerPtr);
|
blackboardPtr->GetData("Brain", thinkerPtr);
|
||||||
|
|
||||||
if (thinkerPtr->EmptyValue()) {
|
|
||||||
std::cout << "empty item\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return thinkerPtr->EmptyValue();
|
return thinkerPtr->EmptyValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,4 +714,5 @@ namespace BT_Condition
|
|||||||
|
|
||||||
return thinkerPtr->HouseToReExplore();
|
return thinkerPtr->HouseToReExplore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace BT_Condition
|
|||||||
bool CheckTimerLock(Blackboard* blackboardPtr, const std::string& timerName);
|
bool CheckTimerLock(Blackboard* blackboardPtr, const std::string& timerName);
|
||||||
bool CheckTimer(Blackboard* blackboardPtr, const std::string& timerName, bool doOnce);
|
bool CheckTimer(Blackboard* blackboardPtr, const std::string& timerName, bool doOnce);
|
||||||
|
|
||||||
bool SeePurgeZone(Blackboard* blackboardPtr);
|
bool InPurgeZone(Blackboard* blackboardPtr);
|
||||||
|
|
||||||
bool SeeZombie(Blackboard* blackboardPtr);
|
bool SeeZombie(Blackboard* blackboardPtr);
|
||||||
bool HasWeapon(Blackboard* blackboardPtr);
|
bool HasWeapon(Blackboard* blackboardPtr);
|
||||||
|
|||||||
@@ -8,6 +8,24 @@ using namespace std::placeholders;
|
|||||||
|
|
||||||
namespace BigThink
|
namespace BigThink
|
||||||
{
|
{
|
||||||
|
BT::Selector* ItemHandling() {
|
||||||
|
constexpr float HpThreshold{ 0.f };
|
||||||
|
|
||||||
|
return
|
||||||
|
new BT::Selector({
|
||||||
|
new BT::Sequence({
|
||||||
|
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::MEDKIT)),
|
||||||
|
new BT::Conditional(std::bind(BT_Condition::HpUnderThreshold, _1, HpThreshold)),
|
||||||
|
new BT::Action(std::bind(BT_Action::UseItem, _1, eItemType::MEDKIT))
|
||||||
|
}),
|
||||||
|
new BT::Sequence({
|
||||||
|
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::FOOD)),
|
||||||
|
new BT::Conditional(BT_Condition::CheckMinNeededEnergy),
|
||||||
|
new BT::Action(std::bind(BT_Action::UseItem, _1, eItemType::FOOD))
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
BT::Sequence* ZombieHandling() {
|
BT::Sequence* ZombieHandling() {
|
||||||
constexpr float minShotgunAngleDiff{ .2f };
|
constexpr float minShotgunAngleDiff{ .2f };
|
||||||
constexpr float minPistolAngleDiff{ .1f };
|
constexpr float minPistolAngleDiff{ .1f };
|
||||||
@@ -56,30 +74,12 @@ namespace BigThink
|
|||||||
constexpr int searchDegree{ 5 };
|
constexpr int searchDegree{ 5 };
|
||||||
return
|
return
|
||||||
new BT::Sequence({
|
new BT::Sequence({
|
||||||
new BT::Conditional(BT_Condition::SeePurgeZone),
|
new BT::Conditional(BT_Condition::InPurgeZone),
|
||||||
new BT::Action(std::bind(BT_Action::FindClosestEdge, _1, searchDegree)),
|
new BT::Action(std::bind(BT_Action::FindClosestEdge, _1, searchDegree)),
|
||||||
new BT::Action(BT_Action::GoToTarget)
|
new BT::Action(BT_Action::GoToTarget)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BT::Selector* ItemHandling() {
|
|
||||||
constexpr float HpThreshold{ 0.f };
|
|
||||||
|
|
||||||
return
|
|
||||||
new BT::Selector({
|
|
||||||
new BT::Sequence({
|
|
||||||
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::MEDKIT)),
|
|
||||||
new BT::Conditional(std::bind(BT_Condition::HpUnderThreshold, _1, HpThreshold)),
|
|
||||||
new BT::Action(std::bind(BT_Action::UseItem, _1, eItemType::MEDKIT))
|
|
||||||
}),
|
|
||||||
new BT::Sequence({
|
|
||||||
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::FOOD)),
|
|
||||||
new BT::Conditional(BT_Condition::CheckMinNeededEnergy),
|
|
||||||
new BT::Action(std::bind(BT_Action::UseItem, _1, eItemType::FOOD))
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
BT::PartialSequence* PickUpHandling() {
|
BT::PartialSequence* PickUpHandling() {
|
||||||
return
|
return
|
||||||
new BT::PartialSequence({
|
new BT::PartialSequence({
|
||||||
@@ -133,13 +133,18 @@ namespace BigThink
|
|||||||
constexpr float InsideOffset{ 5.f };
|
constexpr float InsideOffset{ 5.f };
|
||||||
|
|
||||||
const std::string BeforeLeavingTimer{ "BeforeLeaving" };
|
const std::string BeforeLeavingTimer{ "BeforeLeaving" };
|
||||||
constexpr bool BeforeLeavingDoOnce{ true };
|
constexpr bool BeforeLeavingDoOnce{ false };
|
||||||
|
|
||||||
|
const std::string NoHouseTimer{ "NoHouse" };
|
||||||
|
constexpr float noHouseTimeout = 5.0f; // Time in seconds before giving up and going random
|
||||||
|
constexpr bool NoHouseDoOnce{ false };
|
||||||
|
|
||||||
return
|
return
|
||||||
new BT::Selector({
|
new BT::Selector({
|
||||||
new BT::Sequence({
|
new BT::Sequence({
|
||||||
new BT::Conditional(BT_Condition::SeeHouse),
|
new BT::Conditional(BT_Condition::SeeHouse),
|
||||||
new BT::Action(BT_Action::CheckHouses)
|
new BT::Action(BT_Action::CheckHouses),
|
||||||
|
new BT::Action(std::bind(BT_Action::SetTimer, _1, NoHouseTimer, NoHouseDoOnce)) // Reset timer when we see a house
|
||||||
}),
|
}),
|
||||||
new BT::PartialSequence({
|
new BT::PartialSequence({
|
||||||
new BT::Conditional(BT_Condition::InsideTargetHouse),
|
new BT::Conditional(BT_Condition::InsideTargetHouse),
|
||||||
@@ -156,16 +161,21 @@ namespace BigThink
|
|||||||
new BT::Action(BT_Action::GoToTarget),
|
new BT::Action(BT_Action::GoToTarget),
|
||||||
}),
|
}),
|
||||||
new BT::PartialSequence({
|
new BT::PartialSequence({
|
||||||
new BT::Action(std::bind(BT_Action::TryFindHouse, _1, searchRadius, searchDegree)),
|
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
||||||
new BT::Action(BT_Action::EnableSpin),
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
new BT::Action(BT_Action::GoToTarget)
|
new BT::Action(BT_Action::GoToTarget)
|
||||||
}),
|
}),
|
||||||
new BT::PartialSequence({
|
/*new BT::PartialSequence({
|
||||||
|
new BT::Action(std::bind(BT_Action::TryFindHouse, _1, searchRadius, searchDegree)),
|
||||||
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
|
new BT::Action(BT_Action::GoToTarget)
|
||||||
|
}),*/
|
||||||
|
/*new BT::PartialSequence({
|
||||||
new BT::Conditional(BT_Condition::ReExploreHouse),
|
new BT::Conditional(BT_Condition::ReExploreHouse),
|
||||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||||
new BT::Action(BT_Action::EnableSpin),
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
new BT::Action(BT_Action::GoToTarget),
|
new BT::Action(BT_Action::GoToTarget),
|
||||||
}),
|
}),*/
|
||||||
new BT::PartialSequence({
|
new BT::PartialSequence({
|
||||||
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
||||||
new BT::Action(BT_Action::EnableSpin),
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
@@ -192,6 +202,13 @@ namespace BigThink
|
|||||||
new BT::Action(BT_Action::EnableSpin),
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
new BT::Action(BT_Action::GoToTarget)
|
new BT::Action(BT_Action::GoToTarget)
|
||||||
}),
|
}),
|
||||||
|
new BT::PartialSequence({
|
||||||
|
new BT::Conditional(std::bind(BT_Condition::CheckTimer, _1, NoHouseTimer, NoHouseDoOnce)), // Check if we haven't seen a house in a while
|
||||||
|
new BT::Action(std::bind(BT_Action::SetTimer, _1, NoHouseTimer, NoHouseDoOnce)), // Reset the timer
|
||||||
|
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius * 2)), // Go further when random walking
|
||||||
|
new BT::Action(BT_Action::EnableSpin),
|
||||||
|
new BT::Action(BT_Action::GoToTarget)
|
||||||
|
}),
|
||||||
new BT::PartialSequence({
|
new BT::PartialSequence({
|
||||||
new BT::Conditional(BT_Condition::ReExploreHouse),
|
new BT::Conditional(BT_Condition::ReExploreHouse),
|
||||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||||
@@ -199,11 +216,6 @@ namespace BigThink
|
|||||||
new BT::Action(BT_Action::GoToTarget),
|
new BT::Action(BT_Action::GoToTarget),
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new BT::PartialSequence({
|
|
||||||
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
|
||||||
new BT::Action(BT_Action::EnableSpin),
|
|
||||||
new BT::Action(BT_Action::GoToTarget)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ namespace BT
|
|||||||
|
|
||||||
namespace BigThink
|
namespace BigThink
|
||||||
{
|
{
|
||||||
|
BT::Selector* ItemHandling();
|
||||||
BT::Sequence* ZombieHandling();
|
BT::Sequence* ZombieHandling();
|
||||||
BT::Sequence* PurgeZoneHandling();
|
BT::Sequence* PurgeZoneHandling();
|
||||||
BT::Selector* ItemHandling();
|
|
||||||
BT::PartialSequence* PickUpHandling();
|
BT::PartialSequence* PickUpHandling();
|
||||||
BT::Selector* HouseHandling();
|
BT::Selector* HouseHandling();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ add_library(Exam_Plugin SHARED
|
|||||||
target_link_libraries(Exam_Plugin PUBLIC ${EXAM_LIB_DEBUG})
|
target_link_libraries(Exam_Plugin PUBLIC ${EXAM_LIB_DEBUG})
|
||||||
target_include_directories(Exam_Plugin PUBLIC ${EXAM_INCLUDE_DIR})
|
target_include_directories(Exam_Plugin PUBLIC ${EXAM_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# Explicit debug info generation flags for MSVC
|
||||||
|
target_compile_options(Exam_Plugin PRIVATE
|
||||||
|
$<$<CONFIG:Debug>:/Zi>)
|
||||||
|
target_link_options(Exam_Plugin PRIVATE
|
||||||
|
$<$<CONFIG:Debug>:/DEBUG>)
|
||||||
|
|
||||||
set_target_properties(Exam_Plugin PROPERTIES
|
set_target_properties(Exam_Plugin PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/_DEMO_DEBUG"
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/_DEMO_DEBUG"
|
||||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/_DEMO_DEBUG"
|
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/_DEMO_DEBUG"
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ void SurvivalAgentPlugin::Initialize(IBaseInterface* pInterface, PluginInfo& inf
|
|||||||
Blackboard* blackboardPtr{ CreateBlackboard() };
|
Blackboard* blackboardPtr{ CreateBlackboard() };
|
||||||
m_BehaviourTree = new BT::BehaviorTree(blackboardPtr,
|
m_BehaviourTree = new BT::BehaviorTree(blackboardPtr,
|
||||||
new BT::Selector({
|
new BT::Selector({
|
||||||
|
BigThink::ItemHandling(),
|
||||||
BigThink::ZombieHandling(),
|
BigThink::ZombieHandling(),
|
||||||
BigThink::PurgeZoneHandling(),
|
BigThink::PurgeZoneHandling(),
|
||||||
BigThink::ItemHandling(),
|
|
||||||
BigThink::PickUpHandling(),
|
BigThink::PickUpHandling(),
|
||||||
BigThink::HouseHandling()
|
BigThink::HouseHandling()
|
||||||
}));
|
}));
|
||||||
@@ -69,6 +69,10 @@ Blackboard* SurvivalAgentPlugin::CreateBlackboard() {
|
|||||||
blackboardPtr->AddData("TimerBeforeLeavingDoOnce", false);
|
blackboardPtr->AddData("TimerBeforeLeavingDoOnce", false);
|
||||||
blackboardPtr->AddData("MaxTimeBeforeLeaving", 3.f);
|
blackboardPtr->AddData("MaxTimeBeforeLeaving", 3.f);
|
||||||
|
|
||||||
|
blackboardPtr->AddData("MaxTimeNoHouse", 5.f);
|
||||||
|
blackboardPtr->AddData("TimerNoHouse", std::chrono::steady_clock::time_point{});
|
||||||
|
blackboardPtr->AddData("TimerNoHouseDoOnce", false);
|
||||||
|
|
||||||
return blackboardPtr;
|
return blackboardPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +117,7 @@ void SurvivalAgentPlugin::InitGameDebugParams(GameDebugParams& params)
|
|||||||
params.SpawnPurgeZonesOnMiddleClick = true;
|
params.SpawnPurgeZonesOnMiddleClick = true;
|
||||||
params.PrintDebugMessages = true;
|
params.PrintDebugMessages = true;
|
||||||
params.ShowDebugItemNames = true;
|
params.ShowDebugItemNames = true;
|
||||||
params.Seed = -1; //-1 = don't set seed. Any other number = fixed seed //TIP: use Seed = int(time(nullptr)) for pure randomness
|
params.Seed = int(time(nullptr)); //-1 = don't set seed. Any other number = fixed seed //TIP: use Seed = int(time(nullptr)) for pure randomness
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalAgentPlugin::Update_Debug(float dt)
|
void SurvivalAgentPlugin::Update_Debug(float dt)
|
||||||
@@ -194,6 +198,16 @@ SteeringPlugin_Output SurvivalAgentPlugin::UpdateSteering(float dt)
|
|||||||
m_BehaviourTree->GetBlackboard()->GetData("Steering", steering);
|
m_BehaviourTree->GetBlackboard()->GetData("Steering", steering);
|
||||||
m_BehaviourTree->GetBlackboard()->GetData("Spin", spin);
|
m_BehaviourTree->GetBlackboard()->GetData("Spin", spin);
|
||||||
|
|
||||||
|
if (m_pInterface->Agent_GetInfo().Stamina >= 10 || m_Running) {
|
||||||
|
m_Running = true;
|
||||||
|
steering.RunMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pInterface->Agent_GetInfo().Stamina <= 0.1f) {
|
||||||
|
m_Running = false;
|
||||||
|
steering.RunMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (spin) {
|
if (spin) {
|
||||||
steering.AutoOrient = false;
|
steering.AutoOrient = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ private:
|
|||||||
void UpdateBlackboard(const SteeringPlugin_Output& steering);
|
void UpdateBlackboard(const SteeringPlugin_Output& steering);
|
||||||
BT::BehaviorTree* m_BehaviourTree = nullptr;
|
BT::BehaviorTree* m_BehaviourTree = nullptr;
|
||||||
Thinker* m_Thinker = nullptr;
|
Thinker* m_Thinker = nullptr;
|
||||||
|
|
||||||
|
bool m_Running{};
|
||||||
};
|
};
|
||||||
|
|
||||||
//ENTRY
|
//ENTRY
|
||||||
|
|||||||
@@ -3,19 +3,18 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
std::vector<Thinker::ItemMemory>::iterator Thinker::FindLeastValueItem(const eItemType& itemType) {
|
std::vector<Thinker::ItemMemory>::iterator Thinker::FindLeastValueItem(const eItemType& itemType) {
|
||||||
std::ranges::partition(m_ItemMemory,
|
auto minIt = m_ItemMemory.end();
|
||||||
[itemType](const ItemMemory& memory)->bool { return memory.ItemInfo.Type == itemType; });
|
|
||||||
|
|
||||||
const auto minItem =
|
for (auto it = m_ItemMemory.begin(); it != m_ItemMemory.end(); ++it) {
|
||||||
std::ranges::min_element(m_ItemMemory,
|
if (it->ItemInfo.Type != itemType)
|
||||||
[itemType](const ItemMemory& lhs, const ItemMemory& rhs)->bool {
|
continue;
|
||||||
if (lhs.ItemInfo.Type == itemType && rhs.ItemInfo.Type == itemType) {
|
|
||||||
return lhs.ItemInfo.Value < rhs.ItemInfo.Value;
|
if (minIt == m_ItemMemory.end() || it->ItemInfo.Value < minIt->ItemInfo.Value) {
|
||||||
|
minIt = it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return minItem;
|
return minIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thinker::IsInvNotFull() const {
|
bool Thinker::IsInvNotFull() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user