aboutsummaryrefslogtreecommitdiff
path: root/src/entities/maresciallo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r--src/entities/maresciallo.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c
index 52c5d96..826a7d4 100644
--- a/src/entities/maresciallo.c
+++ b/src/entities/maresciallo.c
@@ -22,6 +22,7 @@ void initMaresciallo(Entity * entity, Game * game) {
Maresciallo * data = (Maresciallo*)entity->data;
data->timeSinceLastBulletShot = GetTime();
+ data->timeSinceLastMissileShot = GetTime();
PIDConfig flyToPointPID = (PIDConfig){
.kP = 1.1,
@@ -98,19 +99,40 @@ void updateGunMaresciallo(Game * game, Entity * entity) {
Maresciallo * data = (Maresciallo*)entity->data;
Entity * player = getEntityFromWorld(game->world, 0);
- if (t - data->timeSinceLastBulletShot < MARESCIALLO_COOLDOWN)
+ if (t - data->timeSinceLastBulletShot < MARESCIALLO_BULLET_COOLDOWN)
return;
+ SetRandomSeed(time(NULL));
+
+ // Shoots bullet that cant miss if random thingy.
+ if (GetRandomValue(1, MARESCIALLO_CHANGE_OF_HIT) != 1)
+ return;
+
+ Vector3 direction = Vector3Subtract(player->position, entity->position);
+ direction = Vector3Normalize(direction);
+
// Create and shoot bullet.
- Bullet bullet = createBulletFromEntity(*entity, MARESCIALLO_BULLET_DAMAGE);
+ Bullet bullet = createBulletFromDirection(*entity, direction, MARESCIALLO_BULLET_DAMAGE);
BulletHitInfo hit = shootBulletAtEntity(player, bullet);
- // Testing missile.
+ printf("This fucker hithit ajskdlfjkl %d\n", hit.hit);
+
+ data->timeSinceLastBulletShot = t;
+}
+
+// A missile, might find in a school in florida.
+void updateMissilesMaresciallo(Game * game, Entity * entity) {
+ double t = GetTime();
+ Maresciallo * data = (Maresciallo*)entity->data;
+
+ if (t - data->timeSinceLastMissileShot < MARESCIALLO_MISSILE_COOLDOWN)
+ return;
+
Entity missile = createEntity(ENTITY_GUIDED_MISSILE, game);
missile.position = entity->position;
scheduleEntityToAdd(&game->world, missile);
- data->timeSinceLastBulletShot = t;
+ data->timeSinceLastMissileShot = t;
}
void updateMaresciallo(Game * game, Entity * entity) {
@@ -124,6 +146,7 @@ void updateMaresciallo(Game * game, Entity * entity) {
// Fly away if to close to player.
if (dis < MARESCIALLO_CIRCLE_AT_DIS - 1 || dis >= MARESCIALLO_COME_BACK_AT_DIS) {
flyToPointMaresciallo(game, entity);
+ updateMissilesMaresciallo(game, entity);
} else {
circlePlayerMaresciallo(game, entity);
}