- equipping newly recruited units

- cavalry skill bonus
- chargers
- configurable hunger
This commit is contained in:
Enno Rehling 2009-05-18 20:50:19 +00:00
parent bb50d7a9ef
commit 120508716e
12 changed files with 143 additions and 20 deletions

View File

@ -234,6 +234,8 @@ add_recruits(unit * u, int number, int wanted)
assert(number<=wanted); assert(number<=wanted);
if (number > 0) { if (number > 0) {
unit * unew; unit * unew;
char equipment[64];
#if KARMA_MODULE #if KARMA_MODULE
int i = fspecial(u->faction, FS_MILITIA); int i = fspecial(u->faction, FS_MILITIA);
#endif /* KARMA_MODULE */ #endif /* KARMA_MODULE */
@ -246,10 +248,10 @@ add_recruits(unit * u, int number, int wanted)
unew = create_unit(r, u->faction, number, u->race, 0, NULL, u); unew = create_unit(r, u->faction, number, u->race, 0, NULL, u);
} }
if (unew->race == new_race[RC_URUK]) { snprintf(equipment, sizeof(equipment), "new_%s_unit", u->race->_name[0]);
change_level(unew, SK_MELEE, 1); equip_unit(unew, get_equipment(equipment));
change_level(unew, SK_SPEAR, 1);
}
if (unew->race->ec_flags & ECF_REC_HORSES) { if (unew->race->ec_flags & ECF_REC_HORSES) {
change_level(unew, SK_RIDING, 1); change_level(unew, SK_RIDING, 1);
} }

View File

@ -699,6 +699,34 @@ weapon_skill(const weapon_type * wtype, const unit * u, boolean attacking)
return skill; return skill;
} }
static int CavalrySkill(void)
{
static int skill = -1;
if (skill<0) {
skill = get_param_int(global.parameters, "rules.cavalry.skill", 2);
}
return skill;
}
static int
CavalryBonus(const unit * u)
{
static int mode = -1;
if (mode<0) {
mode = get_param_int(global.parameters, "rules.cavalry.mode", 1);
}
if (mode==0) {
/* old rule, Eressea 1.0 compat */
return 2;
} else {
/* new rule, chargers in Eressea 1.1 */
int skl = effskill(u, SK_RIDING);
skl = skl*3/2-3;
return MAX(skl, 0);
}
}
static int static int
weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boolean missile) weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boolean missile)
/* effektiver Waffenskill während des Kampfes */ /* effektiver Waffenskill während des Kampfes */
@ -747,7 +775,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
/* Burgenbonus, Pferdebonus */ /* Burgenbonus, Pferdebonus */
if (is_riding(t) && (wtype==NULL || (fval(wtype, WTF_HORSEBONUS) && !fval(wtype, WTF_MISSILE)))) { if (is_riding(t) && (wtype==NULL || (fval(wtype, WTF_HORSEBONUS) && !fval(wtype, WTF_MISSILE)))) {
skill += 2; skill += CavalryBonus(tu);
if (wtype) skill = skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING); if (wtype) skill = skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING);
} }
@ -2191,6 +2219,37 @@ add_tactics(tactics * ta, fighter * fig, int value)
ta->value = value; ta->value = value;
} }
static double horsebonus(const unit * u)
{
static const item_type * it_horse = 0;
static const item_type * it_elvenhorse = 0;
static const item_type * it_charger = 0;
region * r = u->region;
int n1 = 0, n2 = 0, n3 = 0;
item * itm = u->items;
int skl = eff_skill(u, SK_RIDING, r);
if (skl<1) return 0.0;
if (it_horse==0) {
it_horse = it_find("horse");
it_elvenhorse = it_find("elvenhorse");
it_charger = it_find("charger");
}
while (itm) {
if (itm->type->flags&ITF_ANIMAL) {
if (itm->type==it_elvenhorse) n3 +=itm->number;
else if (itm->type==it_charger) n2 +=itm->number;
else if (itm->type==it_horse) n1 +=itm->number;
}
}
if (skl >= 5 && n3>=u->number) return 0.30;
if (skl >= 3 && n2+n3>=u->number) return 0.20;
if (skl >= 1 && n1+n2+n3>=u->number) return 0.10;
return 0.0F;
}
double double
fleechance(unit * u) fleechance(unit * u)
{ {
@ -2200,11 +2259,7 @@ fleechance(unit * u)
/* Einheit u versucht, dem Getümmel zu entkommen */ /* Einheit u versucht, dem Getümmel zu entkommen */
c += (eff_skill(u, SK_STEALTH, r) * 0.05); c += (eff_skill(u, SK_STEALTH, r) * 0.05);
c += horsebonus(u);
if (get_item(u, I_ELVENHORSE) >= u->number && eff_skill(u, SK_RIDING, r) >= 5)
c += 0.30;
else if (get_item(u, I_HORSE) >= u->number && eff_skill(u, SK_RIDING, r) >= 1)
c += 0.10;
if (u->race == new_race[RC_HALFLING]) { if (u->race == new_race[RC_HALFLING]) {
c += 0.20; c += 0.20;
@ -3214,7 +3269,14 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
fig->horses = fig->unit->number; fig->horses = fig->unit->number;
fig->elvenhorses = 0; fig->elvenhorses = 0;
} else { } else {
fig->horses = get_item(u, I_HORSE); static const item_type * it_charger = 0;
if (it_charger==0) {
it_charger = it_find("charger");
if (!it_charger) {
it_charger = it_find("horse");
}
}
fig->horses = i_get(u->items, it_charger);
fig->elvenhorses = get_item(u, I_ELVENHORSE); fig->elvenhorses = get_item(u, I_ELVENHORSE);
} }
@ -3244,7 +3306,7 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
if (fig->horses) { if (fig->horses) {
if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r)
|| eff_skill(u, SK_RIDING, r) < 2 || u->race == new_race[RC_TROLL] || fval(u, UFL_WERE)) || eff_skill(u, SK_RIDING, r) < CavalrySkill() || u->race == new_race[RC_TROLL] || fval(u, UFL_WERE))
fig->horses = 0; fig->horses = 0;
} }

