Peniblere skillchecks.

Bugfix für die Dämonen.
Retro-Fix für die Auswertung fehlt noch, kommt morgen.
Bugfix 0-hp Personen in Vulkaneruptionen.
This commit is contained in:
Enno Rehling 2002-03-11 00:06:14 +00:00
parent 40cc9a2d9a
commit 0faa820456
6 changed files with 35 additions and 14 deletions

View File

@ -2168,7 +2168,7 @@ display_item(faction *f, unit *u, const item_type * itype)
FILE *fp;
char t[NAMESIZE + 1];
char filename[MAX_PATH];
const char *name, *info;
const char *name;
if (u && *i_find(&u->items, itype) == NULL) return false;
/*

View File

@ -728,7 +728,6 @@ volcano_outbreak(region *r)
attrib *a;
region *rn;
unit *u, **up;
int dead;
faction *f;
for (u=r->units; u; u=u->next) {
@ -759,7 +758,7 @@ volcano_outbreak(region *r)
for (up=&r->units; *up;) {
unit * u = *up;
dead = damage_unit(u, "4d10", true, false);
int dead = damage_unit(u, "4d10", true, false);
if (dead) {
ADDMSG(&u->faction->msgs, new_message(u->faction,
"volcano_dead%u:unit%r:region%i:dead", u, r, dead));
@ -802,7 +801,7 @@ volcano_outbreak(region *r)
/* Personen bekommen 3W10 Punkte Schaden. */
for (up=&rn->units; *up;) {
unit * u = *up;
dead = damage_unit(u, "3d10", true, false);
int dead = damage_unit(u, "3d10", true, false);
if (dead) {
ADDMSG(&u->faction->msgs, new_message(u->faction,
"volcano_dead%u:unit%r:region%i:dead", u, rn, dead));
@ -1136,11 +1135,7 @@ randomevents(void)
* Es ist auch deshalb fast egal, weil es ja im Grunde nicht dem Dämon,
* sondern der Region zu gute kommt - und da ist der anwender schnuppe
*/
#if SKILLPOINTS
skill_t sk;
#else
skill * sv;
#endif
int dc;
if (!bfind) {
unit * ud = u;
@ -1178,8 +1173,8 @@ randomevents(void)
dc = max(0, dc);
sv = u->skills;
while (sv!=u->skills+u->skill_size) {
if (rand() % 100 < 25) {
int weeks = 0+rand()%3;
if (sv->level>0 && rand() % 100 < 25) {
int weeks = 1+rand()%3;
if (rand() % 100 < 40) reduce_skill(u, sv, weeks);
else while (weeks--) learn_skill(u, sv->id, 1.0);
}

View File

@ -307,6 +307,7 @@ sk_set(skill * sv, int level)
void
sk_set(skill * sv, int level)
{
assert(level!=0);
sv->weeks = (unsigned char)skill_weeks(level);
sv->level = (unsigned char)level;
}

View File

@ -507,17 +507,21 @@ get_level(const unit * u, skill_t id)
}
void
set_level(unit * u, skill_t id, int value)
set_level(unit * u, skill_t sk, int value)
{
skill * sv = u->skills;
if (value==0) {
remove_skill(u, sk);
return;
}
while (sv != u->skills + u->skill_size) {
if (sv->id == id) {
if (sv->id == sk) {
sk_set(sv, value);
return;
}
++sv;
}
sk_set(add_skill(u, id), value);
sk_set(add_skill(u, sk), value);
}
static attrib_type at_leftship = {
@ -698,7 +702,8 @@ transfermen(unit * u, unit * u2, int n)
sn->weeks = (unsigned char)weeks;
assert(sn->weeks>0 && sn->weeks<=sn->level*2+1);
} else if (sn) {
sk_set(sn, 0);
remove_skill(u2, sk);
sn = NULL;
}
}
a = a_find(u->attribs, &at_effect);
@ -840,6 +845,22 @@ learn_skill(unit * u, skill_t sk, double chance)
return true;
}
void
remove_skill(unit *u, skill_t sk)
{
skill * sv = u->skills;
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
if (sv->id==sk) {
skill * sl = u->skills + u->skill_size - 1;
if (sl!=sv) {
*sv = *sl;
}
--u->skill_size;
return;
}
}
}
skill *
add_skill(unit * u, skill_t id)
{

View File

@ -111,6 +111,7 @@ extern const struct unit u_unknown;
extern struct unit * udestroy;
extern struct skill * add_skill(struct unit * u, skill_t id);
extern void remove_skill(struct unit *u, skill_t sk);
extern struct skill * get_skill(const struct unit * u, skill_t id);
extern boolean has_skill(const unit* u, skill_t sk);

View File

@ -1203,6 +1203,9 @@ stats(void)
for (u=r->units;u;u=u->next) {
for (itm=u->items;itm;itm=itm->next) {
if (itm->number>10000000) {
itm->number=1;
}
i_change(&items, itm->type, itm->number);
}
}