1
This commit is contained in:
parent
ce7c06d841
commit
435fef7a89
@ -282,10 +282,21 @@ void HeroAI::DoMoveAI()
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if (owner->room->IsPveRoom()) {
|
|
||||||
}
|
|
||||||
int speed = std::max(1, (int)hero->GetSpeed()) * 1;
|
int speed = std::max(1, (int)hero->GetSpeed()) * 1;
|
||||||
|
a8::Vec2 old_pos = hero->GetPos();
|
||||||
hero->_UpdateMove(speed);
|
hero->_UpdateMove(speed);
|
||||||
|
if (owner->room->IsPveRoom() && IsNearGas()) {
|
||||||
|
#if 1
|
||||||
|
hero->SetPos(old_pos);
|
||||||
|
hero->on_move_collision();
|
||||||
|
#else
|
||||||
|
//if (hero->room->GetFrameNo() - node_->last_adjust_dir_frameno > SERVER_FRAME_RATE * 3) {
|
||||||
|
a8::Vec2 dir = hero->GetPos() - hero->room->GetGasData().pos_new;
|
||||||
|
hero->SetMoveDir(dir);
|
||||||
|
node_->last_adjust_dir_frameno = hero->room->GetFrameNo();
|
||||||
|
//}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
hero->on_move_collision = old_on_move_collision_func;
|
hero->on_move_collision = old_on_move_collision_func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,3 +624,10 @@ void HeroAI::ForceRandomWalk(int time, int idle_time)
|
|||||||
node_->next_random_move_frameno = myself->room->GetFrameNo() +
|
node_->next_random_move_frameno = myself->room->GetFrameNo() +
|
||||||
idle_time / FRAME_RATE_MS;
|
idle_time / FRAME_RATE_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HeroAI::IsNearGas()
|
||||||
|
{
|
||||||
|
Hero* hero = (Hero*)owner;
|
||||||
|
float distance = hero->GetPos().Distance(hero->room->GetGasData().pos_new);
|
||||||
|
return distance + hero->GetRadius() * 2 + 20 > hero->room->GetGasData().rad_new;
|
||||||
|
}
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
a8::Vec2 target_pos;
|
a8::Vec2 target_pos;
|
||||||
RoomObstacleWeakPtr target_obstacle;
|
RoomObstacleWeakPtr target_obstacle;
|
||||||
long long last_collision_times = 0;
|
long long last_collision_times = 0;
|
||||||
|
|
||||||
|
long long last_adjust_dir_frameno = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HeroAI : public AIComponent
|
class HeroAI : public AIComponent
|
||||||
@ -66,6 +68,7 @@ protected:
|
|||||||
float GetAttackRange();
|
float GetAttackRange();
|
||||||
float GetShotRange();
|
float GetShotRange();
|
||||||
int GetAttackTimes();
|
int GetAttackTimes();
|
||||||
|
bool IsNearGas();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HeroAINode* node_ = nullptr;
|
HeroAINode* node_ = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user