From cd8191e2b12ca24a03945fa8c5f800a53f7bee7f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 20 May 2019 16:29:50 +0800 Subject: [PATCH] 1 --- server/gameserver/android.ai.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index 7734ccf..191d472 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -1,5 +1,7 @@ #include "precompile.h" +#include + #include "android.ai.h" #include "android.h" #include "room.h" @@ -119,10 +121,13 @@ void AndroidAI::DoAttack() if (enemy) { Human* sender = (Human*)owner; Vector2D shot_dir = enemy->pos - sender->pos; - shot_dir.Normalize(); - shot_dir.Rotate((rand() % 10) / 180.0f); - sender->attack_dir = shot_dir; - sender->Shot(shot_dir); + if (std::abs(shot_dir.x) > FLT_EPSILON || + std::abs(shot_dir.y) > FLT_EPSILON) { + shot_dir.Normalize(); + shot_dir.Rotate((rand() % 10) / 180.0f); + sender->attack_dir = shot_dir; + sender->Shot(shot_dir); + } } } }