Some finetuning to the combat changes (better weapon selection)

This commit is contained in:
Enno Rehling 2002-10-04 21:37:35 +00:00
parent 38e3799362
commit e9c40d9495
3 changed files with 30 additions and 30 deletions

View File

@ -630,30 +630,38 @@ riding(const troop t) {
}
static weapon *
select_weapon(const troop t, boolean attacking, boolean missile)
/* select the primary weapon for this trooper */
preferred_weapon(const troop t, boolean attacking)
{
weapon * weapon = NULL;
weapon * missile = t.fighter->person[t.index].missile;
weapon * melee = t.fighter->person[t.index].melee;
if (attacking) {
if (!missile) {
/* try your best weapon if it's melee */
weapon = t.fighter->person[t.index].preferred;
} else {
/* from the back rows, use your missile weapon */
weapon = t.fighter->person[t.index].missile;
if (melee==NULL || (missile && missile->attackskill>melee->attackskill)) {
return missile;
}
} else {
if (!missile) {
/* have to use your melee weapon if it's melee */
weapon = t.fighter->person[t.index].melee;
} else {
/* from the back rows, use your best skill */
weapon = t.fighter->person[t.index].preferred;
if (melee==NULL || (missile && missile->defenseskill>melee->defenseskill)) {
return missile;
}
}
return weapon;
return melee;
}
static weapon *
select_weapon(const troop t, boolean attacking, boolean ismissile)
/* select the primary weapon for this trooper */
{
if (attacking) {
if (ismissile) {
/* from the back rows, have to use your missile weapon */
return t.fighter->person[t.index].missile;
}
} else {
if (!ismissile) {
/* have to use your melee weapon if it's melee */
return t.fighter->person[t.index].melee;
}
}
return preferred_weapon(t, attacking);
}
/* ------------------------------------------------------------- */
@ -1923,8 +1931,8 @@ attack(battle *b, troop ta, const att *a)
* konventionell weiter */
do_combatspell(ta, row);
} else {
weapon * wp = ta.fighter->person[ta.index].preferred;
if (row!=FIGHT_ROW) wp = ta.fighter->person[ta.index].missile;
weapon * wp = ta.fighter->person[ta.index].missile;
if (row==FIGHT_ROW) wp = preferred_weapon(ta, true);
/* Sonderbehandlungen */
if (getreload(ta)) {
@ -2877,7 +2885,6 @@ make_fighter(battle * b, unit * u, boolean attack)
if (weapon_weight(fig->weapons+owp[oi], false)<=wpless) {
continue; /* we fight better with bare hands */
}
fig->person[i].preferred = fig->person[i].melee = &fig->weapons[owp[oi]];
++fig->weapons[owp[oi]].used;
}
/* hand out missile weapons (from back to front, in case of mixed troops). */
@ -2890,11 +2897,6 @@ make_fighter(battle * b, unit * u, boolean attack)
fig->person[i].missile = &fig->weapons[dwp[di]];
++fig->weapons[dwp[di]].used;
}
if (fig->person[i].missile && (fig->person[i].melee==NULL ||
weapon_weight(fig->person[i].missile, true) >
weapon_weight(fig->person[i].melee, false))) {
fig->person[i].preferred = fig->person[i].missile;
}
}
}

View File

@ -157,7 +157,6 @@ typedef struct fighter {
int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss.
* dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */
int last_action : 8; /* In welcher Runde haben wir zuletzt etwas getan */
struct weapon * preferred; /* weapon with best skill */
struct weapon * missile; /* missile weapon */
struct weapon * melee; /* melee weapon */
} * person;

View File

@ -335,14 +335,12 @@ sp_combatrosthauch(fighter * fi, int level, int power, spell * sp)
i_change(&df->unit->items, wp->type->itype, -n);
for (p=0;n && p!=df->unit->number;++p) {
if (df->person[p].missile==wp) {
df->person[p].preferred = df->person[p].melee;
df->person[p].missile = NULL;
--n;
}
}
for (p=0;n && p!=df->unit->number;++p) {
if (df->person[p].melee==wp) {
df->person[p].preferred = df->person[p].missile;
df->person[p].melee = NULL;
--n;
}
@ -1286,7 +1284,8 @@ sp_windshield(fighter * fi, int level, int power, spell * sp)
break;
assert(!helping(fi->side, df->side));
if (df->person[dt.index].preferred && df->person[dt.index].preferred==df->person[dt.index].missile) {
if (df->person[dt.index].missile) {
/* this suxx... affects your melee weapon as well. */
df->person[dt.index].attack -= at_malus;
--force;
}