2005-01-30 09:57:16 +01:00
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <kernel/eressea.h>
|
|
|
|
|
#include "items.h"
|
|
|
|
|
|
2006-01-29 09:31:54 +01:00
|
|
|
|
#include "study.h"
|
|
|
|
|
|
2005-01-31 00:33:28 +01:00
|
|
|
|
#include <kernel/curse.h>
|
|
|
|
|
#include <kernel/building.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/item.h>
|
2005-01-31 00:33:28 +01:00
|
|
|
|
#include <kernel/magic.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <kernel/message.h>
|
|
|
|
|
#include <kernel/movement.h>
|
|
|
|
|
#include <kernel/order.h>
|
|
|
|
|
#include <kernel/plane.h>
|
2005-10-23 11:05:11 +02:00
|
|
|
|
#include <kernel/pool.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
|
#include <kernel/skill.h>
|
2005-10-23 11:05:11 +02:00
|
|
|
|
#include <kernel/spell.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
|
2005-10-26 22:30:02 +02:00
|
|
|
|
#include <items/demonseye.h>
|
|
|
|
|
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <util/attrib.h>
|
|
|
|
|
#include <util/functions.h>
|
2007-06-22 00:31:28 +02:00
|
|
|
|
#include <util/parser.h>
|
2005-01-31 00:33:28 +01:00
|
|
|
|
#include <util/rand.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
|
2006-11-05 21:14:07 +01:00
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
2005-01-30 09:57:16 +01:00
|
|
|
|
/* BEGIN 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;
|
|
|
|
|
}
|
|
|
|
|
/* END studypotion */
|
|
|
|
|
|
|
|
|
|
/* BEGIN speedsail */
|
2006-11-05 21:14:07 +01:00
|
|
|
|
#define SPEEDSAIL_EFFECT 1
|
2005-01-30 09:57:16 +01:00
|
|
|
|
static int
|
|
|
|
|
use_speedsail(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
|
|
|
|
|
{
|
2006-11-05 21:14:07 +01:00
|
|
|
|
curse *c;
|
|
|
|
|
variant effect;
|
|
|
|
|
ship * sh = u->ship;
|
|
|
|
|
if (!sh) {
|
|
|
|
|
cmistake(u, ord, 20, MSG_MOVE);
|
|
|
|
|
return -1;
|
2005-01-30 09:57:16 +01:00
|
|
|
|
}
|
2006-11-05 21:14:07 +01:00
|
|
|
|
|
|
|
|
|
effect.i = SPEEDSAIL_EFFECT;
|
|
|
|
|
c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0);
|
2007-04-22 01:04:24 +02:00
|
|
|
|
c_setflag(c, CURSE_NOAGE);
|
2006-11-05 21:14:07 +01:00
|
|
|
|
|
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit speed", u, SPEEDSAIL_EFFECT));
|
|
|
|
|
itype->rtype->uchange(u, itype->rtype, -1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
2005-01-30 09:57:16 +01:00
|
|
|
|
}
|
|
|
|
|
/* END speedsail */
|
|
|
|
|
|
2005-10-23 11:05:11 +02:00
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/* Kann auch von Nichtmagiern benutzt werden, erzeugt eine
|
|
|
|
|
* Antimagiezone, die zwei Runden bestehen bleibt */
|
2005-10-25 15:17:55 +02:00
|
|
|
|
static int
|
2005-10-23 17:11:22 +02:00
|
|
|
|
use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struct order * ord)
|
2005-10-23 11:05:11 +02:00
|
|
|
|
{
|
2005-10-23 17:11:22 +02:00
|
|
|
|
region * r = u->region;
|
2005-10-23 12:20:55 +02:00
|
|
|
|
const resource_type * rt_crystal = NULL;
|
2005-10-23 11:05:11 +02:00
|
|
|
|
int i;
|
2005-10-23 12:15:30 +02:00
|
|
|
|
|
|
|
|
|
if (rt_crystal == NULL) {
|
|
|
|
|
rt_crystal = rt_find("antimagic");
|
|
|
|
|
assert(rt_crystal!=NULL);
|
|
|
|
|
}
|
2005-10-23 11:05:11 +02:00
|
|
|
|
for (i=0;i!=amount;++i) {
|
|
|
|
|
int effect, duration = 2;
|
|
|
|
|
double force;
|
|
|
|
|
spell *sp = find_spell(M_GRAU, "antimagiczone");
|
|
|
|
|
attrib ** ap = &r->attribs;
|
|
|
|
|
unused(ord);
|
|
|
|
|
assert(sp);
|
|
|
|
|
|
|
|
|
|
/* Reduziert die St<53>rke jedes Spruchs um effect */
|
|
|
|
|
effect = sp->level;
|
|
|
|
|
|
|
|
|
|
/* H<>lt Spr<70>che bis zu einem summierten Gesamtlevel von power aus.
|
|
|
|
|
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
|
|
|
|
|
* um seine Stufe */
|
|
|
|
|
force = sp->level * 20; /* Stufe 5 =~ 100 */
|
|
|
|
|
|
|
|
|
|
/* Regionszauber aufl<66>sen */
|
|
|
|
|
while (*ap && force > 0) {
|
|
|
|
|
curse * c;
|
|
|
|
|
attrib * a = *ap;
|
|
|
|
|
if (!fval(a->type, ATF_CURSE)) {
|
|
|
|
|
do { ap = &(*ap)->next; } while (*ap && a->type==(*ap)->type);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
c = (curse*)a->data.v;
|
|
|
|
|
|
|
|
|
|
/* Immunit<69>t pr<70>fen */
|
2007-04-22 01:04:24 +02:00
|
|
|
|
if (c_flags(c) & CURSE_IMMUNE) {
|
2005-10-23 11:05:11 +02:00
|
|
|
|
do { ap = &(*ap)->next; } while (*ap && a->type==(*ap)->type);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
force = destr_curse(c, effect, force);
|
|
|
|
|
if(c->vigour <= 0) {
|
|
|
|
|
a_remove(&r->attribs, a);
|
|
|
|
|
}
|
|
|
|
|
if(*ap) ap = &(*ap)->next;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-22 01:04:24 +02:00
|
|
|
|
if (force > 0) {
|
2005-10-23 11:05:11 +02:00
|
|
|
|
variant var ;
|
|
|
|
|
var.i = effect;
|
2005-10-23 17:11:22 +02:00
|
|
|
|
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0);
|
2005-10-23 11:05:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-30 16:42:15 +01:00
|
|
|
|
use_pooled(u, rt_crystal, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
|
2005-10-23 17:11:22 +02:00
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal",
|
|
|
|
|
"unit region", u, r));
|
2005-10-25 15:17:55 +02:00
|
|
|
|
return 0;
|
2005-10-23 11:05:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-01-31 00:33:28 +01:00
|
|
|
|
static int
|
|
|
|
|
use_instantartsculpture(struct unit * u, const struct item_type * itype,
|
|
|
|
|
int amount, struct order * ord)
|
|
|
|
|
{
|
|
|
|
|
building *b;
|
|
|
|
|
|
|
|
|
|
if(u->region->land == NULL) {
|
2007-05-22 19:09:23 +02:00
|
|
|
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
2005-01-31 00:33:28 +01:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b = new_building(bt_find("artsculpture"), u->region, u->faction->locale);
|
|
|
|
|
b->size = 100;
|
|
|
|
|
|
|
|
|
|
ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region",
|
|
|
|
|
u, u->region));
|
|
|
|
|
|
|
|
|
|
itype->rtype->uchange(u, itype->rtype, -1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
use_instantartacademy(struct unit * u, const struct item_type * itype,
|
|
|
|
|
int amount, struct order * ord)
|
|
|
|
|
{
|
|
|
|
|
building *b;
|
|
|
|
|
|
|
|
|
|
if(u->region->land == NULL) {
|
2007-05-22 19:09:23 +02:00
|
|
|
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
2005-01-31 00:33:28 +01:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b = new_building(bt_find("artacademy"), u->region, u->faction->locale);
|
|
|
|
|
b->size = 100;
|
|
|
|
|
|
|
|
|
|
ADDMSG(&u->region->msgs, msg_message(
|
|
|
|
|
"artacademy_create", "unit region", u, u->region));
|
|
|
|
|
|
|
|
|
|
itype->rtype->uchange(u, itype->rtype, -1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define BAGPIPEFRACTION dice_rand("2d4+2")
|
|
|
|
|
#define BAGPIPEDURATION dice_rand("2d10+4")
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
use_bagpipeoffear(struct unit * u, const struct item_type * itype,
|
|
|
|
|
int amount, struct order * ord)
|
|
|
|
|
{
|
|
|
|
|
int money;
|
2005-06-10 00:10:35 +02:00
|
|
|
|
variant effect;
|
2005-01-31 00:33:28 +01:00
|
|
|
|
|
|
|
|
|
if(get_curse(u->region->attribs, ct_find("depression"))) {
|
|
|
|
|
cmistake(u, ord, 58, MSG_MAGIC);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
money = entertainmoney(u->region)/BAGPIPEFRACTION;
|
|
|
|
|
change_money(u, money);
|
|
|
|
|
rsetmoney(u->region, rmoney(u->region) - money);
|
|
|
|
|
|
2005-06-10 00:10:35 +02:00
|
|
|
|
effect.i = 0;
|
2005-01-31 00:33:28 +01:00
|
|
|
|
create_curse(u, &u->region->attribs, ct_find("depression"),
|
2005-06-10 00:10:35 +02:00
|
|
|
|
20, BAGPIPEDURATION, effect, 0);
|
2005-01-31 00:33:28 +01:00
|
|
|
|
|
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("bagpipeoffear_faction",
|
|
|
|
|
"unit region command money", u, u->region, ord, money));
|
|
|
|
|
|
|
|
|
|
ADDMSG(&u->region->msgs, msg_message("bagpipeoffear_region",
|
|
|
|
|
"unit money", u, money));
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
use_aurapotion50(struct unit * u, const struct item_type * itype,
|
|
|
|
|
int amount, struct order * ord)
|
|
|
|
|
{
|
|
|
|
|
if(!is_mage(u)) {
|
|
|
|
|
cmistake(u, ord, 214, MSG_MAGIC);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
change_spellpoints(u, 50);
|
|
|
|
|
|
|
|
|
|
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
|
|
|
|
"unit region command", u, u->region, ord));
|
|
|
|
|
|
|
|
|
|
itype->rtype->uchange(u, itype->rtype, -1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-30 09:57:16 +01:00
|
|
|
|
void
|
2005-10-26 21:02:45 +02:00
|
|
|
|
register_itemfunctions(void)
|
2005-01-30 09:57:16 +01:00
|
|
|
|
{
|
2005-10-26 22:30:02 +02:00
|
|
|
|
register_demonseye();
|
2005-10-23 11:05:11 +02:00
|
|
|
|
register_function((pf_generic)use_antimagiccrystal, "use_antimagiccrystal");
|
2005-01-31 00:33:28 +01:00
|
|
|
|
register_function((pf_generic)use_instantartsculpture, "use_instantartsculpture");
|
2005-01-30 09:57:16 +01:00
|
|
|
|
register_function((pf_generic)use_studypotion, "use_studypotion");
|
|
|
|
|
register_function((pf_generic)use_speedsail, "use_speedsail");
|
2005-01-31 00:33:28 +01:00
|
|
|
|
register_function((pf_generic)use_instantartacademy, "use_instantartacademy");
|
|
|
|
|
register_function((pf_generic)use_bagpipeoffear, "use_bagpipeoffear");
|
|
|
|
|
register_function((pf_generic)use_aurapotion50, "use_aurapotion50");
|
2005-01-30 09:57:16 +01:00
|
|
|
|
}
|