we shooting
This commit is contained in:
@@ -4,34 +4,80 @@
|
||||
#include "Behaviour.h"
|
||||
#include "BehaviourTree.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
namespace BigThink
|
||||
{
|
||||
constexpr float HpThreshold{ 8.f }; // TODO: Make this a parameter
|
||||
BT::Sequence* ZombieHandling() {
|
||||
constexpr float minShotgunAngleDiff{ .2f };
|
||||
constexpr float minPistolAngleDiff{ .1f };
|
||||
constexpr float maxShotgunShootRange{ 8.f };
|
||||
constexpr float maxPistolShootRange{ 15.f };
|
||||
|
||||
const std::string ShotgunTimer{ "Shotgun" };
|
||||
constexpr bool ShotgunDoOnce{ true };
|
||||
|
||||
const std::string PistolTimer{ "Pistol" };
|
||||
constexpr bool PistolDoOnce{ true };
|
||||
|
||||
return
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::SeeZombie),
|
||||
new BT::Sequence({
|
||||
new BT::Action(BT_Action::AvoidingZombie),
|
||||
new BT::Conditional(BT_Condition::HasWeapon),
|
||||
new BT::Action(BT_Action::SetZombieTarget),
|
||||
new BT::Sequence({
|
||||
new BT::Action(BT_Action::RotateToZombie),
|
||||
new BT::Selector({
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::SHOTGUN)),
|
||||
new BT::Conditional(std::bind(BT_Condition::InRange, _1, maxShotgunShootRange)),
|
||||
new BT::Action(std::bind(BT_Action::ReadyToShoot, _1, minShotgunAngleDiff)),
|
||||
new BT::Conditional(std::bind(BT_Condition::CheckTimer, _1, ShotgunTimer, ShotgunDoOnce)),
|
||||
new BT::Action(std::bind(BT_Action::Shoot, _1, eItemType::SHOTGUN)),
|
||||
new BT::Action(std::bind(BT_Action::SetTimer, _1, ShotgunTimer, ShotgunDoOnce))
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::ItemInInv, _1, eItemType::PISTOL)),
|
||||
new BT::Conditional(std::bind(BT_Condition::InRange, _1, maxPistolShootRange)),
|
||||
new BT::Action(std::bind(BT_Action::ReadyToShoot, _1, minPistolAngleDiff)),
|
||||
new BT::Conditional(std::bind(BT_Condition::CheckTimer, _1, PistolTimer, PistolDoOnce)),
|
||||
new BT::Action(std::bind(BT_Action::Shoot, _1, eItemType::PISTOL)),
|
||||
new BT::Action(std::bind(BT_Action::SetTimer, _1, PistolTimer, PistolDoOnce))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
BT::Sequence* PurgeZoneHandling() {
|
||||
constexpr int searchDegree{ 45 };
|
||||
constexpr int searchDegree{ 5 };
|
||||
return
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::SeePurgeZone),
|
||||
new BT::Action(std::bind(BT_Action::FindClosestEdge, std::placeholders::_1, searchDegree)),
|
||||
new BT::Action(std::bind(BT_Action::FindClosestEdge, _1, searchDegree)),
|
||||
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, std::placeholders::_1, eItemType::MEDKIT)),
|
||||
new BT::Conditional(std::bind(BT_Condition::HpUnderThreshold, std::placeholders::_1, HpThreshold)),
|
||||
new BT::Action(std::bind(BT_Action::UseItem, std::placeholders::_1, eItemType::MEDKIT))
|
||||
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, std::placeholders::_1, eItemType::FOOD)),
|
||||
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, std::placeholders::_1, eItemType::FOOD))
|
||||
new BT::Action(std::bind(BT_Action::UseItem, _1, eItemType::FOOD))
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
BT::PartialSequence* PickUpHandling() {
|
||||
@@ -43,7 +89,7 @@ namespace BigThink
|
||||
new BT::Action(BT_Action::GoToTarget),
|
||||
new BT::Selector({
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::GARBAGE)),
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, _1, eItemType::GARBAGE)),
|
||||
new BT::Action(BT_Action::DestroyItemOnFloor)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
@@ -58,19 +104,19 @@ namespace BigThink
|
||||
new BT::Conditional(BT_Condition::InvIsFull),
|
||||
new BT::Selector({
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::FOOD)),
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem,_1, eItemType::FOOD)),
|
||||
new BT::Action(BT_Action::CheckItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::MEDKIT)),
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, _1, eItemType::MEDKIT)),
|
||||
new BT::Action(BT_Action::CheckItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::SHOTGUN)),
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, _1, eItemType::SHOTGUN)),
|
||||
new BT::Action(BT_Action::CheckItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::PISTOL)),
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, _1, eItemType::PISTOL)),
|
||||
new BT::Action(BT_Action::CheckItem)
|
||||
})
|
||||
})
|
||||
@@ -80,9 +126,10 @@ namespace BigThink
|
||||
}
|
||||
|
||||
BT::Selector* HouseHandling() {
|
||||
constexpr float maxTravelDistance{ 100.f };
|
||||
constexpr int searchRadius{ 300 };
|
||||
constexpr int searchDegree{ 45 }; //TODO
|
||||
constexpr float maxTravelDistance{ 400.f };
|
||||
constexpr int searchRadius{ 500 };
|
||||
constexpr int randomRadius{ 50 };
|
||||
constexpr int searchDegree{ 5 };
|
||||
constexpr float InsideOffset{ 5.f };
|
||||
|
||||
const std::string BeforeLeavingTimer{ "BeforeLeaving" };
|
||||
@@ -90,60 +137,70 @@ namespace BigThink
|
||||
|
||||
return
|
||||
new BT::Selector({
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::SeeHouse),
|
||||
new BT::Action(BT_Action::CheckHouses)
|
||||
}),
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(BT_Condition::InsideTargetHouse),
|
||||
new BT::Action(BT_Action::SetExpireDate),
|
||||
new BT::Action(std::bind(BT_Action::SetTimer, std::placeholders::_1, BeforeLeavingTimer, BeforeLeavingDoOnce)),
|
||||
new BT::Action(std::bind(BT_Action::SetTimer, _1, BeforeLeavingTimer, BeforeLeavingDoOnce)),
|
||||
new BT::Selector({
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::CheckTimer, std::placeholders::_1, BeforeLeavingTimer, BeforeLeavingDoOnce)),
|
||||
new BT::Conditional(std::bind(BT_Condition::CheckTimer, _1, BeforeLeavingTimer, BeforeLeavingDoOnce)),
|
||||
new BT::Selector({
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(BT_Condition::NewHouse),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, std::placeholders::_1, maxTravelDistance)),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget),
|
||||
}),
|
||||
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::Action(std::bind(BT_Action::GetHouseAsTarget, std::placeholders::_1, maxTravelDistance)),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget),
|
||||
}),
|
||||
new BT::PartialSequence({
|
||||
new BT::Action(std::bind(BT_Action::TryFindHouse, std::placeholders::_1, searchRadius, searchDegree)),
|
||||
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget)
|
||||
})
|
||||
}),
|
||||
}),
|
||||
new BT::PartialSequence({
|
||||
new BT::Action(std::bind(BT_Action::GetInsideTarget, std::placeholders::_1, InsideOffset)),
|
||||
new BT::Action(std::bind(BT_Action::GetInsideTarget, _1, InsideOffset)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget)
|
||||
}),
|
||||
})
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::SeeHouse),
|
||||
new BT::Action(BT_Action::CheckHouses)
|
||||
}),
|
||||
new BT::Selector({
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(BT_Condition::NewHouse),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, std::placeholders::_1, maxTravelDistance)),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget),
|
||||
}),
|
||||
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::Action(std::bind(BT_Action::GetHouseAsTarget, std::placeholders::_1, maxTravelDistance)),
|
||||
new BT::Action(std::bind(BT_Action::GetHouseAsTarget, _1, maxTravelDistance)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget),
|
||||
})
|
||||
}),
|
||||
new BT::PartialSequence({
|
||||
new BT::Action(std::bind(BT_Action::TryFindHouse, std::placeholders::_1, searchRadius, searchDegree)),
|
||||
new BT::Action(std::bind(BT_Action::FindRandomLocation, _1, randomRadius)),
|
||||
new BT::Action(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user