1
This commit is contained in:
parent
ff3e213d1b
commit
50d35e27aa
@ -404,6 +404,9 @@ void AndroidAI::UpdateAttack()
|
||||
}
|
||||
float distance = myself->GetPos().Distance(node_->target.Get()->GetPos());
|
||||
if (distance > GetAttackRange()) {
|
||||
#ifdef MAP3D
|
||||
ChangeToStateNewAI(ASE_Pursuit);
|
||||
#else
|
||||
if (ai_meta->i->pursuit_radius() <= 0) {
|
||||
//站桩
|
||||
ChangeToStateNewAI(ASE_Thinking);
|
||||
@ -415,6 +418,7 @@ void AndroidAI::UpdateAttack()
|
||||
ChangeToStateNewAI(ASE_Thinking);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
//攻击逻辑
|
||||
@ -469,11 +473,15 @@ void AndroidAI::UpdatePursuit()
|
||||
ChangeToStateNewAI(ASE_Attack);
|
||||
} else {
|
||||
#ifdef MAP3D
|
||||
if (node_->exec_frame_num > 100 * 2) {
|
||||
ChangeToStateNewAI(ASE_Thinking);
|
||||
return;
|
||||
}
|
||||
a8::Vec3 center;
|
||||
glm::vec3 random_pt;
|
||||
center.x = myself->GetPos().x;
|
||||
center.x = myself->GetPos().x / 10.0f;
|
||||
center.y = 0;
|
||||
center.z = myself->GetPos().y;
|
||||
center.z = myself->GetPos().y / 10.0f;
|
||||
int ret = myself->room->map_instance->FindRandomPointAroundCircle
|
||||
(0,
|
||||
center,
|
||||
|
@ -75,6 +75,11 @@ bool MoveHelper::GetMovePosition(glm::vec3& out_pos)
|
||||
|
||||
void MoveHelper::CalcTargetPos(float distance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (paths_.size() > 1) {
|
||||
a8::XPrintf("CalcTargetPos old_size:%d\n", {paths_.size()});
|
||||
}
|
||||
#endif
|
||||
ClearPath();
|
||||
Creature* c = (Creature*)owner_;
|
||||
glm::vec3 start;
|
||||
@ -173,30 +178,40 @@ void MoveHelper::ClearPath()
|
||||
void MoveHelper::AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths)
|
||||
{
|
||||
glm::vec3 last_pos;
|
||||
last_pos.x = start.x;
|
||||
last_pos.y = start.y;
|
||||
last_pos.z = start.z;
|
||||
last_pos.x = start.x * 10.f;
|
||||
last_pos.y = start.y * 10.f;
|
||||
last_pos.z = start.z * 10.f;
|
||||
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
MovePathPoint* p = new MovePathPoint();
|
||||
p->src_pos = last_pos;
|
||||
|
||||
p->tar_pos.x = paths[i].x;
|
||||
p->tar_pos.y = paths[i].y;
|
||||
p->tar_pos.z = paths[i].z;
|
||||
p->tar_pos.x = paths[i].x * 10.f;
|
||||
p->tar_pos.y = paths[i].y * 10.f;
|
||||
p->tar_pos.z = paths[i].z * 10.f;
|
||||
|
||||
p->curr_pos = p->src_pos;
|
||||
|
||||
glm::vec2 src_pos;
|
||||
glm::vec2 tar_pos;
|
||||
|
||||
src_pos.x = p->src_pos.x;
|
||||
src_pos.y = p->src_pos.y;
|
||||
src_pos.x = p->src_pos.x * 10.f;
|
||||
src_pos.y = p->src_pos.y * 10.f;
|
||||
|
||||
tar_pos.x = p->tar_pos.x;
|
||||
tar_pos.y = p->tar_pos.y;
|
||||
tar_pos.x = p->tar_pos.x * 10.f;
|
||||
tar_pos.y = p->tar_pos.y * 10.f;
|
||||
|
||||
//p->distance = glm::norm(tar_pos - src_pos);
|
||||
{
|
||||
a8::Vec2 v1;
|
||||
a8::Vec2 v2;
|
||||
v1.x = tar_pos.x;
|
||||
v1.y = tar_pos.y;
|
||||
|
||||
v2.x = src_pos.x;
|
||||
v2.y = src_pos.y;
|
||||
|
||||
p->distance = v1.Distance(v2);
|
||||
}
|
||||
glm::vec2 dir = tar_pos - src_pos;
|
||||
glm::normalize(dir);
|
||||
|
||||
@ -204,6 +219,16 @@ void MoveHelper::AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths)
|
||||
p->dir.y = 0;
|
||||
p->dir.z = dir.y;
|
||||
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("AddPaths size:%d i:%d src_pos:%f,%f tar_pos:%f:%f\n",
|
||||
{
|
||||
paths.size(),
|
||||
i,
|
||||
src_pos.x,
|
||||
src_pos.y,
|
||||
tar_pos.x,
|
||||
tar_pos.y});
|
||||
#endif
|
||||
paths_.push_back(p);
|
||||
}
|
||||
}
|
||||
|
@ -3699,10 +3699,14 @@ int Room::GetOnlinePlayerNum()
|
||||
|
||||
size_t Room::GetRoomMaxPlayerNum()
|
||||
{
|
||||
#ifdef MAP3D
|
||||
return 2;
|
||||
#else
|
||||
if (pve_instance) {
|
||||
return pve_human_num;
|
||||
}
|
||||
return map_meta_->i->player();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Room::InitAndroidAI()
|
||||
|
@ -439,7 +439,7 @@ void InternalShot(Creature* c,
|
||||
bullet_born_offset = a8::Vec2(v.z *10*1, v.x*10*-1);
|
||||
bullet_born_pos = c->GetPos() + bullet_born_offset;
|
||||
if (c->IsPlayer() || c->IsCar()) {
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG1
|
||||
a8::XPrintf("idx:%d offset:%f,%f angle:%f old_angle:%f angle_xy:%f,%f %f %f gun_muzzle_position:%f,%f,%f pos:%f,%f gun_id:%d t:%d\n",
|
||||
{
|
||||
bulletIdx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user