forked from github/server
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
dee05076ac
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<building name="castle" capacity="1">
|
<building name="castle" capacity="1" fort="1">
|
||||||
<function name="name" value="castle_name_2"/>
|
<function name="name" value="castle_name_2"/>
|
||||||
<function name="protection" value="building_protection"/>
|
<function name="protection" value="building_protection"/>
|
||||||
<function name="taxes" value="lua_building_taxes"/>
|
<function name="taxes" value="lua_building_taxes"/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<building name="castle" capacity="1">
|
<building name="castle" capacity="1" fort="1">
|
||||||
<function name="name" value="castle_name"/>
|
<function name="name" value="castle_name"/>
|
||||||
<function name="protection" value="building_protection"/>
|
<function name="protection" value="building_protection"/>
|
||||||
<construction skill="building" minskill="1" maxsize="2" reqsize="1" defense_bonus="0">
|
<construction skill="building" minskill="1" maxsize="2" reqsize="1" defense_bonus="0">
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<xi:include href="config://default/buildings/castle-2.xml" />
|
<xi:include href="config://default/buildings/castle-2.xml" />
|
||||||
|
|
||||||
<building name="watch" capacity="1" maxsize="10">
|
<building name="watch" capacity="1" maxsize="10" fort="1">
|
||||||
<function name="name" value="fort_name"/>
|
<function name="name" value="fort_name"/>
|
||||||
<function name="protection" value="building_protection"/>
|
<function name="protection" value="building_protection"/>
|
||||||
<function name="taxes" value="lua_building_taxes"/>
|
<function name="taxes" value="lua_building_taxes"/>
|
||||||
|
|
|
@ -47,6 +47,7 @@ extern "C" {
|
||||||
#define BTF_MAGIC 0x40 /* magical effect */
|
#define BTF_MAGIC 0x40 /* magical effect */
|
||||||
#define BTF_ONEPERTURN 0x80 /* one one sizepoint can be added per turn */
|
#define BTF_ONEPERTURN 0x80 /* one one sizepoint can be added per turn */
|
||||||
#define BTF_NAMECHANGE 0x100 /* name and description can be changed more than once */
|
#define BTF_NAMECHANGE 0x100 /* name and description can be changed more than once */
|
||||||
|
#define BTF_FORTIFICATION 0x200 /* safe from monsters */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DEFENSE_BONUS,
|
DEFENSE_BONUS,
|
||||||
|
|
|
@ -305,7 +305,7 @@ static void json_terrain(cJSON *json, terrain_type *ter) {
|
||||||
static void json_building(cJSON *json, building_type *bt) {
|
static void json_building(cJSON *json, building_type *bt) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
const char *flags[] = {
|
const char *flags[] = {
|
||||||
"nodestroy", "nobuild", "unique", "decay", "dynamic", "magic", "oneperturn", "namechange", 0
|
"nodestroy", "nobuild", "unique", "decay", "dynamic", "magic", "oneperturn", "namechange", "fort", 0
|
||||||
};
|
};
|
||||||
if (json->type != cJSON_Object) {
|
if (json->type != cJSON_Object) {
|
||||||
log_error("building %s is not a json object: %d", json->string, json->type);
|
log_error("building %s is not a json object: %d", json->string, json->type);
|
||||||
|
|
|
@ -270,6 +270,8 @@ static int parse_buildings(xmlDocPtr doc)
|
||||||
btype->flags |= BTF_DECAY;
|
btype->flags |= BTF_DECAY;
|
||||||
if (xml_bvalue(node, "magic", false))
|
if (xml_bvalue(node, "magic", false))
|
||||||
btype->flags |= BTF_MAGIC;
|
btype->flags |= BTF_MAGIC;
|
||||||
|
if (xml_bvalue(node, "fort", false))
|
||||||
|
btype->flags |= BTF_FORTIFICATION;
|
||||||
|
|
||||||
/* reading eressea/buildings/building/construction */
|
/* reading eressea/buildings/building/construction */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/build.h>
|
#include <kernel/build.h>
|
||||||
|
#include <kernel/building.h>
|
||||||
#include <kernel/curse.h>
|
#include <kernel/curse.h>
|
||||||
#include <kernel/equipment.h>
|
#include <kernel/equipment.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
|
@ -156,45 +157,47 @@ static order *monster_attack(unit * u, const unit * target)
|
||||||
return create_order(K_ATTACK, u->faction->locale, "%i", target->no);
|
return create_order(K_ATTACK, u->faction->locale, "%i", target->no);
|
||||||
}
|
}
|
||||||
|
|
||||||
static order *get_money_for_dragon(region * r, unit * u, int wanted)
|
static bool in_safe_building(unit *u1, unit *u2) {
|
||||||
{
|
if (u1->building && u2->building == u1->building) {
|
||||||
unit *u2;
|
building * b = inside_building(u1);
|
||||||
int n;
|
if (u2->building) {
|
||||||
double attack_chance = monster_attack_chance();
|
if (b != inside_building(u2)) return true;
|
||||||
|
}
|
||||||
if (attack_chance > 0.0 && is_guard(u, GUARD_TAX)) {
|
if (b->type->flags & BTF_FORTIFICATION) {
|
||||||
/* attackiere bewachende Einheiten nur wenn wir selbst schon bewachen */
|
return true;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
|
||||||
if (u2 != u && is_guard(u2, GUARD_TAX) && u->faction!=u2->faction) {
|
|
||||||
/*In E3 + E4 etwas problematisch, da der Regionsbesitzer immer bewacht. Der Drache greift also immer die Burg an!*/
|
|
||||||
order *ord = monster_attack(u, u2);
|
|
||||||
if (ord)
|
|
||||||
addlist(&u->orders, ord);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static order *get_money_for_dragon(region * r, unit * u, int wanted)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
bool attacks = monster_attack_chance() > 0.0;
|
||||||
|
|
||||||
/* falls genug geld in der region ist, treiben wir steuern ein. */
|
/* falls genug geld in der region ist, treiben wir steuern ein. */
|
||||||
if (rmoney(r) >= wanted) {
|
if (rmoney(r) >= wanted) {
|
||||||
/* 5% chance, dass der drache aus einer laune raus attackiert */
|
/* 5% chance, dass der drache aus einer laune raus attackiert */
|
||||||
if (attack_chance <= 0.0 || chance(1.0 - u_race(u)->aggression)) {
|
if (!attacks || chance(1.0 - u_race(u)->aggression)) {
|
||||||
/* Drachen haben in E3 und E4 keine Einnahmen. Neuer Befehl Pluendern erstmal nur fuer Monster?*/
|
/* Drachen haben in E3 und E4 keine Einnahmen. Neuer Befehl Pluendern erstmal nur fuer Monster?*/
|
||||||
return create_order(K_LOOT, default_locale, NULL);
|
return create_order(K_LOOT, default_locale, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
|
* und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */
|
||||||
n = 0;
|
n = 0;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
if (attacks && is_guard(u, GUARD_TAX)) {
|
||||||
if (inside_building(u2) != u->building && is_guard(u, GUARD_TAX) && u2->faction != u->faction && cansee(u->faction, r, u2, 0)) {
|
unit *u2;
|
||||||
int m = get_money(u2);
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (m == 0 || is_guard(u2, GUARD_TAX) || attack_chance <= 0.0)
|
if (u2->faction != u->faction && cansee(u->faction, r, u2, 0) && !in_safe_building(u, u2)) {
|
||||||
continue;
|
int m = get_money(u2);
|
||||||
else {
|
if (m != 0) {
|
||||||
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 += m;
|
n += m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,8 +206,7 @@ static order *get_money_for_dragon(region * r, unit * u, int wanted)
|
||||||
/* falls die einnahmen erreicht werden, bleibt das monster noch eine */
|
/* falls die einnahmen erreicht werden, bleibt das monster noch eine */
|
||||||
/* runde hier. */
|
/* runde hier. */
|
||||||
if (n + rmoney(r) >= wanted) {
|
if (n + rmoney(r) >= wanted) {
|
||||||
keyword_t kwd = keyword_disabled(K_TAX) ? K_LOOT : K_TAX;
|
return create_order(K_LOOT, default_locale, NULL);
|
||||||
return create_order(kwd, default_locale, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wenn wir NULL zurueckliefern, macht der drache was anderes, z.b. weggehen */
|
/* wenn wir NULL zurueckliefern, macht der drache was anderes, z.b. weggehen */
|
||||||
|
@ -549,16 +551,17 @@ static order *monster_seeks_target(region * r, unit * u)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void monster_attacks(unit * u)
|
static void monster_attacks(unit * monster)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = monster->region;
|
||||||
unit *u2;
|
unit *u;
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u2->faction != u->faction && cansee(u->faction, r, u2, 0) && !inside_building(u2)) {
|
if (u->faction != monster->faction && cansee(monster->faction, r, u, 0) && !in_safe_building(u, monster)) {
|
||||||
order *ord = monster_attack(u, u2);
|
order *ord = monster_attack(monster, u);
|
||||||
if (ord)
|
if (ord) {
|
||||||
addlist(&u->orders, ord);
|
addlist(&monster->orders, ord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue