From b6443e40ba6a3d21160f624d874dfa9ecb414489 Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Sun, 1 Nov 2015 17:14:51 +0100 Subject: [PATCH 1/5] reanimated dead code --- src/battle.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/battle.c b/src/battle.c index 319aa4151..1707b29ad 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1156,13 +1156,11 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* Momentan nur Trollgürtel und Werwolf-Eigenschaft */ am = select_magicarmor(dt); -#if CHANGED_CROSSBOWS if (awtype && fval(awtype, WTF_ARMORPIERCING)) { /* crossbows */ ar /= 2; an /= 2; } -#endif if (rule_armor < 0) { rule_armor = get_param_int(global.parameters, "rules.combat.nat_armor", 0); From dab8bdf7ef957943f9d21e84749ab23968d34ff9 Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Sun, 1 Nov 2015 17:15:11 +0100 Subject: [PATCH 2/5] WIP new test for armor penetration --- src/battle.test.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/battle.test.c b/src/battle.test.c index 264e9c0be..e473e137e 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -204,6 +204,71 @@ static void test_building_defence_bonus(CuTest * tc) test_cleanup(); } +static void test_armor_penetration(CuTest * tc) +{ + faction* pAttackingFaction = NULL; + faction* pDefendingFaction_Human = NULL; + faction* pDefendingFaction_Demon = NULL; + unit* pAttackingUnit = NULL; + unit* pDefendingUnit = NULL; + fighter* pAttackingFighter = NULL; + fighter* pDefendingFighter = NULL; + troop attackingTroop; + troop defendingTroop; + side* pAttackingSide = NULL; + side* pDefendingSide = NULL; + region* pRegion = NULL; + battle* pBattle = NULL; + + test_cleanup(); + test_create_world(); + + resource_type* pResType_Crossbow = rt_get_or_create("crossbow"); + item_type* pItemType_Crossbow = it_get_or_create(pResType_Crossbow); + (void)new_weapontype(pItemType_Crossbow, WTF_ARMORPIERCING, 0.0, NULL, 0, 0, 1, SK_CROSSBOW, 1); + item* pItem_Crossbow = i_new(pItemType_Crossbow, 1); + + item_type* pItemType_Armor = it_get_or_create(rt_get_or_create("plate")); + /*armor_type* pArmorType = */new_armortype(pItemType_Armor, 0.0, 0.0, 5, ATF_NONE); + + pRegion = findregion(0, 0); + + pAttackingFaction = test_create_faction(NULL); + pDefendingFaction_Human = test_create_faction(rc_get_or_create("human")); + pDefendingFaction_Demon = test_create_faction(rc_get_or_create("demon")); + + pAttackingUnit = test_create_unit(pAttackingFaction, pRegion); + scale_number(pAttackingUnit, 1); + set_level(pAttackingUnit, SK_CROSSBOW, 10); + pAttackingUnit->items = pItem_Crossbow; + + + pDefendingUnit = test_create_unit(pDefendingFaction_Human, pRegion); + scale_number(pDefendingUnit, 1); + //i_change(&(pDefendingUnit->items), pItemType_Armor, 1); + + pBattle = make_battle(pRegion); + pAttackingSide = make_side(pBattle, pAttackingFaction, NULL, 0, NULL); + pDefendingSide = make_side(pBattle, pDefendingFaction_Human, NULL, 0, NULL); + + pAttackingFighter = make_fighter(pBattle, pAttackingUnit, pAttackingSide, false); + attackingTroop.fighter = pAttackingFighter; + attackingTroop.index = 0; + + pDefendingFighter = make_fighter(pBattle, pDefendingUnit, pDefendingSide, false); + defendingTroop.fighter = pDefendingFighter; + defendingTroop.index = 0; + + int initialHP = 10; + pDefendingUnit->hp = initialHP; + + CuAssertTrue(tc, terminate(defendingTroop, attackingTroop, AT_STANDARD, "10", true)); + + CuAssertIntEquals(tc, initialHP - 10, pDefendingUnit->hp); + + test_cleanup(); +} + CuSuite *get_battle_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -212,5 +277,6 @@ CuSuite *get_battle_suite(void) SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus); SUITE_ADD_TEST(suite, test_building_bonus_respects_size); SUITE_ADD_TEST(suite, test_building_defence_bonus); + SUITE_ADD_TEST(suite, test_armor_penetration); return suite; } From 0e83cc69d393582ac6e60b0c6a3def707940a85f Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Mon, 2 Nov 2015 18:27:07 +0100 Subject: [PATCH 3/5] missed a spot... --- src/settings.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/settings.h b/src/settings.h index 7f97eb8a8..267a27d12 100644 --- a/src/settings.h +++ b/src/settings.h @@ -37,6 +37,5 @@ */ #define MUSEUM_MODULE 1 #define ARENA_MODULE 1 -#define CHANGED_CROSSBOWS 0 /* use the WTF_ARMORPIERCING flag */ #undef REGIONOWNERS /* (WIP) region-owner uses HELP_TRAVEL to control entry to region */ From bf42143b1116e8017453713543167deae157eed7 Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Tue, 3 Nov 2015 00:01:10 +0100 Subject: [PATCH 4/5] Revert "WIP new test for armor penetration" This reverts commit dab8bdf7ef957943f9d21e84749ab23968d34ff9. --- src/battle.test.c | 66 ----------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/src/battle.test.c b/src/battle.test.c index e473e137e..264e9c0be 100644 --- a/src/battle.test.c +++ b/src/battle.test.c @@ -204,71 +204,6 @@ static void test_building_defence_bonus(CuTest * tc) test_cleanup(); } -static void test_armor_penetration(CuTest * tc) -{ - faction* pAttackingFaction = NULL; - faction* pDefendingFaction_Human = NULL; - faction* pDefendingFaction_Demon = NULL; - unit* pAttackingUnit = NULL; - unit* pDefendingUnit = NULL; - fighter* pAttackingFighter = NULL; - fighter* pDefendingFighter = NULL; - troop attackingTroop; - troop defendingTroop; - side* pAttackingSide = NULL; - side* pDefendingSide = NULL; - region* pRegion = NULL; - battle* pBattle = NULL; - - test_cleanup(); - test_create_world(); - - resource_type* pResType_Crossbow = rt_get_or_create("crossbow"); - item_type* pItemType_Crossbow = it_get_or_create(pResType_Crossbow); - (void)new_weapontype(pItemType_Crossbow, WTF_ARMORPIERCING, 0.0, NULL, 0, 0, 1, SK_CROSSBOW, 1); - item* pItem_Crossbow = i_new(pItemType_Crossbow, 1); - - item_type* pItemType_Armor = it_get_or_create(rt_get_or_create("plate")); - /*armor_type* pArmorType = */new_armortype(pItemType_Armor, 0.0, 0.0, 5, ATF_NONE); - - pRegion = findregion(0, 0); - - pAttackingFaction = test_create_faction(NULL); - pDefendingFaction_Human = test_create_faction(rc_get_or_create("human")); - pDefendingFaction_Demon = test_create_faction(rc_get_or_create("demon")); - - pAttackingUnit = test_create_unit(pAttackingFaction, pRegion); - scale_number(pAttackingUnit, 1); - set_level(pAttackingUnit, SK_CROSSBOW, 10); - pAttackingUnit->items = pItem_Crossbow; - - - pDefendingUnit = test_create_unit(pDefendingFaction_Human, pRegion); - scale_number(pDefendingUnit, 1); - //i_change(&(pDefendingUnit->items), pItemType_Armor, 1); - - pBattle = make_battle(pRegion); - pAttackingSide = make_side(pBattle, pAttackingFaction, NULL, 0, NULL); - pDefendingSide = make_side(pBattle, pDefendingFaction_Human, NULL, 0, NULL); - - pAttackingFighter = make_fighter(pBattle, pAttackingUnit, pAttackingSide, false); - attackingTroop.fighter = pAttackingFighter; - attackingTroop.index = 0; - - pDefendingFighter = make_fighter(pBattle, pDefendingUnit, pDefendingSide, false); - defendingTroop.fighter = pDefendingFighter; - defendingTroop.index = 0; - - int initialHP = 10; - pDefendingUnit->hp = initialHP; - - CuAssertTrue(tc, terminate(defendingTroop, attackingTroop, AT_STANDARD, "10", true)); - - CuAssertIntEquals(tc, initialHP - 10, pDefendingUnit->hp); - - test_cleanup(); -} - CuSuite *get_battle_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -277,6 +212,5 @@ CuSuite *get_battle_suite(void) SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus); SUITE_ADD_TEST(suite, test_building_bonus_respects_size); SUITE_ADD_TEST(suite, test_building_defence_bonus); - SUITE_ADD_TEST(suite, test_armor_penetration); return suite; } From 5178bbd674b122a64eab25144ccb56516e442862 Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Tue, 3 Nov 2015 00:05:55 +0100 Subject: [PATCH 5/5] moved application of armor-penetration halfed armor now includes the effect of natural armor, but not the effect of magic armor --- src/battle.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/battle.c b/src/battle.c index 1707b29ad..b60094053 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1156,12 +1156,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* Momentan nur Trollgürtel und Werwolf-Eigenschaft */ am = select_magicarmor(dt); - if (awtype && fval(awtype, WTF_ARMORPIERCING)) { - /* crossbows */ - ar /= 2; - an /= 2; - } - if (rule_armor < 0) { rule_armor = get_param_int(global.parameters, "rules.combat.nat_armor", 0); } @@ -1178,6 +1172,12 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) /* use the higher value, add half the other value */ ar = (ar > an) ? (ar + an / 2) : (an + ar / 2); } + + if (awtype && fval(awtype, WTF_ARMORPIERCING)) { + /* crossbows */ + ar /= 2; + } + ar += am; if (type != AT_COMBATSPELL && type != AT_SPELL) {