Lighthouse: only show large swimming units (more than 10 weight).

Eliminate RCF_INVISIBLE and the spell race.
This commit is contained in:
Enno Rehling 2020-08-05 16:29:20 +02:00
parent 90511b434c
commit 19a2a69f33
10 changed files with 20 additions and 47 deletions

View File

@ -400,7 +400,7 @@
<attack type="1" damage="1d4"/>
<attack type="6" spell="fiery_dragonbreath" level="3" />
</race>
<race name="ghost" magres="80" maxaura="0.5" regaura="0.100000" weight="500" capacity="540" speed="1.0" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
<race name="ghost" magres="80" maxaura="0.5" regaura="0.1" weight="500" capacity="540" speed="1.0" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
<ai splitsize="5000" scarepeasants="yes"/>
<skill name="crossbow" modifier="-99"/>
<skill name="mining" modifier="-99"/>
@ -678,10 +678,6 @@
<skill name="weaponsmithing" modifier="14"/>
<attack type="4" damage="2d8+4"/>
</race>
<race name="spell" maxaura="1" regaura="0.100000" weight="0" capacity="0" speed="0.0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" learn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
<ai splitsize="1"/>
<attack type="1" damage="1d4"/>
</race>
<race name="special" maxaura="0" regaura="0" weight="0" capacity="0" speed="0.0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
<ai splitsize="1"/>
<attack type="1" damage="1d4"/>

View File

@ -675,10 +675,6 @@
<skill name="weaponsmithing" modifier="14"/>
<attack type="4" damage="2d8+4"/>
</race>
<race name="spell" maxaura="1" regaura="0.100000" weight="0" capacity="0" speed="0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" learn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
<ai splitsize="1"/>
<attack type="1" damage="1d4"/>
</race>
<race name="special" maxaura="0" regaura="0" weight="0" capacity="0" speed="0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
<ai splitsize="1"/>
<attack type="1" damage="1d4"/>

View File

