Merge branch 'master' into portal_branches portal_branches
authorAdam Borowski <kilobyte@angband.pl>
Wed, 25 Apr 2012 14:35:56 +0000 (16:35 +0200)
committerAdam Borowski <kilobyte@angband.pl>
Wed, 25 Apr 2012 14:35:56 +0000 (16:35 +0200)
73 files changed:
1  2 
crawl-ref/source/abl-show.cc
crawl-ref/source/abyss.cc
crawl-ref/source/arena.cc
crawl-ref/source/artefact.cc
crawl-ref/source/beam.cc
crawl-ref/source/cluautil.h
crawl-ref/source/command.cc
crawl-ref/source/dat/des/altar/overflow.des
crawl-ref/source/dat/des/builder/shops.des
crawl-ref/source/dat/des/portals/bailey.des
crawl-ref/source/dat/des/portals/wizlab.des
crawl-ref/source/dat/des/variable/evilmike_ambush.des
crawl-ref/source/dat/des/variable/mini_features.des
crawl-ref/source/dat/des/variable/mini_monsters.des
crawl-ref/source/dbg-asrt.cc
crawl-ref/source/decks.cc
crawl-ref/source/decks.h
crawl-ref/source/defines.h
crawl-ref/source/dgn-shoals.cc
crawl-ref/source/directn.cc
crawl-ref/source/dungeon.cc
crawl-ref/source/effects.cc
crawl-ref/source/enum.h
crawl-ref/source/files.cc
crawl-ref/source/food.cc
crawl-ref/source/godpassive.cc
crawl-ref/source/hiscores.cc
crawl-ref/source/hiscores.h
crawl-ref/source/items.cc
crawl-ref/source/l_dgn.cc
crawl-ref/source/l_dgnbld.cc
crawl-ref/source/l_item.cc
crawl-ref/source/l_you.cc
crawl-ref/source/main.cc
crawl-ref/source/makeitem.cc
crawl-ref/source/mapdef.cc
crawl-ref/source/mapdef.h
crawl-ref/source/maps.cc
crawl-ref/source/melee_attack.cc
crawl-ref/source/misc.cc
crawl-ref/source/mon-abil.cc
crawl-ref/source/mon-act.cc
crawl-ref/source/mon-cast.cc
crawl-ref/source/mon-movetarget.cc
crawl-ref/source/mon-pick.cc
crawl-ref/source/mon-place.cc
crawl-ref/source/mon-stuff.cc
crawl-ref/source/mon-util.cc
crawl-ref/source/monster.cc
crawl-ref/source/ng-init.cc
crawl-ref/source/ng-setup.cc
crawl-ref/source/output.cc
crawl-ref/source/player.cc
crawl-ref/source/player.h
crawl-ref/source/religion.cc
crawl-ref/source/rltiles/dc-item.txt
crawl-ref/source/shopping.cc
crawl-ref/source/spl-miscast.cc
crawl-ref/source/spl-transloc.cc
crawl-ref/source/startup.cc
crawl-ref/source/stash.cc
crawl-ref/source/tags.cc
crawl-ref/source/terrain.cc
crawl-ref/source/terrain.h
crawl-ref/source/tilepick.cc
crawl-ref/source/tileview.cc
crawl-ref/source/traps.cc
crawl-ref/source/traps.h
crawl-ref/source/view.cc
crawl-ref/source/viewmap.cc
crawl-ref/source/wiz-dgn.cc
crawl-ref/source/wiz-mon.cc
crawl-ref/source/xom.cc

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -4806,10 -4816,10 +4816,10 @@@ mon_resist_type bolt::apply_enchantment
          return (MON_AFFECTED);
  
      case BEAM_BANISH:
 -        if (you.level_type == LEVEL_ABYSS)
 +        if (player_in_branch(BRANCH_ABYSS))
              simple_monster_message(mon, " wobbles for a moment.");
          else
-             mon->banish();
+             mon->banish(agent());
          obvious_effect = true;
          return (MON_AFFECTED);
  
Simple merge
Simple merge
@@@ -169,11 -169,10 +169,10 @@@ ENDMA
  
  # This is an ancient vault.
  NAME:  solitary_fountain
 -DEPTH: D, Elf, Vault
 +DEPTH: D, Elf, Vaults
  TAGS:  allow_dup extra luniq_mini
  SUBST: ?=TUV
- KMASK: T = no_monster_gen
- KMASK: U = no_monster_gen
+ KMASK: TU = no_monster_gen
  MAP
  .....
  .....
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -2029,19 -2061,20 +2027,19 @@@ static void _ruin_level(Iterator ri
      }
  }
  
- static void _place_feature_mimics(dungeon_feature_type dest_stairs_type)
 -static bool _mimic_at_level(int level_number)
