forked from github/server
broke several monster behaviors, fixed.
This commit is contained in:
parent
3771b88bc6
commit
b1098f7838
|
@ -294,7 +294,7 @@ static race *rc_find_i(const char *name)
|
|||
return rc;
|
||||
}
|
||||
|
||||
const race * rc_find(const char *name) {
|
||||
race * rc_find(const char *name) {
|
||||
return rc_find_i(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ extern "C" {
|
|||
race *rc_create(const char *zName);
|
||||
race *rc_get_or_create(const char *name);
|
||||
bool rc_changed(int *cache);
|
||||
const race *rc_find(const char *);
|
||||
race *rc_find(const char *);
|
||||
void free_races(void);
|
||||
|
||||
bool rc_can_use(const struct race *rc, const struct item_type *itype);
|
||||
|
|
|
@ -794,9 +794,9 @@ void plan_monsters(faction * f)
|
|||
|
||||
/* units with a plan to kill get ATTACK orders (even if they don't guard): */
|
||||
ta = a_find(u->attribs, &at_hate);
|
||||
if (ta && !monster_is_waiting(u) && monster_can_attack(u)) {
|
||||
if (ta && !monster_is_waiting(u)) {
|
||||
unit *tu = (unit *)ta->data.v;
|
||||
if (tu && tu->region == r) {
|
||||
if (tu && tu->region == r && monster_can_attack(u)) {
|
||||
order * ord = monster_attack(u, tu);
|
||||
if (ord) {
|
||||
unit_addorder(u, ord);
|
||||
|
|
|
@ -97,6 +97,7 @@ static void test_monsters_attack_ocean(CuTest * tc)
|
|||
{
|
||||
region *r;
|
||||
unit *u, *m;
|
||||
race *rc;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
|
@ -105,12 +106,18 @@ static void test_monsters_attack_ocean(CuTest * tc)
|
|||
unit_setid(u, 2);
|
||||
m = test_create_unit(m->faction, r);
|
||||
assert(!m->region->land);
|
||||
|
||||
|
||||
config_set("rules.monsters.attack_chance", "1");
|
||||
rc = rc_find(m->_race->_name);
|
||||
|
||||
freset(rc, RCF_SWIM);
|
||||
plan_monsters(m->faction);
|
||||
CuAssertPtrEquals(tc, NULL, find_order("attack 2", m));
|
||||
|
||||
fset(rc, RCF_SWIM);
|
||||
plan_monsters(m->faction);
|
||||
CuAssertPtrNotNull(tc, find_order("attack 2", m));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
@ -145,7 +152,7 @@ static void test_seaserpent_piracy(CuTest * tc)
|
|||
u_setrace(m, rc = test_create_race("seaserpent"));
|
||||
assert(!m->region->land);
|
||||
fset(m, UFL_MOVED);
|
||||
fset(rc, RCF_ATTACK_MOVED);
|
||||
fset(rc, RCF_ATTACK_MOVED|RCF_SWIM);
|
||||
|
||||
config_set("rules.monsters.attack_chance", "1");
|
||||
|
||||
|
|
Loading…
Reference in New Issue