• 0
Sign in to follow this  
utofaery

npctalk color in script

Question

1. Can we change npctalk color when in script ?

2. cases on npc whisper function

how do a player activate an npc that has whisper function this thing is a maze to me...

 

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I vaguely remember we discuss about *dispbottom2 and *message2 custom script command during my stay on hercules
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?do=findComment&comment=25468


answer is yes, it just not implemented
look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded

BUILDIN_FUNC(npctalk)
{
	struct npc_data* nd = NULL;
	const char* str = script_getstr(st,2);

	if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0)
		nd = npc_name2id(script_getstr(st, 3));
	else
		nd = (struct npc_data *)map_id2bl(st->oid);

	if (nd != NULL) {
		send_target target = AREA;
		char message[CHAT_SIZE_MAX];

		if (script_hasdata(st, 4)) {
			switch(script_getnum(st, 4)) {
				case BC_ALL:	target = ALL_CLIENT;	break;
				case BC_MAP:	target = ALL_SAMEMAP;	break;
				case BC_SELF:	target = SELF;			break;
				case BC_AREA:
				default:		target = AREA;			break;
			}
		}
		safesnprintf(message, sizeof(message), "%s", str);
		if (target != SELF)
			clif_messagecolor(&nd->bl, color_table[COLOR_WHITE], message, false, target);
		else {
			TBL_PC *sd = map_id2sd(st->rid);
			if (sd == NULL)
				return SCRIPT_CMD_FAILURE;
			clif_messagecolor_target(&nd->bl, color_table[COLOR_WHITE], message, false, target, sd);
		}
	}
	return SCRIPT_CMD_SUCCESS;
}

 

so I play around again with it, Hercules plugin of course,

#include "common/hercules.h"
#include "map/clif.h"
#include "map/script.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"messagecolor",
	SERVER_TYPE_MAP,
	"0.1",
	HPM_VERSION,
};

BUILDIN(messagecolor) {
	struct block_list *bl = map->id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return false;
	}
	clif->messagecolor( bl, script_getnum(st,4), script_getstr(st,3) );
	return true;
}

HPExport void plugin_init (void) {
	addScriptCommand( "messagecolor", "isi", messagecolor );
}
prontera,155,185,5	script	kjsdhfksjf	1_F_MARIA,{
//	messagecolor getcharid(3), "asdfasdf", C_BLUE; <-- doesn't work
	messagecolor getnpcid(), "asdfasdf", C_BLUE;
	messagecolor getnpcid(), "asdfasdf", C_RED;
	messagecolor getnpcid(), "asdfasdf", C_YELLOW;
	messagecolor getnpcid(), "asdfasdf", C_PINK;
	messagecolor getnpcid(), "asdfasdf", C_PURPLE;
	messagecolor getnpcid(), "asdfasdf", C_ORANGE;
	end;
}

screen2019Hercules027.jpg

 

 

2. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

https://github.com/rathena/rathena/blob/master/doc/whisper_sys.txt

Share this post


Link to post
Share on other sites
  • 0
9 minutes ago, AnnieRuru said:

I vaguely remember we discuss about *dispbottom2 and *message2 custom script command during my stay on hercules
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?do=findComment&amp;comment=25468


answer is yes, it just not implemented
look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded

BUILDIN_FUNC(npctalk)
{
	struct npc_data* nd = NULL;
	const char* str = script_getstr(st,2);

	if (script_hasdata(st, 3) && strlen(script_getstr(st,3)) > 0)
		nd = npc_name2id(script_getstr(st, 3));
	else
		nd = (struct npc_data *)map_id2bl(st->oid);

	if (nd != NULL) {
		send_target target = AREA;
		char message[CHAT_SIZE_MAX];

		if (script_hasdata(st, 4)) {
			switch(script_getnum(st, 4)) {
				case BC_ALL:	target = ALL_CLIENT;	break;
				case BC_MAP:	target = ALL_SAMEMAP;	break;
				case BC_SELF:	target = SELF;			break;
				case BC_AREA:
				default:		target = AREA;			break;
			}
		}
		safesnprintf(message, sizeof(message), "%s", str);
		if (target != SELF)
			clif_messagecolor(&nd->bl, color_table[COLOR_WHITE], message, false, target);
		else {
			TBL_PC *sd = map_id2sd(st->rid);
			if (sd == NULL)
				return SCRIPT_CMD_FAILURE;
			clif_messagecolor_target(&nd->bl, color_table[COLOR_WHITE], message, false, target, sd);
		}
	}
	return SCRIPT_CMD_SUCCESS;
}

 

