New feature: learning speed

This commit is contained in:
Enno Rehling 2009-06-03 20:03:03 +00:00
parent 7b24248ac2
commit d871101994
6 changed files with 27 additions and 25 deletions

View File

@ -151,6 +151,14 @@ const attrib_type at_learning = {
ATF_UNIQUE ATF_UNIQUE
}; };
static int
study_days(unit * student, skill_t sk)
{
int speed = 30 + student->race->study_speed_base;
if (student->race->study_speed) speed += student->race->study_speed[sk];
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)
@ -171,7 +179,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
return 0; return 0;
} }
n = student->number * 30; n = study_days(student, sk);
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;

View File

@ -207,21 +207,6 @@ HelpMask(void)
return value; return value;
} }
/** specifies modes that are restricted to members of the same alliance.
* if this returns a non-zero value, then you cannot give those modes to a
* faction unless they are in the same alliance.
*/
int
HelpMask(void)
{
static int help_mask = 0;
if (help_mask==0) {
help_mask = get_param_int(global.parameters, "rules.help.mask", HELP_ALL);
}
return help_mask;
}
int int
AllianceRestricted(void) AllianceRestricted(void)
{ {

View File

@ -125,6 +125,8 @@ rc_new(const char * zName)
rc->attack[0].type = AT_COMBATSPELL; rc->attack[0].type = AT_COMBATSPELL;
rc->attack[1].type = AT_NONE; rc->attack[1].type = AT_NONE;
rc->speed = 0;
rc->study_speed_base = 0;
return rc; return rc;
} }

View File

@ -75,6 +75,8 @@ 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) */
boolean __remove_me_nonplayer; boolean __remove_me_nonplayer;
int flags; int flags;
int battle_flags; int battle_flags;

View File

@ -1565,6 +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);
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);
@ -1626,17 +1627,21 @@ 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);
skill_t sk;
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue!=NULL); assert(propValue!=NULL);
if (mod!=0) { sk = sk_find((const char*)propValue);
skill_t sk = sk_find((const char*)propValue); if (sk!=NOSKILL) {
if (sk!=NOSKILL) { rc->bonus[sk] = (char)mod;
rc->bonus[sk] = (char)mod; if (speed) {
} else { if (!rc->study_speed) rc->study_speed = calloc(1, MAXSKILLS);
log_error(("unknown skill '%s' in race '%s'\n", rc->study_speed[sk] = speed;
(const char*)propValue, rc->_name[0]));
} }
} else {
log_error(("unknown skill '%s' in race '%s'\n",
(const char*)propValue, rc->_name[0]));
} }
xmlFree(propValue); xmlFree(propValue);
} }

View File

@ -27,8 +27,8 @@
<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" 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="armorer" modifier="1"/>
<skill name="building" modifier="1"/> <skill name="building" modifier="1"/>
<skill name="cartmaking" modifier="-1"/> <skill name="cartmaking" modifier="-1"/>