Even when not init_spell, we must still register.

Fixing serious (and old) armor bug
This commit is contained in:
Enno Rehling 2009-01-31 14:08:23 +00:00
parent 0d068f6aa6
commit 57de6ab6e1
4 changed files with 87 additions and 33 deletions

View File

@ -115,6 +115,39 @@ static message * msg_separator;
const troop no_troop = {0, 0}; const troop no_troop = {0, 0};
static int max_turns = 0;
static int damage_rules = 0;
#define DAMAGE_CRITICAL (1<<0)
#define DAMAGE_MELEE_BONUS (1<<1)
#define DAMAGE_MISSILE_BONUS (1<<2)
#define DAMAGE_UNARMED_BONUS (1<<3)
#define DAMAGE_SKILL_BONUS (1<<4)
/** initialize rules from configuration.
*/
static void
static_rules(void)
{
/* maximum number of combat turns */
max_turns = get_param_int(global.parameters, "rules.combat.turns", COMBAT_TURNS);
/* damage calculation */
if (get_param_int(global.parameters, "rules.combat.critical", 1)) {
damage_rules |= DAMAGE_CRITICAL;
}
if (get_param_int(global.parameters, "rules.combat.melee_bonus", 1)) {
damage_rules |= DAMAGE_MELEE_BONUS;
}
if (get_param_int(global.parameters, "rules.combat.missile_bonus", 1)) {
damage_rules |= DAMAGE_MISSILE_BONUS;
}
if (get_param_int(global.parameters, "rules.combat.unarmed_bonus", 1)) {
damage_rules |= DAMAGE_UNARMED_BONUS;
}
if (get_param_int(global.parameters, "rules.combat.skill_bonus", 1)) {
damage_rules |= DAMAGE_SKILL_BONUS;
}
}
static int static int
army_index(side * s) army_index(side * s)
{ {
@ -698,6 +731,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
static const armor_type * static const armor_type *
select_armor(troop t, boolean shield) select_armor(troop t, boolean shield)
{ {
int type = shield?ATF_SHIELD:0;
unit * u = t.fighter->unit; unit * u = t.fighter->unit;
const armor * a = t.fighter->armors; const armor * a = t.fighter->armors;
int geschuetzt = 0; int geschuetzt = 0;
@ -712,12 +746,14 @@ select_armor(troop t, boolean shield)
} }
for (;a;a=a->next) { for (;a;a=a->next) {
if (a->atype->flags & ATF_SHIELD) { if ((a->atype->flags & ATF_SHIELD)==type) {
geschuetzt += a->count; geschuetzt += a->count;
if (geschuetzt > t.index) /* unser Kandidat wird geschuetzt */ if (geschuetzt > t.index) {
/* unser Kandidat wird geschuetzt */
return a->atype; return a->atype;
} }
} }
}
return NULL; return NULL;
} }
@ -999,8 +1035,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
ar += am; ar += am;
if (type!=AT_COMBATSPELL && type!=AT_SPELL) { if (type!=AT_COMBATSPELL && type!=AT_SPELL) {
/* Kein Zauber, normaler Waffenschaden */
double kritchance = (sk * 3 - sd) / 200.0;
#if KARMA_MODULE #if KARMA_MODULE
int faerie_level = fspecial(du->faction, FS_FAERIE); int faerie_level = fspecial(du->faction, FS_FAERIE);
@ -1017,32 +1051,44 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
#endif /* KARMA_MODULE */ #endif /* KARMA_MODULE */
if (damage_rules&DAMAGE_CRITICAL) {
double kritchance = (sk * 3 - sd) / 200.0;
kritchance = MAX(kritchance, 0.005); kritchance = MAX(kritchance, 0.005);
kritchance = MIN(0.9, kritchance); kritchance = MIN(0.9, kritchance);
while (chance(kritchance)) { while (chance(kritchance)) {
if (bdebug) { if (bdebug) {
fprintf(bdebug, "%s/%d landet einen kritischen Treffer", unitid(au), at.index); fprintf(bdebug, "%s/%d lands a critical hit", unitid(au), at.index);
} }
da += dice_rand(damage); da += dice_rand(damage);
} }
}
da += rc_specialdamage(au->race, du->race, awtype); da += rc_specialdamage(au->race, du->race, awtype);
if (awtype!=NULL && fval(awtype, WTF_MISSILE)) { if (awtype!=NULL && fval(awtype, WTF_MISSILE)) {
/* Fernkampfschadenbonus */ /* missile weapon bonus */
if (damage_rules&DAMAGE_MISSILE_BONUS) {
da += af->person[at.index].damage_rear; da += af->person[at.index].damage_rear;
}
} else if (awtype==NULL) { } else if (awtype==NULL) {
/* Waffenloser kampf, bonus von talentwert*/ /* skill bonus for unarmed combat */
if (damage_rules&DAMAGE_UNARMED_BONUS) {
da += effskill(au, SK_WEAPONLESS); da += effskill(au, SK_WEAPONLESS);
}
} else { } else {
/* Nahkampfschadensbonus */ /* melee bonus */
if (damage_rules&DAMAGE_MELEE_BONUS) {
da += af->person[at.index].damage; da += af->person[at.index].damage;
} }
}
/* Skilldifferenzbonus */ /* Skilldifferenzbonus */
if (damage_rules&DAMAGE_SKILL_BONUS) {
da += MAX(0, (sk-sd)/DAMAGE_QUOTIENT); da += MAX(0, (sk-sd)/DAMAGE_QUOTIENT);
} }
}
if (magic) { if (magic) {
@ -3943,12 +3989,16 @@ battle_flee(battle * b)
void void
do_battle(region * r) do_battle(region * r)
{ {
static int max_turns = 0;
battle *b = NULL; battle *b = NULL;
boolean fighting = false; boolean fighting = false;
ship * sh; ship * sh;
building *bu; building *bu;
static int init_rules = 0;
if (!init_rules) {
static_rules();
init_rules = 1;
}
if (msg_separator==NULL) { if (msg_separator==NULL) {
msg_separator = msg_message("battle::section", ""); msg_separator = msg_message("battle::section", "");
} }
@ -3996,9 +4046,6 @@ do_battle(region * r)
print_stats(b); /* gibt die Kampfaufstellung aus */ print_stats(b); /* gibt die Kampfaufstellung aus */
log_stdio(stdout, "%s (%d, %d) : ", rname(r, NULL), r->x, r->y); log_stdio(stdout, "%s (%d, %d) : ", rname(r, NULL), r->x, r->y);
if (max_turns==0) {
max_turns = get_param_int(global.parameters, "rules.combat_turns", COMBAT_TURNS);
}
for (;battle_report(b) && b->turn<=max_turns;++b->turn) { for (;battle_report(b) && b->turn<=max_turns;++b->turn) {
if (bdebug) { if (bdebug) {
fprintf(bdebug, "*** Turn: %d\n", b->turn); fprintf(bdebug, "*** Turn: %d\n", b->turn);

View File

@ -8855,17 +8855,18 @@ init_spells(void)
set_spelldata_i(sp, data); set_spelldata_i(sp, data);
register_spell(sp); register_spell(sp);
} }
at_register(&at_cursewall);
at_register(&at_unitdissolve);
at_register(&at_wdwpyramid);
register_bordertype(&bt_firewall);
register_bordertype(&bt_wisps);
register_bordertype(&bt_chaosgate);
} }
void void
register_spells(void) register_spells(void)
{ {
at_register(&at_cursewall);
at_register(&at_unitdissolve);
at_register(&at_wdwpyramid);
register_bordertype(&bt_firewall);
register_bordertype(&bt_wisps);
register_bordertype(&bt_chaosgate);
/* sp_summon_alp */ /* sp_summon_alp */
register_alp(); register_alp();

View File

@ -604,6 +604,7 @@ main(int argc, char *argv[])
char * lc_ctype; char * lc_ctype;
char * lc_numeric; char * lc_numeric;
rng_init((unsigned long)time(0));
setup_signal_handler(); setup_signal_handler();
sqlpatch = true; sqlpatch = true;

View File

@ -6,21 +6,21 @@
<xi:include href="de/strings.xml"/> <xi:include href="de/strings.xml"/>
<xi:include href="en/strings.xml"/> <xi:include href="en/strings.xml"/>
<xi:include href="common/items.xml" />
<xi:include href="common/armor.xml" /> <xi:include href="common/armor.xml" />
<xi:include href="common/weapons.xml" /> <xi:include href="common/items.xml" />
<xi:include href="common/resources.xml" />
<xi:include href="common/luxuries.xml" /> <xi:include href="common/luxuries.xml" />
<xi:include href="common/potions.xml" /> <xi:include href="common/potions.xml" />
<xi:include href="eressea2/terrains.xml"/> <xi:include href="common/resources.xml" />
<xi:include href="eressea2/races.xml"/> <xi:include href="eressea2/races.xml"/>
<xi:include href="eressea2/spells.xml"/>
<xi:include href="eressea2/terrains.xml"/>
<xi:include href="eressea2/weapons.xml" />
<xi:include href="spoils.xml"/> <xi:include href="spoils.xml"/>
<xi:include href="prefixes.xml"/> <xi:include href="prefixes.xml"/>
<xi:include href="ships.xml"/> <xi:include href="ships.xml"/>
<xi:include href="buildings.xml"/> <xi:include href="buildings.xml"/>
<xi:include href="eressea/calendar.xml"/> <xi:include href="eressea/calendar.xml"/>
<xi:include href="equipment.xml"/> <xi:include href="equipment.xml"/>
<xi:include href="spells.xml"/>
<xi:include href="dungeons.xml"/> <xi:include href="dungeons.xml"/>
<xi:include href="directions.xml"/> <xi:include href="directions.xml"/>
@ -95,7 +95,12 @@
<param name="modules.wormholes" value="0"/> <param name="modules.wormholes" value="0"/>
<param name="rules.check_overload" value="0"/> <param name="rules.check_overload" value="0"/>
<param name="rules.combat_turns" value="1"/> <param name="rules.combat.critical" value="0"/>
<param name="rules.combat.melee_bonus" value="0"/>
<param name="rules.combat.missile_bonus" value="0"/>
<param name="rules.combat.skill_bonus" value="0"/>
<param name="rules.combat.turns" value="1"/>
<param name="rules.combat.unarmed_bonus" value="0"/>
<param name="rules.give" value="3"/> <!-- only self + peasants --> <param name="rules.give" value="3"/> <!-- only self + peasants -->
<param name="rules.stamina" value="0"/> <!-- does not affect hp --> <param name="rules.stamina" value="0"/> <!-- does not affect hp -->
<param name="skill.maxlevel" value="10"/> <param name="skill.maxlevel" value="10"/>