- ich denke, es liegt daran dass es regionen gibt, die schemen zweier anderer regionen sind - für die ist nicht klar, welche astralregion bei zaubern wie dem tor benutzt werden.
This commit is contained in:
Enno Rehling 2004-05-24 23:09:10 +00:00
parent deaf47ded7
commit 85d0383471
7 changed files with 163 additions and 166 deletions

View File

@ -1348,7 +1348,7 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
if (sd->mode==see_unit && r->planep && r->planep->id == 1 && !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) if (sd->mode==see_unit && r->planep && r->planep->id == 1 && !is_cursed(r->attribs, C_ASTRALBLOCK, 0))
{ {
/* Sonderbehandlung Teleport-Ebene */ /* Sonderbehandlung Teleport-Ebene */
region_list *rl = allinhab_in_range(r_astral_to_standard(r),TP_RADIUS); region_list *rl = astralregions(r_astral_to_standard(r), inhabitable);
if (rl) { if (rl) {
region_list *rl2 = rl; region_list *rl2 = rl;

View File

@ -1367,7 +1367,7 @@ describe(FILE * F, const region * r, int partial, faction * f)
if (partial==0 && r->planep && r->planep->id == 1 && if (partial==0 && r->planep && r->planep->id == 1 &&
!is_cursed(r->attribs, C_ASTRALBLOCK, 0)) { !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
/* Sonderbehandlung Teleport-Ebene */ /* Sonderbehandlung Teleport-Ebene */
region_list *rl = allinhab_in_range(r_astral_to_standard(r), TP_RADIUS); region_list *rl = astralregions(r_astral_to_standard(r), inhabitable);
region_list *rl2; region_list *rl2;
if (rl) { if (rl) {

View File

@ -38,7 +38,7 @@ const int FIREWORK_RANGE=10;
static int static int
use_birthday_firework(struct unit * u, const struct item_type * itype, int amount, const char *cm) use_birthday_firework(struct unit * u, const struct item_type * itype, int amount, const char *cm)
{ {
region_list *rlist = all_in_range(u->region, FIREWORK_RANGE); region_list *rlist = all_in_range(u->region, FIREWORK_RANGE, NULL);
region_list *rl; region_list *rl;
message *m; message *m;
const char *name; const char *name;

View File

@ -41,6 +41,7 @@
#include "spell.h" #include "spell.h"
#include "ship.h" #include "ship.h"
#include "skill.h" #include "skill.h"
#include "teleport.h"
#include "unit.h" #include "unit.h"
/* util includes */ /* util includes */
@ -1065,7 +1066,7 @@ travel(unit * u, region * next, int flucht, region_list ** routep)
/* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell. /* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell.
* Nicht kumulativ mit anderen Beschleunigungen! */ * Nicht kumulativ mit anderen Beschleunigungen! */
if ( mp == 1 && getplane(next) == astral_plane && is_mage(u)) { if ( mp == 1 && getplane(next) == get_astralplane() && is_mage(u)) {
if(get_mage(u)->magietyp == M_ASTRAL if(get_mage(u)->magietyp == M_ASTRAL
|| get_mage(u)->magietyp == M_TRAUM) { || get_mage(u)->magietyp == M_TRAUM) {
mp *= 2; mp *= 2;

View File

@ -1916,7 +1916,7 @@ sp_treewalkexit(castorder *co)
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
if(getplane(r) != astral_plane) { if(getplane(r) != get_astralplane()) {
cmistake(mage, strdup(co->order), 193, MSG_MAGIC); cmistake(mage, strdup(co->order), 193, MSG_MAGIC);
return 0; return 0;
} }
@ -1939,7 +1939,7 @@ sp_treewalkexit(castorder *co)
tay = rt->y; tay = rt->y;
rt = NULL; rt = NULL;
rl = allinhab_in_range(r_astral_to_standard(r),TP_RADIUS); rl = astralregions(r_astral_to_standard(r), inhabitable);
rt = 0; rt = 0;
rl2 = rl; rl2 = rl;
@ -2232,7 +2232,7 @@ sp_fog_of_confusion(castorder *co)
range = (power-11)/3-1; range = (power-11)/3-1;
duration = (int)((power-11)/1.5)+1; duration = (int)((power-11)/1.5)+1;
rl = all_in_range(r, (int)range); rl = all_in_range(r, (int)range, NULL);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
curse * c; curse * c;
@ -2807,7 +2807,7 @@ sp_summondragon(castorder *co)
} }
} }
rl = all_in_range(r, (int)power); rl = all_in_range(r, (int)power, NULL);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
for(u = rl2->data->units; u; u = u->next) { for(u = rl2->data->units; u; u = u->next) {
@ -5598,7 +5598,7 @@ sp_dream_of_confusion(castorder *co)
double range = (power-14)/2-1; double range = (power-14)/2-1;
int duration = (int)(power-14)+1; int duration = (int)(power-14)+1;
rl = all_in_range(r, (int)range); rl = all_in_range(r, (int)range, NULL);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
region * r2 = rl2->data; region * r2 = rl2->data;
@ -5934,7 +5934,7 @@ sp_pullastral(castorder *co)
case 1: case 1:
rt = r; rt = r;
ro = pa->param[0]->data.r; ro = pa->param[0]->data.r;
rl = all_in_range(r_astral_to_standard(r), TP_RADIUS); rl = astralregions(r_astral_to_standard(r), NULL);
rl2 = rl; rl2 = rl;
while (rl2!=NULL) { while (rl2!=NULL) {
region * r2 = rl2->data; region * r2 = rl2->data;
@ -6066,7 +6066,7 @@ sp_leaveastral(castorder *co)
MSG_MAGIC, ML_MISTAKE); MSG_MAGIC, ML_MISTAKE);
return 0; return 0;
} }
rl = allinhab_in_range(r_astral_to_standard(r), TP_RADIUS); rl = astralregions(r_astral_to_standard(r), inhabitable);
rl2 = rl; rl2 = rl;
while (rl2!=NULL) { while (rl2!=NULL) {
if (rl2->data == rt) break; if (rl2->data == rt) break;
@ -6391,7 +6391,7 @@ sp_viewreality(castorder *co)
return 0; return 0;
} }
rl = all_in_range(r_astral_to_standard(r), TP_RADIUS); rl = astralregions(r_astral_to_standard(r), NULL);
/* Irgendwann mal auf Curses u/o Attribut umstellen. */ /* Irgendwann mal auf Curses u/o Attribut umstellen. */
for (rl2=rl; rl2; rl2=rl2->next) { for (rl2=rl; rl2; rl2=rl2->next) {
@ -6440,7 +6440,7 @@ sp_disruptastral(castorder *co)
return 0; return 0;
} }
rl = all_in_range(rt, (int)(power/5)); rl = all_in_range(rt, (int)(power/5), NULL);
for (rl2=rl; rl2!=NULL; rl2=rl2->next) { for (rl2=rl; rl2!=NULL; rl2=rl2->next) {
attrib *a, *a2; attrib *a, *a2;
@ -6454,7 +6454,7 @@ sp_disruptastral(castorder *co)
if (r2->units!=NULL) { if (r2->units!=NULL) {
region_list * trl2; region_list * trl2;
trl = allinhab_in_range(r_astral_to_standard(rl2->data), TP_RADIUS); trl = astralregions(r_astral_to_standard(rl2->data), inhabitable);
for (trl2 = trl; trl2; trl2 = trl2->next) ++inhab_regions; for (trl2 = trl; trl2; trl2 = trl2->next) ++inhab_regions;
} }

View File

@ -1,23 +1,23 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2003 * Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de) * Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de) * Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
* *
* based on: * based on:
* *
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace * Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
* Atlantis v1.7 Copyright 1996 by Alex Schröder * Atlantis v1.7 Copyright 1996 by Alex Schröder
* *
* This program may not be used, modified or distributed without * This program may not be used, modified or distributed without
* prior permission by the authors of Eressea. * prior permission by the authors of Eressea.
* This program may not be sold or used commercially without prior written * This program may not be sold or used commercially without prior written
* permission from the authors. * permission from the authors.
*/ */
#include <config.h> #include <config.h>
#include "eressea.h" #include "eressea.h"
@ -35,170 +35,172 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#define TE_CENTER_X 1000
#define TE_CENTER_Y 1000
#define TP_RADIUS 4
static int static int
real2tp(int rk) { real2tp(int rk) {
/* in C: /* in C:
* -4 / 5 = 0; * -4 / 5 = 0;
* +4 / 5 = 0; * +4 / 5 = 0;
* !!!!!!!!!!; * !!!!!!!!!!;
*/ */
return (rk + (TP_RADIUS*5000)) / TP_RADIUS - 5000; return (rk + (TP_RADIUS*5000)) / TP_RADIUS - 5000;
} }
static region * static region *
tpregion(const region *r) { tpregion(const region *r) {
return findregion(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y)); return findregion(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
}
region_list *
astralregions(const region * r, boolean (*valid)(const region *))
{
region_list * rlist = NULL;
int x, y;
assert(rplane(r) == NULL);
if (r==NULL) return NULL;
r = r_astral_to_standard(r);
for (x=r->x-TP_RADIUS;x<=r->x+TP_RADIUS;++x) {
for (y=r->y-TP_RADIUS;y<=r->y+TP_RADIUS;++y) {
region * rn;
int dist = koor_distance(r->x, r->y, x, y);
if (dist > TP_RADIUS) continue;
if (dist==4) {
/* these three regions are in dispute with the NW, W & SW areas */
if (x==-2 && y==0) continue;
if (x==-2 && y==2) continue;
if (x==0 && y==-2) continue;
}
rn = findregion(x, y);
if (rn!=NULL && (valid==NULL || valid(rn))) add_regionlist(&rlist, rn);
}
}
return rlist;
} }
region * region *
r_standard_to_astral(const region *r) r_standard_to_astral(const region *r)
{ {
region *r2; region *r2;
#if 0 r2 = tpregion(r);
int x, y;
x = TE_CENTER_X + (r->x/TP_RADIUS); if (rplane(r2) != get_astralplane() || rterrain(r2) != T_ASTRAL) return NULL;
y = TE_CENTER_Y + (r->y/TP_RADIUS);
r2 = findregion(x,y); return r2;
#endif
r2 = tpregion(r);
if(getplaneid(r2) != 1 || rterrain(r2) != T_ASTRAL)
return NULL;
return r2;
} }
region * region *
r_astral_to_standard(const region *r) r_astral_to_standard(const region *r)
{ {
int x, y; int x, y;
region *r2; region *r2;
assert(getplaneid(r) == 1); assert(rplane(r) == get_astralplane());
x = (r->x-TE_CENTER_X)*TP_RADIUS; x = (r->x-TE_CENTER_X)*TP_RADIUS;
y = (r->y-TE_CENTER_Y)*TP_RADIUS; y = (r->y-TE_CENTER_Y)*TP_RADIUS;
r2 = findregion(x,y); r2 = findregion(x,y);
if(!r2 || getplaneid(r2) != 0) if (r2!=NULL || getplaneid(r2) != 0) return NULL;
return NULL;
return r2; return r2;
} }
region_list * region_list *
all_in_range(region *r, int n) all_in_range(const region *r, int n, boolean (*valid)(const region *))
{ {
int x,y; int x,y;
region_list *rlist = NULL; region_list *rlist = NULL;
region *r2;
if(r == NULL) return NULL; /* Um Probleme abzufangen, if (r == NULL) return NULL;
wenn zu einer Astralregion
noch kein Realitätsregion existiert.
Nicht gut, aber nicht zu ändern. */
for(x = r->x-n; x <= r->x+n; x++) { for (x = r->x-n; x <= r->x+n; x++) {
for(y = r->y-n; y <= r->y+n; y++) { for (y = r->y-n; y <= r->y+n; y++) {
if(koor_distance(r->x, r->y, x, y) <= n) { if (koor_distance(r->x, r->y, x, y) <= n) {
r2 = findregion(x,y); region * r2 = findregion(x,y);
if(r2) add_regionlist(&rlist, findregion(x,y)); if (r2!=NULL && (valid==NULL || valid(r2))) add_regionlist(&rlist, r2);
} }
} }
} }
return rlist; return rlist;
} }
void void
random_in_teleport_plane(void) random_in_teleport_plane(void)
{ {
region *r; region *r;
unit *u; faction *f0 = findfaction(MONSTER_FACTION);
faction *f0 = findfaction(MONSTER_FACTION); int next = rand() % 100;
if(!f0) return; if (f0==NULL) return;
for(r=regions; r; r=r->next) { for (r=regions; r; r=r->next) {
if(getplaneid(r) != 1 || rterrain(r) != T_ASTRAL) continue; if (rplane(r) != get_astralplane() || rterrain(r) != T_ASTRAL) continue;
/* Neues Monster ? */ /* Neues Monster ? */
if(rand()%100 == 0) { if (next-- == 0) {
switch(rand()%1) { unit *u = createunit(r, f0, 1+rand()%10+rand()%10, new_race[RC_HIRNTOETER]);
case 0:
u = createunit(r, f0, 1+rand()%10+rand()%10, new_race[RC_HIRNTOETER]); set_string(&u->name, "Hirntöter");
set_string(&u->name, "Hirntöter"); set_string(&u->display, "Wabernde grüne Schwaden treiben durch den Nebel und verdichten sich zu einer unheimlichen Kreatur, die nur aus einem langen Ruderschwanz und einem riesigen runden Maul zu bestehen scheint.");
set_string(&u->display, "Wabernde grüne Schwaden treiben durch den Nebel und verdichten sich zu einer unheimlichen Kreatur, die nur aus einem langen Ruderschwanz und einem riesigen runden Maul zu bestehen scheint."); set_level(u, SK_STEALTH, 1);
set_level(u, SK_STEALTH, 1); set_level(u, SK_OBSERVATION, 1);
set_level(u, SK_OBSERVATION, 1); next = rand() % 100;
break; }
} }
}
}
} }
plane * astral_plane; plane *
get_astralplane(void)
{
static plane * astral_plane = NULL;
if (astral_plane==NULL) {
astral_plane = getplanebyid(1);
}
if (astral_plane==NULL) {
astral_plane = create_new_plane(1, "Astralraum",
TE_CENTER_X-500, TE_CENTER_X+500,
TE_CENTER_Y-500, TE_CENTER_Y+500, 0);
}
return astral_plane;
}
void void
create_teleport_plane(void) create_teleport_plane(void)
{ {
region *r; region *r;
int i; int i;
plane * aplane = get_astralplane();
astral_plane = getplanebyid(1); /* Regionsbereich aufbauen. */
/* wichtig: das muß auch für neue regionen gemacht werden.
* Evtl. bringt man es besser in new_region() unter, und
* übergibt an new_region die plane mit, in der die
* Region gemacht wird.
*/
if (!astral_plane) { for (r=regions;r;r=r->next) if(r->planep == NULL) {
astral_plane = create_new_plane(1, "Astralraum", region *ra = tpregion(r);
TE_CENTER_X-500, TE_CENTER_X+500, if (ra==NULL) {
TE_CENTER_Y-500, TE_CENTER_Y+500, ra = new_region(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
0); rsetterrain(ra, T_ASTRAL);
} }
ra->planep = aplane;
if (terrain[rterrain(r)].flags & FORBIDDEN_LAND) rsetterrain(ra, T_ASTRALB);
}
/* Regionsbereich aufbauen. */ for(i=0;i<4;i++) {
/* wichtig: das muß auch für neue regionen gemacht werden. random_in_teleport_plane();
* Evtl. bringt man es besser in new_region() unter, und }
* übergibt an new_region die plane mit, in der die
* Region gemacht wird.
*/
for (r=regions;r;r=r->next) if(r->planep == NULL) {
region *ra = tpregion(r);
if (!ra) {
ra = new_region(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
rsetterrain(ra, T_ASTRAL);
}
ra->planep = getplanebyid(1);
if (terrain[rterrain(r)].flags & FORBIDDEN_LAND) rsetterrain(ra, T_ASTRALB);
}
for(i=0;i<4;i++) {
random_in_teleport_plane();
}
} }
region_list * boolean
allinhab_in_range(const region *r, int n) inhabitable(const region * r)
{ {
int x,y; return landregion(rterrain(r));
region_list *rlist = NULL;
region *r2;
if(r == NULL) return NULL; /* Um Probleme abzufangen,
wenn zu einer Astralregion
noch kein Realitätsregion existiert.
Nicht gut, aber nicht zu ändern. */
for(x = r->x-n; x <= r->x+n; x++) {
for(y = r->y-n; y <= r->y+n; y++) {
if(koor_distance(r->x, r->y, x, y) <= n) {
r2 = findregion(x,y);
if (r2 && landregion(rterrain(r2)))
add_regionlist(&rlist, findregion(x,y));
}
}
}
return rlist;
} }

View File

@ -18,21 +18,15 @@
extern "C" { extern "C" {
#endif #endif
#define TE_CENTER_X 1000 struct region *r_standard_to_astral(const struct region *r);
#define TE_CENTER_Y 1000 struct region *r_astral_to_standard(const struct region *);
#define ENNOS_PLANE 1 extern struct region_list *astralregions(const struct region * r, boolean (*valid)(const struct region *));
#if ENNOS_PLANE extern struct region_list *all_in_range(const struct region *r, int n, boolean (*valid)(const struct region *));
#define TP_RADIUS 4 extern boolean inhabitable(const struct region * r);
#else extern struct plane * get_astralplane(void);
#define RADIUS 75
#define TP_RADIUS 2 void create_teleport_plane(void);
#endif void set_teleport_plane_regiontypes(void);
struct region *r_standard_to_astral(const struct region *r);
struct region *r_astral_to_standard(const struct region *);
struct region_list *all_in_range(struct region *r, int n);
struct region_list *allinhab_in_range(const struct region *r, int n);
void create_teleport_plane(void);
void set_teleport_plane_regiontypes(void);
#ifdef __cplusplus #ifdef __cplusplus
} }