forked from github/server
bug 2238: respect the dragon speed multiplier.
This commit is contained in:
parent
a7c45d31ad
commit
f4e56d1512
2 changed files with 45 additions and 33 deletions
64
src/move.c
64
src/move.c
|
@ -1388,47 +1388,45 @@ int movement_speed(const unit * u)
|
||||||
const race *rc = u_race(u);
|
const race *rc = u_race(u);
|
||||||
double dk = rc->speed;
|
double dk = rc->speed;
|
||||||
assert(u->number);
|
assert(u->number);
|
||||||
|
|
||||||
/* dragons have a fixed speed, and no other effects work on them: */
|
/* dragons have a fixed speed, and no other effects work on them: */
|
||||||
if (fval(rc, RCF_DRAGON)) {
|
if (u_race(u) == get_race(RC_SONGDRAGON)) {
|
||||||
return BP_DRAGON;
|
|
||||||
}
|
|
||||||
switch (old_race(u_race(u))) {
|
|
||||||
case RC_BIRTHDAYDRAGON: /* FIXME: catdragon has RCF_DRAGON, so this cannot happen */
|
|
||||||
case RC_SONGDRAGON:
|
|
||||||
mp = BP_DRAGON;
|
mp = BP_DRAGON;
|
||||||
break;
|
}
|
||||||
default:
|
else {
|
||||||
mp = walk_mode(u);
|
if (fval(rc, RCF_DRAGON)) {
|
||||||
if (mp>=BP_RIDING) {
|
mp = BP_DRAGON;
|
||||||
dk = 1.0;
|
|
||||||
}
|
}
|
||||||
break;
|
else {
|
||||||
}
|
mp = walk_mode(u);
|
||||||
|
if (mp >= BP_RIDING) {
|
||||||
|
dk = 1.0;
|
||||||
|
}
|
||||||
|
if (u->attribs) {
|
||||||
|
curse *c = get_curse(u->attribs, &ct_speed);
|
||||||
|
if (c != NULL) {
|
||||||
|
int men = get_cursedmen(u, c);
|
||||||
|
dk *= 1.0 + (double)men / (double)u->number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (u->attribs) {
|
/* unicorn in inventory */
|
||||||
curse *c = get_curse(u->attribs, &ct_speed);
|
if (u->number <= i_get(u->items, it_find("fairyboot"))) {
|
||||||
if (c != NULL) {
|
|
||||||
int men = get_cursedmen(u, c);
|
|
||||||
dk *= 1.0 + (double)men / (double)u->number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* unicorn in inventory */
|
|
||||||
if (u->number <= i_get(u->items, it_find("fairyboot"))) {
|
|
||||||
mp *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell.
|
|
||||||
* Nicht kumulativ mit anderen Beschleunigungen! */
|
|
||||||
if (mp * dk <= BP_WALKING * u_race(u)->speed && is_astral(u->region)) {
|
|
||||||
sc_mage *mage = get_mage(u);
|
|
||||||
if (mage && (mage->magietyp == M_TYBIED || mage->magietyp == M_ILLAUN)) {
|
|
||||||
if (has_skill(u, SK_MAGIC)) {
|
|
||||||
mp *= 2;
|
mp *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell.
|
||||||
|
* Nicht kumulativ mit anderen Beschleunigungen! */
|
||||||
|
if (mp * dk <= BP_WALKING * u_race(u)->speed && is_astral(u->region)) {
|
||||||
|
sc_mage *mage = get_mage(u);
|
||||||
|
if (mage && (mage->magietyp == M_TYBIED || mage->magietyp == M_ILLAUN)) {
|
||||||
|
if (has_skill(u, SK_MAGIC)) {
|
||||||
|
mp *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)(dk * mp);
|
return (int)(dk * mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,10 +592,24 @@ static void test_route_pause(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_movement_speed_dragon(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
race *rc;
|
||||||
|
test_setup();
|
||||||
|
|
||||||
|
rc = test_create_race("dragon");
|
||||||
|
rc->flags |= RCF_DRAGON;
|
||||||
|
rc->speed = 1.5;
|
||||||
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||||
|
CuAssertIntEquals(tc, 6, movement_speed(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_move_suite(void)
|
CuSuite *get_move_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_movement_speed);
|
SUITE_ADD_TEST(suite, test_movement_speed);
|
||||||
|
SUITE_ADD_TEST(suite, test_movement_speed_dragon);
|
||||||
SUITE_ADD_TEST(suite, test_walkingcapacity);
|
SUITE_ADD_TEST(suite, test_walkingcapacity);
|
||||||
SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast);
|
SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast);
|
||||||
SUITE_ADD_TEST(suite, test_ship_leave_trail);
|
SUITE_ADD_TEST(suite, test_ship_leave_trail);
|
||||||
|
|
Loading…
Reference in a new issue