summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-25 13:22:48 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-25 13:22:48 +1000
commite711d4b1bb15d82886af6fbf557d63e74f2b5fd0 (patch)
tree2d52b0ebf028be58db570f87e7282d0ff1fbb6f4
parent750012d6a9fc992d5651acd58a4eaff69dac106c (diff)
downloadcrawl-ref-e711d4b1bb15d82886af6fbf557d63e74f2b5fd0.tar.gz
crawl-ref-e711d4b1bb15d82886af6fbf557d63e74f2b5fd0.zip
A start at a dLua spells library.
Provides wrappers for non-player Toxic Radiance and Ozocubu's Refrigeration. These are basically just an adjustment of kill categories and messages to allow them to be used as background effects in WizLabs (Ozocubu's and Olgreb's). Hopefully a wrapper for monster (and possibly player)-cast bolt structures can also be included, which could then be accessed with the (planned) Lua traps functionality.
-rw-r--r--crawl-ref/source/dlua.cc1
-rw-r--r--crawl-ref/source/l_feat.cc2
-rw-r--r--crawl-ref/source/l_libs.h1
-rw-r--r--crawl-ref/source/l_spells.cc30
-rw-r--r--crawl-ref/source/makefile.obj1
-rw-r--r--crawl-ref/source/spells2.cc31
-rw-r--r--crawl-ref/source/spells2.h4
7 files changed, 59 insertions, 11 deletions
diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc
index dec579a9a1..218819a4d5 100644
--- a/crawl-ref/source/dlua.cc
+++ b/crawl-ref/source/dlua.cc
@@ -284,6 +284,7 @@ void init_dungeon_lua()
luaL_openlib(dlua, "dgn", dgn_subvault_dlib, 0);
luaL_openlib(dlua, "dgn", dgn_tile_dlib, 0);
luaL_openlib(dlua, "feat", feat_dlib, 0);
+ luaL_openlib(dlua, "spells", spells_dlib, 0);
luaL_openlib(dlua, "debug", debug_dlib, 0);
luaL_openlib(dlua, "los", los_dlib, 0);
diff --git a/crawl-ref/source/l_feat.cc b/crawl-ref/source/l_feat.cc
index a9ae861a14..00529c11dc 100644
--- a/crawl-ref/source/l_feat.cc
+++ b/crawl-ref/source/l_feat.cc
@@ -1,5 +1,5 @@
/*
- * File: l_featfeat.cc
+ * File: l_feat.cc
* Summary: Boolean feat-related functions lua library "feat".
*/
diff --git a/crawl-ref/source/l_libs.h b/crawl-ref/source/l_libs.h
index 0d7484fe75..d09434be0c 100644
--- a/crawl-ref/source/l_libs.h
+++ b/crawl-ref/source/l_libs.h
@@ -51,6 +51,7 @@ extern const struct luaL_reg dgn_mons_dlib[];
extern const struct luaL_reg dgn_subvault_dlib[];
extern const struct luaL_reg dgn_tile_dlib[];
extern const struct luaL_reg feat_dlib[];
+extern const struct luaL_reg spells_dlib[];
extern const struct luaL_reg los_dlib[];
extern const struct luaL_reg mapmarker_dlib[];
diff --git a/crawl-ref/source/l_spells.cc b/crawl-ref/source/l_spells.cc
new file mode 100644
index 0000000000..8e5c2feffa
--- /dev/null
+++ b/crawl-ref/source/l_spells.cc
@@ -0,0 +1,30 @@
+/*
+ * File: l_spells.cc
+ * Summary: Boolean feat-related functions lua library "feat".
+ */
+
+#include "AppHdr.h"
+
+#include "clua.h"
+#include "cluautil.h"
+#include "l_libs.h"
+
+#include "coord.h"
+#include "dungeon.h"
+#include "env.h"
+#include "spells1.h"
+#include "spells2.h"
+#include "spells3.h"
+#include "spells4.h"
+#include "terrain.h"
+
+LUAWRAP(_refrigeration, cast_refrigeration(luaL_checkint(ls, 1), true))
+LUAWRAP(_toxic_radiance, cast_toxic_radiance(true))
+
+const struct luaL_reg spells_dlib[] =
+{
+{ "refrigeration", _refrigeration },
+{ "toxic_radiance", _toxic_radiance },
+{ NULL, NULL }
+};
+
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index fd38cf9783..8761eb11e7 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -79,6 +79,7 @@ l_mapmrk.o \
l_moninf.o \
l_mons.o \
l_option.o \
+l_spells.o \
l_subvault.o \
l_travel.o \
l_view.o \
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index b4e15848b8..4902786aa6 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -625,9 +625,12 @@ static std::string _describe_monsters(const counted_monster_list &list)
// Poisonous light passes right through invisible players
// and monsters, and so, they are unaffected by this spell --
// assumes only you can cast this spell (or would want to).
-void cast_toxic_radiance()
+void cast_toxic_radiance(bool non_player)
{
- mpr("You radiate a sickly green light!");
+ if (non_player)
+ mpr("The air is filled with a sickly green light!");
+ else
+ mpr("You radiate a sickly green light!");
flash_view(GREEN);
more();
@@ -655,10 +658,13 @@ void cast_toxic_radiance()
// this check should not be !monster->invisible().
if (!mi->has_ench(ENCH_INVIS))
{
+ kill_category kc = KC_YOU;
+ if (non_player)
+ kc = KC_OTHER;
bool affected =
- poison_monster(*mi, KC_YOU, 1, false, false);
+ poison_monster(*mi, kc, 1, false, false);
- if (coinflip() && poison_monster(*mi, KC_YOU, false, false))
+ if (coinflip() && poison_monster(*mi, kc, false, false))
affected = true;
if (affected)
@@ -685,14 +691,20 @@ void cast_toxic_radiance()
{
// Exclamation mark to suggest that a lot of creatures were
// affected.
- mpr("The monsters around you are poisoned!");
+ if (non_player)
+ mpr("Nearby monsters are poisoned!");
+ else
+ mpr("The monsters around you are poisoned!");
}
}
}
-void cast_refrigeration(int pow)
+void cast_refrigeration(int pow, bool non_player)
{
- mpr("The heat is drained from your surroundings.");
+ if (non_player)
+ mpr("Something drains the heat from around you.");
+ else
+ mpr("The heat is drained from your surroundings.");
flash_view(LIGHTCYAN);
more();
@@ -752,7 +764,10 @@ void cast_refrigeration(int pow)
// Calculate damage and apply.
int hurt = mons_adjust_flavoured(*mi, beam, dam_dice.roll());
- mi->hurt(&you, hurt, BEAM_COLD);
+ if (non_player)
+ mi->hurt(NULL, hurt, BEAM_COLD);
+ else
+ mi->hurt(&you, hurt, BEAM_COLD);
// Cold-blooded creatures can be slowed.
if (mi->alive()
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index c85b9ea605..64349079de 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -24,8 +24,8 @@ bool vampiric_drain(int pow, const dist &vmove);
int detect_creatures(int pow, bool telepathic = false);
int detect_items(int pow);
int detect_traps(int pow);
-void cast_refrigeration(int pow);
-void cast_toxic_radiance(void);
+void cast_refrigeration(int pow, bool non_player = false);
+void cast_toxic_radiance(bool non_player = false);
void drain_life(int pow);
bool restore_stat(unsigned char which_stat, unsigned char stat_gain,