@ -745,9 +745,6 @@ void cr_output_unit(stream *out, const faction * f,
assert(u && u->number);
if (fval(u_race(u), RCF_INVISIBLE))
return;
stream_printf(out, "EINHEIT %d\n", u->no);
stream_printf(out, "\"%s\";Name\n", unit_getname(u));
str = u_description(u, lang);

View File

@ -212,11 +212,10 @@ extern "C" {
#define RCF_COASTAL (1<<22) /* kann in Landregionen an der Kueste sein */
#define RCF_UNARMEDGUARD (1<<23) /* kann ohne Waffen bewachen */
#define RCF_CANSAIL (1<<24) /* Einheit darf Schiffe betreten */
#define RCF_INVISIBLE (1<<25) /* not visible in any report */
#define RCF_FAMILIAR (1<<25) /* may be a familiar */
#define RCF_SHIPSPEED (1<<26) /* race gets +1 on shipspeed */
#define RCF_ATTACK_MOVED (1<<27) /* may attack if it has moved */
#define RCF_MIGRANTS (1<<28) /* may have migrant units (human bonus) */
#define RCF_FAMILIAR (1<<29) /* may be a familiar */
#define RCF_DEFAULT RCF_CANSAIL

View File

@ -937,9 +937,7 @@ void u_setfaction(unit * u, faction * f)
bool count_unit(const unit *u)
{
const race *rc = u_race(u);
/* spells are invisible. units we cannot see do not count to our limit */
return rc == NULL || (rc->flags & RCF_INVISIBLE) == 0;
return u_race(u) != NULL;
}
void set_number(unit * u, int count)
@ -948,7 +946,7 @@ void set_number(unit * u, int count)
assert(count <= UNIT_MAXSIZE);
if (count == 0) {
u->flags &= ~(UFL_HERO);
u->flags &= ~UFL_HERO;
}
if (u->faction && count_unit(u)) {
u->faction->num_people += count - u->number;

View File

@ -520,14 +520,11 @@ static void test_heal_factor(CuTest *tc) {
}
static void test_unlimited_units(CuTest *tc) {
race *rc;
faction *f;
unit *u;
test_setup();
f = test_create_faction(NULL);
rc = test_create_race("spell");
rc->flags |= RCF_INVISIBLE;
CuAssertIntEquals(tc, 0, f->num_units);
CuAssertIntEquals(tc, 0, f->num_people);
u = test_create_unit(f, test_create_region(0, 0, NULL));
@ -540,14 +537,7 @@ static void test_unlimited_units(CuTest *tc) {
u_setfaction(u, f);
CuAssertIntEquals(tc, 1, f->num_units);
CuAssertIntEquals(tc, 1, f->num_people);
u_setrace(u, rc);
CuAssertTrue(tc, !count_unit(u));
CuAssertIntEquals(tc, 0, f->num_units);
CuAssertIntEquals(tc, 0, f->num_people);
scale_number(u, 10);
CuAssertIntEquals(tc, 0, f->num_units);
CuAssertIntEquals(tc, 0, f->num_people);
u_setrace(u, f->race);
CuAssertIntEquals(tc, 1, f->num_units);
CuAssertIntEquals(tc, 10, f->num_people);
remove_unit(&u->region->units, u);

View File

@ -4068,31 +4068,30 @@ void turn_end(void)
update_spells();
}
/** determine if unit can be seen by faction
/**
* Determine if unit can be seen by faction.
*
* @param f -- the observiong faction
* @param u -- the unit that is observed
* @param r -- the region that u is obesrved from (see below)
* @param m -- terrain modifier to stealth
*
*
* r kann != u->region sein, wenn es um Durchreisen geht,
* oder Zauber (sp_generous, sp_fetchastral).
* Es muss auch niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
bool
cansee(const faction * f, const region * r, const unit * u, int modifier)
* erblickt wird.
*/
bool cansee(const faction * f, const region * r, const unit * u, int modifier)
{
int stealth, rings;
if (u->faction == f || omniscient(f)) {
return true;
}
else if (fval(u_race(u), RCF_INVISIBLE)) {
return false;
}
else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator);
if (a) { /* u is an empty temporary unit. In this special case
we look at the creating unit. */
if (a) {
/* u is an empty temporary unit. In this special case we look at the creating unit. */
u = (unit *)a->data.v;
}
else {
@ -4132,7 +4131,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
bool cansee_unit(const unit * u, const unit * target, int modifier)
/* target->region kann != u->region sein, wenn es um durchreisen geht */
{
if (fval(u_race(target), RCF_INVISIBLE) || target->number == 0)
if (target->number == 0)
return false;
else if (target->faction == u->faction)
return true;
@ -4175,7 +4174,7 @@ cansee_durchgezogen(const faction * f, const region * r, const unit * u,
{
unit *u2;
if (fval(u_race(u), RCF_INVISIBLE) || u->number == 0)
if (u->number == 0)
return false;
else if (u->faction == f)
return true;

View File

@ -627,9 +627,6 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_
bool isbattle = (mode == seen_battle);
char buf[8192];
if (fval(u_race(u), RCF_INVISIBLE))
return;
newline(out);
dh = bufunit_depr(f, u, mode, buf, sizeof(buf));
@ -1231,7 +1228,7 @@ static void report_statistics(struct stream *out, const region * r, const factio
/* count */
for (number = 0, u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
if (u->faction == f) {
for (itm = u->items; itm; itm = itm->next) {
i_change(&items, itm->type, itm->number);
}
@ -1321,7 +1318,7 @@ report_template(const char *filename, report_context * ctx, const char *bom)
continue;
for (u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
if (u->faction == f) {
order *ord;
if (!dh) {
plane *pl = getplane(r);

View File

@ -2371,7 +2371,7 @@ bool visible_unit(const unit *u, const faction *f, int stealthmod, seen_mode mod
else {
if (stealthmod > INT_MIN) {
if (mode == seen_lighthouse) {
return true;
return u_race(u)->weight > 10000;
} else if (mode > seen_travel || u->building || u->ship || is_guard(u)) {
return cansee(f, u->region, u, stealthmod);
}

View File

@ -870,7 +870,8 @@ static void test_visible_unit(CuTest *tc) {
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, 0, seen_lighthouse));
CuAssertTrue(tc, !visible_unit(u, f, -2, seen_lighthouse));
rc->weight = 11000;
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
u->ship = sh = test_create_ship(u->region, NULL);