- Weihnachtsitem (Sonnensegel)

- Iteminfos könenn in den XML-Dateien stehen, brauchen keine eigene Datei mehr
- NEUSTART übernimmt das vorherige Parteialter
This commit is contained in:
Enno Rehling 2004-12-20 22:59:42 +00:00
parent a5239bb241
commit d4da3b1223
10 changed files with 233 additions and 67 deletions

View File

@ -120,6 +120,7 @@ restart_race(unit *u, const race * rc)
unit * nu = addplayer(u->region, f);
order ** ordp = &u->orders;
f->subscription = u->faction->subscription;
f->age = u->faction->age;
fset(f, FFL_RESTART);
if (f->subscription) {
sql_print(("UPDATE subscriptions set faction='%s', race='%s' where id=%u;\n",
@ -975,7 +976,7 @@ transfer_faction(faction *f, faction *f2)
}
static int
restart(unit * u, struct order * ord)
restart_cmd(unit * u, struct order * ord)
{
init_tokens(ord);
skip_token(); /* skip keyword */
@ -1091,7 +1092,7 @@ parse_quit(void)
break;
case K_RESTART:
if (u->number > 0) {
if (restart(u, ord)!=0) ord = NULL;
if (restart_cmd(u, ord)!=0) ord = NULL;
}
break;
}
@ -2211,35 +2212,42 @@ display_item(faction *f, unit *u, const item_type * itype)
char t[NAMESIZE + 1];
char filename[MAX_PATH];
const char *name;
const char *info;
const char *key;
if (u && *i_find(&u->items, itype) == NULL) return false;
name = resourcename(itype->rtype, 0);
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name);
fp = fopen(filename, "r");
if (!fp) {
name = locale_string(f->locale, resourcename(itype->rtype, 0));
key = mkname("iteminfo", name);
info = locale_string(f->locale, key);
if (info==key) {
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name);
fp = fopen(filename, "r");
}
if (!fp) {
name = resourcename(itype->rtype, 0);
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name);
fp = fopen(filename, "r");
}
if (!fp) return false;
buf[0]='\0';
while (fgets(t, NAMESIZE, fp) != NULL) {
if (t[strlen(t) - 1] == '\n') {
t[strlen(t) - 1] = 0;
if (!fp) {
name = locale_string(f->locale, resourcename(itype->rtype, 0));
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name);
fp = fopen(filename, "r");
}
strcat(buf, t);
if (!fp) {
name = resourcename(itype->rtype, 0);
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name);
fp = fopen(filename, "r");
}
if (!fp) return false;
buf[0]='\0';
while (fgets(t, NAMESIZE, fp) != NULL) {
if (t[strlen(t) - 1] == '\n') {
t[strlen(t) - 1] = 0;
}
strcat(buf, t);
}
fclose(fp);
info = buf;
}
fclose(fp);
name = buf;
ADDMSG(&f->msgs, msg_message("displayitem", "weight item description",
itype->weight/1000, itype->rtype, strdup(name)));
itype->weight/1000, itype->rtype, strdup(info)));
return true;
}

View File

@ -19,6 +19,7 @@
#include "xerewards.h"
#include "artrewards.h"
#include "weapons.h"
#include "speedsail.h"
#include "racespoils.h"
#if GROWING_TREES
# include "seed.h"
@ -42,6 +43,7 @@ register_items(void)
register_catapultammo();
register_racespoils();
register_artrewards();
register_speedsail();
}
void

View File

@ -175,6 +175,12 @@
<File
RelativePath=".\seed.c">
</File>
<File
RelativePath=".\speedsail.c">
</File>
<File
RelativePath=".\speedsail.h">
</File>
<File
RelativePath=".\weapons.c">
</File>

View File

@ -0,0 +1,84 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <config.h>
#include <eressea.h>
#include "speedsail.h"
/* kernel includes */
#include <faction.h>
#include <item.h>
#include <message.h>
#include <movement.h>
#include <plane.h>
#include <region.h>
#include <ship.h>
#include <unit.h>
/* util includes */
#include <functions.h>
/* libc includes */
#include <assert.h>
static int
use_speedsail(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
{
struct plane * p = rplane(u->region);
unused(amount);
unused(itype);
if (p!=NULL) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
return EUNUSABLE;
} else {
if (u->ship) {
attrib * a = a_find(u->ship->attribs, &at_speedup);
if (a!=NULL) {
a = a_add(&u->ship->attribs, a_new(&at_speedup));
a->data.sa[0] = 50; /* speed */
a->data.sa[1] = 50; /* decay */
ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit", u));
return 0;
} else {
cmistake(u, ord, 211, MSG_EVENT);
}
} else {
cmistake(u, ord, 144, MSG_EVENT);
}
return EUNUSABLE;
}
}
static resource_type rt_speedsail = {
{ "speedsail", "speedsail_p" },
{ "speedsail", "speedsail_p" },
RTF_ITEM,
&res_changeitem
};
item_type it_speedsail = {
&rt_speedsail, /* resourcetype */
0, 0, 0, /* flags, weight, capacity */
NULL, /* construction */
&use_speedsail,
NULL,
NULL
};
void
register_speedsail(void)
{
it_register(&it_speedsail);
}

View File

