Skip to content

Commit

Permalink
micro fix +1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-str committed Mar 3, 2021
1 parent aa975cf commit 3a9a07b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a9a07b

Please sign in to comment.