Clean up handling of SHOOT_IN_AIR and SHOOT_ON_GROUND with some fringe behaviour changes. These are bit values, not enums! Patch reviewed by SafetyOff.

master
Per Inge Mathisen 2010-10-17 23:30:58 +02:00
parent 1477265908
commit 8a01df2f1a
3 changed files with 5 additions and 15 deletions

View File

@ -434,14 +434,6 @@ BOOL actionTargetTurret(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, WEAPON *
pitchRate = gameTimeAdjustedIncrement(pitchRate);
pitchRate = MAX(pitchRate, DEG(1));
/* if ( (psAttacker->type == OBJ_STRUCTURE) &&
(((STRUCTURE *)psAttacker)->pStructureType->type == REF_DEFENSE) &&
(asWeaponStats[((STRUCTURE *)psAttacker)->asWeaps[0].nStat].surfaceToAir == SHOOT_IN_AIR) )
{
rotRate = DEG(180);
pitchRate = DEG(180);
}*/
//and point the turret at target
targetRotation = calcDirection(psAttacker->pos.x, psAttacker->pos.y, psTarget->pos.x, psTarget->pos.y);

View File

@ -858,7 +858,7 @@ static void proj_InFlightFunc(PROJECTILE *psProj, bool bIndirect)
continue;
}
if (psStats->surfaceToAir == SHOOT_IN_AIR &&
if (!(psStats->surfaceToAir & SHOOT_ON_GROUND) &&
(psTempObj->type == OBJ_STRUCTURE ||
psTempObj->type == OBJ_FEATURE ||
(psTempObj->type == OBJ_DROID && !isFlying((DROID *)psTempObj))
@ -1227,9 +1227,8 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
bool bTargetInAir = (asPropulsionTypes[asPropulsionStats[psCurrD->asBits[COMP_PROPULSION].nStat].propulsionType].travel == AIR && ((DROID *)psCurrD)->sMove.Status != MOVEINACTIVE);
// Check whether we can hit it and it is in hit radius
if (!((psStats->surfaceToAir == SHOOT_IN_AIR && !bTargetInAir) ||
(psStats->surfaceToAir == SHOOT_ON_GROUND && bTargetInAir)) &&
Vector3i_InSphere(psCurrD->pos, psObj->pos, psStats->radius))
if ((((psStats->surfaceToAir & SHOOT_IN_AIR) && bTargetInAir) || ((psStats->surfaceToAir & SHOOT_ON_GROUND) && !bTargetInAir))
&& Vector3i_InSphere(psCurrD->pos, psObj->pos, psStats->radius))
{
int dice = gameRand(100);
if (dice < weaponRadiusHit(psStats, psObj->player))
@ -1264,7 +1263,7 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
}
// FIXME Check whether we hit above maximum structure height, to skip unnecessary calculations!
if (psStats->surfaceToAir != SHOOT_IN_AIR)
if (psStats->surfaceToAir & SHOOT_ON_GROUND)
{
STRUCTURE *psCurrS, *psNextS;

View File

@ -9392,8 +9392,7 @@ BOOL scrNumAAinRange(void)
{
if(psStruct->visible[lookingPlayer]) //if can see it
{
if(objHasWeapon((BASE_OBJECT *) psStruct) &&
(asWeaponStats[psStruct->asWeaps[0].nStat].surfaceToAir == SHOOT_IN_AIR) )
if (objHasWeapon((BASE_OBJECT *) psStruct) && (asWeaponStats[psStruct->asWeaps[0].nStat].surfaceToAir & SHOOT_IN_AIR))
{
if (range < 0
|| world_coord(hypotf(tx - map_coord(psStruct->pos.x), ty - map_coord(psStruct->pos.y))) < range) //enemy in range