forked from github/server
bug 2684: update sp_showastral and sp_viewreality.
add more messages add unit tests closes https://bugs.eressea.de/view.php?id=2684
This commit is contained in:
parent
cf1c06ad29
commit
9e3dc18daa
10 changed files with 178 additions and 70 deletions
|
@ -247,14 +247,14 @@
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
<message name="curseinfo::skill_2" section="events">
|
<message name="curseinfo_skill_2" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
<arg name="skill" type="skill"/>
|
<arg name="skill" type="skill"/>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
<message name="curseinfo::skill_1" section="events">
|
<message name="curseinfo_skill_1" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
<arg name="skill" type="skill"/>
|
<arg name="skill" type="skill"/>
|
||||||
|
@ -1124,6 +1124,12 @@
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message name="showastral_effect" section="magic">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
<message name="recruit_effect" section="magic">
|
<message name="recruit_effect" section="magic">
|
||||||
<type>
|
<type>
|
||||||
<arg name="mage" type="unit"/>
|
<arg name="mage" type="unit"/>
|
||||||
|
@ -5798,13 +5804,6 @@
|
||||||
<arg name="command" type="order"/>
|
<arg name="command" type="order"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
<message name="spellfail::noway" section="magic">
|
|
||||||
<type>
|
|
||||||
<arg name="unit" type="unit"/>
|
|
||||||
<arg name="region" type="region"/>
|
|
||||||
<arg name="command" type="order"/>
|
|
||||||
</type>
|
|
||||||
</message>
|
|
||||||
<message name="spellfail::nocontact" section="magic">
|
<message name="spellfail::nocontact" section="magic">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
|
|
@ -656,7 +656,7 @@ msgstr "\"$unit($unit) ertrinkt in $region($region).\""
|
||||||
msgid "travel"
|
msgid "travel"
|
||||||
msgstr "\"$unit($unit) $if($eq($mode,1),\"reitet\", \"wandert\") von $region($start) nach $region($end).$if($isnull($regions),\"\",\" Dabei wurde $trail($regions) durchquert.\")\""
|
msgstr "\"$unit($unit) $if($eq($mode,1),\"reitet\", \"wandert\") von $region($start) nach $region($end).$if($isnull($regions),\"\",\" Dabei wurde $trail($regions) durchquert.\")\""
|
||||||
|
|
||||||
msgid "curseinfo::skill_1"
|
msgid "curseinfo_skill_1"
|
||||||
msgstr "\"$unit($unit) ist ungewöhnlich geschickt in $skill($skill). ($int36($id))\""
|
msgstr "\"$unit($unit) ist ungewöhnlich geschickt in $skill($skill). ($int36($id))\""
|
||||||
|
|
||||||
msgid "error11"
|
msgid "error11"
|
||||||
|
@ -1487,12 +1487,9 @@ msgstr "\"Ein magischer Schimmer liegt auf diesen Mauern. ($int36($id))\""
|
||||||
msgid "changebanner"
|
msgid "changebanner"
|
||||||
msgstr "\"Das Banner wurde auf '$value' geändert.\""
|
msgstr "\"Das Banner wurde auf '$value' geändert.\""
|
||||||
|
|
||||||
msgid "curseinfo::skill_2"
|
msgid "curseinfo_skill_2"
|
||||||
msgstr "\"$unit($unit) ist ungewöhnlich ungeschickt in $skill($skill). ($int36($id))\""
|
msgstr "\"$unit($unit) ist ungewöhnlich ungeschickt in $skill($skill). ($int36($id))\""
|
||||||
|
|
||||||
msgid "spellfail::noway"
|
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Dorthin führt kein Weg.\""
|
|
||||||
|
|
||||||
msgid "spellbuildingresists"
|
msgid "spellbuildingresists"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Gebäude $int36($id) konnte nicht verzaubert werden.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Gebäude $int36($id) konnte nicht verzaubert werden.\""
|
||||||
|
|
||||||
|
@ -2522,6 +2519,9 @@ msgstr "\"$unit($mage) meint, dass auf $region($region) ein Zauber liegt, konnte
|
||||||
msgid "viewreality_effect"
|
msgid "viewreality_effect"
|
||||||
msgstr "\"$unit($unit) gelingt es, durch die Nebel auf die Realität zu blicken.\""
|
msgstr "\"$unit($unit) gelingt es, durch die Nebel auf die Realität zu blicken.\""
|
||||||
|
|
||||||
|
msgid "showastral_effect"
|
||||||
|
msgstr "\"$unit($unit) gelingt es, in die Nebel des Astralraums zu blicken.\""
|
||||||
|
|
||||||
msgid "use_speedsail"
|
msgid "use_speedsail"
|
||||||
msgstr "\"$unit($unit) setzt ein Sonnensegel. Die Geschwindigkeit des Schiffes erhöht um $int($speed).\""
|
msgstr "\"$unit($unit) setzt ein Sonnensegel. Die Geschwindigkeit des Schiffes erhöht um $int($speed).\""
|
||||||
|
|
||||||
|
|
|
@ -656,7 +656,7 @@ msgstr "\"$unit($unit) drowns in $region($region).\""
|
||||||
msgid "travel"
|
msgid "travel"
|
||||||
msgstr "\"$unit($unit) $if($eq($mode,1),\"rides\", \"walks\") from $region($start) to $region($end)$if($isnull($regions),\"\",\" by way of $trail($regions)\").\""
|
msgstr "\"$unit($unit) $if($eq($mode,1),\"rides\", \"walks\") from $region($start) to $region($end)$if($isnull($regions),\"\",\" by way of $trail($regions)\").\""
|
||||||
|
|
||||||
msgid "curseinfo::skill_1"
|
msgid "curseinfo_skill_1"
|
||||||
msgstr "\"$unit($unit) is incredibly skilled at $skill($skill). ($int36($id))\""
|
msgstr "\"$unit($unit) is incredibly skilled at $skill($skill). ($int36($id))\""
|
||||||
|
|
||||||
msgid "error11"
|
msgid "error11"
|
||||||
|
@ -1487,12 +1487,9 @@ msgstr "\"A magical shimmer lies on these walls. ($int36($id))\""
|
||||||
msgid "changebanner"
|
msgid "changebanner"
|
||||||
msgstr "\"Banner has been changed to '$value'.\""
|
msgstr "\"Banner has been changed to '$value'.\""
|
||||||
|
|
||||||
msgid "curseinfo::skill_2"
|
msgid "curseinfo_skill_2"
|
||||||
msgstr "\"$unit($unit) has some troubles with $skill($skill). ($int36($id))\""
|
msgstr "\"$unit($unit) has some troubles with $skill($skill). ($int36($id))\""
|
||||||
|
|
||||||
msgid "spellfail::noway"
|
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - There is no route leading there.\""
|
|
||||||
|
|
||||||
msgid "spellbuildingresists"
|
msgid "spellbuildingresists"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Building $int36($id) could not be charmed.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Building $int36($id) could not be charmed.\""
|
||||||
|
|
||||||
|
@ -2519,6 +2516,9 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - The magician de
|
||||||
msgid "analyse_region_fail"
|
msgid "analyse_region_fail"
|
||||||
msgstr "\"It appears to $unit($mage) that $region($region) is charmed, but no details have been revealed.\""
|
msgstr "\"It appears to $unit($mage) that $region($region) is charmed, but no details have been revealed.\""
|
||||||
|
|
||||||
|
msgid "showastral_effect"
|
||||||
|
msgstr "\"$unit($unit) has a vision of the astral plane.\""
|
||||||
|
|
||||||
msgid "viewreality_effect"
|
msgid "viewreality_effect"
|
||||||
msgstr "\"$unit($unit) manages to catch a glimpse of reality through the fog.\""
|
msgstr "\"$unit($unit) manages to catch a glimpse of reality through the fog.\""
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ void set_observer(region *r, faction *f, int skill, int turns)
|
||||||
attrib *a = a_find(r->attribs, &at_observer);
|
attrib *a = a_find(r->attribs, &at_observer);
|
||||||
while (a && a->type == &at_observer) {
|
while (a && a->type == &at_observer) {
|
||||||
obs_data *od = (obs_data *)a->data.v;
|
obs_data *od = (obs_data *)a->data.v;
|
||||||
if (od->f == f && od->skill < skill) {
|
if (od->f == f) {
|
||||||
od->skill = skill;
|
od->skill = skill;
|
||||||
od->timer = turns;
|
od->timer = turns;
|
||||||
return;
|
return;
|
||||||
|
|
68
src/spells.c
68
src/spells.c
|
@ -5203,22 +5203,21 @@ int sp_leaveastral(castorder * co)
|
||||||
case 1:
|
case 1:
|
||||||
rt = pa->param[0]->data.r;
|
rt = pa->param[0]->data.r;
|
||||||
if (!rt || r_standard_to_astral(rt) != r || !inhabitable(rt)) {
|
if (!rt || r_standard_to_astral(rt) != r || !inhabitable(rt)) {
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
cmistake(mage, co->order, 216, MSG_MAGIC);
|
||||||
"spellfail::noway", ""));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ro = r;
|
ro = r;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
"spell_astral_only", ""));
|
"spell_astral_only", NULL));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ro == NULL || is_cursed(ro->attribs, &ct_astralblock)
|
if (ro == NULL || is_cursed(ro->attribs, &ct_astralblock)
|
||||||
|| is_cursed(rt->attribs, &ct_astralblock)) {
|
|| is_cursed(rt->attribs, &ct_astralblock)) {
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
"spellfail_astralblock", ""));
|
"spellfail_astralblock", NULL));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5423,13 +5422,10 @@ int sp_fetchastral(castorder * co)
|
||||||
return cast_level;
|
return cast_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cb_not_astral_blocked(const struct region *rt) {
|
static bool cb_show_astral(const struct region *r) {
|
||||||
return !is_cursed(rt->attribs, &ct_astralblock);
|
return r->units && !is_cursed(r->attribs, &ct_astralblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef SHOWASTRAL_IS_BORKED
|
|
||||||
#ifndef SHOWASTRAL_IS_BORKED
|
|
||||||
#define SHOWASTRAL_MAX_RADIUS 5
|
|
||||||
int sp_showastral(castorder * co)
|
int sp_showastral(castorder * co)
|
||||||
{
|
{
|
||||||
region *rt;
|
region *rt;
|
||||||
|
@ -5440,29 +5436,24 @@ int sp_showastral(castorder * co)
|
||||||
int radius = (force < SHOWASTRAL_MAX_RADIUS) ? force : SHOWASTRAL_MAX_RADIUS;
|
int radius = (force < SHOWASTRAL_MAX_RADIUS) ? force : SHOWASTRAL_MAX_RADIUS;
|
||||||
region *targets[4 * SHOWASTRAL_MAX_RADIUS * SHOWASTRAL_MAX_RADIUS];
|
region *targets[4 * SHOWASTRAL_MAX_RADIUS * SHOWASTRAL_MAX_RADIUS];
|
||||||
|
|
||||||
switch (getplaneid(r)) {
|
if (getplaneid(r) == 1) {
|
||||||
case 0:
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
rt = r_standard_to_astral(r);
|
"spell_astral_forbidden", NULL));
|
||||||
if (!rt || fval(rt->terrain, FORBIDDEN_REGION)) {
|
return 0;
|
||||||
/* Hier gibt es keine Verbindung zur astralen Welt */
|
}
|
||||||
cmistake(mage, co->order, 216, MSG_MAGIC);
|
rt = r_standard_to_astral(r);
|
||||||
return 0;
|
if (rt == NULL || fval(rt->terrain, FORBIDDEN_REGION) || is_cursed(r->attribs, &ct_astralblock)) {
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
rt = r;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Hier gibt es keine Verbindung zur astralen Welt */
|
/* Hier gibt es keine Verbindung zur astralen Welt */
|
||||||
cmistake(mage, co->order, 216, MSG_MAGIC);
|
cmistake(mage, co->order, 216, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = regions_in_range(rt, radius, cb_not_astral_blocked, targets);
|
n = regions_in_range(rt, radius, cb_show_astral, targets);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
/* sprintf(buf, "%s kann niemanden im astralen Nebel entdecken.",
|
/* sprintf(buf, "%s kann niemanden im astralen Nebel entdecken.",
|
||||||
unitname(mage)); */
|
unitname(mage)); */
|
||||||
cmistake(mage, co->order, 220, MSG_MAGIC);
|
cmistake(mage, co->order, 220, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
@ -5470,43 +5461,52 @@ int sp_showastral(castorder * co)
|
||||||
region *rt = targets[i];
|
region *rt = targets[i];
|
||||||
set_observer(rt, mage->faction, (int)(co->force / 2), 2);
|
set_observer(rt, mage->faction, (int)(co->force / 2), 2);
|
||||||
}
|
}
|
||||||
|
ADDMSG(&mage->faction->msgs, msg_message("showastral_effect", "unit", mage));
|
||||||
}
|
}
|
||||||
|
|
||||||
return co->level;
|
return co->level;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static bool cb_view_reality(const struct region *r) {
|
||||||
|
return !is_cursed(r->attribs, &ct_astralblock);
|
||||||
|
}
|
||||||
|
|
||||||
int sp_viewreality(castorder * co)
|
int sp_viewreality(castorder * co)
|
||||||
{
|
{
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *mage = co_get_caster(co);
|
unit *mage = co_get_caster(co);
|
||||||
int force = (int)co->force;
|
int force = (int)co->force;
|
||||||
message *m;
|
|
||||||
region *rl[MAX_SCHEMES];
|
region *rl[MAX_SCHEMES];
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (getplaneid(r) != 1) {
|
if (getplaneid(r) != 1) {
|
||||||
/* sprintf(buf, "Dieser Zauber kann nur im Astralraum gezaubert werden."); */
|
/* sprintf(buf, "Dieser Zauber kann nur im Astralraum gezaubert werden."); */
|
||||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||||
"spell_astral_only", ""));
|
"spell_astral_only", NULL));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
num = get_astralregions(r, NULL, rl);
|
if (is_cursed(r->attribs, &ct_astralblock)) {
|
||||||
|
cmistake(mage, co->order, 216, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
num = get_astralregions(r, cb_view_reality, rl);
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i != num; ++i) {
|
for (i = 0; i != num; ++i) {
|
||||||
region *rt = rl[i];
|
region *rt = rl[i];
|
||||||
if (!is_cursed(rt->attribs, &ct_astralblock)) {
|
set_observer(rt, mage->faction, force / 2, 2);
|
||||||
set_observer(rt, mage->faction, force / 2, 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
cmistake(mage, co->order, 216, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
m = msg_message("viewreality_effect", "unit", mage);
|
ADDMSG(&mage->faction->msgs, msg_message("viewreality_effect", "unit", mage));
|
||||||
r_addmessage(r, mage->faction, m);
|
|
||||||
msg_release(m);
|
|
||||||
|
|
||||||
return co->level;
|
return co->level;
|
||||||
}
|
}
|
||||||
|
@ -6421,9 +6421,7 @@ static spelldata spell_functions[] = {
|
||||||
{ "analyze_magic", sp_analysemagic, 0 },
|
{ "analyze_magic", sp_analysemagic, 0 },
|
||||||
{ "concealing_aura", sp_itemcloak, 0 },
|
{ "concealing_aura", sp_itemcloak, 0 },
|
||||||
{ "tybiedfumbleshield", sp_fumbleshield, 0 },
|
{ "tybiedfumbleshield", sp_fumbleshield, 0 },
|
||||||
#ifndef SHOWASTRAL_IS_BORKED
|
|
||||||
{ "show_astral", sp_showastral, 0 },
|
{ "show_astral", sp_showastral, 0 },
|
||||||
#endif
|
|
||||||
{ "resist_magic", sp_resist_magic_bonus, 0 },
|
{ "resist_magic", sp_resist_magic_bonus, 0 },
|
||||||
{ "keeploot", sp_keeploot, 0 },
|
{ "keeploot", sp_keeploot, 0 },
|
||||||
{ "enterastral", sp_enterastral, 0 },
|
{ "enterastral", sp_enterastral, 0 },
|
||||||
|
|
|
@ -16,10 +16,11 @@ extern "C" {
|
||||||
void register_magicresistance(void);
|
void register_magicresistance(void);
|
||||||
void register_spells(void);
|
void register_spells(void);
|
||||||
|
|
||||||
|
#define SHOWASTRAL_MAX_RADIUS 5
|
||||||
int sp_baddreams(struct castorder * co);
|
int sp_baddreams(struct castorder * co);
|
||||||
int sp_gooddreams(struct castorder * co);
|
int sp_gooddreams(struct castorder * co);
|
||||||
int sp_viewreality(struct castorder * co);
|
int sp_viewreality(struct castorder * co);
|
||||||
|
int sp_showastral(struct castorder * co);
|
||||||
#define ACTION_RESET 0x01 /* reset the one-time-flag FFL_SELECT (on first pass) */
|
#define ACTION_RESET 0x01 /* reset the one-time-flag FFL_SELECT (on first pass) */
|
||||||
#define ACTION_CANSEE 0x02 /* to people who can see the actor */
|
#define ACTION_CANSEE 0x02 /* to people who can see the actor */
|
||||||
#define ACTION_CANNOTSEE 0x04 /* to people who can not see the actor */
|
#define ACTION_CANNOTSEE 0x04 /* to people who can not see the actor */
|
||||||
|
|
|
@ -120,38 +120,147 @@ static void test_view_reality(CuTest *tc) {
|
||||||
faction *f;
|
faction *f;
|
||||||
unit *u;
|
unit *u;
|
||||||
castorder co;
|
castorder co;
|
||||||
|
curse *c;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
|
mt_create_error(216);
|
||||||
|
mt_create_error(220);
|
||||||
mt_create_va(mt_new("spell_astral_only", NULL),
|
mt_create_va(mt_new("spell_astral_only", NULL),
|
||||||
"unit:unit", "region:region", "command:order", MT_NEW_END);
|
"unit:unit", "region:region", "command:order", MT_NEW_END);
|
||||||
mt_create_va(mt_new("viewreality_effect", NULL),
|
mt_create_va(mt_new("viewreality_effect", NULL),
|
||||||
"unit:unit", MT_NEW_END);
|
"unit:unit", MT_NEW_END);
|
||||||
r = test_create_region(0, 0, NULL);
|
rx = test_create_region(0, TP_RADIUS + 1, NULL);
|
||||||
rx = test_create_region(0, TP_RADIUS+1, NULL);
|
|
||||||
ra = test_create_region(real2tp(r->x), real2tp(r->y), NULL);
|
|
||||||
ra->_plane = get_astralplane();
|
|
||||||
f = test_create_faction(NULL);
|
f = test_create_faction(NULL);
|
||||||
u = test_create_unit(f, r);
|
u = test_create_unit(f, rx);
|
||||||
|
|
||||||
|
/* can only cast in astral space */
|
||||||
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
||||||
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
|
||||||
CuAssertIntEquals(tc, 0, sp_viewreality(&co));
|
CuAssertIntEquals(tc, 0, sp_viewreality(&co));
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "spell_astral_only"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "spell_astral_only"));
|
||||||
free_castorder(&co);
|
free_castorder(&co);
|
||||||
|
|
||||||
test_clear_messagelist(&f->msgs);
|
test_clear_messagelist(&f->msgs);
|
||||||
|
ra = test_create_region(real2tp(0), real2tp(0), NULL);
|
||||||
|
ra->_plane = get_astralplane();
|
||||||
move_unit(u, ra, NULL);
|
move_unit(u, ra, NULL);
|
||||||
|
|
||||||
|
/* there is no connection from ra to rx */
|
||||||
|
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_viewreality(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error216"));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(rx, f));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
test_clear_messagelist(&f->msgs);
|
||||||
|
r = test_create_region(0, 0, NULL);
|
||||||
|
|
||||||
|
test_clear_messagelist(&f->msgs);
|
||||||
|
|
||||||
|
/* units exist, r can be seen, but rx is out of range */
|
||||||
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
|
||||||
CuAssertIntEquals(tc, 9, sp_viewreality(&co));
|
CuAssertIntEquals(tc, 9, sp_viewreality(&co));
|
||||||
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "spell_astral_only"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "viewreality_effect"));
|
||||||
CuAssertIntEquals(tc, 5, get_observer(r, f));
|
CuAssertIntEquals(tc, 5, get_observer(r, f));
|
||||||
CuAssertIntEquals(tc, -1, get_observer(rx, f));
|
CuAssertIntEquals(tc, -1, get_observer(rx, f));
|
||||||
CuAssertPtrEquals(tc, f, (void *)ra->individual_messages->viewer);
|
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(ra->individual_messages->msgs, "viewreality_effect"));
|
|
||||||
free_castorder(&co);
|
free_castorder(&co);
|
||||||
|
|
||||||
|
set_observer(r, f, -1, -1);
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
||||||
|
|
||||||
|
/* target region r exists, but astral space is blocked */
|
||||||
|
c = create_curse(NULL, &ra->attribs, &ct_astralblock, 50.0, 1, 50, 0);
|
||||||
|
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_viewreality(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error216"));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
||||||
|
free_castorder(&co);
|
||||||
|
remove_curse(&ra->attribs, c);
|
||||||
|
|
||||||
|
/* target region r exists, but astral interference is blocked */
|
||||||
|
c = create_curse(NULL, &r->attribs, &ct_astralblock, 50.0, 1, 50, 0);
|
||||||
|
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_viewreality(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error216"));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_show_astral(CuTest *tc) {
|
||||||
|
region *r, *ra, *rx;
|
||||||
|
faction *f;
|
||||||
|
unit *u;
|
||||||
|
castorder co;
|
||||||
|
curse * c;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
mt_create_error(216);
|
||||||
|
mt_create_error(220);
|
||||||
|
mt_create_va(mt_new("spell_astral_forbidden", NULL),
|
||||||
|
"unit:unit", "region:region", "command:order", MT_NEW_END);
|
||||||
|
mt_create_va(mt_new("showastral_effect", NULL),
|
||||||
|
"unit:unit", MT_NEW_END);
|
||||||
|
ra = test_create_region(real2tp(0), real2tp(0) + 1 + SHOWASTRAL_MAX_RADIUS, NULL);
|
||||||
|
ra->_plane = get_astralplane();
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
u = test_create_unit(f, ra);
|
||||||
|
|
||||||
|
/* error: unit is in astral space */
|
||||||
|
test_create_castorder(&co, u, 10, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_showastral(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "spell_astral_forbidden"));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
test_clear_messagelist(&f->msgs);
|
||||||
|
r = test_create_region(0, 0, NULL);
|
||||||
|
move_unit(u, r, NULL);
|
||||||
|
|
||||||
|
/* error: no target region */
|
||||||
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_showastral(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error216"));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(ra, f));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
rx = test_create_region(real2tp(r->x), real2tp(r->y), NULL);
|
||||||
|
rx->_plane = ra->_plane;
|
||||||
|
|
||||||
|
/* rx is in range, but empty */
|
||||||
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_showastral(&co));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(rx, f));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(ra, f));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error220"));
|
||||||
|
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "showastral_effect"));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
test_create_unit(f, ra);
|
||||||
|
test_create_unit(f, rx);
|
||||||
|
/* rx is in range, but ra is not */
|
||||||
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 9, sp_showastral(&co));
|
||||||
|
CuAssertIntEquals(tc, 5, get_observer(rx, f));
|
||||||
|
CuAssertIntEquals(tc, -1, get_observer(ra, f));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "showastral_effect"));
|
||||||
|
free_castorder(&co);
|
||||||
|
|
||||||
|
/* astral block on r */
|
||||||
|
c = create_curse(NULL, &r->attribs, &ct_astralblock, 50.0, 1, 50, 0);
|
||||||
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_showastral(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error216"));
|
||||||
|
free_castorder(&co);
|
||||||
|
remove_curse(&r->attribs, c);
|
||||||
|
|
||||||
|
/* astral block on rx */
|
||||||
|
c = create_curse(NULL, &rx->attribs, &ct_astralblock, 50.0, 1, 50, 0);
|
||||||
|
test_create_castorder(&co, u, 9, 10.0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, sp_showastral(&co));
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error220"));
|
||||||
|
free_castorder(&co);
|
||||||
|
remove_curse(&rx->attribs, c);
|
||||||
|
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +285,7 @@ CuSuite *get_spells_suite(void)
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_watch_region);
|
SUITE_ADD_TEST(suite, test_watch_region);
|
||||||
SUITE_ADD_TEST(suite, test_view_reality);
|
SUITE_ADD_TEST(suite, test_view_reality);
|
||||||
|
SUITE_ADD_TEST(suite, test_show_astral);
|
||||||
SUITE_ADD_TEST(suite, test_good_dreams);
|
SUITE_ADD_TEST(suite, test_good_dreams);
|
||||||
SUITE_ADD_TEST(suite, test_bad_dreams);
|
SUITE_ADD_TEST(suite, test_bad_dreams);
|
||||||
SUITE_ADD_TEST(suite, test_dreams);
|
SUITE_ADD_TEST(suite, test_dreams);
|
||||||
|
|
|
@ -318,10 +318,10 @@ static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c,
|
||||||
unit *u = (unit *)obj;
|
unit *u = (unit *)obj;
|
||||||
int sk = c->data.i;
|
int sk = c->data.i;
|
||||||
if (c->effect > 0) {
|
if (c->effect > 0) {
|
||||||
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
|
return msg_message("curseinfo_skill_1", "unit skill id", u, sk, c->no);
|
||||||
}
|
}
|
||||||
else if (c->effect < 0) {
|
else if (c->effect < 0) {
|
||||||
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
|
return msg_message("curseinfo_skill_2", "unit skill id", u, sk, c->no);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define TE_CENTER 1000
|
#define TE_CENTER 1000
|
||||||
#define TP_DISTANCE 4
|
|
||||||
|
|
||||||
int real2tp(int rk)
|
int real2tp(int rk)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TP_RADIUS 2 /* Radius von Schemen */
|
#define TP_DISTANCE 4
|
||||||
|
#define TP_RADIUS (TP_DISTANCE/2) /* Radius von Schemen */
|
||||||
#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4)
|
#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4)
|
||||||
|
|
||||||
struct region;
|
struct region;
|
||||||
|
|
Loading…
Reference in a new issue