From 6b87faf047454c3fbcac478fddb91753f2118898 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Oct 2005 17:04:16 +0000 Subject: [PATCH] First test to remove items from code: AXE and RUSTY_AXE are out. Rewriting the rust-spell. Now affecting armor as well (with lower chance) --- src/common/items/weapons.c | 5 -- src/common/kernel/combatspells.c | 2 - src/common/kernel/item.c | 8 --- src/common/kernel/item.h | 3 - src/common/kernel/spell.c | 106 +++++++++++++++++-------------- src/res/equipment.xml | 4 +- src/res/resources.xml | 28 +++++++- 7 files changed, 87 insertions(+), 69 deletions(-) diff --git a/src/common/items/weapons.c b/src/common/items/weapons.c index 05228da45..64399ffd7 100644 --- a/src/common/items/weapons.c +++ b/src/common/items/weapons.c @@ -61,7 +61,6 @@ enum { WP_SPEAR, WP_GREATSWORD, WP_SWORD, - WP_AXE, WP_LANCE, WP_RUSTY_SWORD, WP_RUSTY_GREATSWORD, @@ -128,16 +127,12 @@ static weapondata weapontable[WP_MAX + 1] = {0.00, "2d8+3", "2d8+3", I_GREATSWORD, SK_SWORD, -1, -2, false, false, { RL_NONE, 0}, CUT }, /* Schwert */ {0.00, "1d9+2", "1d9+2", I_SWORD, SK_SWORD, 0, 0, false, false, { RL_NONE, 0}, CUT }, - /* Kriegsaxt */ - {0.00, "2d6+4", "2d6+4", I_AXE, SK_SWORD, 1, -2, false, false, { RL_NONE, 0}, CUT }, /* Lanze */ {0.00, "1d5", "2d6+5", I_LANCE, SK_SPEAR, 0, -2, false, false, { RL_NONE, 0}, PIERCE }, /* Rostiges Schwert */ {0.00, "1d9", "1d9", I_RUSTY_SWORD, SK_SWORD, -1, -1, false, false, { RL_NONE, 0}, CUT }, /* Rostiger Zweihänder */ {0.00, "2d8", "2d8", I_RUSTY_GREATSWORD, SK_SWORD, -2, -3, false, false, { RL_NONE, 0}, CUT }, - /* Rostige Axt */ - {0.00, "2d6", "2d6", I_RUSTY_AXE, SK_SWORD, 0, -3, false, false, { RL_NONE, 0}, CUT }, /* Rostige Hellebarde */ {0.00, "2d6", "2d6", I_RUSTY_HALBERD, SK_SPEAR, -2, 1, false, false, { RL_NONE, 0}, CUT }, /* Unbewaffnet */ diff --git a/src/common/kernel/combatspells.c b/src/common/kernel/combatspells.c index 7f1ac3748..5086808c6 100644 --- a/src/common/kernel/combatspells.c +++ b/src/common/kernel/combatspells.c @@ -314,8 +314,6 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp) /* da n min(force, x), sollte force maximal auf 0 sinken */ assert(force >= 0); - /* Eisenwaffen: I_SWORD, I_GREATSWORD, I_AXE, I_HALBERD (50%) */ - if (df->weapons) { int w; for (w=0;df->weapons[w].type!=NULL;++w) { diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index e409c6fd8..a73748adb 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -980,10 +980,6 @@ static t_item itemdata[MAXITEMS] = { {"Bihänder", "Bihänder", "Bihänder", "Bihänder"}, IS_PRODUCT, SK_WEAPONSMITH, 4, {2, 0, 0, 0, 0, 0}, 200, 0, 0, NULL }, - { /* I_AXE 36 */ - {"Kriegsaxt", "Kriegsäxte", "Kriegsaxt", "Kriegsäxte"}, - IS_PRODUCT, SK_WEAPONSMITH, 3, {1, 1, 0, 0, 0, 0}, 200, 0, 0, NULL - }, { /* I_LAENSWORD 38 */ {"Laenschwert", "Laenschwerter", "Laenschwert", "Laenschwerter"}, IS_PRODUCT, SK_WEAPONSMITH, 8, {0, 0, 0, 0, 1, 0}, 100, 0, 0, NULL @@ -1122,10 +1118,6 @@ static t_item itemdata[MAXITEMS] = { {"Rostiger Zweihänder", "Rostige Zweihänder", "Rostiger Zweihänder", "Rostige Zweihänder"}, IS_PRODUCT, SK_WEAPONSMITH, 4, {2, 0, 0, 0, 0, 0}, 200, 0, 0, NULL }, - { /* I_RUSTY_AXE */ - {"Rostige Kriegsaxt", "Rostige Kriegsäxte", "Rostige Kriegsaxt", "Rostige Kriegsäxte"}, - IS_PRODUCT, SK_WEAPONSMITH, 3, {1, 1, 0, 0, 0, 0}, 200, 0, 0, NULL - }, { /* I_RUSTY_HALBERD */ {"Rostige Hellebarde", "Rostige Hellebarden", "Rostige Hellebarde", "Rostige Hellebarden"}, IS_PRODUCT, SK_WEAPONSMITH, 3, {1, 1, 0, 0, 0, 0}, 200, 0, 0, NULL diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index 9ae69ead0..4ff7f8663 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -304,7 +304,6 @@ enum { I_DRAGONHEAD, I_CHASTITY_BELT, /* bleibt */ I_GREATSWORD, - I_AXE, I_LAENSWORD, I_LAEN, I_SHIELD, @@ -345,7 +344,6 @@ enum { I_SACK_OF_CONSERVATION, I_SPHERE_OF_INVISIBILITY, I_RUSTY_GREATSWORD, - I_RUSTY_AXE, I_RUSTY_HALBERD, MAX_ITEMS /* do not use outside item.c ! */ }; @@ -379,7 +377,6 @@ enum { R_DRAGONHEAD, R_CHASTITY_BELT, R_GREATSWORD, - R_AXE, R_EOGSWORD, R_EOG, R_SHIELD, diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 6f3a3a8f6..f048d4a7d 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -1287,75 +1287,85 @@ patzer_ents(castorder *co) * Gebiet: Gwyrrd * Wirkung: * Zerstört zwischen Stufe und Stufe*10 Eisenwaffen - * Eisenwaffen: I_SWORD, I_GREATSWORD, I_AXE, I_HALBERD * * Flag: * (FARCASTING | SPELLLEVEL | UNITSPELL | TESTCANSEE | TESTRESISTANCE) */ /* Syntax: ZAUBER [REGION x y] [STUFE 2] "Rosthauch" 1111 2222 3333 */ +typedef struct iron_weapon { + const struct item_type * type; + const struct item_type * rusty; + float chance; + struct iron_weapon * next; +} iron_weapon; + +static iron_weapon * ironweapons = NULL; + +void +add_ironweapon(const struct item_type * type, const struct item_type * rusty, float chance) +{ + iron_weapon * iweapon = malloc(sizeof(iron_weapon)); + iweapon->type = type; + iweapon->rusty = rusty; + iweapon->chance = chance; + iweapon->next = ironweapons; + ironweapons = iweapon; +} + static int sp_rosthauch(castorder *co) { - unit *u; - int ironweapon; - int i, n; + int n; int success = 0; region *r = co->rt; unit *mage = (unit *)co->magician; int cast_level = co->level; - double force = co->force; + int force = (int)co->force; spellparameter *pa = co->par; + if (ironweapons==NULL) { + add_ironweapon(it_find("sword"), it_find("rustysword"), 1.0); + add_ironweapon(it_find("axe"), it_find("rustyaxe"), 1.0); + add_ironweapon(it_find("greatsword"), it_find("rustygreatsword"), 1.0); + add_ironweapon(it_find("halberd"), it_find("rustyhalberd"), 0.5f); +#ifndef NO_RUSTY_ARMOR + add_ironweapon(it_find("shield"), it_find("rustyshield"), 0.5f); + add_ironweapon(it_find("chainmail"), it_find("rustychainmail"), 0.2f); +#endif + } + force = rand()%((int)(force * 10)) + force; /* fuer jede Einheit */ - for (n = 0; n < pa->length; n++) { - static const item_type * it_halberd = NULL; - if (it_halberd==NULL) it_halberd = it_find("halberd"); - if (force<=0) break; + for (n = 0; n < pa->length; n++) { + unit *u = pa->param[n]->data.u; + int ironweapon = 0; + iron_weapon * iweapon = ironweapons; - if(pa->param[n]->flag == TARGET_RESISTS - || pa->param[n]->flag == TARGET_NOTFOUND) - continue; + if (force<=0) break; + if (pa->param[n]->flag & (TARGET_RESISTS|TARGET_NOTFOUND)) continue; - u = pa->param[n]->data.u; + for (;iweapon!=NULL;iweapon=iweapon->next) { + item ** ip = i_find(&u->items, iweapon->type); + if (ip) { + int i = min((*ip)->number, force); + if (iweapon->chance<1.0) { + i = (int)(i*iweapon->chance); + } + if (i>0) { + force -= i; + ironweapon += i; + i_change(ip, iweapon->type, -i); + if (iweapon->rusty) { + i_change(&u->items, iweapon->rusty, i); + } + } + } + if (force<=0) break; + } - /* Eisenwaffen: I_SWORD, I_GREATSWORD, I_AXE, I_HALBERD (50% Chance)*/ - ironweapon = 0; - - i = min(get_item(u, I_SWORD), (int)force); - if (i > 0) { - change_item(u, I_SWORD, -i); - change_item(u, I_RUSTY_SWORD, i); - force -= i; - ironweapon += i; - } - i = min(get_item(u, I_GREATSWORD), (int)force); - if (i > 0){ - change_item(u, I_GREATSWORD, -i); - change_item(u, I_RUSTY_GREATSWORD, i); - force -= i; - ironweapon += i; - } - i = min(get_item(u, I_AXE), (int)force); - if (i > 0){ - change_item(u, I_AXE, -i); - change_item(u, I_RUSTY_AXE, i); - force -= i; - ironweapon += i; - } - i = min(i_get(u->items, it_halberd), (int)force); - if (i > 0){ - if(rand()%100 < 50){ - i_change(&u->items, it_halberd, -i); - i_change(&u->items, olditemtype[I_RUSTY_HALBERD], i); - force -= i; - ironweapon += i; - } - } - - if (ironweapon) { + if (ironweapon>0) { /* {$mage mage} legt einen Rosthauch auf {target}. {amount} Waffen * wurden vom Rost zerfressen */ ADDMSG(&mage->faction->msgs, msg_message( diff --git a/src/res/equipment.xml b/src/res/equipment.xml index 7e7e8e064..891745afd 100644 --- a/src/res/equipment.xml +++ b/src/res/equipment.xml @@ -9,14 +9,14 @@ - + - + diff --git a/src/res/resources.xml b/src/res/resources.xml index e4b6bca5d..3e335720f 100644 --- a/src/res/resources.xml +++ b/src/res/resources.xml @@ -32,7 +32,7 @@ - + @@ -54,6 +54,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +