- OPTION TALENTVERSCHIEBUNG

- Bugfixes
This commit is contained in:
Christian Schlittchen 2002-02-22 19:41:20 +00:00
parent 489cb20b62
commit 6ef723f412
20 changed files with 98 additions and 36 deletions

View File

@ -247,7 +247,7 @@ change_level(unit * u, skill_t sk, int bylevel)
{ {
skill * sv = get_skill(u, sk); skill * sv = get_skill(u, sk);
assert(bylevel>0); assert(bylevel>0);
if (sv==0) set_skill(u, sk, bylevel, 0); if (sv==0) set_skill(u, sk, bylevel, 0, false);
else { else {
sv->level = (unsigned char)(sv->level+bylevel); sv->level = (unsigned char)(sv->level+bylevel);
sv->learning = 0; sv->learning = 0;

View File

@ -394,7 +394,7 @@ live(region * r)
} /* bestes Talent raussuchen */ } /* bestes Talent raussuchen */
if (sb!=NULL) { if (sb!=NULL) {
int weeks = min(effect, u->number); int weeks = min(effect, u->number);
reduce_skill(sb, weeks); reduce_skill(u, sb, weeks);
ADDMSG(&u->faction->msgs, msg_message("dumbeffect", ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
"unit weeks skill", u, weeks, (skill_t)sb->id)); "unit weeks skill", u, weeks, (skill_t)sb->id));
} /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */
@ -3394,6 +3394,7 @@ processorders (void)
puts(" - Zaubern"); puts(" - Zaubern");
magic(); magic();
remove_empty_units();
puts(" - Lehren"); puts(" - Lehren");
teaching(); teaching();

View File

@ -1038,7 +1038,7 @@ godcurse(void)
skill * sv = u->skills; skill * sv = u->skills;
while (sv!=u->skills+u->skill_size) { while (sv!=u->skills+u->skill_size) {
int weeks = 1+rand()%3; int weeks = 1+rand()%3;
reduce_skill(sv, weeks); reduce_skill(u, sv, weeks);
++sv; ++sv;
} }
#endif #endif
@ -1211,7 +1211,7 @@ randomevents(void)
while (sv!=u->skills+u->skill_size) { while (sv!=u->skills+u->skill_size) {
if (rand() % 100 < 25) { if (rand() % 100 < 25) {
int weeks = 0+rand()%3; 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); else while (weeks--) learn_skill(u, sv->id, 1.0);
} }
++sv; ++sv;

View File

@ -992,10 +992,10 @@ drain_exp(unit *u, int n)
skill * sv = get_skill(u, sk); skill * sv = get_skill(u, sk);
while (n>0) { while (n>0) {
if (n>=30*u->number) { if (n>=30*u->number) {
reduce_skill(sv, 1); reduce_skill(u, sv, 1);
n-=30; n-=30;
} else { } else {
if (rand()%(30*u->number)<n) reduce_skill(sv, 1); if (rand()%(30*u->number)<n) reduce_skill(u, sv, 1);
n = 0; n = 0;
} }
} }

View File

@ -546,10 +546,10 @@ sp_mindblast(fighter * fi, int level, int power, spell * sp)
skill * sv = get_skill(du, sk); skill * sv = get_skill(du, sk);
while (n>0) { while (n>0) {
if (n>=30*du->number) { if (n>=30*du->number) {
reduce_skill(sv, 1); reduce_skill(du, sv, 1);
n-=30; n-=30;
} else { } else {
if (rand()%(30*du->number)<n) reduce_skill(sv, 1); if (rand()%(30*du->number)<n) reduce_skill(du, sv, 1);
n = 0; n = 0;
} }
} }

View File

@ -271,7 +271,8 @@ const char *options[MAXOPTIONS] =
"MATERIALPOOL", "MATERIALPOOL",
"ADRESSEN", "ADRESSEN",
"BZIP2", "BZIP2",
"PUNKTE" "PUNKTE",
"SHOWSKCHANGE"
}; };
int int

View File

@ -42,7 +42,7 @@ typedef char direction_t;
typedef int race_t; typedef int race_t;
typedef int curse_t; typedef int curse_t;
typedef int magic_t; typedef int magic_t;
typedef int skill_t; typedef short skill_t;
typedef int herb_t; typedef int herb_t;
typedef int potion_t; typedef int potion_t;
typedef int luxury_t; typedef int luxury_t;
@ -561,6 +561,7 @@ enum {
O_ADRESSEN, /* 512 */ O_ADRESSEN, /* 512 */
O_BZIP2, /* 1024 - crkurz compatible flag */ O_BZIP2, /* 1024 - crkurz compatible flag */
O_SCORE, /* 2048 - punkte anzeigen? */ O_SCORE, /* 2048 - punkte anzeigen? */
O_SHOWSKCHANGE, /* 4096 - Skillveränderungen anzeigen? */
MAXOPTIONS MAXOPTIONS
}; };

View File

