Weihnachtsevent mit dickem Gnom und Sonnensegeln, jetzt komplett implementiert.

Beinhaltet Partei-Inventory und neuen Befehl CLAIM / BEANSPRUCHEN.
This commit is contained in:
Enno Rehling 2004-12-22 00:53:12 +00:00
parent d4da3b1223
commit 080a9a8bba
12 changed files with 171 additions and 39 deletions

View File

@ -746,6 +746,7 @@ cr_output_unit(FILE * F, const region * r,
fputs("1;hero\n", F); fputs("1;hero\n", F);
} }
#endif #endif
if (fval(u, UFL_HUNGER) && (u->faction == f)) { if (fval(u, UFL_HUNGER) && (u->faction == f)) {
fputs("1;hunger\n", F); fputs("1;hunger\n", F);
} }
@ -753,7 +754,6 @@ cr_output_unit(FILE * F, const region * r,
fprintf(F, "%d;Aura\n", get_spellpoints(u)); fprintf(F, "%d;Aura\n", get_spellpoints(u));
fprintf(F, "%d;Auramax\n", max_spellpoints(u->region,u)); fprintf(F, "%d;Auramax\n", max_spellpoints(u->region,u));
} }
/* default commands */ /* default commands */
fprintf(F, "COMMANDS\n"); fprintf(F, "COMMANDS\n");
if (u->lastorder) { if (u->lastorder) {
@ -1085,6 +1085,7 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
const time_t report_time) const time_t report_time)
{ {
int i; int i;
item * itm;
const char * prefix; const char * prefix;
region * r; region * r;
building *b; building *b;
@ -1159,6 +1160,12 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
fprintf(F, "\"%s\";Parteiname\n", f->name); fprintf(F, "\"%s\";Parteiname\n", f->name);
fprintf(F, "\"%s\";email\n", f->email); fprintf(F, "\"%s\";email\n", f->email);
fprintf(F, "\"%s\";banner\n", f->banner); fprintf(F, "\"%s\";banner\n", f->banner);
for (itm=f->items; itm; itm=itm->next) {
int in = itm->number;
const char * ic = LOC(f->locale, resourcename(itm->type->rtype, in));
if (itm==f->items) fputs("GEGENSTAENDE\n", F);
fprintf(F, "%d;%s\n", in, add_translation(ic, LOC(f->locale, ic)));
}
fputs("OPTIONEN\n", F); fputs("OPTIONEN\n", F);
for (i=0;i!=MAXOPTIONS;++i) { for (i=0;i!=MAXOPTIONS;++i) {
fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]); fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]);

View File

@ -3644,6 +3644,38 @@ use_cmd(unit * u, struct order * ord)
return 0; return 0;
} }
static int
claim_cmd(unit * u, struct order * ord)
{
const char * t;
int n;
const item_type * itype;
init_tokens(ord);
skip_token();
t = getstrtoken();
n = atoi(t);
if (n==0) {
n = 1;
} else {
t = getstrtoken();
}
itype = finditemtype(t, u->faction->locale);
if (itype!=NULL) {
item ** iclaim = i_find(&u->faction->items, itype);
if (iclaim!=NULL) {
n = min(n, (*iclaim)->number);
i_change(iclaim, itype, -n);
i_change(&u->items, itype, n);
}
} else {
cmistake(u, ord, 43, MSG_PRODUCE);
}
return 0;
}
void void
processorders (void) processorders (void)
{ {
@ -3666,6 +3698,7 @@ processorders (void)
age_factions(); age_factions();
puts(" - Benutzen"); puts(" - Benutzen");
parse(K_CLAIM, claim_cmd, false);
parse(K_USE, use_cmd, false); parse(K_USE, use_cmd, false);
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)"); puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)");

View File

