Fixed the experimental fighter not running away from chargers.

This oddity was caused by exactly what I thought it was caused by:
the code assumed that all bullets are created equal, and each bullet
had a 1 in 50 chance of causing the ship to run away. Well, the
charger inflicts so much damage that 50 shots would be a ridiculous
amount of damage for even the experimental fighter.

So now, except in Classic difficulty, whether or not it runs away
is determined partly by how much damage a weapon inflicts.
Specifically, the chance is now the damage of the bullet out of 150.

High-damage weapons are still a useful idea; after all, a 100 damage
weapon is 100 guaranteed damage, even if the fighter is likely to flee.
However, it gets rid of the skewed nature of the fleeing behavior and
prevents the charger from subverting the purpose of the behavior.
This commit is contained in:
onpon4 2016-01-09 08:01:23 -05:00
parent efb7a135be
commit fa43f2aabe
1 changed files with 5 additions and 1 deletions

View File

@ -1772,6 +1772,8 @@ void alien_destroy(object *alien, object *attacker)
void alien_hurt(object *alien, object *attacker, int damage, bool ion)
{
double run_chance;
if (ion)
alien->systemPower -= damage;
else
@ -1828,7 +1830,9 @@ void alien_hurt(object *alien, object *attacker, int damage, bool ion)
}
}
if ((alien->flags & FL_RUNSAWAY) && ((rand() % 50) == 0))
run_chance = (game.difficulty == DIFFICULTY_ORIGINAL) ? 0.2 : damage / 150.;
if ((alien->flags & FL_RUNSAWAY) && CHANCE(run_chance))
{
alien->flags |= FL_LEAVESECTOR;
}