From c36b14e9e055ee28356a9d5e443538cc75f5b9e4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Apr 2007 01:10:38 +0000 Subject: [PATCH] Nur Boote und Langboote koennen per Zauber fliegen. Ein Item fuer den Flug von anderen Schiffen. --- src/common/kernel/movement.c | 7 ++++- src/common/spells/spells.c | 51 +++++++++++++++++++++------------- src/common/spells/spells.h | 2 ++ src/eressea/lua/gamecode.cpp | 15 ++++++++++ src/res/eressea/de/strings.xml | 11 ++++++++ src/res/eressea/items.xml | 6 ++++ src/scripts/eressea.lua | 1 + src/scripts/eressea/items.lua | 17 ++++++++++++ 8 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 src/scripts/eressea/items.lua diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 14ed09c67..a6169a229 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -672,8 +672,13 @@ ship_allowed(const struct ship * sh, const region * r) static boolean flying_ship(const ship * sh) { + static const curse_type * ct_flyingship; + if (!ct_flyingship) { + ct_flyingship = ct_find("flyingship"); + assert(ct_flyingship); + } if (sh->type->flags & SFL_FLY) return true; - if (is_cursed(sh->attribs, C_SHIP_FLYING, 0)) return true; + if (curse_active(get_curse(sh->attribs, ct_flyingship))) return true; return false; } diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index bb9b4c465..a99860cb0 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -6544,10 +6544,22 @@ sp_movecastle(castorder *co) return cast_level; } -boolean -shipcurse_flyingship(ship* sh, int power, int duration) +curse * +shipcurse_flyingship(ship* sh, unit * mage, double power, int duration) { - return false; + static const curse_type * ct_flyingship = NULL; + if (!ct_flyingship) { + ct_flyingship = ct_find("flyingship"); + assert(ct_flyingship); + } + if (curse_active(get_curse(sh->attribs, ct_flyingship))) { + return NULL; + } else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) { + return NULL; + } else { + /* mit C_SHIP_NODRIFT haben wir kein Problem */ + return create_curse(mage, &sh->attribs, ct_flyingship, power, duration, zero_effect, 0); + } } /* ------------------------------------------------------------- */ /* Name: Luftschiff @@ -6572,30 +6584,29 @@ sp_flying_ship(castorder *co) double power = co->force; spellparameter *pa = co->par; message * m = NULL; + curse * c; /* wenn kein Ziel gefunden, Zauber abbrechen */ if (pa->param[0]->flag == TARGET_NOTFOUND) return 0; + if (sh->type->construction->maxsize>50) { + /* TODO: error message */ + return 0; + } sh = pa->param[0]->data.sh; - if (is_cursed(sh->attribs, C_SHIP_FLYING, 0) ) { -/* sprintf(buf, "Auf dem Schiff befindet liegt bereits so ein Zauber."); */ - cmistake(mage, co->order, 211, MSG_MAGIC); - return 0; - } - if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0) ) { -/* sprintf(buf, "Es ist zu gefährlich, ein sturmgepeitschtes Schiff " - "fliegen zu lassen."); */ - cmistake(mage, co->order, 210, MSG_MAGIC); - return 0; - } - /* mit C_SHIP_NODRIFT haben wir kein Problem */ - /* Duration = 1, nur diese Runde */ - create_curse(mage, &sh->attribs, ct_find("flyingship"), power, 1, zero_effect, 0); - /* Da der Spruch nur diese Runde wirkt, brauchen wir kein - * set_cursedisplay() zu benutzten - es sieht eh niemand... - */ + c = shipcurse_flyingship(sh, mage, power, 1); + if (c==NULL) { + if (is_cursed(sh->attribs, C_SHIP_FLYING, 0) ) { + /* Auf dem Schiff befindet liegt bereits so ein Zauber. */ + cmistake(mage, co->order, 211, MSG_MAGIC); + } else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0) ) { + /* Es ist zu gefährlich, ein sturmgepeitschtes Schiff fliegen zu lassen. */ + cmistake(mage, co->order, 210, MSG_MAGIC); + } + return 0; + } sh->coast = NODIRECTION; /* melden, 1x pro Partei */ diff --git a/src/common/spells/spells.h b/src/common/spells/spells.h index 0a288b1bd..ee52a315d 100644 --- a/src/common/spells/spells.h +++ b/src/common/spells/spells.h @@ -19,6 +19,8 @@ extern "C" { #endif extern void register_spells(void); + extern struct curse * shipcurse_flyingship(struct ship* sh, struct unit * mage, double power, int duration); + /* für Feuerwände: in movement muß das noch explizit getestet werden. * besser wäre eine blcok_type::move() routine, die den effekt diff --git a/src/eressea/lua/gamecode.cpp b/src/eressea/lua/gamecode.cpp index a856b6e35..0767eaf9c 100644 --- a/src/eressea/lua/gamecode.cpp +++ b/src/eressea/lua/gamecode.cpp @@ -13,11 +13,14 @@ #include #include +#include + // kernel includes #include #include #include #include +#include #include #include #include @@ -265,6 +268,15 @@ process_orders(void) return 0; } +static int +levitate_ship(ship& sh, unit& mage, double power, int duration) +{ + curse * c = shipcurse_flyingship(&sh, &mage, power, duration); + if (c) { + return c->no; + } + return 0; +} void bind_gamecode(lua_State * L) @@ -290,6 +302,9 @@ bind_gamecode(lua_State * L) def("message_faction", &message_faction), def("message_region", &message_region), + /* spells and stuff */ + def("levitate_ship", &levitate_ship), + /* scripted monsters */ def("spawn_braineaters", &spawn_braineaters), def("spawn_undead", &spawn_undead), diff --git a/src/res/eressea/de/strings.xml b/src/res/eressea/de/strings.xml index 6489dfc1b..90ffb243f 100644 --- a/src/res/eressea/de/strings.xml +++ b/src/res/eressea/de/strings.xml @@ -30,6 +30,9 @@ + + Benutzt der Kapitän des Schiffes diesen Talisman, so wird allen an Bord befindlichen Mallornsamen ihre magisch Energie entzogen, und das Schiff kann mit dieser Energie bis zu zwei Wochen lang fliegen. + Eine Geburtstagstorte mit 10 Kerzen. Herzlichen Glückwunsch, Eressea! A birthday cake with 10 candles. Happy Birthday, Eressea! @@ -166,6 +169,14 @@ the sky one cold winter night, is said to have aphrodisiacal powers. + + Ring der Levitation + ring of levitation + + + Ringe der Levitation + rings of levitation + Geburtstagstorte birthday cake diff --git a/src/res/eressea/items.xml b/src/res/eressea/items.xml index 3cab0f22b..27f7f0965 100644 --- a/src/res/eressea/items.xml +++ b/src/res/eressea/items.xml @@ -22,6 +22,12 @@ + + + + + + diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 1c442831a..9de500f77 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -30,6 +30,7 @@ function run_scripts() "eressea/eternath.lua", "eressea/wedding-jadee.lua", "eressea/ponnuki.lua", + "eressea/items.lua", "eressea/xmas2004.lua", "eressea/10years.lua", "eressea/xmas2005.lua", diff --git a/src/scripts/eressea/items.lua b/src/scripts/eressea/items.lua new file mode 100644 index 000000000..8558624fc --- /dev/null +++ b/src/scripts/eressea/items.lua @@ -0,0 +1,17 @@ +function use_ring_of_levitation(u, amount) + if u.ship~=nil and amount>0 then + local mallorn = 0 + for u2 in u.region.units do + local i = u2:get_item("mallornseed") + if i>0 then + u2:use_item("mallornseed", i) + u2:add_item("seed", i) + mallorn = mallorn + i + end + end + if mallorn>0 then + levitate_ship(u.ship, u, mallorn, 2) + end + end + return 0 +end