@ -2065,6 +2065,24 @@ report(FILE *F, faction * f, const faction_list * addresses,
} }
#endif #endif
if (f->items!=NULL) {
item * iclaim = f->items;
char * edit = buf;
strcpy(edit, LOC(f->locale, "claimable"));
edit += strlen(edit);
while (iclaim!=NULL) {
sprintf(edit, "%d %s", iclaim->number,
LOC(f->locale, resourcename(iclaim->type->rtype, iclaim->number)));
iclaim = iclaim->next;
if (iclaim!=NULL) {
strcat(edit, ", ");
}
edit += strlen(edit);
}
rnl(F);
centre(F, buf, true);
}
if (f->age > 1 && f->lastorders != turn) { if (f->age > 1 && f->lastorders != turn) {
rnl(F); rnl(F);
if (turn - f->lastorders == 1) { if (turn - f->lastorders == 1) {

View File

@ -406,8 +406,9 @@ const char *keywords[MAXKEYWORDS] =
"WERWESEN", "WERWESEN",
"XONTORMIA", "XONTORMIA",
"ALLIANZ", "ALLIANZ",
"BEANSPRUCHEN",
#ifdef HEROES #ifdef HEROES
"PROMOTION" "PROMOTION",
#endif #endif
}; };

View File

@ -160,6 +160,7 @@ struct building_type;
#define CURSEVIGOURISFLOAT_VERSION 315 #define CURSEVIGOURISFLOAT_VERSION 315
#define SAVEXMLNAME_VERSION 316 #define SAVEXMLNAME_VERSION 316
#define SAVEALLIANCE_VERSION 317 #define SAVEALLIANCE_VERSION 317
#define CLAIM_VERSION 318
#define MIN_VERSION ALLIANCES_VERSION #define MIN_VERSION ALLIANCES_VERSION
#define REGIONOWNERS_VERSION 400 #define REGIONOWNERS_VERSION 400
@ -168,7 +169,7 @@ struct building_type;
#ifdef REGIONOWNERS #ifdef REGIONOWNERS
# define RELEASE_VERSION REGIONOWNERS_VERSION # define RELEASE_VERSION REGIONOWNERS_VERSION
#else #else
# define RELEASE_VERSION SAVEALLIANCE_VERSION # define RELEASE_VERSION CLAIM_VERSION
#endif #endif
#if RESOURCE_CONVERSION #if RESOURCE_CONVERSION
@ -448,6 +449,7 @@ enum {
K_WEREWOLF, K_WEREWOLF,
K_XE, K_XE,
K_ALLIANCE, K_ALLIANCE,
K_CLAIM,
#ifdef HEROES #ifdef HEROES
K_PROMOTION, K_PROMOTION,
#endif #endif

View File

@ -97,6 +97,7 @@ typedef struct faction {
struct region * r; struct region * r;
struct message_list * msgs; struct message_list * msgs;
} * battles; } * battles;
struct item * items; /* items this faction can claim */
} faction; } faction;
typedef struct faction_list { typedef struct faction_list {

View File

@ -1578,6 +1578,11 @@ readfaction(FILE * F)
freset(f, FFL_OVERRIDE); freset(f, FFL_OVERRIDE);
a_read(F, &f->attribs); a_read(F, &f->attribs);
#if RELEASE_VERSION>=CLAIM_VERSION
if (global.data_version>=CLAIM_VERSION) {
read_items(F, &f->items);
}
#endif
#ifdef MSG_LEVELS #ifdef MSG_LEVELS
read_msglevels(&f->warnings, F); read_msglevels(&f->warnings, F);
#else #else
@ -1670,6 +1675,10 @@ writefaction(FILE * F, const faction * f)
wi(F, f->flags); wi(F, f->flags);
a_write(F, f->attribs); a_write(F, f->attribs);
wnl(F); wnl(F);
if (global.data_version>=CLAIM_VERSION) {
write_items(F, f->items);
wnl(F);
}
#ifdef MSG_LEVELS #ifdef MSG_LEVELS
write_msglevels(f->warnings, F); write_msglevels(f->warnings, F);
#else #else

View File

@ -5,6 +5,8 @@
// kernel includes // kernel includes
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/message.h>
#include <kernel/unit.h> #include <kernel/unit.h>
// util includes // util includes
@ -146,6 +148,24 @@ faction_delete_variable(faction& f, const char *key)
return delete_variable(&((&f)->attribs), key); return delete_variable(&((&f)->attribs), key);
} }
static int
faction_additem(faction& f, const char * iname, int number)
{
const item_type * itype = it_find(iname);
if (itype!=NULL) {
item * i = i_change(&f.items, itype, number);
return i?i->number:0;
} // if (itype!=NULL)
return -1;
}
static void
faction_addnotice(faction& f, const char * str)
{
str = LOC(f.locale, str);
ADDMSG(&f.msgs, msg_message("msg_event", "string", str));
}
void void
bind_faction(lua_State * L) bind_faction(lua_State * L)
{ {
@ -170,6 +190,8 @@ bind_faction(lua_State * L)
.def_readwrite("age", &faction::age) .def_readwrite("age", &faction::age)
.def_readwrite("subscription", &faction::subscription) .def_readwrite("subscription", &faction::subscription)
.def_readwrite("lastturn", &faction::lastorders) .def_readwrite("lastturn", &faction::lastorders)
.def("add_item", &faction_additem)
.def("add_notice", &faction_addnotice)
.property("locale", &faction_locale) .property("locale", &faction_locale)
.property("units", &faction_units, return_stl_iterator) .property("units", &faction_units, return_stl_iterator)
.property("alliance", &faction_getalliance, &faction_setalliance) .property("alliance", &faction_getalliance, &faction_setalliance)

View File

@ -1848,6 +1848,10 @@
<string name="BIETEN"> <string name="BIETEN">
<text locale="de">BIETEN</text> <text locale="de">BIETEN</text>
</string> </string>
<string name="BEANSPRUCHEN">
<text locale="de">BEANSPRUCHEN</text>
<text locale="en">CLAIM</text>
</string>
<string name="BEKLAUEN"> <string name="BEKLAUEN">
<text locale="de">BEKLAUEN</text> <text locale="de">BEKLAUEN</text>
</string> </string>
@ -6003,4 +6007,22 @@
</string> </string>
</namespace> </namespace>
<string name="claimable">
<text locale="de">Einheiten können die folgenden Gegenstände beansprucht werden: </text>
<text locale="en">Units can claim the following items: </text>
</string>
<string name="santa2004">
<text locale="de">'Ho ho ho!' Ein dicker Gnom fliegt auf einem von
8 Jungdrachen gezogenen Schlitten durch die Nacht und vermacht Deiner
Partei ein Sonnensegel. (Um das Segel einer Einheit zu geben, gib
ihr den Befehl 'BEANSPRUCHE 1 Sonnensegel').</text>
<text locale="en">'Ho ho ho!' A fat little gnome Gnom on a sled
pulled by 8 young dragons flies through the stary night and presents
your faction with a solar sail. (To claim this item, one of your units
must issue the order 'CLAIM 1 solar sail'
Partei ein Sonnensegel. (Um das Segel einer Einheit zu geben, gib
ihr den Befehl 'BEANSPRUCHE 1 Sonnensegel').</text>
</string>
</strings> </strings>

View File

@ -18,6 +18,19 @@ function write_emails()
end end
end end
function run_scripts()
scripts = {
"xmas2004"
}
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
end
function process(orders) function process(orders)
file = "" .. get_turn() file = "" .. get_turn()
if read_game(file)~=0 then if read_game(file)~=0 then
@ -36,9 +49,9 @@ function process(orders)
read_orders(orders) read_orders(orders)
plan_monsters() plan_monsters()
-- igjarjuk gets called: -- load scripts:
-- require("igjarjuk-call.lua") run_scripts()
-- call_igjarjuk()
u = get_unit(atoi36("50ki")) u = get_unit(atoi36("50ki"))
if u~=nil then if u~=nil then
u.region:set_flag(14, true) u.region:set_flag(14, true)
@ -46,12 +59,6 @@ function process(orders)
-- --
process_orders() process_orders()
-- igjarjuk special
-- if get_turn() > 374 then
-- require("igjarjuk.lua")
-- wyrm()
-- end
write_passwords() write_passwords()
write_reports() write_reports()

View File

@ -13,9 +13,6 @@ function test_sail()
orc:add_order("NUMMER EINHEIT orc") orc:add_order("NUMMER EINHEIT orc")
orc:add_order("BENENNE EINHEIT Orks") orc:add_order("BENENNE EINHEIT Orks")
orc:add_order("ZEIGEN \"Sonnensegel\"") orc:add_order("ZEIGEN \"Sonnensegel\"")
process_orders()
write_reports()
end end
function test_movement() function test_movement()
@ -93,9 +90,6 @@ function test_movement()
u2:add_order("NUMMER EINHEIT Last") u2:add_order("NUMMER EINHEIT Last")
u2:add_order("BENENNE EINHEIT Verfolger-Verfolger") u2:add_order("BENENNE EINHEIT Verfolger-Verfolger")
process_orders()
write_reports()
end end
@ -133,8 +127,6 @@ function test_handler()
u:add_order("NUMMER PARTEI eviL") u:add_order("NUMMER PARTEI eviL")
u:add_order(msg) u:add_order(msg)
process_orders()
write_reports()
end end
function test_combat() function test_combat()
@ -169,8 +161,6 @@ function test_combat()
u:add_order("KAEMPFE") u:add_order("KAEMPFE")
u:add_order(attack) u:add_order(attack)
process_orders()
write_reports()
end end
function test_rewards() function test_rewards()
@ -238,8 +228,6 @@ function test_rewards()
end end
u:add_order("NUMMER PARTEI eviL") u:add_order("NUMMER PARTEI eviL")
process_orders()
write_reports()
end end
function test_give() function test_give()
@ -256,16 +244,11 @@ function test_give()
u:add_order("GIB TEMP eins ALLES silber") u:add_order("GIB TEMP eins ALLES silber")
u:add_order("NUMMER PARTEI test") u:add_order("NUMMER PARTEI test")
process_orders()
write_reports()
end end
function test_write() function test_write()
read_game("24") read_game("24")
read_orders("befehle") read_orders("befehle")
process_orders()
write_reports()
write_game("25")
end end
function move_north(u) function move_north(u)
@ -291,7 +274,6 @@ function test_monsters()
set_brain("braineater", move_north) set_brain("braineater", move_north)
plan_monsters() plan_monsters()
process_orders()
end end
function test_parser() function test_parser()
@ -308,10 +290,6 @@ function test_parser()
u:add_order("Nummer Partei test") u:add_order("Nummer Partei test")
u:add_order("BENENNE PARTEI \"Diese Partei heisst \\\"Enno's Schergen\\\".\"") u:add_order("BENENNE PARTEI \"Diese Partei heisst \\\"Enno's Schergen\\\".\"")
u:add_order("BENENNE EINHEIT \"Mein Name ist \\\"Enno\\\".\"") u:add_order("BENENNE EINHEIT \"Mein Name ist \\\"Enno\\\".\"")
process_orders()
write_reports()
write_game("parser")
end end
function test_fail() function test_fail()
@ -322,7 +300,19 @@ function test_fail()
print(f) print(f)
end end
test_sail() function run_scripts()
scripts = {
"xmas2004.lua"
}
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
end
-- test_movement() -- test_movement()
-- test_fail() -- test_fail()
-- test_handler() -- test_handler()
@ -332,5 +322,8 @@ test_sail()
-- test_rewards() -- test_rewards()
-- test_give() -- test_give()
-- test_write() -- test_write()
-- read_game("test")
-- write_game("test") test_sail()
run_scripts()
process_orders()
write_reports()

17
src/scripts/xmas2004.lua Normal file
View File

@ -0,0 +1,17 @@
function xmas2004()
print(get_gamename())
if get_gamename() == "Eressea" then
if not get_flag("xm04") then
print("Es weihnachtet sehr")
set_flag("xm04", true)
for f in factions() do
f:add_item("speedsail", 1)
f:add_notice("santa2004")
print(f)
end
end
end
end
print("Ja, ist denn schon Weihnachten?")
xmas2004()