forked from github/server
tweaked parameters for massive overload
so ... many ... configuration parameters scrubbed lua test
This commit is contained in:
parent
a7a82662b7
commit
92ee0f24a4
|
@ -789,27 +789,3 @@ function test_volcanooutbreak_message()
|
|||
assert_not_equal("", msg:render("de"))
|
||||
assert_not_equal("", msg:render("en"))
|
||||
end
|
||||
|
||||
function test_ship_massive()
|
||||
set_rule("rules.ship.drifting", "1")
|
||||
set_rule("rules.ship.damage_drift", "0.02")
|
||||
local r = region.create(0,0, "ocean")
|
||||
region.create(1,0, "plain")
|
||||
region.create(0,1, "ocean")
|
||||
local f = faction.create("massive@eressea.de", "human", "de")
|
||||
|
||||
local s1 = ship.create(r, "cutter")
|
||||
s1.damage = 390
|
||||
local u1 = unit.create(f, r, 10)
|
||||
u1.ship = s1
|
||||
-- u1:set_skill("sailing", 10)
|
||||
u1:clear_orders()
|
||||
u1:add_order("NACH o")
|
||||
|
||||
update_owners()
|
||||
process_orders()
|
||||
write_reports()
|
||||
assert_equal(990, s1.damage)
|
||||
|
||||
set_rule("rules.ship.drifting", "0")
|
||||
end
|
||||
|
|
40
src/move.c
40
src/move.c
|
@ -721,12 +721,38 @@ static float damage_drift(void)
|
|||
return value;
|
||||
}
|
||||
|
||||
static double damage_overload(double overload)
|
||||
static double overload_start(void) {
|
||||
return get_param_flt(global.parameters, "rules.ship.overload.start", 1.1);
|
||||
}
|
||||
|
||||
static double overload_worse(void) {
|
||||
return get_param_flt(global.parameters, "rules.ship.overload.worse", 1.5);
|
||||
}
|
||||
|
||||
static double overload_worst(void) {
|
||||
return get_param_flt(global.parameters, "rules.ship.overload.worst", 5.0);
|
||||
}
|
||||
|
||||
static double overload_default_damage(void) {
|
||||
return get_param_flt(global.parameters, "rules.ship.overload.damage.default", 0.05);
|
||||
}
|
||||
|
||||
static double overload_max_damage(void) {
|
||||
return get_param_flt(global.parameters, "rules.ship.overload.damage.max", 0.37);
|
||||
}
|
||||
|
||||
double damage_overload(double overload)
|
||||
{
|
||||
static double damage;
|
||||
damage = get_param_flt(global.parameters, "rules.ship.damage_overload_min", 0.2);
|
||||
damage *= overload - OVERLOAD_THRESHOLD + 1;
|
||||
damage = _min(damage, get_param_flt(global.parameters, "rules.ship.damage_overload_max", 0.37));
|
||||
double damage, badness;
|
||||
if (overload < overload_start())
|
||||
return 0;
|
||||
damage = overload_default_damage();
|
||||
badness = overload - overload_worse();
|
||||
if (badness >= 0) {
|
||||
damage += _min(badness, overload_worst() - overload_worse()) *
|
||||
(overload_max_damage() - damage) /
|
||||
(overload_worst() - overload_worse());
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
|
@ -794,7 +820,7 @@ static void drifting_ships(region * r)
|
|||
}
|
||||
|
||||
ovl = overload(r, sh);
|
||||
if (ovl >= OVERLOAD_THRESHOLD) {
|
||||
if (ovl >= overload_start()) {
|
||||
rnext = NULL;
|
||||
} else {
|
||||
/* Auswahl einer Richtung: Zuerst auf Land, dann
|
||||
|
@ -830,7 +856,7 @@ static void drifting_ships(region * r)
|
|||
|
||||
if (sh != NULL) {
|
||||
fset(sh, SF_DRIFTED);
|
||||
if (ovl >= OVERLOAD_THRESHOLD) {
|
||||
if (ovl >= overload_start()) {
|
||||
damage_ship(sh, damage_overload(ovl));
|
||||
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh));
|
||||
} else
|
||||
|
|
|
@ -42,8 +42,6 @@ extern "C" {
|
|||
#define HORSESNEEDED 2
|
||||
#define STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */
|
||||
|
||||
#define OVERLOAD_THRESHOLD 1.5
|
||||
|
||||
/* ein mensch wiegt 10, traegt also 5, ein pferd wiegt 50, traegt also 20. ein
|
||||
** wagen wird von zwei pferden gezogen und traegt total 140, davon 40 die
|
||||
** pferde, macht nur noch 100, aber samt eigenem gewicht (40) macht also 140. */
|
||||
|
|
|
@ -314,7 +314,7 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
test_create_world();
|
||||
|
||||
fix->st_boat = st_get_or_create("boat");
|
||||
fix->st_boat->cabins = 10000;
|
||||
fix->st_boat->cabins = 20000;
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
|
||||
assert(fix->r && fix->r->terrain->flags & SAIL_INTO);
|
||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
|
@ -338,7 +338,7 @@ static void test_ship_normal_overload(CuTest *tc) {
|
|||
struct drift_fixture fix;
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 12;
|
||||
fix.u->number = 21;
|
||||
movement();
|
||||
CuAssertPtrEquals(tc, fix.u->region, findregion(0, 0));
|
||||
CuAssertIntEquals(tc, 2, ship_damage_percent(fix.sh));
|
||||
|
@ -349,10 +349,10 @@ static void test_ship_big_overload(CuTest *tc) {
|
|||
struct drift_fixture fix;
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 15;
|
||||
fix.u->number = 22;
|
||||
movement();
|
||||
CuAssertPtrEquals(tc, fix.u->region, findregion(-1, 0));
|
||||
CuAssertIntEquals(tc, 20, ship_damage_percent(fix.sh));
|
||||
CuAssertIntEquals(tc, 5, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ static void test_ship_no_real_overload(CuTest *tc) {
|
|||
struct drift_fixture fix;
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 12;
|
||||
fix.u->number = 21;
|
||||
damage_ship(fix.sh, .80);
|
||||
movement();
|
||||
CuAssertPtrEquals(tc, fix.u->region, findregion(0, 0));
|
||||
|
@ -372,7 +372,7 @@ static void test_ship_ridiculous_overload(CuTest *tc) {
|
|||
struct drift_fixture fix;
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 100;
|
||||
fix.u->number = 500;
|
||||
movement();
|
||||
CuAssertIntEquals(tc, 37, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
@ -383,7 +383,7 @@ static void test_ship_ridiculous_overload_no_captain(CuTest *tc) {
|
|||
setup_drift(&fix);
|
||||
set_level(fix.u, SK_SAILING, 0);
|
||||
|
||||
fix.u->number = 100;
|
||||
fix.u->number = 500;
|
||||
movement();
|
||||
CuAssertIntEquals(tc, 37, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
@ -393,8 +393,8 @@ static void test_ship_ridiculous_overload_bad(CuTest *tc) {
|
|||
struct drift_fixture fix;
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 200;
|
||||
set_param(&global.parameters, "rules.ship.damage_overload_max", "1");
|
||||
fix.u->number = 500;
|
||||
set_param(&global.parameters, "rules.ship.overload.damage.max", "1");
|
||||
movement();
|
||||
CuAssertTrue(tc, ship_damage_percent(fix.sh) > 99);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
@ -402,6 +402,15 @@ static void test_ship_ridiculous_overload_bad(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "shipsink"));
|
||||
}
|
||||
|
||||
extern double damage_overload(double overload);
|
||||
|
||||
static void test_ship_damage_overload(CuTest *tc) {
|
||||
CuAssertDblEquals(tc, 0.0, damage_overload(1), ASSERT_DBL_DELTA);
|
||||
CuAssertDblEquals(tc, 0.05, damage_overload(1.1), ASSERT_DBL_DELTA);
|
||||
CuAssertDblEquals(tc, 0.05, damage_overload(1.5), ASSERT_DBL_DELTA);
|
||||
CuAssertDblEquals(tc, 0.21, damage_overload(3.25), ASSERT_DBL_DELTA);
|
||||
CuAssertDblEquals(tc, 0.37, damage_overload(5), ASSERT_DBL_DELTA);
|
||||
}
|
||||
|
||||
CuSuite *get_move_suite(void)
|
||||
{
|
||||
|
@ -424,5 +433,6 @@ CuSuite *get_move_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_ship_ridiculous_overload);
|
||||
SUITE_ADD_TEST(suite, test_ship_ridiculous_overload_bad);
|
||||
SUITE_ADD_TEST(suite, test_ship_ridiculous_overload_no_captain);
|
||||
SUITE_ADD_TEST(suite, test_ship_damage_overload);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue