change effskill signature to take a region, change eff_skill to work on a skill * to avoid multiple lookups.

This commit is contained in:
Enno Rehling 2015-08-27 16:16:55 +02:00
parent 6889cb0c80
commit de808bf146
24 changed files with 199 additions and 184 deletions

View File

@ -52,7 +52,7 @@ void herbsearch(unit * u, int max)
region * r = u->region; region * r = u->region;
int herbsfound; int herbsfound;
const item_type *whichherb; const item_type *whichherb;
int effsk = effskill(u, SK_HERBALISM); int effsk = effskill(u, SK_HERBALISM, 0);
if (effsk == 0) { if (effsk == 0) {
cmistake(u, u->thisorder, 59, MSG_PRODUCE); cmistake(u, u->thisorder, 59, MSG_PRODUCE);

View File

@ -5,6 +5,7 @@
#include <util/attrib.h> #include <util/attrib.h>
#include <attributes/stealth.h> #include <attributes/stealth.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
attrib_type at_stealth = { attrib_type at_stealth = {
@ -49,9 +50,10 @@ int eff_stealth(const unit * u, const region * r)
{ {
int e = 0; int e = 0;
assert(u->region == r); // TODO: param r is useless
/* Auf Schiffen keine Tarnung! */ /* Auf Schiffen keine Tarnung! */
if (!u->ship && skill_enabled(SK_STEALTH)) { if (!u->ship && skill_enabled(SK_STEALTH)) {
e = eff_skill(u, SK_STEALTH, r); e = effskill(u, SK_STEALTH, r);
if (u->flags & UFL_STEALTH) { if (u->flags & UFL_STEALTH) {
int es = u_geteffstealth(u); int es = u_geteffstealth(u);

View File

@ -504,7 +504,7 @@ const armor_type * sh)
if (tohit < 0.5) if (tohit < 0.5)
tohit = 0.5; tohit = 0.5;
if (chance(tohit)) { if (chance(tohit)) {
int defense = effskill(dt.fighter->unit, SK_STAMINA); int defense = effskill(dt.fighter->unit, SK_STAMINA, dt.fighter->unit->region);
double tosave = defense * 0.05; double tosave = defense * 0.05;
return !chance(tosave); return !chance(tosave);
} }
@ -586,12 +586,12 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
int skill; int skill;
if (wtype == NULL) { if (wtype == NULL) {
skill = effskill(u, SK_WEAPONLESS); skill = effskill(u, SK_WEAPONLESS, 0);
if (skill <= 0) { if (skill <= 0) {
/* wenn kein waffenloser kampf, dann den rassen-defaultwert */ /* wenn kein waffenloser kampf, dann den rassen-defaultwert */
if (u_race(u) == get_race(RC_ORC)) { if (u_race(u) == get_race(RC_ORC)) {
int sword = effskill(u, SK_MELEE); int sword = effskill(u, SK_MELEE, 0);
int spear = effskill(u, SK_SPEAR); int spear = effskill(u, SK_SPEAR, 0);
skill = _max(sword, spear) - 3; skill = _max(sword, spear) - 3;
if (attacking) { if (attacking) {
skill = _max(skill, u_race(u)->at_default); skill = _max(skill, u_race(u)->at_default);
@ -636,7 +636,7 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
/* changed: if we own a weapon, we have at least a skill of 0 */ /* changed: if we own a weapon, we have at least a skill of 0 */
if (!i_canuse(u, wtype->itype)) if (!i_canuse(u, wtype->itype))
return -1; return -1;
skill = effskill(u, wtype->skill); skill = effskill(u, wtype->skill, 0);
if (skill < wtype->minskill) if (skill < wtype->minskill)
skill = 0; skill = 0;
if (skill > 0) { if (skill > 0) {
@ -683,7 +683,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
} }
else { else {
/* new rule, chargers in Eressea 1.1 */ /* new rule, chargers in Eressea 1.1 */
int skl = effskill(u, SK_RIDING); int skl = effskill(u, SK_RIDING, 0);
/* only half against trolls */ /* only half against trolls */
if (skl > 0) { if (skl > 0) {
if (type == BONUS_DAMAGE) { if (type == BONUS_DAMAGE) {
@ -1031,7 +1031,7 @@ static int natural_armor(unit * du)
bonus[u_race(du)->index] = -1; bonus[u_race(du)->index] = -1;
} }
if (bonus[u_race(du)->index] > 0) { if (bonus[u_race(du)->index] > 0) {
int sk = effskill(du, SK_STAMINA); int sk = effskill(du, SK_STAMINA, 0);
sk /= bonus[u_race(du)->index]; sk /= bonus[u_race(du)->index];
an += sk; an += sk;
} }
@ -1686,7 +1686,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
if (fig->alive <= 0) if (fig->alive <= 0)
continue; /* fighter kann im Kampf getötet worden sein */ continue; /* fighter kann im Kampf getötet worden sein */
level = eff_skill(mage, SK_MAGIC, r); level = effskill(mage, SK_MAGIC, r);
if (level > 0) { if (level > 0) {
double power; double power;
const spell *sp; const spell *sp;
@ -2330,7 +2330,7 @@ void do_regenerate(fighter * af)
while (ta.index--) { while (ta.index--) {
struct person *p = af->person + ta.index; struct person *p = af->person + ta.index;
p->hp += effskill(au, SK_STAMINA); p->hp += effskill(au, SK_STAMINA, 0);
p->hp = _min(unit_max_hp(au), p->hp); p->hp = _min(unit_max_hp(au), p->hp);
} }
} }
@ -2353,7 +2353,7 @@ static double horsebonus(const unit * u)
const item_type *it_horse, *it_elvenhorse, *it_charger; const item_type *it_horse, *it_elvenhorse, *it_charger;
int n1 = 0, n2 = 0, n3 = 0; int n1 = 0, n2 = 0, n3 = 0;
item *itm; item *itm;
int skl = eff_skill(u, SK_RIDING, u->region); int skl = effskill(u, SK_RIDING, 0);
const resource_type *rtype; const resource_type *rtype;
if (skl < 1) return 0.0; if (skl < 1) return 0.0;
@ -2384,11 +2384,10 @@ static double horsebonus(const unit * u)
double fleechance(unit * u) double fleechance(unit * u)
{ {
double c = 0.20; /* Fluchtwahrscheinlichkeit in % */ double c = 0.20; /* Fluchtwahrscheinlichkeit in % */
region *r = u->region;
attrib *a = a_find(u->attribs, &at_fleechance); attrib *a = a_find(u->attribs, &at_fleechance);
/* Einheit u versucht, dem Getümmel zu entkommen */ /* Einheit u versucht, dem Getümmel zu entkommen */
c += (eff_skill(u, SK_STEALTH, r) * 0.05); c += (effskill(u, SK_STEALTH, 0) * 0.05);
c += horsebonus(u); c += horsebonus(u);
if (u_race(u) == get_race(RC_HALFLING)) { if (u_race(u) == get_race(RC_HALFLING)) {
@ -3188,7 +3187,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
region *r = b->region; region *r = b->region;
item *itm; item *itm;
fighter *fig = NULL; fighter *fig = NULL;
int h, i, tactics = eff_skill(u, SK_TACTICS, r); int h, i, tactics = effskill(u, SK_TACTICS, 0);
int berserk; int berserk;
int strongmen; int strongmen;
int speeded = 0, speed = 1; int speeded = 0, speed = 1;
@ -3432,17 +3431,17 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
* keine addierten boni. */ * keine addierten boni. */
/* Zuerst mal die Spezialbehandlung gewisser Sonderfälle. */ /* Zuerst mal die Spezialbehandlung gewisser Sonderfälle. */
fig->magic = eff_skill(u, SK_MAGIC, r); fig->magic = effskill(u, SK_MAGIC, 0);
if (fig->horses) { if (fig->horses) {
if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r)
|| eff_skill(u, SK_RIDING, r) < CavalrySkill() || effskill(u, SK_RIDING, 0) < CavalrySkill()
|| u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE)) || u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE))
fig->horses = 0; fig->horses = 0;
} }
if (fig->elvenhorses) { if (fig->elvenhorses) {
if (eff_skill(u, SK_RIDING, r) < 5 || u_race(u) == get_race(RC_TROLL) if (effskill(u, SK_RIDING, 0) < 5 || u_race(u) == get_race(RC_TROLL)
|| fval(u, UFL_WERE)) || fval(u, UFL_WERE))
fig->elvenhorses = 0; fig->elvenhorses = 0;
} }

View File

@ -425,7 +425,7 @@ static int tolua_unit_effskill(lua_State * L)
unit *self = (unit *)tolua_tousertype(L, 1, 0); unit *self = (unit *)tolua_tousertype(L, 1, 0);
const char *skname = tolua_tostring(L, 2, 0); const char *skname = tolua_tostring(L, 2, 0);
skill_t sk = findskill(skname); skill_t sk = findskill(skname);
int value = (sk == NOSKILL) ? -1 : eff_skill(self, sk, self->region); int value = (sk == NOSKILL) ? -1 : effskill(self, sk, 0);
lua_pushinteger(L, value); lua_pushinteger(L, value);
return 1; return 1;
} }

View File

@ -832,7 +832,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
prefix))); prefix)));
} }
if (u->faction != f && a_fshidden if (u->faction != f && a_fshidden
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) { && a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH, 0) >= 6) {
stream_printf(out, "-1;Anzahl\n"); stream_printf(out, "-1;Anzahl\n");
} }
else { else {
@ -942,14 +942,13 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
pr = 0; pr = 0;
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
if (sv->level > 0) { if (sv->level > 0) {
skill_t sk = sv->id; int esk = eff_skill(u, sv, r);
int esk = eff_skill(u, sk, r);
if (!pr) { if (!pr) {
pr = 1; pr = 1;
stream_printf(out, "TALENTE\n"); stream_printf(out, "TALENTE\n");
} }
stream_printf(out, "%d %d;%s\n", u->number * level_days(sv->level), esk, stream_printf(out, "%d %d;%s\n", u->number * level_days(sv->level), esk,
translate(mkname("skill", skillnames[sk]), skillname(sk, translate(mkname("skill", skillnames[sv->id]), skillname(sv->id,
f->locale))); f->locale)));
} }
} }
@ -957,7 +956,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
/* spells that this unit can cast */ /* spells that this unit can cast */
mage = get_mage(u); mage = get_mage(u);
if (mage) { if (mage) {
int i, maxlevel = effskill(u, SK_MAGIC); int i, maxlevel = effskill(u, SK_MAGIC, 0);
cr_output_spells(out, u, maxlevel); cr_output_spells(out, u, maxlevel);
for (i = 0; i != MAXCOMBATSPELLS; ++i) { for (i = 0; i != MAXCOMBATSPELLS; ++i) {
@ -979,7 +978,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
show = u->items; show = u->items;
} }
else if (!itemcloak && mode >= see_unit && !(a_fshidden else if (!itemcloak && mode >= see_unit && !(a_fshidden
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) { && a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH, 0) >= 3)) {
int n = report_items(u->items, result, MAX_INVENTORY, u, f); int n = report_items(u->items, result, MAX_INVENTORY, u, f);
assert(n >= 0); assert(n >= 0);
if (n > 0) if (n > 0)

View File

@ -999,7 +999,7 @@ static void manufacture(unit * u, const item_type * itype, int want)
int minskill = itype->construction->minskill; int minskill = itype->construction->minskill;
skill_t sk = itype->construction->skill; skill_t sk = itype->construction->skill;
skill = effskill(u, sk); skill = effskill(u, sk, 0);
skill = skill =
skillmod(itype->rtype->attribs, u, u->region, sk, skill, SMF_PRODUCTION); skillmod(itype->rtype->attribs, u, u->region, sk, skill, SMF_PRODUCTION);
@ -1159,7 +1159,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
assert(itype->construction->skill != 0 assert(itype->construction->skill != 0
|| "limited resource needs a required skill for making it"); || "limited resource needs a required skill for making it");
skill = eff_skill(u, itype->construction->skill, u->region); skill = effskill(u, itype->construction->skill, 0);
if (skill == 0) { if (skill == 0) {
skill_t sk = itype->construction->skill; skill_t sk = itype->construction->skill;
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
@ -1282,7 +1282,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
if (!fval(al, AFL_DONE)) { if (!fval(al, AFL_DONE)) {
int req = required(al->want - al->get, al->save); int req = required(al->want - al->get, al->save);
assert(al->get <= al->want && al->get >= 0); assert(al->get <= al->want && al->get >= 0);
if (eff_skill(al->unit, itype->construction->skill, r) if (effskill(al->unit, itype->construction->skill, 0)
>= rm->level + itype->construction->minskill - 1) { >= rm->level + itype->construction->minskill - 1) {
if (req) { if (req) {
norders += req; norders += req;
@ -1817,7 +1817,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
} }
/* Ein Händler kann nur 10 Güter pro Talentpunkt handeln. */ /* Ein Händler kann nur 10 Güter pro Talentpunkt handeln. */
k = u->number * 10 * eff_skill(u, SK_TRADE, r); k = u->number * 10 * effskill(u, SK_TRADE, 0);
/* hat der Händler bereits gehandelt, muss die Menge der bereits /* hat der Händler bereits gehandelt, muss die Menge der bereits
* verkauften/gekauften Güter abgezogen werden */ * verkauften/gekauften Güter abgezogen werden */
@ -2134,7 +2134,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
/* Ein Händler kann nur 10 Güter pro Talentpunkt verkaufen. */ /* Ein Händler kann nur 10 Güter pro Talentpunkt verkaufen. */
n = _min(n, u->number * 10 * eff_skill(u, SK_TRADE, r)); n = _min(n, u->number * 10 * effskill(u, SK_TRADE, 0));
if (!n) { if (!n) {
cmistake(u, ord, 54, MSG_COMMERCE); cmistake(u, ord, 54, MSG_COMMERCE);
@ -2181,7 +2181,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
* existiert, so dass man arrays von orders machen kann. */ * existiert, so dass man arrays von orders machen kann. */
/* Ein Händler kann nur 10 Güter pro Talentpunkt handeln. */ /* Ein Händler kann nur 10 Güter pro Talentpunkt handeln. */
k = u->number * 10 * eff_skill(u, SK_TRADE, r); k = u->number * 10 * effskill(u, SK_TRADE, 0);
/* hat der Händler bereits gehandelt, muss die Menge der bereits /* hat der Händler bereits gehandelt, muss die Menge der bereits
* verkauften/gekauften Güter abgezogen werden */ * verkauften/gekauften Güter abgezogen werden */
@ -2280,7 +2280,7 @@ static void plant(region * r, unit * u, int raw)
} }
/* Skill prüfen */ /* Skill prüfen */
skill = eff_skill(u, SK_HERBALISM, r); skill = effskill(u, SK_HERBALISM, 0);
itype = rherbtype(r); itype = rherbtype(r);
if (skill < 6) { if (skill < 6) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
@ -2325,6 +2325,7 @@ static void planttrees(region * r, unit * u, int raw)
int n, i, skill, planted = 0; int n, i, skill, planted = 0;
const resource_type *rtype; const resource_type *rtype;
assert(r == u->region); // TODO: param r is unnecessary
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
return; return;
} }
@ -2333,7 +2334,7 @@ static void planttrees(region * r, unit * u, int raw)
rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED);
/* Skill prüfen */ /* Skill prüfen */
skill = eff_skill(u, SK_HERBALISM, r); skill = effskill(u, SK_HERBALISM, 0);
if (skill < 6) { if (skill < 6) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_feedback(u, u->thisorder, "plant_skills", msg_feedback(u, u->thisorder, "plant_skills",
@ -2380,6 +2381,7 @@ static void breedtrees(region * r, unit * u, int raw)
static int gamecookie = -1; static int gamecookie = -1;
static int current_season; static int current_season;
assert(r == u->region); // TODO: param r is unnecessary
if (gamecookie != global.cookie) { if (gamecookie != global.cookie) {
gamedate date; gamedate date;
get_gamedate(turn, &date); get_gamedate(turn, &date);
@ -2401,7 +2403,7 @@ static void breedtrees(region * r, unit * u, int raw)
rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED);
/* Skill prüfen */ /* Skill prüfen */
skill = eff_skill(u, SK_HERBALISM, r); skill = effskill(u, SK_HERBALISM, 0);
if (skill < 12) { if (skill < 12) {
planttrees(r, u, raw); planttrees(r, u, raw);
return; return;
@ -2440,8 +2442,9 @@ static void breedhorses(region * r, unit * u)
struct building *b = inside_building(u); struct building *b = inside_building(u);
const struct building_type *btype = b ? b->type : NULL; const struct building_type *btype = b ? b->type : NULL;
const struct resource_type *rhorse = get_resourcetype(R_HORSE); const struct resource_type *rhorse = get_resourcetype(R_HORSE);
int horses; int horses, effsk;
assert(rhorse && rhorse->itype); assert(rhorse && rhorse->itype);
assert(r == u->region); // TODO: param r is unnecessary
if (btype != bt_find("stables")) { if (btype != bt_find("stables")) {
cmistake(u, u->thisorder, 122, MSG_PRODUCE); cmistake(u, u->thisorder, 122, MSG_PRODUCE);
return; return;
@ -2451,11 +2454,12 @@ static void breedhorses(region * r, unit * u)
cmistake(u, u->thisorder, 107, MSG_PRODUCE); cmistake(u, u->thisorder, 107, MSG_PRODUCE);
return; return;
} }
n = u->number * eff_skill(u, SK_HORSE_TRAINING, r); effsk = effskill(u, SK_HORSE_TRAINING, 0);
n = u->number * effsk;
n = _min(n, horses); n = _min(n, horses);
for (c = 0; c < n; c++) { for (c = 0; c < n; c++) {
if (rng_int() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) { if (rng_int() % 100 < effsk) {
i_change(&u->items, rhorse->itype, 1); i_change(&u->items, rhorse->itype, 1);
++breed; ++breed;
} }
@ -2551,7 +2555,7 @@ static void research_cmd(unit * u, struct order *ord)
kwd = init_order(ord); kwd = init_order(ord);
assert(kwd == K_RESEARCH); assert(kwd == K_RESEARCH);
if (eff_skill(u, SK_HERBALISM, r) < 7) { if (effskill(u, SK_HERBALISM, 0) < 7) {
cmistake(u, ord, 227, MSG_EVENT); cmistake(u, ord, 227, MSG_EVENT);
return; return;
} }
@ -2584,8 +2588,9 @@ static int max_skill(region * r, faction * f, skill_t sk)
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->faction == f) { if (u->faction == f) {
if (eff_skill(u, sk, r) > w) { int effsk = effskill(u, sk, 0);
w = eff_skill(u, sk, r); if (effsk > w) {
w = effsk;
} }
} }
} }
@ -2614,7 +2619,7 @@ message * check_steal(const unit * u, struct order *ord) {
static void steal_cmd(unit * u, struct order *ord, request ** stealorders) static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
{ {
const resource_type *rring = get_resourcetype(R_RING_OF_NIMBLEFINGER); const resource_type *rring = get_resourcetype(R_RING_OF_NIMBLEFINGER);
int n, i, id; int n, i, id, effsk;
bool goblin = false; bool goblin = false;
request *o; request *o;
unit *u2 = NULL; unit *u2 = NULL;
@ -2671,11 +2676,12 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
return; return;
} }
n = eff_skill(u, SK_STEALTH, r) - max_skill(r, f, SK_PERCEPTION); effsk = effskill(u, SK_STEALTH, 0);
n = effsk - max_skill(r, f, SK_PERCEPTION);
if (n <= 0) { if (n <= 0) {
/* Wahrnehmung == Tarnung */ /* Wahrnehmung == Tarnung */
if (u_race(u) != get_race(RC_GOBLIN) || eff_skill(u, SK_STEALTH, r) <= 3) { if (u_race(u) != get_race(RC_GOBLIN) || effsk <= 3) {
ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2)); ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
if (n == 0) { if (n == 0) {
ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2)); ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
@ -2771,7 +2777,7 @@ void entertain_cmd(unit * u, struct order *ord)
cmistake(u, ord, 58, MSG_INCOME); cmistake(u, ord, 58, MSG_INCOME);
return; return;
} }
if (!effskill(u, SK_ENTERTAINMENT)) { if (!effskill(u, SK_ENTERTAINMENT, 0)) {
cmistake(u, ord, 58, MSG_INCOME); cmistake(u, ord, 58, MSG_INCOME);
return; return;
} }
@ -2788,7 +2794,7 @@ void entertain_cmd(unit * u, struct order *ord)
return; return;
} }
u->wants = u->number * (entertainbase + effskill(u, SK_ENTERTAINMENT) u->wants = u->number * (entertainbase + effskill(u, SK_ENTERTAINMENT, 0)
* entertainperlevel); * entertainperlevel);
max_e = getuint(); max_e = getuint();
@ -3002,7 +3008,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
u->wants = _min(income(u), max); u->wants = _min(income(u), max);
} }
else { else {
u->wants = _min(n * eff_skill(u, SK_TAXING, r) * 20, max); u->wants = _min(n * effskill(u, SK_TAXING, 0) * 20, max);
} }
u2 = is_guarded(r, u, GUARD_TAX); u2 = is_guarded(r, u, GUARD_TAX);
@ -3077,7 +3083,7 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders)
} }
else { else {
/* For player start with 20 Silver +10 every 5 level of close combat skill*/ /* For player start with 20 Silver +10 every 5 level of close combat skill*/
int skbonus = (_max(eff_skill(u, SK_MELEE, r), eff_skill(u, SK_SPEAR, r)) * 2 / 10) + 2; int skbonus = (_max(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2;
u->wants = _min(n * skbonus * 10, max); u->wants = _min(n * skbonus * 10, max);
} }

View File

@ -123,7 +123,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
n = _min(n, road); n = _min(n, road);
if (n != 0) { if (n != 0) {
region *r2 = rconnect(r, d); region *r2 = rconnect(r, d);
int willdo = eff_skill(u, SK_ROAD_BUILDING, r) * u->number; int willdo = effskill(u, SK_ROAD_BUILDING, 0) * u->number;
willdo = _min(willdo, n); willdo = _min(willdo, n);
if (willdo == 0) { if (willdo == 0) {
/* TODO: error message */ /* TODO: error message */
@ -263,11 +263,13 @@ int destroy_cmd(unit * u, struct order *ord)
void build_road(region * r, unit * u, int size, direction_t d) void build_road(region * r, unit * u, int size, direction_t d)
{ {
int n, left; int n, left, effsk;
region *rn = rconnect(r, d); region *rn = rconnect(r, d);
assert(u->number); assert(u->number);
if (!eff_skill(u, SK_ROAD_BUILDING, r)) { assert(r == u->region); // TODO: param r is unnecessary
effsk = effskill(u, SK_ROAD_BUILDING, 0);
if (!effsk) {
cmistake(u, u->thisorder, 103, MSG_PRODUCE); cmistake(u, u->thisorder, 103, MSG_PRODUCE);
return; return;
} }
@ -337,7 +339,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
left = _min(n, left); left = _min(n, left);
/* n = maximum by skill. try to maximize it */ /* n = maximum by skill. try to maximize it */
n = u->number * eff_skill(u, SK_ROAD_BUILDING, r); n = u->number * effsk;
if (n < left) { if (n < left) {
const resource_type *ring = get_resourcetype(R_RING_OF_NIMBLEFINGER); const resource_type *ring = get_resourcetype(R_RING_OF_NIMBLEFINGER);
item *itm = ring ? *i_find(&u->items, ring->itype) : 0; item *itm = ring ? *i_find(&u->items, ring->itype) : 0;
@ -349,12 +351,11 @@ void build_road(region * r, unit * u, int size, direction_t d)
if (n < left) { if (n < left) {
int dm = get_effect(u, oldpotiontype[P_DOMORE]); int dm = get_effect(u, oldpotiontype[P_DOMORE]);
if (dm != 0) { if (dm != 0) {
int sk = eff_skill(u, SK_ROAD_BUILDING, r); int todo = (left - n + effsk - 1) / effsk;
int todo = (left - n + sk - 1) / sk;
todo = _min(todo, u->number); todo = _min(todo, u->number);
dm = _min(dm, todo); dm = _min(dm, todo);
change_effect(u, oldpotiontype[P_DOMORE], -dm); change_effect(u, oldpotiontype[P_DOMORE], -dm);
n += dm * sk; n += dm * effsk;
} /* Auswirkung Schaffenstrunk */ } /* Auswirkung Schaffenstrunk */
} }
@ -456,7 +457,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
int dm = get_effect(u, oldpotiontype[P_DOMORE]); int dm = get_effect(u, oldpotiontype[P_DOMORE]);
assert(u->number); assert(u->number);
basesk = effskill(u, type->skill); basesk = effskill(u, type->skill, 0);
if (basesk == 0) if (basesk == 0)
return ENEEDSKILL; return ENEEDSKILL;
@ -676,7 +677,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
assert(u->number); assert(u->number);
assert(btype->construction); assert(btype->construction);
if (eff_skill(u, SK_BUILDING, r) == 0) { if (effskill(u, SK_BUILDING, 0) == 0) {
cmistake(u, ord, 101, MSG_PRODUCE); cmistake(u, ord, 101, MSG_PRODUCE);
return 0; return 0;
} }
@ -887,7 +888,8 @@ order * ord)
const construction *cons = newtype->construction; const construction *cons = newtype->construction;
order *new_order; order *new_order;
if (!eff_skill(u, SK_SHIPBUILDING, r)) { assert(u->region == r); // TODO: param r is unnecessary
if (!effskill(u, SK_SHIPBUILDING, 0)) {
cmistake(u, ord, 100, MSG_PRODUCE); cmistake(u, ord, 100, MSG_PRODUCE);
return; return;
} }
@ -897,7 +899,7 @@ order * ord)
} }
/* check if skill and material for 1 size is available */ /* check if skill and material for 1 size is available */
if (eff_skill(u, cons->skill, r) < cons->minskill) { if (effskill(u, cons->skill, 0) < cons->minskill) {
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder,
"error_build_skill_low", "value", cons->minskill)); "error_build_skill_low", "value", cons->minskill));
return; return;
@ -935,7 +937,8 @@ void continue_ship(region * r, unit * u, int want)
ship *sh; ship *sh;
int msize; int msize;
if (!eff_skill(u, SK_SHIPBUILDING, r)) { assert(u->region == r); // TODO: param r is unnecessary
if (!effskill(u, SK_SHIPBUILDING, 0)) {
cmistake(u, u->thisorder, 100, MSG_PRODUCE); cmistake(u, u->thisorder, 100, MSG_PRODUCE);
return; return;
} }
@ -956,7 +959,7 @@ void continue_ship(region * r, unit * u, int want)
cmistake(u, u->thisorder, 16, MSG_PRODUCE); cmistake(u, u->thisorder, 16, MSG_PRODUCE);
return; return;
} }
if (eff_skill(u, cons->skill, r) < cons->minskill) { if (effskill(u, cons->skill, 0) < cons->minskill) {
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder,
"error_build_skill_low", "value", cons->minskill)); "error_build_skill_low", "value", cons->minskill));
return; return;

View File

@ -434,10 +434,9 @@ static bool
b_blockfogwall(const connection * b, const unit * u, const region * r) b_blockfogwall(const connection * b, const unit * u, const region * r)
{ {
unused_arg(b); unused_arg(b);
unused_arg(r);
if (!u) if (!u)
return true; return true;
return (bool)(effskill(u, SK_PERCEPTION) > 4); /* Das ist die alte Nebelwand */ return (bool)(effskill(u, SK_PERCEPTION, r) > 4); /* Das ist die alte Nebelwand */
} }
/** Legacy type used in old Eressea games, no longer in use. */ /** Legacy type used in old Eressea games, no longer in use. */

View File

@ -825,7 +825,7 @@ int amount, struct order *ord)
"")); ""));
return ECUSTOM; return ECUSTOM;
} }
if (effskill(u, SK_STEALTH) <= effskill(target, SK_PERCEPTION)) { if (effskill(u, SK_STEALTH, 0) <= effskill(target, SK_PERCEPTION, 0)) {
cmistake(u, ord, 64, MSG_EVENT); cmistake(u, ord, 64, MSG_EVENT);
return ECUSTOM; return ECUSTOM;
} }

View File

@ -1671,7 +1671,7 @@ int readgame(const char *filename, bool backup)
sc_mage *mage = get_mage(u); sc_mage *mage = get_mage(u);
if (mage) { if (mage) {
faction *f = u->faction; faction *f = u->faction;
int skl = effskill(u, SK_MAGIC); int skl = effskill(u, SK_MAGIC, 0);
if (f->magiegebiet == M_GRAY) { if (f->magiegebiet == M_GRAY) {
log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]); log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]);
f->magiegebiet = mage->magietyp; f->magiegebiet = mage->magietyp;

View File

@ -273,7 +273,7 @@ static int ShipSpeedBonus(const unit * u)
int level = get_param_int(global.parameters, "movement.shipspeed.skillbonus", 0); int level = get_param_int(global.parameters, "movement.shipspeed.skillbonus", 0);
if (level > 0) { if (level > 0) {
ship *sh = u->ship; ship *sh = u->ship;
int skl = effskill(u, SK_SAILING); int skl = effskill(u, SK_SAILING, 0);
int minsk = (sh->type->cptskill + 1) / 2; int minsk = (sh->type->cptskill + 1) / 2;
return (skl - minsk) / level; return (skl - minsk) / level;
} }
@ -288,7 +288,7 @@ int crew_skill(const ship *sh) {
for (u = sh->region->units; u; u = u->next) { for (u = sh->region->units; u; u = u->next) {
if (u->ship == sh) { if (u->ship == sh) {
n += eff_skill(u, SK_SAILING, sh->region) * u->number; n += effskill(u, SK_SAILING, 0) * u->number;
} }
} }
return n; return n;

View File

@ -1365,31 +1365,31 @@ int get_modifier(const unit * u, skill_t sk, int level, const region * r, bool n
return skill - bskill; return skill - bskill;
} }
int eff_skill(const unit * u, skill_t sk, const region * r) int eff_skill(const unit * u, const skill *sv, const region *r)
{ {
if (skill_enabled(sk)) { assert(u);
int level = get_level(u, sk); if (!r) r = u->region;
if (level > 0) { if (sv && sv->level>0) {
int mlevel = level + get_modifier(u, sk, level, r, false); int mlevel = sv->level + get_modifier(u, sv->id, sv->level, r, false);
if (mlevel > 0) { if (mlevel > 0) {
int skillcap = SkillCap(sk); int skillcap = SkillCap(sv->id);
if (skillcap && mlevel > skillcap) { if (skillcap && mlevel > skillcap) {
return skillcap; return skillcap;
} }
return mlevel; return mlevel;
} }
} }
}
return 0; return 0;
} }
int eff_skill_study(const unit * u, skill_t sk, const region * r) int effskill_study(const unit * u, skill_t sk, const region * r)
{ {
int level = get_level(u, sk); skill *sv = unit_skill(u, sk);
if (level > 0) { if (sv && sv->level > 0) {
int mlevel = level + get_modifier(u, sk, level, r, true); int mlevel = sv->level;
if (!r) r = u->region;
mlevel += get_modifier(u, sv->id, sv->level, r, true);
if (mlevel > 0) if (mlevel > 0)
return mlevel; return mlevel;
} }
@ -1741,7 +1741,7 @@ int unit_max_hp(const unit * u)
h = u_race(u)->hitpoints; h = u_race(u)->hitpoints;
if (rules_stamina & 1) { if (rules_stamina & 1) {
p = pow(effskill(u, SK_STAMINA) / 2.0, 1.5) * 0.2; p = pow(effskill(u, SK_STAMINA, u->region) / 2.0, 1.5) * 0.2;
h += (int)(h * p + 0.5); h += (int)(h * p + 0.5);
} }
@ -1852,9 +1852,20 @@ struct spellbook * unit_get_spellbook(const struct unit * u)
return 0; return 0;
} }
int effskill(const unit * u, skill_t sk) int effskill(const unit * u, skill_t sk, const region *r)
{ {
return eff_skill(u, sk, u->region); assert(u);
if (skill_enabled(sk)) {
skill *sv = u->skills;
while (sv != u->skills + u->skill_size) {
if (sv->id == sk) {
return eff_skill(u, sv, r);
}
++sv;
}
}
return 0;
} }
void remove_empty_units_in_region(region * r) void remove_empty_units_in_region(region * r)

View File

@ -160,7 +160,7 @@ extern "C" {
void remove_skill(struct unit *u, skill_t sk); void remove_skill(struct unit *u, skill_t sk);
struct skill *unit_skill(const struct unit *u, skill_t id); struct skill *unit_skill(const struct unit *u, skill_t id);
bool has_skill(const unit * u, skill_t sk); bool has_skill(const unit * u, skill_t sk);
int effskill(const struct unit *u, skill_t sk); int effskill(const struct unit *u, skill_t sk, const struct region *r);
int produceexp(struct unit *u, skill_t sk, int n); int produceexp(struct unit *u, skill_t sk, int n);
int SkillCap(skill_t sk); int SkillCap(skill_t sk);
@ -168,14 +168,12 @@ extern "C" {
int get_level(const struct unit *u, skill_t id); int get_level(const struct unit *u, skill_t id);
extern void transfermen(struct unit *u, struct unit *u2, int n); extern void transfermen(struct unit *u, struct unit *u2, int n);
extern int eff_skill(const struct unit *u, skill_t sk, int eff_skill(const struct unit *u, const struct skill *sv, const struct region *r);
const struct region *r); int effskill_study(const struct unit *u, skill_t sk, const struct region *r);
extern int eff_skill_study(const struct unit *u, skill_t sk,
const struct region *r);
extern int get_modifier(const struct unit *u, skill_t sk, int lvl, int get_modifier(const struct unit *u, skill_t sk, int level,
const struct region *r, bool noitem); const struct region *r, bool noitem);
extern int remove_unit(struct unit **ulist, struct unit *u); int remove_unit(struct unit **ulist, struct unit *u);
#define GIFT_SELF 1<<0 #define GIFT_SELF 1<<0
#define GIFT_FRIENDS 1<<1 #define GIFT_FRIENDS 1<<1

View File

@ -894,7 +894,7 @@ static int slipthru(const region * r, const unit * u, const building * b)
/* u wird am hinein- oder herausschluepfen gehindert, wenn STEALTH <= /* u wird am hinein- oder herausschluepfen gehindert, wenn STEALTH <=
* OBSERVATION +2 der belagerer u2 ist */ * OBSERVATION +2 der belagerer u2 ist */
n = eff_skill(u, SK_STEALTH, r); n = effskill(u, SK_STEALTH, r);
for (u2 = r->units; u2; u2 = u2->next) { for (u2 = r->units; u2; u2 = u2->next) {
if (usiege(u2) == b) { if (usiege(u2) == b) {
@ -902,7 +902,7 @@ static int slipthru(const region * r, const unit * u, const building * b)
if (invisible(u, u2) >= u->number) if (invisible(u, u2) >= u->number)
continue; continue;
o = eff_skill(u2, SK_PERCEPTION, r); o = effskill(u2, SK_PERCEPTION, r);
if (o + 2 >= n) { if (o + 2 >= n) {
return 0; /* entdeckt! */ return 0; /* entdeckt! */
@ -2290,7 +2290,7 @@ static bool display_potion(faction * f, unit * u, const potion_type * ptype)
return false; return false;
else { else {
int i = i_get(u->items, ptype->itype); int i = i_get(u->items, ptype->itype);
if (i == 0 && 2 * ptype->level > effskill(u, SK_ALCHEMY)) { if (i == 0 && 2 * ptype->level > effskill(u, SK_ALCHEMY, 0)) {
return false; return false;
} }
} }
@ -2465,7 +2465,7 @@ static void reshow(unit * u, struct order *ord, const char *s, param_t p)
a_removeall(&u->faction->attribs, &at_seenspell); a_removeall(&u->faction->attribs, &at_seenspell);
break; break;
case P_POTIONS: case P_POTIONS:
skill = effskill(u, SK_ALCHEMY); skill = effskill(u, SK_ALCHEMY, 0);
c = 0; c = 0;
for (ptype = potiontypes; ptype != NULL; ptype = ptype->next) { for (ptype = potiontypes; ptype != NULL; ptype = ptype->next) {
if (ptype->level * 2 <= skill) { if (ptype->level * 2 <= skill) {
@ -3138,7 +3138,7 @@ static building *age_building(building * b)
curse *c = get_curse(rt->attribs, ct_astralblock); curse *c = get_curse(rt->attribs, ct_astralblock);
if (c == NULL) { if (c == NULL) {
if (mage != NULL) { if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC, 0);
float effect = 100; float effect = 100;
/* the mage reactivates the circle */ /* the mage reactivates the circle */
c = create_curse(mage, &rt->attribs, ct_astralblock, c = create_curse(mage, &rt->attribs, ct_astralblock,
@ -3148,7 +3148,7 @@ static building *age_building(building * b)
} }
} }
else if (mage != NULL) { else if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC, 0);
c->duration = _max(c->duration, sk / 2); c->duration = _max(c->duration, sk / 2);
c->vigour = _max(c->vigour, (float)sk); c->vigour = _max(c->vigour, (float)sk);
} }
@ -3693,7 +3693,7 @@ static int faction_getmages(faction * f, unit ** results, int numresults)
if (u->number > 0) { if (u->number > 0) {
sc_mage *mage = get_mage(u); sc_mage *mage = get_mage(u);
if (mage) { if (mage) {
int level = eff_skill(u, SK_MAGIC, u->region); int level = effskill(u, SK_MAGIC, 0);
if (level > maxlevel) { if (level > maxlevel) {
maxlevel = level; maxlevel = level;
} }
@ -3752,7 +3752,7 @@ static void update_spells(void)
unit * u = mages[i]; unit * u = mages[i];
sc_mage *mage = get_mage(u); sc_mage *mage = get_mage(u);
if (mage && mage->spellbook) { if (mage && mage->spellbook) {
int level = effskill(u, SK_MAGIC); int level = effskill(u, SK_MAGIC, 0);
show_new_spells(f, level, mage->spellbook); show_new_spells(f, level, mage->spellbook);
} }
} }
@ -4182,7 +4182,7 @@ int armedmen(const unit * u, bool siege_weapons)
item *itm; item *itm;
int n = 0; int n = 0;
if (!(urace(u)->flags & RCF_NOWEAPONS)) { if (!(urace(u)->flags & RCF_NOWEAPONS)) {
if (effskill(u, SK_WEAPONLESS) >= 1) { if (effskill(u, SK_WEAPONLESS, 0) >= 1) {
/* kann ohne waffen bewachen: fuer drachen */ /* kann ohne waffen bewachen: fuer drachen */
n = u->number; n = u->number;
} }
@ -4193,7 +4193,7 @@ int armedmen(const unit * u, bool siege_weapons)
const weapon_type *wtype = resource2weapon(itm->type->rtype); const weapon_type *wtype = resource2weapon(itm->type->rtype);
if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE))) if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE)))
continue; continue;
if (effskill(u, wtype->skill) >= wtype->minskill) if (effskill(u, wtype->skill, 0) >= wtype->minskill)
n += itm->number; n += itm->number;
/* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */ /* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */
if (n > u->number) if (n > u->number)
@ -4238,9 +4238,9 @@ int siege_cmd(unit * u, order * ord)
d = _min(u->number, d); d = _min(u->number, d);
pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d); pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d);
d = _min(pooled, d); d = _min(pooled, d);
if (eff_skill(u, SK_CATAPULT, r) >= 1) { if (effskill(u, SK_CATAPULT, 0) >= 1) {
katapultiere = d; katapultiere = d;
d *= eff_skill(u, SK_CATAPULT, r); d *= effskill(u, SK_CATAPULT, 0);
} }
else { else {
d = 0; d = 0;
@ -4604,6 +4604,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
int stealth, rings; int stealth, rings;
unit *u2 = r->units; unit *u2 = r->units;
assert(u->region == r); // TODO: param r is unnecessary
if (u->faction == f || omniscient(f)) { if (u->faction == f || omniscient(f)) {
return true; return true;
} }
@ -4640,7 +4641,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
while (u2) { while (u2) {
if (rings < u->number || invisible(u, u2) < u->number) { if (rings < u->number || invisible(u, u2) < u->number) {
if (skill_enabled(SK_PERCEPTION)) { if (skill_enabled(SK_PERCEPTION)) {
int observation = eff_skill(u2, SK_PERCEPTION, r); int observation = effskill(u2, SK_PERCEPTION, 0);
if (observation >= stealth) { if (observation >= stealth) {
return true; return true;
@ -4684,7 +4685,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
return false; return false;
} }
if (skill_enabled(SK_PERCEPTION)) { if (skill_enabled(SK_PERCEPTION)) {
o = eff_skill(u, SK_PERCEPTION, target->region); o = effskill(u, SK_PERCEPTION, target->region);
if (o >= n) { if (o >= n) {
return true; return true;
} }
@ -4730,7 +4731,7 @@ int modifier)
if (rings && invisible(u, u2) >= u->number) if (rings && invisible(u, u2) >= u->number)
continue; continue;
o = eff_skill(u2, SK_PERCEPTION, r); o = effskill(u2, SK_PERCEPTION, 0);
if (o >= n) { if (o >= n) {
return true; return true;

View File

@ -81,7 +81,7 @@ int lighthouse_range(const building * b, const faction * f)
if (c > buildingcapacity(b)) if (c > buildingcapacity(b))
break; break;
if (f == NULL || u->faction == f) { if (f == NULL || u->faction == f) {
int sk = eff_skill(u, SK_PERCEPTION, r) / 3; int sk = effskill(u, SK_PERCEPTION, 0) / 3;
d = _max(d, sk); d = _max(d, sk);
d = _min(maxd, d); d = _min(maxd, d);
if (d == maxd) if (d == maxd)
@ -131,7 +131,7 @@ bool check_leuchtturm(region * r, faction * f)
d = distance(r, r2); d = distance(r, r2);
if (maxd < d) if (maxd < d)
break; break;
if (eff_skill(u, SK_PERCEPTION, r) >= d * 3) if (effskill(u, SK_PERCEPTION, 0) >= d * 3)
return true; return true;
} }
} }

View File

@ -517,7 +517,7 @@ int u_hasspell(const unit *u, const struct spell *sp)
spellbook * book = unit_get_spellbook(u); spellbook * book = unit_get_spellbook(u);
spellbook_entry * sbe = book ? spellbook_get(book, sp) : 0; spellbook_entry * sbe = book ? spellbook_get(book, sp) : 0;
if (sbe) { if (sbe) {
return sbe->level <= effskill(u, SK_MAGIC); return sbe->level <= effskill(u, SK_MAGIC, 0);
} }
return 0; return 0;
} }
@ -531,7 +531,7 @@ int get_combatspelllevel(const unit * u, int nr)
assert(nr < MAXCOMBATSPELLS); assert(nr < MAXCOMBATSPELLS);
if (m) { if (m) {
int level = eff_skill(u, SK_MAGIC, u->region); int level = effskill(u, SK_MAGIC, 0);
return _min(m->combatspells[nr].level, level); return _min(m->combatspells[nr].level, level);
} }
return -1; return -1;
@ -703,7 +703,7 @@ static int use_item_aura(const region * r, const unit * u)
{ {
int sk, n; int sk, n;
sk = eff_skill(u, SK_MAGIC, r); sk = effskill(u, SK_MAGIC, r);
n = (int)(sk * sk * u_race(u)->maxaura / 4); n = (int)(sk * sk * u_race(u)->maxaura / 4);
return n; return n;
@ -717,7 +717,7 @@ int max_spellpoints(const region * r, const unit * u)
double divisor = 1.2; double divisor = 1.2;
const struct resource_type *rtype; const struct resource_type *rtype;
sk = eff_skill(u, SK_MAGIC, r); sk = effskill(u, SK_MAGIC, r);
msp = u_race(u)->maxaura * (pow(sk, potenz) / divisor + 1) + get_spchange(u); msp = u_race(u)->maxaura * (pow(sk, potenz) / divisor + 1) + get_spchange(u);
rtype = rt_find("aurafocus"); rtype = rt_find("aurafocus");
@ -950,7 +950,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
return false; return false;
} }
/* reicht die Stufe aus? */ /* reicht die Stufe aus? */
if (eff_skill(u, SK_MAGIC, u->region) < level) { if (effskill(u, SK_MAGIC, 0) < level) {
/* die Einheit ist nicht erfahren genug für diesen Zauber */ /* die Einheit ist nicht erfahren genug für diesen Zauber */
cmistake(u, ord, 169, MSG_MAGIC); cmistake(u, ord, 169, MSG_MAGIC);
return false; return false;
@ -1123,7 +1123,7 @@ double magic_resistance(unit * target)
assert(target->number > 0); assert(target->number > 0);
/* Magier haben einen Resistenzbonus vom Magietalent * 5% */ /* Magier haben einen Resistenzbonus vom Magietalent * 5% */
probability += effskill(target, SK_MAGIC) * 0.05; probability += effskill(target, SK_MAGIC, 0) * 0.05;
/* Auswirkungen von Zaubern auf der Einheit */ /* Auswirkungen von Zaubern auf der Einheit */
c = get_curse(target->attribs, ct_find("magicresistance")); c = get_curse(target->attribs, ct_find("magicresistance"));
@ -1207,10 +1207,10 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
skill *sv; skill *sv;
unit *u = (unit *)obj; unit *u = (unit *)obj;
at = effskill(magician, SK_MAGIC); at = effskill(magician, SK_MAGIC, 0);
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
int sk = effskill(u, sv->id); int sk = eff_skill(u, sv, 0);
if (pa < sk) if (pa < sk)
pa = sk; pa = sk;
} }
@ -1282,7 +1282,7 @@ bool fumble(region * r, unit * u, const spell * sp, int cast_grade)
* */ * */
int rnd = 0; int rnd = 0;
double x = (double)cast_grade / (double)eff_skill(u, SK_MAGIC, r); double x = (double)cast_grade / (double)effskill(u, SK_MAGIC, r);
int fumble_chance = (int)(((double)x * 40.0) - 20.0); int fumble_chance = (int)(((double)x * 40.0) - 20.0);
struct building *b = inside_building(u); struct building *b = inside_building(u);
const struct building_type *btype = b ? b->type : NULL; const struct building_type *btype = b ? b->type : NULL;
@ -1432,7 +1432,7 @@ static double regeneration(unit * u)
double potenz = 1.5; double potenz = 1.5;
double divisor = 2.0; double divisor = 2.0;
sk = effskill(u, SK_MAGIC); sk = effskill(u, SK_MAGIC, 0);
/* Rassenbonus/-malus */ /* Rassenbonus/-malus */
d = pow(sk, potenz) * u_race(u)->regaura / divisor; d = pow(sk, potenz) * u_race(u)->regaura / divisor;
d++; d++;
@ -2149,7 +2149,7 @@ static int sm_familiar(const unit * u, const region * r, skill_t sk, int value)
/* the familiar is dead */ /* the familiar is dead */
return value; return value;
} }
mod = eff_skill(familiar, sk, r) / 2; mod = effskill(familiar, sk, r) / 2;
if (r != familiar->region) { if (r != familiar->region) {
mod /= distance(r, familiar->region); mod /= distance(r, familiar->region);
} }
@ -2515,7 +2515,7 @@ static castorder *cast_cmd(unit * u, order * ord)
cmistake(u, ord, 269, MSG_MAGIC); cmistake(u, ord, 269, MSG_MAGIC);
return 0; return 0;
} }
level = eff_skill(u, SK_MAGIC, r); level = effskill(u, SK_MAGIC, 0);
init_order(ord); init_order(ord);
s = gettoken(token, sizeof(token)); s = gettoken(token, sizeof(token));
@ -2648,7 +2648,7 @@ static castorder *cast_cmd(unit * u, order * ord)
} }
/* Stufenangabe bei nicht Stufenvariierbaren Sprüchen abfangen */ /* Stufenangabe bei nicht Stufenvariierbaren Sprüchen abfangen */
if (!(sp->sptyp & SPELLLEVEL)) { if (!(sp->sptyp & SPELLLEVEL)) {
int ilevel = eff_skill(u, SK_MAGIC, u->region); int ilevel = effskill(u, SK_MAGIC, 0);
if (ilevel != level) { if (ilevel != level) {
level = ilevel; level = ilevel;
ADDMSG(&u->faction->msgs, msg_message("spellfail::nolevel", ADDMSG(&u->faction->msgs, msg_message("spellfail::nolevel",
@ -2674,7 +2674,7 @@ static castorder *cast_cmd(unit * u, order * ord)
"mage", caster)); "mage", caster));
return 0; return 0;
} }
if (distance(caster->region, r) > eff_skill(caster, SK_MAGIC, caster->region)) { if (distance(caster->region, r) > effskill(caster, SK_MAGIC, 0)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "familiar_toofar", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "familiar_toofar",
"mage", caster)); "mage", caster));
return 0; return 0;
@ -2684,7 +2684,7 @@ static castorder *cast_cmd(unit * u, order * ord)
* löschen, zaubern kann er noch */ * löschen, zaubern kann er noch */
range *= 2; range *= 2;
set_order(&caster->thisorder, NULL); set_order(&caster->thisorder, NULL);
level = _min(level, eff_skill(caster, SK_MAGIC, caster->region) / 2); level = _min(level, effskill(caster, SK_MAGIC, 0) / 2);
} }
} }
/* Weitere Argumente zusammenbasteln */ /* Weitere Argumente zusammenbasteln */

View File

@ -853,7 +853,7 @@ void plan_monsters(faction * f)
/* Einheiten, die Waffenlosen Kampf lernen könnten, lernen es um /* Einheiten, die Waffenlosen Kampf lernen könnten, lernen es um
* zu bewachen: */ * zu bewachen: */
if (u_race(u)->bonus[SK_WEAPONLESS] != -99) { if (u_race(u)->bonus[SK_WEAPONLESS] != -99) {
if (eff_skill(u, SK_WEAPONLESS, u->region) < 1) { if (effskill(u, SK_WEAPONLESS, 0) < 1) {
long_order = long_order =
create_order(K_STUDY, f->locale, "'%s'", create_order(K_STUDY, f->locale, "'%s'",
skillname(SK_WEAPONLESS, f->locale)); skillname(SK_WEAPONLESS, f->locale));

View File

@ -251,7 +251,7 @@ static int ridingcapacity(unit * u)
** tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er ** tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er
** von zwei Pferden gezogen wird */ ** von zwei Pferden gezogen wird */
animals = _min(animals, effskill(u, SK_RIDING) * u->number * 2); animals = _min(animals, effskill(u, SK_RIDING, 0) * u->number * 2);
if (fval(u_race(u), RCF_HORSE)) if (fval(u_race(u), RCF_HORSE))
animals += u->number; animals += u->number;
@ -275,7 +275,7 @@ int walkingcapacity(const struct unit *u)
/* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches
* die Leute tragen */ * die Leute tragen */
pferde_fuer_wagen = _min(animals, effskill(u, SK_RIDING) * u->number * 4); pferde_fuer_wagen = _min(animals, effskill(u, SK_RIDING, 0) * u->number * 4);
if (fval(u_race(u), RCF_HORSE)) { if (fval(u_race(u), RCF_HORSE)) {
animals += u->number; animals += u->number;
people = 0; people = 0;
@ -338,7 +338,7 @@ static int canwalk(unit * u)
int maxwagen, maxpferde; int maxwagen, maxpferde;
int vehicles = 0, vcap = 0; int vehicles = 0, vcap = 0;
int animals = 0, acap = 0; int animals = 0, acap = 0;
int effsk;
/* workaround: monsters are too stupid to drop items, therefore they have /* workaround: monsters are too stupid to drop items, therefore they have
* infinite carrying capacity */ * infinite carrying capacity */
@ -347,11 +347,12 @@ static int canwalk(unit * u)
get_transporters(u->items, &animals, &acap, &vehicles, &vcap); get_transporters(u->items, &animals, &acap, &vehicles, &vcap);
maxwagen = effskill(u, SK_RIDING) * u->number * 2; effsk = effskill(u, SK_RIDING, 0);
maxwagen = effsk * u->number * 2;
if (u_race(u) == get_race(RC_TROLL)) { if (u_race(u) == get_race(RC_TROLL)) {
maxwagen = _max(maxwagen, u->number / 4); maxwagen = _max(maxwagen, u->number / 4);
} }
maxpferde = effskill(u, SK_RIDING) * u->number * 4 + u->number; maxpferde = effsk * u->number * 4 + u->number;
if (animals > maxpferde) if (animals > maxpferde)
return E_CANWALK_TOOMANYHORSES; return E_CANWALK_TOOMANYHORSES;
@ -375,7 +376,7 @@ static int canwalk(unit * u)
bool canfly(unit * u) bool canfly(unit * u)
{ {
if (i_get(u->items, it_find("pegasus")) >= u->number && effskill(u, SK_RIDING) >= 4) if (i_get(u->items, it_find("pegasus")) >= u->number && effskill(u, SK_RIDING, 0) >= 4)
return true; return true;
if (fval(u_race(u), RCF_FLY)) if (fval(u_race(u), RCF_FLY))
@ -389,7 +390,7 @@ bool canfly(unit * u)
bool canswim(unit * u) bool canswim(unit * u)
{ {
if (i_get(u->items, it_find("dolphin")) >= u->number && effskill(u, SK_RIDING) >= 4) if (i_get(u->items, it_find("dolphin")) >= u->number && effskill(u, SK_RIDING, 0) >= 4)
return true; return true;
if (u_race(u)->flags & RCF_FLY) if (u_race(u)->flags & RCF_FLY)
@ -410,7 +411,7 @@ bool canswim(unit * u)
static int canride(unit * u) static int canride(unit * u)
{ {
int horses = 0, maxhorses, unicorns = 0, maxunicorns; int horses = 0, maxhorses, unicorns = 0, maxunicorns;
int skill = effskill(u, SK_RIDING); int skill = effskill(u, SK_RIDING, 0);
item *itm; item *itm;
const item_type *it_horse, *it_elvenhorse, *it_charger; const item_type *it_horse, *it_elvenhorse, *it_charger;
const resource_type *rtype; const resource_type *rtype;
@ -483,7 +484,7 @@ static ship *do_maelstrom(region * r, unit * u)
int damage; int damage;
ship *sh = u->ship; ship *sh = u->ship;
damage = rng_int() % 75 + rng_int() % 75 - eff_skill(u, SK_SAILING, r) * 4; damage = rng_int() % 75 + rng_int() % 75 - effskill(u, SK_SAILING, r) * 4;
if (damage <= 0) { if (damage <= 0) {
return sh; return sh;
@ -606,7 +607,7 @@ ship *move_ship(ship * sh, region * from, region * to, region_list * route)
ulist = &u->next; ulist = &u->next;
u->ship = sh; /* undo the trick -- do not use u_set_ship here */ u->ship = sh; /* undo the trick -- do not use u_set_ship here */
} }
if (route && eff_skill(u, SK_SAILING, from) >= 1) { if (route && effskill(u, SK_SAILING, from) >= 1) {
produceexp(u, SK_SAILING, u->number); produceexp(u, SK_SAILING, u->number);
} }
} }
@ -739,7 +740,7 @@ static void drifting_ships(region * r)
continue; continue;
if (firstu == NULL) if (firstu == NULL)
firstu = captain; firstu = captain;
if (eff_skill(captain, SK_SAILING, r) >= sh->type->cptskill) { if (effskill(captain, SK_SAILING, r) >= sh->type->cptskill) {
break; break;
} }
} }
@ -869,7 +870,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
return NULL; return NULL;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (is_guard(u, GUARD_TRAVELTHRU)) { if (is_guard(u, GUARD_TRAVELTHRU)) {
int sk = eff_skill(u, SK_PERCEPTION, r); int sk = effskill(u, SK_PERCEPTION, r);
if (invisible(reisender, u) >= reisender->number) if (invisible(reisender, u) >= reisender->number)
continue; continue;
if (!(u_race(u)->flags & RCF_FLY) && u_race(reisender)->flags & RCF_FLY) if (!(u_race(u)->flags & RCF_FLY) && u_race(reisender)->flags & RCF_FLY)
@ -1717,7 +1718,7 @@ static bool ship_ready(const region * r, unit * u)
cmistake(u, u->thisorder, 146, MSG_MOVE); cmistake(u, u->thisorder, 146, MSG_MOVE);
return false; return false;
} }
if (eff_skill(u, SK_SAILING, r) < u->ship->type->cptskill) { if (effskill(u, SK_SAILING, r) < u->ship->type->cptskill) {
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder,
"error_captain_skill_low", "value ship", u->ship->type->cptskill, "error_captain_skill_low", "value ship", u->ship->type->cptskill,
u->ship)); u->ship));
@ -2060,11 +2061,11 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
for (u2 = current_point->units; u2; u2 = u2->next) { for (u2 = current_point->units; u2; u2 = u2->next) {
if (u2->ship == sh && !alliedunit(harbourmaster, u->faction, HELP_GUARD)) { if (u2->ship == sh && !alliedunit(harbourmaster, u->faction, HELP_GUARD)) {
if (effskill(harbourmaster, SK_PERCEPTION) > effskill(u2, SK_STEALTH)) { if (effskill(harbourmaster, SK_PERCEPTION, 0) > effskill(u2, SK_STEALTH, 0)) {
for (itm = u2->items; itm; itm = itm->next) { for (itm = u2->items; itm; itm = itm->next) {
const luxury_type *ltype = resource2luxury(itm->type->rtype); const luxury_type *ltype = resource2luxury(itm->type->rtype);
if (ltype != NULL && itm->number > 0) { if (ltype != NULL && itm->number > 0) {
int st = itm->number * effskill(harbourmaster, SK_TRADE) / 50; int st = itm->number * effskill(harbourmaster, SK_TRADE, 0) / 50;
st = _min(itm->number, st); st = _min(itm->number, st);
if (st > 0) { if (st > 0) {

View File

@ -291,9 +291,9 @@ static void get_allies(region * r, unit * u)
break; break;
} }
else { else {
if (eff_skill(u, SK_LONGBOW, r) < 3 if (effskill(u, SK_LONGBOW, r) < 3
&& eff_skill(u, SK_HERBALISM, r) < 2 && effskill(u, SK_HERBALISM, r) < 2
&& eff_skill(u, SK_MAGIC, r) < 2) { && effskill(u, SK_MAGIC, r) < 2) {
return; return;
} }
name = "random_forest_men"; name = "random_forest_men";
@ -303,7 +303,7 @@ static void get_allies(region * r, unit * u)
break; break;
case T_SWAMP: case T_SWAMP:
if (eff_skill(u, SK_MELEE, r) <= 1) { if (effskill(u, SK_MELEE, r) <= 1) {
return; return;
} }
name = "random_swamp_men"; name = "random_swamp_men";
@ -312,7 +312,7 @@ static void get_allies(region * r, unit * u)
break; break;
case T_DESERT: case T_DESERT:
if (eff_skill(u, SK_RIDING, r) <= 2) { if (effskill(u, SK_RIDING, r) <= 2) {
return; return;
} }
name = "random_desert_men"; name = "random_desert_men";
@ -321,7 +321,7 @@ static void get_allies(region * r, unit * u)
break; break;
case T_HIGHLAND: case T_HIGHLAND:
if (eff_skill(u, SK_MELEE, r) <= 1) { if (effskill(u, SK_MELEE, r) <= 1) {
return; return;
} }
name = "random_highland_men"; name = "random_highland_men";
@ -330,7 +330,7 @@ static void get_allies(region * r, unit * u)
break; break;
case T_MOUNTAIN: case T_MOUNTAIN:
if (eff_skill(u, SK_MELEE, r) <= 1 || eff_skill(u, SK_TRADE, r) <= 2) { if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 2) {
return; return;
} }
name = "random_mountain_men"; name = "random_mountain_men";
@ -339,7 +339,7 @@ static void get_allies(region * r, unit * u)
break; break;
case T_GLACIER: case T_GLACIER:
if (eff_skill(u, SK_MELEE, r) <= 1 || eff_skill(u, SK_TRADE, r) <= 1) { if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 1) {
return; return;
} }
name = "random_glacier_men"; name = "random_glacier_men";

View File

@ -420,7 +420,7 @@ const faction * viewer)
const unit *u; const unit *u;
for (u = r->units; visible != res->amount && u != NULL; u = u->next) { for (u = r->units; visible != res->amount && u != NULL; u = u->next) {
if (u->faction == viewer) { if (u->faction == viewer) {
int s = eff_skill(u, itype->construction->skill, r); int s = effskill(u, itype->construction->skill, 0);
if (s > maxskill) { if (s > maxskill) {
maxskill = s; maxskill = s;
visible = res->type->visible(res, maxskill); visible = res->type->visible(res, maxskill);
@ -515,7 +515,7 @@ size_t size)
bufp = STRLCPY(bufp, ", ", size); bufp = STRLCPY(bufp, ", ", size);
if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1 if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1
&& effskill(u, SK_STEALTH) >= 6) { && effskill(u, SK_STEALTH, 0) >= 6) {
bufp = STRLCPY(bufp, "? ", size); bufp = STRLCPY(bufp, "? ", size);
} }
else { else {
@ -602,7 +602,7 @@ size_t size)
show = u->items; show = u->items;
} }
else if (!itemcloak && mode >= see_unit && !(a_fshidden else if (!itemcloak && mode >= see_unit && !(a_fshidden
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) { && a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH, 0) >= 3)) {
int n = report_items(u->items, results, MAX_INVENTORY, u, f); int n = report_items(u->items, results, MAX_INVENTORY, u, f);
assert(n >= 0); assert(n >= 0);
if (n > 0) if (n > 0)
@ -641,7 +641,7 @@ size_t size)
if (book) { if (book) {
quicklist *ql = book->spells; quicklist *ql = book->spells;
int qi, header, maxlevel = effskill(u, SK_MAGIC); int qi, header, maxlevel = effskill(u, SK_MAGIC, 0);
int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u)); int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
if (wrptr(&bufp, &size, result) != 0) { if (wrptr(&bufp, &size, result) != 0) {
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -810,7 +810,7 @@ const struct unit * u, struct skill * sv, int *dh, int days)
} }
} }
effsk = effskill(u, sv->id); effsk = eff_skill(u, sv, 0);
if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d", effsk)) != 0) if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d", effsk)) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -1351,7 +1351,7 @@ static void view_regatta(struct seen_region **seen, region * r, faction * f)
int skill = 0; int skill = 0;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->faction == f) { if (u->faction == f) {
int es = effskill(u, SK_PERCEPTION); int es = effskill(u, SK_PERCEPTION, 0);
if (es > skill) if (es > skill)
skill = es; skill = es;
} }

View File

@ -2516,7 +2516,7 @@ static int sp_fumblecurse(castorder * co)
target = pa->param[0]->data.u; target = pa->param[0]->data.u;
rx = rng_int() % 3; rx = rng_int() % 3;
sx = cast_level - effskill(target, SK_MAGIC); sx = cast_level - effskill(target, SK_MAGIC, 0);
duration = _max(sx, rx) + 1; duration = _max(sx, rx) + 1;
effect = force / 2; effect = force / 2;
@ -3254,7 +3254,7 @@ static int sp_bloodsacrifice(castorder * co)
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
int aura; int aura;
int skill = eff_skill(mage, SK_MAGIC, mage->region); int skill = effskill(mage, SK_MAGIC, 0);
int hp = (int)(co->force * 8); int hp = (int)(co->force * 8);
if (hp <= 0) { if (hp <= 0) {
@ -3591,11 +3591,11 @@ static int sp_charmingsong(castorder * co)
} }
/* Magieresistensbonus fuer hoehere Talentwerte */ /* Magieresistensbonus fuer hoehere Talentwerte */
for (i = 0; i < MAXSKILLS; i++) { for (i = 0; i < MAXSKILLS; i++) {
int sk = effskill(target, i); int sk = effskill(target, i, 0);
if (tb < sk) if (tb < sk)
tb = sk; tb = sk;
} }
tb -= effskill(mage, SK_MAGIC); tb -= effskill(mage, SK_MAGIC, 0);
if (tb > 0) { if (tb > 0) {
resist_bonus += tb * 15; resist_bonus += tb * 15;
} }
@ -4143,7 +4143,7 @@ static int sp_pump(castorder * co)
create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0, create_unit(rt, mage->faction, RS_FARVISION, get_race(RC_SPELL), 0,
"spell/pump", NULL); "spell/pump", NULL);
u->age = 2; u->age = 2;
set_level(u, SK_PERCEPTION, eff_skill(target, SK_PERCEPTION, u->region)); set_level(u, SK_PERCEPTION, effskill(target, SK_PERCEPTION, 0));
return cast_level; return cast_level;
} }
@ -4795,7 +4795,7 @@ int sp_dreamreading(castorder * co)
"spell/dreamreading", NULL); "spell/dreamreading", NULL);
set_number(u2, 1); set_number(u2, 1);
u2->age = 2; /* Nur fuer diese Runde. */ u2->age = 2; /* Nur fuer diese Runde. */
set_level(u2, SK_PERCEPTION, eff_skill(u, SK_PERCEPTION, u2->region)); set_level(u2, SK_PERCEPTION, effskill(u, SK_PERCEPTION, u2->region));
msg = msg =
msg_message("sp_dreamreading_effect", "mage unit region", mage, u, msg_message("sp_dreamreading_effect", "mage unit region", mage, u,

View File

@ -99,7 +99,7 @@ void spy_message(int spy, const unit * u, const unit * target)
strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale), strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale),
sizeof(buf) - 1); sizeof(buf) - 1);
strncat(buf, " ", sizeof(buf) - 1); strncat(buf, " ", sizeof(buf) - 1);
strncat(buf, itoa10(eff_skill(target, (skill_t)sv->id, target->region)), strncat(buf, itoa10(eff_skill(target, sv, target->region)),
sizeof(buf) - 1); sizeof(buf) - 1);
} }
} }
@ -134,14 +134,14 @@ int spy_cmd(unit * u, struct order *ord)
cmistake(u, u->thisorder, 24, MSG_EVENT); cmistake(u, u->thisorder, 24, MSG_EVENT);
return 0; return 0;
} }
if (eff_skill(u, SK_SPY, r) < 1) { if (effskill(u, SK_SPY, 0) < 1) {
cmistake(u, u->thisorder, 39, MSG_EVENT); cmistake(u, u->thisorder, 39, MSG_EVENT);
return 0; return 0;
} }
/* Die Grundchance fuer einen erfolgreichen Spionage-Versuch ist 10%. /* Die Grundchance fuer einen erfolgreichen Spionage-Versuch ist 10%.
* Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent * Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
* des Opfers uebersteigt, erhoeht sich dieses um 5%*/ * des Opfers uebersteigt, erhoeht sich dieses um 5%*/
spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r); spy = effskill(u, SK_SPY, 0) - effskill(target, SK_STEALTH, r);
spychance = 0.1 + _max(spy * 0.05, 0.0); spychance = 0.1 + _max(spy * 0.05, 0.0);
if (chance(spychance)) { if (chance(spychance)) {
@ -154,8 +154,8 @@ int spy_cmd(unit * u, struct order *ord)
/* der Spion kann identifiziert werden, wenn das Opfer bessere /* der Spion kann identifiziert werden, wenn das Opfer bessere
* Wahrnehmung als das Ziel Tarnung + Spionage/2 hat */ * Wahrnehmung als das Ziel Tarnung + Spionage/2 hat */
observe = eff_skill(target, SK_PERCEPTION, r) observe = effskill(target, SK_PERCEPTION, r)
- (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r) / 2); - (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2);
if (invisible(u, target) >= u->number) { if (invisible(u, target) >= u->number) {
observe = _min(observe, 0); observe = _min(observe, 0);
@ -164,8 +164,8 @@ int spy_cmd(unit * u, struct order *ord)
/* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der /* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der
* Spionageversuch bemerkt wurde. Die Wahrscheinlich dafuer ist (100 - * Spionageversuch bemerkt wurde. Die Wahrscheinlich dafuer ist (100 -
* SpionageSpion*5 + WahrnehmungOpfer*2)%. */ * SpionageSpion*5 + WahrnehmungOpfer*2)%. */
observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05) observechance = 1.0 - (effskill(u, SK_SPY, 0) * 0.05)
+ (eff_skill(target, SK_PERCEPTION, r) * 0.02); + (effskill(target, SK_PERCEPTION, 0) * 0.02);
if (chance(observechance)) { if (chance(observechance)) {
ADDMSG(&target->faction->msgs, msg_message("spydetect", ADDMSG(&target->faction->msgs, msg_message("spydetect",
@ -228,7 +228,7 @@ int setstealth_cmd(unit * u, struct order *ord)
if (isdigit(s[0])) { if (isdigit(s[0])) {
/* Tarnungslevel setzen */ /* Tarnungslevel setzen */
level = atoi((const char *)s); level = atoi((const char *)s);
if (level > effskill(u, SK_STEALTH)) { if (level > effskill(u, SK_STEALTH, 0)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_lowstealth", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_lowstealth", ""));
return 0; return 0;
} }
@ -352,7 +352,7 @@ static int top_skill(region * r, faction * f, ship * sh, skill_t sk)
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->ship == sh && u->faction == f) { if (u->ship == sh && u->faction == f) {
int s = eff_skill(u, sk, r); int s = effskill(u, sk, 0);
value = _max(s, value); value = _max(s, value);
} }
} }
@ -498,7 +498,6 @@ int sabotage_cmd(unit * u, struct order *ord)
param_t p; param_t p;
ship *sh; ship *sh;
unit *u2; unit *u2;
region *r;
int skdiff = INT_MAX; int skdiff = INT_MAX;
assert(u); assert(u);
@ -517,13 +516,12 @@ int sabotage_cmd(unit * u, struct order *ord)
return 0; return 0;
} }
u2 = ship_owner(sh); u2 = ship_owner(sh);
r = u->region;
if (u2->faction != u->faction) { if (u2->faction != u->faction) {
skdiff = skdiff =
eff_skill(u, SK_SPY, r) - top_skill(r, u2->faction, sh, SK_PERCEPTION); effskill(u, SK_SPY, 0) - top_skill(u->region, u2->faction, sh, SK_PERCEPTION);
} }
if (try_destruction(u, u2, sh, skdiff)) { if (try_destruction(u, u2, sh, skdiff)) {
sink_ship(r, sh, u); sink_ship(u->region, sh, u);
} }
break; break;
default: default:

View File

@ -347,8 +347,7 @@ int teach_cmd(unit * u, struct order *ord)
sk = teachskill[i]; sk = teachskill[i];
} }
if (sk != NOSKILL if (sk != NOSKILL
&& eff_skill_study(u, sk, && effskill_study(u, sk, 0) - TEACHDIFFERENCE > effskill_study(student, sk, 0)) {
r) - TEACHDIFFERENCE > eff_skill_study(student, sk, r)) {
teaching -= teach_unit(u, student, teaching, sk, true, &academy); teaching -= teach_unit(u, student, teaching, sk, true, &academy);
} }
} }
@ -366,8 +365,7 @@ int teach_cmd(unit * u, struct order *ord)
init_order(student->thisorder); init_order(student->thisorder);
sk = getskill(student->faction->locale); sk = getskill(student->faction->locale);
if (sk != NOSKILL if (sk != NOSKILL
&& eff_skill_study(u, sk, r) - TEACHDIFFERENCE >= eff_skill(student, && effskill_study(u, sk, 0) - TEACHDIFFERENCE >= effskill(student, sk, 0)) {
sk, r)) {
teaching -= teach_unit(u, student, teaching, sk, true, &academy); teaching -= teach_unit(u, student, teaching, sk, true, &academy);
} }
} }
@ -454,8 +452,8 @@ int teach_cmd(unit * u, struct order *ord)
} }
/* u is teacher, u2 is student */ /* u is teacher, u2 is student */
if (eff_skill_study(u2, sk, r) > eff_skill_study(u, sk, if (effskill_study(u2, sk, 0) > effskill_study(u, sk, 0)
r) - TEACHDIFFERENCE) { - TEACHDIFFERENCE) {
if (feedback) { if (feedback) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "teach_asgood", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "teach_asgood",
"student", u2)); "student", u2));
@ -565,7 +563,7 @@ int study_cmd(unit * u, order * ord)
cmistake(u, ord, 77, MSG_EVENT); cmistake(u, ord, 77, MSG_EVENT);
return 0; return 0;
} }
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) { if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk, 0)) {
cmistake(u, ord, 771, MSG_EVENT); cmistake(u, ord, 771, MSG_EVENT);
return 0; return 0;
} }
@ -684,7 +682,7 @@ int study_cmd(unit * u, order * ord)
} }
} }
if (sk == SK_ALCHEMY) { if (sk == SK_ALCHEMY) {
maxalchemy = eff_skill(u, SK_ALCHEMY, r); maxalchemy = effskill(u, SK_ALCHEMY, 0);
if (!has_skill(u, SK_ALCHEMY)) { if (!has_skill(u, SK_ALCHEMY)) {
int amax = skill_limit(u->faction, SK_ALCHEMY); int amax = skill_limit(u->faction, SK_ALCHEMY);
if (count_skill(u->faction, SK_ALCHEMY) + u->number > amax) { if (count_skill(u->faction, SK_ALCHEMY) + u->number > amax) {
@ -779,7 +777,7 @@ int study_cmd(unit * u, order * ord)
if (feedback) { if (feedback) {
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher", ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
"teacher student skill level", teacher, u, sk, "teacher student skill level", teacher, u, sk,
effskill(u, sk))); effskill(u, sk, 0)));
} }
ADDMSG(&u->faction->msgs, msg_message("teach_student", ADDMSG(&u->faction->msgs, msg_message("teach_student",
"teacher student skill", teacher, u, sk)); "teacher student skill", teacher, u, sk));
@ -796,7 +794,7 @@ int study_cmd(unit * u, order * ord)
if (sk == SK_ALCHEMY) { if (sk == SK_ALCHEMY) {
const potion_type *ptype; const potion_type *ptype;
faction *f = u->faction; faction *f = u->faction;
int skill = eff_skill(u, SK_ALCHEMY, r); int skill = effskill(u, SK_ALCHEMY, 0);
if (skill > maxalchemy) { if (skill > maxalchemy) {
for (ptype = potiontypes; ptype; ptype = ptype->next) { for (ptype = potiontypes; ptype; ptype = ptype->next) {
if (skill == ptype->level * 2) { if (skill == ptype->level * 2) {

View File

@ -440,7 +440,7 @@ summary *make_summary(void)
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) { for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
skill_t sk = sv->id; skill_t sk = sv->id;
int aktskill = eff_skill(u, sk, r); int aktskill = effskill(u, sk, r);
if (aktskill > s->maxskill) if (aktskill > s->maxskill)
s->maxskill = aktskill; s->maxskill = aktskill;
} }