forked from github/server
Erstmal nur der Burgenbonus
Das mit der Größe kommt noch mal extra, der Übersicht wegen. Sinvoller weise kann man den Bonus jetzt in der castle.xml einstellen. Mit neuen Defaultwerten in den XML Dateien.
This commit is contained in:
parent
90f4ed9753
commit
ac3195851a
|
@ -1,24 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
<building name="castle" capacity="1">
|
||||
<function name="name" value="castle_name_2"/>
|
||||
<function name="protection" value="lua_building_protection"/>
|
||||
<function name="protection" value="building_protection"/>
|
||||
<function name="taxes" value="lua_building_taxes"/>
|
||||
<construction skill="building" minskill="1" maxsize="10" reqsize="1">
|
||||
<construction skill="building" minskill="1" maxsize="10" reqsize="1" prot="0">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="2" maxsize="40" reqsize="1">
|
||||
<construction skill="building" minskill="2" maxsize="40" reqsize="1" prot="1">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="3" maxsize="200" reqsize="1">
|
||||
<construction skill="building" minskill="3" maxsize="200" reqsize="1" prot="3">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="4" maxsize="1000" reqsize="1">
|
||||
<construction skill="building" minskill="4" maxsize="1000" reqsize="1" prot="5">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="5" maxsize="5000" reqsize="1">
|
||||
<construction skill="building" minskill="5" maxsize="5000" reqsize="1" prot="8">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="6" reqsize="1">
|
||||
<construction skill="building" minskill="6" reqsize="1" prot="12">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
</building>
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
<building name="castle" capacity="1">
|
||||
<function name="name" value="castle_name"/>
|
||||
<function name="protection" value="eressea_building_protection"/>
|
||||
<construction skill="building" minskill="1" maxsize="2" reqsize="1">
|
||||
<function name="protection" value="building_protection"/>
|
||||
<construction skill="building" minskill="1" maxsize="2" reqsize="1" prot="0">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="1" maxsize="8" reqsize="1">
|
||||
<construction skill="building" minskill="1" maxsize="8" reqsize="1" prot="0">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="2" maxsize="40" reqsize="1">
|
||||
<construction skill="building" minskill="2" maxsize="40" reqsize="1" prot="1">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="3" maxsize="200" reqsize="1">
|
||||
<construction skill="building" minskill="3" maxsize="200" reqsize="1" prot="3">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="4" maxsize="1000" reqsize="1">
|
||||
<construction skill="building" minskill="4" maxsize="1000" reqsize="1" prot="5">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="5" maxsize="5000" reqsize="1">
|
||||
<construction skill="building" minskill="5" maxsize="5000" reqsize="1" prot="8">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="6" reqsize="1">
|
||||
<construction skill="building" minskill="6" reqsize="1" prot="12">
|
||||
<requirement type="stone" quantity="1"/>
|
||||
</construction>
|
||||
</building>
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
<building name="watch" capacity="1" maxsize="10">
|
||||
<function name="name" value="fort_name"/>
|
||||
<function name="protection" value="lua_building_protection"/>
|
||||
<function name="protection" value="building_protection"/>
|
||||
<function name="taxes" value="lua_building_taxes"/>
|
||||
<construction skill="building" minskill="1" maxsize="5" reqsize="1">
|
||||
<construction skill="building" minskill="1" maxsize="5" reqsize="1" prot="0">
|
||||
<requirement type="log" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="2" maxsize="5" reqsize="1">
|
||||
<construction skill="building" minskill="2" maxsize="5" reqsize="1" prot="1">
|
||||
<requirement type="log" quantity="1"/>
|
||||
</construction>
|
||||
<construction skill="building" minskill="2" reqsize="1">
|
||||
<construction skill="building" minskill="2" reqsize="1" prot="2">
|
||||
<requirement type="log" quantity="1"/>
|
||||
</construction>
|
||||
</building>
|
||||
|
|
|
@ -26,10 +26,6 @@ function item_canuse(u, iname)
|
|||
return true
|
||||
end
|
||||
|
||||
function building_protection(b, u)
|
||||
return 1
|
||||
end
|
||||
|
||||
function building_taxes(b, blevel)
|
||||
btype = b.type
|
||||
if btype=="castle" then
|
||||
|
|
|
@ -1901,7 +1901,7 @@ int skilldiff(troop at, troop dt, int dist)
|
|||
init = true;
|
||||
}
|
||||
if (df->building->type->protection) {
|
||||
int beff = df->building->type->protection(df->building, du);
|
||||
int beff = df->building->type->protection(df->building, du, DEFENSE_BONUS);
|
||||
if (beff) {
|
||||
skdiff -= beff;
|
||||
is_protected = 2;
|
||||
|
@ -1918,7 +1918,7 @@ int skilldiff(troop at, troop dt, int dist)
|
|||
if (magicwalls_ct
|
||||
&& curse_active(get_curse(df->building->attribs, magicwalls_ct))) {
|
||||
/* Verdoppelt Burgenbonus */
|
||||
skdiff -= buildingeffsize(df->building, false);
|
||||
skdiff -= df->building->type->protection(df->building, du, DEFENSE_BONUS);
|
||||
}
|
||||
}
|
||||
/* Goblin-Verteidigung
|
||||
|
|
|
@ -57,7 +57,7 @@ static void test_make_fighter(CuTest * tc)
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static int add_two(building * b, unit * u) {
|
||||
static int add_two(building * b, unit * u, buildingbonus bonus) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -388,32 +388,6 @@ static void lua_agebuilding(building * b)
|
|||
}
|
||||
}
|
||||
|
||||
static int lua_building_protection(building * b, unit * u)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
const char *fname = "building_protection";
|
||||
int result = 0;
|
||||
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
|
||||
if (lua_pcall(L, 2, 1, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("building_protection(%s, %s) calling '%s': %s.\n", buildingname(b), unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
log_error("building_protection(%s, %s) calling '%s': not a function.\n", buildingname(b), unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static double lua_building_taxes(building * b, int level)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
|
|
|
@ -45,6 +45,9 @@ extern "C" {
|
|||
|
||||
int maxsize; /* maximum size of this type */
|
||||
int reqsize; /* size of object using up 1 set of requirement. */
|
||||
int prot; /* protection bonus (defense) during combat */
|
||||
int ccbonus; /* close combat attack bonus*/
|
||||
int rangedbonus; /* ranged attack bonus */
|
||||
requirement *materials; /* material req'd to build one object */
|
||||
const struct building_type *btype;
|
||||
/* building type required to make this thing */
|
||||
|
|
|
@ -316,12 +316,32 @@ const building_type *findbuildingtype(const char *name,
|
|||
return (const building_type *)type.v;
|
||||
}
|
||||
|
||||
static int eressea_building_protection(building * b, unit * u)
|
||||
static int building_protection(building * b, unit * u, buildingbonus bonus)
|
||||
{
|
||||
int beff = buildingeffsize(b, false) - 1;
|
||||
/* -1 because the tradepost has no protection value */
|
||||
|
||||
return beff;
|
||||
int i = 0;
|
||||
int bsize = buildingeffsize(b, false);
|
||||
const construction *cons = b->type->construction;
|
||||
if (!cons || !cons->improvement) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < bsize; i++)
|
||||
{
|
||||
cons = cons->improvement;
|
||||
}
|
||||
|
||||
switch (bonus)
|
||||
{
|
||||
case DEFENSE_BONUS:
|
||||
return cons->prot;
|
||||
case CC_ATTACK_BONUS:
|
||||
return cons->ccbonus;
|
||||
case RANGED_ATTACK_BONUS:
|
||||
return cons->rangedbonus;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int meropis_building_protection(building * b, unit * u)
|
||||
|
@ -331,8 +351,8 @@ static int meropis_building_protection(building * b, unit * u)
|
|||
|
||||
void register_buildings(void)
|
||||
{
|
||||
register_function((pf_generic)& eressea_building_protection,
|
||||
"eressea_building_protection");
|
||||
register_function((pf_generic)& building_protection,
|
||||
"building_protection");
|
||||
register_function((pf_generic)& meropis_building_protection,
|
||||
"meropis_building_protection");
|
||||
register_function((pf_generic)& init_smithy, "init_smithy");
|
||||
|
|
|
@ -48,6 +48,12 @@ extern "C" {
|
|||
#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 */
|
||||
|
||||
typedef enum {
|
||||
DEFENSE_BONUS,
|
||||
CC_ATTACK_BONUS,
|
||||
RANGED_ATTACK_BONUS,
|
||||
} buildingbonus;
|
||||
|
||||
typedef struct building_type {
|
||||
char *_name;
|
||||
|
||||
|
@ -66,7 +72,7 @@ extern "C" {
|
|||
const struct building * b, int size);
|
||||
void (*init) (struct building_type *);
|
||||
void (*age) (struct building *);
|
||||
int (*protection) (struct building *, struct unit *);
|
||||
int (*protection) (struct building *, struct unit *, buildingbonus);
|
||||
double (*taxes) (const struct building *, int size);
|
||||
struct attrib *attribs;
|
||||
} building_type;
|
||||
|
|
|
@ -167,7 +167,10 @@ construction ** consPtr)
|
|||
con->maxsize = xml_ivalue(node, "maxsize", -1);
|
||||
con->minskill = xml_ivalue(node, "minskill", -1);
|
||||
con->reqsize = xml_ivalue(node, "reqsize", -1);
|
||||
|
||||
con->prot = xml_ivalue(node, "prot", 0);
|
||||
con->ccbonus = xml_ivalue(node, "ccbonus", 0);
|
||||
con->rangedbonus = xml_ivalue(node, "rangedbonus", 0);
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "building");
|
||||
if (propValue != NULL) {
|
||||
con->btype = bt_get_or_create((const char *)propValue);
|
||||
|
@ -297,7 +300,7 @@ static int parse_buildings(xmlDocPtr doc)
|
|||
btype->age = (void(*)(struct building *))fun;
|
||||
}
|
||||
else if (strcmp((const char *)propValue, "protection") == 0) {
|
||||
btype->protection = (int(*)(struct building *, struct unit *))fun;
|
||||
btype->protection = (int(*)(struct building *, struct unit *, buildingbonus))fun;
|
||||
}
|
||||
else if (strcmp((const char *)propValue, "taxes") == 0) {
|
||||
btype->taxes = (double(*)(const struct building *, int))fun;
|
||||
|
|
Loading…
Reference in New Issue