so I play around again with it, Hercules plugin of course,

#include "common/hercules.h"
#include "map/clif.h"
#include "map/script.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"messagecolor",
	SERVER_TYPE_MAP,
	"0.1",
	HPM_VERSION,
};

BUILDIN(messagecolor) {
	struct block_list *bl = map->id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return false;
	}
	clif->messagecolor( bl, script_getnum(st,4), script_getstr(st,3) );
	return true;
}

HPExport void plugin_init (void) {
	addScriptCommand( "messagecolor", "isi", messagecolor );
}
prontera,155,185,5	script	kjsdhfksjf	1_F_MARIA,{
//	messagecolor getcharid(3), "asdfasdf", C_BLUE; <-- doesn't work
	messagecolor getnpcid(), "asdfasdf", C_BLUE;
	messagecolor getnpcid(), "asdfasdf", C_RED;
	messagecolor getnpcid(), "asdfasdf", C_YELLOW;
	messagecolor getnpcid(), "asdfasdf", C_PINK;
	messagecolor getnpcid(), "asdfasdf", C_PURPLE;
	messagecolor getnpcid(), "asdfasdf", C_ORANGE;
	end;
}

screen2019Hercules027.jpg

 

 

2. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

https://github.com/rathena/rathena/blob/master/doc/whisper_sys.txt

Could you convert this plugin to rAthena please? instead of Hercules.

Share this post


Link to post
Share on other sites
  • 0
46 minutes ago, Elysium said:

Could you convert this plugin to rAthena please? instead of Hercules.

BUILDIN_FUNC(messagecolor) {
	struct block_list *bl = map_id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return SCRIPT_CMD_FAILURE;
	}
	clif_messagecolor( bl, script_getnum(st,4), script_getstr(st,3), true, AREA);
	return SCRIPT_CMD_SUCCESS;
}
BUILDIN_DEF(messagecolor,"isi"),

 

Remember the reason why it doesn't work on players, because "@fontcolor" uses a trick to disguise player as monster
https://github.com/HerculesWS/Hercules/issues/1217
https://github.com/HerculesWS/Hercules/issues/1930

apparently rAthena "@fontcolor" is broken

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0
2 minutes ago, AnnieRuru said:
BUILDIN_FUNC(messagecolor) {
	struct block_list *bl = map_id2bl( script_getnum(st,2) );
	if (!bl) {
		ShowWarning("buildin_messagecolor: Error in finding object GID %d!\n", script_getnum(st,2));
		return SCRIPT_CMD_FAILURE;
	}
	clif_messagecolor( bl, script_getnum(st,4), script_getstr(st,3), true, AREA);
	return SCRIPT_CMD_SUCCESS;
}
BUILDIN_DEF(messagecolor,"isi"),

 

Remember the reason why it doesn't work on players, because "@fontcolor" uses a trick to disguise player as monster
https://github.com/HerculesWS/Hercules/issues/1217
https://github.com/HerculesWS/Hercules/issues/1930

Thank you Ma'dam! i'll test it

Share this post


Link to post
Share on other sites
  • 0
52 minutes ago, AnnieRuru said:

1.

look at the npctalk inside script.cpp, it default to color_table[COLOR_WHITE], this value is hard-coded

 

2

so I play around again with it, Hercules plugin of course,

 

 

3. forget the whisper feature, that thing is from the past
everyone use *bindatcmd now

1. nice npctalk white is messy and bad.  now can change it...

2. thanks for that.

 

3. at the time it was still hot/ popular thing, I can barely get the concept of it ... that's why I am asking though.

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

Edited by utofaery

Share this post


Link to post
Share on other sites
  • 0
9 minutes ago, utofaery said:

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

/*==========================================
 * Added built-in functions
 *------------------------------------------*/
static void add_buildin_func(void)
{
	int i;
	for( i = 0; buildin_func[i].func; i++ )
	{
		// arg must follow the pattern: (v|s|i|r|l)*\?*\*?
		// 'v' - value (either string or int or reference)
		// 's' - string
		// 'i' - int
		// 'r' - reference (of a variable)
		// 'l' - label
		// '?' - one optional parameter
		// '*' - unknown number of optional parameters

 

no idea what to say, its part of source modification

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, utofaery said:

1. nice npctalk white is messy and bad.  now can change it...

2. thanks for that.

 

3. at the time it was still hot/ popular thing, I can barely get the concept of it ... that's why I am asking though.

4. wait a second what is "isi" ???

as in "Malay" language??? for content??? or it means???

isi = integer, string, integer

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this