diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 6b0b2b243..c03542ff8 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -247,7 +247,7 @@ change_level(unit * u, skill_t sk, int bylevel) { skill * sv = get_skill(u, sk); assert(bylevel>0); - if (sv==0) set_skill(u, sk, bylevel, 0); + if (sv==0) set_skill(u, sk, bylevel, 0, false); else { sv->level = (unsigned char)(sv->level+bylevel); sv->learning = 0; diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index b92e85b9e..7163e65dc 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -394,7 +394,7 @@ live(region * r) } /* bestes Talent raussuchen */ if (sb!=NULL) { int weeks = min(effect, u->number); - reduce_skill(sb, weeks); + reduce_skill(u, sb, weeks); ADDMSG(&u->faction->msgs, msg_message("dumbeffect", "unit weeks skill", u, weeks, (skill_t)sb->id)); } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ @@ -3394,6 +3394,7 @@ processorders (void) puts(" - Zaubern"); magic(); + remove_empty_units(); puts(" - Lehren"); teaching(); diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 5f6fac0d0..f595f8d73 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -1038,7 +1038,7 @@ godcurse(void) skill * sv = u->skills; while (sv!=u->skills+u->skill_size) { int weeks = 1+rand()%3; - reduce_skill(sv, weeks); + reduce_skill(u, sv, weeks); ++sv; } #endif @@ -1211,7 +1211,7 @@ randomevents(void) while (sv!=u->skills+u->skill_size) { if (rand() % 100 < 25) { int weeks = 0+rand()%3; - if (rand() % 100 < 40) reduce_skill(sv, weeks); + if (rand() % 100 < 40) reduce_skill(u, sv, weeks); else while (weeks--) learn_skill(u, sv->id, 1.0); } ++sv; diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 5c480508e..4b84d60cc 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -992,10 +992,10 @@ drain_exp(unit *u, int n) skill * sv = get_skill(u, sk); while (n>0) { if (n>=30*u->number) { - reduce_skill(sv, 1); + reduce_skill(u, sv, 1); n-=30; } else { - if (rand()%(30*u->number)number)0) { if (n>=30*du->number) { - reduce_skill(sv, 1); + reduce_skill(du, sv, 1); n-=30; } else { - if (rand()%(30*du->number)number)number) return; @@ -625,13 +626,25 @@ spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, sbuf += sprintf(sbuf, "%d/", i); } } - sbuf += sprintf(sbuf, "%d", effskill(u, sk)); -#if SKILLPOINTS + effsk = effskill(u, sk); + sbuf += sprintf(sbuf, "%d", effsk); + +#if SKILLPOINTS == 1 if (days) { assert(u->number); sbuf += sprintf(sbuf, " [%d]", get_skill(u, sk) / u->number); } +#else + if(effsk > 0 && u->faction->options & Pow(O_SHOWSKCHANGE)) { + attrib *a; + for(a = a_find(u->attribs,&at_showskchange); a; a=a->nexttype) { + if(a->data.sa[0] == sk) { + sbuf += sprintf(sbuf, " (%s%hd)", (a->data.sa[1]>0)?"+":"", a->data.sa[1]); + break; + } + } + } #endif } diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index c5221986f..8b6e668f7 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1472,14 +1472,14 @@ readgame(boolean backup) int lvl = level(skill); int weeks = (skill - level_days(lvl))/30; if (weeks || lvl) { - set_skill(u, sk, lvl, 2*weeks); + set_skill(u, sk, lvl, 2*weeks, true); } } } else { while ((sk = (skill_t) ri(F)) != NOSKILL) { int level = ri(F); int weeks = ri(F); - set_skill(u, sk, level, weeks); + set_skill(u, sk, level, weeks, true); } } #endif diff --git a/src/common/kernel/skill.c b/src/common/kernel/skill.c index c91536307..f96ca020d 100644 --- a/src/common/kernel/skill.c +++ b/src/common/kernel/skill.c @@ -30,6 +30,7 @@ #include "curse.h" #include "region.h" #include "karma.h" +#include "attrib.h" /* libc includes */ #include @@ -257,13 +258,16 @@ level(int days) #if !SKILLPOINTS void -reduce_skill(skill * sv, int change) +reduce_skill(unit *u, skill * sv, int change) { if (sv->learning>=change) { /* just forget a few weeks */ sv->learning = (unsigned char)(sv->learning-change); } else { int weeks; + unsigned char oldlevel = sv->level; + attrib *a; + change -= sv->learning; while (change>=sv->level && sv->level > 0) { change -= sv->level; @@ -279,6 +283,18 @@ reduce_skill(skill * sv, int change) weeks = 0; } sv->learning = (unsigned char)weeks; + + for(a = a_find(u->attribs, &at_showskchange);a;a = a->nexttype) { + if(a->data.sa[0] == sv->id) { + a->data.sa[1] = (short)(a->data.sa[1] + (sv->level-oldlevel)); + break; + } + } + if(a == NULL) { + a = a_add(&u->attribs, a_new(&at_showskchange)); + a->data.sa[0] = sv->id; + a->data.sa[1] = (short)(sv->level-oldlevel); + } } assert(sv->level>=0 && sv->learning>=0 && sv->learning<=sv->level*2); } diff --git a/src/common/kernel/skill.h b/src/common/kernel/skill.h index de468064f..6710cb7ff 100644 --- a/src/common/kernel/skill.h +++ b/src/common/kernel/skill.h @@ -57,7 +57,7 @@ extern int level(int days); # define skill_level(level) level_days(level) #else # define skill_level(level) (level) -extern void reduce_skill(skill * sv, int change); +extern void reduce_skill(struct unit *u, skill * sv, int change); extern int skill_compare(const skill * sk, const skill * sc); #endif diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index b4508e73e..209809630 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -144,7 +144,7 @@ do_shock(unit *u, char *reason) if(rand()%10 < 2) { for (sk=0; sk < MAXSKILLS; sk++) { int n = get_skill(u, sk); - if (n!=0) set_skill(u, sk, (n*9)/10); + if (n!=0) set_skill(u, sk, (n*9)/10, false); } } #else @@ -152,7 +152,7 @@ do_shock(unit *u, char *reason) skill * sv = u->skills+i; int weeks = (sv->level * sv->level - sv->level) / 2 + sv->learning; int change = (weeks+9) / 10; - reduce_skill(sv, change); + reduce_skill(u, sv, change); } #endif @@ -4699,7 +4699,7 @@ sp_headache(castorder *co) if (smax!=NULL) { /* wirkt auf maximal 10 Personen */ int change = min(10, target->number) * (rand()%2+1) / target->number; - reduce_skill(smax, change); + reduce_skill(target, smax, change); } #endif set_string(&target->thisorder, ""); diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index d72286f77..13995b8d6 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -777,7 +777,7 @@ transfermen(unit * u, unit * u2, int n) skill * sv; for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) { if (u2->number == 0) { - set_skill(u2, sv->id, sv->level, sv->learning); + set_skill(u2, sv->id, sv->level, sv->learning, false); } else { skill * sn = get_skill(u2, sv->id); if (sn) { @@ -919,6 +919,11 @@ set_number(unit * u, int count) } #if !SKILLPOINTS + +attrib_type at_showskchange = { + "showskchange", NULL, NULL, NULL, NULL, NULL +}; + boolean learn_skill(unit * u, skill_t sk, double chance) { @@ -939,25 +944,27 @@ learn_skill(unit * u, skill_t sk, double chance) if (rand()%2==0) --heads; if (heads>coins) break; } - if (heads) ++weeks; - else ++level; - if (!sv) { - set_skill(u, sk, level, weeks); + if (heads) { + ++weeks; } else { - sv->level = (unsigned char)level; - sv->learning = (unsigned char)weeks; + ++level; + weeks = 0; } + set_skill(u, sk, level, weeks, false); return heads==0; } void -set_skill(unit * u, skill_t id, int level, int weeks) +set_skill(unit * u, skill_t id, int level, int weeks, boolean load) { + attrib *a; skill *i = u->skills; + unsigned char oldlevel = 0; assert(level>=0 && weeks>=0 && weeks<=level*2); for (; i != u->skills + u->skill_size; ++i) { if (i->id == id) { + oldlevel = i->level; if (level || weeks) { i->level = (unsigned char)level; i->learning = (unsigned char)weeks; @@ -967,7 +974,23 @@ set_skill(unit * u, skill_t id, int level, int weeks) } return; } - } if (!level && !weeks) { + } + + if(load == false) { + for(a = a_find(u->attribs, &at_showskchange);a;a = a->nexttype) { + if(a->data.sa[0] == id) { + a->data.sa[1] = (short)(a->data.sa[1] + (level-oldlevel)); + break; + } + } + if(a == NULL) { + a = a_add(&u->attribs, a_new(&at_showskchange)); + a->data.sa[0] = id; + a->data.sa[1] = (short)(level-oldlevel); + } + } + + if (!level && !weeks) { return; } ++u->skill_size; diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index 56eba2544..f5ed6b403 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -73,6 +73,7 @@ extern attrib_type at_potionuser; extern attrib_type at_contact; extern attrib_type at_effect; extern attrib_type at_private; +extern attrib_type at_showskchange; int ualias(const struct unit * u); @@ -116,7 +117,7 @@ extern int get_skill(const struct unit * u, skill_t id); #define has_skill(u, id) (get_skill(u, id)>0) #define change_level(u, sk, bylevel) set_level(u, sk, max(0,get_level(u,sk)+bylevel)); #else -extern void set_skill(struct unit * u, skill_t id, int level, int weeks); +extern void set_skill(struct unit * u, skill_t id, int level, int weeks, boolean load); extern struct skill * get_skill(const struct unit * u, skill_t id); extern boolean has_skill(const unit* u, skill_t sk); #endif diff --git a/src/common/modules/arena.c b/src/common/modules/arena.c index 8fd503ba8..630421e1e 100644 --- a/src/common/modules/arena.c +++ b/src/common/modules/arena.c @@ -192,7 +192,7 @@ use_wand_of_tears(unit * user, const struct item_type * itype, const char * cmd) #if SKILLPOINTS change_skill(u, u->skills[i].id, -10); #else - if (rand()%3) reduce_skill(u->skills+i, 1); + if (rand()%3) reduce_skill(u, u->skills+i, 1); #endif } if (k) ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect", diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index ef7dc2ce9..449bcd2bf 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -21,8 +21,8 @@ #define REMOVENMRNEWBIE 1 #define REMOVENMRTIMEOUT 1 #define HUNGER_DISABLES_LONGORDERS 1 -#define REDUCED_PEASANTGROWTH 0 +#define REDUCED_PEASANTGROWTH 1 #define RACE_ADJUSTMENTS 1 -#define TEACHDIFFERENCE 1 +#define TEACHDIFFERENCE 2 #define PEASANT_ADJUSTMENT 1 -#define SKILLPOINTS 1 +#define SKILLPOINTS 0 diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index b06ff4033..70c7e63ab 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -299,7 +299,7 @@ change_level(unit * u, skill_t sk, int bylevel) { skill * sv = get_skill(u, sk); assert(bylevel>0); - if (sv==0) set_skill(u, sk, bylevel, 0); + if (sv==0) set_skill(u, sk, bylevel, 0, true); else { sv->level = (unsigned char)(sv->level+bylevel); sv->learning = 0; diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 61bd95625..763fcab45 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -193,6 +193,9 @@ PUNKTE + + TALENTVERSCHIEBUNGEN + Schiffstypen diff --git a/src/res/en/strings.xml b/src/res/en/strings.xml index a49c5f25f..cb488e337 100644 --- a/src/res/en/strings.xml +++ b/src/res/en/strings.xml @@ -41,6 +41,9 @@ TEMPLATE + + SKILLCHANGES + INFO