aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-09-13 18:34:03 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-09-13 18:34:03 -0600
commit3b22489413553e837a7da437b2c3cd69823095ab (patch)
tree903c69c5f0ada44e915212657eb97d082c8dbd00 /src
parent7d4d948dfa92416c802229b1c444a44785ee2a0c (diff)
maresciallo gun and missile stuff in different procedures
Diffstat (limited to 'src')
-rw-r--r--src/entities/guidedMissile.c4
-rw-r--r--src/entities/guidedMissile.h3
-rw-r--r--src/entities/maresciallo.c31
-rw-r--r--src/entities/maresciallo.h6
4 files changed, 36 insertions, 8 deletions
diff --git a/src/entities/guidedMissile.c b/src/entities/guidedMissile.c
index b7f6b68..cd5bbe1 100644
--- a/src/entities/guidedMissile.c
+++ b/src/entities/guidedMissile.c
@@ -24,7 +24,7 @@ void initGuidedMissile(Entity * entity, Game * game) {
.controller.bangbang.speed = 80,
.controller.bangbang.stopAt = 0.0,
.controlType = ENTITY_FLY_TO_POINT_BANG_BANG,
- .rotationSpeed = 20.0,
+ .rotationSpeed = 10.0,
.applyRotation = true
};
}
@@ -73,7 +73,7 @@ void guidedMissileGoBoomBoom(Game * game, Entity * entity) {
// Get player distance and get the damage the missile will do.
float distance = Vector3Distance(player->position, entity->position);
- float damage = distance * GUIDED_MISSILE_DAMAGE;
+ float damage = fabsf(GUIDED_MISSILE_DAMAGE - (distance * GUIDED_MISSILE_BOOM_DISTANCE_MOD));
// Hurt this mother fucker.
player->health -= damage;
diff --git a/src/entities/guidedMissile.h b/src/entities/guidedMissile.h
index 8d33e86..149fe26 100644
--- a/src/entities/guidedMissile.h
+++ b/src/entities/guidedMissile.h
@@ -7,7 +7,8 @@
#ifndef GUIDED_MISSILE_H
#define GUIDED_MISSILE_H
-#define GUIDED_MISSILE_DAMAGE 2.0
+#define GUIDED_MISSILE_DAMAGE 0.5
+#define GUIDED_MISSILE_BOOM_DISTANCE_MOD 0.3
#define GUIDED_MISSILE_BOOM_BOOM_AT 5.0
#define GUIDED_MISSILE_DEATH_DAY 5.0 // Its like a birth day but sad.
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);
}
diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h
index a88910c..d1d17af 100644
--- a/src/entities/maresciallo.h
+++ b/src/entities/maresciallo.h
@@ -9,12 +9,16 @@
#define MARESCIALLO_ROTATION_SPEED 20.0
#define MARESCIALLO_CIRCLE_PLAYER_SPEED 1.0
-#define MARESCIALLO_COOLDOWN 3.0
+#define MARESCIALLO_BULLET_COOLDOWN 3.0
#define MARESCIALLO_BULLET_DAMAGE 0.01
+#define MARESCIALLO_CHANGE_OF_HIT 10
+
+#define MARESCIALLO_MISSILE_COOLDOWN 3.0
typedef struct Maresciallo {
EntityFlyToPointInfo flyToPoint;
double timeSinceLastBulletShot;
+ double timeSinceLastMissileShot;
} Maresciallo;
void initMaresciallo(Entity * entity, Game * game);