eliminate old_race. make the catdragon act like a dragon.

This commit is contained in:
Enno Rehling 2016-09-19 18:42:14 +02:00
parent 043ff40d02
commit a7fbe4901b
5 changed files with 75 additions and 63 deletions

View File

@ -717,7 +717,7 @@
<attack type="4" damage="1d6"/>
<attack type="1" damage="1d5"/>
</race>
<race name="catdragon" magres="0.900000" maxaura="1.000000" regaura="1.000000" recruitcost="500000" weight="20000" capacity="10000" speed="1.000000" hp="20" damage="2d40" unarmedattack="0" unarmeddefense="0" defensemodifier="50" fly="yes" walk="yes" teach="no" shapeshift="yes" giveperson="yes" getitem="yes">
<race name="catdragon" magres="0.900000" maxaura="1.000000" regaura="1.000000" recruitcost="500000" weight="20000" capacity="10000" speed="1.000000" hp="20" damage="2d40" unarmedattack="0" unarmeddefense="0" defensemodifier="50" fly="yes" walk="yes" teach="no" shapeshift="yes" giveperson="yes" getitem="yes" dragon="yes">
<ai splitsize="1"/>
<attack type="4" damage="2d40"/>
<attack type="4" damage="2d40"/>

View File

@ -1037,17 +1037,18 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_
{
const race *ar = u_race(au);
int m, modifier = 0;
switch (old_race(ar)) {
case RC_HALFLING:
if (wtype != NULL && dragonrace(u_race(du))) {
if (wtype != NULL) {
if (fval(u_race(du), RCF_DRAGON)) {
static int cache;
static race *rc_halfling;
if (rc_changed(&cache)) {
rc_halfling = get_race(RC_HALFLING);
}
if (ar == rc_halfling) {
modifier += 5;
}
break;
default:
break;
}
if (wtype != NULL && wtype->modifiers != NULL) {
if (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) {
@ -1065,6 +1066,7 @@ static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_
}
}
}
}
return modifier;
}

View File

@ -114,6 +114,8 @@ static void recruit_init(void)
int income(const unit * u)
{
// TODO: make this a property, like race.income, no hard-coding of values
if (fval(u_race(u), RCF_DRAGON)) {
switch (old_race(u_race(u))) {
case RC_FIREDRAGON:
return 150 * u->number;
@ -122,9 +124,11 @@ int income(const unit * u)
case RC_WYRM:
return 5000 * u->number;
default:
return 20 * u->number;
break;
}
}
return 20 * u->number;
}
static void scramble(void *data, unsigned int n, size_t width)
{

View File

@ -67,28 +67,34 @@ void update_guards(void)
unsigned int guard_flags(const unit * u)
{
// TODO: this should be a property of the race, like race.guard_flags
static int rc_cache;
static race *rc_elf, *rc_ent, *rc_ironkeeper;
const race *rc = u_race(u);
unsigned int flags =
GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX;
// TODO: configuration, not define
#if GUARD_DISABLES_PRODUCTION == 1
flags |= GUARD_PRODUCE;
#endif
#if GUARD_DISABLES_RECRUIT == 1
flags |= GUARD_RECRUIT;
#endif
switch (old_race(u_race(u))) {
case RC_ELF:
if (u->faction->race != u_race(u))
break;
/* else fallthrough */
case RC_TREEMAN:
if (rc_changed(&rc_cache)) {
rc_elf = get_race(RC_ELF);
rc_ent = get_race(RC_TREEMAN);
rc_ironkeeper = get_race(RC_IRONKEEPER);
}
if (rc == rc_elf) {
if (u->faction->race == u_race(u)) {
flags |= GUARD_TREES;
break;
case RC_IRONKEEPER:
}
}
else if (rc == rc_ent) {
flags |= GUARD_TREES;
}
else if (rc == rc_ironkeeper) {
flags = GUARD_MINING;
break;
default:
/* TODO: This should be configuration variables, all of it */
break;
}
return flags;
}

View File

@ -244,7 +244,7 @@ extern "C" {
#define omniscient(f) ((f)->race==get_race(RC_ILLUSION) || (f)->race==get_race(RC_TEMPLATE))
#define playerrace(rc) (!fval((rc), RCF_NPC))
#define dragonrace(rc) ((rc) == get_race(RC_FIREDRAGON) || (rc) == get_race(RC_DRAGON) || (rc) == get_race(RC_WYRM) || (rc) == get_race(RC_BIRTHDAYDRAGON))
#define dragonrace(rc) (fval(rc, RCF_DRAGON))
#define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc))
#define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY))