summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2018-05-26 23:42:02 +0000
committerAsheraf <acheraf1998@gmail.com>2018-06-30 00:43:06 +0100
commitdff7e258eb1e4eefc5d455212a912fe454b7d3d3 (patch)
tree23b057fee0bb2b53bc688f7adefa91ef35a297cc
parent8ea98a7ff92e0f34f323342b1d69da42d92f39ae (diff)
downloadhercules-dff7e258eb1e4eefc5d455212a912fe454b7d3d3.tar.gz
hercules-dff7e258eb1e4eefc5d455212a912fe454b7d3d3.tar.bz2
hercules-dff7e258eb1e4eefc5d455212a912fe454b7d3d3.tar.xz
hercules-dff7e258eb1e4eefc5d455212a912fe454b7d3d3.zip
add support for send target in unittalk
-rw-r--r--doc/script_commands.txt31
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/clif.c14
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/script.c24
-rw-r--r--src/map/skill.c2
6 files changed, 63 insertions, 18 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index efccf799b..53d24de4d 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -6631,22 +6631,49 @@ Examples:
*unitwarp(<GID>, <Mapname>, <x>, <y>)
*unitattack(<GID>, <Target ID>)
*unitstop(<GID>)
-*unittalk(<GID>, <Text>{, show_name})
+*unittalk(<GID>, <Text>{, show_name{, <send_target>{, <target_id>}}})
*unitemote(<GID>, <Emote>)
Okay, these commands should be fairly self explaining.
For the emotions, you can look in db/constants.conf for prefixes with e_
PS: unitwarp() supports a <GID> of zero, which causes the executor of the
-PS: unittalk() can receive a third parameter:
+PS: unittalk() can receive 3 extra parameters:
show_name:
true: Shows Unit name like "UnitName : Message" (default)
false: Hides Unit name
+ send_target:
+ AREA_CHAT_WOC: sends the message to everyone in view range including the attached unit (default)
+ SELF: sends the message to the given unit gid only
+ target_id:
+ if send_target is set to SELF, the message will be shown by the given gid,
+ target_id allows changing the unit that will see the message.
script to be affected. This can be used with OnTouchNPC to warp
monsters:
OnTouchNPC:
unitwarp(0, "this", -1, -1);
+ // hide the npc name from the text
+ unittalk(getnpcid(0), "foobar", false);
+
+ // display by npc to everyone
+ unittalk(getnpcid(0), "foobar", true);
+
+ // display by npc to npc
+ unittalk(getnpcid(0), "foobar", true, SELF);
+
+ // display the text by the npc to the attached player only
+ unittalk(getnpcid(0), "foobar", true, SELF, playerattached());
+
+ // display by player to everyone
+ unittalk(playerattached(), "foobar", true);
+
+ // display by player to himself only
+ unittalk(playerattached(), "foobar", true, SELF);
+
+ // display the text by the 1st player to the attached player only
+ unittalk(getcharid(CHAR_ID_ACCOUNT, "Name"), "foobar", true, SELF, playerattached());
+
---------------------------------------
*disablenpc("<NPC object name>")
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index ae0c776c6..a9b8fb7b0 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -6228,7 +6228,7 @@ ACMD(npctalk)
snprintf(temp, sizeof(temp), "%s : %s", name, mes);
if(ifcolor) clif->messagecolor(&nd->bl,color,temp);
- else clif->disp_overhead(&nd->bl, temp);
+ else clif->disp_overhead(&nd->bl, temp, AREA_CHAT_WOC, NULL);
return true;
}
@@ -6288,7 +6288,7 @@ ACMD(pettalk)
}
snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
- clif->disp_overhead(&pd->bl, temp);
+ clif->disp_overhead(&pd->bl, temp, AREA_CHAT_WOC, NULL);
return true;
}
@@ -7063,7 +7063,7 @@ ACMD(homtalk)
}
snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
- clif->disp_overhead(&sd->hd->bl, temp);
+ clif->disp_overhead(&sd->hd->bl, temp, AREA_CHAT_WOC, NULL);
return true;
}
@@ -7423,7 +7423,7 @@ ACMD(me)
}
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,270), sd->status.name, tempmes); // *%s %s*
- clif->disp_overhead(&sd->bl, atcmd_output);
+ clif->disp_overhead(&sd->bl, atcmd_output, AREA_CHAT_WOC, NULL);
return true;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 654c43b53..18fb063ef 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8965,7 +8965,7 @@ void clif_slide(struct block_list *bl, int x, int y)
/// Public chat message (ZC_NOTIFY_CHAT). lordalfa/Skotlex - used by @me as well
/// 008d <packet len>.W <id>.L <message>.?B
-void clif_disp_overhead(struct block_list *bl, const char *mes)
+void clif_disp_overhead(struct block_list *bl, const char *mes, enum send_target target, struct block_list *target_bl)
{
char buf[CHAT_SIZE_MAX + (int)sizeof(struct PACKET_ZC_NOTIFY_CHAT)];
uint32 max_len = CHAT_SIZE_MAX - (int)sizeof(struct PACKET_ZC_NOTIFY_CHAT);
@@ -8986,11 +8986,15 @@ void clif_disp_overhead(struct block_list *bl, const char *mes)
p->PacketLength = mes_len + (int)sizeof(struct PACKET_ZC_NOTIFY_CHAT); // len of message + 8 (command+len+id)
p->GID = bl->id;
safestrncpy(p->Message, mes, mes_len);
- clif->send(p, p->PacketLength, bl, AREA_CHAT_WOC);
+ if (target == SELF && target_bl != NULL) {
+ clif->send(p, p->PacketLength, target_bl, SELF);
+ } else {
+ clif->send(p, p->PacketLength, bl, AREA_CHAT_WOC);
- // send back message to the speaker
- if (bl->type == BL_PC)
- clif->notify_playerchat(bl, mes);
+ // send back message to the speaker
+ if (bl->type == BL_PC)
+ clif->notify_playerchat(bl, mes);
+ }
}
void clif_notify_playerchat(struct block_list *bl, const char *mes)
diff --git a/src/map/clif.h b/src/map/clif.h
index 6c07998d5..1dffc2711 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -939,7 +939,7 @@ struct clif_interface {
void (*broadcast2) (struct block_list *bl, const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target);
void (*messagecolor_self) (int fd, uint32 color, const char *msg);
void (*messagecolor) (struct block_list* bl, uint32 color, const char* msg);
- void (*disp_overhead) (struct block_list *bl, const char* mes);
+ void (*disp_overhead) (struct block_list *bl, const char *mes, enum send_target target, struct block_list *target_bl);
void (*notify_playerchat) (struct block_list *bl, const char *mes);
void (*msgtable) (struct map_session_data* sd, enum clif_messages msg_id);
void (*msgtable_num) (struct map_session_data *sd, enum clif_messages msg_id, int value);
diff --git a/src/map/script.c b/src/map/script.c
index 94a991d06..e1d26e731 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15594,7 +15594,7 @@ BUILDIN(npctalk)
} else {
safesnprintf(message, sizeof(message), "%s", str);
}
- clif->disp_overhead(&nd->bl, message);
+ clif->disp_overhead(&nd->bl, message, AREA_CHAT_WOC, NULL);
}
return true;
@@ -20117,12 +20117,13 @@ BUILDIN(unitstop) {
/// Makes the unit say the message
///
-/// unittalk(<unit_id>,"<message>"{, show_name});
+/// unittalk(<unit_id>,"<message>"{, show_name{, <send_target>{, <target_id>}}});
BUILDIN(unittalk) {
int unit_id;
const char* message;
- struct block_list* bl;
+ struct block_list *bl, *target_bl = NULL;
bool show_name = true;
+ enum send_target target = AREA_CHAT_WOC;
unit_id = script_getnum(st,2);
message = script_getstr(st, 3);
@@ -20131,6 +20132,14 @@ BUILDIN(unittalk) {
show_name = (script_getnum(st, 4) != 0) ? true : false;
}
+ if (script_hasdata(st, 5)) {
+ target = script_getnum(st, 5);
+ }
+
+ if (script_hasdata(st, 6)) {
+ target_bl = map->id2bl(script_getnum(st, 6));
+ }
+
bl = map->id2bl(unit_id);
if( bl != NULL ) {
struct StringBuf sbuf;
@@ -20144,7 +20153,12 @@ BUILDIN(unittalk) {
} else {
StrBuf->Printf(&sbuf, "%s", message);
}
- clif->disp_overhead(bl, StrBuf->Value(&sbuf));
+
+ if (bl->type == BL_PC && target == SELF && (target_bl == NULL || bl == target_bl)) {
+ clif->notify_playerchat(bl, StrBuf->Value(&sbuf));
+ } else {
+ clif->disp_overhead(bl, StrBuf->Value(&sbuf), target, target_bl);
+ }
StrBuf->Destroy(&sbuf);
}
@@ -24789,7 +24803,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(unitwarp,"isii"),
BUILDIN_DEF(unitattack,"iv?"),
BUILDIN_DEF(unitstop,"i"),
- BUILDIN_DEF(unittalk,"is?"),
+ BUILDIN_DEF(unittalk,"is???"),
BUILDIN_DEF(unitemote,"ii"),
BUILDIN_DEF(unitskilluseid,"ivi?"), // originally by Qamera [Celest]
BUILDIN_DEF(unitskillusepos,"iviii"), // [Celest]
diff --git a/src/map/skill.c b/src/map/skill.c
index 34c36d7f3..f437ce66c 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -7168,7 +7168,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
//NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches)
char temp[70];
snprintf(temp, sizeof(temp), "%s : %s !!", md->name, skill->get_desc(skill_id));
- clif->disp_overhead(&md->bl,temp);
+ clif->disp_overhead(&md->bl, temp, AREA_CHAT_WOC, NULL);
}
break;