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="4" damage="1d6"/>
<attack type="1" damage="1d5"/> <attack type="1" damage="1d5"/>
</race> </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"/> <ai splitsize="1"/>
<attack type="4" damage="2d40"/> <attack type="4" damage="2d40"/>
<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); const race *ar = u_race(au);
int m, modifier = 0; int m, modifier = 0;
if (wtype != NULL) {
switch (old_race(ar)) { if (fval(u_race(du), RCF_DRAGON)) {
case RC_HALFLING: static int cache;
if (wtype != NULL && dragonrace(u_race(du))) { static race *rc_halfling;
if (rc_changed(&cache)) {
rc_halfling = get_race(RC_HALFLING);
}
if (ar == rc_halfling) {
modifier += 5; modifier += 5;
} }
break;
default:
break;
} }
if (wtype != NULL && wtype->modifiers != NULL) { if (wtype->modifiers != NULL) {
for (m = 0; wtype->modifiers[m].value; ++m) { for (m = 0; wtype->modifiers[m].value; ++m) {
/* weapon damage for this weapon, possibly by race */ /* weapon damage for this weapon, possibly by race */
if (wtype->modifiers[m].flags & WMF_DAMAGE) { 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; return modifier;
} }

View File

@ -114,6 +114,8 @@ static void recruit_init(void)
int income(const unit * u) 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))) { switch (old_race(u_race(u))) {
case RC_FIREDRAGON: case RC_FIREDRAGON:
return 150 * u->number; return 150 * u->number;
@ -122,9 +124,11 @@ int income(const unit * u)
case RC_WYRM: case RC_WYRM:
return 5000 * u->number; return 5000 * u->number;
default: default:
return 20 * u->number; break;
} }
} }
return 20 * u->number;
}
static void scramble(void *data, unsigned int n, size_t width) 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) 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 = unsigned int flags =
GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX;
// TODO: configuration, not define
#if GUARD_DISABLES_PRODUCTION == 1 #if GUARD_DISABLES_PRODUCTION == 1
flags |= GUARD_PRODUCE; flags |= GUARD_PRODUCE;
#endif #endif
#if GUARD_DISABLES_RECRUIT == 1 #if GUARD_DISABLES_RECRUIT == 1
flags |= GUARD_RECRUIT; flags |= GUARD_RECRUIT;
#endif #endif
switch (old_race(u_race(u))) { if (rc_changed(&rc_cache)) {
case RC_ELF: rc_elf = get_race(RC_ELF);
if (u->faction->race != u_race(u)) rc_ent = get_race(RC_TREEMAN);
break; rc_ironkeeper = get_race(RC_IRONKEEPER);
/* else fallthrough */ }
case RC_TREEMAN: if (rc == rc_elf) {
if (u->faction->race == u_race(u)) {
flags |= GUARD_TREES; flags |= GUARD_TREES;
break; }
case RC_IRONKEEPER: }
else if (rc == rc_ent) {
flags |= GUARD_TREES;
}
else if (rc == rc_ironkeeper) {
flags = GUARD_MINING; flags = GUARD_MINING;
break;
default:
/* TODO: This should be configuration variables, all of it */
break;
} }
return flags; 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 omniscient(f) ((f)->race==get_race(RC_ILLUSION) || (f)->race==get_race(RC_TEMPLATE))
#define playerrace(rc) (!fval((rc), RCF_NPC)) #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 humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==get_race(RC_DRACOID) || playerrace(rc))
#define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY)) #define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY))