forked from github/server
Add a new attribute and RF_OBSERVER flag.
This commit is contained in:
parent
4353773c3b
commit
15702daf99
|
@ -1404,7 +1404,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
}
|
||||
cr_output_curses_compat(F, f, r, TYP_REGION);
|
||||
cr_borders(r, f, r->seen.mode, F);
|
||||
if (r->seen.mode == seen_unit && is_astral(r)
|
||||
if (r->seen.mode >= seen_unit && is_astral(r)
|
||||
&& !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region_list *rl = astralregions(r, inhabitable);
|
||||
|
@ -1427,7 +1427,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
}
|
||||
|
||||
cr_output_travelthru(F, r, f);
|
||||
if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
message_list *mlist = r_getmessages(r, f);
|
||||
cr_output_messages(F, r->msgs, f);
|
||||
if (mlist) {
|
||||
|
|
|
@ -34,7 +34,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#define RF_MALLORN (1<<1) /* persistent */
|
||||
#define RF_BLOCKED (1<<2) /* persistent */
|
||||
|
||||
#define RF_UNUSED_3 (1<<3)
|
||||
#define RF_OBSERVER (1<<3) /* persistent */
|
||||
#define RF_UNUSED_4 (1<<4)
|
||||
#define RF_UNUSED_5 (1<<5)
|
||||
#define RF_UNUSED_6 (1<<6)
|
||||
|
|
|
@ -79,8 +79,8 @@ typedef enum {
|
|||
seen_neighbour,
|
||||
seen_lighthouse,
|
||||
seen_travel,
|
||||
seen_far,
|
||||
seen_unit,
|
||||
seen_spell,
|
||||
seen_battle
|
||||
} seen_mode;
|
||||
|
||||
|
|
25
src/report.c
25
src/report.c
|
@ -992,7 +992,7 @@ static void describe(stream *out, const region * r, faction * f)
|
|||
}
|
||||
|
||||
/* iron & stone */
|
||||
if (r->seen.mode == seen_unit) {
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
resource_report result[MAX_RAWMATERIALS];
|
||||
int n, numresults = report_resources(r, result, MAX_RAWMATERIALS, f, true);
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ static void describe(stream *out, const region * r, faction * f)
|
|||
*bufp = 0;
|
||||
paragraph(out, buf, 0, 0, 0);
|
||||
|
||||
if (r->seen.mode == seen_unit && is_astral(r) &&
|
||||
if (r->seen.mode >= seen_unit && is_astral(r) &&
|
||||
!is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region_list *rl = astralregions(r, inhabitable);
|
||||
|
@ -2285,7 +2285,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
continue;
|
||||
/* Beschreibung */
|
||||
|
||||
if (r->seen.mode == seen_unit) {
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
anyunits = 1;
|
||||
describe(out, r, f);
|
||||
if (markets_module() && r->land) {
|
||||
|
@ -2317,27 +2317,18 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
write_travelthru(out, r, f);
|
||||
}
|
||||
else {
|
||||
if (r->seen.mode == seen_far) {
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
guards(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
}
|
||||
else {
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
}
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
}
|
||||
/* Statistik */
|
||||
|
||||
if (wants_stats && r->seen.mode == seen_unit)
|
||||
if (wants_stats && r->seen.mode >= seen_unit)
|
||||
statistics(out, r, f);
|
||||
|
||||
/* Nachrichten an REGION in der Region */
|
||||
|
||||
if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
// TODO: Bug 2073
|
||||
message_list *mlist = r_getmessages(r, f);
|
||||
if (mlist) {
|
||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <kernel/config.h>
|
||||
#include "reports.h"
|
||||
#include "laws.h"
|
||||
#include "spells.h"
|
||||
#include "travelthru.h"
|
||||
#include "lighthouse.h"
|
||||
#include "donations.h"
|
||||
|
@ -92,6 +93,7 @@ const char *visibility[] = {
|
|||
"travel",
|
||||
"far",
|
||||
"unit",
|
||||
"spell",
|
||||
"battle"
|
||||
};
|
||||
|
||||
|
@ -943,9 +945,9 @@ const struct unit *ucansee(const struct faction *f, const struct unit *u,
|
|||
int stealth_modifier(seen_mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case seen_spell:
|
||||
case seen_unit:
|
||||
return 0;
|
||||
case seen_far:
|
||||
case seen_lighthouse:
|
||||
return -2;
|
||||
case seen_travel:
|
||||
|
@ -1336,6 +1338,12 @@ void prepare_report(report_context *ctx, faction *f)
|
|||
for (r = ctx->first; r!=ctx->last; r = r->next) {
|
||||
unit *u;
|
||||
|
||||
if (fval(r, RF_OBSERVER)) {
|
||||
int skill = get_observer(r, f);
|
||||
if (skill >= 0) {
|
||||
add_seen_nb(f, r, seen_spell);
|
||||
}
|
||||
}
|
||||
if (fval(r, RF_LIGHTHOUSE)) {
|
||||
/* region owners get the report from lighthouses */
|
||||
if (rule_region_owners && bt_lighthouse) {
|
||||
|
|
|
@ -437,7 +437,7 @@ static void test_report_far_vision(CuTest *tc) {
|
|||
u1 = test_create_unit(f, r1);
|
||||
r2 = test_create_region(10, 0, 0);
|
||||
rc = test_create_race("spell");
|
||||
watch_region(r2, f, 10);
|
||||
set_observer(r2, f, 10);
|
||||
CuAssertPtrEquals(tc, r1, f->first);
|
||||
CuAssertPtrEquals(tc, r2, f->last);
|
||||
report_context ctx;
|
||||
|
@ -445,7 +445,7 @@ static void test_report_far_vision(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, 0, ctx.last);
|
||||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_unit, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_spell, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
}
|
||||
|
|
280
src/spells.c
280
src/spells.c
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2015
|
||||
|
@ -32,7 +32,7 @@
|
|||
#include <spells/combatspells.h>
|
||||
#include <spells/flyingship.h>
|
||||
|
||||
/* kernel includes */
|
||||
/* kernel includes */
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/connection.h>
|
||||
#include <kernel/building.h>
|
||||
|
@ -440,40 +440,40 @@ report_effect(region * r, unit * mage, message * seen, message * unseen)
|
|||
*
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: Vertrauter
|
||||
* Stufe: 10
|
||||
*
|
||||
* Wirkung:
|
||||
* Der Magier beschwoert einen Vertrauten, ein kleines Tier, welches
|
||||
* dem Magier zu Diensten ist. Der Magier kann durch die Augen des
|
||||
* Vertrauten sehen, und durch den Vertrauten zaubern, allerdings nur
|
||||
* mit seiner halben Stufe. Je nach Vertrautem erhaelt der Magier
|
||||
* evtl diverse Skillmodifikationen. Der Typ des Vertrauten ist
|
||||
* zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflußt.
|
||||
* "Tierische" Vertraute brauchen keinen Unterhalt.
|
||||
*
|
||||
* Ein paar Moeglichkeiten:
|
||||
* Magieg. Rasse Besonderheiten
|
||||
* Eule Tybied -/- fliegt, Auraregeneration
|
||||
* Rabe Ilaun -/- fliegt
|
||||
* Imp Draig -/- Magieresistenz?
|
||||
* Fuchs Gwyrrd -/- Wahrnehmung
|
||||
* ???? Cerddor -/- ???? (Singvogel?, Papagei?)
|
||||
* Adler -/- -/- fliegt, +Wahrnehmung, =^=Adlerauge-Spruch?
|
||||
* Kraehe -/- -/- fliegt, +Tarnung (weil unauffaellig)
|
||||
* Delphin -/- Meerm. schwimmt
|
||||
* Wolf -/- Ork
|
||||
* Hund -/- Mensch kann evtl BEWACHE ausfuehren
|
||||
* Ratte -/- Goblin
|
||||
* Albatros -/- -/- fliegt, kann auf Ozean "landen"
|
||||
* Affe -/- -/- kann evtl BEKLAUE ausfuehren
|
||||
* Goblin -/- !Goblin normale Einheit
|
||||
* Katze -/- !Katze normale Einheit
|
||||
* Daemon -/- !Daemon normale Einheit
|
||||
*
|
||||
* Spezielle V. fuer Katzen, Trolle, Elfen, Daemonen, Insekten, Zwerge?
|
||||
*/
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: Vertrauter
|
||||
* Stufe: 10
|
||||
*
|
||||
* Wirkung:
|
||||
* Der Magier beschwoert einen Vertrauten, ein kleines Tier, welches
|
||||
* dem Magier zu Diensten ist. Der Magier kann durch die Augen des
|
||||
* Vertrauten sehen, und durch den Vertrauten zaubern, allerdings nur
|
||||
* mit seiner halben Stufe. Je nach Vertrautem erhaelt der Magier
|
||||
* evtl diverse Skillmodifikationen. Der Typ des Vertrauten ist
|
||||
* zufaellig bestimmt, wird aber durch Magiegebiet und Rasse beeinflußt.
|
||||
* "Tierische" Vertraute brauchen keinen Unterhalt.
|
||||
*
|
||||
* Ein paar Moeglichkeiten:
|
||||
* Magieg. Rasse Besonderheiten
|
||||
* Eule Tybied -/- fliegt, Auraregeneration
|
||||
* Rabe Ilaun -/- fliegt
|
||||
* Imp Draig -/- Magieresistenz?
|
||||
* Fuchs Gwyrrd -/- Wahrnehmung
|
||||
* ???? Cerddor -/- ???? (Singvogel?, Papagei?)
|
||||
* Adler -/- -/- fliegt, +Wahrnehmung, =^=Adlerauge-Spruch?
|
||||
* Kraehe -/- -/- fliegt, +Tarnung (weil unauffaellig)
|
||||
* Delphin -/- Meerm. schwimmt
|
||||
* Wolf -/- Ork
|
||||
* Hund -/- Mensch kann evtl BEWACHE ausfuehren
|
||||
* Ratte -/- Goblin
|
||||
* Albatros -/- -/- fliegt, kann auf Ozean "landen"
|
||||
* Affe -/- -/- kann evtl BEKLAUE ausfuehren
|
||||
* Goblin -/- !Goblin normale Einheit
|
||||
* Katze -/- !Katze normale Einheit
|
||||
* Daemon -/- !Daemon normale Einheit
|
||||
*
|
||||
* Spezielle V. fuer Katzen, Trolle, Elfen, Daemonen, Insekten, Zwerge?
|
||||
*/
|
||||
|
||||
static const race *select_familiar(const race * magerace, magic_t magiegebiet)
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ static int sp_summon_familiar(castorder * co)
|
|||
if (dh == 0) {
|
||||
bytes =
|
||||
strlcpy(bufp, (const char *)LOC(mage->faction->locale,
|
||||
"list_and"), size);
|
||||
"list_and"), size);
|
||||
}
|
||||
else {
|
||||
bytes = strlcpy(bufp, (const char *)", ", size);
|
||||
|
@ -615,7 +615,7 @@ static int sp_summon_familiar(castorder * co)
|
|||
}
|
||||
bytes =
|
||||
strlcpy(bufp, (const char *)skillname((skill_t)sk, mage->faction->locale),
|
||||
size);
|
||||
size);
|
||||
assert(bytes <= INT_MAX);
|
||||
if (wrptr(&bufp, &size, (int)bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1246,7 +1246,7 @@ static void fumble_ents(const castorder * co)
|
|||
* Flag:
|
||||
* (FARCASTING | SPELLLEVEL | UNITSPELL | TESTCANSEE | TESTRESISTANCE)
|
||||
*/
|
||||
/* Syntax: ZAUBER [REGION x y] [STUFE 2] "Rosthauch" 1111 2222 3333 */
|
||||
/* Syntax: ZAUBER [REGION x y] [STUFE 2] "Rosthauch" 1111 2222 3333 */
|
||||
|
||||
typedef struct iron_weapon {
|
||||
const struct item_type *type;
|
||||
|
@ -1259,7 +1259,7 @@ static iron_weapon *ironweapons = NULL;
|
|||
|
||||
void
|
||||
add_ironweapon(const struct item_type *type, const struct item_type *rusty,
|
||||
float chance)
|
||||
float chance)
|
||||
{
|
||||
iron_weapon *iweapon = malloc(sizeof(iron_weapon));
|
||||
assert_alloc(iweapon);
|
||||
|
@ -1366,7 +1366,7 @@ static int sp_rosthauch(castorder * co)
|
|||
* Flag:
|
||||
* (UNITSPELL | SPELLLEVEL | ONSHIPCAST | TESTCANSEE)
|
||||
*/
|
||||
/* Syntax: ZAUBER [STUFE n] "Kaelteschutz" eh1 [eh2 [eh3 [...]]] */
|
||||
/* Syntax: ZAUBER [STUFE n] "Kaelteschutz" eh1 [eh2 [eh3 [...]]] */
|
||||
|
||||
static int sp_kaelteschutz(castorder * co)
|
||||
{
|
||||
|
@ -1410,7 +1410,7 @@ static int sp_kaelteschutz(castorder * co)
|
|||
u));
|
||||
if (u->faction != mage->faction)
|
||||
ADDMSG(&u->faction->msgs, msg_message("heat_effect", "mage target",
|
||||
cansee(u->faction, r, mage, 0) ? mage : NULL, u));
|
||||
cansee(u->faction, r, mage, 0) ? mage : NULL, u));
|
||||
i = cast_level;
|
||||
}
|
||||
/* Erstattung? */
|
||||
|
@ -1430,7 +1430,7 @@ static int sp_kaelteschutz(castorder * co)
|
|||
* Flag:
|
||||
* (UNITSPELL | TESTCANSEE | SPELLLEVEL)
|
||||
*/
|
||||
/* Syntax: ZAUBER "Funkenregen" eh1 */
|
||||
/* Syntax: ZAUBER "Funkenregen" eh1 */
|
||||
|
||||
static int sp_sparkle(castorder * co)
|
||||
{
|
||||
|
@ -1503,11 +1503,11 @@ static int sp_create_irongolem(castorder * co)
|
|||
int number = lovar(force * 8 * RESOURCE_QUANTITY);
|
||||
static int cache;
|
||||
static const race * golem_rc;
|
||||
|
||||
|
||||
if (rc_changed(&cache)) {
|
||||
golem_rc = rc_find("irongolem");
|
||||
}
|
||||
|
||||
|
||||
if (number < 1) {
|
||||
number = 1;
|
||||
}
|
||||
|
@ -1529,8 +1529,8 @@ static int sp_create_irongolem(castorder * co)
|
|||
|
||||
ADDMSG(&mage->faction->msgs,
|
||||
msg_message("magiccreate_effect", "region command unit amount object",
|
||||
mage->region, co->order, mage, number,
|
||||
LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL))));
|
||||
mage->region, co->order, mage, number,
|
||||
LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL))));
|
||||
|
||||
return cast_level;
|
||||
}
|
||||
|
@ -1572,7 +1572,7 @@ static int sp_create_stonegolem(castorder * co)
|
|||
int number = lovar(co->force * 5 * RESOURCE_QUANTITY);
|
||||
static int cache;
|
||||
static const race * golem_rc;
|
||||
|
||||
|
||||
if (rc_changed(&cache)) {
|
||||
golem_rc = rc_find("stonegolem");
|
||||
}
|
||||
|
@ -1596,8 +1596,8 @@ static int sp_create_stonegolem(castorder * co)
|
|||
|
||||
ADDMSG(&mage->faction->msgs,
|
||||
msg_message("magiccreate_effect", "region command unit amount object",
|
||||
mage->region, co->order, mage, number,
|
||||
LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL))));
|
||||
mage->region, co->order, mage, number,
|
||||
LOC(mage->faction->locale, rc_name_s(golem_rc, (u2->number == 1) ? NAME_SINGULAR : NAME_PLURAL))));
|
||||
|
||||
return cast_level;
|
||||
}
|
||||
|
@ -2203,17 +2203,17 @@ static int sp_ironkeeper(castorder * co)
|
|||
fset(keeper, UFL_ANON_FACTION);
|
||||
}
|
||||
|
||||
{
|
||||
trigger *tkill = trigger_killunit(keeper);
|
||||
add_trigger(&keeper->attribs, "timer", trigger_timeout(cast_level + 2,
|
||||
tkill));
|
||||
}
|
||||
{
|
||||
trigger *tkill = trigger_killunit(keeper);
|
||||
add_trigger(&keeper->attribs, "timer", trigger_timeout(cast_level + 2,
|
||||
tkill));
|
||||
}
|
||||
|
||||
msg = msg_message("summon_effect", "mage amount race", mage, 1, u_race(keeper));
|
||||
r_addmessage(r, NULL, msg);
|
||||
msg_release(msg);
|
||||
msg = msg_message("summon_effect", "mage amount race", mage, 1, u_race(keeper));
|
||||
r_addmessage(r, NULL, msg);
|
||||
msg_release(msg);
|
||||
|
||||
return cast_level;
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -2384,7 +2384,7 @@ void patzer_peasantmob(const castorder * co)
|
|||
|
||||
u =
|
||||
create_unit(r, f, n, get_race(RC_PEASANT), 0, LOC(f->locale, "angry_mob"),
|
||||
NULL);
|
||||
NULL);
|
||||
fset(u, UFL_ISNEW);
|
||||
/* guard(u, GUARD_ALL); hier zu frueh! Befehl BEWACHE setzten */
|
||||
addlist(&u->orders, create_order(K_GUARD, lang, NULL));
|
||||
|
@ -2457,7 +2457,7 @@ static int sp_forest_fire(castorder * co)
|
|||
freset(u->faction, FFL_SELECT);
|
||||
msg =
|
||||
msg_message("forestfire_effect", "mage region amount", mage, r,
|
||||
destroyed + vernichtet_schoesslinge);
|
||||
destroyed + vernichtet_schoesslinge);
|
||||
r_addmessage(r, NULL, msg);
|
||||
add_message(&mage->faction->msgs, msg);
|
||||
msg_release(msg);
|
||||
|
@ -2627,10 +2627,10 @@ static int sp_summondragon(castorder * co)
|
|||
number = 6;
|
||||
break;
|
||||
}
|
||||
{
|
||||
trigger *tsummon = trigger_createunit(r, f, race, number);
|
||||
add_trigger(&r->attribs, "timer", trigger_timeout(time, tsummon));
|
||||
}
|
||||
{
|
||||
trigger *tsummon = trigger_createunit(r, f, race, number);
|
||||
add_trigger(&r->attribs, "timer", trigger_timeout(time, tsummon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2705,15 +2705,15 @@ static int sp_firewall(castorder * co)
|
|||
}
|
||||
|
||||
/* melden, 1x pro Partei */
|
||||
{
|
||||
message *seen = msg_message("firewall_effect", "mage region", mage, r);
|
||||
message *unseen = msg_message("firewall_effect", "mage region", NULL, r);
|
||||
report_effect(r, mage, seen, unseen);
|
||||
msg_release(seen);
|
||||
msg_release(unseen);
|
||||
}
|
||||
{
|
||||
message *seen = msg_message("firewall_effect", "mage region", mage, r);
|
||||
message *unseen = msg_message("firewall_effect", "mage region", NULL, r);
|
||||
report_effect(r, mage, seen, unseen);
|
||||
msg_release(seen);
|
||||
msg_release(unseen);
|
||||
}
|
||||
|
||||
return cast_level;
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -2861,7 +2861,7 @@ static int dc_age(struct curse *c)
|
|||
damage *= (1.0 - magic_resistance(u));
|
||||
hp = change_hitpoints(u, -(int)damage);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message((hp>0)?"poison_damage":"poison_death", "region unit", r, u));
|
||||
ADDMSG(&u->faction->msgs, msg_message((hp > 0) ? "poison_damage" : "poison_death", "region unit", r, u));
|
||||
if (*up == u)
|
||||
up = &u->next;
|
||||
}
|
||||
|
@ -2916,7 +2916,7 @@ static int dc_read_compat(struct attrib *a, void *target, gamedata *data)
|
|||
effect = strength;
|
||||
c =
|
||||
create_curse(u, &r->attribs, &ct_deathcloud, strength * 2, duration,
|
||||
effect, 0);
|
||||
effect, 0);
|
||||
c->data.v = r;
|
||||
if (u == NULL) {
|
||||
ur_add(var, &c->magician, resolve_unit);
|
||||
|
@ -3123,7 +3123,7 @@ static bool chaosgate_valid(const connection * b)
|
|||
}
|
||||
|
||||
static struct region *chaosgate_move(const connection * b, struct unit *u,
|
||||
struct region *from, struct region *to, bool routing)
|
||||
struct region *from, struct region *to, bool routing)
|
||||
{
|
||||
if (!routing) {
|
||||
int maxhp = u->hp / 4;
|
||||
|
@ -3317,7 +3317,7 @@ static int sp_bloodsacrifice(castorder * co)
|
|||
change_spellpoints(mage, aura);
|
||||
ADDMSG(&mage->faction->msgs,
|
||||
msg_message("sp_bloodsacrifice_effect",
|
||||
"unit region command amount", mage, mage->region, co->order, aura));
|
||||
"unit region command amount", mage, mage->region, co->order, aura));
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
|
@ -3811,7 +3811,7 @@ static int sp_raisepeasantmob(castorder * co)
|
|||
|
||||
u =
|
||||
create_unit(r, monsters, n, get_race(RC_PEASANT), 0, LOC(monsters->locale,
|
||||
"furious_mob"), NULL);
|
||||
"furious_mob"), NULL);
|
||||
fset(u, UFL_ISNEW);
|
||||
guard(u, GUARD_ALL);
|
||||
a = a_new(&at_unitdissolve);
|
||||
|
@ -4111,13 +4111,92 @@ static int sp_bigrecruit(castorder * co)
|
|||
return cast_level;
|
||||
}
|
||||
|
||||
void watch_region(region *r, faction *f, int perception)
|
||||
{
|
||||
unit *u;
|
||||
typedef struct obs_data {
|
||||
faction *f;
|
||||
int skill;
|
||||
int timer;
|
||||
} obs_data;
|
||||
|
||||
u = create_unit(r, f, 1, get_race(RC_SPELL), 0, NULL, NULL);
|
||||
u->age = 2;
|
||||
set_level(u, SK_PERCEPTION, perception);
|
||||
static void obs_init(struct attrib *a)
|
||||
{
|
||||
a->data.v = malloc(sizeof(obs_data));
|
||||
}
|
||||
|
||||
static void obs_done(struct attrib *a)
|
||||
{
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
static int obs_age(struct attrib *a, void *owner)
|
||||
{
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
update_interval(od->f, (region *)owner);
|
||||
return --od->timer;
|
||||
}
|
||||
|
||||
static void obs_write(const struct attrib *a, const void *owner, struct storage *store)
|
||||
{
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
write_faction_reference(od->f, store);
|
||||
WRITE_INT(store, od->skill);
|
||||
WRITE_INT(store, od->timer);
|
||||
}
|
||||
|
||||
static int obs_read(struct attrib *a, void *owner, struct gamedata *data)
|
||||
{
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
|
||||
read_reference(&od->f, data, read_faction_reference, resolve_faction);
|
||||
READ_INT(data->store, &od->skill);
|
||||
READ_INT(data->store, &od->timer);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
attrib_type at_observer = { "observer", obs_init, obs_done, obs_age, obs_write, obs_read };
|
||||
|
||||
static attrib *make_observer(faction *f, int perception)
|
||||
{
|
||||
attrib * a = a_new(&at_observer);
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
od->f = f;
|
||||
od->skill = perception;
|
||||
od->timer = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
int get_observer(region *r, faction *f) {
|
||||
if (fval(r, RF_OBSERVER)) {
|
||||
attrib *a = a_find(r->attribs, &at_observer);
|
||||
while (a && a->type == &at_observer) {
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
if (od->f == f) {
|
||||
return od->skill;
|
||||
}
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void set_observer(region *r, faction *f, int skill)
|
||||
{
|
||||
update_interval(f, r);
|
||||
if (fval(r, RF_OBSERVER)) {
|
||||
attrib *a = a_find(r->attribs, &at_observer);
|
||||
while (a && a->type == &at_observer) {
|
||||
obs_data *od = (obs_data *)a->data.v;
|
||||
if (od->f == f && od->skill < skill) {
|
||||
od->skill = skill;
|
||||
od->timer = 2;
|
||||
return;
|
||||
}
|
||||
a = a->nexttype;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fset(r, RF_OBSERVER);
|
||||
}
|
||||
a_add(&r->attribs, make_observer(f, skill));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -4133,7 +4212,7 @@ void watch_region(region *r, faction *f, int perception)
|
|||
* (UNITSPELL | TESTCANSEE)
|
||||
*/
|
||||
|
||||
/* restistenz der einheit pruefen */
|
||||
/* restistenz der einheit pruefen */
|
||||
static int sp_pump(castorder * co)
|
||||
{
|
||||
unit *u, *target;
|
||||
|
@ -4176,7 +4255,7 @@ static int sp_pump(castorder * co)
|
|||
return cast_level / 2;
|
||||
}
|
||||
|
||||
watch_region(rt, mage->faction, effskill(target, SK_PERCEPTION, 0));
|
||||
set_observer(rt, mage->faction, effskill(target, SK_PERCEPTION, 0));
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
|
@ -4400,7 +4479,7 @@ static int sp_raisepeasants(castorder * co)
|
|||
|
||||
u2 =
|
||||
create_unit(r, mage->faction, bauern, get_race(RC_PEASANT), 0,
|
||||
LOC(mage->faction->locale, "furious_mob"), mage);
|
||||
LOC(mage->faction->locale, "furious_mob"), mage);
|
||||
|
||||
fset(u2, UFL_LOCKED);
|
||||
if (rule_stealth_anon()) {
|
||||
|
@ -4414,7 +4493,7 @@ static int sp_raisepeasants(castorder * co)
|
|||
|
||||
msg =
|
||||
msg_message("sp_raisepeasants_effect", "mage region amount", mage, r,
|
||||
u2->number);
|
||||
u2->number);
|
||||
r_addmessage(r, NULL, msg);
|
||||
if (mage->region != r) {
|
||||
add_message(&mage->faction->msgs, msg);
|
||||
|
@ -4527,7 +4606,7 @@ int sp_icastle(castorder * co)
|
|||
if (type == bt_illusion) {
|
||||
b->size = (rng_int() % (int)((power * power) + 1) * 10);
|
||||
}
|
||||
else if (type->maxsize >0) {
|
||||
else if (type->maxsize > 0) {
|
||||
b->size = type->maxsize;
|
||||
}
|
||||
else {
|
||||
|
@ -4766,7 +4845,7 @@ int sp_clonecopy(castorder * co)
|
|||
"clone_of"), unitname(mage));
|
||||
clone =
|
||||
create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name,
|
||||
mage);
|
||||
mage);
|
||||
setstatus(clone, ST_FLEE);
|
||||
fset(clone, UFL_LOCKED);
|
||||
|
||||
|
@ -4815,11 +4894,11 @@ int sp_dreamreading(castorder * co)
|
|||
return 0;
|
||||
}
|
||||
|
||||
watch_region(u->region, mage->faction, effskill(u, SK_PERCEPTION, u->region));
|
||||
set_observer(u->region, mage->faction, effskill(u, SK_PERCEPTION, u->region));
|
||||
|
||||
msg =
|
||||
msg_message("sp_dreamreading_effect", "mage unit region", mage, u,
|
||||
u->region);
|
||||
u->region);
|
||||
r_addmessage(r, mage->faction, msg);
|
||||
msg_release(msg);
|
||||
return cast_level;
|
||||
|
@ -5622,7 +5701,8 @@ int sp_showastral(castorder * co)
|
|||
/* sprintf(buf, "%s kann niemanden im astralen Nebel entdecken.",
|
||||
unitname(mage)); */
|
||||
cmistake(mage, co->order, 220, MSG_MAGIC);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
/* Ausgeben */
|
||||
|
||||
|
@ -5642,13 +5722,14 @@ int sp_showastral(castorder * co)
|
|||
}
|
||||
icat(u->number);
|
||||
scat(" ");
|
||||
scat(LOC(mage->faction->locale, rc_name_s(u_race(u), (u->number==1) ? NAME_SINGULAR:NAME_PLURAL)));
|
||||
scat(LOC(mage->faction->locale, rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)));
|
||||
scat(", Entfernung ");
|
||||
icat(distance(rl2->data, rt));
|
||||
scat(")");
|
||||
if (c == n - 1) {
|
||||
scat(" und ");
|
||||
} else if (c < n - 1) {
|
||||
}
|
||||
else if (c < n - 1) {
|
||||
scat(", ");
|
||||
}
|
||||
}
|
||||
|
@ -5688,7 +5769,7 @@ int sp_viewreality(castorder * co)
|
|||
for (rl2 = rl; rl2; rl2 = rl2->next) {
|
||||
region *rt = rl2->data;
|
||||
if (!is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
|
||||
watch_region(rt, mage->faction, co->level / 2);
|
||||
set_observer(rt, mage->faction, co->level / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6262,8 +6343,8 @@ int sp_speed2(castorder * co)
|
|||
* Flags:
|
||||
* (FARCASTING | SPELLLEVEL | ONSHIPCAST | TESTCANSEE)
|
||||
*/
|
||||
/* Jeder gebrochene Zauber verbraucht c->vigour an Zauberkraft
|
||||
* (force) */
|
||||
/* Jeder gebrochene Zauber verbraucht c->vigour an Zauberkraft
|
||||
* (force) */
|
||||
int sp_q_antimagie(castorder * co)
|
||||
{
|
||||
attrib **ap;
|
||||
|
@ -6411,7 +6492,7 @@ int sp_break_curse(castorder * co)
|
|||
/* Es wurde kein Ziel gefunden */
|
||||
ADDMSG(&mage->faction->msgs,
|
||||
msg_message("spelltargetnotfound", "unit region command",
|
||||
mage, mage->region, co->order));
|
||||
mage, mage->region, co->order));
|
||||
}
|
||||
|
||||
/* curse aufloesen, wenn zauber staerker (force > vigour) */
|
||||
|
@ -6718,6 +6799,7 @@ void register_spells(void)
|
|||
register_borders();
|
||||
|
||||
at_register(&at_wdwpyramid);
|
||||
at_register(&at_observer);
|
||||
at_register(&at_deathcloud_compat);
|
||||
|
||||
/* init_firewall(); */
|
||||
|
|
|
@ -31,7 +31,8 @@ extern "C" {
|
|||
|
||||
void register_spells(void);
|
||||
|
||||
void watch_region(struct region *r, struct faction *f, int perception);
|
||||
void set_observer(struct region *r, struct faction *f, int perception);
|
||||
int get_observer(struct region *r, struct faction *f);
|
||||
|
||||
int sp_baddreams(castorder * co);
|
||||
int sp_gooddreams(castorder * co);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <kernel/curse.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/unit.h>
|
||||
|
@ -106,9 +107,28 @@ static void test_bad_dreams(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_watch_region(CuTest *tc) {
|
||||
region *r;
|
||||
faction *f;
|
||||
test_setup();
|
||||
test_create_race("spell");
|
||||
CuAssertPtrNotNull(tc, get_race(RC_SPELL));
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
||||
set_observer(r, f, 0);
|
||||
CuAssertIntEquals(tc, 0, get_observer(r, f));
|
||||
set_observer(r, f, 10);
|
||||
CuAssertIntEquals(tc, 10, get_observer(r, f));
|
||||
CuAssertIntEquals(tc, RF_OBSERVER, fval(r, RF_OBSERVER));
|
||||
CuAssertPtrNotNull(tc, r->attribs);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_spells_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_watch_region);
|
||||
SUITE_ADD_TEST(suite, test_good_dreams);
|
||||
SUITE_ADD_TEST(suite, test_bad_dreams);
|
||||
SUITE_ADD_TEST(suite, test_dreams);
|
||||
|
|
Loading…
Reference in New Issue