@ -456,7 +456,7 @@ new_message(struct faction * receiver, const char* sig, ...)
args[i] = (void*)oldresourcetype[(resource_t)va_arg(marker, resource_t)]; args[i] = (void*)oldresourcetype[(resource_t)va_arg(marker, resource_t)];
break; break;
case 't': case 't':
args[i] = (void*)va_arg(marker, skill_t); args[i] = (void*)va_arg(marker, int);
break; break;
case 'd': case 'd':
args[i] = (void*)i; args[i] = (void*)i;

View File

@ -599,7 +599,8 @@ spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh,
boolean days) boolean days)
{ {
char * sbuf = buf+strlen(buf); char * sbuf = buf+strlen(buf);
int i; int i, effsk;
if (!u->number) if (!u->number)
return; 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/", i);
} }
} }
sbuf += sprintf(sbuf, "%d", effskill(u, sk));
#if SKILLPOINTS effsk = effskill(u, sk);
sbuf += sprintf(sbuf, "%d", effsk);
#if SKILLPOINTS == 1
if (days) { if (days) {
assert(u->number); assert(u->number);
sbuf += sprintf(sbuf, " [%d]", get_skill(u, sk) / 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 #endif
} }

View File

@ -1472,14 +1472,14 @@ readgame(boolean backup)
int lvl = level(skill); int lvl = level(skill);
int weeks = (skill - level_days(lvl))/30; int weeks = (skill - level_days(lvl))/30;
if (weeks || lvl) { if (weeks || lvl) {
set_skill(u, sk, lvl, 2*weeks); set_skill(u, sk, lvl, 2*weeks, true);
} }
} }
} else { } else {
while ((sk = (skill_t) ri(F)) != NOSKILL) { while ((sk = (skill_t) ri(F)) != NOSKILL) {
int level = ri(F); int level = ri(F);
int weeks = ri(F); int weeks = ri(F);
set_skill(u, sk, level, weeks); set_skill(u, sk, level, weeks, true);
} }
} }
#endif #endif

View File

@ -30,6 +30,7 @@
#include "curse.h" #include "curse.h"
#include "region.h" #include "region.h"
#include "karma.h" #include "karma.h"
#include "attrib.h"
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
@ -257,13 +258,16 @@ level(int days)
#if !SKILLPOINTS #if !SKILLPOINTS
void void
reduce_skill(skill * sv, int change) reduce_skill(unit *u, skill * sv, int change)
{ {
if (sv->learning>=change) { if (sv->learning>=change) {
/* just forget a few weeks */ /* just forget a few weeks */
sv->learning = (unsigned char)(sv->learning-change); sv->learning = (unsigned char)(sv->learning-change);
} else { } else {
int weeks; int weeks;
unsigned char oldlevel = sv->level;
attrib *a;
change -= sv->learning; change -= sv->learning;
while (change>=sv->level && sv->level > 0) { while (change>=sv->level && sv->level > 0) {
change -= sv->level; change -= sv->level;
@ -279,6 +283,18 @@ reduce_skill(skill * sv, int change)
weeks = 0; weeks = 0;
} }
sv->learning = (unsigned char)weeks; 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); assert(sv->level>=0 && sv->learning>=0 && sv->learning<=sv->level*2);
} }

View File

@ -57,7 +57,7 @@ extern int level(int days);
# define skill_level(level) level_days(level) # define skill_level(level) level_days(level)
#else #else
# define skill_level(level) (level) # 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); extern int skill_compare(const skill * sk, const skill * sc);
#endif #endif

View File

@ -144,7 +144,7 @@ do_shock(unit *u, char *reason)
if(rand()%10 < 2) { if(rand()%10 < 2) {
for (sk=0; sk < MAXSKILLS; sk++) { for (sk=0; sk < MAXSKILLS; sk++) {
int n = get_skill(u, 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 #else
@ -152,7 +152,7 @@ do_shock(unit *u, char *reason)
skill * sv = u->skills+i; skill * sv = u->skills+i;
int weeks = (sv->level * sv->level - sv->level) / 2 + sv->learning; int weeks = (sv->level * sv->level - sv->level) / 2 + sv->learning;
int change = (weeks+9) / 10; int change = (weeks+9) / 10;
reduce_skill(sv, change); reduce_skill(u, sv, change);
} }
#endif #endif
@ -4699,7 +4699,7 @@ sp_headache(castorder *co)
if (smax!=NULL) { if (smax!=NULL) {
/* wirkt auf maximal 10 Personen */ /* wirkt auf maximal 10 Personen */
int change = min(10, target->number) * (rand()%2+1) / target->number; int change = min(10, target->number) * (rand()%2+1) / target->number;
reduce_skill(smax, change); reduce_skill(target, smax, change);
} }
#endif #endif
set_string(&target->thisorder, ""); set_string(&target->thisorder, "");

View File

@ -777,7 +777,7 @@ transfermen(unit * u, unit * u2, int n)
skill * sv; skill * sv;
for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) { for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) {
if (u2->number == 0) { if (u2->number == 0) {
set_skill(u2, sv->id, sv->level, sv->learning); set_skill(u2, sv->id, sv->level, sv->learning, false);
} else { } else {
skill * sn = get_skill(u2, sv->id); skill * sn = get_skill(u2, sv->id);
if (sn) { if (sn) {
@ -919,6 +919,11 @@ set_number(unit * u, int count)
} }
#if !SKILLPOINTS #if !SKILLPOINTS
attrib_type at_showskchange = {
"showskchange", NULL, NULL, NULL, NULL, NULL
};
boolean boolean
learn_skill(unit * u, skill_t sk, double chance) 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 (rand()%2==0) --heads;
if (heads>coins) break; if (heads>coins) break;
} }
if (heads) ++weeks; if (heads) {
else ++level; ++weeks;
if (!sv) {
set_skill(u, sk, level, weeks);
} else { } else {
sv->level = (unsigned char)level; ++level;
sv->learning = (unsigned char)weeks; weeks = 0;
} }
set_skill(u, sk, level, weeks, false);
return heads==0; return heads==0;
} }
void 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; skill *i = u->skills;
unsigned char oldlevel = 0;
assert(level>=0 && weeks>=0 && weeks<=level*2); assert(level>=0 && weeks>=0 && weeks<=level*2);
for (; i != u->skills + u->skill_size; ++i) { for (; i != u->skills + u->skill_size; ++i) {
if (i->id == id) { if (i->id == id) {
oldlevel = i->level;
if (level || weeks) { if (level || weeks) {
i->level = (unsigned char)level; i->level = (unsigned char)level;
i->learning = (unsigned char)weeks; i->learning = (unsigned char)weeks;
@ -967,7 +974,23 @@ set_skill(unit * u, skill_t id, int level, int weeks)
} }
return; 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; return;
} }
++u->skill_size; ++u->skill_size;

View File

@ -73,6 +73,7 @@ extern attrib_type at_potionuser;
extern attrib_type at_contact; extern attrib_type at_contact;
extern attrib_type at_effect; extern attrib_type at_effect;
extern attrib_type at_private; extern attrib_type at_private;
extern attrib_type at_showskchange;
int ualias(const struct unit * u); 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 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)); #define change_level(u, sk, bylevel) set_level(u, sk, max(0,get_level(u,sk)+bylevel));
#else #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 struct skill * get_skill(const struct unit * u, skill_t id);
extern boolean has_skill(const unit* u, skill_t sk); extern boolean has_skill(const unit* u, skill_t sk);
#endif #endif

View File

@ -192,7 +192,7 @@ use_wand_of_tears(unit * user, const struct item_type * itype, const char * cmd)
#if SKILLPOINTS #if SKILLPOINTS
change_skill(u, u->skills[i].id, -10); change_skill(u, u->skills[i].id, -10);
#else #else
if (rand()%3) reduce_skill(u->skills+i, 1); if (rand()%3) reduce_skill(u, u->skills+i, 1);
#endif #endif
} }
if (k) ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect", if (k) ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect",

