diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-13 18:34:03 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-13 18:34:03 -0600 |
commit | 3b22489413553e837a7da437b2c3cd69823095ab (patch) | |
tree | 903c69c5f0ada44e915212657eb97d082c8dbd00 /src/entities/maresciallo.c | |
parent | 7d4d948dfa92416c802229b1c444a44785ee2a0c (diff) |
maresciallo gun and missile stuff in different procedures
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r-- | src/entities/maresciallo.c | 31 |
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); } |