diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-11-15 16:25:54 -0700 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-11-15 16:25:54 -0700 |
commit | 581ea4aaf1acefa663446faa32a480bbcc3e084c (patch) | |
tree | 47e05bab3da699d707d0af089f8b8287fbda38fd | |
parent | 22535c8b18cda1d5a1ee771616425fc3941a801c (diff) |
Kill log only shows stuff you killed
-rw-r--r-- | src/entities/antifaShip.c | 11 | ||||
-rw-r--r-- | src/entities/antifaShip.h | 1 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 19 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 4 | ||||
-rw-r--r-- | src/entities/soldato.c | 4 | ||||
-rw-r--r-- | src/entity.c | 1 | ||||
-rw-r--r-- | src/entity.h | 1 | ||||
-rw-r--r-- | src/world.c | 6 |
8 files changed, 25 insertions, 22 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index b90060e..1ba8db9 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -152,17 +152,16 @@ void fireBulletAntifa(Game * game, Entity * entity) { if (t - data->timeSinceLastBullet < ANTIFA_BULLET_COOLDOWN) return; - puts("shoot shoot"); - - Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, 1.0); + Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, ANTIFA_BULLET_DAMAGE); BulletHitInfo info = shootBullet(&game->world, bullet); data->lastBulletShot = bullet; if (info.hit) { Entity * hitEntity = getEntityFromWorld(game->world, info.hitId); - printVector3(hitEntity->position); - } else { - puts("you stink"); + + // We were the fucker that killed this low iq fascist! + if (hitEntity->health <= 0.0) + hitEntity->killedByPlayer = true; } data->timeSinceLastBullet = t; diff --git a/src/entities/antifaShip.h b/src/entities/antifaShip.h index 2781584..a99e419 100644 --- a/src/entities/antifaShip.h +++ b/src/entities/antifaShip.h @@ -8,6 +8,7 @@ #define ANTIFA_SHIP_MAX_SPEED 200.0 #define ANTIFA_BULLET_COOLDOWN 0.5 #define ANTIFA_DRAW_BULLET_FOR 0.05 +#define ANTIFA_BULLET_DAMAGE 0.5 // Auto target shit. #define ANTIFA_START_AUTO_TARGET_MAX 0.5 // How far off auto target can be entail it drops. 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; } diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h index b853ef4..2d46eeb 100644 --- a/src/entities/maresciallo.h +++ b/src/entities/maresciallo.h @@ -11,7 +11,7 @@ #define MARESCIALLO_BULLET_COOLDOWN 3.0 #define MARESCIALLO_BULLET_DAMAGE 0.01 -#define MARESCIALLO_CHANGE_OF_HIT 10 +#define MARESCIALLO_GUN_TARGETING_SPEED 20.0 #define MARESCIALLO_MISSILE_COOLDOWN 5.0 @@ -19,6 +19,8 @@ typedef struct Maresciallo { EntityFlyToPointInfo flyToPoint; double timeSinceLastBulletShot; double timeSinceLastMissileShot; + + Vector3 gunTarget; } Maresciallo; void initMaresciallo(Entity * entity, Game * game); diff --git a/src/entities/soldato.c b/src/entities/soldato.c index 7318d5b..28e9b67 100644 --- a/src/entities/soldato.c +++ b/src/entities/soldato.c @@ -123,8 +123,8 @@ void updateSoldatoGuns(Game * game, Entity * entity) { Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, SOLDATO_BULLET_DAMAGE); BulletHitInfo hit = shootBulletAtEntity(player, bullet); - if (hit.hit) - printf("This fucker hit %lf\n", t); + // if (hit.hit) + // printf("This fucker hit %lf\n", t); data->timeSinceLastShot = t; } diff --git a/src/entity.c b/src/entity.c index 7fbf966..a44220a 100644 --- a/src/entity.c +++ b/src/entity.c @@ -62,6 +62,7 @@ Entity createEntity(EntityType type, Game * game) { .updateCb = info.updateCb, .drawCb = info.drawCb, .health = ENTITY_MAX_HEALTH, + .killedByPlayer = false, .follow = (EntityFollow){ .leaderId = ENTITY_NONE, .followerId = ENTITY_NONE diff --git a/src/entity.h b/src/entity.h index dfc38a4..a7e442d 100644 --- a/src/entity.h +++ b/src/entity.h @@ -120,6 +120,7 @@ typedef struct Entity { // Health is a percent from 1.0 to 0.0. float health; + bool killedByPlayer; EntityCollision collision; diff --git a/src/world.c b/src/world.c index f104ec1..2764b32 100644 --- a/src/world.c +++ b/src/world.c @@ -348,7 +348,11 @@ void updateWorld(World * world, Game * game) { // "bring out your dead!" for (i = 0; i < killCount; ++i) { - pushKill(&game->killLog, *getEntityFromWorld(*world, kills[i])); + entity = getEntityFromWorld(*world, kills[i]); + + if (entity->killedByPlayer) + pushKill(&game->killLog, *entity); + removeEntityFromWorld(world, kills[i]); } |