added weapon sounds and AI doesnt shoot if not in range
This commit is contained in:
parent
d1a7053149
commit
8016bab3e8
8 changed files with 48 additions and 13 deletions
12
COMShip.h
12
COMShip.h
|
|
@ -34,6 +34,18 @@ public:
|
|||
name = std::move(_name);
|
||||
};
|
||||
|
||||
void shoot(std::vector<Shootable*> &shots) override {
|
||||
for (Weapon *w : weapons) {
|
||||
double angle = -getAimAngle(target->getPosition(), getPosition());
|
||||
double leftEffectiveBorder = spritePhysics.direction + w->getEffectiveAngle()/2;
|
||||
double rightEffectiveBorder = spritePhysics.direction - w->getEffectiveAngle()/2;
|
||||
|
||||
if (w->canShoot() && ( angle < leftEffectiveBorder && angle > rightEffectiveBorder) && distance(target->getPosition(), getPosition()) < w->getProjectile().getRange()) {
|
||||
shots.push_back(w->shoot(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template< class RNG >
|
||||
Status pathfind(const sf::RenderWindow &window, RNG &gen, System *loc, Ship* player, std::vector<Shootable*> &projectiles) {
|
||||
if (status != ATTACKING && isHostile()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue