Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: submarines
Home

[Freeciv-Dev] Re: submarines

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: submarines
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 10 Sep 2002 21:50:58 +0000 (GMT)

On Tue, 10 Sep 2002, Christian Knoke wrote:
> And I was quite sure that the firepower wouldn't affect the
> defense ...
>
> Hhm. Looking into some nested *_defense_*() in combat.c ...
> .............................
>
> Looks like that the source is with me! Yeah!

???

void get_modified_firepower(struct unit *attacker, struct unit *defender,
                            int *att_fp, int *def_fp)
{
  *att_fp = unit_type(attacker)->firepower;
  *def_fp = unit_type(defender)->firepower;

  /* pearl harbour - defender's firepower is reduced to one,
   *                 attacker's is multiplied by two         */
  if (is_sailing_unit(defender) && map_get_city(defender->x, defender->y)) {
    *att_fp *= 2;
    *def_fp = 1;
  }

  /*
   * When attacked by fighters, helicopters have their firepower
   * reduced to 1.
   */
  if (is_heli_unit(defender) && unit_flag(attacker, F_FIGHTER)) {
    *def_fp = 1;
  }

  /* In land bombardment both units have their firepower reduced to 1 */
  if (is_sailing_unit(attacker)
      && map_get_terrain(defender->x, defender->y) != T_OCEAN
      && is_ground_unit(defender)) {
    *att_fp = 1;
    *def_fp = 1;
  }
}
...
double unit_win_chance(struct unit *attacker, struct unit *defender)
{
  int def_power = get_total_defense_power(attacker, defender);
  int att_power = get_total_attack_power(attacker, defender);

  double chance;

  int def_fp, att_fp;
  get_modified_firepower(attacker, defender, &att_fp, &def_fp);

  chance = win_chance(att_power, attacker->hp, att_fp,
                      def_power, defender->hp, def_fp);

  return chance;
}

No way.

Yours
Per

"I don't see why people are so upset about cloning sheep. American
television networks have been doing that to their audiences for years."
-- Jello Biafra



[Prev in Thread] Current Thread [Next in Thread]