Skip to content

Commit

Permalink
Clean up handling of SHOOT_IN_AIR and SHOOT_ON_GROUND with some fring…
Browse files Browse the repository at this point in the history
…e behaviour changes. These are bit values, not enums! Patch reviewed by SafetyOff.
  • Loading branch information
perim committed Oct 17, 2010
1 parent 1477265 commit 8a01df2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
8 changes: 0 additions & 8 deletions src/action.c
Expand Up @@ -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);

Expand Down
9 changes: 4 additions & 5 deletions src/projectile.c
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/scriptfuncs.c
Expand Up @@ -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
Expand Down

0 comments on commit 8a01df2

Please sign in to comment.