From 425cf5368d4147398a45c5088b6ab957672d41d2 Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Fri, 7 May 2004 11:11:30 +0000 Subject: [PATCH] - Horn des Tanzes - Gefangener Windgeist --- src/common/gamecode/report.c | 4 +- src/common/items/Jamfile | 1 + src/common/items/artrewards.c | 168 ++++++++++++++++++++++++++++++++++ src/common/items/artrewards.h | 32 +++++++ src/common/items/items.c | 2 + src/common/kernel/eressea.c | 21 ++++- src/common/kernel/magic.c | 15 --- src/common/kernel/movement.c | 17 ++++ src/common/kernel/movement.h | 2 + src/common/kernel/ship.c | 14 +++ src/common/kernel/ship.h | 3 +- src/common/spells/shipcurse.c | 21 ++++- src/eressea@amber.mk | 2 +- src/res/de/strings.xml | 16 ++++ src/res/messages.xml | 52 +++++++++++ 15 files changed, 349 insertions(+), 21 deletions(-) create mode 100644 src/common/items/artrewards.c create mode 100644 src/common/items/artrewards.h diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 00121ca71..9b616a464 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -2299,9 +2299,9 @@ report(FILE *F, faction * f, const faction_list * addresses, w += weight(u); } } - sprintf(buf, "%s, %s, (%d/%d)", + sprintf(buf, "%s, %s %s, (%d/%d)", shipname(sh), - LOC(f->locale, sh->type->name[0]), + LOC(f->locale, sh->type->name[0]), (w + 99) / 100, /* +99 weil sonst die Nachkommastellen ignoriert würden */ shipcapacity(sh) / 100); } else { diff --git a/src/common/items/Jamfile b/src/common/items/Jamfile index 5ae94923a..e0e23eb0d 100644 --- a/src/common/items/Jamfile +++ b/src/common/items/Jamfile @@ -18,6 +18,7 @@ SOURCES = seed.c weapons.c xerewards.c + artrewards.c ; Library items : $(SOURCES) ; diff --git a/src/common/items/artrewards.c b/src/common/items/artrewards.c new file mode 100644 index 000000000..eb7f6ad68 --- /dev/null +++ b/src/common/items/artrewards.c @@ -0,0 +1,168 @@ +/* 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 +#include +#include "artrewards.h" + +/* kernel includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* util includes */ +#include + +/* libc includes */ +#include +#include +#include + +#define HORNRANGE 10 +#define HORNDURATION 3 +#define HORNIMMUNITY 30 + +static int +age_peaceimmune(attrib * a) +{ + return --a->data.i; +} + +static attrib_type at_peaceimmune = { + "peaceimmune", + NULL, NULL, + age_peaceimmune, + a_writedefault, + a_readdefault +}; + +static int +use_hornofdancing(struct unit * u, const struct item_type * itype, + int amount, const char *cm) +{ + region *r; + int regionsPacified = 0; + + for(r=regions; r; r=r->next) { + if(distance(u->region, r) < HORNRANGE) { + if(a_find(r->attribs, &at_peaceimmune) == NULL) { + attrib *a; + + create_curse(u, &r->attribs, ct_find("peacezone"), + 20, HORNDURATION, 1, 0); + + a = a_add(&r->attribs, a_new(&at_peaceimmune)); + a->data.i = HORNIMMUNITY; + + ADDMSG(&r->msgs, msg_message("hornofpeace_r_success", + "unit region", u, u->region)); + + regionsPacified++; + } else { + ADDMSG(&r->msgs, msg_message("hornofpeace_r_nosuccess", + "unit region", u, u->region)); + } + } + } + + if(regionsPacified > 0) { + ADDMSG(&u->faction->msgs, msg_message("hornofpeace_u_success", + "unit region command pacified", u, u->region, cm, regionsPacified)); + } else { + ADDMSG(&u->faction->msgs, msg_message("hornofpeace_u_nosuccess", + "unit region command", u, u->region, cm)); + } + + return 0; +} + +static resource_type rt_hornofdancing = { + { "hornofdancing", "hornofdancing_p" }, + { "hornofdancing", "hornofdancing_p" }, + RTF_ITEM, + &res_changeitem +}; + +item_type it_hornofdancing = { + &rt_hornofdancing, /* resourcetype */ + 0, 0, 0, /* flags, weight, capacity */ + NULL, /* construction */ + &use_hornofdancing, + NULL, + NULL +}; + + +#define SPEEDUP 2 + +static int +use_trappedairelemental(struct unit * u, const struct item_type * itype, + int amount, const char *cm) +{ + curse *c; + int shipId; + ship *sh; + + shipId = getshipid(); + if(shipId <= 0) { + cmistake(u, cm, 20, MSG_MOVE); + return 0; + } + + sh = findshipr(u->region, shipId); + if(!sh) { + cmistake(u, cm, 20, MSG_MOVE); + return 0; + } + + c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), + 20, 999999, SPEEDUP, 0); + curse_setflag(c, CURSE_NOAGE); + + ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success", + "unit region command ship", u, u->region, cm, sh)); + return 1; +} + +static resource_type rt_trappedairelemental = { + { "trappedairelemental", "trappedairelemental_p" }, + { "trappedairelemental", "trappedairelemental_p" }, + RTF_ITEM, + &res_changeitem +}; + +item_type it_trappedairelemental = { + &rt_trappedairelemental, /* resourcetype */ + 0, 0, 0, /* flags, weight, capacity */ + NULL, /* construction */ + &use_trappedairelemental, + NULL, + NULL +}; + +void +register_artrewards(void) +{ + at_register(&at_peaceimmune); + it_register(&it_hornofdancing); + register_function((pf_generic)use_hornofdancing, "usehornofdancing"); + it_register(&it_trappedairelemental); + register_function((pf_generic)use_trappedairelemental, "trappedairelemental"); +} + diff --git a/src/common/items/artrewards.h b/src/common/items/artrewards.h new file mode 100644 index 000000000..e0bfbeb2d --- /dev/null +++ b/src/common/items/artrewards.h @@ -0,0 +1,32 @@ +/* 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_ARTREWARDS +#define H_ITM_ARTREWARDS +#ifdef __cplusplus +extern "C" { +#endif + +extern struct item_type it_hornofdancing; +extern struct item_type it_trappedairelemental; +extern struct item_type it_bagpipeoffear; +extern struct item_type it_instantartacademie; +extern struct item_type it_instantartsculpture; + +extern void register_artrewards(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/common/items/items.c b/src/common/items/items.c index 8b18e232e..034a7dedd 100644 --- a/src/common/items/items.c +++ b/src/common/items/items.c @@ -18,6 +18,7 @@ #include "lmsreward.h" #include "demonseye.h" #include "xerewards.h" +#include "artrewards.h" #include "weapons.h" #include "racespoils.h" #if GROWING_TREES @@ -42,6 +43,7 @@ register_items(void) register_questkeys(); register_catapultammo(); register_racespoils(); + register_artrewards(); } void diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index de0dcc081..c84f904c3 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -57,6 +57,7 @@ #include "ship.h" #include "karma.h" #include "group.h" +#include "movement.h" /* util includes */ #include @@ -485,6 +486,9 @@ shipspeed (const ship * sh, const unit * u) int k = sh->type->range; static const curse_type * stormwind_ct, * nodrift_ct; static boolean init; + attrib *a; + curse *c; + if (!init) { init = true; stormwind_ct = ct_find("stormwind"); @@ -501,8 +505,22 @@ shipspeed (const ship * sh, const unit * u) k += 1; if (old_race(u->faction->race) == RC_AQUARIAN - && old_race(u->race) == RC_AQUARIAN) + && old_race(u->race) == RC_AQUARIAN) { k += 1; + } + + a = a_find(sh->attribs, &at_speedup); + while(a != NULL) { + k += a->data.i; + a = a->nexttype; + } + + c = get_curse(sh->attribs, ct_find("shipspeedup")); + while(c) { + k += curse_geteffect(c); + c = c->nexthash; + } + #ifdef SHIPSPEED k *= SHIPSPEED; #endif @@ -3088,6 +3106,7 @@ attrib_init(void) #ifdef WDW_PYRAMIDSPELL at_register(&at_wdwpyramid); #endif + at_register(&at_speedup); } void diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index 1b98254c3..9071a5632 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -106,21 +106,6 @@ MagicPower(void) return value; } -static ship * -findshipr(const region *r, int n) - /* Ein Schiff in einer bestimmten Region finden: */ -{ - ship * sh; - - for (sh = r->ships; sh; sh = sh->next) { - if (sh->no == n) { - assert(sh->region == r); - return sh; - } - } - return 0; -} - static building * findbuildingr(const region *r, int n) /* Ein Gebäude in einer bestimmten Region finden: */ diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index abf53c98b..d1dc7f781 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -132,6 +132,23 @@ attrib_type at_traveldir_new = { a_traveldir_new_read }; +static int +age_speedup(attrib *a) +{ + if(a->data.i > 0) { + --a->data.i; + } + return a->data.i; +} + +attrib_type at_speedup = { + "speedup", + NULL, NULL, + age_speedup, + a_writedefault, + a_readdefault +}; + /* ------------------------------------------------------------- */ direction_t diff --git a/src/common/kernel/movement.h b/src/common/kernel/movement.h index 1509fd864..0efbf0469 100644 --- a/src/common/kernel/movement.h +++ b/src/common/kernel/movement.h @@ -65,6 +65,8 @@ struct building_type; boolean buildingtype_exists(const struct region * r, const struct building_type * bt); struct unit* owner_buildingtyp(const struct region * r, const struct building_type * bt); +extern struct attrib_type at_speedup; + #ifdef __cplusplus } #endif diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 3238a157d..46d97066f 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -128,6 +128,20 @@ findship(int i) return sfindhash(i); } +struct ship * +findshipr(const region *r, int n) +{ + ship * sh; + + for (sh = r->ships; sh; sh = sh->next) { + if (sh->no == n) { + assert(sh->region == r); + return sh; + } + } + return 0; +} + void damage_ship(ship * sh, double percent) { diff --git a/src/common/kernel/ship.h b/src/common/kernel/ship.h index 1277588c3..8f80bfbbb 100644 --- a/src/common/kernel/ship.h +++ b/src/common/kernel/ship.h @@ -87,7 +87,8 @@ extern void getshipweight(const struct ship * sh, int *weight, int *cabins); extern ship *new_ship(const struct ship_type * stype, struct region * r); extern const char *shipname(const struct ship * sh); -extern ship *findship(int n); +extern struct ship *findship(int n); +extern struct ship *findshipr(const struct region *r, int n); extern const struct ship_type * findshiptype(const char *s, const struct locale * lang); diff --git a/src/common/spells/shipcurse.c b/src/common/spells/shipcurse.c index 637ec5d4b..31fb33ed1 100644 --- a/src/common/spells/shipcurse.c +++ b/src/common/spells/shipcurse.c @@ -78,7 +78,6 @@ cinfo_shipnodrift(const struct locale * lang, void * obj, typ_t typ, curse *c, i return 1; } -/* C_DISORIENTATION */ static int cinfo_disorientation(void * obj, typ_t typ, curse *c, int self) { @@ -94,6 +93,20 @@ cinfo_disorientation(void * obj, typ_t typ, curse *c, int self) return 1; } +static int +cinfo_shipspeedup(void * obj, typ_t typ, curse *c, int self) +{ + unused(typ); + unused(obj); + unused(self); + + assert(typ == TYP_SHIP); + + sprintf(buf, "Ein Windgeist beschleunigt dieses Schiff. (%s)", curseid(c)); + + return 1; +} + static struct curse_type ct_stormwind = { "stormwind", CURSETYP_NORM, 0, NO_MERGE, "", @@ -115,16 +128,22 @@ static struct curse_type ct_shipdisorientation = { "shipdisorientation", CURSETYP_NORM, 0, NO_MERGE, "Dieses Schiff hat sich verfahren." }; +static struct curse_type ct_shipspeedup = { "shipspeedup", + CURSETYP_NORM, 0, 0, + NULL +}; void register_shipcurse(void) { register_function((pf_generic)cinfo_disorientation, "curseinfo::disorientation"); register_function((pf_generic)cinfo_shipnodrift, "curseinfo::shipnodrift"); + register_function((pf_generic)cinfo_shipspeedup, "curseinfo::shipspeedup"); ct_register(&ct_stormwind); ct_register(&ct_flyingship); ct_register(&ct_nodrift); ct_register(&ct_shipdisorientation); + ct_register(&ct_shipspeedup); } diff --git a/src/eressea@amber.mk b/src/eressea@amber.mk index a61e8a30d..e5baa45b2 100644 --- a/src/eressea@amber.mk +++ b/src/eressea@amber.mk @@ -4,7 +4,7 @@ ifndef ERESSEA endif # Hier definieren, damit nicht '@gcc' -CC = gcc-3.3 -D_GNU_SOURCE -ansi -pedantic +CC = gcc-3.3 -D_GNU_SOURCE -ansi -pedantic -I/usr/include/libxml2 DEPEND = @gcc-3.3 -MM -MG -r # CC = gcc -D_GNU_SOURCE AR = ar diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 83941c6a3..b99507060 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -1389,6 +1389,22 @@ Saphirne Schlüssel sapphire keys + + Horn des Tanzes + horn of dancing + + + Hörner des Tanzes + horns of dancing + + + Gefangener Windgeist + trapped air elemental + + + Gefangene Windgeister + trapped air elementals + diff --git a/src/res/messages.xml b/src/res/messages.xml index d0fa588a7..3ddff12ef 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -5811,5 +5811,57 @@ "$unit($unit) in $region($region): '$order($command)' - Die Einheit $unit($target) hat keinen Kontakt mit uns aufgenommen." "$unit($unit) in $region($region): '$order($command)' - The unit $unit($target) did not contact us." + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - $int($pacified) Regionen wurden befriedet." + "$unit($unit) in $region($region): '$order($command)' - $int($pacified) regions have been pacified." + + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Keine Region konnte befriedet werden." + "$unit($unit) in $region($region): '$order($command)' - No region could be pacified." + + + + + + + + "$unit($unit) in $region($region) bläst das Horn des Tanzes. In der ganzen Region breitet sich eine friedliche Feststimmmung aus." + "$unit($unit) in $region($region) blows the Horn of Dancing. Peaceful harmony spreads over the region." + + + + + + + + "$unit($unit) in $region($region) bläst das Horn des Tanzes, doch niemand hier lässt sich von Stimmung anstecken." + "$unit($unit) in $region($region) blows the Horn of Dancing, but nobody here gets into the mood." + + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Die $ship($ship) wird jetzt schneller ihr Ziel erreichen." + "$unit($unit) in $region($region): '$order($command)' - The $ship($ship) will now be faster." + +