forked from github/server
simplify race masking for weapon modifiers.
This commit is contained in:
parent
4812fa1c41
commit
3cb1d1a071
9 changed files with 22 additions and 67 deletions
|
@ -11,9 +11,7 @@
|
|||
<damage type="rider" value="2d6+4"/>
|
||||
<damage type="footman" value="2d6+4"/>
|
||||
<modifier type="missile_target" value="2"/>
|
||||
<modifier type="damage" value="1">
|
||||
<race name="elf"/>
|
||||
</modifier>
|
||||
<modifier type="damage" value="1" races="elf"/>
|
||||
</weapon>
|
||||
</item>
|
||||
</resource>
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
<damage type="rider" value="1d11+2"/>
|
||||
<damage type="footman" value="1d11+2"/>
|
||||
<modifier type="missile_target" value="2"/>
|
||||
<modifier type="damage" value="1">
|
||||
<race name="elf"/>
|
||||
</modifier>
|
||||
<modifier type="damage" value="1" races="elf"/>
|
||||
</weapon>
|
||||
</item>
|
||||
</resource>
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
<construction skill="armorer" minskill="4">
|
||||
<requirement type="iron" quantity="1"/>
|
||||
</construction>
|
||||
<armor ac="0" penalty="-0.15" projectile="0.25" magres="0.0" shield="yes">
|
||||
<modifier type="canuse" function="mod_dwarves_only"/>
|
||||
</armor>
|
||||
<armor ac="0" penalty="-0.15" projectile="0.25" magres="0.0" shield="yes"/>
|
||||
</item>
|
||||
</resource>
|
||||
<resource name="shield">
|
||||
|
|
|
@ -136,9 +136,7 @@
|
|||
<damage type="rider" value="2d4+5"/>
|
||||
<damage type="footman" value="2d4+5"/>
|
||||
<modifier type="missile_target" value="2"/>
|
||||
<modifier type="damage" value="1">
|
||||
<race name="elf"/>
|
||||
</modifier>
|
||||
<modifier type="damage" value="1" races="elf"/>
|
||||
</weapon>
|
||||
</item>
|
||||
</resource>
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
<damage type="footman" value="3d8+8"/>
|
||||
<modifier type="missile_target" value="2"/>
|
||||
<modifier type="skill" value="-90"/>
|
||||
<modifier type="skill" value="100">
|
||||
<race name="snowman"/>
|
||||
</modifier>
|
||||
<modifier type="skill" value="100" races="snowman"/>
|
||||
</weapon>
|
||||
</item>
|
||||
</resource>
|
||||
|
|
30
src/battle.c
30
src/battle.c
|
@ -723,6 +723,7 @@ bool missile)
|
|||
}
|
||||
if (wtype->modifiers != NULL) {
|
||||
/* Pferdebonus, Lanzenbonus, usw. */
|
||||
const race *rc = u_race(tu);
|
||||
int m;
|
||||
unsigned int flags =
|
||||
WMF_SKILL | (attacking ? WMF_OFFENSIVE : WMF_DEFENSIVE);
|
||||
|
@ -738,17 +739,10 @@ bool missile)
|
|||
|
||||
for (m = 0; wtype->modifiers[m].value; ++m) {
|
||||
if ((wtype->modifiers[m].flags & flags) == flags) {
|
||||
race_list *rlist = wtype->modifiers[m].races;
|
||||
if (rlist != NULL) {
|
||||
while (rlist) {
|
||||
if (rlist->data == u_race(tu))
|
||||
break;
|
||||
rlist = rlist->next;
|
||||
}
|
||||
if (rlist == NULL)
|
||||
continue;
|
||||
int mask = wtype->modifiers[m].race_mask;
|
||||
if ((mask == 0) || (mask & rc->mask_item)) {
|
||||
skill += wtype->modifiers[m].value;
|
||||
}
|
||||
skill += wtype->modifiers[m].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1029,17 +1023,10 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_
|
|||
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;
|
||||
int mask = wtype->modifiers[m].race_mask;
|
||||
if ((mask == 0) || (mask & ar->mask_item)) {
|
||||
modifier += wtype->modifiers[m].value;
|
||||
}
|
||||
modifier += wtype->modifiers[m].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3272,8 +3259,9 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
|||
adata->atype = itm->type->rtype->atype;
|
||||
adata->count = itm->number;
|
||||
for (aptr = &fig->armors; *aptr; aptr = &(*aptr)->next) {
|
||||
if (adata->atype->prot > (*aptr)->atype->prot)
|
||||
if (adata->atype->prot > (*aptr)->atype->prot) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
adata->next = *aptr;
|
||||
*aptr = adata;
|
||||
|
|
|
@ -609,16 +609,6 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value)
|
|||
return -118;
|
||||
}
|
||||
|
||||
static int
|
||||
mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value)
|
||||
{
|
||||
UNUSED_ARG(r);
|
||||
if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->ec_flags & ECF_IRONGOLEM)) {
|
||||
return value;
|
||||
}
|
||||
return -118;
|
||||
}
|
||||
|
||||
void
|
||||
register_item_give(int(*foo) (struct unit *, struct unit *,
|
||||
const struct item_type *, int, struct order *), const char *name)
|
||||
|
@ -973,7 +963,6 @@ void register_resources(void)
|
|||
registered = true;
|
||||
|
||||
register_function((pf_generic)mod_elves_only, "mod_elves_only");
|
||||
register_function((pf_generic)mod_dwarves_only, "mod_dwarves_only");
|
||||
register_function((pf_generic)res_changeitem, "changeitem");
|
||||
register_function((pf_generic)res_changeperson, "changeperson");
|
||||
register_function((pf_generic)res_changepeasants, "changepeasants");
|
||||
|
|
|
@ -147,8 +147,8 @@ extern "C" {
|
|||
struct race_list;
|
||||
typedef struct weapon_mod {
|
||||
int value;
|
||||
unsigned int flags;
|
||||
struct race_list *races;
|
||||
int flags;
|
||||
int race_mask;
|
||||
} weapon_mod;
|
||||
|
||||
#define ATF_NONE 0x00
|
||||
|
|
|
@ -520,6 +520,8 @@ static armor_type *xml_readarmor(xmlXPathContextPtr xpath, item_type * itype)
|
|||
return atype;
|
||||
}
|
||||
|
||||
static void mask_races(xmlNodePtr node, const char *key, int *maskp);
|
||||
|
||||
static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
||||
{
|
||||
xmlNodePtr node = xpath->node;
|
||||
|
@ -591,8 +593,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
|||
wtype->modifiers = calloc(result->nodesetval->nodeNr + 1, sizeof(weapon_mod));
|
||||
for (k = 0; k != result->nodesetval->nodeNr; ++k) {
|
||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||
xmlXPathObjectPtr races;
|
||||
int r, flags = 0;
|
||||
int flags = 0;
|
||||
|
||||
if (xml_bvalue(node, "walking", false))
|
||||
flags |= WMF_WALKING;
|
||||
|
@ -619,21 +620,8 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
|||
wtype->modifiers[k].flags = flags;
|
||||
wtype->modifiers[k].value = xml_ivalue(node, "value", 0);
|
||||
|
||||
xpath->node = node;
|
||||
races = xmlXPathEvalExpression(BAD_CAST "race", xpath);
|
||||
for (r = 0; r != races->nodesetval->nodeNr; ++r) {
|
||||
xmlNodePtr node = races->nodesetval->nodeTab[r];
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
if (propValue != NULL) {
|
||||
const race *rc = rc_find((const char *)propValue);
|
||||
if (rc == NULL)
|
||||
rc = rc_get_or_create((const char *)propValue);
|
||||
racelist_insert(&wtype->modifiers[k].races, rc);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(races);
|
||||
mask_races(node, "races", &wtype->modifiers[k].race_mask);
|
||||
wtype->modifiers[k].race_mask = 0;
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
|
||||
|
@ -1311,7 +1299,7 @@ static void parse_ai(race * rc, xmlNodePtr node)
|
|||
rc->flags |= RCF_ATTACK_MOVED;
|
||||
}
|
||||
|
||||
static void set_study_speed(race *rc, skill_t sk, int modifier){
|
||||
static void set_study_speed(race *rc, skill_t sk, int modifier) {
|
||||
if (!rc->study_speed)
|
||||
rc->study_speed = calloc(1, MAXSKILLS);
|
||||
rc->study_speed[sk] = (char)modifier;
|
||||
|
|
Loading…
Reference in a new issue