View File

@ -63,6 +63,7 @@
#include <util/log.h> #include <util/log.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/parser.h> #include <util/parser.h>
#include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
#include <util/sql.h> #include <util/sql.h>
#include <util/translation.h> #include <util/translation.h>
@ -2509,9 +2510,21 @@ hunger(int number, unit * u)
region * r = u->region; region * r = u->region;
int dead = 0, hpsub = 0; int dead = 0, hpsub = 0;
int hp = u->hp / u->number; int hp = u->hp / u->number;
static const char * damage = 0;
static const char * rcdamage = 0;
static const race * rc = 0;
if (!damage) {
damage = get_param(global.parameters, "hunger.damage");
if (damage==NULL) damage = "1d12+12";
}
if (rc!=u->race) {
rcdamage = get_param(u->race->parameters, "hunger.damage");
rc = u->race;
}
while (number--) { while (number--) {
int dam = u->race==new_race[RC_HALFLING]?15+rng_int()%14:(13+rng_int()%12); int dam = dice_rand(rcdamage?rcdamage:damage);
if (dam >= hp) { if (dam >= hp) {
++dead; ++dead;
} else { } else {

View File

@ -171,7 +171,7 @@ typedef struct spell {
typedef struct spell_list { typedef struct spell_list {
struct spell_list * next; struct spell_list * next;
spell * data; spell * data; /* TODO: should be const */
} spell_list; } spell_list;
extern void spelllist_add(spell_list ** lspells, struct spell * sp); extern void spelllist_add(spell_list ** lspells, struct spell * sp);

View File

@ -1332,22 +1332,27 @@ parse_equipment(xmlDocPtr doc)
xpath->node = node; xpath->node = node;
xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath); xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath);
assert(!eq->callback);
add_callbacks(eq, xpathResult->nodesetval); add_callbacks(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult); xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "item", xpath); xpathResult = xmlXPathEvalExpression(BAD_CAST "item", xpath);
assert(!eq->items);
add_items(eq, xpathResult->nodesetval); add_items(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult); xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "spell", xpath); xpathResult = xmlXPathEvalExpression(BAD_CAST "spell", xpath);
assert(!eq->spells);
add_spells(eq, xpathResult->nodesetval); add_spells(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult); xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "skill", xpath); xpathResult = xmlXPathEvalExpression(BAD_CAST "skill", xpath);
assert(!eq->skills);
add_skills(eq, xpathResult->nodesetval); add_skills(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult); xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "subset", xpath); xpathResult = xmlXPathEvalExpression(BAD_CAST "subset", xpath);
assert(!eq->subsets);
add_subsets(doc, eq, xpathResult->nodesetval); add_subsets(doc, eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult); xmlXPathFreeObject(xpathResult);

