WdW-Pyramiden

This commit is contained in:
Christian Schlittchen 2005-10-23 11:27:55 +00:00
parent f6cc641d9c
commit 1c7ace7556
13 changed files with 224 additions and 101 deletions

View File

@ -9,6 +9,7 @@ SubDirHdrs $(SUBDIR)/../.. ;
SOURCES = SOURCES =
aggressive.c aggressive.c
alliance.c
at_movement.c at_movement.c
attributes.c attributes.c
fleechance.c fleechance.c

View File

@ -39,6 +39,9 @@
#endif #endif
#include "moved.h" #include "moved.h"
#include "variable.h" #include "variable.h"
#ifdef WDW_PYRAMID
#include "alliance.h"
#endif
/* util includes */ /* util includes */
#include <attrib.h> #include <attrib.h>

View File

@ -24,6 +24,7 @@
#include <attributes/overrideroads.h> #include <attributes/overrideroads.h>
#include <attributes/viewrange.h> #include <attributes/viewrange.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/alliance.h>
#ifdef AT_OPTION #ifdef AT_OPTION
# include <attributes/option.h> # include <attributes/option.h>
#endif #endif
@ -61,6 +62,7 @@
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/teleport.h> #include <kernel/teleport.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/alliance.h>
#ifdef USE_UGROUPS #ifdef USE_UGROUPS
# include <ugroup.h> # include <ugroup.h>
#endif #endif
@ -1870,20 +1872,59 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
scat(b->display); scat(b->display);
i = b->display[strlen(b->display) - 1]; i = b->display[strlen(b->display) - 1];
} }
#ifdef WDW_PYRAMID
if (i != '!' && i != '?' && i != '.')
scat(", ");
if(b->type == bt_find("pyramid")) {
unit * owner = buildingowner(r, b);
scat("Größenstufe ");
icat(wdw_pyramid_level(b));
scat(".");
if (owner && owner->faction==f) {
const construction *ctype = b->type->construction;
int completed = b->size;
int c;
scat(" Baukosten pro Größenpunkt: ");
while(ctype->improvement != NULL &&
ctype->improvement != ctype &&
ctype->maxsize > 0 &&
ctype->maxsize <= completed)
{
completed -= ctype->maxsize;
ctype = ctype->improvement;
}
assert(ctype->materials != NULL);
for (c=0;ctype->materials[c].number;c++) {
resource_t rtype = ctype->materials[c].type;
int number = ctype->materials[c].number;
if(c > 0) {
scat(", ");
}
icat(number);
scat(" ");
scat(locale_string(lang,
resourcename(oldresourcetype[rtype],
number!=1?GR_PLURAL:0)));
}
scat(".");
}
}
#else
if (i != '!' && i != '?' && i != '.') if (i != '!' && i != '?' && i != '.')
scat("."); scat(".");
#if WDW_PYRAMID
if(b->type == bt_find("wdw_pyramid")) {
attrib *a = a_find(b->attribs, &at_alliance));
if(f->alliance && f->alliance->id == a->data.i) {
scat("Die Größenstufe dieser Pyramide ist ");
icat(wdw_pyramid_level(b));
scat(". Die nächste Größenstufe wird mit ");
icat(wdw_pyramid_size_for_next_level(b));
scat(" Größenpunkten erreicht. Baukosten pro Größenpunkt: ");
}
}
#endif #endif
rparagraph(F, buf, 2, 0); rparagraph(F, buf, 2, 0);

View File

