summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-11-02 19:30:00 +0300
committerAndrei Karas <akaras@inbox.ru>2017-11-04 23:24:24 +0300
commitff898b1d949aac48c9017e89d5f7ba5e18d65870 (patch)
tree1dd52678af736ede65b36b165b2032bac10b2954 /src
parent497a25b19d58ace8e450614f0b6cab433a040428 (diff)
downloadhercules-ff898b1d949aac48c9017e89d5f7ba5e18d65870.tar.gz
hercules-ff898b1d949aac48c9017e89d5f7ba5e18d65870.tar.bz2
hercules-ff898b1d949aac48c9017e89d5f7ba5e18d65870.tar.xz
hercules-ff898b1d949aac48c9017e89d5f7ba5e18d65870.zip
Refresh npc after changing fields in setunitdata.
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c25
-rw-r--r--src/map/npc.c13
-rw-r--r--src/map/npc.h1
-rw-r--r--src/map/script.c3
4 files changed, 31 insertions, 11 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index f17ee14e6..4dc36be6d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -3345,17 +3345,22 @@ void clif_changelook(struct block_list *bl,int type,int val)
#if PACKETVER < 4
clif->sendlook(bl, bl->id, type, val, 0, target);
#else
- if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
- nullpo_retv(vd);
- type = LOOK_WEAPON;
- val = vd->weapon;
- val2 = vd->shield;
- }
- if (clif->isdisguised(bl)) {
- clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
- clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ if (bl->type != BL_NPC) {
+ if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
+ nullpo_retv(vd);
+ type = LOOK_WEAPON;
+ val = vd->weapon;
+ val2 = vd->shield;
+ }
+ if (clif->isdisguised(bl)) {
+ clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
+ clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ } else {
+ clif->sendlook(bl, bl->id, type, val, val2, target);
+ }
} else {
- clif->sendlook(bl, bl->id, type, val, val2, target);
+ struct npc_data *nd = BL_UCAST(BL_NPC, bl);
+ npc->refresh(nd);
}
#endif
}
diff --git a/src/map/npc.c b/src/map/npc.c
index c9edb2595..0702b2525 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -3659,6 +3659,18 @@ void npc_setclass(struct npc_data* nd, short class_) {
clif->spawn(&nd->bl);// fade in
}
+void npc_refresh(struct npc_data* nd)
+{
+ nullpo_retv(nd);
+
+ if (map->list[nd->bl.m].users) {
+ // using here CLR_TRICKDEAD because other flags show effects.
+ // probably need use other flag or other way to refresh npc.
+ clif->clearunit_area(&nd->bl, CLR_TRICKDEAD); // fade out
+ clif->spawn(&nd->bl); // fade in
+ }
+}
+
// @commands (script based)
int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname)
{
@@ -5196,4 +5208,5 @@ void npc_defaults(void) {
npc->market_delfromsql = npc_market_delfromsql;
npc->market_delfromsql_sub = npc_market_delfromsql_sub;
npc->db_checkid = npc_db_checkid;
+ npc->refresh = npc_refresh;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 68ab18820..8bb38f252 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -309,6 +309,7 @@ struct npc_interface {
void (*market_delfromsql) (struct npc_data *nd, unsigned short index);
void (*market_delfromsql_sub) (const char *npcname, unsigned short index);
bool (*db_checkid) (const int id);
+ void (*refresh) (struct npc_data* nd);
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
diff --git a/src/map/script.c b/src/map/script.c
index bbaa5f6ed..5773457a7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -19158,7 +19158,8 @@ BUILDIN(setunitdata)
nd->status.dmotion = (unsigned short) val;
break;
case UDT_SEX:
- nd->vd.sex = (char) val;
+ nd->vd.sex = (char)val;
+ npc->refresh(nd);
break;
case UDT_HAIRSTYLE:
clif->changelook(bl, LOOK_HAIR, val);