View File

@ -26,6 +26,7 @@
<xi:include href="e2k9/strings.xml"/> <xi:include href="e2k9/strings.xml"/>
<xi:include href="e2k9/races.xml"/> <xi:include href="e2k9/races.xml"/>
<xi:include href="e2k9/buildings.xml"/> <xi:include href="e2k9/buildings.xml"/>
<xi:include href="e2k9/equipment.xml"/>
<xi:include href="e2k9/spells.xml"/> <xi:include href="e2k9/spells.xml"/>
<equipment> <equipment>
@ -108,11 +109,14 @@
<param name="nmr.removenewbie" value="10"/> <param name="nmr.removenewbie" value="10"/>
<param name="GiveRestriction" value="3"/> <param name="GiveRestriction" value="3"/>
<param name="hunger.long" value="1"/> <param name="hunger.long" value="1"/>
<param name="hunger.damage" value="1d9+9"/>
<param name="recruit.allow_merge" value="1"/> <param name="recruit.allow_merge" value="1"/>
<param name="rules.check_overload" value="0"/> <param name="rules.check_overload" value="0"/>
<param name="rules.combat.herospeed" value="3"/> <param name="rules.combat.herospeed" value="3"/>
<param name="rules.combat.skill_bonus" value="0"/> <param name="rules.combat.skill_bonus" value="0"/>
<param name="rules.combat.loot" value="3"/> <!-- only self + monsters --> <param name="rules.combat.loot" value="3"/> <!-- only self + monsters -->
<param name="rules.cavalry.skill" value="4"/>
<param name="rules.cavalry.mode" value="1"/>
<param name="rules.economy.taxation" value="1"/> <param name="rules.economy.taxation" value="1"/>
<param name="rules.give" value="3"/> <!-- only self + peasants --> <param name="rules.give" value="3"/> <!-- only self + peasants -->
<param name="rules.help.mask" value="fight guard stealth money"/> <param name="rules.help.mask" value="fight guard stealth money"/>

View File

@ -6,6 +6,7 @@
<construction skill="training" minskill="4" reqsize="1"> <construction skill="training" minskill="4" reqsize="1">
<requirement type="money" quantity="200"/> <requirement type="money" quantity="200"/>
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>
<requirement type="horse" quantity="1"/>
</construction> </construction>
<function name="give" value="givehorses"/> <function name="give" value="givehorses"/>
</item> </item>

View File

