forked from github/server
Drachen: kein eigenes Silber riechen, keine unsichtbaren Einheiten angreifen.
This commit is contained in:
parent
2fc718b983
commit
9b4ffd9e25
|
@ -116,13 +116,14 @@ get_money_for_dragon(region * r, unit * u, int wanted)
|
||||||
/* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an */
|
/* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->faction != u->faction && get_money(u2)) {
|
if (u2->faction != u->faction && cansee(u->faction, r, u2, 0)) {
|
||||||
if (getguard(u2) & GUARD_TAX) continue;
|
int m = get_money(u2);
|
||||||
|
if (m==0 || (getguard(u2) & GUARD_TAX)) continue;
|
||||||
else {
|
else {
|
||||||
order * ord = monster_attack(u, u2);
|
order * ord = monster_attack(u, u2);
|
||||||
if (ord) {
|
if (ord) {
|
||||||
addlist(&u->orders, ord);
|
addlist(&u->orders, ord);
|
||||||
n += get_money(u2);
|
n += m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,19 +140,22 @@ get_money_for_dragon(region * r, unit * u, int wanted)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
money(region * r)
|
all_money(region * r, faction * f)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
m = rmoney(r);
|
m = rmoney(r);
|
||||||
for (u = r->units; u; u = u->next)
|
for (u = r->units; u; u = u->next) {
|
||||||
m += get_money(u);
|
if (f!=u->faction) {
|
||||||
|
m += get_money(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static direction_t
|
static direction_t
|
||||||
richest_neighbour(region * r, int absolut)
|
richest_neighbour(region * r, faction * f, int absolut)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* m - maximum an Geld, d - Richtung, i - index, t = Geld hier */
|
/* m - maximum an Geld, d - Richtung, i - index, t = Geld hier */
|
||||||
|
@ -161,9 +165,9 @@ richest_neighbour(region * r, int absolut)
|
||||||
direction_t d = NODIRECTION, i;
|
direction_t d = NODIRECTION, i;
|
||||||
|
|
||||||
if (absolut == 1 || rpeasants(r) == 0) {
|
if (absolut == 1 || rpeasants(r) == 0) {
|
||||||
m = (double) money(r);
|
m = (double) all_money(r, f);
|
||||||
} else {
|
} else {
|
||||||
m = (double) money(r) / (double) rpeasants(r);
|
m = (double) all_money(r, f) / (double) rpeasants(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finde die region mit dem meisten geld */
|
/* finde die region mit dem meisten geld */
|
||||||
|
@ -171,9 +175,9 @@ richest_neighbour(region * r, int absolut)
|
||||||
for (i = 0; i != MAXDIRECTIONS; i++)
|
for (i = 0; i != MAXDIRECTIONS; i++)
|
||||||
if (rconnect(r, i) && rterrain(rconnect(r, i)) != T_OCEAN) {
|
if (rconnect(r, i) && rterrain(rconnect(r, i)) != T_OCEAN) {
|
||||||
if (absolut == 1 || rpeasants(r) == 0) {
|
if (absolut == 1 || rpeasants(r) == 0) {
|
||||||
t = (double) money(rconnect(r, i));
|
t = (double) all_money(rconnect(r, i), f);
|
||||||
} else {
|
} else {
|
||||||
t = (double) money(rconnect(r, i)) / (double) rpeasants(r);
|
t = (double) all_money(rconnect(r, i), f) / (double) rpeasants(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > m) {
|
if (t > m) {
|
||||||
|
@ -304,7 +308,7 @@ monster_move(region * r, unit * u)
|
||||||
case RC_FIREDRAGON:
|
case RC_FIREDRAGON:
|
||||||
case RC_DRAGON:
|
case RC_DRAGON:
|
||||||
case RC_WYRM:
|
case RC_WYRM:
|
||||||
d = richest_neighbour(r, 1);
|
d = richest_neighbour(r, u->faction, 1);
|
||||||
break;
|
break;
|
||||||
case RC_TREEMAN:
|
case RC_TREEMAN:
|
||||||
d = treeman_neighbour(r);
|
d = treeman_neighbour(r);
|
||||||
|
@ -333,7 +337,7 @@ monster_move(region * r, unit * u)
|
||||||
static int
|
static int
|
||||||
dragon_affinity_value(region *r, unit *u)
|
dragon_affinity_value(region *r, unit *u)
|
||||||
{
|
{
|
||||||
int m = count_all_money(r);
|
int m = all_money(r, u->faction);
|
||||||
|
|
||||||
if(u->race == new_race[RC_FIREDRAGON]) {
|
if(u->race == new_race[RC_FIREDRAGON]) {
|
||||||
return (int)(normalvariate(m,m/2));
|
return (int)(normalvariate(m,m/2));
|
||||||
|
|
|
@ -552,18 +552,6 @@ resourcepath(void)
|
||||||
return strcat(strcpy(zText, basepath()), "/res");
|
return strcat(strcpy(zText, basepath()), "/res");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
count_all_money(const region * r)
|
|
||||||
{
|
|
||||||
const unit *u;
|
|
||||||
int m = rmoney(r);
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next)
|
|
||||||
m += get_money(u);
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
count_skill(faction * f, skill_t sk)
|
count_skill(faction * f, skill_t sk)
|
||||||
{
|
{
|
||||||
|
|
|
@ -907,7 +907,6 @@ extern int lighthouse_range(const struct building * b, const struct faction * f)
|
||||||
/* skills */
|
/* skills */
|
||||||
extern int max_skill(struct faction * f, skill_t sk);
|
extern int max_skill(struct faction * f, skill_t sk);
|
||||||
extern int count_skill(struct faction * f, skill_t sk);
|
extern int count_skill(struct faction * f, skill_t sk);
|
||||||
extern int count_all_money(const struct region * r);
|
|
||||||
|
|
||||||
/* direction, geography */
|
/* direction, geography */
|
||||||
extern const char *directions[];
|
extern const char *directions[];
|
||||||
|
|
|
@ -171,6 +171,18 @@ SpecialFunction(region *r)
|
||||||
delwin(win);
|
delwin(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
count_all_money(const region * r)
|
||||||
|
{
|
||||||
|
const unit *u;
|
||||||
|
int m = rmoney(r);
|
||||||
|
|
||||||
|
for (u = r->units; u; u = u->next)
|
||||||
|
m += get_money(u);
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
char Tchar[MAXRACES] = "ZEOGMTDIHK~uifdwtbrsz";
|
char Tchar[MAXRACES] = "ZEOGMTDIHK~uifdwtbrsz";
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue