forked from github/server
rostregen bugfix commit ruined indentation
This commit is contained in:
parent
206a3007a7
commit
d9febc30d8
438
src/battle.c
438
src/battle.c
|
@ -1177,9 +1177,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
*defskill = weapon_effskill(dt, at, weapon, false, false);
|
||||
if (weapon != NULL)
|
||||
*dwtype = weapon->type;
|
||||
}
|
||||
}
|
||||
|
||||
static void calculate_attack_type(troop at, troop dt, int type, bool missile,
|
||||
static void calculate_attack_type(troop at, troop dt, int type, bool missile,
|
||||
const weapon_type **awtype, int *attskill, bool *magic) {
|
||||
const weapon *weapon;
|
||||
|
||||
|
@ -1202,9 +1202,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int crit_damage(int attskill, int defskill, const char *damage_formula) {
|
||||
static int crit_damage(int attskill, int defskill, const char *damage_formula) {
|
||||
int damage = 0;
|
||||
if (rule_damage & DAMAGE_CRITICAL) {
|
||||
double kritchance = ((double)attskill * 3.0 - (double)defskill) / 200.0;
|
||||
|
@ -1218,9 +1218,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
static int apply_race_resistance(int reduced_damage, fighter *df,
|
||||
static int apply_race_resistance(int reduced_damage, fighter *df,
|
||||
const weapon_type *awtype, bool magic) {
|
||||
unit *du = df->unit;
|
||||
|
||||
|
@ -1240,9 +1240,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
reduced_damage /= 2;
|
||||
}
|
||||
return reduced_damage;
|
||||
}
|
||||
}
|
||||
|
||||
static int apply_magicshield(int reduced_damage, fighter *df,
|
||||
static int apply_magicshield(int reduced_damage, fighter *df,
|
||||
const weapon_type *awtype, battle *b, bool magic) {
|
||||
side *ds = df->side;
|
||||
selist *ql;
|
||||
|
@ -1273,11 +1273,11 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
|
||||
return reduced_damage;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
terminate(troop dt, troop at, int type, const char *damage_formula, bool missile)
|
||||
{
|
||||
bool
|
||||
terminate(troop dt, troop at, int type, const char *damage_formula, bool missile)
|
||||
{
|
||||
fighter *df = dt.fighter;
|
||||
fighter *af = at.fighter;
|
||||
unit *au = af->unit;
|
||||
|
@ -1361,11 +1361,11 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
kill_troop(dt);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
count_side(const side * s, const side * vs, int minrow, int maxrow, int select)
|
||||
{
|
||||
static int
|
||||
count_side(const side * s, const side * vs, int minrow, int maxrow, int select)
|
||||
{
|
||||
fighter *fig;
|
||||
int people = 0;
|
||||
int unitrow[NUMROWS];
|
||||
|
@ -1393,14 +1393,14 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return people;
|
||||
}
|
||||
}
|
||||
|
||||
/* return the number of live allies warning: this function only considers
|
||||
/* return the number of live allies warning: this function only considers
|
||||
* troops that are still alive, not those that are still fighting although
|
||||
* dead. */
|
||||
int
|
||||
count_allies(const side * as, int minrow, int maxrow, int select, int allytype)
|
||||
{
|
||||
int
|
||||
count_allies(const side * as, int minrow, int maxrow, int select, int allytype)
|
||||
{
|
||||
battle *b = as->battle;
|
||||
side *ds;
|
||||
int count = 0;
|
||||
|
@ -1414,12 +1414,12 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow,
|
||||
static int
|
||||
count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow,
|
||||
int select)
|
||||
{
|
||||
{
|
||||
side *es, *as = af->side;
|
||||
int i = 0;
|
||||
|
||||
|
@ -1435,12 +1435,12 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
count_enemies(battle * b, const fighter * af, int minrow, int maxrow,
|
||||
int select)
|
||||
{
|
||||
{
|
||||
int sr = statusrow(af->status);
|
||||
side *as = af->side;
|
||||
|
||||
|
@ -1469,10 +1469,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
troop select_enemy(fighter * af, int minrow, int maxrow, int select)
|
||||
{
|
||||
troop select_enemy(fighter * af, int minrow, int maxrow, int select)
|
||||
{
|
||||
side *as = af->side;
|
||||
battle *b = as->battle;
|
||||
int si, selected;
|
||||
|
@ -1552,10 +1552,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
assert(!selected);
|
||||
return no_troop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static int get_tactics(const side * as, const side * ds)
|
||||
{
|
||||
static int get_tactics(const side * as, const side * ds)
|
||||
{
|
||||
battle *b = as->battle;
|
||||
side *stac;
|
||||
int result = 0;
|
||||
|
@ -1574,9 +1574,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return result - defense;
|
||||
}
|
||||
}
|
||||
|
||||
double tactics_chance(const unit *u, int skilldiff) {
|
||||
double tactics_chance(const unit *u, int skilldiff) {
|
||||
double tacch = 0.1 * skilldiff;
|
||||
if (fval(u->region->terrain, SEA_REGION)) {
|
||||
const ship *sh = u->ship;
|
||||
|
@ -1585,10 +1585,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return tacch;
|
||||
}
|
||||
}
|
||||
|
||||
static troop select_opponent(battle * b, troop at, int mindist, int maxdist)
|
||||
{
|
||||
static troop select_opponent(battle * b, troop at, int mindist, int maxdist)
|
||||
{
|
||||
fighter *af = at.fighter;
|
||||
troop dt;
|
||||
|
||||
|
@ -1620,10 +1620,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata)
|
||||
{
|
||||
selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata)
|
||||
{
|
||||
side *s;
|
||||
selist *fightervp = 0;
|
||||
|
||||
|
@ -1652,42 +1652,42 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
|
||||
return fightervp;
|
||||
}
|
||||
}
|
||||
|
||||
struct selector {
|
||||
struct selector {
|
||||
int minrow;
|
||||
int maxrow;
|
||||
};
|
||||
};
|
||||
|
||||
static bool select_row(const side *vs, const fighter *fig, void *cbdata)
|
||||
{
|
||||
static bool select_row(const side *vs, const fighter *fig, void *cbdata)
|
||||
{
|
||||
struct selector *sel = (struct selector *)cbdata;
|
||||
int row = get_unitrow(fig, vs);
|
||||
return (row >= sel->minrow && row <= sel->maxrow);
|
||||
}
|
||||
}
|
||||
|
||||
selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask)
|
||||
{
|
||||
selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask)
|
||||
{
|
||||
struct selector sel;
|
||||
sel.maxrow = maxrow;
|
||||
sel.minrow = minrow;
|
||||
return select_fighters(b, vs, mask, select_row, &sel);
|
||||
}
|
||||
}
|
||||
|
||||
static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp)
|
||||
{
|
||||
static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp)
|
||||
{
|
||||
message *m = msg_message("spell_failed", "unit spell", mage, sp);
|
||||
message_all(b, m);
|
||||
msg_release(m);
|
||||
}
|
||||
}
|
||||
|
||||
static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) {
|
||||
static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) {
|
||||
co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0);
|
||||
co->magician.fig = fig;
|
||||
return co;
|
||||
}
|
||||
}
|
||||
|
||||
static void summon_igjarjuk(battle *b, spellrank spellranks[]) {
|
||||
static void summon_igjarjuk(battle *b, spellrank spellranks[]) {
|
||||
side *s;
|
||||
castorder *co;
|
||||
|
||||
|
@ -1723,10 +1723,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_combatmagic(battle * b, combatmagic_t was)
|
||||
{
|
||||
void do_combatmagic(battle * b, combatmagic_t was)
|
||||
{
|
||||
side *s;
|
||||
castorder *co;
|
||||
region *r = b->region;
|
||||
|
@ -1817,10 +1817,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
for (rank = 0; rank < MAX_SPELLRANK; rank++) {
|
||||
free_castorders(spellranks[rank].begin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int cast_combatspell(troop at, const spell * sp, int level, double force)
|
||||
{
|
||||
static int cast_combatspell(troop at, const spell * sp, int level, double force)
|
||||
{
|
||||
castorder co;
|
||||
|
||||
create_castorder_combat(&co, at.fighter, sp, level, force);
|
||||
|
@ -1830,10 +1830,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
pay_spell(at.fighter->unit, NULL, sp, level, 1);
|
||||
}
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
static void do_combatspell(troop at)
|
||||
{
|
||||
static void do_combatspell(troop at)
|
||||
{
|
||||
const spell *sp;
|
||||
fighter *fi = at.fighter;
|
||||
unit *mage = fi->unit;
|
||||
|
@ -1896,15 +1896,15 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
|
||||
level = cast_combatspell(at, sp, level, power);
|
||||
}
|
||||
}
|
||||
|
||||
/* Sonderattacken: Monster patzern nicht und zahlen auch keine
|
||||
/* Sonderattacken: Monster patzern nicht und zahlen auch keine
|
||||
* Spruchkosten. Da die Spruchstaerke direkt durch den Level bestimmt
|
||||
* wird, wirkt auch keine Antimagie (wird sonst in spellpower
|
||||
* gemacht) */
|
||||
|
||||
static void do_extra_spell(troop at, const att * a)
|
||||
{
|
||||
static void do_extra_spell(troop at, const att * a)
|
||||
{
|
||||
const spell *sp = spellref_get(a->data.sp);
|
||||
|
||||
if (!sp) {
|
||||
|
@ -1914,10 +1914,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
assert(a->level > 0);
|
||||
cast_combatspell(at, sp, a->level, a->level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int skilldiff(troop at, troop dt, int dist)
|
||||
{
|
||||
int skilldiff(troop at, troop dt, int dist)
|
||||
{
|
||||
fighter *af = at.fighter, *df = dt.fighter;
|
||||
unit *au = af->unit, *du = df->unit;
|
||||
int is_protected = 0, skdiff = 0;
|
||||
|
@ -1990,24 +1990,24 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
skdiff -= weapon_effskill(dt, at, dwp, false, dist > 1);
|
||||
}
|
||||
return skdiff;
|
||||
}
|
||||
}
|
||||
|
||||
static int setreload(troop at)
|
||||
{
|
||||
static int setreload(troop at)
|
||||
{
|
||||
fighter *af = at.fighter;
|
||||
const weapon_type *wtype = af->person[at.index].missile->type;
|
||||
if (wtype->reload == 0)
|
||||
return 0;
|
||||
return af->person[at.index].reload = wtype->reload;
|
||||
}
|
||||
}
|
||||
|
||||
int getreload(troop at)
|
||||
{
|
||||
int getreload(troop at)
|
||||
{
|
||||
return at.fighter->person[at.index].reload;
|
||||
}
|
||||
}
|
||||
|
||||
int hits(troop at, troop dt, weapon * awp)
|
||||
{
|
||||
int hits(troop at, troop dt, weapon * awp)
|
||||
{
|
||||
fighter *af = at.fighter, *df = dt.fighter;
|
||||
const armor_type *armor, *shield = 0;
|
||||
int skdiff = 0;
|
||||
|
@ -2048,10 +2048,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void dazzle(battle * b, troop * td)
|
||||
{
|
||||
void dazzle(battle * b, troop * td)
|
||||
{
|
||||
UNUSED_ARG(b);
|
||||
/* Nicht kumulativ ! */
|
||||
if (td->fighter->person[td->index].flags & (FL_COURAGE | FL_DAZZLED)) {
|
||||
|
@ -2060,10 +2060,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
|
||||
td->fighter->person[td->index].flags |= FL_DAZZLED;
|
||||
td->fighter->person[td->index].defense--;
|
||||
}
|
||||
}
|
||||
|
||||
void damage_building(battle * b, building * bldg, int damage_abs)
|
||||
{
|
||||
void damage_building(battle * b, building * bldg, int damage_abs)
|
||||
{
|
||||
assert(bldg);
|
||||
bldg->size -= damage_abs;
|
||||
if (bldg->size < 1) bldg->size = 1;
|
||||
|
@ -2090,15 +2090,15 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int attacks_per_round(troop t)
|
||||
{
|
||||
static int attacks_per_round(troop t)
|
||||
{
|
||||
return t.fighter->person[t.index].speed;
|
||||
}
|
||||
}
|
||||
|
||||
static void make_heroes(battle * b)
|
||||
{
|
||||
static void make_heroes(battle * b)
|
||||
{
|
||||
side *s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fig;
|
||||
|
@ -2115,10 +2115,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void attack(battle * b, troop ta, const att * a, int numattack)
|
||||
{
|
||||
static void attack(battle * b, troop ta, const att * a, int numattack)
|
||||
{
|
||||
fighter *af = ta.fighter;
|
||||
troop td;
|
||||
unit *au = af->unit;
|
||||
|
@ -2271,10 +2271,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_attack(fighter * af)
|
||||
{
|
||||
void do_attack(fighter * af)
|
||||
{
|
||||
troop ta;
|
||||
unit *au = af->unit;
|
||||
side *side = af->side;
|
||||
|
@ -2325,10 +2325,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
msg_release(m);
|
||||
af->catmsg = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void add_tactics(tactics * ta, fighter * fig, int value)
|
||||
{
|
||||
static void add_tactics(tactics * ta, fighter * fig, int value)
|
||||
{
|
||||
if (value == 0 || value < ta->value)
|
||||
return;
|
||||
if (value > ta->value) {
|
||||
|
@ -2338,10 +2338,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
selist_push(&ta->fighters, fig);
|
||||
selist_push(&fig->side->battle->leaders, fig);
|
||||
ta->value = value;
|
||||
}
|
||||
}
|
||||
|
||||
static int horse_fleeing_bonus(const unit * u)
|
||||
{
|
||||
static int horse_fleeing_bonus(const unit * u)
|
||||
{
|
||||
const item_type *it_horse, *it_elvenhorse, *it_charger;
|
||||
int n1 = 0, n2 = 0, n3 = 0;
|
||||
item *itm;
|
||||
|
@ -2369,10 +2369,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
if (n1 + n2 + n3 >= u->number)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int fleechance(unit * u)
|
||||
{
|
||||
static int fleechance(unit * u)
|
||||
{
|
||||
int p = flee_chance_base; /* Fluchtwahrscheinlichkeit in % */
|
||||
/* Einheit u versucht, dem Getuemmel zu entkommen */
|
||||
|
||||
|
@ -2386,14 +2386,14 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
/** add a new army to the conflict.
|
||||
/** add a new army to the conflict.
|
||||
* beware: armies need to be added _at the beginning_ of the list because
|
||||
* otherwise join_allies() will get into trouble */
|
||||
side *make_side(battle * b, const faction * f, const group * g,
|
||||
side *make_side(battle * b, const faction * f, const group * g,
|
||||
unsigned int flags, const faction * stealthfaction)
|
||||
{
|
||||
{
|
||||
side *s1 = b->sides + b->nsides;
|
||||
bfaction *bf;
|
||||
|
||||
|
@ -2432,10 +2432,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
assert(bf);
|
||||
return s1;
|
||||
}
|
||||
}
|
||||
|
||||
troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
|
||||
{
|
||||
troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
|
||||
{
|
||||
side *as = af->side;
|
||||
battle *b = as->battle;
|
||||
side *ds;
|
||||
|
@ -2467,11 +2467,11 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
assert(!"we should never have gotten here");
|
||||
return no_troop;
|
||||
}
|
||||
}
|
||||
|
||||
static int loot_quota(const unit * src, const unit * dst,
|
||||
static int loot_quota(const unit * src, const unit * dst,
|
||||
const item_type * type, int n)
|
||||
{
|
||||
{
|
||||
UNUSED_ARG(type);
|
||||
if (dst && src && src->faction != dst->faction) {
|
||||
double divisor = config_get_flt("rules.items.loot_divisor", 1);
|
||||
|
@ -2488,10 +2488,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
static void loot_items(fighter * corpse)
|
||||
{
|
||||
static void loot_items(fighter * corpse)
|
||||
{
|
||||
unit *u = corpse->unit;
|
||||
item *itm = u->items;
|
||||
battle *b = corpse->side->battle;
|
||||
|
@ -2565,24 +2565,24 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
itm = itm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool seematrix(const faction * f, const side * s)
|
||||
{
|
||||
bool seematrix(const faction * f, const side * s)
|
||||
{
|
||||
if (f == s->faction)
|
||||
return true;
|
||||
if (s->flags & SIDE_STEALTH)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static double PopulationDamage(void)
|
||||
{
|
||||
static double PopulationDamage(void)
|
||||
{
|
||||
return rule_population_damage / 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
static void battle_effects(battle * b, int dead_players)
|
||||
{
|
||||
static void battle_effects(battle * b, int dead_players)
|
||||
{
|
||||
region *r = b->region;
|
||||
int rp = rpeasants(r);
|
||||
|
||||
|
@ -2596,10 +2596,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
rsetpeasants(r, rp - dead_peasants);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void reorder_fleeing(region * r)
|
||||
{
|
||||
static void reorder_fleeing(region * r)
|
||||
{
|
||||
unit **usrc = &r->units;
|
||||
unit **udst = &r->units;
|
||||
unit *ufirst = NULL;
|
||||
|
@ -2622,10 +2622,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
*udst = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void aftermath(battle * b)
|
||||
{
|
||||
static void aftermath(battle * b)
|
||||
{
|
||||
region *r = b->region;
|
||||
side *s;
|
||||
int dead_players = 0;
|
||||
|
@ -2860,10 +2860,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
|
||||
reorder_fleeing(r);
|
||||
}
|
||||
}
|
||||
|
||||
static void battle_punit(unit * u, battle * b)
|
||||
{
|
||||
static void battle_punit(unit * u, battle * b)
|
||||
{
|
||||
bfaction *bf;
|
||||
|
||||
for (bf = b->factions; bf; bf = bf->next) {
|
||||
|
@ -2877,10 +2877,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
if (S)
|
||||
freestrlist(S);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void print_fighters(battle * b, const side * s)
|
||||
{
|
||||
static void print_fighters(battle * b, const side * s)
|
||||
{
|
||||
fighter *df;
|
||||
int row;
|
||||
|
||||
|
@ -2902,20 +2902,20 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
if (m != NULL)
|
||||
msg_release(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_attacker(const fighter * fig)
|
||||
{
|
||||
bool is_attacker(const fighter * fig)
|
||||
{
|
||||
return fval(fig, FIG_ATTACKER) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_attacker(fighter * fig)
|
||||
{
|
||||
static void set_attacker(fighter * fig)
|
||||
{
|
||||
fset(fig, FIG_ATTACKER);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_stats(battle * b)
|
||||
{
|
||||
static void print_stats(battle * b)
|
||||
{
|
||||
side *s2;
|
||||
side *s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
|
@ -3036,18 +3036,18 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int weapon_weight(const weapon * w, bool missile)
|
||||
{
|
||||
static int weapon_weight(const weapon * w, bool missile)
|
||||
{
|
||||
if (missile == !!(fval(w->type, WTF_MISSILE))) {
|
||||
return w->attackskill + w->defenseskill;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
side * get_side(battle * b, const struct unit * u)
|
||||
{
|
||||
side * get_side(battle * b, const struct unit * u)
|
||||
{
|
||||
side * s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
if (s->faction == u->faction) {
|
||||
|
@ -3060,10 +3060,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction)
|
||||
{
|
||||
side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction)
|
||||
{
|
||||
side * s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
if (s->faction == f && s->group == g) {
|
||||
|
@ -3078,10 +3078,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
||||
{
|
||||
fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
||||
{
|
||||
#define WMAX 20
|
||||
weapon weapons[WMAX];
|
||||
region *r = b->region;
|
||||
|
@ -3370,10 +3370,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
add_tactics(&fig->side->leader, fig, tactics);
|
||||
++b->nfighters;
|
||||
return fig;
|
||||
}
|
||||
}
|
||||
|
||||
int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
|
||||
{
|
||||
int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
|
||||
{
|
||||
side *s;
|
||||
fighter *fc = NULL;
|
||||
|
||||
|
@ -3397,10 +3397,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
*cp = fc;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
battle *make_battle(region * r)
|
||||
{
|
||||
battle *make_battle(region * r)
|
||||
{
|
||||
unit *u;
|
||||
bfaction *bf;
|
||||
building * bld;
|
||||
|
@ -3439,15 +3439,15 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
freset(f, FFL_MARK);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
static void free_side(side * si)
|
||||
{
|
||||
static void free_side(side * si)
|
||||
{
|
||||
selist_free(si->leader.fighters);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_fighter(fighter * fig)
|
||||
{
|
||||
static void free_fighter(fighter * fig)
|
||||
{
|
||||
armor **ap = &fig->armors;
|
||||
while (*ap) {
|
||||
armor *a = *ap;
|
||||
|
@ -3460,9 +3460,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
free(fig->person);
|
||||
free(fig->weapons);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void battle_free(battle * b) {
|
||||
static void battle_free(battle * b) {
|
||||
side *s;
|
||||
|
||||
assert(b);
|
||||
|
@ -3479,10 +3479,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
free_side(s);
|
||||
}
|
||||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
void free_battle(battle * b)
|
||||
{
|
||||
void free_battle(battle * b)
|
||||
{
|
||||
while (b->factions) {
|
||||
bfaction *bf = b->factions;
|
||||
b->factions = bf->next;
|
||||
|
@ -3494,15 +3494,15 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
selist_free(b->meffects);
|
||||
|
||||
battle_free(b);
|
||||
}
|
||||
}
|
||||
|
||||
static int *get_alive(side * s)
|
||||
{
|
||||
static int *get_alive(side * s)
|
||||
{
|
||||
return s->size;
|
||||
}
|
||||
}
|
||||
|
||||
static int battle_report(battle * b)
|
||||
{
|
||||
static int battle_report(battle * b)
|
||||
{
|
||||
side *s, *s2;
|
||||
bool cont = false;
|
||||
bfaction *bf;
|
||||
|
@ -3577,10 +3577,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
fbattlerecord(b, fac, buf);
|
||||
}
|
||||
return cont;
|
||||
}
|
||||
}
|
||||
|
||||
static void join_allies(battle * b)
|
||||
{
|
||||
static void join_allies(battle * b)
|
||||
{
|
||||
region *r = b->region;
|
||||
unit *u;
|
||||
side *s, *s_end = b->sides + b->nsides;
|
||||
|
@ -3673,10 +3673,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void flee(const troop dt)
|
||||
{
|
||||
static void flee(const troop dt)
|
||||
{
|
||||
fighter *fig = dt.fighter;
|
||||
unit *u = fig->unit;
|
||||
int fchance = fleechance(u);
|
||||
|
@ -3694,9 +3694,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
setguard(u, false);
|
||||
kill_troop(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_calmed(const unit *u, const faction *f) {
|
||||
static bool is_calmed(const unit *u, const faction *f) {
|
||||
attrib *a = a_find(u->attribs, &at_curse);
|
||||
|
||||
while (a && a->type == &at_curse) {
|
||||
|
@ -3709,10 +3709,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
a = a->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool start_battle(region * r, battle ** bp)
|
||||
{
|
||||
static bool start_battle(region * r, battle ** bp)
|
||||
{
|
||||
battle *b = NULL;
|
||||
unit *u;
|
||||
bool fighting = false;
|
||||
|
@ -3861,14 +3861,14 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
*bp = b;
|
||||
return fighting;
|
||||
}
|
||||
}
|
||||
|
||||
/** execute one round of attacks
|
||||
/** execute one round of attacks
|
||||
* fig->fighting is used to determine who attacks, not fig->alive, since
|
||||
* the latter may be influenced by attacks that already took place.
|
||||
*/
|
||||
static void battle_attacks(battle * b)
|
||||
{
|
||||
static void battle_attacks(battle * b)
|
||||
{
|
||||
side *s;
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
|
@ -3887,14 +3887,14 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** updates the number of attacking troops in each fighter struct.
|
||||
/** updates the number of attacking troops in each fighter struct.
|
||||
* this has to be calculated _before_ the actual attacks take
|
||||
* place because otherwise dead troops would not strike in the
|
||||
* round they die. */
|
||||
static void battle_update(battle * b)
|
||||
{
|
||||
static void battle_update(battle * b)
|
||||
{
|
||||
side *s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fig;
|
||||
|
@ -3902,13 +3902,13 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
fig->fighting = fig->alive - fig->removed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** attempt to flee from battle before the next round begins
|
||||
/** attempt to flee from battle before the next round begins
|
||||
* there's a double attempt before the first round, but only
|
||||
* one attempt before round zero, the potential tactics round. */
|
||||
static void battle_flee(battle * b)
|
||||
{
|
||||
static void battle_flee(battle * b)
|
||||
{
|
||||
int attempt, flee_ops = 1;
|
||||
|
||||
if (b->turn == 1)
|
||||
|
@ -3966,9 +3966,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_enemy(battle *b, unit *u1, unit *u2) {
|
||||
static bool is_enemy(battle *b, unit *u1, unit *u2) {
|
||||
if (u1->faction != u2->faction) {
|
||||
if (b) {
|
||||
side *es, *s1 = 0, *s2 = 0;
|
||||
|
@ -3985,9 +3985,9 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void force_leave(region *r, battle *b) {
|
||||
void force_leave(region *r, battle *b) {
|
||||
unit *u;
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
|
@ -4012,10 +4012,10 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
leave(u, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void do_battle(region * r) {
|
||||
static void do_battle(region * r) {
|
||||
battle *b = NULL;
|
||||
bool fighting;
|
||||
ship *sh;
|
||||
|
@ -4076,12 +4076,12 @@ static void calculate_defense_type(troop at, troop dt, int type, bool missile,
|
|||
* Hilfsstrukturen * wieder loeschen: */
|
||||
|
||||
free_battle(b);
|
||||
}
|
||||
}
|
||||
|
||||
void do_battles(void) {
|
||||
void do_battles(void) {
|
||||
region *r;
|
||||
init_rules();
|
||||
for (r = regions; r; r = r->next) {
|
||||
do_battle(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue