Implemented Dialog Types (#8110)

Fixes #8109

Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Pokye 2024-02-26 18:08:52 -03:00 committed by GitHub
parent e196eadcaa
commit eb308dcad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 207 additions and 0 deletions

View File

@ -11412,3 +11412,37 @@ Example:
autoloot(10000); // 100.00%
---------------------------------------
*setdialogalign(<align>);
Set vertical or horizontal align in NPC dialog.
Valid aligns:
- horizontal align:
DIALOG_ALIGN_LEFT
DIALOG_ALIGN_CENTER
DIALOG_ALIGN_RIGHT
- vertical align:
DIALOG_ALIGN_TOP
DIALOG_ALIGN_MIDDLE
DIALOG_ALIGN_BOTTOM
---------------------------------------
*setdialogsize(<width>, <height>)
Set size for NPC dialog in pixels.
---------------------------------------
*setdialogpos(<x>, <y>)
Set position for NPC dialog in pixels.
---------------------------------------
*setdialogpospercent(<x>, <y>)
Set position for NPC dialog in screen size percent.
---------------------------------------

View File

@ -25187,6 +25187,57 @@ void clif_parse_reset_skill( int fd, map_session_data* sd ){
#endif
}
void clif_set_dialog_align(map_session_data& sd, int npcid, e_say_dialog_align align)
{
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20221024
PACKET_ZC_DIALOG_TEXT_ALIGN p = {};
p.PacketType = HEADER_ZC_DIALOG_TEXT_ALIGN;
p.align = align;
clif_send( &p, sizeof( p ), &sd.bl, SELF );
#endif // PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20221024
}
void clif_set_npc_window_size(map_session_data& sd, int width, int height)
{
#if PACKETVER_MAIN_NUM >= 20220504
PACKET_ZC_DIALOG_WINDOW_SIZE p = {};
p.PacketType = HEADER_ZC_DIALOG_WINDOW_SIZE;
p.width = width;
p.height = height;
clif_send( &p, sizeof( p ), &sd.bl, SELF );
#endif // PACKETVER_MAIN_NUM >= 20220504
}
void clif_set_npc_window_pos(map_session_data& sd, int x, int y)
{
#if PACKETVER_MAIN_NUM >= 20220504
PACKET_ZC_DIALOG_WINDOW_POS p = {};
p.PacketType = HEADER_ZC_DIALOG_WINDOW_POS;
p.x = x;
p.y = y;
clif_send( &p, sizeof( p ), &sd.bl, SELF );
#endif // PACKETVER_MAIN_NUM >= 20220504
}
void clif_set_npc_window_pos_percent(map_session_data& sd, int x, int y)
{
#if PACKETVER_MAIN_NUM >= 20220504
PACKET_ZC_DIALOG_WINDOW_POS2 p = {};
p.PacketType = HEADER_ZC_DIALOG_WINDOW_POS2;
p.x = x;
p.y = y;
clif_send( &p, sizeof( p ), &sd.bl, SELF );
#endif // PACKETVER_MAIN_NUM >= 20220504
}
/*==========================================
* Main client packet processing function
*------------------------------------------*/

View File

@ -1254,4 +1254,9 @@ void clif_macro_reporter_status(map_session_data &sd, e_macro_report_status styp
void clif_dynamicnpc_result( map_session_data& sd, e_dynamicnpc_result result );
void clif_set_dialog_align(map_session_data& sd, int npcid, e_say_dialog_align align);
void clif_set_npc_window_size(map_session_data& sd, int width, int height);
void clif_set_npc_window_pos(map_session_data& sd, int x, int y);
void clif_set_npc_window_pos_percent(map_session_data& sd, int x, int y);
#endif /* CLIF_HPP */

View File

@ -861,6 +861,18 @@ struct map_data_other_server {
uint16 port;
};
/**
* align for packet ZC_SAY_DIALOG_ALIGN
**/
enum e_say_dialog_align : uint8 {
DIALOG_ALIGN_LEFT = 0,
DIALOG_ALIGN_RIGHT = 1,
DIALOG_ALIGN_CENTER = 2,
DIALOG_ALIGN_TOP = 3,
DIALOG_ALIGN_MIDDLE = 4,
DIALOG_ALIGN_BOTTOM = 5
};
struct inter_conf {
uint32 start_status_points;
bool emblem_woe_change;

View File

@ -27123,6 +27123,106 @@ BUILDIN_FUNC(opentips){
#endif
}
BUILDIN_FUNC(setdialogalign){
map_session_data *sd;
if ( !script_rid2sd(sd) ) {
return SCRIPT_CMD_FAILURE;
}
int32 align = script_getnum( st, 2 );
if( align < DIALOG_ALIGN_LEFT || align > DIALOG_ALIGN_BOTTOM ){
ShowError( "buildin_setdialogalign: Unknown align value %d\n", align );
return SCRIPT_CMD_FAILURE;
}
clif_set_dialog_align( *sd, st->oid, static_cast<e_say_dialog_align>( align ) );
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(setdialogsize){
map_session_data *sd;
if ( !script_rid2sd(sd) ) {
script_pushint(st, 0);
return SCRIPT_CMD_FAILURE;
}
int32 x = script_getnum( st, 2 );
if( x < 0 || x > INT16_MAX ){
ShowError( "buildin_setdialogsize: x size %d is out of range [0,%d]\n", x, INT16_MAX );
return SCRIPT_CMD_FAILURE;
}
int32 y = script_getnum( st, 3 );
if( y < 0 || y > INT16_MAX ){
ShowError( "buildin_setdialogsize: y size %d is out of range [0,%d]\n", y, INT16_MAX );
return SCRIPT_CMD_FAILURE;
}
clif_set_npc_window_size( *sd, x, y );
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(setdialogpos){
map_session_data *sd;
if ( !script_rid2sd(sd) ) {
script_pushint(st, 0);
return SCRIPT_CMD_FAILURE;
}
int32 x = script_getnum( st, 2 );
if( x < 0 || x > INT16_MAX ){
ShowError( "buildin_setdialogpos: x position %d is out of range [0,%d]\n", x, INT16_MAX );
return SCRIPT_CMD_FAILURE;
}
int32 y = script_getnum( st, 3 );
if( y < 0 || y > INT16_MAX ){
ShowError( "buildin_setdialogpos: y position %d is out of range [0,%d]\n", y, INT16_MAX );
return SCRIPT_CMD_FAILURE;
}
clif_set_npc_window_pos( *sd, x, y );
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(setdialogpospercent){
map_session_data *sd;
if ( !script_rid2sd(sd) ) {
script_pushint(st, 0);
return SCRIPT_CMD_FAILURE;
}
int32 x = script_getnum( st, 2 );
if( x < 0 || x > 100 ){
ShowError( "buildin_setdialogpospercent: x rate %d is out of range [0,100]\n", x );
return SCRIPT_CMD_FAILURE;
}
int32 y = script_getnum( st, 3 );
if( y < 0 || y > 100 ){
ShowError( "buildin_setdialogpospercent: y rate %d is out of range [0,100]\n", y );
return SCRIPT_CMD_FAILURE;
}
clif_set_npc_window_pos_percent( *sd, x, y );
return SCRIPT_CMD_SUCCESS;
}
#include <custom/script.inc>
// declarations that were supposed to be exported from npc_chat.cpp
@ -27883,6 +27983,11 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(autoloot,"??"),
BUILDIN_DEF(opentips, "i?"),
BUILDIN_DEF(setdialogalign, "i"),
BUILDIN_DEF(setdialogsize, "ii"),
BUILDIN_DEF(setdialogpos, "ii"),
BUILDIN_DEF(setdialogpospercent, "ii"),
#include <custom/script_def.inc>
{NULL,NULL,NULL},