Merge branch 'develop' of github.com:ennorehling/eressea into develop

This commit is contained in:
Enno Rehling 2016-10-04 09:15:11 +02:00
commit 3338f00fcb
6 changed files with 115 additions and 70 deletions

View File

@ -1886,7 +1886,13 @@ int skilldiff(troop at, troop dt, int dist)
unit *au = af->unit, *du = df->unit; unit *au = af->unit, *du = df->unit;
int is_protected = 0, skdiff = 0; int is_protected = 0, skdiff = 0;
weapon *awp = select_weapon(at, true, dist > 1); weapon *awp = select_weapon(at, true, dist > 1);
static int rc_cache;
static const race *rc_halfling, *rc_goblin;
if (rc_changed(&rc_cache)) {
rc_halfling = get_race(RC_HALFLING);
rc_goblin = get_race(RC_GOBLIN);
}
skdiff += af->person[at.index].attack; skdiff += af->person[at.index].attack;
skdiff -= df->person[dt.index].defence; skdiff -= df->person[dt.index].defence;
@ -1894,11 +1900,10 @@ int skilldiff(troop at, troop dt, int dist)
skdiff += 2; skdiff += 2;
/* Effekte durch Rassen */ /* Effekte durch Rassen */
if (awp != NULL && u_race(au) == get_race(RC_HALFLING) && dragonrace(u_race(du))) { if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) {
skdiff += 5; skdiff += 5;
} }
else if (u_race(au) == rc_goblin) {
if (u_race(au) == get_race(RC_GOBLIN)) {
if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) {
skdiff += 1; skdiff += 1;
} }

View File

@ -125,7 +125,13 @@ static bool RemoveNMRNewbie(void)
static void age_unit(region * r, unit * u) static void age_unit(region * r, unit * u)
{ {
if (u_race(u) == get_race(RC_SPELL)) { static int rc_cache;
static const race *rc_spell;
if (rc_changed(&rc_cache)) {
rc_spell = get_race(RC_SPELL);
}
if (u_race(u) == rc_spell) {
if (--u->age <= 0) { if (--u->age <= 0) {
remove_unit(&r->units, u); remove_unit(&r->units, u);
} }

View File

@ -1031,9 +1031,8 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
double double
spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord) spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord)
{ {
curse *c;
double force = cast_level; double force = cast_level;
int elf_power; static int elf_power, config;
const struct resource_type *rtype; const struct resource_type *rtype;
if (sp == NULL) { if (sp == NULL) {
@ -1046,54 +1045,65 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
if (btype && btype->flags & BTF_MAGIC) ++force; if (btype && btype->flags & BTF_MAGIC) ++force;
} }
elf_power = config_get_int("rules.magic.elfpower", 0); if (config_changed(&config)) {
elf_power = config_get_int("rules.magic.elfpower", 0);
if (elf_power && u_race(u) == get_race(RC_ELF) && r_isforest(r)) { }
++force; if (elf_power) {
static int rc_cache;
static const race *rc_elf;
if (rc_changed(&rc_cache)) {
rc_elf = get_race(RC_ELF);
}
if (u_race(u) == rc_elf && r_isforest(r)) {
++force;
}
} }
rtype = rt_find("rop"); rtype = rt_find("rop");
if (rtype && i_get(u->items, rtype->itype) > 0) { if (rtype && i_get(u->items, rtype->itype) > 0) {
++force; ++force;
} }
/* Antimagie in der Zielregion */ if (r->attribs) {
c = get_curse(r->attribs, ct_find("antimagiczone")); curse *c;
if (curse_active(c)) {
unit *mage = c->magician; /* Antimagie in der Zielregion */
force -= curse_geteffect(c); c = get_curse(r->attribs, ct_find("antimagiczone"));
curse_changevigour(&r->attribs, c, -cast_level); if (curse_active(c)) {
cmistake(u, ord, 185, MSG_MAGIC); unit *mage = c->magician;
if (mage != NULL && mage->faction != NULL) { force -= curse_geteffect(c);
if (force > 0) { curse_changevigour(&r->attribs, c, -cast_level);
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell", cmistake(u, ord, 185, MSG_MAGIC);
"self mage region", mage, u, r)); if (mage != NULL && mage->faction != NULL) {
if (force > 0) {
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
"self mage region", mage, u, r));
}
else {
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
"self mage region", mage, u, r));
}
} }
else { }
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
"self mage region", mage, u, r)); /* Patzerfluch-Effekt: */
c = get_curse(r->attribs, ct_find("fumble"));
if (curse_active(c)) {
unit *mage = c->magician;
force -= curse_geteffect(c);
curse_changevigour(&u->attribs, c, -1);
cmistake(u, ord, 185, MSG_MAGIC);
if (mage != NULL && mage->faction != NULL) {
if (force > 0) {
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
"self mage region", mage, u, r));
}
else {
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
"self mage region", mage, u, r));
}
} }
} }
} }
/* Patzerfluch-Effekt: */
c = get_curse(r->attribs, ct_find("fumble"));
if (curse_active(c)) {
unit *mage = c->magician;
force -= curse_geteffect(c);
curse_changevigour(&u->attribs, c, -1);
cmistake(u, ord, 185, MSG_MAGIC);
if (mage != NULL && mage->faction != NULL) {
if (force > 0) {
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
"self mage region", mage, u, r));
}
else {
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
"self mage region", mage, u, r));
}
}
}
return _max(force, 0); return _max(force, 0);
} }
@ -2784,6 +2794,8 @@ void magic(void)
int rank; int rank;
castorder *co; castorder *co;
spellrank spellranks[MAX_SPELLRANK]; spellrank spellranks[MAX_SPELLRANK];
const race *rc_spell = get_race(RC_SPELL);
const race *rc_insect = get_race(RC_INSECT);
memset(spellranks, 0, sizeof(spellranks)); memset(spellranks, 0, sizeof(spellranks));
@ -2792,10 +2804,10 @@ void magic(void)
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
order *ord; order *ord;
if (u->number <= 0 || u_race(u) == get_race(RC_SPELL)) if (u->number <= 0 || u_race(u) == rc_spell)
continue; continue;
if (u_race(u) == get_race(RC_INSECT) && r_insectstalled(r) && if (u_race(u) == rc_insect && r_insectstalled(r) &&
!is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) !is_cursed(u->attribs, C_KAELTESCHUTZ, 0))
continue; continue;