@ -0,0 +1,26 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef H_ITM_SPEEDVIAL
#define H_ITM_SPEEDVIAL
#ifdef __cplusplus
extern "C" {
#endif
extern void register_speedsail(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -587,7 +587,7 @@ shipspeed (const ship * sh, const unit * u)
a = a_find(sh->attribs, &at_speedup);
while (a != NULL) {
k += a->data.i;
k += a->data.sa[0];
a = a->nexttype;
}

View File

@ -159,10 +159,10 @@ attrib_type at_shiptrail = {
static int
age_speedup(attrib *a)
{
if(a->data.i > 0) {
--a->data.i;
if (a->data.sa[0] > 0) {
a->data.sa[0] = a->data.sa[0] - a->data.sa[1];
}
return a->data.i;
return a->data.sa[0]>0;
}
attrib_type at_speedup = {

View File

@ -7,6 +7,19 @@
_a: including article (ein Troll, a troll)
-->
<namespace name="iteminfo">
<string name="speedsail">
<text locale="de">
Setzt eine Einheit dieses Segel auf einem Schiff, so erhöht
sich dessen Reichweite kurzfristig um 50 Regionen.
</text>
<text locale="en">
A unit setting this sail on a ship temporarily increases the
ship's range by 50 regions.
</text>
</string>
</namespace>
<namespace name="school">
<string name="none">
<text locale="de">Kein Magiegebiet</text>
@ -575,6 +588,14 @@
<text locale="de">Katapultmunition</text>
<text locale="en">ammunition</text>
</string>
<string name="speedsail">
<text locale="de">Sonnensegel</text>
<text locale="en">solar sail</text>
</string>
<string name="speedsail_p">
<text locale="de">Sonnensegel</text>
<text locale="en">solar sails</text>
</string>
<string name="elfspoil">
<text locale="de">Elfenohr</text>
@ -3947,33 +3968,23 @@
</string>
<string name="miracle_doctor">
<text locale="de">
Wenn einem der Alchemist nicht weiterhelfen kann, geht
man zu dem
gelehrten Tybiedmagier. Seine Tränke und Tinkturen
helfen gegen alles,
was man sonst nicht bekommen kann. Ob nun die kryptische
Formel unter dem
Holzschuh des untreuen Ehemannes wirklich geholfen hat -
nun, der des
Lesens nicht mächtige Bauer wird es nie wissen. Dem
Magier hilft es
auf jeden Fall... beim Füllen seines Geldbeutels. 50
Silber pro Stufe
lassen sich so in einer Woche verdienen.
Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem
gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen
alles, was man sonst nicht bekommen kann. Ob nun die kryptische
Formel unter dem Holzschuh des untreuen Ehemannes wirklich geholfen
hat - nun, der des Lesens nicht mächtige Bauer wird es nie wissen.
Dem Magier hilft es auf jeden Fall... beim Füllen seines
Geldbeutels. 50 Silber pro Stufe lassen sich so in einer Woche
verdienen.
</text>
<text locale="en">
If the local alchemist could not help you, you should
visit a
scholar of Tybied. His potions and tinctures may help
when nothing
else does. If the cryptic formula under the wooden shoes
of the
unfaithful husband really helped? - well, the peasant,
who isn't
capable of reading, will never know. At least it helped
the mage...
to fill his purse. In one week he can earn 50 silver per
level that way.
If the local alchemist could not help you, you should visit a
scholar of Tybied. His potions and tinctures may help when nothing
else does. If the cryptic formula under the wooden shoes of the
unfaithful husband really helped? - well, the peasant, who isn't
capable of reading, will never know. At least it helped the mage...
to fill his purse. In one week he can earn 50 silver per level that
way.
</text>
</string>

View File

@ -202,6 +202,14 @@
<text locale="fr">"heavy fog makes it impossible to leave the region. ($int36($id))"</text>
<text locale="en">"heavy fog makes it impossible to leave the region. ($int36($id))"</text>
</message>
<message name="use_speedsail" section="events">
<type>
<arg name="unit" type="unit"/>
</type>
<text locale="de">"$unit($unit) setzt ein Sonnensegel. Die Geschwindigkeit des Schiffes erhöht sich dramatisch."</text>
<text locale="fr">"$unit($unit) sets a solar sail. The ship's speed is greatly increased."</text>
<text locale="en">"$unit($unit) sets a solar sail. The ship's speed is greatly increased."</text>
</message>
<message name="use_questkey_wrongregion" section="events">
<type>
<arg name="region" type="region"/>

View File

@ -1,3 +1,23 @@
function test_sail()
r0 = terraform(0, 0, "plain")
orcs = add_faction("enno@eressea.de", "orc", "de")
orcs.age = 20
orc = add_unit(orcs, r0)
orc.number = 1
orc:add_item("speedsail", orc.number)
orc:clear_orders()
orc:add_order("NUMMER PARTEI orcs")
orc:add_order("NUMMER EINHEIT orc")
orc:add_order("BENENNE EINHEIT Orks")
orc:add_order("ZEIGEN \"Sonnensegel\"")
process_orders()
write_reports()
end
function test_movement()
west = direction("west")
east = direction("east")
@ -302,7 +322,8 @@ function test_fail()
print(f)
end
test_movement()
test_sail()
-- test_movement()
-- test_fail()
-- test_handler()
-- test_parser()