forked from github/server
study potion. To use this potion, you must have:
- a level < 2 in the skill - a STUDY order for a no-fee skill Each potion adds 1 study attempt, up to a maximum of 15 attempts
This commit is contained in:
parent
13172a28af
commit
31b609b7b9
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "eressea.h"
|
#include "eressea.h"
|
||||||
|
#include "study.h"
|
||||||
|
|
||||||
#include "alchemy.h"
|
#include "alchemy.h"
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
|
@ -97,8 +98,8 @@ magic_lowskill(unit *u)
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
int
|
||||||
study_cost(unit *u, int talent)
|
study_cost(unit *u, skill_t talent)
|
||||||
{
|
{
|
||||||
int stufe, k = 50;
|
int stufe, k = 50;
|
||||||
|
|
||||||
|
@ -122,12 +123,6 @@ study_cost(unit *u, int talent)
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
#define MAXTEACHERS 4
|
|
||||||
typedef struct teaching_info {
|
|
||||||
unit * teachers[MAXTEACHERS];
|
|
||||||
int value;
|
|
||||||
} teaching_info;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_learning(struct attrib * a)
|
init_learning(struct attrib * a)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +135,7 @@ done_learning(struct attrib * a)
|
||||||
free(a->data.v);
|
free(a->data.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const attrib_type at_learning = {
|
const attrib_type at_learning = {
|
||||||
"learning",
|
"learning",
|
||||||
init_learning, done_learning, NULL, NULL, NULL,
|
init_learning, done_learning, NULL, NULL, NULL,
|
||||||
ATF_UNIQUE
|
ATF_UNIQUE
|
||||||
|
|
|
@ -8,6 +8,7 @@ SubDirHdrs $(SUBDIR)/.. ;
|
||||||
SubDirHdrs $(SUBDIR)/../.. ;
|
SubDirHdrs $(SUBDIR)/../.. ;
|
||||||
|
|
||||||
SOURCES =
|
SOURCES =
|
||||||
|
artrewards.c
|
||||||
birthday_firework.c
|
birthday_firework.c
|
||||||
catapultammo.c
|
catapultammo.c
|
||||||
demonseye.c
|
demonseye.c
|
||||||
|
@ -15,10 +16,10 @@ SOURCES =
|
||||||
questkeys.c
|
questkeys.c
|
||||||
racespoils.c
|
racespoils.c
|
||||||
seed.c
|
seed.c
|
||||||
|
speedsail.c
|
||||||
|
studypotion.c
|
||||||
weapons.c
|
weapons.c
|
||||||
xerewards.c
|
xerewards.c
|
||||||
artrewards.c
|
|
||||||
speedsail.c
|
|
||||||
;
|
;
|
||||||
|
|
||||||
Library items : $(SOURCES) ;
|
Library items : $(SOURCES) ;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "artrewards.h"
|
#include "artrewards.h"
|
||||||
#include "weapons.h"
|
#include "weapons.h"
|
||||||
#include "speedsail.h"
|
#include "speedsail.h"
|
||||||
|
#include "studypotion.h"
|
||||||
#include "racespoils.h"
|
#include "racespoils.h"
|
||||||
#if GROWING_TREES
|
#if GROWING_TREES
|
||||||
# include "seed.h"
|
# include "seed.h"
|
||||||
|
@ -44,6 +45,7 @@ register_items(void)
|
||||||
register_racespoils();
|
register_racespoils();
|
||||||
register_artrewards();
|
register_artrewards();
|
||||||
register_speedsail();
|
register_speedsail();
|
||||||
|
register_studypotion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -181,6 +181,12 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\speedsail.h">
|
RelativePath=".\speedsail.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\studypotion.c">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\studypotion.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\weapons.c">
|
RelativePath=".\weapons.c">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -17,17 +17,17 @@
|
||||||
#include "speedsail.h"
|
#include "speedsail.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <item.h>
|
#include <kernel/item.h>
|
||||||
#include <message.h>
|
#include <kernel/message.h>
|
||||||
#include <movement.h>
|
#include <kernel/movement.h>
|
||||||
#include <plane.h>
|
#include <kernel/plane.h>
|
||||||
#include <region.h>
|
#include <kernel/region.h>
|
||||||
#include <ship.h>
|
#include <kernel/ship.h>
|
||||||
#include <unit.h>
|
#include <kernel/unit.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <functions.h>
|
#include <util/functions.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -61,25 +61,8 @@ use_speedsail(struct unit * u, const struct item_type * itype, int amount, struc
|
||||||
return EUNUSABLE;
|
return EUNUSABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static resource_type rt_speedsail = {
|
|
||||||
{ "speedsail", "speedsail_p" },
|
|
||||||
{ "speedsail", "speedsail_p" },
|
|
||||||
RTF_ITEM,
|
|
||||||
&res_changeitem
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
item_type it_speedsail = {
|
|
||||||
&rt_speedsail, /* resourcetype */
|
|
||||||
0, 0, 0, /* flags, weight, capacity */
|
|
||||||
NULL, /* construction */
|
|
||||||
&use_speedsail,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
register_speedsail(void)
|
register_speedsail(void)
|
||||||
{
|
{
|
||||||
it_register(&it_speedsail);
|
register_function((pf_generic)use_speedsail, "use_speedsail");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include <config.h>
|
||||||
|
#include <kernel/eressea.h>
|
||||||
|
#include "studypotion.h"
|
||||||
|
|
||||||
|
#include <kernel/faction.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
|
#include <kernel/order.h>
|
||||||
|
#include <kernel/skill.h>
|
||||||
|
#include <kernel/study.h>
|
||||||
|
#include <kernel/unit.h>
|
||||||
|
|
||||||
|
#include <util/attrib.h>
|
||||||
|
#include <util/functions.h>
|
||||||
|
|
||||||
|
/* BEGIN it_studypotion */
|
||||||
|
#define MAXGAIN 15
|
||||||
|
static int
|
||||||
|
use_studypotion(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
|
||||||
|
{
|
||||||
|
if (get_keyword(u->thisorder) == K_STUDY) {
|
||||||
|
skill_t sk;
|
||||||
|
skill * sv;
|
||||||
|
|
||||||
|
init_tokens(u->thisorder);
|
||||||
|
skip_token();
|
||||||
|
sk = findskill(getstrtoken(), u->faction->locale);
|
||||||
|
sv = get_skill(u, sk);
|
||||||
|
|
||||||
|
if (sv && sv->level > 2) {
|
||||||
|
/* TODO: message */
|
||||||
|
} else if (study_cost(u, sk)>0) {
|
||||||
|
/* TODO: message */
|
||||||
|
} else {
|
||||||
|
attrib * a = a_find(u->attribs, &at_learning);
|
||||||
|
teaching_info * teach;
|
||||||
|
if (a==NULL) {
|
||||||
|
a = a_add(&u->attribs, a_new(&at_learning));
|
||||||
|
}
|
||||||
|
teach = (teaching_info*) a->data.v;
|
||||||
|
if (amount>MAXGAIN) amount = MAXGAIN;
|
||||||
|
teach->value += amount * 30;
|
||||||
|
if (teach->value > MAXGAIN * 30) {
|
||||||
|
teach->value = MAXGAIN * 30;
|
||||||
|
}
|
||||||
|
i_change(&u->items, itype, -amount);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EUNUSABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
register_studypotion(void)
|
||||||
|
{
|
||||||
|
register_function((pf_generic)use_studypotion, "use_studypotion");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* END it_studypotion */
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* vi: set ts=2:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||||
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||||
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||||
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||||
|
* Enno Rehling (enno@eressea-pbem.de)
|
||||||
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||||
|
*
|
||||||
|
* This program may not be used, modified or distributed without
|
||||||
|
* prior permission by the authors of Eressea.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef H_ITM_STUDYPOTION
|
||||||
|
#define H_ITM_STUDYPOTION
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void register_studypotion(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -12,8 +12,30 @@
|
||||||
* prior permission by the authors of Eressea.
|
* prior permission by the authors of Eressea.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void teaching(void);
|
#ifndef H_KRNL_STUDY
|
||||||
void learn(void);
|
#define H_KRNL_STUDY
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void teaching(void);
|
||||||
|
extern void learn(void);
|
||||||
|
|
||||||
extern magic_t getmagicskill(void);
|
extern magic_t getmagicskill(void);
|
||||||
extern boolean is_migrant(struct unit *u);
|
extern boolean is_migrant(struct unit *u);
|
||||||
|
extern int study_cost(struct unit *u, skill_t talent);
|
||||||
|
|
||||||
|
#define MAXTEACHERS 4
|
||||||
|
typedef struct teaching_info {
|
||||||
|
struct unit * teachers[MAXTEACHERS];
|
||||||
|
int value;
|
||||||
|
} teaching_info;
|
||||||
|
|
||||||
|
extern const struct attrib_type at_learning;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -6034,4 +6034,14 @@
|
||||||
<text locale="en">grails</text>
|
<text locale="en">grails</text>
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="studypotion">
|
||||||
|
<text locale="de">Lerntrank</text>
|
||||||
|
<text locale="en">brain boost</text>
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="studypotion_p">
|
||||||
|
<text locale="de">Lerntränke</text>
|
||||||
|
<text locale="en">brain boosts</text>
|
||||||
|
</string>
|
||||||
|
|
||||||
</strings>
|
</strings>
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
</item>
|
</item>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
|
<resource name="studypotion">
|
||||||
|
<item weight="0">
|
||||||
|
<function name="use" value="use_studypotion"/>
|
||||||
|
</item>
|
||||||
|
</resource>
|
||||||
|
|
||||||
|
<resource name="speedsail">
|
||||||
|
<item weight="0">
|
||||||
|
<function name="use" value="use_speedsail"/>
|
||||||
|
</item>
|
||||||
|
</resource>
|
||||||
|
|
||||||
<resource name="snowman">
|
<resource name="snowman">
|
||||||
<!-- xmas gimmik -->
|
<!-- xmas gimmik -->
|
||||||
<item notlost="yes" weight="1"/>
|
<item notlost="yes" weight="1"/>
|
||||||
|
|
Loading…
Reference in New Issue