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 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);
+}