From 9220bec0adcd72d64e301cc9b5d6f9e1af6a4ab3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Nov 2014 22:25:17 +0300 Subject: Add script function setnpcsex. New function: setnpcsex [names,] sex --- src/map/script.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/map/script.c') 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); +} -- cgit v1.2.3-60-g2f50