New feature: learning speed

- final version and parameters for e2k9
This commit is contained in:
Enno Rehling 2009-06-03 20:47:18 +00:00
parent d871101994
commit 52127ced69
4 changed files with 23 additions and 12 deletions

View file

@ -154,14 +154,20 @@ const attrib_type at_learning = {
static int static int
study_days(unit * student, skill_t sk) study_days(unit * student, skill_t sk)
{ {
int speed = 30 + student->race->study_speed_base; int speed = 30;
if (student->race->study_speed) speed += student->race->study_speed[sk]; if (student->race->study_speed) {
speed += student->race->study_speed[sk];
}
if (speed<30) {
skill * sv = get_skill(student, sk);
if (sv==0) return 30;
}
return student->number * speed; return student->number * speed;
} }
static int static int
teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
boolean report, int * academy) boolean report, int * academy)
{ {
teaching_info * teach = NULL; teaching_info * teach = NULL;
attrib * a; attrib * a;
@ -179,7 +185,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
return 0; return 0;
} }
n = study_days(student, sk); n = 30;
a = a_find(student->attribs, &at_learning); a = a_find(student->attribs, &at_learning);
if (a!=NULL) { if (a!=NULL) {
teach = (teaching_info*)a->data.v; teach = (teaching_info*)a->data.v;
@ -487,6 +493,7 @@ study_speedup(unit * u)
} }
return 1.0; return 1.0;
} }
int int
learn_cmd(unit * u, order * ord) learn_cmd(unit * u, order * ord)
{ {
@ -703,8 +710,8 @@ learn_cmd(unit * u, order * ord)
} }
multi *= study_speedup(u); multi *= study_speedup(u);
days = study_days(u, sk);
days = (int)((u->number * 30 + teach->value) * multi); days = (int)((days + teach->value) * multi);
/* the artacademy currently improves the learning of entertainment /* the artacademy currently improves the learning of entertainment
of all units in the region, to be able to make it cumulative with of all units in the region, to be able to make it cumulative with

View file

@ -75,7 +75,6 @@ typedef struct race {
const spell * precombatspell; const spell * precombatspell;
struct att attack[10]; struct att attack[10];
char bonus[MAXSKILLS]; char bonus[MAXSKILLS];
char study_speed_base;
signed char * study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */ signed char * study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */
boolean __remove_me_nonplayer; boolean __remove_me_nonplayer;
int flags; int flags;

View file

@ -1541,7 +1541,7 @@ parse_races(xmlDocPtr doc)
xmlChar * propValue; xmlChar * propValue;
race * rc; race * rc;
xmlXPathObjectPtr result; xmlXPathObjectPtr result;
int k; int k, study_speed_base;
struct att * attack; struct att * attack;
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
@ -1565,7 +1565,7 @@ parse_races(xmlDocPtr doc)
rc->speed = (float)xml_fvalue(node, "speed", 1.0F); rc->speed = (float)xml_fvalue(node, "speed", 1.0F);
rc->hitpoints = xml_ivalue(node, "hp", 0); rc->hitpoints = xml_ivalue(node, "hp", 0);
rc->armor = (char)xml_ivalue(node, "ac", 0); rc->armor = (char)xml_ivalue(node, "ac", 0);
rc->study_speed_base = xml_ivalue(node, "studyspeed", 0); study_speed_base = xml_ivalue(node, "studyspeed", 0);
rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2);
rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2); rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2);
@ -1627,7 +1627,7 @@ parse_races(xmlDocPtr doc)
for (k=0;k!=result->nodesetval->nodeNr;++k) { for (k=0;k!=result->nodesetval->nodeNr;++k) {
xmlNodePtr node = result->nodesetval->nodeTab[k]; xmlNodePtr node = result->nodesetval->nodeTab[k];
int mod = xml_ivalue(node, "modifier", 0); int mod = xml_ivalue(node, "modifier", 0);
int speed = xml_ivalue(node, "speed", 0); int speed = xml_ivalue(node, "speed", study_speed_base);
skill_t sk; skill_t sk;
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");

View file

@ -24,20 +24,25 @@
<familiar race="imp"/> <familiar race="imp"/>
</race> </race>
<race name="uruk" magres="-0.05" maxaura="1.0" regaura="1.0" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="uruk" studyspeed="-5" magres="-0.05" maxaura="1.0" regaura="1.0" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.0" 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"/>
<param name="other_cost" value="500"/> <param name="other_cost" value="500"/>
<skill name="armorer" modifier="1"/>
<skill name="bow" speed="+5"/>
<skill name="building" modifier="1"/> <skill name="building" modifier="1"/>
<skill name="cartmaking" modifier="-1"/> <skill name="cartmaking" modifier="-1"/>
<skill name="catapult" speed="+5"/>
<skill name="crossbow" speed="+5"/>
<skill name="forestry" modifier="1"/> <skill name="forestry" modifier="1"/>
<skill name="herbalism" modifier="-2"/> <skill name="herbalism" modifier="-2"/>
<skill name="melee" speed="+5"/>
<skill name="mining" modifier="1"/> <skill name="mining" modifier="1"/>
<skill name="quarrying" modifier="1"/> <skill name="quarrying" modifier="1"/>
<skill name="riding" modifier="-99"/> <skill name="riding" modifier="-99"/>
<skill name="sailing" modifier="-1"/> <skill name="sailing" modifier="-1"/>
<skill name="stamina" speed="0"/>
<skill name="shipcraft" modifier="-1"/> <skill name="shipcraft" modifier="-1"/>
<skill name="tactics" modifier="1"/> <skill name="tactics" modifier="1"/>
<skill name="training" modifier="-1"/> <skill name="training" modifier="-1"/>