@ -40,6 +40,7 @@
#include "ship.h" #include "ship.h"
#include "skill.h" #include "skill.h"
#include "unit.h" #include "unit.h"
#include "alliance.h"
/* from libutil */ /* from libutil */
#include <attrib.h> #include <attrib.h>
@ -59,6 +60,7 @@
/* attributes inclues */ /* attributes inclues */
#include <attributes/matmod.h> #include <attributes/matmod.h>
#include <attributes/alliance.h>
#define STONERECYCLE 50 #define STONERECYCLE 50
/* Name, MaxGroesse, MinBauTalent, Kapazitaet, {Eisen, Holz, Stein, BauSilber, /* Name, MaxGroesse, MinBauTalent, Kapazitaet, {Eisen, Holz, Stein, BauSilber,
@ -627,16 +629,19 @@ build(unit * u, const construction * ctype, int completed, int want)
effsk = basesk; effsk = basesk;
if (inside_building(u)) { if (inside_building(u)) {
effsk = skillmod(u->building->type->attribs, u, u->region, type->skill, effsk, SMF_PRODUCTION); effsk = skillmod(u->building->type->attribs, u, u->region, type->skill,
effsk, SMF_PRODUCTION);
} }
effsk = skillmod(type->attribs, u, u->region, type->skill, effsk, SMF_PRODUCTION); effsk = skillmod(type->attribs, u, u->region, type->skill,
effsk, SMF_PRODUCTION);
if (effsk<0) return effsk; /* pass errors to caller */ if (effsk<0) return effsk; /* pass errors to caller */
if (effsk==0) return ENEEDSKILL; if (effsk==0) return ENEEDSKILL;
skills = effsk * u->number; skills = effsk * u->number;
/* technically, nimblefinge and domore should be in a global set of "game"-attributes, /* technically, nimblefinge and domore should be in a global set of
* (as at_skillmod) but for a while, we're leaving them in here. */ * "game"-attributes, (as at_skillmod) but for a while, we're leaving
* them in here. */
if (dm != 0) { if (dm != 0) {
/* Auswirkung Schaffenstrunk */ /* Auswirkung Schaffenstrunk */
@ -649,9 +654,9 @@ build(unit * u, const construction * ctype, int completed, int want)
/* skip over everything that's already been done: /* skip over everything that's already been done:
* type->improvement==NULL means no more improvements, but no size limits * type->improvement==NULL means no more improvements, but no size limits
* type->improvement==type means build another object of the same time while material lasts * type->improvement==type means build another object of the same time
* type->improvement==x means build x when type is finished * while material lasts type->improvement==x means build x when type
*/ * is finished */
while (type->improvement!=NULL && while (type->improvement!=NULL &&
type->improvement!=type && type->improvement!=type &&
type->maxsize>0 && type->maxsize>0 &&
@ -852,6 +857,13 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
cmistake(u, ord, 221, MSG_PRODUCE); cmistake(u, ord, 221, MSG_PRODUCE);
return; return;
} }
if (btype->flags & BTF_ONEPERTURN) {
if(b && fval(b, BLD_EXPANDED)) {
cmistake(u, ord, 318, MSG_PRODUCE);
return;
}
want = 1;
}
if (b) built = b->size; if (b) built = b->size;
if (want<=0 || want == INT_MAX) { if (want<=0 || want == INT_MAX) {
@ -913,8 +925,8 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
u->building = b; u->building = b;
fset(u, UFL_OWNER); fset(u, UFL_OWNER);
#if WDW_PYRAMID #ifdef WDW_PYRAMID
if(b->type == bt_find("wdw_pyramid") && u->faction->alliance != NULL) { if(b->type == bt_find("pyramid") && u->faction->alliance != NULL) {
attrib * a = a_add(&b->attribs, a_new(&at_alliance)); attrib * a = a_add(&b->attribs, a_new(&at_alliance));
a->data.i = u->faction->alliance->id; a->data.i = u->faction->alliance->id;
} }
@ -949,6 +961,8 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
} }
b->size += built; b->size += built;
fset(b, BLD_EXPANDED);
update_lighthouse(b); update_lighthouse(b);

View File

@ -37,6 +37,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h>
/* attributes includes */ /* attributes includes */
#include <attributes/matmod.h> #include <attributes/matmod.h>
@ -298,81 +299,51 @@ castle_name(int bsize)
return fname[i]; return fname[i];
} }
#if WDW_PYRAMID #ifdef WDW_PYRAMID
static requirement wdw_pyramid_req[][] = {
{{R_STONE, 100, 0}, {R_WOOD, 100, 0}, {R_IRON, 100, 0}, {NORESOURCE, 0, 0.0 }},
{{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, {NORESOURCE, 0, 0.0 }},
{{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0},
{R_MALLORN, 1, 0}, {NORESOURCE, 0, 0.0 }},
{{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0},
{R_LAEN, 1, 0}, {NORESOURCE, 0, 0.0 }},
{{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0},
{R_TOADSLIME, 1, 0}, {NORESOURCE, 0, 0.0 }},
{{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0},
{R_BALM, 1, 0.0 }, {R_SPICES, 1, 0.0 }, {R_JEWELERY, 1, 0.0 },
{R_MYRRH, 1, 0.0 }, {R_OIL, 1, 0.0 }, {R_SILK, 1, 0.0 },
{R_INCENSE, 1, 0.0 }, {NORESOURCE, 0, 0.0 }}
}
static const char *
pyramid_name(int bsize)
{
static const struct building_type * bt_pyramid;
static char p_name_buf[32];
int level=0;
const construction * ctype;
static construction wdw_pyramid_bld[] = { if(!bt_pyramid) bt_pyramid = bt_find("pyramid");
{ SK_BUILDING, 10, 1, 1, pyramid_req[0], wdw_pyramid_bld[0] }, /* 0 -> 1 */ assert(bt_pyramid);
{ SK_BUILDING, 3, 6, 1, pyramid_req[1], wdw_pyramid_bld[1] }, /* -> 7 */
{ SK_BUILDING, 4, 1, 1, pyramid_req[2], wdw_pyramid_bld[2] }, /* -> 8 */ ctype = bt_pyramid->construction;
{ SK_BUILDING, 5, 13, 1, pyramid_req[1], wdw_pyramid_bld[3] }, /* -> 21 */
{ SK_BUILDING, 6, 1, 1, pyramid_req[3], wdw_pyramid_bld[4] }, /* -> 22 */ while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
{ SK_BUILDING, 7, 41, 1, pyramid_req[1], wdw_pyramid_bld[5] }, /* -> 63 */ bsize-=ctype->maxsize;
{ SK_BUILDING, 8, 1, 1, pyramid_req[4], wdw_pyramid_bld[6] }, /* -> 64 */ ctype=ctype->improvement;
{ SK_BUILDING, 9, 125, 1, pyramid_req[1], wdw_pyramid_bld[7] }, /* -> 189 */ ++level;
{ SK_BUILDING, 10, 1, 1, pyramid_req[5], wdw_pyramid_bld[8] }, /* -> 190 */ }
{ SK_BUILDING, 100, 100000, 1, pyramid_req[0], NULL } /* should never be seen */
sprintf(p_name_buf, "pyramid%d", level);
return p_name_buf;
} }
int int
wdw_pyramid_level(const struct building *b) wdw_pyramid_level(const struct building *b)
{ {
int size = 0; const construction *ctype = b->type->construction;
int level; int completed = b->size;
int level = 0;
for(level=0; wdw_pyramid_bld[level].improvement != NULL; level++) { while(ctype->improvement != NULL &&
size += wdw_pyramid_bld[level].maxsize; ctype->improvement != ctype &&
if(size > b->size) break; ctype->maxsize > 0 &&
ctype->maxsize <= completed)
{
++level;
completed-=ctype->maxsize;
ctype = ctype->improvement;
} }
return level; return level;
} }
int
wdw_pyramid_size_for_next_level(const struct building *b)
{
int size = 0;
int level;
for(level=0; wdw_pyramid_bld[level].improvement != NULL; level++) {
size += wdw_pyramid_bld[level].maxsize;
if(size > b->size) {
return size - b->size;
}
}
return INT_MAX;
}
static const char *
wdw_pyramid_name(int bsize)
{
return "wdw_pyramid";
}
building_type bt_wdw_pyramid = {
"wdw_pyramid",
BTF_INDESTRUCTIBLE,
1, 4, -1,
0, 0, 0, 1.0,
NULL,
&wdw_pyramid_bld[0],
wdw_pyramid_name
};
#endif #endif
/* for finding out what was meant by a particular building string */ /* for finding out what was meant by a particular building string */
@ -412,10 +383,8 @@ register_buildings(void)
{ {
register_function((pf_generic)init_smithy, "init_smithy"); register_function((pf_generic)init_smithy, "init_smithy");
register_function((pf_generic)castle_name, "castle_name"); register_function((pf_generic)castle_name, "castle_name");
#ifdef WDW_PYRAMID
#if WDW_PYRAMID register_function((pf_generic)pyramid_name, "pyramid_name");
register_function((pf_generic)wdw_pyramid_name, "wdw_pyramid_name");
bt_register(&bt_wdw_pyramid);
#endif #endif
} }