View File

@ -269,21 +269,27 @@ static direction_t richest_neighbour(region * r, faction * f, int absolut)
static bool room_for_race_in_region(region * r, const race * rc) static bool room_for_race_in_region(region * r, const race * rc)
{ {
unit *u; if (rc->splitsize > 0) {
int c = 0; unit *u;
int c = 0;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u_race(u) == rc) if (u_race(u) == rc) {
c += u->number; c += u->number;
if (c > rc->splitsize * 2) {
return false;
}
}
}
} }
return true;
return (c <= (rc->splitsize * 2));
} }
static direction_t random_neighbour(region * r, unit * u) static direction_t random_neighbour(region * r, unit * u)
{ {
int i; int i;
region * next[MAXDIRECTIONS]; region *next[MAXDIRECTIONS], *backup[MAXDIRECTIONS];
region **pick;
int rr, c = 0, c2 = 0; int rr, c = 0, c2 = 0;
const race *rc = u_race(u); const race *rc = u_race(u);
@ -298,19 +304,22 @@ static direction_t random_neighbour(region * r, unit * u)
} else { } else {
next[i] = NULL; next[i] = NULL;
} }
backup[i] = rn;
c2++; c2++;
} else { } else {
next[i] = NULL; next[i] = NULL;
backup[i] = NULL;
} }
} }
pick = next;
if (c == 0) { if (c == 0) {
if (c2 == 0) { if (c2 == 0) {
return NODIRECTION; return NODIRECTION;
} }
else { else {
pick = backup;
c = c2; c = c2;
c2 = 0; /* c2 == 0 -> room_for_race nicht beachten */
} }
} }
@ -320,14 +329,14 @@ static direction_t random_neighbour(region * r, unit * u)
/* Durchzählen */ /* Durchzählen */
c = -1; c = 0;
for (i = 0; i != MAXDIRECTIONS; i++) { for (i = 0; i != MAXDIRECTIONS; i++) {
region *rn = next[i]; region *rn = pick[i];
if (rn) { if (rn) {
c++;
if (c == rr) { if (c == rr) {
return (direction_t)i; return (direction_t)i;
} }
c++;
} }
} }
@ -543,19 +552,21 @@ static order *monster_learn(unit * u)
return NULL; return NULL;
} }
static bool check_overpopulated(unit * u) static bool check_overpopulated(const unit * u)
{ {
unit *u2; const race *rc = u_race(u);
int c = 0; if (rc->splitsize > 0) {
unit *u2;
int c = 0;
for (u2 = u->region->units; u2; u2 = u2->next) { for (u2 = u->region->units; u2; u2 = u2->next) {
if (u_race(u2) == u_race(u) && u != u2) if (u != u2 && u_race(u2) == rc) {
c += u2->number; c += u2->number;
if (c > rc->splitsize * 2)
return true;
}
}
} }
if (c > u_race(u)->splitsize * 2)
return true;
return false; return false;
} }

View File

@ -731,11 +731,16 @@ static void orc_growth(void)
static void demon_skillchanges(void) static void demon_skillchanges(void)
{ {
region *r; region *r;
static const race *rc_demon;
static int rc_cache;
if (rc_changed(&rc_cache)) {
rc_demon = get_race(RC_DAEMON);
}
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit *u; unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u_race(u) == get_race(RC_DAEMON)) { if (u_race(u) == rc_demon) {
demon_skillchange(u); demon_skillchange(u);
} }
} }

View File

@ -546,6 +546,12 @@ int study_cmd(unit * u, order * ord)
int maxalchemy = 0; int maxalchemy = 0;
int speed_rule = (study_rule_t)config_get_int("study.speedup", 0); int speed_rule = (study_rule_t)config_get_int("study.speedup", 0);
bool learn_newskills = config_get_int("study.newskills", 1) != 0; bool learn_newskills = config_get_int("study.newskills", 1) != 0;
static const race *rc_snotling;
static int rc_cache;
if (rc_changed(&rc_cache)) {
rc_snotling = get_race(RC_SNOTLING);
}
if (!unit_can_study(u)) { if (!unit_can_study(u)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
@ -575,7 +581,7 @@ int study_cmd(unit * u, order * ord)
} }
/* snotlings koennen Talente nur bis T8 lernen */ /* snotlings koennen Talente nur bis T8 lernen */
if (u_race(u) == get_race(RC_SNOTLING)) { if (u_race(u) == rc_snotling) {
if (get_level(u, sk) >= 8) { if (get_level(u, sk) >= 8) {
cmistake(u, ord, 308, MSG_EVENT); cmistake(u, ord, 308, MSG_EVENT);
return 0; return 0;