fix some more glitchy stuff
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#define TO_RAD(i) i * (M_PI / 180)
|
||||
|
||||
#define PRINT_FUNCTION_NAME() std::cout << __func__ << std::endl
|
||||
|
||||
static int randNumRange(int minRange, int maxRange) {
|
||||
std::random_device rd;
|
||||
std::mt19937 seed(rd());
|
||||
@@ -17,6 +19,7 @@ static int randNumRange(int minRange, int maxRange) {
|
||||
namespace BT_Action
|
||||
{
|
||||
BT::State SetTimer(Blackboard* blackboardPtr, const std::string& timerName, bool doOnce) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
bool didOnce{};
|
||||
blackboardPtr->GetData("Timer" + timerName + "DoOnce", didOnce);
|
||||
|
||||
@@ -32,18 +35,21 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State UnlockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
blackboardPtr->ChangeData("TimerLock" + timerName, false);
|
||||
|
||||
return BT::State::Success;
|
||||
}
|
||||
|
||||
BT::State LockTimer(Blackboard* blackboardPtr, const std::string& timerName) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
blackboardPtr->ChangeData("TimerLock" + timerName, true);
|
||||
|
||||
return BT::State::Success;
|
||||
}
|
||||
|
||||
BT::State GoToTarget(Blackboard* blackboardPtr) {
|
||||
//PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Elite::Vector2 target{};
|
||||
SteeringPlugin_Output steering{};
|
||||
@@ -71,7 +77,7 @@ namespace BT_Action
|
||||
|
||||
steering.LinearVelocity = nextTargetPos - agentInfo.Position;
|
||||
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::duration<float> elapsedSec{ currentTime - timer };
|
||||
@@ -81,7 +87,7 @@ namespace BT_Action
|
||||
return BT::State::Success;
|
||||
}
|
||||
|
||||
if (Distance(target, agentInfo.Position) < 2.f) {
|
||||
if (Distance(target, agentInfo.Position) < 3.f) {
|
||||
blackboardPtr->ChangeData("FailSafeDoOnce", false);
|
||||
|
||||
return BT::State::Success;
|
||||
@@ -93,6 +99,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State EnableSpin(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
SteeringPlugin_Output steering{};
|
||||
|
||||
@@ -109,6 +116,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State DisableSpin(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
blackboardPtr->ChangeData("Spin", false);
|
||||
|
||||
return BT::State::Success;
|
||||
@@ -116,6 +124,7 @@ namespace BT_Action
|
||||
|
||||
|
||||
BT::State FindClosestEdge(Blackboard* blackboardPtr, int degree) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
blackboardPtr->GetData("Interface", interfacePtr);
|
||||
|
||||
@@ -150,6 +159,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State SetZombieTarget(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
blackboardPtr->GetData("Interface", interfacePtr);
|
||||
|
||||
@@ -176,6 +186,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State AvoidingZombie(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
SteeringPlugin_Output steering{};
|
||||
|
||||
@@ -201,6 +212,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State RotateToZombie(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
EnemyInfo zombieInfo{};
|
||||
SteeringPlugin_Output steering{};
|
||||
@@ -222,6 +234,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State ReadyToShoot(Blackboard* blackboardPtr, float minAngleDiff) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
float angleDiff{};
|
||||
|
||||
blackboardPtr->GetData("angleDiff", angleDiff);
|
||||
@@ -230,6 +243,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State Shoot(Blackboard* blackboardPtr, eItemType type) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
|
||||
@@ -250,6 +264,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State SetItemAsTarget(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
blackboardPtr->GetData("Interface", interfacePtr);
|
||||
|
||||
@@ -277,6 +292,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State DestroyItemOnFloor(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
ItemInfo targetItem{};
|
||||
|
||||
@@ -290,6 +306,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State PickUpItem(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
ItemInfo targetItem{};
|
||||
@@ -312,6 +329,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State SwapItem(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
ItemInfo targetItem{};
|
||||
@@ -332,6 +350,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State CheckItem(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
ItemInfo targetItem{};
|
||||
@@ -372,6 +391,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State UseItem(Blackboard* blackboardPtr, eItemType type) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
|
||||
@@ -392,6 +412,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State TryFindHouse(Blackboard* blackboardPtr, float searchRadius, int degree) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
|
||||
@@ -416,8 +437,9 @@ namespace BT_Action
|
||||
const Elite::Vector2 target = interfacePtr->NavMesh_GetClosestPathPoint(pointOnCircle);
|
||||
|
||||
|
||||
if (target == Elite::Vector2(400, 400)) {
|
||||
std::cout << pointOnCircle << std::endl;
|
||||
const float worldDimensions{ interfacePtr->World_GetInfo().Dimensions.x / 2 };
|
||||
if (std::abs(target.x) >= worldDimensions || std::abs(target.y) >= worldDimensions) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pointOnCircle != target) {
|
||||
@@ -444,12 +466,17 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State FindRandomLocation(Blackboard* blackboardPtr, float randomRadius) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
blackboardPtr->GetData("Interface", interfacePtr);
|
||||
|
||||
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);
|
||||
|
||||
@@ -457,6 +484,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State GetHouseAsTarget(Blackboard* blackboardPtr, float maxTravelDistance) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
IExamInterface* interfacePtr{};
|
||||
Thinker* thinkerPtr{};
|
||||
|
||||
@@ -476,6 +504,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State CheckHouses(Blackboard* blackboardPtr) {
|
||||
//PRINT_FUNCTION_NAME();
|
||||
Thinker* thinkerPtr{};
|
||||
IExamInterface* interfacePtr{};
|
||||
|
||||
@@ -490,6 +519,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State SetExpireDate(Blackboard* blackboardPtr) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
Thinker* thinkerPtr{};
|
||||
HouseInfo targetHouse{};
|
||||
|
||||
@@ -502,6 +532,7 @@ namespace BT_Action
|
||||
}
|
||||
|
||||
BT::State GetInsideTarget(Blackboard* blackboardPtr, float offset) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
HouseInfo targetHouse{};
|
||||
blackboardPtr->GetData("TargetHouse", targetHouse);
|
||||
|
||||
@@ -546,6 +577,28 @@ namespace BT_Condition
|
||||
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) {
|
||||
IExamInterface* interfacePtr{};
|
||||
blackboardPtr->GetData("Interface", interfacePtr);
|
||||
@@ -569,13 +622,6 @@ namespace BT_Condition
|
||||
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) {
|
||||
Thinker* thinkerPtr{};
|
||||
blackboardPtr->GetData("Brain", thinkerPtr);
|
||||
@@ -626,10 +672,6 @@ namespace BT_Condition
|
||||
Thinker* thinkerPtr{};
|
||||
blackboardPtr->GetData("Brain", thinkerPtr);
|
||||
|
||||
if (thinkerPtr->EmptyValue()) {
|
||||
std::cout << "empty item\n";
|
||||
}
|
||||
|
||||
return thinkerPtr->EmptyValue();
|
||||
}
|
||||
|
||||
@@ -672,4 +714,5 @@ namespace BT_Condition
|
||||
|
||||
return thinkerPtr->HouseToReExplore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user