summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c38
-rw-r--r--src/map/script.h1
3 files changed, 40 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 519ca02..361f019 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -79,6 +79,7 @@ HPExport void plugin_init (void)
addScriptCommand("removemapmask", "si", removeMapMask);
addScriptCommand("getmapmask", "s", getMapMask);
addScriptCommand("getnpcclass", "*", getNpcClass);
+ addScriptCommand("setnpcsex", "*", setNpcSex);
do_init_langs();
diff --git a/src/map/script.c b/src/map/script.c
index e762583..86e613e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -16,6 +16,7 @@
#include "../../../map/pc.h"
#include "../../../map/script.h"
#include "../../../map/quest.h"
+#include "../../../map/unit.h"
#include "map/script.h"
#include "map/clif.h"
@@ -534,3 +535,40 @@ BUILDIN(getNpcClass)
return true;
}
+
+BUILDIN(setNpcSex)
+{
+ struct npc_data *nd = NULL;
+ int sex = 0;
+ if (script_hasdata(st, 3))
+ {
+ nd = npc->name2id (script_getstr(st, 2));
+ sex = script_getnum(st, 3);
+ }
+ else if (script_hasdata(st, 2))
+ {
+ sex = script_getnum(st, 2);
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!nd && !st->oid)
+ {
+ return false;
+ }
+
+ if (!nd)
+ nd = (struct npc_data *) map->id2bl(st->oid);
+
+ if (!nd || !nd->vd)
+ {
+ script_pushint(st, -1);
+ return false;
+ }
+
+ clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);
+ nd->vd->sex = sex;
+ clif->spawn(&nd->bl);
+}
diff --git a/src/map/script.h b/src/map/script.h
index 36e8150..034a5cd 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -25,5 +25,6 @@ BUILDIN(getMapMask);
BUILDIN(addMapMask);
BUILDIN(removeMapMask);
BUILDIN(getNpcClass);
+BUILDIN(setNpcSex);
#endif // EVOL_MAP_SCRIPT