summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-28 22:25:17 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-28 22:25:17 +0300
commit9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3 (patch)
tree3fbf5baa988727b49010b6f62ee3d6d8ff7c51b9 /src/map
parent5a5662d5615909e2274627001fd634712dee3bde (diff)
downloadevol-hercules-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.gz
evol-hercules-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.bz2
evol-hercules-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.xz
evol-hercules-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.zip
Add script function setnpcsex.
New function: setnpcsex [names,] sex
Diffstat (limited to 'src/map')
-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