Permalink
Browse files

Revert to the simpler sensor range model.

  • Loading branch information...
1 parent 2e69fd0 commit a45d2ffe772c6e2e95d213cb090e108970ea36c7 @Deiz Deiz committed Feb 27, 2012
Showing with 17 additions and 23 deletions.
  1. +2 −0 src/pilot.h
  2. +14 −21 src/pilot_ew.c
  3. +0 −1 src/pilot_ew.h
  4. +1 −1 src/pilot_outfit.c
View
@@ -305,6 +305,8 @@ typedef struct Pilot_ {
double ew_mass; /**< Mass factor. */
double ew_heat; /**< Heat factor, affects hide. */
double ew_hide; /**< Static hide factor. */
+ double ew_movement; /**< Movement factor. */
+ double ew_evasion; /**< Dynamic evasion factor. */
double ew_detect; /**< Static detection factor. */
double ew_jumpDetect; /** Static jump detection factor */
View
@@ -35,7 +35,7 @@ void pilot_ewUpdateStatic( Pilot *p )
{
p->ew_mass = pilot_ewMass( p->solid->mass );
p->ew_heat = pilot_ewHeat( p->heat_T );
- p->ew_hide = pow2(p->ew_base_hide * p->ew_mass * p->ew_heat);
+ p->ew_hide = p->ew_base_hide * p->ew_mass * p->ew_heat;
}
@@ -49,6 +49,10 @@ void pilot_ewUpdateDynamic( Pilot *p )
/* Update hide. */
p->ew_heat = pilot_ewHeat( p->heat_T );
p->ew_hide = p->ew_base_hide * p->ew_mass * p->ew_heat;
+
+ /* Update evasion. */
+ p->ew_movement = pilot_ewMovement( VMOD(p->solid->vel) );
+ p->ew_evasion = p->ew_hide * p->ew_movement * EVASION_SCALE;
}
@@ -60,19 +64,9 @@ void pilot_ewUpdateDynamic( Pilot *p )
*/
double pilot_ewMovement( double vmod )
{
- return 1. + vmod / 1000.;
+ return 1. + vmod / 100.;
}
-/**
- * @brief Gets the electronic warfare evasion modifier for a given pilot.
- *
- * @param target The pilot doing the evading.
- * @return The electronic warfare evasion modifier.
- */
-double pilot_ewEvasion( const Pilot *target )
-{
- return (target->ew_hide * EVASION_SCALE);
-}
/**
* @brief Gets the electronic warfare heat modifier for a given temperature.
@@ -156,7 +150,7 @@ int pilot_inRange( const Pilot *p, double x, double y )
*/
int pilot_inRangePilot( const Pilot *p, const Pilot *target )
{
- double d, sense, ewMovement;
+ double d, sense;
/* Special case player or omni-visible. */
if ((pilot_isPlayer(p) && pilot_isFlag(target, PILOT_VISPLAYER)) ||
@@ -167,10 +161,9 @@ int pilot_inRangePilot( const Pilot *p, const Pilot *target )
d = vect_dist2( &p->solid->pos, &target->solid->pos );
sense = sensor_curRange * p->ew_detect;
- ewMovement = pilot_ewMovement( vect_dist( &p->solid->vel, &target->solid->vel ));
- if (d * pilot_ewEvasion( target ) * ewMovement < sense)
+ if (d * target->ew_evasion < sense)
return 1;
- else if (d * target->ew_hide < sense * ewMovement)
+ else if (d * target->ew_hide < sense)
return -1;
return 0;
@@ -201,7 +194,8 @@ int pilot_inRangePlanet( const Pilot *p, int target )
if ( !pnt->real )
return 0;
- sense = sensor_curRange * p->ew_detect;
+ /* @TODO ew_detect should be squared upon being set. */
+ sense = sensor_curRange * pow2(p->ew_detect);
/* Get distance. */
d = vect_dist2( &p->solid->pos, &pnt->pos );
@@ -259,14 +253,13 @@ int pilot_inRangeJump( const Pilot *p, int i )
*/
double pilot_ewWeaponTrack( const Pilot *p, const Pilot *t, double track )
{
- double limit, lead, evade;
+ double limit, lead;
limit = track * p->ew_detect;
- evade = pilot_ewEvasion( t ) * pilot_ewMovement( vect_dist( &p->solid->vel, &t->solid->vel ));
- if ( evade < limit )
+ if (t->ew_evasion < limit)
lead = 1.;
else
- lead = MAX( 0., 1. - 0.5*(evade/limit - 1.));
+ lead = MAX( 0., 1. - 0.5*(t->ew_evasion/limit - 1.));
return lead;
}
View
@@ -36,7 +36,6 @@ void pilot_ewUpdateDynamic( Pilot *p );
* Individual electronic warfare properties.
*/
double pilot_ewMovement( double vmod );
-double pilot_ewEvasion( const Pilot *target );
double pilot_ewHeat( double T );
double pilot_ewMass( double mass );
View
@@ -864,7 +864,7 @@ void pilot_calcStats( Pilot* pilot )
s->ew_detect = 1. + (s->ew_detect-1.) * exp( -0.2 * (double)(MAX(amount.ew_detect-1,0)) );
s->ew_jumpDetect = 1. + (s->ew_jumpDetect-1.) * exp( -0.2 * (double)(MAX(amount.ew_jumpDetect-1,0)) );
pilot->ew_base_hide = s->ew_hide;
- pilot->ew_detect = pow2(s->ew_detect);
+ pilot->ew_detect = s->ew_detect;
pilot->ew_jumpDetect = pow2(s->ew_jumpDetect);
/*

0 comments on commit a45d2ff

Please sign in to comment.