From 18f222b67d03dc8ad7584b972025bf58dbf39c1a Mon Sep 17 00:00:00 2001 From: Frost Date: Sun, 14 Jun 2015 21:21:55 +0800 Subject: Added Configuration in enabling/disabling monster hp bar on new clients. Closes #558 Signed-off-by: Haru --- conf/battle/monster.conf | 4 ++++ src/map/battle.c | 1 + src/map/battle.h | 2 ++ src/map/clif.c | 6 +++--- src/map/mob.c | 20 ++++++++++---------- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/conf/battle/monster.conf b/conf/battle/monster.conf index b26bda207..3167c11b1 100644 --- a/conf/battle/monster.conf +++ b/conf/battle/monster.conf @@ -211,6 +211,10 @@ mob_slave_keep_target: yes // See http://irowiki.org/wiki/MVP#Gravestone mvp_tomb_enabled: yes +// Show hp bar on monsters? (Default: yes) +// NOTE: only works on client 2012-04-04aRagexeRE onwards +show_monster_hp_bar: yes + // Whether or not the size of specially summoned mobs influences experience, drop rates, // and stats. The rates will be doubled for large mobs, and halved for small ones. // This is only invoked under the 'monster' command, @monsterbig, and @monstersmall. (Note 1) diff --git a/src/map/battle.c b/src/map/battle.c index d4f789d34..fb6a1c580 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7133,6 +7133,7 @@ static const struct battle_data { { "mob_icewall_walk_block", &battle_config.mob_icewall_walk_block, 75, 0, 255, }, { "boss_icewall_walk_block", &battle_config.boss_icewall_walk_block, 0, 0, 255, }, { "feature.roulette", &battle_config.feature_roulette, 1, 0, 1, }, + { "show_monster_hp_bar", &battle_config.show_monster_hp_bar, 1, 0, 1, }, }; #ifndef STATS_OPT_OUT /** diff --git a/src/map/battle.h b/src/map/battle.h index b211afff5..0ebc0aeb9 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -507,6 +507,8 @@ struct Battle_Config { int stormgust_knockback; int feature_roulette; + + int show_monster_hp_bar; // [Frost] }; /* criteria for battle_config.idletime_critera */ diff --git a/src/map/clif.c b/src/map/clif.c index f61bc7055..d1b20a750 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4217,10 +4217,10 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { else if(md->special_state.size==SZ_MEDIUM) clif->specialeffect_single(bl,421,sd->fd); #if PACKETVER >= 20120404 - if( !(md->status.mode&MD_BOSS) ){ + if (battle_config.show_monster_hp_bar && !(md->status.mode&MD_BOSS)) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++) {// must show hp bar to all char who already hit the mob. - if( md->dmglog[i].id == sd->status.char_id ) { + if (md->dmglog[i].id == sd->status.char_id) { clif->monster_hp_bar(md, sd); break; } @@ -17719,7 +17719,7 @@ void clif_monster_hp_bar( struct mob_data* md, struct map_session_data *sd ) { p.HP = md->status.hp; p.MaxHP = md->status.max_hp; - clif->send(&p,sizeof(p),&sd->bl,SELF); + clif->send(&p, sizeof(p), &sd->bl, SELF); } /* [Ind/Hercules] placeholder for unsupported incoming packets (avoids server disconnecting client) */ diff --git a/src/map/mob.c b/src/map/mob.c index 8c5e398b7..35e0cd5ab 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2064,13 +2064,13 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { return; #if PACKETVER >= 20120404 - if( !(md->status.mode&MD_BOSS) ){ + if (battle_config.show_monster_hp_bar && !(md->status.mode&MD_BOSS)) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob. - if( md->dmglog[i].id ) { + if (md->dmglog[i].id) { struct map_session_data *sd = map->charid2sd(md->dmglog[i].id); - if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range - clif->monster_hp_bar(md,sd); + if (sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE)) // check if in range + clif->monster_hp_bar(md, sd); } } } @@ -2798,19 +2798,19 @@ int mob_class_change (struct mob_data *md, int class_) /*========================================== * mob heal, update display hp info of mob for players *------------------------------------------*/ -void mob_heal(struct mob_data *md,unsigned int heal) +void mob_heal(struct mob_data *md, unsigned int heal) { if (battle_config.show_mob_info&3) clif->charnameack (0, &md->bl); - + #if PACKETVER >= 20120404 - if( !(md->status.mode&MD_BOSS) ){ + if (battle_config.show_monster_hp_bar && !(md->status.mode&MD_BOSS)) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob. - if( md->dmglog[i].id ) { + if (md->dmglog[i].id) { struct map_session_data *sd = map->charid2sd(md->dmglog[i].id); - if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range - clif->monster_hp_bar(md,sd); + if (sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE)) // check if in range + clif->monster_hp_bar(md, sd); } } } -- cgit v1.2.3-60-g2f50