2001-09-05 21:40:40 +02:00
|
|
|
/* vi: set ts=2:
|
|
|
|
*
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <eressea.h>
|
|
|
|
#include "xerewards.h"
|
|
|
|
|
|
|
|
/* kernel includes */
|
|
|
|
#include <item.h>
|
|
|
|
#include <region.h>
|
|
|
|
#include <faction.h>
|
|
|
|
#include <unit.h>
|
2002-02-15 17:13:30 +01:00
|
|
|
#include <skill.h>
|
2001-09-05 21:40:40 +02:00
|
|
|
#include <curse.h>
|
|
|
|
#include <message.h>
|
|
|
|
#include <magic.h>
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
/* util includes */
|
|
|
|
#include <functions.h>
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
/* libc includes */
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
static int
|
2002-03-16 18:30:48 +01:00
|
|
|
use_skillpotion(struct unit * u, const struct item_type * itype, int amount, const char *cm)
|
2001-09-05 21:40:40 +02:00
|
|
|
{
|
2002-03-16 18:30:48 +01:00
|
|
|
int i;
|
|
|
|
for (i=0;i!=amount;++i) {
|
|
|
|
skill * sv = u->skills;
|
|
|
|
while (sv!=u->skills+u->skill_size) {
|
|
|
|
int i;
|
|
|
|
for (i=0;i!=3;++i) learn_skill(u, sv->id, 1.0);
|
|
|
|
++sv;
|
|
|
|
}
|
2002-02-15 17:13:30 +01:00
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
add_message(&u->faction->msgs, new_message(u->faction,
|
|
|
|
"skillpotion_use%u:unit", u));
|
|
|
|
|
2002-03-16 18:30:48 +01:00
|
|
|
res_changeitem(u, itype->rtype, -amount);
|
|
|
|
return 0;
|
2001-09-05 21:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static resource_type rt_skillpotion = {
|
|
|
|
{ "skillpotion", "skillpotion_p" },
|
|
|
|
{ "skillpotion", "skillpotion_p" },
|
|
|
|
RTF_ITEM,
|
|
|
|
&res_changeitem
|
|
|
|
};
|
|
|
|
|
|
|
|
item_type it_skillpotion = {
|
|
|
|
&rt_skillpotion, /* resourcetype */
|
|
|
|
0, 0, 0, /* flags, weight, capacity */
|
|
|
|
NULL, /* construction */
|
|
|
|
&use_skillpotion,
|
2002-03-16 18:30:48 +01:00
|
|
|
NULL,
|
2001-09-05 21:40:40 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2002-03-16 18:30:48 +01:00
|
|
|
use_manacrystal(struct unit * u, const struct item_type * itype, int amount, const char *cm)
|
2001-09-05 21:40:40 +02:00
|
|
|
{
|
2002-03-16 18:30:48 +01:00
|
|
|
int i, sp = 0;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
if(!is_mage(u)) {
|
|
|
|
cmistake(u, u->thisorder, 295, MSG_EVENT);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-03-16 18:30:48 +01:00
|
|
|
for (i=0;i!=amount;++i) {
|
|
|
|
sp += max(25, max_spellpoints(u->region, u)/2);
|
|
|
|
change_spellpoints(u, sp);
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
add_message(&u->faction->msgs, new_message(u->faction,
|
|
|
|
"manacrystal_use%u:unit%i:aura", u, sp));
|
|
|
|
|
2002-03-16 18:30:48 +01:00
|
|
|
res_changeitem(u, itype->rtype, -amount);
|
|
|
|
return 0;
|
2001-09-05 21:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static resource_type rt_manacrystal = {
|
|
|
|
{ "manacrystal", "manacrystal_p" },
|
|
|
|
{ "manacrystal", "manacrystal_p" },
|
|
|
|
RTF_ITEM,
|
|
|
|
&res_changeitem
|
|
|
|
};
|
|
|
|
|
|
|
|
item_type it_manacrystal = {
|
|
|
|
&rt_manacrystal, /* resourcetype */
|
|
|
|
0, 0, 0, /* flags, weight, capacity */
|
|
|
|
NULL, /* construction */
|
|
|
|
&use_manacrystal,
|
2002-03-16 18:30:48 +01:00
|
|
|
NULL,
|
2001-09-05 21:40:40 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-12-10 01:13:39 +01:00
|
|
|
register_xerewards(void)
|
2001-09-05 21:40:40 +02:00
|
|
|
{
|
|
|
|
it_register(&it_skillpotion);
|
|
|
|
it_register(&it_manacrystal);
|
2001-12-10 01:13:39 +01:00
|
|
|
register_function((pf_generic)use_skillpotion, "useskillpotion");
|
|
|
|
register_function((pf_generic)use_manacrystal, "usemanacrystal");
|
2001-09-05 21:40:40 +02:00
|
|
|
}
|
|
|
|
|