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 "regioncurse.h"
|
2014-11-01 12:57:01 +01:00
|
|
|
|
#include "magic.h"
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* 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/objtypes.h>
|
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/terrain.h>
|
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
|
|
|
|
|
/* util includes */
|
2017-08-06 18:52:09 +02:00
|
|
|
|
#include <util/log.h>
|
2017-12-29 06:13:28 +01:00
|
|
|
|
#include <util/macros.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <util/nrmessage.h>
|
|
|
|
|
#include <util/message.h>
|
|
|
|
|
#include <util/functions.h>
|
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* godcursezone
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
const curse * c, int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
|
region *r = (region *)obj;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(typ);
|
|
|
|
|
UNUSED_ARG(self);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
assert(typ == TYP_REGION);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2016-11-17 11:27:20 +01:00
|
|
|
|
if (r->terrain->flags & SEA_REGION) {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
return msg_message("curseinfo::godcurseocean", "id", c->no);
|
|
|
|
|
}
|
|
|
|
|
return msg_message("curseinfo::godcurse", "id", c->no);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_godcursezone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"godcursezone",
|
2017-08-18 18:42:59 +02:00
|
|
|
|
CURSETYP_NORM, CURSE_IMMUNE, (NO_MERGE),
|
2011-03-07 08:03:10 +01:00
|
|
|
|
cinfo_cursed_by_the_gods,
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_GBDREAM
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(self);
|
|
|
|
|
UNUSED_ARG(typ);
|
|
|
|
|
UNUSED_ARG(obj);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
assert(typ == TYP_REGION);
|
|
|
|
|
|
|
|
|
|
if (c->effect > 0) {
|
|
|
|
|
return msg_message("curseinfo::gooddream", "id", c->no);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return msg_message("curseinfo::baddream", "id", c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_gbdream = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"gbdream",
|
2017-08-18 18:42:59 +02:00
|
|
|
|
CURSETYP_NORM, 0, (NO_MERGE), cinfo_dreamcurse
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
/*
|
|
|
|
|
* C_MAGICSTREET
|
|
|
|
|
* erzeugt Stra<EFBFBD>ennetz
|
|
|
|
|
*/
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse * c,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(typ);
|
|
|
|
|
UNUSED_ARG(self);
|
|
|
|
|
UNUSED_ARG(obj);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
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);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_magicstreet = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"magicstreet",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_magicstreet
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_antimagiczone(const void *obj, objtype_t typ, const curse * c,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(typ);
|
|
|
|
|
UNUSED_ARG(self);
|
|
|
|
|
UNUSED_ARG(obj);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
assert(typ == TYP_REGION);
|
|
|
|
|
|
|
|
|
|
/* Magier sp<73>ren eine Antimagiezone */
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
return msg_message("curseinfo::antimagiczone", "id", c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
|
return NULL;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* alle Magier k<>nnen eine Antimagiezone wahrnehmen */
|
|
|
|
|
static int
|
2012-05-17 09:14:05 +02:00
|
|
|
|
cansee_antimagiczone(const struct faction *viewer, const void *obj, objtype_t typ,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
const curse * c, int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
|
region *r;
|
|
|
|
|
unit *u = NULL;
|
|
|
|
|
unit *mage = c->magician;
|
|
|
|
|
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(typ);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
|
|
assert(typ == TYP_REGION);
|
|
|
|
|
r = (region *)obj;
|
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
|
if (u->faction == viewer) {
|
|
|
|
|
if (u == mage) {
|
|
|
|
|
self = 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (is_mage(u)) {
|
|
|
|
|
self = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
|
return self;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_antimagiczone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"antimagiczone",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_antimagiczone, NULL, NULL, NULL, cansee_antimagiczone
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
2012-05-17 09:14:05 +02:00
|
|
|
|
static message *cinfo_farvision(const void *obj, objtype_t typ, const curse * c,
|
2015-01-30 20:37:14 +01:00
|
|
|
|
int self)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2017-01-10 16:31:05 +01:00
|
|
|
|
UNUSED_ARG(typ);
|
|
|
|
|
UNUSED_ARG(obj);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
|
assert(typ == TYP_REGION);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
|
/* Magier sp<73>ren eine farvision */
|
|
|
|
|
if (self != 0) {
|
|
|
|
|
return msg_message("curseinfo::farvision", "id", c->no);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static struct curse_type ct_farvision = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"farvision",
|
|
|
|
|
CURSETYP_NORM, 0, (NO_MERGE),
|
|
|
|
|
cinfo_farvision
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_fogtrap = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"fogtrap",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_maelstrom = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"maelstrom",
|
2017-08-18 18:42:59 +02:00
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
2015-01-30 20:37:14 +01:00
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_blessedharvest = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"blessedharvest",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-08-06 18:52:09 +02:00
|
|
|
|
int harvest_effect(const struct region *r) {
|
|
|
|
|
if (r->attribs) {
|
|
|
|
|
curse *c = get_curse(r->attribs, &ct_blessedharvest);
|
|
|
|
|
if (c) {
|
|
|
|
|
int happy = curse_geteffect_int(c);
|
|
|
|
|
if (happy != 1) {
|
|
|
|
|
/* https://bugs.eressea.de/view.php?id=2353 detect and fix bad harvest */
|
|
|
|
|
log_error("blessedharvest curse %d has effect=%d, duration=%d", c->no, happy, c->duration);
|
|
|
|
|
c->effect = 1.0;
|
|
|
|
|
}
|
|
|
|
|
return happy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_drought = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"drought",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_badlearn = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"badlearn",
|
2017-08-18 18:42:59 +02:00
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
2015-01-30 20:37:14 +01:00
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* Tr<54>bsal-Zauber */
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_depression = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"depression",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Astralblock, auf Astralregion */
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_astralblock = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"astralblock",
|
|
|
|
|
CURSETYP_NORM, 0, NO_MERGE,
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* Unterhaltungsanteil vermehren */
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_generous = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"generous",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR | M_MAXEFFECT),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* verhindert Attackiere regional */
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_peacezone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"peacezone",
|
|
|
|
|
CURSETYP_NORM, 0, NO_MERGE,
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
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 */
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_badmagicresistancezone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"badmagicresistancezone",
|
|
|
|
|
CURSETYP_NORM, 0, NO_MERGE,
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
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 */
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_goodmagicresistancezone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"goodmagicresistancezone",
|
|
|
|
|
CURSETYP_NORM, 0, NO_MERGE,
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_riotzone = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"riotzone",
|
|
|
|
|
CURSETYP_NORM, 0, (M_DURATION),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
|
const struct curse_type ct_holyground = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"holyground",
|
|
|
|
|
CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2017-08-21 19:43:35 +02:00
|
|
|
|
const struct curse_type ct_healing = {
|
2015-01-30 20:37:14 +01:00
|
|
|
|
"healingzone",
|
|
|
|
|
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
|
|
|
|
|
cinfo_simple
|
2010-08-08 09:40:42 +02:00
|
|
|
|
};
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
void register_regioncurse(void)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2015-01-30 20:37:14 +01: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);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|