Merge pull request #461 from ennorehling/feature/bug-2173-easy-braineaters

easy braineaters
This commit is contained in:
Enno Rehling 2016-01-28 22:55:33 +01:00
commit fda20b2fb4
14 changed files with 53 additions and 33 deletions

View file

@ -88,6 +88,7 @@ set (ERESSEA_SRC
names.c
lighthouse.c
reports.c
teleport.c
guard.c
prefix.c
donations.c

View file

@ -45,7 +45,6 @@ without prior permission by the authors of Eressea.
#include <kernel/item.h>
#include <kernel/order.h>
#include <kernel/ship.h>
#include <kernel/teleport.h>
#include <kernel/faction.h>
#include <kernel/save.h>
#include <kernel/spell.h>
@ -54,6 +53,7 @@ without prior permission by the authors of Eressea.
#include "creport.h"
#include "economy.h"
#include "summary.h"
#include "teleport.h"
#include "laws.h"
#include "monster.h"
#include "market.h"

View file

@ -36,6 +36,7 @@ without prior permission by the authors of Eressea.
#include "move.h"
#include "reports.h"
#include "alchemy.h"
#include "teleport.h"
/* kernel includes */
#include <kernel/alliance.h>
@ -55,7 +56,6 @@ without prior permission by the authors of Eressea.
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/save.h>

View file

@ -19,6 +19,7 @@
#include "listbox.h"
#include "wormhole.h"
#include "calendar.h"
#include "teleport.h"
#include <modules/xmas.h>
#include <modules/gmcmd.h>
@ -36,7 +37,6 @@
#include <kernel/plane.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/teleport.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>
#include <kernel/resources.h>

View file

@ -50,7 +50,6 @@ ship.c
skills.c
spellbook.c
spell.c
teleport.c
terrain.c
unit.c
xmlreader.c

View file

@ -36,6 +36,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "study.h"
#include "wormhole.h"
#include "prefix.h"
#include "teleport.h"
#include "calendar.h"
#include "guard.h"
@ -59,7 +60,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h> /* for volcanoes in emigration (needs a flag) */
#include <kernel/unit.h>

View file

@ -41,7 +41,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/version.h>
@ -1127,8 +1126,13 @@ double magic_resistance(unit * target)
curse *c;
const curse_type * ct_goodresist = 0, *ct_badresist = 0;
const resource_type *rtype;
double probability = u_race(target)->magres;
const race *rc = u_race(target);
double probability = rc->magres;
const plane *pl = rplane(target->region);
if (rc == get_race(RC_HIRNTOETER) && !pl) {
probability /= 2;
}
assert(target->number > 0);
/* Magier haben einen Resistenzbonus vom Magietalent * 5% */
probability += effskill(target, SK_MAGIC, 0) * 0.05;
@ -1989,7 +1993,7 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
case 'r':
/* Parameter sind zwei Regionskoordinaten */
/* this silly thing only works in the normal plane! */
j = addparam_region(param + i, &spobj, u, ord, get_normalplane());
j = addparam_region(param + i, &spobj, u, ord, NULL);
++c;
break;
case 'b':

View file

@ -1,7 +1,9 @@
#include <platform.h>
#include "magic.h"
#include "teleport.h"
#include <kernel/race.h>
#include <kernel/faction.h>
#include <kernel/order.h>
#include <kernel/item.h>
@ -402,6 +404,25 @@ void test_multi_cast(CuTest *tc) {
test_cleanup();
}
static void test_magic_resistance(CuTest *tc) {
unit *u;
race *rc;
test_cleanup();
rc = test_create_race("human");
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
CuAssertDblEquals(tc, rc->magres, magic_resistance(u), 0.01);
rc->magres = 1.0;
CuAssertDblEquals_Msg(tc, "magic resistance is capped at 0.9", 0.9, magic_resistance(u), 0.01);
rc = test_create_race("braineater");
rc->magres = 1.0;
u_setrace(u, rc);
CuAssertDblEquals_Msg(tc, "brain eaters outside astral space have 50% magres", 0.5, magic_resistance(u), 0.01);
u->region->_plane = get_astralplane();
CuAssertDblEquals_Msg(tc, "brain eaters in astral space have full magres", 0.9, magic_resistance(u), 0.01);
test_cleanup();
}
CuSuite *get_magic_suite(void)
{
CuSuite *suite = CuSuiteNew();
@ -417,5 +438,6 @@ CuSuite *get_magic_suite(void)
SUITE_ADD_TEST(suite, test_set_main_combatspell);
SUITE_ADD_TEST(suite, test_set_post_combatspell);
SUITE_ADD_TEST(suite, test_hasspell);
SUITE_ADD_TEST(suite, test_magic_resistance);
return suite;
}

View file

@ -44,13 +44,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/render.h>
#include <kernel/save.h>
#include <kernel/ship.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>
#include <spells/flyingship.h>
#include "teleport.h"
#include "direction.h"
#include "calendar.h"
#include "skill.h"

View file

@ -42,6 +42,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "upkeep.h"
#include "vortex.h"
#include "calendar.h"
#include "teleport.h"
/* kernel includes */
#include <kernel/ally.h>
@ -65,7 +66,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>

View file

@ -43,7 +43,7 @@ extern "C" {
struct seen_region *next;
struct region *r;
seen_t mode;
bool disbelieves;
bool disbelieves; /* potion of truth */
} seen_region;
struct seen_region **seen_init(void);

View file

@ -22,6 +22,7 @@
#include "direction.h"
#include "randenc.h"
#include "monster.h"
#include "teleport.h"
#include <spells/borders.h>
#include <spells/buildingcurse.h>
@ -49,7 +50,6 @@
#include <kernel/save.h>
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>
@ -3146,7 +3146,7 @@ static int sp_chaossuction(castorder * co)
unit *mage = co->magician.u;
int cast_level = co->level;
if (getplane(r) != get_normalplane()) {
if (rplane(r)) {
/* Der Zauber funktioniert nur in der materiellen Welt. */
cmistake(mage, co->order, 190, MSG_MAGIC);
return 0;
@ -5436,8 +5436,9 @@ int sp_fetchastral(castorder * co)
region *rt = co_get_region(co); /* region to which we are fetching */
region *ro = NULL; /* region in which the target is */
if (rplane(rt) != get_normalplane()) {
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "error190", ""));
if (rplane(rt)) {
/* Der Zauber funktioniert nur in der materiellen Welt. */
cmistake(mage, co->order, 190, MSG_MAGIC);
return 0;
}

View file

@ -21,19 +21,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "teleport.h"
/* kernel includes */
#include "equipment.h"
#include "unit.h"
#include "region.h"
#include "race.h"
#include "skill.h"
#include "terrain.h"
#include "faction.h"
#include "plane.h"
#include <kernel/equipment.h>
#include <kernel/unit.h>
#include <kernel/region.h>
#include <kernel/race.h>
#include <kernel/terrain.h>
#include <kernel/faction.h>
#include <kernel/plane.h>
/* util includes */
#include <util/log.h>
#include <util/rng.h>
#include "skill.h"
#include "monster.h"
/* libc includes */
@ -96,8 +96,7 @@ region_list *astralregions(const region * r, bool(*valid) (const region *))
region *r_standard_to_astral(const region * r)
{
if (rplane(r) != get_normalplane())
return NULL;
assert(!rplane(r));
return tpregion(r);
}
@ -109,9 +108,9 @@ region *r_astral_to_standard(const region * r)
assert(is_astral(r));
x = (r->x - TE_CENTER_X) * TP_DISTANCE;
y = (r->y - TE_CENTER_Y) * TP_DISTANCE;
pnormalize(&x, &y, get_normalplane());
pnormalize(&x, &y, NULL);
r2 = findregion(x, y);
if (r2 == NULL || rplane(r2) != get_normalplane())
if (r2 == NULL || rplane(r2))
return NULL;
return r2;
@ -168,11 +167,6 @@ void spawn_braineaters(float chance)
}
}
plane *get_normalplane(void)
{
return NULL;
}
bool is_astral(const region * r)
{
plane *pl = get_astralplane();

View file

@ -31,7 +31,6 @@ extern "C" {
extern bool inhabitable(const struct region *r);
extern bool is_astral(const struct region *r);
extern struct plane *get_astralplane(void);
extern struct plane *get_normalplane(void);
void create_teleport_plane(void);
void set_teleport_plane_regiontypes(void);