diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-28 22:25:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-28 22:25:17 +0300 |
commit | 9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3 (patch) | |
tree | 3fbf5baa988727b49010b6f62ee3d6d8ff7c51b9 /src/map/script.c | |
parent | 5a5662d5615909e2274627001fd634712dee3bde (diff) | |
download | plugin-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.gz plugin-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.bz2 plugin-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.tar.xz plugin-9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3.zip |
Add script function setnpcsex.
New function: setnpcsex [names,] sex
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 38 |
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); +} |