@ -6,6 +6,7 @@
<race name="goblin" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="6" weight="600" capacity="440" speed="1.000000" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="goblin" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="6" weight="600" capacity="440" speed="1.000000" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<param name="hunger.damage" value="1d8+7"/>
<param name="other_race" value="demon"/> <param name="other_race" value="demon"/>
<param name="other_cost" value="500"/> <param name="other_cost" value="500"/>
<skill name="alchemy" modifier="1"/> <skill name="alchemy" modifier="1"/>
@ -24,7 +25,7 @@
<familiar race="imp"/> <familiar race="imp"/>
</race> </race>
<race name="uruk" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="uruk" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<param name="other_race" value="troll"/> <param name="other_race" value="troll"/>
@ -64,7 +65,7 @@
<familiar race="giantturtle"/> <familiar race="giantturtle"/>
</race> </race>
<race name="halfling" magres="0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="halfling" magres="0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<param name="other_race" value="dwarf"/> <param name="other_race" value="dwarf"/>
@ -91,7 +92,7 @@
<!-- begin secondary races --> <!-- begin secondary races -->
<race name="demon" magres="0.150000" maxaura="1.000000" regaura="1.250000" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="50" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> <race name="demon" magres="0.150000" maxaura="1.000000" regaura="1.250000" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<skill name="alchemy" modifier="2"/> <skill name="alchemy" modifier="2"/>
@ -114,7 +115,7 @@
<familiar race="ghost"/> <familiar race="ghost"/>
</race> </race>
<race name="elf" magres="0.100000" maxaura="1.000000" regaura="1.250000" recruitcost="130" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="elf" magres="0.100000" maxaura="1.000000" regaura="1.250000" recruitcost="130" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<skill name="alchemy" modifier="-1"/> <skill name="alchemy" modifier="-1"/>
@ -136,7 +137,7 @@
<familiar race="unicorn"/> <familiar race="unicorn"/>
</race> </race>
<race name="troll" magres="0.100000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="10" weight="2000" capacity="1080" speed="1.000000" hp="30" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="troll" magres="0.100000" maxaura="1.000000" regaura="1.000000" recruitcost="100" maintenance="10" weight="2000" capacity="1080" speed="1.000000" hp="20" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<skill name="armorer" modifier="2"/> <skill name="armorer" modifier="2"/>
@ -159,7 +160,7 @@
<familiar race="rat"/> <familiar race="rat"/>
</race> </race>
<race name="dwarf" magres="0.050000" maxaura="1.000000" regaura="0.500000" recruitcost="110" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="dwarf" magres="0.050000" maxaura="1.000000" regaura="0.500000" recruitcost="110" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<skill name="armorer" modifier="2"/> <skill name="armorer" modifier="2"/>

View File

@ -19,4 +19,13 @@
<text locale="de">Wache</text> <text locale="de">Wache</text>
<text locale="en">watch</text> <text locale="en">watch</text>
</string> </string>
<string name="charger">
<text locale="de">Streitross</text>
<text locale="en">charger</text>
</string>
<string name="charger_p">
<text locale="de">Streitrösser</text>
<text locale="en">chargers</text>
</string>
</string> </string>

View File

@ -28,4 +28,28 @@
</item> </item>
</resource> </resource>
<resource name="greatsword">
<item weight="200" score="30">
<construction skill="weaponsmithing" minskill="4" reqsize="1">
<requirement type="iron" quantity="2"/>
</construction>
<weapon cut="true" skill="melee" offmod="-1" defmod="-2" horse="false">
<damage type="rider" value="2d8+3"/>
<damage type="footman" value="2d8+3"/>
</weapon>
</item>
</resource>
<resource name="rustygreatsword">
<item weight="200" score="20">
<construction skill="weaponsmithing" minskill="4" reqsize="1">
<requirement type="iron" quantity="2"/>
</construction>
<weapon cut="true" skill="melee" offmod="-2" defmod="-3" horse="false">
<damage type="rider" value="2d8"/>
<damage type="footman" value="2d8"/>
</weapon>
</item>
</resource>
</resources> </resources>

View File

@ -19,6 +19,7 @@
<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="eressea/equipment.xml"/>
<xi:include href="eressea/spells.xml"/> <xi:include href="eressea/spells.xml"/>
<xi:include href="terrains.xml"/> <xi:include href="terrains.xml"/>
<xi:include href="dungeons.xml"/> <xi:include href="dungeons.xml"/>

View File

@ -807,6 +807,7 @@
<race name="halfling" magres="0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="halfling" magres="0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/> <function name="itemdrop" value="defaultdrops"/>
<param name="hunger.damage" value="1d14+14"/>
<skill name="crossbow" modifier="1"/> <skill name="crossbow" modifier="1"/>
<skill name="mining" modifier="1"/> <skill name="mining" modifier="1"/>
<skill name="bow" modifier="-1"/> <skill name="bow" modifier="-1"/>