Bugfix Dämonenverschiebung

Bugfix Dämonenfressen
Bugfix Allianzcode
This commit is contained in:
Enno Rehling 2002-10-08 06:46:03 +00:00
parent 92941d03e1
commit 5db83f6217
9 changed files with 43 additions and 31 deletions

View File

@ -1049,7 +1049,6 @@ randomevents(void)
region *r;
building *b, *b2;
unit *u;
int unfed;
/* Eiseberge */
for (r=regions; r; r=r->next) freset(r, RF_DH);
@ -1152,7 +1151,6 @@ randomevents(void)
* sondern der Region zu gute kommt - und da ist der anwender schnuppe
*/
skill * sv;
int dc;
if (!bfind) {
unit * ud = u;
while (ud) {
@ -1163,14 +1161,25 @@ randomevents(void)
bfind = true;
}
if (r->planep==0 || !fval(r->planep, PFL_NOFEED)) {
unfed = (u->number - bauernblut) - peasantfood;
bauernblut = max(0, bauernblut-u->number);
if (unfed > 0) {
int demons = u->number;
if (bauernblut>=demons) {
bauernblut -= demons;
demons = 0;
} else if (bauernblut) {
demons-=bauernblut;
}
if (peasantfood>=demons) {
peasantfood -= demons;
demons = 0;
} else {
demons-=peasantfood;
}
if (demons > 0) {
#ifdef DAEMON_HUNGER
hunger(u, unfed); /* nicht gefütterte dämonen hungern */
hunger(u, demons); /* nicht gefütterte dämonen hungern */
#else
c = 0;
for (n = 0; n < unfed; n++) {
for (n = 0; n != demons; n++) {
if (rand() % 100 < 10) {
c++;
}
@ -1184,16 +1193,15 @@ randomevents(void)
#endif
}
}
dc = max(u->number - bauernblut, 0);
dc = min(dc, peasantfood);
dc = peasantfood - max(u->number - bauernblut, 0);
dc = max(0, dc);
sv = u->skills;
while (sv!=u->skills+u->skill_size) {
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);
if (rand() % 100 < 40) {
reduce_skill(u, sv, weeks);
} else {
while (weeks--) learn_skill(u, sv->id, 1.0);
}
}
++sv;
}

View File

@ -1811,7 +1811,7 @@ list_address(FILE * F, const faction * uf, const faction_list * seenfactions)
const faction * f = flist->data;
if (f->no!=MONSTER_FACTION) {
sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner);
rparagraph(F, buf, 4, ALLIED(uf, f)?'+':'*');
rparagraph(F, buf, 4, (char)(ALLIED(uf, f)?'+':'*'));
}
flist = flist->next;
}

View File

@ -402,8 +402,6 @@ b_namequestportal(const border * b, const region * r, const struct faction * f,
return "gewaltiges offenes Tor";
}
}
return "";
}
border_type bt_questportal = {

View File

@ -1294,10 +1294,9 @@ use_oldresource(region * r, const resource_type * rtype, int norders)
#if GROWING_TREES
int avail_grownup = rtrees(r,2);
int avail_young = rtrees(r,1);
int avail = avail_grownup + avail_young;
int wcount;
assert(norders <= avail);
assert(norders <= avail_grownup + avail_young);
if(norders <= avail_grownup) {
rsettrees(r, 2, avail_grownup-norders);

View File

@ -887,6 +887,7 @@ get_addresses(const faction * f, const seen_region * seenregions)
}
#ifdef ALLIANCES
if(f->alliance != NULL) {
faction * f2;
for(f2 = factions; f2; f2 = f2->next) {
if(f2->alliance != NULL && f2->alliance == f->alliance) {
faction_list ** fnew = &flist;

View File

@ -1524,6 +1524,7 @@ readunit(FILE * F)
} else {
rs(F, buf);
if (strcmp(buf, "giant turtle")==0) strcpy(buf, "giantturtle");
if (strcmp(buf, "elf")==0) strcpy(buf, "demon");
u->race = rc_find(buf);
assert(u->race);
rs(F, buf);

View File

@ -278,25 +278,28 @@ skill_weeks(int level)
}
void
reduce_skill(unit *u, skill * sv, int weeks)
reduce_skill(unit * u, skill * sv, unsigned int weeks)
{
boolean reroll = false;
int reroll = false;
while (sv->level>0 && weeks>sv->level) {
weeks -= sv->level;
--sv->level;
}
if (sv->level*2+1<sv->weeks) reroll = true;
if (sv->level>0) {
if (rand()%sv->level < weeks) {
sv->weeks+=weeks;
while (sv->level!=0 && sv->weeks>sv->level) {
weeks = sv->weeks-sv->level;
--sv->level;
reroll = true;
sv->weeks = weeks;
}
} else {
reroll = true;
}
if (reroll) sv->weeks = (unsigned char)skill_weeks(sv->level);
assert(sv->weeks<=sv->level*2+1);
if (sv->level==0) {
/* reroll */
sv->weeks = (unsigned char)skill_weeks(sv->level);
}
}
int
skill_compare(const skill * sk, const skill * sc)

View File

@ -24,9 +24,9 @@ extern signed char skill_bonus(struct unit * u, struct region * r);
typedef struct skill {
unsigned char id;
unsigned char level;
unsigned char weeks;
unsigned char old;
unsigned int level : 8;
unsigned int weeks : 8;
unsigned int old : 8;
} skill;
typedef struct skillmod_data {
@ -50,7 +50,7 @@ extern int level_days(int level);
extern int level(int days);
#define skill_level(level) (level)
extern void reduce_skill(struct unit *u, skill * sv, int change);
extern void reduce_skill(struct unit *u, skill * sv, unsigned int change);
extern int skill_weeks(int level);
extern int skill_compare(const skill * sk, const skill * sc);

View File

@ -109,7 +109,9 @@ read_gmcreate(attrib * a, FILE * F)
const item_type ** p_itype = (const item_type **)&a->data.v;
fscanf(F, "%s", zText);
*p_itype = it_find(zText);
assert(*p_itype);
if (a->data.v==NULL) {
log_error(("unknown itemtype %s in gmcreate attribute\n", zText));
}
return AT_READ_OK;
}