This commit is contained in:
Enno Rehling 2014-07-26 22:52:31 +02:00
commit d994caf7a3
8 changed files with 100 additions and 79 deletions

View File

@ -8,7 +8,7 @@ memcheck = 0
locales = de,en locales = de,en
[config] [config]
game = eressea rules = eressea
source_dir = .. source_dir = ..
maxnmrs = 10 maxnmrs = 10

View File

@ -8,7 +8,7 @@ memcheck = 0
locales = de,en locales = de,en
[config] [config]
game = e3a rules = e3a
source_dir = .. source_dir = ..
maxnmrs = 20 maxnmrs = 20

View File

@ -18,5 +18,5 @@ fi
$ROOT/$BIN_DIR/eressea/test_eressea $ROOT/$BIN_DIR/eressea/test_eressea
cd $ROOT cd $ROOT
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/runtests.lua $ROOT/$BIN_DIR/eressea/eressea -v0 scripts/runtests.lua
grep ERROR eressea.log #grep ERROR eressea.log
cd $OLDWPD cd $OLDWPD

View File

@ -137,9 +137,9 @@ function test_ship_capacity()
process_orders() process_orders()
-- print(s.region, u.region, r2) -- print(s.region, u.region, r2)
assert_equal(r2.id, u1.region.id, "boat with 5 humans did not move") assert_equal(r2, u1.region, "boat with 5 humans did not move")
assert_not_equal(r2.id, u2.region.id, "boat with too many people has moved") assert_not_equal(r2, u2.region, "boat with too many people has moved")
assert_not_equal(r2.id, u4.region.id, "boat with too much cargo has moved") assert_not_equal(r2, u4.region, "boat with too much cargo has moved")
end end
function test_levitate() function test_levitate()

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_BUILD 680 #define VERSION_BUILD 681

View File

@ -1164,17 +1164,10 @@ void economics(region * r)
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
order *ord; order *ord;
bool destroyed = false;
if (u->number > 0) { if (u->number > 0) {
for (ord = u->orders; ord; ord = ord->next) { for (ord = u->orders; ord; ord = ord->next) {
keyword_t kwd = getkeyword(ord); keyword_t kwd = getkeyword(ord);
if (kwd == K_DESTROY) { if (kwd == K_GIVE) {
if (!destroyed) {
if (destroy_cmd(u, ord) != 0)
ord = NULL;
destroyed = true;
}
} else if (kwd == K_GIVE) {
give_cmd(u, ord); give_cmd(u, ord);
} else if (kwd == K_FORGET) { } else if (kwd == K_FORGET) {
forget_cmd(u, ord); forget_cmd(u, ord);
@ -1207,6 +1200,27 @@ void economics(region * r)
if (recruitorders) if (recruitorders)
expandrecruit(r, recruitorders); expandrecruit(r, recruitorders);
remove_empty_units_in_region(r); remove_empty_units_in_region(r);
for (u = r->units; u; u = u->next) {
order *ord;
bool destroyed = false;
if (u->number > 0) {
for (ord = u->orders; ord; ord = ord->next) {
keyword_t kwd = getkeyword(ord);
if (kwd == K_DESTROY) {
if (!destroyed) {
if (destroy_cmd(u, ord) != 0)
ord = NULL;
destroyed = true;
}
}
if (u->orders == NULL) {
break;
}
}
}
}
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */

View File

@ -128,64 +128,68 @@ void equip_unit(struct unit *u, const struct equipment *eq)
void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask) void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
{ {
if (eq) { if (eq) {
if (mask & EQUIP_SKILLS) { if (mask & EQUIP_SKILLS) {
int sk; int sk;
for (sk = 0; sk != MAXSKILLS; ++sk) { for (sk = 0; sk != MAXSKILLS; ++sk) {
if (eq->skills[sk] != NULL) { if (eq->skills[sk] != NULL) {
int i = dice_rand(eq->skills[sk]); int i = dice_rand(eq->skills[sk]);
if (i > 0) if (i > 0) {
set_level(u, (skill_t)sk, i); set_level(u, (skill_t)sk, i);
} if (sk==SK_STAMINA) {
} u->hp = unit_max_hp(u) * u->number;
} }
}
if (mask & EQUIP_SPELLS) { }
if (eq->spellbook) {
quicklist * ql = eq->spellbook->spells;
int qi;
sc_mage * mage = get_mage(u);
for (qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry *sbe = (spellbook_entry *) ql_get(ql, qi);
unit_add_spell(u, mage, sbe->sp, sbe->level);
}
}
}
if (mask & EQUIP_ITEMS) {
itemdata *idata;
for (idata = eq->items; idata != NULL; idata = idata->next) {
int i = u->number * dice_rand(idata->value);
if (i > 0) {
i_add(&u->items, i_new(idata->itype, i));
}
}
}
if (eq->subsets) {
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {
equip_unit_mask(u, eq->subsets[i].sets[k].set, mask);
break;
} }
rnd -= eq->subsets[i].sets[k].chance;
}
} }
}
if (mask & EQUIP_SPELLS) {
if (eq->spellbook) {
quicklist * ql = eq->spellbook->spells;
int qi;
sc_mage * mage = get_mage(u);
for (qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry *sbe = (spellbook_entry *) ql_get(ql, qi);
unit_add_spell(u, mage, sbe->sp, sbe->level);
}
}
}
if (mask & EQUIP_ITEMS) {
itemdata *idata;
for (idata = eq->items; idata != NULL; idata = idata->next) {
int i = u->number * dice_rand(idata->value);
if (i > 0) {
i_add(&u->items, i_new(idata->itype, i));
}
}
}
if (eq->subsets) {
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {
equip_unit_mask(u, eq->subsets[i].sets[k].set, mask);
break;
}
rnd -= eq->subsets[i].sets[k].chance;
}
}
}
}
if (mask & EQUIP_SPECIAL) {
if (eq->callback)
eq->callback(eq, u);
}
} }
if (mask & EQUIP_SPECIAL) {
if (eq->callback)
eq->callback(eq, u);
}
}
} }
void equip_items(struct item **items, const struct equipment *eq) void equip_items(struct item **items, const struct equipment *eq)

View File

@ -3226,15 +3226,18 @@ static int sp_bloodsacrifice(castorder * co)
*/ */
static void skill_summoned(unit * u, int level) static void skill_summoned(unit * u, int level)
{ {
if (level > 0) { if (level > 0) {
const race *rc = u_race(u); const race *rc = u_race(u);
skill_t sk; skill_t sk;
for (sk = 0; sk != MAXSKILLS; ++sk) { for (sk = 0; sk != MAXSKILLS; ++sk) {
if (rc->bonus[sk] > 0) { if (rc->bonus[sk] > 0) {
set_level(u, sk, level); set_level(u, sk, level);
} }
}
if (rc->bonus[SK_STAMINA]) {
u->hp = unit_max_hp(u) * u->number;
}
} }
}
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -4928,7 +4931,7 @@ int sp_resist_magic_bonus(castorder * co)
float power = co->force; float power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
/* Pro Stufe koennen bis zu 5 Personen verzaubert werden */ /* Pro Stufe koennen bis zu 5 Personen verzaubert werden */
double maxvictims = 5; double maxvictims = 5 * power;
int victims = (int)maxvictims; int victims = (int)maxvictims;
/* Schleife ueber alle angegebenen Einheiten */ /* Schleife ueber alle angegebenen Einheiten */