From ff898b1d949aac48c9017e89d5f7ba5e18d65870 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Nov 2017 19:30:00 +0300 Subject: Refresh npc after changing fields in setunitdata. --- src/map/clif.c | 25 +++++++++++++++---------- src/map/npc.c | 13 +++++++++++++ src/map/npc.h | 1 + src/map/script.c | 3 ++- 4 files changed, 31 insertions(+), 11 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-60-g2f50