From f2144b1053e5e8e7d3320c550d8363ab5dd9846b Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 24 Sep 2013 23:31:44 +0100 Subject: [PATCH] [Change] Fewer explosions with beam weapons. --- src/weapon.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/weapon.c b/src/weapon.c index 4f40c43..78d7635 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -297,13 +297,27 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) { case OUTFIT_TYPE_BOLT: case OUTFIT_TYPE_TURRET_BOLT: case OUTFIT_TYPE_MISSILE_DUMB_AMMO: /* Dumb missiles are like bolts. */ - case OUTFIT_TYPE_BEAM: /* Timer usage is actually more complicated for beams.. */ + wlayer[i]->timer -= dt; + if(wlayer[i]->timer < 0.) { + weapon_destroy(wlayer[i], layer); + continue; + } + break; + /* Beam weapons handled apart. */ + case OUTFIT_TYPE_BEAM: case OUTFIT_TYPE_TURRET_BEAM: wlayer[i]->timer -= dt; if(wlayer[i]->timer < 0.) { weapon_destroy(wlayer[i],layer); continue; } + wlayer[i]->lockon -= dt; + if(wlayer[i]->lockon < 0.) { + if(wlayer[i]->lockon < -1.) + wlayer[i]->lockon = 0.100; + else + wlayer[i]->lockon = -1.; + } break; default: WARN("Weapon of type '%s' has no update implemented yet!", @@ -499,12 +513,14 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer, } ai_attacked(p, w->parent); } - spfx_add(outfit_spfx(w->outfit), pos[0].x, pos[0].y, - VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK); - spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y, - VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK); - - } else { + if(w->lockon == -1.) { /* Code to signal create explosions. */ + spfx_add(outfit_spfx(w->outfit), pos[0].x, pos[0].y, + VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK); + spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y, + VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK); + } + } + else if(w->lockon == -1.) { spfx_add(outfit_spfx(w->outfit), pos[0].x, pos[0].y, VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT); spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y, @@ -538,9 +554,7 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* /* Bolts treated together. */ case OUTFIT_TYPE_BOLT: case OUTFIT_TYPE_TURRET_BOLT: - /* Only difference is the direction of fire. */ - if((outfit->type == OUTFIT_TYPE_TURRET_BOLT) && (w->parent != w->target) && - (w->target != 0)) { /* Must have a valid target. */ + if((outfit->type == OUTFIT_TYPE_TURRET_BEAM) && (w->parent != w->target)) { pilot_target = pilot_get(w->target); /* Get the distance. */