summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-04-30 08:45:23 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-04-30 15:02:57 -0700
commitba57847533f1f39f90126e83bbeb544a3772e9ef (patch)
tree18d918eff01061eb251ba672b8c369073d6673dd
parentd93e795a85b8362c5971c23eeac2a48a3cae104b (diff)
downloadtmwa-ba57847533f1f39f90126e83bbeb544a3772e9ef.tar.gz
tmwa-ba57847533f1f39f90126e83bbeb544a3772e9ef.tar.bz2
tmwa-ba57847533f1f39f90126e83bbeb544a3772e9ef.tar.xz
tmwa-ba57847533f1f39f90126e83bbeb544a3772e9ef.zip
Restore fakenpcname script command
Closes: #2
-rw-r--r--src/char/char.cpp2
-rw-r--r--src/map/script.cpp24
2 files changed, 24 insertions, 2 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp
index 772adac..c3c22de 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -535,7 +535,7 @@ int mmo_char_init(void)
static
void mmo_char_sync(void)
{
- int i, j, k;
+ int i;
int lock;
FILE *fp;
diff --git a/src/map/script.cpp b/src/map/script.cpp
index a76563f..b5e2aca 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -4291,11 +4291,32 @@ void builtin_isdead(ScriptState *st)
push_val(st->stack, ScriptCode::INT, pc_isdead(sd));
}
+/*========================================
+ * Changes a NPC name, and sprite
+ *----------------------------------------
+ */
+static
+void builtin_fakenpcname(ScriptState *st)
+{
+ const char *name = conv_str(st, &(st->stack->stack_data[st->start + 2]));
+ const char *newname = conv_str(st, &(st->stack->stack_data[st->start + 3]));
+ int newsprite = conv_num(st, &(st->stack->stack_data[st->start + 4]));
+ struct npc_data *nd = npc_name2id(name);
+ if (!nd)
+ return;
+ strzcpy(nd->name, newname, sizeof(nd->name));
+ nd->npc_class = newsprite;
+
+ // Refresh this npc
+ npc_enable(name, 0);
+ npc_enable(name, 1);
+
+}
+
/*============================
* Gets the PC's x pos
*----------------------------
*/
-
static
void builtin_getx(ScriptState *st)
{
@@ -5229,6 +5250,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(shop, "s"),
BUILTIN(isdead, ""),
BUILTIN(unequipbyid, "i"),
+ BUILTIN(fakenpcname, "ssi"),
BUILTIN(getx, ""),
BUILTIN(gety, ""),
BUILTIN(getmap, ""),