"Tragekapazität von Monstern zu hoch"
throwing away carts because monsters don't know what to do with them.
This commit is contained in:
Enno Rehling 2008-08-28 15:16:13 +00:00
parent 38ff80892f
commit 802b9332c7
4 changed files with 46 additions and 34 deletions

View file

@ -78,18 +78,30 @@
static void static void
reduce_weight(unit * u) reduce_weight(unit * u)
{ {
int horses = get_resource(u, oldresourcetype[R_HORSE]); int capacity, weight = 0;
int capacity = walkingcapacity(u);
item ** itmp = &u->items; item ** itmp = &u->items;
int weight = 0; int horses = get_resource(u, oldresourcetype[R_HORSE]);
if (horses > 0) { if (horses > 0) {
horses = MIN(horses, (u->number*2)); horses = MIN(horses, (u->number*2));
change_resource(u, oldresourcetype[R_HORSE], - horses); change_resource(u, oldresourcetype[R_HORSE], - horses);
} }
/* 0. ditch any vehicles */
while (*itmp!=NULL) {
item * itm = *itmp;
const item_type * itype = itm->type;
weight += itm->number*itype->weight;
if (itype->flags & ITF_VEHICLE) {
give_item(itm->number, itm->type, u, NULL, NULL);
}
if (*itmp==itm) itmp=&itm->next;
}
capacity = walkingcapacity(u);
/* 1. get rid of anything that isn't silver or really lightweight or helpful in combat */ /* 1. get rid of anything that isn't silver or really lightweight or helpful in combat */
while (capacity>0 && *itmp!=NULL) { for (itmp = &u->items;*itmp && capacity>0;) {
item * itm = *itmp; item * itm = *itmp;
const item_type * itype = itm->type; const item_type * itype = itm->type;
weight += itm->number*itype->weight; weight += itm->number*itype->weight;

View file

@ -190,7 +190,7 @@ bin_r_str_buf(struct storage * store, char * result, size_t size)
result[0] = 0; result[0] = 0;
} else { } else {
len = (size_t)i; len = (size_t)i;
rd = MIN(len, size); rd = MIN(len, size-1);
fread(result, sizeof(char), rd, file(store)); fread(result, sizeof(char), rd, file(store));
if (rd<len) { if (rd<len) {
fseek(file(store), (long)(len-rd), SEEK_CUR); fseek(file(store), (long)(len-rd), SEEK_CUR);

View file

@ -284,56 +284,56 @@ ridingcapacity(unit * u)
int int
walkingcapacity(const struct unit * u) walkingcapacity(const struct unit * u)
{ {
int n, tmp, people, pferde_fuer_wagen; int n, tmp, people, pferde_fuer_wagen;
int wagen_ohne_pferde, wagen_mit_pferden, wagen_mit_trollen; int wagen_ohne_pferde, wagen_mit_pferden, wagen_mit_trollen;
int vehicles = 0, vcap = 0; int vehicles = 0, vcap = 0;
int animals = 0, acap = 0; int animals = 0, acap = 0;
get_transporters(u->items, &animals, &acap, &vehicles, &vcap); get_transporters(u->items, &animals, &acap, &vehicles, &vcap);
/* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches
* die Leute tragen */ * die Leute tragen */
pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING) * u->number * 4); pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING) * u->number * 4);
if (fval(u->race, RCF_HORSE)) { if (fval(u->race, RCF_HORSE)) {
animals += u->number; animals += u->number;
people = 0; people = 0;
} else { } else {
people = u->number; people = u->number;
} }
/* maximal diese Pferde können zum Ziehen benutzt werden */ /* maximal diese Pferde können zum Ziehen benutzt werden */
wagen_mit_pferden = MIN(vehicles, pferde_fuer_wagen / HORSESNEEDED); wagen_mit_pferden = MIN(vehicles, pferde_fuer_wagen / HORSESNEEDED);
n = wagen_mit_pferden * vcap; n = wagen_mit_pferden * vcap;
if (u->race == new_race[RC_TROLL]) { if (u->race == new_race[RC_TROLL]) {
/* 4 Trolle ziehen einen Wagen. */ /* 4 Trolle ziehen einen Wagen. */
/* Unbesetzte Wagen feststellen */ /* Unbesetzte Wagen feststellen */
wagen_ohne_pferde = vehicles - wagen_mit_pferden; wagen_ohne_pferde = vehicles - wagen_mit_pferden;
/* Genug Trolle, um die Restwagen zu ziehen? */ /* Genug Trolle, um die Restwagen zu ziehen? */
wagen_mit_trollen = MIN(u->number / 4, wagen_ohne_pferde); wagen_mit_trollen = MIN(u->number / 4, wagen_ohne_pferde);
/* Wagenkapazität hinzuzählen */ /* Wagenkapazität hinzuzählen */
n += wagen_mit_trollen * vcap; n += wagen_mit_trollen * vcap;
wagen_ohne_pferde -= wagen_mit_trollen; wagen_ohne_pferde -= wagen_mit_trollen;
} }
n += animals * acap; n += animals * acap;
n += people * personcapacity(u); n += people * personcapacity(u);
/* Goliathwasser */ /* Goliathwasser */
tmp = get_effect(u, oldpotiontype[P_STRONG]); tmp = get_effect(u, oldpotiontype[P_STRONG]);
if (tmp>0) { if (tmp>0) {
int horsecap = olditemtype[I_HORSE]->capacity; int horsecap = olditemtype[I_HORSE]->capacity;
if (tmp>people) tmp = people; if (tmp>people) tmp = people;
n += tmp * (horsecap - personcapacity(u)); n += tmp * (horsecap - personcapacity(u));
} }
/* change_effect wird in ageing gemacht */ /* change_effect wird in ageing gemacht */
tmp = get_item(u, I_TROLLBELT); tmp = get_item(u, I_TROLLBELT);
n += MIN(people, tmp) * (STRENGTHMULTIPLIER-1) * personcapacity(u); n += MIN(people, tmp) * (STRENGTHMULTIPLIER-1) * personcapacity(u);
return n; return n;
} }
enum { enum {

View file

@ -194,7 +194,7 @@ static struct curse_type ct_fogtrap = {
static struct curse_type ct_maelstrom = { static struct curse_type ct_maelstrom = {
"maelstrom", "maelstrom",
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR), CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
NULL cinfo_simple
}; };
static struct curse_type ct_blessedharvest = { static struct curse_type ct_blessedharvest = {
"blessedharvest", "blessedharvest",