summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorNo Name <remoit(DOT)nane(AT)gmail(DOT)com>2010-04-04 05:24:55 -0700
committerJared Adams <jaxad0127@gmail.com>2010-04-04 18:47:48 -0600
commit8d9fe31ed15fb9ce681d6cfe783fd9c4af646d16 (patch)
treead2c4884daff963a177c093267c57708f4cdd21e /src/map/script.c
parent6d2fb0bf050c95a6ea1dbed09c7faef05b77253f (diff)
downloadtmwa-8d9fe31ed15fb9ce681d6cfe783fd9c4af646d16.tar.gz
tmwa-8d9fe31ed15fb9ce681d6cfe783fd9c4af646d16.tar.bz2
tmwa-8d9fe31ed15fb9ce681d6cfe783fd9c4af646d16.tar.xz
tmwa-8d9fe31ed15fb9ce681d6cfe783fd9c4af646d16.zip
Add npcwarp script function to allow an NPC to warp to a new position on its map.
This patch models its behavior partly on that of movenpc and the atcommand npcmove.
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 0ede96c..5bf6fa5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -300,6 +300,7 @@ int buildin_specialeffect2 (struct script_state *st); // special effect script
int buildin_nude (struct script_state *st); // nude [Valaris]
int buildin_gmcommand (struct script_state *st); // [MouseJstr]
int buildin_movenpc (struct script_state *st); // [MouseJstr]
+int buildin_npcwarp (struct script_state *st); // [remoitnane]
int buildin_message (struct script_state *st); // [MouseJstr]
int buildin_npctalk (struct script_state *st); // [Valaris]
int buildin_hasitems (struct script_state *st); // [Valaris]
@@ -702,6 +703,8 @@ struct
buildin_gmcommand, "gmcommand", "*"}, // [MouseJstr]
// {buildin_movenpc,"movenpc","siis"}, // [MouseJstr]
{
+ buildin_npcwarp, "npcwarp", "iis"}, // [remoitnane]
+ {
buildin_message, "message", "s*"}, // [MouseJstr]
{
buildin_npctalk, "npctalk", "*"}, // [Valaris]
@@ -6802,6 +6805,41 @@ int buildin_movenpc (struct script_state *st)
}
/*==========================================
+ * npcwarp [remoitnane]
+ * Move NPC to a new position on the same map.
+ *------------------------------------------
+ */
+int buildin_npcwarp (struct script_state *st)
+{
+ int x, y;
+ char *npc;
+ struct npc_data *nd = NULL;
+
+ x = conv_num (st, &(st->stack->stack_data[st->start + 2]));
+ y = conv_num (st, &(st->stack->stack_data[st->start + 3]));
+ npc = conv_str (st, &(st->stack->stack_data[st->start + 4]));
+ nd = npc_name2id (npc);
+
+ if (!nd)
+ return -1;
+
+ short m = nd->bl.m;
+
+ /* Crude sanity checks. */
+ if (m < 0 || !nd->bl.prev
+ || x < 0 || x > map[m].xs -1
+ || y < 0 || y > map[m].ys - 1)
+ return -1;
+
+ npc_enable (npc, 0);
+ nd->bl.x = x;
+ nd->bl.y = y;
+ npc_enable (npc, 1);
+
+ return 0;
+}
+
+/*==========================================
* message [MouseJstr]
*------------------------------------------
*/