From 6edc930f4ac192c7c033356f66d36ab9739027c6 Mon Sep 17 00:00:00 2001 From: Atemo Date: Sun, 26 May 2024 00:10:38 +0200 Subject: [PATCH] WZ_ESTIMATION --- src/map/clif.cpp | 54 +++++++++++++++++---------------------- src/map/clif.hpp | 2 +- src/map/clif_packetdb.hpp | 1 - src/map/packets.hpp | 22 ++++++++++++++++ src/map/skill.cpp | 3 ++- 5 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 65a65e6988..da14c2bb50 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -6261,39 +6261,33 @@ void clif_skill_teleportmessage( map_session_data& sd, e_notify_mapinfo_result r } -/// Displays Sense (WZ_ESTIMATION) information window (ZC_MONSTER_INFO). +/// Displays Sense (WZ_ESTIMATION) information window. /// 018c .W .W .W .L .W .W .W .W -/// .B .B .B .B .B .B .B .B .B -void clif_skill_estimation(map_session_data *sd,struct block_list *dst) -{ - struct status_data *status; - unsigned char buf[64]; - int i, fix; +/// .B .B .B .B .B .B .B .B .B (ZC_MONSTER_INFO) +void clif_skill_estimation( map_session_data& sd, mob_data& md ){ + PACKET_ZC_MONSTER_INFO packet{}; - nullpo_retv(sd); - nullpo_retv(dst); + packet.packetType = HEADER_ZC_MONSTER_INFO; + packet.class_ = md.vd->class_; + packet.level = static_cast( md.level ); + packet.size = md.status.size; + packet.hp = md.status.hp; + packet.def = static_cast( ((battle_config.estimation_type&1) ? md.status.def : 0 ) + ((battle_config.estimation_type&2) ? md.status.def2 : 0 ) ); + packet.race = md.status.race; + packet.mdef = static_cast( ((battle_config.estimation_type&1) ? md.status.mdef : 0 ) + ((battle_config.estimation_type&2) ? md.status.mdef2 : 0 ) ); + packet.element = md.status.def_ele; + // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] + packet.water = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 1, md.status.def_ele), (int16)0 ) ); + packet.earth = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 2, md.status.def_ele), (int16)0 ) ); + packet.fire = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 3, md.status.def_ele), (int16)0 ) ); + packet.wind = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 4, md.status.def_ele), (int16)0 ) ); + packet.poison = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 5, md.status.def_ele), (int16)0 ) ); + packet.holy = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 6, md.status.def_ele), (int16)0 ) ); + packet.shadow = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 7, md.status.def_ele), (int16)0 ) ); + packet.ghost = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 8, md.status.def_ele), (int16)0 ) ); + packet.undead = static_cast( std::max( elemental_attribute_db.getAttribute(md.status.ele_lv, 9, md.status.def_ele), (int16)0 ) ); - if( dst->type != BL_MOB ) - return; - - status = status_get_status_data(dst); - - WBUFW(buf, 0)=0x18c; - WBUFW(buf, 2)=status_get_class(dst); - WBUFW(buf, 4)=status_get_lv(dst); - WBUFW(buf, 6)=status->size; - WBUFL(buf, 8)=status->hp; - WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0) - +(battle_config.estimation_type&2?status->def2:0); - WBUFW(buf,14)=status->race; - WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0) - +(battle_config.estimation_type&2?status->mdef2:0); - WBUFW(buf,18)= status->def_ele; - for(i=0;i<9;i++) -// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] - WBUFB(buf,20+i)= (unsigned char)((fix=elemental_attribute_db.getAttribute(status->ele_lv, i+1, status->def_ele))<0?0:fix); - - clif_send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF); + clif_send( &packet, sizeof( packet ), &sd.bl, (sd.status.party_id > 0) ? PARTY_SAMEMAP : SELF ); } diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 47d7a8aaa1..4295393bdb 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -919,7 +919,7 @@ int clif_skill_damage( block_list& src, block_list& dst, t_tick tick, int32 sdel //int clif_skill_damage2(struct block_list *src,struct block_list *dst,t_tick tick,int sdelay,int ddelay,int damage,int div,uint16 skill_id,uint16 skill_lv,enum e_damage_type type); bool clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 skill_id,int heal,t_tick tick); void clif_skill_poseffect( block_list& bl, uint16 skill_id, uint16 skill_lv, int32 x, int32 y, t_tick tick ); -void clif_skill_estimation(map_session_data *sd,struct block_list *dst); +void clif_skill_estimation( map_session_data& sd, mob_data& md ); void clif_skill_warppoint( map_session_data* sd, uint16 skill_id, uint16 skill_lv, const char* map1, const char* map2 = "", const char* map3 = "", const char* map4 = "" ); void clif_skill_memomessage( map_session_data& sd, e_ack_remember_warppoint_result result ); void clif_skill_teleportmessage( map_session_data& sd, e_notify_mapinfo_result result ); diff --git a/src/map/clif_packetdb.hpp b/src/map/clif_packetdb.hpp index bdcbab7ea8..e92d37d952 100644 --- a/src/map/clif_packetdb.hpp +++ b/src/map/clif_packetdb.hpp @@ -231,7 +231,6 @@ packet(0x0187,6); parseable_packet(0x018a,4,clif_parse_QuitGame,2); packet(0x018b,4); - packet(0x018c,29); packet(0x018d,-1); parseable_packet( HEADER_CZ_REQMAKINGITEM, sizeof( struct PACKET_CZ_REQMAKINGITEM ), clif_parse_ProduceMix, 0 ); packet( HEADER_ZC_ACK_REQMAKINGITEM, sizeof( PACKET_ZC_ACK_REQMAKINGITEM ) ); diff --git a/src/map/packets.hpp b/src/map/packets.hpp index 0992406ba3..e3445a5d9e 100644 --- a/src/map/packets.hpp +++ b/src/map/packets.hpp @@ -1036,6 +1036,28 @@ struct PACKET_ZC_DELETEITEM_FROM_MCSTORE { DEFINE_PACKET_HEADER(ZC_DELETEITEM_FROM_MCSTORE, 0x137); #endif +struct PACKET_ZC_MONSTER_INFO { + int16 packetType; + uint16 class_; + uint16 level; + uint16 size; + uint32 hp; + int16 def; + uint16 race; + int16 mdef; + uint16 element; + uint8 water; + uint8 earth; + uint8 fire; + uint8 wind; + uint8 poison; + uint8 holy; + uint8 shadow; + uint8 ghost; + uint8 undead; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_MONSTER_INFO, 0x18c); + // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 ) #pragma pack( pop ) diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 5f9b2ff09f..dcef9932cd 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -9257,7 +9257,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } clif_skill_nodamage(src, bl, skill_id, skill_lv, 1); - clif_skill_estimation(sd, bl); + if (dstmd != nullptr) + clif_skill_estimation( *sd, *dstmd ); if( skill_id == MER_ESTIMATION ) sd = nullptr; break;