forked from github/server
Große Monster können sich auf dem Ozean nicht verstecken.
This commit is contained in:
parent
8c43f21fbe
commit
4a79960cb1
6 changed files with 47 additions and 17 deletions
|
@ -575,3 +575,8 @@ int rc_get_mask(char *list) {
|
|||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool rc_can_learn(const race *rc, skill_t sk) {
|
||||
/* Hack: Talente mit Malus -99 koennen nicht gelernt werden */
|
||||
return rc->bonus[sk] > -99;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ extern "C" {
|
|||
void rc_set_param(struct race *rc, const char *key, const char *value);
|
||||
|
||||
int rc_luxury_trade(const struct race *rc);
|
||||
bool rc_can_learn(const race *rc, skill_t sk);
|
||||
int rc_herb_trade(const struct race *rc);
|
||||
variant rc_magres(const struct race *rc);
|
||||
double rc_maxaura(const struct race *rc);
|
||||
|
|
|
@ -599,7 +599,7 @@ static order *monster_learn(unit * u)
|
|||
c = 0;
|
||||
|
||||
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
||||
if (sv->level > 0) {
|
||||
if (sv->level > 0 && rc_can_learn(u->_race, sv->id)) {
|
||||
if (++c == n) {
|
||||
return create_order(K_STUDY, lang, "'%s'", skillname(sv->id, lang));
|
||||
}
|
||||
|
|
|
@ -2379,14 +2379,14 @@ bool visible_unit(const unit *u, const faction *f, int stealthmod, seen_mode mod
|
|||
if (u->faction == f) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
else if (mode >= seen_lighthouse) {
|
||||
if (stealthmod > INT_MIN) {
|
||||
if ((u->region->terrain->flags & SEA_REGION) && (u_race(u)->weight >= 5000)) {
|
||||
return true;
|
||||
}
|
||||
if (mode >= seen_travel || u->building || u->ship || is_guard(u)) {
|
||||
return cansee(f, u->region, u, stealthmod);
|
||||
}
|
||||
else {
|
||||
return u_race(u)->weight >= 5000;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -875,8 +875,9 @@ static void test_visible_unit(CuTest* tc) {
|
|||
f = test_create_faction();
|
||||
rc = test_create_race("smurf");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
/* visibility on land */
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertTrue(tc, cansee(f, u->region, u, 0));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_spell));
|
||||
|
@ -885,25 +886,49 @@ static void test_visible_unit(CuTest* tc) {
|
|||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_lighthouse_land));
|
||||
|
||||
CuAssertTrue(tc, !visible_unit(u, f, -2, seen_lighthouse));
|
||||
/* weight makes no difference on land */
|
||||
rc->weight = 5000;
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_lighthouse_land));
|
||||
/* stealth makes you invisible */
|
||||
set_level(u, SK_STEALTH, 2);
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_travel));
|
||||
|
||||
/* visibility of stealthed units in oceans */
|
||||
u = test_create_unit(u->faction, test_create_ocean(0, 1));
|
||||
set_level(u, SK_STEALTH, 2);
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_lighthouse));
|
||||
rc->weight = 4999;
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_unit));
|
||||
u->ship = sh = test_create_ship(u->region, NULL);
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_lighthouse));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
u->ship = NULL;
|
||||
|
||||
/* guards can always be seen */
|
||||
setguard(u, true);
|
||||
CuAssertTrue(tc, is_guard(u));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_lighthouse));
|
||||
setguard(u, false);
|
||||
|
||||
u->building = b = test_create_building(u->region, NULL);
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_lighthouse));
|
||||
u->building = NULL;
|
||||
|
||||
set_level(u, SK_STEALTH, 1);
|
||||
|
|
|
@ -472,8 +472,7 @@ bool check_student(const struct unit *u, struct order *ord, skill_t sk) {
|
|||
if (sk < 0 || sk >= MAXSKILLS) {
|
||||
err = 77;
|
||||
}
|
||||
/* Hack: Talente mit Malus -99 koennen nicht gelernt werden */
|
||||
else if (rc->bonus[sk] == -99) {
|
||||
else if (!rc_can_learn(rc, sk)) {
|
||||
err = 771;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue