1
This commit is contained in:
parent
36de35152d
commit
87a8e7dbb6
@ -280,75 +280,122 @@ void BaseAgent::Sleep(int time)
|
|||||||
|
|
||||||
bool BaseAgent::CurrentTargetMoveCanReach()
|
bool BaseAgent::CurrentTargetMoveCanReach()
|
||||||
{
|
{
|
||||||
|
if (!current_target_.Get()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return GetOwner()->room->MoveCanReach(GetOwner()->GetPos().ToGlmVec3(),
|
||||||
|
current_target_.Get()->GetPos().ToGlmVec3());
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::DoSkill(int skill_id)
|
behaviac::EBTStatus BaseAgent::DoSkill(int skill_id)
|
||||||
{
|
{
|
||||||
|
if (!current_target_.Get()) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
int wait_time = 0;
|
||||||
|
if (InternalUseSkill(skill_id, current_target_, wait_time)) {
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 BaseAgent::GetPos()
|
glm::vec3 BaseAgent::GetPos()
|
||||||
{
|
{
|
||||||
|
return GetOwner()->GetPos().ToGlmVec3();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseAgent::MoveCanReach(const glm::vec3& pos)
|
bool BaseAgent::MoveCanReach(const glm::vec3& pos)
|
||||||
{
|
{
|
||||||
|
return GetOwner()->room->MoveCanReach(GetOwner()->GetPos().ToGlmVec3(),
|
||||||
|
pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::SelectUseableSkill(const behaviac::vector<int> skill_ids)
|
behaviac::EBTStatus BaseAgent::SelectUseableSkill(const behaviac::vector<int> skill_ids)
|
||||||
{
|
{
|
||||||
|
selected_skill_id = 0;
|
||||||
|
if (!current_target_.Get()) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
for (int skill_id : skill_ids) {
|
||||||
|
Skill* skill = GetOwner()->GetSkill(skill_id);
|
||||||
|
if (skill && GetOwner()->CanUseSkill(skill->GetSkillId())) {
|
||||||
|
if (!skill->GetMinorType()) {
|
||||||
|
if (current_target_.Get()->GetPos().Distance2D2(GetOwner()->GetPos()) >
|
||||||
|
skill->meta->skill_distance()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
selected_skill_id = skill->GetSkillId();
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::CoFindPathToCurrentTarget(float distance)
|
behaviac::EBTStatus BaseAgent::CoFindPathToCurrentTarget(float distance)
|
||||||
{
|
{
|
||||||
|
if (!current_target_.Get()) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::CoMoveToCurrentTarget(float distance)
|
behaviac::EBTStatus BaseAgent::CoMoveToCurrentTarget(float distance)
|
||||||
{
|
{
|
||||||
|
if (!current_target_.Get()) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseAgent::CurrentTargetIsValid()
|
bool BaseAgent::CurrentTargetIsValid()
|
||||||
{
|
{
|
||||||
|
return current_target_.Get() && !current_target_.Get()->dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::FindEnemy(float range)
|
behaviac::EBTStatus BaseAgent::FindEnemy(float range)
|
||||||
{
|
{
|
||||||
|
Creature* enemy = GetOwner()->room->FindEnemy(GetOwner(), range);
|
||||||
|
find_enemy_target_uniid = enemy ? enemy->GetUniId() : 0;
|
||||||
|
return enemy ? behaviac::BT_SUCCESS : behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BaseAgent::GetCurrentTargetDistance()
|
float BaseAgent::GetCurrentTargetDistance()
|
||||||
{
|
{
|
||||||
|
if (current_target_.Get()) {
|
||||||
|
return current_target_.Get()->GetPos().Distance2D2(GetOwner()->GetPos());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BaseAgent::GetFindEnemyResultTargetDistance()
|
float BaseAgent::GetFindEnemyResultTargetDistance()
|
||||||
{
|
{
|
||||||
|
abort();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 BaseAgent::GetFindEnemyResultTargetPos()
|
glm::vec3 BaseAgent::GetFindEnemyResultTargetPos()
|
||||||
{
|
{
|
||||||
|
abort();
|
||||||
|
return glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseAgent::SetCurrentTarget(int target_uniid)
|
void BaseAgent::SetCurrentTarget(int target_uniid)
|
||||||
{
|
{
|
||||||
|
current_target_.Reset();
|
||||||
|
Creature* c = GetOwner()->room->GetCreatureByUniId(target_uniid);
|
||||||
|
if (c) {
|
||||||
|
current_target_ = c->GetWeakPtrRef();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseAgent::GetFindEnemyResultTargetUniId()
|
int BaseAgent::GetFindEnemyResultTargetUniId()
|
||||||
{
|
{
|
||||||
|
return find_enemy_target_uniid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseAgent::ShotCanReach(const glm::vec3& target_pos)
|
bool BaseAgent::ShotCanReach(const glm::vec3& target_pos)
|
||||||
{
|
{
|
||||||
|
abort();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ protected:
|
|||||||
void Sleep(int time);
|
void Sleep(int time);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
CreatureWeakPtr current_target_;
|
||||||
bool bullet_trace_mode_ = false;
|
bool bullet_trace_mode_ = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
behaviac::EBTStatus last_status_ = behaviac::BT_INVALID;
|
behaviac::EBTStatus last_status_ = behaviac::BT_INVALID;
|
||||||
|
@ -832,6 +832,9 @@ bool Creature::CanUseSkill(int skill_id)
|
|||||||
if (!skill) {
|
if (!skill) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (skill->GetCurrTimes() <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (room->GetGasData().GetGasMode() == GasInactive) {
|
if (room->GetGasData().GetGasMode() == GasInactive) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3513,3 +3513,8 @@ bool Room::BulletCanReach(const glm::vec3& start, const glm::vec3& end)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Room::MoveCanReach(const glm::vec3& start, const glm::vec3& end)
|
||||||
|
{
|
||||||
|
return BulletCanReach(start, end);
|
||||||
|
}
|
||||||
|
@ -261,6 +261,7 @@ public:
|
|||||||
std::shared_ptr<BatchSync> GetBatchSync() { return batch_sync_; }
|
std::shared_ptr<BatchSync> GetBatchSync() { return batch_sync_; }
|
||||||
void GMFastForward();
|
void GMFastForward();
|
||||||
bool BulletCanReach(const glm::vec3& start, const glm::vec3& end);
|
bool BulletCanReach(const glm::vec3& start, const glm::vec3& end);
|
||||||
|
bool MoveCanReach(const glm::vec3& start, const glm::vec3& end);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShuaAndroid();
|
void ShuaAndroid();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user