View File

@ -21,8 +21,8 @@
#define REMOVENMRNEWBIE 1 #define REMOVENMRNEWBIE 1
#define REMOVENMRTIMEOUT 1 #define REMOVENMRTIMEOUT 1
#define HUNGER_DISABLES_LONGORDERS 1 #define HUNGER_DISABLES_LONGORDERS 1
#define REDUCED_PEASANTGROWTH 0 #define REDUCED_PEASANTGROWTH 1
#define RACE_ADJUSTMENTS 1 #define RACE_ADJUSTMENTS 1
#define TEACHDIFFERENCE 1 #define TEACHDIFFERENCE 2
#define PEASANT_ADJUSTMENT 1 #define PEASANT_ADJUSTMENT 1
#define SKILLPOINTS 1 #define SKILLPOINTS 0

View File

@ -299,7 +299,7 @@ change_level(unit * u, skill_t sk, int bylevel)
{ {
skill * sv = get_skill(u, sk); skill * sv = get_skill(u, sk);
assert(bylevel>0); assert(bylevel>0);
if (sv==0) set_skill(u, sk, bylevel, 0); if (sv==0) set_skill(u, sk, bylevel, 0, true);
else { else {
sv->level = (unsigned char)(sv->level+bylevel); sv->level = (unsigned char)(sv->level+bylevel);
sv->learning = 0; sv->learning = 0;

View File

@ -193,6 +193,9 @@
<string name="PUNKTE"> <string name="PUNKTE">
<text locale="de">PUNKTE</text> <text locale="de">PUNKTE</text>
</string> </string>
<string name="SHOWSKCHANGE">
<text locale="de">TALENTVERSCHIEBUNGEN</text>
</string>
<comment>Schiffstypen</comment> <comment>Schiffstypen</comment>
<string name="balloon_a"> <string name="balloon_a">

View File

@ -41,6 +41,9 @@
<string name="ZUGVORLAGE"> <string name="ZUGVORLAGE">
<text locale="en">TEMPLATE</text> <text locale="en">TEMPLATE</text>
</string> </string>
<string name="SHOWSKCHANGE">
<text locale="en">SKILLCHANGES</text>
</string>
<string name="INFO"> <string name="INFO">
<text locale="en">INFO</text> <text locale="en">INFO</text>