Bud can run and explore buildings
This commit is contained in:
152
project/BigThink.cpp
Normal file
152
project/BigThink.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#include "stdafx.h"
|
||||
#include "BigThink.h"
|
||||
|
||||
#include "Behaviour.h"
|
||||
#include "BehaviourTree.h"
|
||||
|
||||
namespace BigThink
|
||||
{
|
||||
constexpr float HpThreshold{ 8.f }; // TODO: Make this a parameter
|
||||
|
||||
BT::Sequence* PurgeZoneHandling() {
|
||||
constexpr int searchDegree{ 45 };
|
||||
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(BT_Action::GoToTarget)
|
||||
});
|
||||
}
|
||||
|
||||
BT::Selector* ItemHandling() {
|
||||
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::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::ItemInInv, std::placeholders::_1, eItemType::FOOD)),
|
||||
new BT::Conditional(BT_Condition::CheckMinNeededEnergy),
|
||||
new BT::Action(std::bind(BT_Action::UseItem, std::placeholders::_1, eItemType::FOOD))
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
BT::PartialSequence* PickUpHandling() {
|
||||
return
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(BT_Condition::SeeItem),
|
||||
new BT::Action(BT_Action::DisableSpin),
|
||||
new BT::Action(BT_Action::SetItemAsTarget),
|
||||
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::Action(BT_Action::DestroyItemOnFloor)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::EmptyValue),
|
||||
new BT::Action(BT_Action::SwapItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(BT_Condition::InvIsNotFull),
|
||||
new BT::Action(BT_Action::PickUpItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
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::Action(BT_Action::CheckItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_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::Action(BT_Action::CheckItem)
|
||||
}),
|
||||
new BT::Sequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::IsTypeOfItem, std::placeholders::_1, eItemType::PISTOL)),
|
||||
new BT::Action(BT_Action::CheckItem)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
BT::Selector* HouseHandling() {
|
||||
constexpr float maxTravelDistance{ 100.f };
|
||||
constexpr int searchRadius{ 300 };
|
||||
constexpr int searchDegree{ 45 }; //TODO
|
||||
constexpr float InsideOffset{ 5.f };
|
||||
|
||||
const std::string BeforeLeavingTimer{ "BeforeLeaving" };
|
||||
constexpr bool BeforeLeavingDoOnce{ true };
|
||||
|
||||
return
|
||||
new BT::Selector({
|
||||
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::Selector({
|
||||
new BT::PartialSequence({
|
||||
new BT::Conditional(std::bind(BT_Condition::CheckTimer, std::placeholders::_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(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(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(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(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(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(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(BT_Action::EnableSpin),
|
||||
new BT::Action(BT_Action::GoToTarget)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user