diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index 02699c0b8..442e83d00 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -234,8 +234,6 @@ function test_familiar_school() local u = unit.create(f, r) u.magic = "draig" u:set_skill("magic", 10) - u.aura = 200 - u:add_spell("fireball") local uf = unit.create(f, r) uf.race = "lynx" u.familiar = uf @@ -247,3 +245,18 @@ function test_familiar_school() assert_equal(0, uf.aura) assert_nil(uf.magic) end + +function test_astral_disruption() + local r = region.create(0, 0, "plain") + local r2 = r:get_astral('fog') + local f = faction.create("human") + local u = unit.create(f, r) + local uh = unit.create(get_monsters(), r2, 1, "braineater") + u.magic = "draig" + u:set_skill("magic", 100) -- level 100 should beat magic resistance + u.aura = 200 + u:add_spell("astral_disruption") + u:add_order('ZAUBERE STUFE 1 "Stoere Astrale Integritaet"') + process_orders() + assert_equal(r, uh.region) +end diff --git a/src/bind_region.c b/src/bind_region.c index d0c184e0d..4ba16192f 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -587,10 +587,10 @@ static int tolua_region_getastral(lua_State * L) if (!rt) { const char *tname = tolua_tostring(L, 2, NULL); + const terrain_type *terrain = get_terrain(tname ? tname : "fog"); plane *pl = get_astralplane(); rt = new_region(real2tp(r->x), real2tp(r->y), pl, 0); - if (tname) { - const terrain_type *terrain = get_terrain(tname); + if (terrain) { terraform_region(rt, terrain); } } diff --git a/src/spells.c b/src/spells.c index 0184fadd5..2669664c7 100644 --- a/src/spells.c +++ b/src/spells.c @@ -5554,7 +5554,14 @@ int sp_viewreality(castorder * co) return cast_level; } -/* ------------------------------------------------------------- */ +/** + * Zauber: Störe astrale Integrität + * + * Dieser Zauber bewirkt eine schwere Störung des Astralraums. Innerhalb eines + * astralen Radius von Stufe/5 Regionen werden alle Astralwesen, die dem Zauber + * nicht wiederstehen können, aus der astralen Ebene geschleudert. Der astrale + * Kontakt mit allen betroffenen Regionen ist für Stufe/3 Wochen gestört. + */ int sp_disruptastral(castorder * co) { region_list *rl, *rl2; @@ -5584,20 +5591,20 @@ int sp_disruptastral(castorder * co) return 0; } - rl = list_all_in_range(rt, (short)(power / 5)); + rl = list_all_in_range(rt, (int)(power / 5)); for (rl2 = rl; rl2 != NULL; rl2 = rl2->next) { attrib *a; double effect; region *r2 = rl2->data; int inhab_regions = 0; - region_list *trl = NULL; + region *rtargets[MAX_SCHEMES]; if (is_cursed(r2->attribs, &ct_astralblock)) continue; if (r2->units != NULL) { - inhab_regions = get_astralregions(r, inhabitable, NULL); + inhab_regions = get_astralregions(r2, inhabitable, rtargets); } /* Nicht-Permanente Tore zerstoeren */ @@ -5613,17 +5620,10 @@ int sp_disruptastral(castorder * co) /* Einheiten auswerfen */ - if (trl != NULL) { + if (inhab_regions) { for (u = r2->units; u; u = u->next) { - region_list *trl2 = trl; - region *tr; int c = rng_int() % inhab_regions; - - /* Zufaellige Zielregion suchen */ - while (c-- != 0) { - trl2 = trl2->next; - } - tr = trl2->data; + region *tr = rtargets[c]; if (!is_magic_resistant(mage, u, 0) && can_survive(u, tr)) { message *msg = msg_message("disrupt_astral", "unit region", u, tr); @@ -5634,7 +5634,6 @@ int sp_disruptastral(castorder * co) move_unit(u, tr, NULL); } } - free_regionlist(trl); } /* Kontakt unterbinden */