This commit is contained in:
aozhiwei 2020-07-15 12:13:34 +08:00
parent d782d47a53
commit 7af787519a
4 changed files with 27 additions and 4 deletions

View File

@ -21,3 +21,4 @@ int AIComponent::GetAiLevel()
{ {
return ai_level_; return ai_level_;
} }

View File

@ -544,7 +544,15 @@ void AndroidNewAI::UpdateRandomWalk()
void AndroidNewAI::UpdatePursuit() void AndroidNewAI::UpdatePursuit()
{ {
Human* myself = (Human*)owner;
float distance = myself->GetPos().Distance(node_.target->GetPos());
if (distance < GetAttackRange()) {
ChangeToStateNewAI(ASE_Attack);
} else {
if (node_.exec_frame_num > 100) {
ChangeToStateNewAI(ASE_RandomWalk);
}
}
} }
void AndroidNewAI::DoMoveNewAI() void AndroidNewAI::DoMoveNewAI()
@ -676,7 +684,7 @@ float AndroidNewAI::GetAttackRange()
if (myself->curr_weapon && myself->curr_weapon->meta) { if (myself->curr_weapon && myself->curr_weapon->meta) {
attack_range = myself->curr_weapon->meta->i->range(); attack_range = myself->curr_weapon->meta->i->range();
} }
attack_range = std::min(500.0f, attack_range); attack_range = std::min(300.0f, attack_range);
return attack_range; return attack_range;
} }
@ -692,8 +700,14 @@ void AndroidNewAI::DoShotNewAI()
if (std::abs(shot_dir.x) > FLT_EPSILON || if (std::abs(shot_dir.x) > FLT_EPSILON ||
std::abs(shot_dir.y) > FLT_EPSILON) { std::abs(shot_dir.y) > FLT_EPSILON) {
shot_dir.Normalize(); shot_dir.Normalize();
myself->attack_dir = shot_dir; if (ai_meta->i->shot_offset_angle() > 0) {
if (rand() % 10 < 3) {
shot_dir.Rotate(ai_meta->i->shot_offset_angle() / 180.0f); shot_dir.Rotate(ai_meta->i->shot_offset_angle() / 180.0f);
} else {
shot_dir.Rotate(ai_meta->i->shot_offset_angle() / -180.0f);
}
}
myself->attack_dir = shot_dir;
myself->Shot(shot_dir, shot_ok); myself->Shot(shot_dir, shot_ok);
if (shot_ok) { if (shot_ok) {
if (node_.shot_times <= 0) { if (node_.shot_times <= 0) {

View File

@ -1005,6 +1005,11 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
{ {
#ifdef DEBUG
if (IsPlayer()) {
return;
}
#endif
auto downed_func = [] (const a8::XParams& param) auto downed_func = [] (const a8::XParams& param)
{ {
Human* hum = (Human*)param.sender.GetUserData(); Human* hum = (Human*)param.sender.GetUserData();

View File

@ -2913,7 +2913,8 @@ void Room::InitAndroidAI()
} }
for (Android* hum : androids) { for (Android* hum : androids) {
#if 1 #if 1
hum->SetAiLevel(2); hum->SetAiLevel(5);
continue;
#endif #endif
if (IsMiniRoom()) { if (IsMiniRoom()) {
int rnd = rand() % MetaMgr::Instance()->mini_room_ai_weights_space; int rnd = rand() % MetaMgr::Instance()->mini_room_ai_weights_space;
@ -2940,3 +2941,5 @@ void Room::InitAndroidAI()
} }
} }
} }