- 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);
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;

View File

@ -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();

View File

@ -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;

View File

@ -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)<n) reduce_skill(sv, 1);
if (rand()%(30*u->number)<n) reduce_skill(u, sv, 1);
n = 0;
}
}

View File

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

View File

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

View File

@ -42,7 +42,7 @@ typedef char direction_t;
typedef int race_t;
typedef int curse_t;
typedef int magic_t;
typedef int skill_t;
typedef short skill_t;
typedef int herb_t;
typedef int potion_t;
typedef int luxury_t;
@ -561,6 +561,7 @@ enum {
O_ADRESSEN, /* 512 */
O_BZIP2, /* 1024 - crkurz compatible flag */
O_SCORE, /* 2048 - punkte anzeigen? */
O_SHOWSKCHANGE, /* 4096 - Skillveränderungen anzeigen? */
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)];
break;
case 't':
args[i] = (void*)va_arg(marker, skill_t);
args[i] = (void*)va_arg(marker, int);
break;
case 'd':
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)
{
char * sbuf = buf+strlen(buf);
int i;
int i, effsk;
if (!u->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
}

View File

@ -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

View File

@ -30,6 +30,7 @@
#include "curse.h"
#include "region.h"
#include "karma.h"
#include "attrib.h"
/* libc includes */
#include <assert.h>
@ -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);
}

View File

@ -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

View File

@ -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, "");

View File

@ -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;

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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;

View File

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

View File

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