View File

@ -39,6 +39,7 @@ typedef struct maintenance {
#define BTF_DYNAMIC 0x10 /* dynamic type, needs bt_write */ #define BTF_DYNAMIC 0x10 /* dynamic type, needs bt_write */
#define BTF_PROTECTION 0x20 /* protection in combat */ #define BTF_PROTECTION 0x20 /* protection in combat */
#define BTF_MAGIC 0x40 /* magical effect */ #define BTF_MAGIC 0x40 /* magical effect */
#define BTF_ONEPERTURN 0x80 /* one one sizepoint can be added per turn */
typedef struct building_type { typedef struct building_type {
const char * _name; const char * _name;
@ -82,6 +83,7 @@ extern struct building_typelist *buildingtypes;
#define BLD_MAINTAINED 0x01 /* vital maintenance paid for */ #define BLD_MAINTAINED 0x01 /* vital maintenance paid for */
#define BLD_WORKING 0x02 /* full maintenance paid, it works */ #define BLD_WORKING 0x02 /* full maintenance paid, it works */
#define BLD_UNGUARDED 0x04 /* you can enter this building anytime */ #define BLD_UNGUARDED 0x04 /* you can enter this building anytime */
#define BLD_EXPANDED 0x08 /* has been expanded this turn */
#define BLD_SAVEMASK 0x00 /* mask for persistent flags */ #define BLD_SAVEMASK 0x00 /* mask for persistent flags */
@ -143,9 +145,8 @@ extern struct unit * buildingowner(const struct region * r, const struct buildin
extern attrib_type at_nodestroy; extern attrib_type at_nodestroy;
extern attrib_type at_building_action; extern attrib_type at_building_action;
#if WDW_PYRAMID #ifdef WDW_PYRAMID
extern int wdw_pyramid_size(const struct building *b); extern int wdw_pyramid_level(const struct building *b);
extern int wdw_pyramid_size_for_next_level(const struct building *b);
#endif #endif
typedef struct building_action { typedef struct building_action {

View File

@ -267,6 +267,7 @@ parse_buildings(xmlDocPtr doc)
bt->auraregen = xml_fvalue(node, "auraregen", 1.0); bt->auraregen = xml_fvalue(node, "auraregen", 1.0);
if (xml_bvalue(node, "nodestroy", false)) bt->flags |= BTF_INDESTRUCTIBLE; if (xml_bvalue(node, "nodestroy", false)) bt->flags |= BTF_INDESTRUCTIBLE;
if (xml_bvalue(node, "oneperturn", false)) bt->flags |= BTF_ONEPERTURN;
if (xml_bvalue(node, "nobuild", false)) bt->flags |= BTF_NOBUILD; if (xml_bvalue(node, "nobuild", false)) bt->flags |= BTF_NOBUILD;
if (xml_bvalue(node, "unique", false)) bt->flags |= BTF_UNIQUE; if (xml_bvalue(node, "unique", false)) bt->flags |= BTF_UNIQUE;
if (xml_bvalue(node, "decay", false)) bt->flags |= BTF_DECAY; if (xml_bvalue(node, "decay", false)) bt->flags |= BTF_DECAY;

View File

@ -53,4 +53,4 @@
#undef XECMD_MODULE #undef XECMD_MODULE
#define WDW_PHOENIX #define WDW_PHOENIX
#define WDW_PYRAMIDSPELL #define WDW_PYRAMIDSPELL
/* #define WDW_PYRAMID 1 */ #define WDW_PYRAMID

View File

@ -166,14 +166,6 @@
</construction> </construction>
</building> </building>
<building name="pyramid" capacity="1" maxcapacity="10000" nodestroy="yes">
<construction skill="sk_building" minskill="10" reqsize="1">
<requirement type="iron" quantity="100"/>
<requirement type="log" quantity="100"/>
<requirement type="stone" quantity="100"/>
</construction>
</building>
<building name="castle" capacity="1" maxcapacity="4"> <building name="castle" capacity="1" maxcapacity="4">
<function name="name" value="castle_name"/> <function name="name" value="castle_name"/>
<construction skill="sk_building" minskill="1" maxsize="2" reqsize="1"> <construction skill="sk_building" minskill="1" maxsize="2" reqsize="1">

View File

@ -2750,6 +2750,17 @@
<text locale="fr">"$unit($unit) drowns when $ship($ship) in $region($region) sinks."</text> <text locale="fr">"$unit($unit) drowns when $ship($ship) in $region($region) sinks."</text>
<text locale="en">"$unit($unit) drowns when $ship($ship) in $region($region) sinks."</text> <text locale="en">"$unit($unit) drowns when $ship($ship) in $region($region) sinks."</text>
</message> </message>
<message name="error318" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="region" type="region"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Das Gebäude kann nur einmal pro Runde erweitert werden."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Thhe building can be expanded only once per turn."</text>
</message>
<message name="error317" section="events"> <message name="error317" section="events">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>

View File

@ -46,6 +46,7 @@
<xi:include href="vinyambar/wdw-strings.xml"/> <xi:include href="vinyambar/wdw-strings.xml"/>
<xi:include href="vinyambar/wdw-resources.xml" /> <xi:include href="vinyambar/wdw-resources.xml" />
<xi:include href="vinyambar/wdw-races.xml"/> <xi:include href="vinyambar/wdw-races.xml"/>
<xi:include href="vinyambar/wdw-buildings.xml"/>
<strings> <strings>
<string name="mailto"> <string name="mailto">

View File

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<buildings>
<building name="pyramid" capacity="1" maxcapacity="10000" nodestroy="yes" oneperturn="yes">
<function name="name" value="pyramid_name"/>
<construction skill="sk_building" minskill="10" maxsize="1" reqsize="1">
<requirement type="iron" quantity="100"/>
<requirement type="log" quantity="100"/>
<requirement type="stone" quantity="100"/>
</construction>
<construction skill="sk_building" minskill="10" maxsize="4" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="log" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="8" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="12" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="16" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="20" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="24" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
<construction skill="sk_building" minskill="11" maxsize="28" reqsize="1">
<requirement type="iron" quantity="10"/>
<requirement type="mallorn" quantity="10"/>
<requirement type="stone" quantity="10"/>
</construction>
</building>
</buildings>

View File

@ -90,6 +90,48 @@
<text locale="de">Smaragde</text> <text locale="de">Smaragde</text>
<text locale="en">emeralds</text> <text locale="en">emeralds</text>
</string> </string>
<string name="pyramid0">
<text locale="de">Pyramide des Hapi</text>
<text locale="en">pyramid of Hapi</text>
</string>
<string name="pyramid1">
<text locale="de">Pyramide der Tayet</text>
<text locale="en">pyramid of Tayet</text>
</string>
<string name="pyramid2">
<text locale="de">Pyramide der Tefnut</text>
<text locale="en">pyramid of Tefnut</text>
</string>
<string name="pyramid3">
<text locale="de">Pyramide des Shu</text>
<text locale="en">pyramid of Shu</text>
</string>
<string name="pyramid4">
<text locale="de">Pyramide der Nuit</text>
<text locale="en">pyramid of Nuit</text>
</string>
<string name="pyramid5">
<text locale="de">Pyramide der Bastet</text>
<text locale="en">pyramid of Bastet</text>
</string>
<string name="pyramid6">
<text locale="de">Pyramide des Horus</text>
<text locale="en">pyramid of Horus </text>
</string>
<string name="pyramid7">
<text locale="de">Pyramide der Maat</text>
<text locale="en">pyramid of Maat</text>
</string>
<string name="pyramid8">
<text locale="de">Pyramide des Osiris</text>
<text locale="en">pyramid of Osiris</text>
</string>
<string name="pyramid9">
<text locale="de">Pyramide des Set</text>
<text locale="en">pyramid of Set</text>
</string>
<string name="pyramid10">
<text locale="de">Pyramide des Thoth</text>
<text locale="en">pyramid of Thoth</text>
</string>
</strings> </strings>