summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
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]
*------------------------------------------
*/