2015-01-30 20:37:14 +01:00
|
|
|
|
/*
|
2010-08-08 09:40:42 +02:00
|
|
|
|
*
|
2015-01-30 20:37:14 +01:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2015
|
2010-08-08 09:40:42 +02:00
|
|
|
|
* 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.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 <platform.h>
|
|
|
|
|
#include <kernel/config.h>
|
|
|
|
|
#include "unitcurse.h"
|
|
|
|
|
|
|
|
|
|
/* kernel includes */
|
|
|
|
|
#include <kernel/curse.h>
|
2014-06-09 18:54:48 +02:00
|
|
|
|
#include <kernel/messages.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <kernel/race.h>
|
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/objtypes.h>
|
|
|
|
|
#include <kernel/version.h>
|
|
|
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
|
#include <util/language.h>
|
|
|
|
|
#include <util/nrmessage.h>
|
|
|
|
|
#include <util/message.h>
|
|
|
|
|
#include <util/base36.h>
|
|
|
|
|
#include <util/functions.h>
|
2013-12-31 10:06:28 +01:00
|
|
|
|
|
|
|
|
|
#include <storage.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_AURA
|
|
|
|
|
*/
|
|
|
|
|
/* erh<72>ht/senkt regeneration und maxaura um effect% */
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_auraboost(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
struct unit *u = (struct unit *)obj;
|
|
|
|
|
unused_arg(typ);
|
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
if (curse_geteffect(c) > 100) {
|
|
|
|
|
return msg_message("curseinfo::auraboost_0", "unit id", u, c->no);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return msg_message("curseinfo::auraboost_1", "unit id", u, c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2014-12-12 23:00:30 +01:00
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
static struct curse_type ct_auraboost = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"auraboost",
|
|
|
|
|
CURSETYP_NORM, CURSE_SPREADMODULO, (NO_MERGE),
|
|
|
|
|
cinfo_auraboost
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Magic Boost - Gabe des Chaos */
|
|
|
|
|
static struct curse_type ct_magicboost = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"magicboost",
|
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_IMMUNE, M_MEN, cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_SLAVE
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_slave(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unit *u;
|
|
|
|
|
unused_arg(typ);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2014-12-12 23:00:30 +01:00
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
u = (unit *)obj;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2014-12-12 23:00:30 +01:00
|
|
|
|
if (self != 0) {
|
|
|
|
|
return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration,
|
|
|
|
|
c->no);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
static struct curse_type ct_slavery = { "slavery",
|
2014-12-12 23:00:30 +01:00
|
|
|
|
CURSETYP_NORM, 0, NO_MERGE,
|
|
|
|
|
cinfo_slave
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_CALM
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_calm(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unused_arg(typ);
|
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
|
|
|
|
|
if (c->magician && c->magician->faction) {
|
|
|
|
|
faction *f = c->magician->faction;
|
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
|
|
|
|
|
|
if (f == NULL || self == 0) {
|
|
|
|
|
const struct race *rc = u_irace(c->magician);
|
|
|
|
|
return msg_message("curseinfo::calm_0", "unit race id", u, rc, c->no);
|
|
|
|
|
}
|
|
|
|
|
return msg_message("curseinfo::calm_1", "unit faction id", u, f, c->no);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2014-12-12 23:00:30 +01:00
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_calmmonster = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"calmmonster",
|
|
|
|
|
CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
|
|
|
|
|
cinfo_calm
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_SPEED
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_speed(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unused_arg(typ);
|
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
|
return msg_message("curseinfo::speed_1", "unit number duration id", u,
|
|
|
|
|
c->data.i, c->duration, c->no);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
static struct curse_type ct_speed = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"speed",
|
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN,
|
|
|
|
|
cinfo_speed
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_ORC
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unused_arg(typ);
|
|
|
|
|
assert(typ == TYP_UNIT);
|
2015-07-08 05:12:26 +02:00
|
|
|
|
assert(obj);
|
2014-12-12 23:00:30 +01:00
|
|
|
|
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
|
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u,
|
|
|
|
|
c->no);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_orcish = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"orcish",
|
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_ISNEW, M_MEN,
|
|
|
|
|
cinfo_unit
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_KAELTESCHUTZ
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_kaelteschutz(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unused_arg(typ);
|
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
|
return msg_message("curseinfo::warmth_1", "unit number id", u,
|
|
|
|
|
get_cursedmen(u, c), c->no);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
static struct curse_type ct_insectfur = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"insectfur",
|
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION),
|
|
|
|
|
cinfo_kaelteschutz
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_SPARKLE
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_sparkle(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
const char *effects[] = {
|
|
|
|
|
NULL, /* end grau */
|
|
|
|
|
"sparkle_1",
|
|
|
|
|
"sparkle_2",
|
|
|
|
|
NULL, /* end traum */
|
|
|
|
|
"sparkle_3",
|
|
|
|
|
"sparkle_4",
|
|
|
|
|
NULL, /* end tybied */
|
|
|
|
|
"sparkle_5",
|
|
|
|
|
"sparkle_6",
|
|
|
|
|
"sparkle_7",
|
|
|
|
|
"sparkle_8",
|
|
|
|
|
NULL, /* end cerrdor */
|
|
|
|
|
"sparkle_9",
|
|
|
|
|
"sparkle_10",
|
|
|
|
|
"sparkle_11",
|
|
|
|
|
"sparkle_12",
|
|
|
|
|
NULL, /* end gwyrrd */
|
|
|
|
|
"sparkle_13",
|
|
|
|
|
"sparkle_14",
|
|
|
|
|
"sparkle_15",
|
|
|
|
|
"sparkle_16",
|
|
|
|
|
"sparkle_17",
|
|
|
|
|
"sparkle_18",
|
|
|
|
|
NULL, /* end draig */
|
|
|
|
|
};
|
|
|
|
|
int m, begin = 0, end = 0;
|
|
|
|
|
unit *u;
|
|
|
|
|
unused_arg(typ);
|
|
|
|
|
|
|
|
|
|
assert(typ == TYP_UNIT);
|
|
|
|
|
u = (unit *)obj;
|
|
|
|
|
|
|
|
|
|
if (!c->magician || !c->magician->faction)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
for (m = 0; m != c->magician->faction->magiegebiet; ++m) {
|
|
|
|
|
while (effects[end] != NULL)
|
|
|
|
|
++end;
|
|
|
|
|
begin = end + 1;
|
|
|
|
|
end = begin;
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (effects[end] != NULL)
|
2014-12-12 23:00:30 +01:00
|
|
|
|
++end;
|
|
|
|
|
if (end == begin)
|
|
|
|
|
return NULL;
|
|
|
|
|
else {
|
|
|
|
|
int index = begin + curse_geteffect_int(c) % (end - begin);
|
|
|
|
|
return msg_message(mkname("curseinfo", effects[index]), "unit id", u,
|
|
|
|
|
c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_sparkle = { "sparkle",
|
2014-12-12 23:00:30 +01:00
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION), cinfo_sparkle
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_STRENGTH
|
|
|
|
|
*/
|
|
|
|
|
static struct curse_type ct_strength = { "strength",
|
2014-12-12 23:00:30 +01:00
|
|
|
|
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_ALLSKILLS (Alp)
|
|
|
|
|
*/
|
|
|
|
|
static struct curse_type ct_worse = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_NOAGE, M_MEN, cinfo_unit
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* C_ITEMCLOAK
|
|
|
|
|
*/
|
|
|
|
|
static struct curse_type ct_itemcloak = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"itemcloak", CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION, cinfo_unit
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_fumble = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"fumble", CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
|
2011-03-07 08:03:10 +01:00
|
|
|
|
cinfo_unit
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_oldrace = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"oldrace", CURSETYP_NORM, CURSE_SPREADALWAYS, NO_MERGE, NULL
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_SKILL
|
|
|
|
|
*/
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static int read_skill(struct storage *store, curse * c, void *target)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int skill;
|
2013-12-31 10:06:28 +01:00
|
|
|
|
READ_INT(store, &skill);
|
2014-12-12 23:00:30 +01:00
|
|
|
|
c->data.i = skill;
|
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2011-03-07 08:03:10 +01:00
|
|
|
|
write_skill(struct storage *store, const curse * c, const void *target)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
WRITE_INT(store, c->data.i);
|
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c,
|
2014-12-12 23:00:30 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
unused_arg(typ);
|
|
|
|
|
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
unit *u = (unit *)obj;
|
|
|
|
|
int sk = c->data.i;
|
|
|
|
|
if (c->effect > 0) {
|
|
|
|
|
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
|
|
|
|
|
}
|
|
|
|
|
else if (c->effect < 0) {
|
|
|
|
|
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2014-12-12 23:00:30 +01:00
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct curse_type ct_skillmod = {
|
2014-12-12 23:00:30 +01:00
|
|
|
|
"skillmod", CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN, cinfo_skillmod,
|
|
|
|
|
NULL, read_skill, write_skill
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
void register_unitcurse(void)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2014-12-12 23:00:30 +01:00
|
|
|
|
ct_register(&ct_auraboost);
|
|
|
|
|
ct_register(&ct_magicboost);
|
|
|
|
|
ct_register(&ct_slavery);
|
|
|
|
|
ct_register(&ct_calmmonster);
|
|
|
|
|
ct_register(&ct_speed);
|
|
|
|
|
ct_register(&ct_orcish);
|
|
|
|
|
ct_register(&ct_insectfur);
|
|
|
|
|
ct_register(&ct_sparkle);
|
|
|
|
|
ct_register(&ct_strength);
|
|
|
|
|
ct_register(&ct_worse);
|
|
|
|
|
ct_register(&ct_skillmod);
|
|
|
|
|
ct_register(&ct_itemcloak);
|
|
|
|
|
ct_register(&ct_fumble);
|
|
|
|
|
ct_register(&ct_oldrace);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|