diff --git a/src/ai.c b/src/ai.c index 4cd2e05..14de13a 100644 --- a/src/ai.c +++ b/src/ai.c @@ -1298,6 +1298,7 @@ static int ai_aim(lua_State* L) { Vec2 tv; double dist, diff; double mod; + double speed; LLUA_MIN_ARGS(1); /* Only acceptable parameter is pilot id. */ @@ -1316,8 +1317,16 @@ static int ai_aim(lua_State* L) { /* Get the distance. */ dist = vect_dist(&cur_pilot->solid->pos, &p->solid->pos); + /* Check if we should recalculate weapon speed with secondary weapon. */ + if((cur_pilot->secondary != NULL) && + outfit_isBolt(cur_pilot->secondary->outfit) && + (cur_pilot->secondary->outfit->type == OUTFIT_TYPE_MISSILE_DUMB)) { + speed = cur_pilot->weap_speed + outfit_speed(cur_pilot->secondary->outfit); + speed /= 2.; + } + /* Time for shots to reach distance. */ - t = dist / cur_pilot->weap_speed; + t = dist / speed; /* Position is calculated on where it should be. */ x = p->solid->pos.x + p->solid->vel.x*t @@ -1369,7 +1378,8 @@ static int ai_settarget(lua_State* L) { */ static int outfit_isMelee(Pilot* p, PilotOutfit* o) { (void)p; - if(outfit_isBolt(o->outfit) || outfit_isBeam(o->outfit)) + if(outfit_isBolt(o->outfit) || outfit_isBeam(o->outfit) || + (o->outfit->type == OUTFIT_TYPE_MISSILE_DUMB)) return 1; return 0; } @@ -1380,7 +1390,9 @@ static int outfit_isMelee(Pilot* p, PilotOutfit* o) { * @param o Outfit to check. */ static int outfit_isRanged(Pilot* p, PilotOutfit* o) { - if(outfit_isFighterBay(o->outfit) || outfit_isLauncher(o->outfit)) { + if(outfit_isFighterBay(o->outfit) || + (outfit_isLauncher(o->outfit) && + (o->outfit->type != OUTFIT_TYPE_MISSILE_DUMB))) { /* Must have ammo. */ if(pilot_getAmmo(p, o->outfit) <= 0) return 0;