++static bool _mimic_at_level()
  {
-     if (player_in_branch(BRANCH_ECUMENICAL_TEMPLE)
-         || player_in_branch(BRANCH_VESTIBULE_OF_HELL)
-         || player_in_branch(BRANCH_SLIME_PITS)
-         || !player_in_connected_branch())
-     {
-         return;
-     }
-     if (env.absdepth0 < FEATURE_MIMIC_DEPTH)
-         return;
 -    return level_number
++    return (!player_in_branch(BRANCH_MAIN_DUNGEON) || you.depth > 1)
+            && !player_in_branch(BRANCH_ECUMENICAL_TEMPLE)
+            && !player_in_branch(BRANCH_VESTIBULE_OF_HELL)
+            && !player_in_branch(BRANCH_SLIME_PITS)
+            && !player_in_branch(BRANCH_TOMB)
 -           && !player_in_level_area(LEVEL_PANDEMONIUM)
++           && !player_in_branch(BRANCH_PANDEMONIUM)
+            && !player_in_hell();
+ }
  
 -static void _place_feature_mimics(int level_number,
 -                                  dungeon_feature_type dest_stairs_type)
++static void _place_feature_mimics(dungeon_feature_type dest_stairs_type)
+ {
      for (rectangle_iterator ri(1); ri; ++ri)
      {
          const coord_def pos = *ri;
      }
  }
  
 -static void _place_item_mimics(int level_number)
 +static void _place_item_mimics()
  {
-     if (env.absdepth0 < ITEM_MIMIC_DEPTH)
+     // No mimics on D:1
 -    if (!level_number)
++    if (!env.absdepth0)
          return;
  
      for (int i = 0; i < MAX_ITEMS; i++)
@@@ -2186,9 -2249,10 +2196,10 @@@ static void _build_dungeon_level(dungeo
  
          // XXX: Moved this here from builder_monsters so that
          //      connectivity can be ensured
 -        _place_uniques(level_number, level_type);
 +        _place_uniques();
  
-         _place_feature_mimics(dest_stairs_type);
 -        if (_mimic_at_level(level_number))
 -            _place_feature_mimics(level_number, dest_stairs_type);
++        if (_mimic_at_level())
++            _place_feature_mimics(dest_stairs_type);
  
          // Any vault-placement activity must happen before this check.
          _dgn_verify_connectivity(nvaults);
      _fixup_misplaced_items();
  
      link_items();
-     _place_item_mimics();
 -    if (_mimic_at_level(level_number))
 -        _place_item_mimics(level_number);
++    if (_mimic_at_level())
++        _place_item_mimics();
  
      if (!player_in_branch(BRANCH_COCYTUS)
          && !player_in_branch(BRANCH_SWAMP)
@@@ -3201,9 -3349,8 +3207,8 @@@ static void _place_branch_entrances(
  
          const bool mimic = !branch_is_unfinished(b->id)
                             && !is_hell_subbranch(b->id)
-                            && dlevel >= FEATURE_MIMIC_DEPTH
 -                           && player_branch_depth() >= b->mindepth
 -                           && player_branch_depth() <= b->maxdepth
 +                           && you.depth >= b->mindepth
 +                           && you.depth <= b->maxdepth
                             && one_chance_in(FEATURE_MIMIC_CHANCE);
  
          if (b->entry_stairs != NUM_FEATURES
@@@ -2008,8 -2144,8 +2013,8 @@@ void handle_time(
      }
  
      // Labyrinth and Abyss maprot.
 -    if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS)
 +    if (player_in_branch(BRANCH_LABYRINTH) || player_in_branch(BRANCH_ABYSS))
-         forget_map(0);
+         forget_map(true);
  
      // Every 20 turns, a variety of other effects.
      if (! (_div(base_time, 200) > _div(old_time, 200)))
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -984,6 -998,41 +998,33 @@@ static int l_item_inslot(lua_State *ls
      return (1);
  }
  
+ static int l_item_get_items_at(lua_State *ls)
+ {
+     coord_def s;
+     s.x = luaL_checkint(ls, 1);
+     s.y = luaL_checkint(ls, 2);
+     coord_def p = player2grid(s);
+     if (!map_bounds(p))
+         return 0;
+     item_def* top = env.map_knowledge(p).item();
+     if (!top || !top->defined())
+         return 0;
+     lua_newtable(ls);
 -    if (StashTracker::is_level_untrackable())
 -    {
 -        // You can still see the top item.
 -        clua_push_item(ls, top);
 -        lua_rawseti(ls, -2, 1);
 -    }
 -    else
++    const std::vector<item_def> items = item_list_in_stash(p);
++    int index = 0;
++    for (std::vector<item_def>::const_iterator i = items.begin();
++         i != items.end(); ++i)
+     {
 -        const std::vector<item_def> items = item_list_in_stash(p);
 -        int index = 0;
 -        for (std::vector<item_def>::const_iterator i = items.begin();
 -             i != items.end(); ++i)
 -        {
 -            clua_push_item_temp(ls, *i);
 -            lua_rawseti(ls, -2, ++index);
 -        }
++        clua_push_item_temp(ls, *i);
++        lua_rawseti(ls, -2, ++index);
+     }
++
+     return (1);
+ }
  struct ItemAccessor
  {
      const char *attribute;
@@@ -295,22 -294,19 +295,35 @@@ LUAFN(you_mutation
      return (luaL_argerror(ls, 1, err.c_str()));
  }
  
 +LUAFN(you_is_level_on_stack)
 +{
 +    std::string levname = luaL_checkstring(ls, 1);
 +    level_id lev;
 +    try
 +    {
 +        lev = level_id::parse_level_id(levname);
 +    }
 +    catch (const std::string &err)
 +    {
 +        return luaL_argerror(ls, 1, err.c_str());
 +    }
 +
 +    PLUARET(boolean, is_level_on_stack(lev));
 +}
 +
+ LUAFN(you_train_skill)
+ {
+     skill_type sk = str_to_skill(luaL_checkstring(ls, 1));
+     if (lua_gettop(ls) >= 2 && you.can_train[sk])
+     {
+         you.train[sk] = std::min(std::max(luaL_checkint(ls, 2), 0), 2);
+         reset_training();
+     }
+     PLUARET(number, you.train[sk]);
+ }
  static const struct luaL_reg you_clib[] =
  {
      { "turn_is_over", you_turn_is_over },
@@@ -1392,11 -1398,15 +1392,9 @@@ static void _go_upstairs(
              shop();
          return;
      }
 -    else if (ygrd == DNGN_ENTER_HELL && you.level_type != LEVEL_DUNGEON)
 -    {
 -        mpr("You can't enter Hell from outside the dungeon!",
 -            MSGCH_ERROR);
 -        return;
 -    }
      // Up and down both work for portals.
      else if (feat_is_bidirectional_portal(ygrd))
-     {
          ;
-     }
      else if (feat_stair_direction(ygrd) != CMD_GO_UPSTAIRS)
      {
          if (ygrd == DNGN_STONE_ARCH)
@@@ -1499,11 -1510,15 +1497,9 @@@ static void _go_downstairs(
              shop();
          return;
      }
 -    else if (ygrd == DNGN_ENTER_HELL && you.level_type != LEVEL_DUNGEON)
 -    {
 -        mpr("You can't enter Hell from outside the dungeon!",
 -            MSGCH_ERROR);
 -        return;
 -    }
      // Up and down both work for portals.
      else if (feat_is_bidirectional_portal(ygrd))
-     {
          ;
-     }
      else if (feat_stair_direction(ygrd) != CMD_GO_DOWNSTAIRS
               && !shaft)
      {
@@@ -792,13 -792,11 +792,11 @@@ static weapon_type _determine_weapon_su
  
  static bool _try_make_item_unrand(item_def& item, int force_type)
  {
 -    if (you.level_type == LEVEL_PANDEMONIUM)
 +    if (player_in_branch(BRANCH_PANDEMONIUM))
-     {
          return (false);
-     }
  
      int idx = find_okay_unrandart(item.base_type, force_type,
 -                                  you.level_type == LEVEL_ABYSS);
 +                                  player_in_branch(BRANCH_ABYSS));
  
      if (idx != -1 && make_item_unrandart(item, idx))
          return (true);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -626,23 -579,8 +625,8 @@@ int mons_standard_level(monster_type mc
      case MONS_TITAN:
          return 31;
  
-     case MONS_DEEP_ELF_BLADEMASTER:
-     case MONS_DEEP_ELF_MASTER_ARCHER:
-         return 34;
-     case MONS_BIG_FISH:
-     case MONS_ELECTRIC_EEL:
-     case MONS_GIANT_GOLDFISH:
-     case MONS_JELLYFISH:
-     case MONS_LAVA_FISH:
-     case MONS_LAVA_SNAKE:
-     case MONS_LAVA_WORM:
-     case MONS_SWAMP_WORM:
-     case MONS_WATER_ELEMENTAL:
-         return 500;
      default:
 -        return 99;
 +        return 999;
      }
  }
  
@@@ -1781,11 -1692,8 +1738,8 @@@ int mons_pitslime_level(monster_type mc
      case MONS_GIANT_ORANGE_BRAIN:
          return 6;
  
-     case MONS_ROYAL_JELLY:
-         return 7;
      default:
 -        return 1;
 +        return 999;
      }
  }
  
Simple merge
@@@ -2271,8 -2265,12 +2265,12 @@@ int monster_die(monster* mons, killer_t
  
              // Monster goes to the Abyss.
              mons->flags |= MF_BANISHED;
-             mons->set_transit(level_id(BRANCH_ABYSS));
+             {
+                 unwind_var<int> dt(mons->damage_total, 0);
+                 unwind_var<int> df(mons->damage_friendly, 0);
 -                mons->set_transit(level_id(LEVEL_ABYSS));
++                mons->set_transit(level_id(BRANCH_ABYSS));
+             }
 -            set_unique_annotation(mons, LEVEL_ABYSS);
 +            set_unique_annotation(mons, BRANCH_ABYSS);
              in_transit = true;
              drop_items = false;
              mons->firing_pos.reset();
@@@ -834,6 -833,14 +833,14 @@@ void discover_mimic(const coord_def& po
      if (wake)
          mg.flags |= MG_DONT_COME;
  
+     // HD is scaled with depth
 -    const int level = you.absdepth0 + 1;
++    const int level = env.absdepth0 + 1;
+     mg.hd = stepdown_value(level, 12, 12, 24, 36);
+     // Early levels get inept mimics instead
+     if (!x_chance_in_y(level - 6, 6))
+         mg.cls = item ? MONS_INEPT_ITEM_MIMIC : MONS_INEPT_FEATURE_MIMIC;
      if (feature_mimic)
      {
          if (feat_is_stone_stair(feat))
Simple merge
Simple merge
Simple merge
@@@ -23,7 -23,7 +23,8 @@@
  #include "colour.h"
  #include "coord.h"
  #include "describe.h"
 +#include "env.h"
+ #include "files.h"
  #include "format.h"
  #include "godabil.h"
  #include "initfile.h"
@@@ -2887,15 -2838,10 +2833,10 @@@ void forget_map(bool rot
  {
      ASSERT(!crawl_state.game_is_arena());
  
-     if (force && !yesno("Really forget level map?", true, 'n'))
-         return;
      // Labyrinth and the Abyss use special rotting rules.
-     const bool rotting_map = (player_in_branch(BRANCH_LABYRINTH)
-                               || player_in_branch(BRANCH_ABYSS));
 -    const bool rot_resist = you.level_type == LEVEL_LABYRINTH
 +    const bool rot_resist = player_in_branch(BRANCH_LABYRINTH)
                                  && you.species == SP_MINOTAUR
 -                            || you.level_type == LEVEL_ABYSS
 +                            || player_in_branch(BRANCH_ABYSS)
                                  && you.religion == GOD_LUGONU;
      const double geometric_chance = 0.99;
      const int radius = (rot_resist ? 200 : 100);
          if (you.see_cell(p) || !env.map_knowledge(p).known())
              continue;
  
-         const int dist = distance(you.pos(), p);
-         bool doDecay = (force || chance_forgotten == 100);
-         if (!doDecay)
+         if (rot)
          {
-             if (rotting_map)
-             {
-                 int chance = pow(geometric_chance,
-                                  std::max(1, (dist - radius) / 40)) * scalar;
-                 doDecay = !x_chance_in_y(chance, scalar);
-             }
-             else
-                 doDecay = !x_chance_in_y(chance_forgotten, 100);
+             const int dist = distance(you.pos(), p);
+             int chance = pow(geometric_chance,
+                              std::max(1, (dist - radius) / 40)) * scalar;
+             if (x_chance_in_y(chance, scalar))
+                 continue;
          }
  
-         if (doDecay)
-         {
-             env.map_knowledge(p).clear();
-             StashTrack.update_stash(p);
+         env.map_knowledge(p).clear();
++        StashTrack.update_stash(p);
  #ifdef USE_TILE
-             tile_forget_map(p);
+         tile_forget_map(p);
  #endif
-         }
      }
  
      ash_detect_portals(is_map_persistent());
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -615,10 -615,11 +615,10 @@@ void MiscastEffect::_potion_effect(poti
  
  bool MiscastEffect::_send_to_abyss()
  {
 -    if (you.level_type == LEVEL_ABYSS
 -        || source == HELL_EFFECT_MISCAST)
 +    if (player_in_branch(BRANCH_ABYSS) || source == HELL_EFFECT_MISCAST)
          return (_malign_gateway()); // attempt to degrade to malign gateway
  
-     target->banish(cause);
+     target->banish(act_source, cause);
      return (true);
  }
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -376,12 -376,10 +376,10 @@@ static const FixedArray<uint8_t, GXM, G
      static int cache_seed = -1;
  
      int seed = random ? -1 :
 -        (static_cast<int>(you.where_are_you) << 8) + you.absdepth0 - 1731813538;
 +        (static_cast<int>(you.where_are_you) << 8) + you.depth - 1731813538;
  
      if (seed == cache_seed && !random)
-     {
          return cache;
-     }
  
      if (!random)
      {
Simple merge
Simple merge
Simple merge
Simple merge