aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-11-10 12:19:50 -0700
committernathansmithsmith <nathansmith7@mailfence.com>2023-11-10 12:19:50 -0700
commit9588ded8d76e720299ad9d1b254409e715164b81 (patch)
tree8f1bac1e904e83b777dc7ab8f3e96e5f83d66465 /src
parentac7470ce5d680caa7fb53c235aea10cba45e1836 (diff)
Making changes to the guns and fine tuning
Diffstat (limited to 'src')
-rw-r--r--src/entities/caporale.c19
-rw-r--r--src/entities/caporale.h6
-rw-r--r--src/entities/sergente.c45
-rw-r--r--src/entities/sergente.h7
-rw-r--r--src/entities/soldato.c14
-rw-r--r--src/entities/soldato.h1
-rw-r--r--src/levels/level1.c2
7 files changed, 48 insertions, 46 deletions
diff --git a/src/entities/caporale.c b/src/entities/caporale.c
index e4566dd..3b29784 100644
--- a/src/entities/caporale.c
+++ b/src/entities/caporale.c
@@ -29,6 +29,7 @@ void initCaporale(Entity * entity, Game * game) {
};
data->timeSinceLastShot = 0.0;
+ data->gunTarget = Vector3One();
}
void closeCaporale(Entity * entity) {
@@ -44,31 +45,23 @@ void updateGunsCaporale(Game * game, Entity * entity) {
Caporale * data = (Caporale*)entity->data;
Entity * player = getEntityFromWorld(game->world, 0);
+ // Update gun target.
+ Vector3 target = Vector3Normalize(Vector3Subtract(player->position, entity->position));
+ data->gunTarget = Vector3Lerp(data->gunTarget, target, GetFrameTime() * CAPORALE_GUN_TARGETING_SPEED);
+
// Cool down.
if (t - data->timeSinceLastShot < CAPORALE_COOLDOWN)
return;
data->timeSinceLastShot = t;
- // Use random number to decide if hit.
- SetRandomSeed(time(NULL));
-
- if (GetRandomValue(1, CAPORALE_CHANGE_OF_HIT) != 1)
- return;
-
- // If random thingy shoot bullet that can't miss.
-
- // Get direction.
- Vector3 direction = Vector3Subtract(player->position, entity->position);
- direction = Vector3Normalize(direction);
-
float damage = CAPORALE_BULLET_DAMAGE;
if (entity->health <= CAPORALE_LOW_HEALTH_THRESHOLD)
damage = CAPORALE_LOW_HEALTH_BULLET_DAMAGE;
// Create bullet and shoot.
- Bullet bullet = createBulletFromDirection(*entity, direction, damage);
+ Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, damage);
shootBulletAtEntity(player, bullet);
}
diff --git a/src/entities/caporale.h b/src/entities/caporale.h
index ac4be6f..18bacbc 100644
--- a/src/entities/caporale.h
+++ b/src/entities/caporale.h
@@ -6,15 +6,17 @@
#ifndef CAPORALE_H
#define CAPORALE_H
-#define CAPORALE_COOLDOWN 0.5
+#define CAPORALE_COOLDOWN 1.0
#define CAPORALE_BULLET_DAMAGE 0.01
-#define CAPORALE_CHANGE_OF_HIT 10
+#define CAPORALE_GUN_TARGETING_SPEED 20.0
#define CAPORALE_LOW_HEALTH_THRESHOLD 0.9
#define CAPORALE_LOW_HEALTH_BULLET_DAMAGE 0.02
typedef struct Caporale {
EntityFlyToPointInfo flyToPlayer;
double timeSinceLastShot;
+
+ Vector3 gunTarget;
} Caporale;
void initCaporale(Entity * entity, Game * game);
diff --git a/src/entities/sergente.c b/src/entities/sergente.c
index 36847d6..0721d1e 100644
--- a/src/entities/sergente.c
+++ b/src/entities/sergente.c
@@ -33,6 +33,7 @@ void initSergente(Entity * entity, Game * game) {
createSergenteTarget(game, entity);
data->timeSinceLastShot = 0.0;
+ data->gunTarget = Vector3One();
}
void closeSergente(Entity * entity) {
@@ -74,6 +75,10 @@ void updateGunsSergente(Game * game, Entity * entity) {
Entity * player = getEntityFromWorld(game->world, 0);
Bullet shot;
+ // Update the fucking gun target.
+ Vector3 target = Vector3Normalize(Vector3Subtract(player->position, entity->position));
+ data->gunTarget = Vector3Lerp(data->gunTarget, target, GetFrameTime() * SERGENTE_GUN_TARGETING_SPEED);
+
// Cool down.
if (t - data->timeSinceLastShot < SERGENTE_COOL_DOWN)
return;
@@ -81,14 +86,12 @@ void updateGunsSergente(Game * game, Entity * entity) {
// We will use random numbers later.
SetRandomSeed(time(NULL));
- // Get direction to player.
- Vector3 dirToPlayer = Vector3Subtract(player->position, entity->position);
- dirToPlayer = Vector3Normalize(dirToPlayer);
+ // Direction shit.
Vector3 direction;
// Shot the shots because this is a fucking shot gun.
for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
- direction = Vector3Add(dirToPlayer, getSergenteShotSpread());
+ direction = Vector3Add(data->gunTarget, getSergenteShotSpread());
// Create shot.
shot = createBulletFromDirection(*entity, direction, SERGENTE_DAMAGE);
@@ -123,27 +126,29 @@ void updateSergente(Game * game, Entity * entity) {
void drawSergente(Game * game, Entity * entity) {
entityDraw(entity);
+ /*
// Debug shots
- // int i;
- // Sergente * data = (Sergente*)entity->data;
- //
- // for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
- // DrawRay(data->shots[i].ray, BLUE);
- // DrawCube(data->shots[i].ray.position, 1.0, 1.0, 1.0, BLUE);
- // }
+ int i;
+ Sergente * data = (Sergente*)entity->data;
+
+ for (i = 0; i < SERGENTE_SHOT_COUNT; ++i) {
+ DrawRay(data->shots[i].ray, BLUE);
+ DrawCube(data->shots[i].ray.position, 1.0, 1.0, 1.0, BLUE);
+ }
// Test if facing player always.
- //DrawLine3D(
- // entity->position,
- // Vector3Add(
- // entity->position,
- // Vector3Scale(Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation), 500.0)
- // ),
- // BLUE
- //);
+ DrawLine3D(
+ entity->position,
+ Vector3Add(
+ entity->position,
+ Vector3Scale(Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, entity->rotation), 500.0)
+ ),
+ BLUE
+ );
// The fucking debug line.
- //DrawLine3D(entity->position, ((Sergente*)entity->data)->target, BLUE);
+ DrawLine3D(entity->position, ((Sergente*)entity->data)->target, BLUE);
+ */
}
void comeBackToPlayerSergente(Game * game, Entity * entity) {
diff --git a/src/entities/sergente.h b/src/entities/sergente.h
index e7d52b5..c2ce96c 100644
--- a/src/entities/sergente.h
+++ b/src/entities/sergente.h
@@ -8,21 +8,24 @@
#define SERGENTE_TARGET_DIS_MIN 5
#define SERGENTE_TARGET_DIS_MAX 100
#define SERGENTE_NEXT_POINT_THRESHOLD 60.0
-#define SERGENTE_COME_BACK_DIS 200.0
+#define SERGENTE_COME_BACK_DIS 800.0
#define SERGENTE_COME_BACK_PERCENT 0.5
#define SERGENTE_ROTATION_SPEED 20.0
// Gun stuff.
#define SERGENTE_COOL_DOWN 0.5
#define SERGENTE_SHOT_COUNT 50
-#define SERGENTE_SPREAD 0.1
+#define SERGENTE_SPREAD 0.05
#define SERGENTE_DAMAGE 0.001
+#define SERGENTE_GUN_TARGETING_SPEED 10.0
typedef struct Sergente {
EntityFlyToPointInfo flyToPoint;
Vector3 target;
+
double timeSinceLastShot;
Bullet shots[SERGENTE_SHOT_COUNT];
+ Vector3 gunTarget;
} Sergente;
void initSergente(Entity * entity, Game * game);
diff --git a/src/entities/soldato.c b/src/entities/soldato.c
index 3f548ac..7318d5b 100644
--- a/src/entities/soldato.c
+++ b/src/entities/soldato.c
@@ -119,14 +119,12 @@ void updateSoldatoGuns(Game * game, Entity * entity) {
if (t - data->timeSinceLastShot < SOLDATO_COOLDOWN)
return;
- // Shoot if in range.
- if (Vector3Distance(entity->position, player->position) <= SOLDATO_GUN_MAX_RANGE) {
- Bullet bullet = createBulletFromDirection(*entity, data->gunTarget, SOLDATO_BULLET_DAMAGE);
- BulletHitInfo hit = shootBulletAtEntity(player, bullet);
+ // Shoot this fucker.
+ 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;
}
@@ -154,12 +152,14 @@ void drawSoldato(Game * game, Entity * entity) {
entityDraw(entity);
// Debug gun.
+ /*
Soldato * data = (Soldato*)entity->data;
DrawLine3D(
entity->position,
Vector3Add(entity->position, Vector3Scale(data->gunTarget, SOLDATO_GUN_MAX_RANGE)),
BLUE
);
+ */
/*
Entity * leader;
diff --git a/src/entities/soldato.h b/src/entities/soldato.h
index efde07d..392be54 100644
--- a/src/entities/soldato.h
+++ b/src/entities/soldato.h
@@ -9,7 +9,6 @@
#define SOLDATO_AIM_RADIOUS 1.5
#define SOLDATO_BULLET_DAMAGE 0.01
#define SOLDATO_GUN_TARGETING_SPEED 10.0 // 3.0
-#define SOLDATO_GUN_MAX_RANGE 400.0
#define SOLDATO_ROTATION_SPEED 0.5
typedef struct Soldato {
diff --git a/src/levels/level1.c b/src/levels/level1.c
index 7ccfe0a..9f7afc9 100644
--- a/src/levels/level1.c
+++ b/src/levels/level1.c
@@ -6,7 +6,7 @@
void initLevel1(Game * game, Levels * levels) {
WorldEntry entries[2] = {
(WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()},
- (WorldEntry){ENTITY_CAPORALE, (Vector3){0.0, 10.0, 50.0}, QuaternionIdentity()}
+ (WorldEntry){ENTITY_SERGENTE, (Vector3){0.0, 10.0, 50.0}, QuaternionIdentity()}
};
addEntriesToWorld(