From 3a9a07b945c1448f27f91e649497836151c9f311 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 3 Mar 2021 18:02:20 +0300 Subject: [PATCH] micro fix +1 --- Enemy.cpp | 14 +++++--------- Enemy.h | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Enemy.cpp b/Enemy.cpp index 6223888..c364cf0 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -108,15 +108,11 @@ void Enemy::Move(Point player_pos) time_when_try_attack = get_time_before_attack(type) + GameTime::Now().GetTime(); } } else { - if (attack_cd && GameTime::Now().TimeCome(attack_cd_time)) { - attack_cd = false; - /*auto can_a = fn_can_attack(pl, pos); - if (can_a.first) { - walk_to_player = true; - time_when_try_attack = GameTime::Now().GetTime(); - } else walk_to_player = false;*/ - } - else if (!attack_cd && GameTime::Now().TimeCome(time_when_try_attack)) { + bool cd_pass = (attack_cd && GameTime::Now().TimeCome(attack_cd_time)); + bool attack_try = (!attack_cd && GameTime::Now().TimeCome(time_when_try_attack)); + if (cd_pass)attack_cd = false; + + if (cd_pass || attack_try) { auto can_a = fn_can_attack(pl, pos); if (can_a.first) { attack_dir = can_a.second; diff --git a/Enemy.h b/Enemy.h index 77d63b1..9d31ac5 100644 --- a/Enemy.h +++ b/Enemy.h @@ -22,13 +22,13 @@ struct Enemy static constexpr double get_cd(int type) { if (type == 0)return 0.7; - if (type == 1)return 2; + if (type == 1)return 2; // 0.1 return 1.5; } static constexpr double get_time_before_attack(int type) { if (type == 0)return 0.3; - if (type == 1)return 3;// 0.9; + if (type == 1)return 0.9; // 5 return 0.5; } static constexpr bool is_fly(int type)