summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-28 00:17:23 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-28 00:29:40 +1000
commit23929ee3b2452b1c3a133061eff44b31dc70fb09 (patch)
tree438759a7c65a1d57fb97ec39c7a3a0beca99ed06
parente42132c99bf63b213388404676a54c6610bd613c (diff)
downloadcrawl-ref-23929ee3b2452b1c3a133061eff44b31dc70fb09.tar.gz
crawl-ref-23929ee3b2452b1c3a133061eff44b31dc70fb09.zip
Customisable clouds!
cloud_struct now has members for colour, name, and tile; colour will be used instead of the default colour of the cloud type, and will be used to recolour the tile of the cloud (if it exists). Name will be used to rebrand the cloud's description, and also alter the message generate while standing in a cloud. Finally, tile can be used to completely customise the tile used for the cloud. The value is stored as a string in order to maintain save compatibility across ASCII and tiles. A random tile (found using tile_main_count) from that set will also be used, however, no duration effects will be applied. Recoloured cloud tiles using just the colour code should be possible, though aren't yet fully tested. This commit bumps TAG_MAJOR_VERSION: changing marshalling of the FogMachine Lua code causes nasty crashes on reloading saved games. Otherwise, I don't think I broke anything else. :-)
-rw-r--r--crawl-ref/source/beam.cc5
-rw-r--r--crawl-ref/source/cloud.cc110
-rw-r--r--crawl-ref/source/cloud.h24
-rw-r--r--crawl-ref/source/dat/clua/lm_fog.lua21
-rw-r--r--crawl-ref/source/directn.cc3
-rw-r--r--crawl-ref/source/externs.h6
-rw-r--r--crawl-ref/source/l_dgn.cc18
-rw-r--r--crawl-ref/source/misc.cc5
-rw-r--r--crawl-ref/source/player.cc2
-rw-r--r--crawl-ref/source/show.cc3
-rw-r--r--crawl-ref/source/spells1.cc17
-rw-r--r--crawl-ref/source/spells1.h9
-rw-r--r--crawl-ref/source/spells4.cc5
-rw-r--r--crawl-ref/source/spells4.h3
-rw-r--r--crawl-ref/source/spl-util.cc19
-rw-r--r--crawl-ref/source/spl-util.h6
-rw-r--r--crawl-ref/source/tags.cc6
-rw-r--r--crawl-ref/source/tags.h2
-rw-r--r--crawl-ref/source/tilepick.cc109
-rw-r--r--crawl-ref/source/tilereg.cc8
-rw-r--r--crawl-ref/source/tiles.h2
-rw-r--r--crawl-ref/source/tutorial.cc2
22 files changed, 261 insertions, 124 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index cdeefc8204..8b05a833d9 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3243,17 +3243,18 @@ void bolt::affect_place_clouds()
if (p == you.pos())
{
mprf("The %s you are in turns into %s!",
- cloud_name(ctype).c_str(), cloud_name(new_type).c_str());
+ cloud_name(cloudidx).c_str(), cloud_name(new_type).c_str());
obvious_effect = true;
}
else if (you.see_cell(p))
{
mprf("A cloud of %s turns into %s.",
- cloud_name(ctype).c_str(), cloud_name(new_type).c_str());
+ cloud_name(cloudidx).c_str(), cloud_name(new_type).c_str());
obvious_effect = true;
}
ctype = new_type;
+ env.cloud[cloudidx].name = "";
return;
}
diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc
index 638432f504..bd5670b846 100644
--- a/crawl-ref/source/cloud.cc
+++ b/crawl-ref/source/cloud.cc
@@ -27,6 +27,11 @@
#include "stuff.h"
#include "env.h"
#include "terrain.h"
+#ifdef USE_TILE
+#include "tiles.h"
+#include "tiledef-gui.h"
+#include "tiledef-main.h"
+#endif
#include "mutation.h"
static int _actual_spread_rate(cloud_type type, int spread_rate)
@@ -70,7 +75,8 @@ static bool _killer_whose_match(kill_category whose, killer_type killer)
static void _new_cloud( int cloud, cloud_type type, const coord_def& p,
int decay, kill_category whose, killer_type killer,
- unsigned char spread_rate )
+ unsigned char spread_rate, int colour, std::string name,
+ std::string tile)
{
ASSERT( env.cloud[cloud].type == CLOUD_NONE );
ASSERT(_killer_whose_match(whose, killer));
@@ -83,13 +89,28 @@ static void _new_cloud( int cloud, cloud_type type, const coord_def& p,
c.whose = whose;
c.killer = killer;
c.spread_rate = spread_rate;
+ c.colour = colour;
+ c.name = name;
+#ifdef USE_TILE
+ if (!tile.empty())
+ {
+ unsigned int index;
+ if (!tile_main_index(tile.c_str(), index))
+ {
+ mprf(MSGCH_ERROR, "Invalid tile requested for cloud: '%s'.", tile.c_str());
+ tile = "";
+ }
+ }
+#endif
+ c.tile = tile;
env.cgrid(p) = cloud;
env.cloud_no++;
}
static void _place_new_cloud(cloud_type cltype, const coord_def& p, int decay,
kill_category whose, killer_type killer,
- int spread_rate)
+ int spread_rate, int colour, std::string name,
+ std::string tile)
{
if (env.cloud_no >= MAX_CLOUDS)
return;
@@ -99,7 +120,8 @@ static void _place_new_cloud(cloud_type cltype, const coord_def& p, int decay,
{
if (env.cloud[ci].type == CLOUD_NONE) // i.e., is empty
{
- _new_cloud( ci, cltype, p, decay, whose, killer, spread_rate );
+ _new_cloud( ci, cltype, p, decay, whose, killer, spread_rate, colour,
+ name, tile );
break;
}
}
@@ -129,7 +151,7 @@ static int _spread_cloud(const cloud_struct &cloud)
newdecay = cloud.decay - 1;
_place_new_cloud( cloud.type, *ai, newdecay, cloud.whose, cloud.killer,
- cloud.spread_rate );
+ cloud.spread_rate, cloud.colour, cloud.name, cloud.tile );
extra_decay += 8;
}
@@ -151,7 +173,8 @@ static void _spread_fire(const cloud_struct &cloud)
// burning trees produce flames all around
if (!cell_is_solid(*ai) && make_flames)
_place_new_cloud( CLOUD_FIRE, *ai, cloud.decay/2+1, cloud.whose,
- cloud.killer, cloud.spread_rate );
+ cloud.killer, cloud.spread_rate, cloud.colour,
+ cloud.name, cloud.tile );
// forest fire doesn't spread in all directions at once,
// every neighbouring square gets a separate roll
@@ -161,7 +184,8 @@ static void _spread_fire(const cloud_struct &cloud)
mpr("The forest fire spreads!");
grd(*ai) = DNGN_FLOOR;
_place_new_cloud( cloud.type, *ai, random2(30)+25, cloud.whose,
- cloud.killer, cloud.spread_rate );
+ cloud.killer, cloud.spread_rate, cloud.colour,
+ cloud.name, cloud.tile );
}
}
@@ -248,6 +272,9 @@ void delete_cloud( int cloud )
c.whose = KC_OTHER;
c.killer = KILL_NONE;
c.spread_rate = 0;
+ c.colour = -1;
+ c.name = "";
+ c.tile = "";
env.cgrid(c.pos) = EMPTY_CLOUD;
c.pos.reset();
@@ -271,32 +298,37 @@ void move_cloud( int cloud, const coord_def& newpos )
// Places a cloud with the given stats assuming one doesn't already
// exist at that point.
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
- kill_category whose, int spread_rate )
+ kill_category whose, int spread_rate, int colour,
+ std::string name, std::string tile)
{
check_place_cloud(cl_type, p, lifetime, whose,
- cloud_struct::whose_to_killer(whose), spread_rate);
+ cloud_struct::whose_to_killer(whose), spread_rate, colour,
+ name, tile);
}
// Places a cloud with the given stats assuming one doesn't already
// exist at that point.
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
- killer_type killer, int spread_rate )
+ killer_type killer, int spread_rate, int colour,
+ std::string name, std::string tile)
{
check_place_cloud(cl_type, p, lifetime,
cloud_struct::killer_to_whose(killer), killer,
- spread_rate);
+ spread_rate, colour, name, tile);
}
// Places a cloud with the given stats assuming one doesn't already
// exist at that point.
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
kill_category whose, killer_type killer,
- int spread_rate )
+ int spread_rate, int colour, std::string name,
+ std::string tile)
{
if (!in_bounds(p) || env.cgrid(p) != EMPTY_CLOUD)
return;
- place_cloud( cl_type, p, lifetime, whose, killer, spread_rate );
+ place_cloud( cl_type, p, lifetime, whose, killer, spread_rate, colour,
+ name, tile );
}
int steam_cloud_damage(const cloud_struct &cloud)
@@ -317,27 +349,32 @@ int steam_cloud_damage(int decay)
// make way if there are too many on level. Will overwrite an old
// cloud under some circumstances.
void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
- kill_category whose, int _spread_rate)
+ kill_category whose, int _spread_rate, int colour,
+ std::string name, std::string tile)
{
place_cloud(cl_type, ctarget, cl_range, whose,
- cloud_struct::whose_to_killer(whose), _spread_rate);
+ cloud_struct::whose_to_killer(whose), _spread_rate,
+ colour, name, tile);
}
// Places a cloud with the given stats. May delete old clouds to
// make way if there are too many on level. Will overwrite an old
// cloud under some circumstances.
void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
- killer_type killer, int _spread_rate)
+ killer_type killer, int _spread_rate, int colour,
+ std::string name, std::string tile)
{
place_cloud(cl_type, ctarget, cl_range,
- cloud_struct::killer_to_whose(killer), killer, _spread_rate);
+ cloud_struct::killer_to_whose(killer), killer, _spread_rate,
+ colour, name, tile);
}
// Places a cloud with the given stats. May delete old clouds to
// make way if there are too many on level. Will overwrite an old
// cloud under some circumstances.
void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
- kill_category whose, killer_type killer, int _spread_rate)
+ kill_category whose, killer_type killer, int _spread_rate,
+ int colour, std::string name, std::string tile)
{
if (is_sanctuary(ctarget) && !is_harmless_cloud(cl_type))
return;
@@ -393,7 +430,7 @@ void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
if (cl_new != -1)
{
_new_cloud( cl_new, cl_type, ctarget, cl_range * 10,
- whose, killer, spread_rate );
+ whose, killer, spread_rate, colour, name, tile );
}
else
{
@@ -403,7 +440,7 @@ void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
if (env.cloud[ci].type == CLOUD_NONE) // ie is empty
{
_new_cloud( ci, cl_type, ctarget, cl_range * 10,
- whose, killer, spread_rate );
+ whose, killer, spread_rate, colour, name, tile );
break;
}
}
@@ -609,6 +646,7 @@ void in_a_cloud()
int cl = env.cgrid(you.pos());
int hurted = 0;
int resist;
+ std::string name = env.cloud[cl].name;
if (you.duration[DUR_CONDENSATION_SHIELD] > 0)
remove_condensation_shield();
@@ -620,7 +658,7 @@ void in_a_cloud()
if (you.duration[DUR_FIRE_SHIELD])
return;
- mpr("You are engulfed in roaring flames!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "roaring flames");
resist = player_res_fire();
@@ -650,7 +688,8 @@ void in_a_cloud()
case CLOUD_STINK:
// If you don't have to breathe, unaffected
- mpr("You are engulfed in noxious fumes!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "noxious fumes");
+
if (player_res_poison())
break;
@@ -674,7 +713,7 @@ void in_a_cloud()
if (you.mutation[MUT_PASSIVE_FREEZE])
break;
- mpr("You are engulfed in freezing vapours!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "freezing vapours");
resist = player_res_cold();
@@ -703,7 +742,8 @@ void in_a_cloud()
case CLOUD_POISON:
// If you don't have to breathe, unaffected
- mpr("You are engulfed in poison gas!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "poison gas");
+
if (!player_res_poison())
{
ouch((random2(10) * you.time_taken) / 10, cl, KILLED_BY_CLOUD,
@@ -717,12 +757,14 @@ void in_a_cloud()
case CLOUD_TLOC_ENERGY:
case CLOUD_PURPLE_SMOKE:
case CLOUD_BLACK_SMOKE:
- mpr("You are engulfed in a cloud of smoke!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "a cloud of smoke");
+
break;
case CLOUD_STEAM:
{
- mpr("You are engulfed in a cloud of scalding steam!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "a cloud of scalding steam");
+
if (player_res_steam() > 0)
{
mpr("It doesn't seem to affect you.");
@@ -746,7 +788,7 @@ void in_a_cloud()
}
case CLOUD_MIASMA:
- mpr("You are engulfed in a dark miasma.");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "a dark miasma");
if (you.res_rotting())
return;
@@ -771,11 +813,12 @@ void in_a_cloud()
you.duration[DUR_MISLED] = 0;
}
- mpr("You are standing in the rain.");
+ mprf("You are engulfed in %s.", !name.empty() ? name.c_str() : "the rain");
+
break;
case CLOUD_MUTAGENIC:
- mpr("You are engulfed in a mutagenic fog!");
+ mprf("You are engulfed in %s!", !name.empty() ? name.c_str() : "a mutagenic fog");
if (coinflip())
{
@@ -870,6 +913,14 @@ cloud_type in_what_cloud()
return (env.cloud[cl].type);
}
+std::string cloud_name(int cloudno)
+{
+ if (!env.cloud[cloudno].name.empty())
+ return (env.cloud[cloudno].name);
+ else
+ return cloud_name(env.cloud[cloudno].type);
+}
+
std::string cloud_name(cloud_type type)
{
switch (type)
@@ -975,6 +1026,9 @@ void cloud_struct::set_killer(killer_type _killer)
int get_cloud_colour(int cloudno)
{
int which_colour = LIGHTGREY;
+ if (env.cloud[cloudno].colour != -1)
+ return (env.cloud[cloudno].colour);
+
switch (env.cloud[cloudno].type)
{
case CLOUD_FIRE:
diff --git a/crawl-ref/source/cloud.h b/crawl-ref/source/cloud.h
index 9cd1ef249c..9bb5ba7f00 100644
--- a/crawl-ref/source/cloud.h
+++ b/crawl-ref/source/cloud.h
@@ -34,19 +34,30 @@ void delete_cloud( int cloud );
void move_cloud( int cloud, const coord_def& newpos );
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
- kill_category whose, int spread_rate = -1 );
+ kill_category whose, int spread_rate = -1,
+ int colour = -1, std::string name = "",
+ std::string tile = "");
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
- killer_type killer, int spread_rate = -1 );
+ killer_type killer, int spread_rate = -1,
+ int colour = -1, std::string name = "",
+ std::string tile = "");
void check_place_cloud( cloud_type cl_type, const coord_def& p, int lifetime,
kill_category whose, killer_type killer,
- int spread_rate = -1 );
+ int spread_rate = -1,
+ int colour = -1, std::string name = "",
+ std::string tile = "");
void place_cloud( cloud_type cl_type, const coord_def& ctarget,
- int cl_range, kill_category whose, int spread_rate = -1 );
+ int cl_range, kill_category whose, int spread_rate = -1,
+ int colour = -1, std::string name = "",
+ std::string tile = "");
void place_cloud( cloud_type cl_type, const coord_def& ctarget,
- int cl_range, killer_type killer, int spread_rate = -1 );
+ int cl_range, killer_type killer, int spread_rate = -1,
+ int colour = -1, std::string name = "",
+ std::string tile = "");
void place_cloud( cloud_type cl_type, const coord_def& ctarget,
int cl_range, kill_category whose, killer_type killer,
- int spread_rate = -1 );
+ int spread_rate = -1, int colour = -1, std::string name = "",
+ std::string tile = "");
void manage_clouds(void);
@@ -61,6 +72,7 @@ int resist_fraction(int resist, int bonus_res = 0);
int max_cloud_damage(cloud_type cl_type, int power = -1);
void in_a_cloud(void);
+std::string cloud_name(int cloudno);
std::string cloud_name(cloud_type type);
int get_cloud_colour(int cloudno);
diff --git a/crawl-ref/source/dat/clua/lm_fog.lua b/crawl-ref/source/dat/clua/lm_fog.lua
index 17b80e652e..ace95fec53 100644
--- a/crawl-ref/source/dat/clua/lm_fog.lua
+++ b/crawl-ref/source/dat/clua/lm_fog.lua
@@ -52,6 +52,10 @@
-- start_clouds: The number of clouds to lay when the level containing
-- the cloud machine is entered. This is necessary since clouds
-- are cleared when the player leaves a level.
+-- colour: A string value with which to recolour the cloud.
+-- name: A string value with which to rebrand (specifically, rename) the
+-- cloud in question.
+-- tile: A string value with which to retile the cloud.
-- listener: A table with a function field called 'func'. Will be called
-- whenever the countdown is activated, and whenever the fog
-- machine is reset. It will be called with a reference to the table,
@@ -100,6 +104,9 @@ function FogMachine:new(pars)
m.size_max = pars.size_max or pars.size
m.spread_rate = pars.spread_rate or -1
m.start_clouds = pars.start_clouds or 1
+ m.colour = pars.colour or ""
+ m.name = pars.name or ""
+ m.tile = pars.tile or ""
m.size_buildup_amnt = pars.size_buildup_amnt or 0
m.size_buildup_time = pars.size_buildup_time or 1
@@ -125,9 +132,10 @@ function FogMachine:new(pars)
end
function FogMachine:apply_cloud(point, pow_min, pow_max, pow_rolls,
- size, cloud_type, kill_cat, spread)
+ size, cloud_type, kill_cat, spread, colour,
+ name, tile)
dgn.apply_area_cloud(point.x, point.y, pow_min, pow_max, pow_rolls, size,
- cloud_type, kill_cat, spread)
+ cloud_type, kill_cat, spread, colour, name, tile)
end
function FogMachine:do_fog(point)
@@ -165,7 +173,8 @@ function FogMachine:do_fog(point)
self:apply_cloud(p, self.pow_min, self.pow_max, self.pow_rolls,
crawl.random_range(size_min, size_max, 1),
- self.cloud_type, self.kill_cat, spread)
+ self.cloud_type, self.kill_cat, spread, self.colour,
+ self.name, self.tile)
end
function FogMachine:do_trigger(triggerer, marker, ev)
@@ -225,6 +234,9 @@ function FogMachine:write(marker, th)
file.marshall(th, self.spread_buildup_amnt)
file.marshall(th, self.spread_buildup_time)
file.marshall(th, self.buildup_turns)
+ file.marshall(th, self.colour)
+ file.marshall(th, self.name)
+ file.marshall(th, self.tile)
end
function FogMachine:read(marker, th)
@@ -245,6 +257,9 @@ function FogMachine:read(marker, th)
self.spread_buildup_amnt = file.unmarshall_number(th)
self.spread_buildup_time = file.unmarshall_number(th)
self.buildup_turns = file.unmarshall_number(th)
+ self.colour = file.unmarshall_string(th)
+ self.name = file.unmarshall_string(th)
+ self.tile = file.unmarshall_string(th)
setmetatable(self, FogMachine)
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 9807ec54dc..3b0a1262b3 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -3418,10 +3418,9 @@ static void _describe_cell(const coord_def& where, bool in_range)
if (env.cgrid(where) != EMPTY_CLOUD)
{
const int cloud_inspected = env.cgrid(where);
- const cloud_type ctype = (cloud_type) env.cloud[cloud_inspected].type;
mprf(MSGCH_EXAMINE, "There is a cloud of %s here.",
- cloud_name(ctype).c_str());
+ cloud_name(cloud_inspected).c_str());
cloud_described = true;
}
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index e1a8083ef3..c3eb240a16 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -257,9 +257,13 @@ struct cloud_struct
unsigned char spread_rate;
kill_category whose;
killer_type killer;
+ int colour;
+ std::string name;
+ std::string tile;
cloud_struct() : pos(), type(CLOUD_NONE), decay(0), spread_rate(0),
- whose(KC_OTHER), killer(KILL_NONE)
+ whose(KC_OTHER), killer(KILL_NONE), colour(-1),
+ name(""), tile("")
{
}
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index 99035d37f0..dddb216da4 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -1173,14 +1173,16 @@ static int lua_cloud_pow_rolls;
static int make_a_lua_cloud(coord_def where, int garbage, int spread_rate,
cloud_type ctype, kill_category whose,
- killer_type killer)
+ killer_type killer, int colour, std::string name,
+ std::string tile)
{
UNUSED( garbage );
const int pow = random_range(lua_cloud_pow_min,
lua_cloud_pow_max,
lua_cloud_pow_rolls);
- place_cloud( ctype, where, pow, whose, killer, spread_rate );
+ place_cloud( ctype, where, pow, whose, killer, spread_rate, colour, name,
+ tile );
return 1;
}
@@ -1200,6 +1202,10 @@ static int dgn_apply_area_cloud(lua_State *ls)
const int spread_rate = lua_isnumber(ls, 9) ? luaL_checkint(ls, 9) : -1;
+ const int colour = lua_isstring(ls, 10) ? str_to_colour(luaL_checkstring(ls, 10)) : -1;
+ std::string name = lua_isstring(ls, 11) ? luaL_checkstring(ls, 11) : "";
+ std::string tile = lua_isstring(ls, 12) ? luaL_checkstring(ls, 12) : "";
+
if (!in_bounds(x, y))
{
char buf[80];
@@ -1265,7 +1271,7 @@ static int dgn_apply_area_cloud(lua_State *ls)
apply_area_cloud(make_a_lua_cloud, coord_def(x, y), 0, size,
ctype, kc, cloud_struct::whose_to_killer(kc),
- spread_rate);
+ spread_rate, colour, name, tile);
return (0);
}
@@ -1282,6 +1288,10 @@ static int dgn_place_cloud(lua_State *ls)
const int spread_rate = lua_isnumber(ls, 6) ? luaL_checkint(ls, 6) : -1;
+ const int colour = lua_isstring(ls, 7) ? str_to_colour(luaL_checkstring(ls, 7)) : -1;
+ std::string name = lua_isstring(ls, 8) ? luaL_checkstring(ls, 8) : "";
+ std::string tile = lua_isstring(ls, 9) ? luaL_checkstring(ls, 9) : "";
+
if (!in_bounds(x, y))
{
char buf[80];
@@ -1315,7 +1325,7 @@ static int dgn_place_cloud(lua_State *ls)
return (0);
}
- place_cloud(ctype, coord_def(x, y), cl_range, kc, spread_rate);
+ place_cloud(ctype, coord_def(x, y), cl_range, kc, spread_rate, colour, name, tile);
return (0);
}
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 3312bfcf94..b5c9e6bb40 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2889,14 +2889,15 @@ bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range)
// check clouds
if (in_bounds(you.pos()) && env.cgrid(you.pos()) != EMPTY_CLOUD)
{
- const cloud_type type = env.cloud[env.cgrid(you.pos())].type;
+ const int cloudidx = env.cgrid(you.pos());
+ const cloud_type type = env.cloud[cloudidx].type;
if (is_damaging_cloud(type, want_move))
{
if (announce)
{
mprf(MSGCH_WARN, "You're standing in a cloud of %s!",
- cloud_name(type).c_str());
+ cloud_name(cloudidx).c_str());
}
return (false);
}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e7e54c63d6..f16b6742c6 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -165,7 +165,7 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift,
{
std::string prompt = make_stringf(
"Really step into that cloud of %s?",
- cloud_name(ctype).c_str());
+ cloud_name(cloud).c_str());
if (!yesno(prompt.c_str(), false, 'n'))
{
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index d6c3ff577a..c37901d7e0 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -273,8 +273,7 @@ void show_def::_update_cloud(int cloudno)
grid(e).colour = which_colour;
#ifdef USE_TILE
- tile_place_cloud(e.x, e.y, env.cloud[cloudno].type,
- env.cloud[cloudno].decay);
+ tile_place_cloud(e.x, e.y, env.cloud[cloudno]);
#endif
}
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 647077f2f4..f6dd4009a3 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -661,29 +661,32 @@ bool stinking_cloud( int pow, bolt &beem )
int cast_big_c(int pow, cloud_type cty, kill_category whose, bolt &beam)
{
- big_cloud( cty, whose, beam.target, pow, 8 + random2(3) );
+ big_cloud( cty, whose, beam.target, pow, 8 + random2(3), -1 );
return (1);
}
void big_cloud(cloud_type cl_type, kill_category whose,
- const coord_def& where, int pow, int size, int spread_rate)
+ const coord_def& where, int pow, int size, int spread_rate,
+ int colour, std::string name, std::string tile)
{
big_cloud(cl_type, whose, cloud_struct::whose_to_killer(whose),
- where, pow, size, spread_rate);
+ where, pow, size, spread_rate, colour, name, tile);
}
void big_cloud(cloud_type cl_type, killer_type killer,
- const coord_def& where, int pow, int size, int spread_rate)
+ const coord_def& where, int pow, int size, int spread_rate,
+ int colour, std::string name, std::string tile)
{
big_cloud(cl_type, cloud_struct::killer_to_whose(killer), killer,
- where, pow, size, spread_rate);
+ where, pow, size, spread_rate, colour, name, tile);
}
void big_cloud(cloud_type cl_type, kill_category whose, killer_type killer,
- const coord_def& where, int pow, int size, int spread_rate)
+ const coord_def& where, int pow, int size, int spread_rate,
+ int colour, std::string name, std::string tile)
{
apply_area_cloud(make_a_normal_cloud, where, pow, size,
- cl_type, whose, killer, spread_rate);
+ cl_type, whose, killer, spread_rate, colour, name, tile);
}
static bool _mons_hostile(const monsters *mon)
diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h
index 8368947f03..b342b71684 100644
--- a/crawl-ref/source/spells1.h
+++ b/crawl-ref/source/spells1.h
@@ -21,11 +21,14 @@ void remove_divine_stamina();
bool cast_vitalisation();
void big_cloud(cloud_type cl_type, kill_category whose, const coord_def& where,
- int pow, int size, int spread_rate = -1);
+ int pow, int size, int spread_rate = -1, int colour = -1,
+ std::string name = "", std::string tile = "");
void big_cloud(cloud_type cl_type, killer_type killer, const coord_def& where,
- int pow, int size, int spread_rate = -1);
+ int pow, int size, int spread_rate = -1, int colour = -1,
+ std::string name = "", std::string tile = "");
void big_cloud(cloud_type cl_type, kill_category whose, killer_type killer,
- const coord_def& where, int pow, int size, int spread_rate = -1);
+ const coord_def& where, int pow, int size, int spread_rate = -1,
+ int colour = -1, std::string name = "", std::string tile = "");
int blink(int pow, bool high_level_controlled_blink, bool wizard_blink = false);
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 6819599ee5..6fbb55f399 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -879,14 +879,15 @@ void cast_dispersal(int pow)
int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
cloud_type ctype, kill_category whose,
- killer_type killer)
+ killer_type killer, int colour, std::string name,
+ std::string tile)
{
if (killer == KILL_NONE)
killer = cloud_struct::whose_to_killer(whose);
place_cloud( ctype, where,
(3 + random2(pow / 4) + random2(pow / 4) + random2(pow / 4)),
- whose, killer, spread_rate );
+ whose, killer, spread_rate, colour, name, tile );
return 1;
}
diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h
index fbadac0203..cd977e3d01 100644
--- a/crawl-ref/source/spells4.h
+++ b/crawl-ref/source/spells4.h
@@ -16,7 +16,8 @@ struct bolt;
bool backlight_monsters(coord_def where, int pow, int garbage);
int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
cloud_type ctype, kill_category,
- killer_type killer = KILL_NONE);
+ killer_type killer = KILL_NONE, int colour = -1,
+ std::string name = "", std::string tile = "");
int disperse_monsters(coord_def where, int pow);
void remove_condensation_shield();
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 2f32ea67e1..75d7264e07 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -73,7 +73,8 @@ static struct spell_desc *_seekspell(spell_type spellid);
static bool _cloud_helper(cloud_func func, const coord_def& where,
int pow, int spread_rate,
cloud_type ctype, kill_category whose,
- killer_type killer);
+ killer_type killer, int colour,
+ std::string name, std::string tile);
//
// BEGIN PUBLIC FUNCTIONS
@@ -677,13 +678,14 @@ int apply_area_within_radius(cell_func cf, const coord_def& where,
void apply_area_cloud( cloud_func func, const coord_def& where,
int pow, int number, cloud_type ctype,
kill_category whose, killer_type killer,
- int spread_rate )
+ int spread_rate, int colour, std::string name,
+ std::string tile)
{
int good_squares = 0;
int neighbours[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (number && _cloud_helper(func, where, pow, spread_rate, ctype, whose,
- killer))
+ killer, colour, name, tile))
number--;
if (number == 0)
@@ -703,7 +705,8 @@ void apply_area_cloud( cloud_func func, const coord_def& where,
{
const int aux = arrs[m][i];
if ( _cloud_helper(func, where + Compass[aux],
- pow, spread_rate, ctype, whose, killer))
+ pow, spread_rate, ctype, whose, killer, colour,
+ name, tile))
{
number--;
good_squares++;
@@ -729,7 +732,7 @@ void apply_area_cloud( cloud_func func, const coord_def& where,
number -= spread;
good_squares--;
apply_area_cloud(func, where + Compass[j], pow, spread, ctype, whose,
- killer, spread_rate);
+ killer, spread_rate, colour, name, tile);
}
}
@@ -893,11 +896,13 @@ bool is_valid_spell(spell_type spell)
static bool _cloud_helper(cloud_func func, const coord_def& where,
int pow, int spread_rate,
cloud_type ctype, kill_category whose,
- killer_type killer)
+ killer_type killer, int colour, std::string name,
+ std::string tile)
{
if (!feat_is_solid(grd(where)) && env.cgrid(where) == EMPTY_CLOUD)
{
- func(where, pow, spread_rate, ctype, whose, killer);
+ func(where, pow, spread_rate, ctype, whose, killer, colour, name,
+ tile);
return (true);
}
diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h
index 8ff8e4ceeb..eb44f4db07 100644
--- a/crawl-ref/source/spl-util.h
+++ b/crawl-ref/source/spl-util.h
@@ -80,7 +80,8 @@ const char* spelltype_long_name( int which_spelltype );
typedef int cell_func(coord_def where, int pow, int aux, actor *agent);
typedef int cloud_func(coord_def where, int pow, int spreadrate,
cloud_type type, kill_category whose,
- killer_type killer);
+ killer_type killer, int colour, std::string name,
+ std::string tile);
int apply_area_visible(cell_func cf, int power,
bool pass_through_trans = false, actor *agent = NULL);
@@ -104,7 +105,8 @@ int apply_area_within_radius(cell_func cf, const coord_def& where,
void apply_area_cloud(cloud_func func, const coord_def& where,
int pow, int number, cloud_type ctype,
kill_category kc, killer_type killer,
- int spread_rate = -1);
+ int spread_rate = -1, int colour = -1,
+ std::string name = "", std::string tile = "");
bool spell_direction( dist &spelld, bolt &pbolt,
targetting_type restrict = DIR_NONE,
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index c092062c23..8a90a4ee00 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -1803,6 +1803,9 @@ static void tag_construct_level(writer &th)
marshallByte(th, (char) env.cloud[i].spread_rate);
marshallByte(th, env.cloud[i].whose);
marshallByte(th, env.cloud[i].killer);
+ marshallShort(th, env.cloud[i].colour);
+ marshallString(th, env.cloud[i].name);
+ marshallString(th, env.cloud[i].tile);
}
// how many shops?
@@ -2201,6 +2204,9 @@ static void tag_read_level( reader &th, char minorVersion )
env.cloud[i].spread_rate = (unsigned char) unmarshallByte(th);
env.cloud[i].whose = static_cast<kill_category>(unmarshallByte(th));
env.cloud[i].killer = static_cast<killer_type>(unmarshallByte(th));
+ env.cloud[i].colour = unmarshallShort(th);
+ env.cloud[i].name = unmarshallString(th);
+ env.cloud[i].tile = unmarshallString(th);
}
// how many shops?
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index e7877dfd6f..3ecacbbcd1 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -40,7 +40,7 @@ enum tag_file_type // file types supported by tag system
enum tag_major_version
{
TAG_MAJOR_START = 5,
- TAG_MAJOR_VERSION = 11
+ TAG_MAJOR_VERSION = 12
};
// Minor version will be reset to zero when major version changes.
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index 36b3e5014c..34cbf7eb7f 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -2649,64 +2649,89 @@ int tileidx_feature(dungeon_feature_type feat, int gx, int gy)
}
}
-static int _tileidx_cloud(int type, int decay)
+static int _tileidx_cloud(cloud_struct cl)
{
+ int type = cl.type;
+ int decay = cl.decay;
+ std::string override = cl.tile;
+ int colour = cl.colour;
+
int ch = TILE_ERROR;
int dur = decay/20;
if (dur > 2)
dur = 2;
- switch (type)
+ if (!override.empty())
{
- case CLOUD_FIRE:
- ch = TILE_CLOUD_FIRE_0 + dur;
- break;
+ unsigned int index;
+ if (!tile_main_index(override.c_str(), index))
+ {
+ mprf(MSGCH_ERROR, "Invalid tile requested for cloud: '%s'.", override.c_str());
+ }
+ else
+ {
+ int offset = tile_main_count(index);
+ ch = index + offset;
+ }
+ }
+ else
+ {
+ switch (type)
+ {
+ case CLOUD_FIRE:
+ ch = TILE_CLOUD_FIRE_0 + dur;
+ break;
- case CLOUD_COLD:
- ch = TILE_CLOUD_COLD_0 + dur;
- break;
+ case CLOUD_COLD:
+ ch = TILE_CLOUD_COLD_0 + dur;
+ break;
- case CLOUD_STINK:
- case CLOUD_POISON:
- ch = TILE_CLOUD_POISON_0 + dur;
- break;
+ case CLOUD_STINK:
+ case CLOUD_POISON:
+ ch = TILE_CLOUD_POISON_0 + dur;
+ break;
- case CLOUD_BLUE_SMOKE:
- ch = TILE_CLOUD_BLUE_SMOKE;
- break;
+ case CLOUD_BLUE_SMOKE:
+ ch = TILE_CLOUD_BLUE_SMOKE;
+ break;
- case CLOUD_PURPLE_SMOKE:
- case CLOUD_TLOC_ENERGY:
- ch = TILE_CLOUD_TLOC_ENERGY;
- break;
+ case CLOUD_PURPLE_SMOKE:
+ case CLOUD_TLOC_ENERGY:
+ ch = TILE_CLOUD_TLOC_ENERGY;
+ break;
- case CLOUD_MIASMA:
- ch = TILE_CLOUD_MIASMA;
- break;
+ case CLOUD_MIASMA:
+ ch = TILE_CLOUD_MIASMA;
+ break;
- case CLOUD_BLACK_SMOKE:
- ch = TILE_CLOUD_BLACK_SMOKE;
- break;
+ case CLOUD_BLACK_SMOKE:
+ ch = TILE_CLOUD_BLACK_SMOKE;
+ break;
- case CLOUD_MUTAGENIC:
- ch = (dur == 0 ? TILE_CLOUD_MUTAGENIC_0 :
- dur == 1 ? TILE_CLOUD_MUTAGENIC_1
- : TILE_CLOUD_MUTAGENIC_2);
- ch += random2(tile_main_count(ch));
- break;
+ case CLOUD_MUTAGENIC:
+ ch = (dur == 0 ? TILE_CLOUD_MUTAGENIC_0 :
+ dur == 1 ? TILE_CLOUD_MUTAGENIC_1
+ : TILE_CLOUD_MUTAGENIC_2);
+ ch += random2(tile_main_count(ch));
+ break;
- case CLOUD_MIST:
- ch = TILE_CLOUD_MIST;
- break;
+ case CLOUD_MIST:
+ ch = TILE_CLOUD_MIST;
+ break;
- case CLOUD_RAIN:
- ch = TILE_CLOUD_RAIN + random2(tile_main_count(TILE_CLOUD_RAIN));
- break;
+ case CLOUD_RAIN:
+ ch = TILE_CLOUD_RAIN + random2(tile_main_count(TILE_CLOUD_RAIN));
+ break;
- default:
- ch = TILE_CLOUD_GREY_SMOKE;
- break;
+ default:
+ ch = TILE_CLOUD_GREY_SMOKE;
+ break;
+ }
}
+
+ if (colour != -1)
+ ch = tile_main_coloured(ch, colour);
+
return (ch | TILE_FLAG_FLYING);
}
@@ -4852,9 +4877,9 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected)
}
}
-void tile_place_cloud(int x, int y, int type, int decay)
+void tile_place_cloud(int x, int y, cloud_struct cl)
{
- env.tile_fg[x][y] = _tileidx_cloud(type, decay);
+ env.tile_fg[x][y] = _tileidx_cloud(cl);
}
unsigned int num_tile_rays = 0;
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 753ea5be30..82ed562c56 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1541,10 +1541,8 @@ int DungeonRegion::handle_mouse(MouseEvent &event)
const int cloudidx = env.cgrid(gc);
if (cloudidx != EMPTY_CLOUD)
{
- cloud_type ctype = env.cloud[cloudidx].type;
-
std::string terrain_desc = desc;
- desc = cloud_name(ctype);
+ desc = cloud_name(cloudidx);
if (!terrain_desc.empty())
desc += "\n" + terrain_desc;
@@ -1937,9 +1935,7 @@ bool DungeonRegion::update_alt_text(std::string &alt)
const int cloudidx = env.cgrid(gc);
if (cloudidx != EMPTY_CLOUD)
{
- cloud_type ctype = env.cloud[cloudidx].type;
-
- inf.prefix = "There is a cloud of " + cloud_name(ctype)
+ inf.prefix = "There is a cloud of " + cloud_name(cloudidx)
+ " here.$$";
}
}
diff --git a/crawl-ref/source/tiles.h b/crawl-ref/source/tiles.h
index d938715e55..2f1028b72d 100644
--- a/crawl-ref/source/tiles.h
+++ b/crawl-ref/source/tiles.h
@@ -74,7 +74,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground = true,
bool detected = false);
void tile_place_item(int x, int y, int idx);
void tile_place_item_marker(int x, int y, int idx);
-void tile_place_cloud(int x, int y, int type, int decay);
+void tile_place_cloud(int x, int y, cloud_struct cl);
void tile_place_ray(const coord_def& gc, bool in_range);
void tile_draw_rays(bool resetCount);
void tile_clear_buf();
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 6893f64262..7f6bc68bc8 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -4440,7 +4440,7 @@ static void _tutorial_describe_cloud(int x, int y)
if (ctype == CLOUD_NONE)
return;
- std::string cname = cloud_name(ctype);
+ std::string cname = cloud_name(env.cgrid(coord_def(x, y)));
std::ostringstream ostr;