diff options
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r-- | src/entities/maresciallo.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index b03d366..4b6ce03 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -40,6 +40,8 @@ void initMaresciallo(Entity * entity, Game * game) { .rotationSpeed = MARESCIALLO_ROTATION_SPEED, .applyRotation = true }; + + data->gunTarget = Vector3One(); } void closeMaresciallo(Entity * entity) { @@ -99,24 +101,17 @@ void updateGunMaresciallo(Game * game, Entity * entity) { Maresciallo * data = (Maresciallo*)entity->data; Entity * player = getEntityFromWorld(game->world, 0); - if (t - data->timeSinceLastBulletShot < MARESCIALLO_BULLET_COOLDOWN) - return; - - SetRandomSeed(time(NULL)); + // Aim at the stupid fucker playing this stupid ass game. + Vector3 target = Vector3Normalize(Vector3Subtract(player->position, entity->position)); + data->gunTarget = Vector3Lerp(data->gunTarget, target, GetFrameTime() * MARESCIALLO_GUN_TARGETING_SPEED); - // Shoots bullet that cant miss if random thingy. - if (GetRandomValue(1, MARESCIALLO_CHANGE_OF_HIT) != 1) + if (t - data->timeSinceLastBulletShot < MARESCIALLO_BULLET_COOLDOWN) return; - Vector3 direction = Vector3Subtract(player->position, entity->position); - direction = Vector3Normalize(direction); - // Create and shoot bullet. - Bullet bullet = createBulletFromDirection(*entity, direction, MARESCIALLO_BULLET_DAMAGE); + Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, MARESCIALLO_BULLET_DAMAGE); BulletHitInfo hit = shootBulletAtEntity(player, bullet); - //printf("This fucker hithit ajskdlfjkl %d\n", hit.hit); - data->timeSinceLastBulletShot = t; } |