server/src/spells/regioncurse.c

304 lines
6.9 KiB
C
Raw Normal View History

2010-08-08 09:40:42 +02:00
/* 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.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 "regioncurse.h"
/* kernel includes */
#include <kernel/curse.h>
#include <kernel/magic.h>
#include <kernel/message.h>
#include <kernel/objtypes.h>
#include <kernel/region.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
/* util includes */
#include <util/nrmessage.h>
#include <util/message.h>
#include <util/functions.h>
/* libc includes */
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/* --------------------------------------------------------------------- */
/* CurseInfo mit Spezialabfragen
*/
/*
* godcursezone
*/
2011-03-07 08:03:10 +01:00
static message *cinfo_cursed_by_the_gods(const void *obj, typ_t typ,
const curse * c, int self)
2010-08-08 09:40:42 +02:00
{
2011-03-07 08:03:10 +01:00
region *r = (region *) obj;
2010-08-08 09:40:42 +02:00
unused(typ);
unused(self);
assert(typ == TYP_REGION);
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
if (fval(r->terrain, SEA_REGION)) {
return msg_message("curseinfo::godcurseocean", "id", c->no);
}
return msg_message("curseinfo::godcurse", "id", c->no);
}
static struct curse_type ct_godcursezone = {
"godcursezone",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, CURSE_IMMUNE | CURSE_ISNEW, (NO_MERGE),
cinfo_cursed_by_the_gods,
2010-08-08 09:40:42 +02:00
};
/* --------------------------------------------------------------------- */
/*
* C_GBDREAM
*/
2011-03-07 08:03:10 +01:00
static message *cinfo_dreamcurse(const void *obj, typ_t typ, const curse * c,
int self)
2010-08-08 09:40:42 +02:00
{
unused(self);
unused(typ);
unused(obj);
assert(typ == TYP_REGION);
if (curse_geteffect(c) > 0) {
return msg_message("curseinfo::gooddream", "id", c->no);
}
return msg_message("curseinfo::baddream", "id", c->no);
}
2011-03-07 08:03:10 +01:00
static struct curse_type ct_gbdream = {
2010-08-08 09:40:42 +02:00
"gbdream",
CURSETYP_NORM, CURSE_ISNEW, (NO_MERGE), cinfo_dreamcurse
};
/* --------------------------------------------------------------------- */
/*
* C_MAGICSTREET
* erzeugt Stra<EFBFBD>ennetz
*/
2011-03-07 08:03:10 +01:00
static message *cinfo_magicstreet(const void *obj, typ_t typ, const curse * c,
int self)
2010-08-08 09:40:42 +02:00
{
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_REGION);
/* Warnung vor Aufl<66>sung */
if (c->duration <= 2) {
return msg_message("curseinfo::magicstreet", "id", c->no);
}
return msg_message("curseinfo::magicstreetwarn", "id", c->no);
}
static struct curse_type ct_magicstreet = {
"magicstreet",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_magicstreet
};
/* --------------------------------------------------------------------- */
2011-03-07 08:03:10 +01:00
static message *cinfo_antimagiczone(const void *obj, typ_t typ, const curse * c,
int self)
2010-08-08 09:40:42 +02:00
{
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_REGION);
/* Magier sp<73>ren eine Antimagiezone */
if (self != 0) {
return msg_message("curseinfo::antimagiczone", "id", c->no);
}
return NULL;
}
/* alle Magier k<>nnen eine Antimagiezone wahrnehmen */
static int
2011-03-07 08:03:10 +01:00
cansee_antimagiczone(const struct faction *viewer, const void *obj, typ_t typ,
const curse * c, int self)
2010-08-08 09:40:42 +02:00
{
region *r;
unit *u = NULL;
unit *mage = c->magician;
unused(typ);
assert(typ == TYP_REGION);
2011-03-07 08:03:10 +01:00
r = (region *) obj;
2010-08-08 09:40:42 +02:00
for (u = r->units; u; u = u->next) {
2011-03-07 08:03:10 +01:00
if (u->faction == viewer) {
if (u == mage) {
2010-08-08 09:40:42 +02:00
self = 2;
break;
}
if (is_mage(u)) {
self = 1;
}
2011-03-07 08:03:10 +01:00
}
2010-08-08 09:40:42 +02:00
}
return self;
}
2011-03-07 08:03:10 +01:00
static struct curse_type ct_antimagiczone = {
2010-08-08 09:40:42 +02:00
"antimagiczone",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_antimagiczone, NULL, NULL, NULL, cansee_antimagiczone
};
/* --------------------------------------------------------------------- */
2011-03-07 08:03:10 +01:00
static message *cinfo_farvision(const void *obj, typ_t typ, const curse * c,
int self)
2010-08-08 09:40:42 +02:00
{
unused(typ);
unused(obj);
assert(typ == TYP_REGION);
/* Magier sp<73>ren eine farvision */
if (self != 0) {
return msg_message("curseinfo::farvision", "id", c->no);
}
return 0;
}
2011-03-07 08:03:10 +01:00
static struct curse_type ct_farvision = {
2010-08-08 09:40:42 +02:00
"farvision",
CURSETYP_NORM, 0, (NO_MERGE),
cinfo_farvision
};
/* --------------------------------------------------------------------- */
static struct curse_type ct_fogtrap = {
"fogtrap",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
static struct curse_type ct_maelstrom = {
"maelstrom",
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
cinfo_simple
};
static struct curse_type ct_blessedharvest = {
"blessedharvest",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
2010-08-08 09:40:42 +02:00
cinfo_simple
};
static struct curse_type ct_drought = {
"drought",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
2010-08-08 09:40:42 +02:00
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
static struct curse_type ct_badlearn = {
"badlearn",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
2010-08-08 09:40:42 +02:00
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
/* Tr<54>bsal-Zauber */
static struct curse_type ct_depression = {
"depression",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
2010-08-08 09:40:42 +02:00
cinfo_simple
};
/* Astralblock, auf Astralregion */
static struct curse_type ct_astralblock = {
"astralblock",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
/* Unterhaltungsanteil vermehren */
static struct curse_type ct_generous = {
"generous",
2011-03-07 08:03:10 +01:00
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR | M_MAXEFFECT),
2010-08-08 09:40:42 +02:00
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
/* verhindert Attackiere regional */
static struct curse_type ct_peacezone = {
"peacezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
/* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x
* pro Einheit */
static struct curse_type ct_badmagicresistancezone = {
"badmagicresistancezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
/* erh<72>ht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro
* Einheit */
static struct curse_type ct_goodmagicresistancezone = {
"goodmagicresistancezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
static struct curse_type ct_riotzone = {
"riotzone",
CURSETYP_NORM, 0, (M_DURATION),
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
static struct curse_type ct_holyground = {
"holyground",
CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD),
cinfo_simple
};
2011-03-07 08:03:10 +01:00
2010-08-08 09:40:42 +02:00
static struct curse_type ct_healing = {
"healingzone",
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
cinfo_simple
};
2011-03-07 08:03:10 +01:00
void register_regioncurse(void)
2010-08-08 09:40:42 +02:00
{
ct_register(&ct_fogtrap);
ct_register(&ct_antimagiczone);
ct_register(&ct_farvision);
ct_register(&ct_gbdream);
ct_register(&ct_maelstrom);
ct_register(&ct_blessedharvest);
ct_register(&ct_drought);
ct_register(&ct_badlearn);
ct_register(&ct_depression);
ct_register(&ct_astralblock);
ct_register(&ct_generous);
ct_register(&ct_peacezone);
ct_register(&ct_magicstreet);
ct_register(&ct_badmagicresistancezone);
ct_register(&ct_goodmagicresistancezone);
ct_register(&ct_riotzone);
ct_register(&ct_godcursezone);
ct_register(&ct_holyground);
ct_register(&ct_healing);
}