Jump to content
  • 0

hpmeter visible MAPFLAG is it possible?


BabaVoss

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.03
  • Content Count:  79
  • Reputation:   0
  • Joined:  06/17/20
  • Last Seen:  

is it possible to enable view_hpmeter on certain maps only. or make a mapflag that enable to see hp on users.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  64
  • Reputation:   40
  • Joined:  03/26/12
  • Last Seen:  

in src\map\script_constants.hpp

Find:

export_constant(MF_NODYNAMICNPC);

Change To:

export_constant(MF_NODYNAMICNPC);
export_constant(MF_VIEW_HPMETER);

in src\map\map.hpp

Find:

	MF_NODYNAMICNPC,
	MF_MAX

Change To:

	MF_NODYNAMICNPC,
	MF_VIEW_HPMETER,
	MF_MAX

in src\map\npc.cpp

Find:

	switch( mapflag ){
		case MF_INVALID:

Change To:

	switch( mapflag ){
		case MF_VIEW_HPMETER:
			if (state) {
				union u_mapflag_args args = {};

				if (sscanf(w4, "%11d", &args.flag_val) < 1)
					args.flag_val = 0; // No level specified, allow everyone.

				map_setmapflag_sub(m, MF_VIEW_HPMETER, true, &args);
			} else
				map_setmapflag(m, MF_VIEW_HPMETER, false);
			break;
                                                           
		case MF_INVALID:

in src\map\map.cpp

Find:

		case MF_NOCOMMAND:
			if (status) {
				nullpo_retr(false, args);

				mapdata->flag[mapflag] = ((args->flag_val <= 0) ? 100 : args->flag_val);
			} else
				mapdata->flag[mapflag] = false;
			break;

Change To:

		case MF_NOCOMMAND:
		case MF_VIEW_HPMETER:
			if (status) {
				nullpo_retr(false, args);

				mapdata->flag[mapflag] = ((args->flag_val <= 0 && mapflag != MF_VIEW_HPMETER) ? 100 : args->flag_val);
			} else
				mapdata->flag[mapflag] = false;
			break;

Find:

		// additional mapflag data
		mapdata->zone = 0; // restricted mapflag zone
		mapdata->flag[MF_NOCOMMAND] = false; // nocommand mapflag level

Change To:

		// additional mapflag data
		mapdata->zone = 0; // restricted mapflag zone
		mapdata->flag[MF_NOCOMMAND] = false; // nocommand mapflag level
		mapdata->flag[MF_VIEW_HPMETER] = 99; // viewhpmeter mapflag level (Blocks everyone except Admin by default)

in src\map\atcommand.cpp

Find:

	if (map_getmapflag(m_id, MF_NOCOSTUME))
		strcat(atcmd_output, " NoCostume |");
	clif_displaymessage(fd, atcmd_output);

Change To:

	if (map_getmapflag(m_id, MF_NOCOSTUME))
		strcat(atcmd_output, " NoCostume |");
	if (map_getmapflag(m_id, MF_VIEW_HPMETER))
		strcat(atcmd_output, " ViewHPMeter |");
	clif_displaymessage(fd, atcmd_output);

in src\map\pc.cpp

Find:

/*==========================================
 * pc Init/Terminate
 *------------------------------------------*/
void do_final_pc(void) {

Change To:

bool pc_can_view_hpmeter(struct map_session_data *sd){
	if(!sd)
		return false;

	if(pc_has_permission(sd,PC_PERM_VIEW_HPMETER) &&
		pc_get_group_level(sd) >= map_getmapflag(sd->bl.m, MF_VIEW_HPMETER))
		return true;

	return false;
}

/*==========================================
 * pc Init/Terminate
 *------------------------------------------*/
void do_final_pc(void) {

in src\map\pc.hpp

Find:

#endif /* PC_HPP */

Change To:

bool pc_can_view_hpmeter(struct map_session_data *sd);

#endif /* PC_HPP */

in src\map\clif.cpp

Find:

	if( pc_has_permission( tsd, PC_PERM_VIEW_HPMETER ) ){
		 clif_hpmeter_single( *tsd, sd->status.account_id, sd->battle_status.hp, sd->battle_status.max_hp );
	}

Change to:

	if( pc_can_view_hpmeter( tsd ) ){
		 clif_hpmeter_single( *tsd, sd->status.account_id, sd->battle_status.hp, sd->battle_status.max_hp );
	}

Find:

	if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
		(sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround
		pc_has_permission(sd, PC_PERM_VIEW_HPMETER)
	)

Change To:

	if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
		(sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround
		pc_can_view_hpmeter(sd)
	)

Find:

		if( pc_has_permission(sd,PC_PERM_VIEW_HPMETER) ) {
			mapdata->hpmeter_visible++;
			sd->state.hpmeter_visible = 1;
		}

Change To:

		if( pc_can_view_hpmeter(sd) ) {
			mapdata->hpmeter_visible++;
			sd->state.hpmeter_visible = 1;
		}

 

Usage:

<mapname><tab>mapflag<tab>view_hpmeter<tab><group_level>

This should set a map with the mapflag to enable view_hpmeter that players with higher or equal to the specified group_level can bypass.

To block everyone set the group_level to 100.

***Note: You still need to add "view_hpmeter: true" to the group permissions on the groups.yml file.***

Edited by joecalis
Changed to block view_hpmeter for everyone except admins by default.
  • Love 1
  • MVP 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...