forked from github/server
refactor of rc_specialdamage, and move it into battle, nothing else uses it.
This commit is contained in:
parent
a28cbc647a
commit
ebd115b04a
37
src/battle.c
37
src/battle.c
|
@ -1042,6 +1042,41 @@ static int natural_armor(unit * du)
|
||||||
return an;
|
return an;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype)
|
||||||
|
{
|
||||||
|
const race *ar = u_race(au);
|
||||||
|
int m, modifier = 0;
|
||||||
|
|
||||||
|
switch (old_race(ar)) {
|
||||||
|
case RC_HALFLING:
|
||||||
|
if (wtype != NULL && dragonrace(u_race(du))) {
|
||||||
|
modifier += 5;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (wtype != NULL && wtype->modifiers != NULL) {
|
||||||
|
for (m = 0; wtype->modifiers[m].value; ++m) {
|
||||||
|
/* weapon damage for this weapon, possibly by race */
|
||||||
|
if (wtype->modifiers[m].flags & WMF_DAMAGE) {
|
||||||
|
race_list *rlist = wtype->modifiers[m].races;
|
||||||
|
if (rlist != NULL) {
|
||||||
|
while (rlist) {
|
||||||
|
if (rlist->data == ar)
|
||||||
|
break;
|
||||||
|
rlist = rlist->next;
|
||||||
|
}
|
||||||
|
if (rlist == NULL)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
modifier += wtype->modifiers[m].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
||||||
{
|
{
|
||||||
|
@ -1163,7 +1198,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
da += rc_specialdamage(u_race(au), u_race(du), awtype);
|
da += rc_specialdamage(au, du, awtype);
|
||||||
|
|
||||||
if (awtype != NULL && fval(awtype, WTF_MISSILE)) {
|
if (awtype != NULL && fval(awtype, WTF_MISSILE)) {
|
||||||
/* missile weapon bonus */
|
/* missile weapon bonus */
|
||||||
|
|
|
@ -280,42 +280,6 @@ const char *racename(const struct locale *loc, const unit * u, const race * rc)
|
||||||
return str ? str : rc->_name;
|
return str ? str : rc->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
rc_specialdamage(const race * ar, const race * dr,
|
|
||||||
const struct weapon_type *wtype)
|
|
||||||
{
|
|
||||||
race_t art = old_race(ar);
|
|
||||||
int m, modifier = 0;
|
|
||||||
|
|
||||||
if (wtype != NULL && wtype->modifiers != NULL)
|
|
||||||
for (m = 0; wtype->modifiers[m].value; ++m) {
|
|
||||||
/* weapon damage for this weapon, possibly by race */
|
|
||||||
if (wtype->modifiers[m].flags & WMF_DAMAGE) {
|
|
||||||
race_list *rlist = wtype->modifiers[m].races;
|
|
||||||
if (rlist != NULL) {
|
|
||||||
while (rlist) {
|
|
||||||
if (rlist->data == ar)
|
|
||||||
break;
|
|
||||||
rlist = rlist->next;
|
|
||||||
}
|
|
||||||
if (rlist == NULL)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
modifier += wtype->modifiers[m].value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (art) {
|
|
||||||
case RC_HALFLING:
|
|
||||||
if (wtype != NULL && dragonrace(dr)) {
|
|
||||||
modifier += 5;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return modifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_race_reference(const race * rc, struct storage *store)
|
void write_race_reference(const race * rc, struct storage *store)
|
||||||
{
|
{
|
||||||
WRITE_TOK(store, rc ? rc->_name : "none");
|
WRITE_TOK(store, rc ? rc->_name : "none");
|
||||||
|
|
|
@ -178,8 +178,6 @@ extern "C" {
|
||||||
|
|
||||||
extern race *rc_get_or_create(const char *name);
|
extern race *rc_get_or_create(const char *name);
|
||||||
extern const race *rc_find(const char *);
|
extern const race *rc_find(const char *);
|
||||||
extern int rc_specialdamage(const race *, const race *,
|
|
||||||
const struct weapon_type *);
|
|
||||||
void free_races(void);
|
void free_races(void);
|
||||||
|
|
||||||
typedef enum name_t { NAME_SINGULAR, NAME_PLURAL, NAME_DEFINITIVE, NAME_CATEGORY } name_t;
|
typedef enum name_t { NAME_SINGULAR, NAME_PLURAL, NAME_DEFINITIVE, NAME_CATEGORY } name_t;
|
||||||
|
|
Loading…
Reference in New Issue