From 597f6f5cb7e39e1fd855f0fc79a7d2c95511e0fc Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 21 Nov 2015 23:45:22 +0000 Subject: [PATCH] Removed missiles types. Now only homing missiles, and rockets for bombers. --- data/fighters/ataf.json | 5 +---- data/fighters/dart.json | 5 +---- data/fighters/firefly.json | 5 +---- data/fighters/hammerhead.json | 10 ++++++---- data/fighters/hyenaA.json | 5 +---- data/fighters/hyenaB.json | 5 +---- data/fighters/jackal.json | 5 +---- data/fighters/khepri.json | 10 ++++++---- data/fighters/kingfisher.json | 5 +---- data/fighters/leopard.json | 5 +---- data/fighters/mantis.json | 5 +---- data/fighters/nymph.json | 5 +---- data/fighters/ray.json | 5 +---- data/fighters/rook.json | 5 +---- data/fighters/scarab.json | 5 +---- data/fighters/simpleDart.json | 5 +---- data/fighters/sphinx.json | 5 +---- data/fighters/taf.json | 5 +---- data/fighters/thunderhead.json | 5 +---- src/battle/ai.c | 4 ++-- src/battle/bullets.c | 19 ++++++++++++++++--- src/battle/fighters.c | 7 ++----- src/battle/hud.c | 2 +- src/battle/player.c | 2 +- src/defs.h | 8 -------- src/structs.h | 2 +- src/system/lookup.c | 4 ---- 27 files changed, 52 insertions(+), 101 deletions(-) diff --git a/data/fighters/ataf.json b/data/fighters/ataf.json index 83c709e..4312778 100644 --- a/data/fighters/ataf.json +++ b/data/fighters/ataf.json @@ -59,8 +59,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/dart.json b/data/fighters/dart.json index c69d123..21ba942 100644 --- a/data/fighters/dart.json +++ b/data/fighters/dart.json @@ -18,8 +18,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 2 - } + "missiles" : 2 } diff --git a/data/fighters/firefly.json b/data/fighters/firefly.json index b94273a..fdabd1a 100644 --- a/data/fighters/firefly.json +++ b/data/fighters/firefly.json @@ -24,8 +24,5 @@ } ], "combinedGuns" : 1, - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 3 - } + "missiles" : 3 } diff --git a/data/fighters/hammerhead.json b/data/fighters/hammerhead.json index 45b74f9..84a1594 100644 --- a/data/fighters/hammerhead.json +++ b/data/fighters/hammerhead.json @@ -16,11 +16,13 @@ "type" : "BT_PLASMA", "x" : 12, "y" : 0 + }, + { + "type" : "BT_ROCKET", + "x" : 0, + "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 60 - }, + "missiles" : 6, "aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE" } diff --git a/data/fighters/hyenaA.json b/data/fighters/hyenaA.json index dd52f99..19bdf97 100644 --- a/data/fighters/hyenaA.json +++ b/data/fighters/hyenaA.json @@ -28,8 +28,5 @@ "y" : -12 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/hyenaB.json b/data/fighters/hyenaB.json index 22e9caf..be48eae 100644 --- a/data/fighters/hyenaB.json +++ b/data/fighters/hyenaB.json @@ -28,8 +28,5 @@ "y" : -12 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/jackal.json b/data/fighters/jackal.json index f7cbe94..e2c16dd 100644 --- a/data/fighters/jackal.json +++ b/data/fighters/jackal.json @@ -18,8 +18,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 3 - } + "missiles" : 3 } diff --git a/data/fighters/khepri.json b/data/fighters/khepri.json index ba55a9e..f55b8d4 100644 --- a/data/fighters/khepri.json +++ b/data/fighters/khepri.json @@ -21,11 +21,13 @@ "type" : "BT_PLASMA", "x" : 0, "y" : 0 + }, + { + "type" : "BT_ROCKET", + "x" : 0, + "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 80 - }, + "missiles" : 8, "aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE" } diff --git a/data/fighters/kingfisher.json b/data/fighters/kingfisher.json index c35894c..d3857a5 100644 --- a/data/fighters/kingfisher.json +++ b/data/fighters/kingfisher.json @@ -28,8 +28,5 @@ "y" : -12 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/leopard.json b/data/fighters/leopard.json index e5513f2..63b36c8 100644 --- a/data/fighters/leopard.json +++ b/data/fighters/leopard.json @@ -23,8 +23,5 @@ "y" : -16 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 3 - } + "missiles" : 3 } diff --git a/data/fighters/mantis.json b/data/fighters/mantis.json index b2a5d28..16226df 100644 --- a/data/fighters/mantis.json +++ b/data/fighters/mantis.json @@ -29,8 +29,5 @@ } ], "combinedGuns" : 1, - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 6 - } + "missiles" : 6 } diff --git a/data/fighters/nymph.json b/data/fighters/nymph.json index 0887c8c..50b2e2c 100644 --- a/data/fighters/nymph.json +++ b/data/fighters/nymph.json @@ -18,8 +18,5 @@ "y" : -2 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 3 - } + "missiles" : 3 } diff --git a/data/fighters/ray.json b/data/fighters/ray.json index e5e7fe3..ffd7489 100644 --- a/data/fighters/ray.json +++ b/data/fighters/ray.json @@ -28,8 +28,5 @@ "y" : -12 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/rook.json b/data/fighters/rook.json index 5b90a43..e9aa865 100644 --- a/data/fighters/rook.json +++ b/data/fighters/rook.json @@ -28,8 +28,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/scarab.json b/data/fighters/scarab.json index 95033e4..5d9488e 100644 --- a/data/fighters/scarab.json +++ b/data/fighters/scarab.json @@ -23,9 +23,6 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 8 - }, + "missiles" : 8, "aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE" } diff --git a/data/fighters/simpleDart.json b/data/fighters/simpleDart.json index 3716d71..5590074 100644 --- a/data/fighters/simpleDart.json +++ b/data/fighters/simpleDart.json @@ -18,8 +18,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 2 - } + "missiles" : 2 } diff --git a/data/fighters/sphinx.json b/data/fighters/sphinx.json index a600ece..f0e6666 100644 --- a/data/fighters/sphinx.json +++ b/data/fighters/sphinx.json @@ -28,8 +28,5 @@ "y" : 0 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 2 - } + "missiles" : 2 } diff --git a/data/fighters/taf.json b/data/fighters/taf.json index b1ac1b0..a84b3b1 100644 --- a/data/fighters/taf.json +++ b/data/fighters/taf.json @@ -18,8 +18,5 @@ "y" : -12 } ], - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/data/fighters/thunderhead.json b/data/fighters/thunderhead.json index 733766c..02dac9a 100644 --- a/data/fighters/thunderhead.json +++ b/data/fighters/thunderhead.json @@ -34,8 +34,5 @@ } ], "combinedGuns" : 1, - "missiles" : { - "type" : "MISSILE_MISSILE", - "ammo" : 4 - } + "missiles" : 4 } diff --git a/src/battle/ai.c b/src/battle/ai.c index af5ccd7..aece224 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -375,11 +375,11 @@ static void preAttack(void) /* force weapon selection, otherwise we'll keep using lasers / mag */ canAttack(self->target); - if (self->guns[0].type && (self->missiles.ammo == 0 || rand() % 50 > 0)) + if (self->guns[0].type && (self->missiles == 0 || rand() % 50 > 0)) { fireGuns(self); } - else if (self->missiles.ammo) + else if (self->missiles) { fireMissile(self); } diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 0e56e9b..5345592 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -73,7 +73,11 @@ void doBullets(void) b->x += b->dx; b->y += b->dy; - if (b->type == BT_MISSILE) + if (b->type == BT_ROCKET) + { + addMissileEngineEffect(b); + } + else if (b->type == BT_MISSILE) { addMissileEngineEffect(b); @@ -315,15 +319,24 @@ void fireGuns(Entity *owner) playBattleSound(b->sound, owner->x, owner->y); } +void fireRocket(Entity *owner) +{ + Bullet *b; + + b = createBullet(BT_ROCKET, owner->x, owner->y, owner); + + playBattleSound(b->sound, owner->x, owner->y); +} + void fireMissile(Entity *owner) { Bullet *b; - b = createBullet(BT_ROCKET + owner->missiles.type, owner->x, owner->y, owner); + b = createBullet(BT_MISSILE, owner->x, owner->y, owner); b->life = FPS * 30; - owner->missiles.ammo--; + owner->missiles--; if (owner == player) { diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 3a26f3a..e69f352 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -116,7 +116,7 @@ static void randomizeDart(Entity *dart) randomizeDartGuns(dart); - dart->missiles.ammo = rand() % 3; + dart->missiles = rand() % 3; sprintf(textureName, "gfx/fighters/dart0%d.png", 1 + rand() % 7); @@ -666,10 +666,7 @@ static void loadFighterDef(char *filename) if (cJSON_GetObjectItem(root, "missiles")) { - node = cJSON_GetObjectItem(root, "missiles"); - - f->missiles.type = lookup(cJSON_GetObjectItem(node, "type")->valuestring); - f->missiles.ammo = f->missiles.maxAmmo = cJSON_GetObjectItem(node, "ammo")->valueint; + f->missiles = cJSON_GetObjectItem(root, "missiles")->valueint; } if (cJSON_GetObjectItem(root, "flags")) diff --git a/src/battle/hud.c b/src/battle/hud.c index 4da7997..d5b4363 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -259,7 +259,7 @@ static void drawBoostECMBar(int current, int max, int x, int y, int r, int g, in static void drawWeaponInfo(void) { drawText(10, 70, 14, TA_LEFT, colors.white, (player->selectedGunType != -1) ? gunName[player->selectedGunType] : "(None)"); - drawText(260, 70, 14, TA_RIGHT, colors.white, "Missiles (%d)", player->missiles.ammo); + drawText(260, 70, 14, TA_RIGHT, colors.white, "Missiles (%d)", player->missiles); } static void drawPlayerTargeter(void) diff --git a/src/battle/player.c b/src/battle/player.c index 6c39657..b04e87c 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -113,7 +113,7 @@ void doPlayer(void) app.keyboard[SDL_SCANCODE_LSHIFT] = 0; } - if (app.keyboard[SDL_SCANCODE_RETURN] && player->missiles.ammo && player->target) + if (app.keyboard[SDL_SCANCODE_RETURN] && player->missiles && player->target) { if (getDistance(player->x, player->y, player->target->x, player->target->y) <= SCREEN_WIDTH) { diff --git a/src/defs.h b/src/defs.h index 5ae396a..fc0ab42 100644 --- a/src/defs.h +++ b/src/defs.h @@ -140,14 +140,6 @@ enum BT_MAX }; -enum -{ - MISSILE_ROCKET, - MISSILE_MISSILE, - MISSILE_FF, - MISSILE_MAX -}; - enum { EFFECT_LINE, diff --git a/src/structs.h b/src/structs.h index 5d3ab29..08ba010 100644 --- a/src/structs.h +++ b/src/structs.h @@ -106,7 +106,7 @@ struct Entity { int aiAggression; int separationRadius; Weapon guns[MAX_FIGHTER_GUNS]; - Weapon missiles; + int missiles; long flags; long aiFlags; SDL_Point targetLocation; diff --git a/src/system/lookup.c b/src/system/lookup.c index 5108163..c5b3bc9 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -90,10 +90,6 @@ void initLookups(void) addLookup("BF_SHIELD_DAMAGE", BF_SHIELD_DAMAGE); addLookup("BF_EXPLODES", BF_EXPLODES); - addLookup("MISSILE_ROCKET", MISSILE_ROCKET); - addLookup("MISSILE_MISSILE", MISSILE_MISSILE); - addLookup("MISSILE_FF", MISSILE_FF); - addLookup("CHALLENGE_ARMOUR", CHALLENGE_ARMOUR); addLookup("CHALLENGE_TIME", CHALLENGE_TIME); addLookup("CHALLENGE_ACCURACY", CHALLENGE_ACCURACY);