SQL 6xx Dialogs & multiple choice on an NPC by Gossip_menu & SmartAI

dokuro

Veteran Member
Verified Member
31
2020
8
Location
Paris
Imgur: The magic of the Internet

Gossip_menu: dialogue & multiple choice on an NPC



A gossip_menu is simply as shown on the screen a window that opens and offers us several choices. It can be created on a NPC or a gameobject, to illustrate this tutorial I would take the example of a teleporting NPC that I created for Azshara.

To create a gossip_menu we will need to define 3 things:


1) The npcflag in creature_template (does not exist on a gameobject and is therefore not necessary) as well as gossip_menu_id (11705 in the example below).



2) create the gossip_menu entries in the gossip_menu_option table as below:

REPLACE INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `OptionBroadcastTextID`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_poi_id`, `box_coded`, `box_money`, `box_text`, `BoxBroadcastTextID`) VALUES
(11705, 0, 0, 'Station du terminus Sud', 0, 1, 1, 0, 0, 0, 0, '', 0),
(11705, 1, 0, 'Station d''orgrimmar', 0, 1, 1, 0, 0, 0, 0, '', 0),
(11705, 2, 0, 'Station Palais de Gallywix', 0, 1, 1, 0, 0, 0, 0, '', 0),
(11705, 3, 0, 'Station Nord (Camp de base Darnassien)', 0, 1, 1, 0, 0, 0, 0, '', 0),
(11705, 4, 0, 'Station des confins Amers', 0, 1, 1, 0, 0, 0, 0, '', 0);

Explanations:
menu_id: this is the gossip_menu_id entered in creature_template,
id: will be used on SAI-editor to know what choice the player made
option_icon: an optional small icon displayed before the text for the choice offered. It can be either:

GOSSIP_ICON_CHAT 0
GOSSIP_ICON_VENDOR 1
GOSSIP_ICON_TAXI 2
GOSSIP_ICON_TRAINER 3
GOSSIP_ICON_INTERACT_1 4
GOSSIP_ICON_INTERACT_2 5
GOSSIP_ICON_MONEY_BAG 6
GOSSIP_ICON_TALK 7
GOSSIP_ICON_TABARD 8
GOSSIP_ICON_BATTLE 9
GOSSIP_ICON_DOT10

option_text: the text for the proposed choice
option_id: for a type of pnj like a salesman or a taxi, personally I always use zero for none.
npc_option_npcflag: the pnj has a flag gossip_menu, leave at 1
action_menu_id: an id for a sub-menu, personally I never needed to go as far as
action_poi_id: point of interest displayed on the minimap
box_money: what the player has to pay (in copper coins)

3) Create the smartai which will manage all its as on the following screen:

Imgur: The magic of the Internet
PS: We don't see it on this screen but the ids (0 to 4) defined in the gossip_menu_option table will appear in EVENT_GOSSIP_SELECT -> gossip_menu_item.


this script smartai :

-- Bilgewater Rocket-jockey SAI
SET @ENTRY := 43217;
UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(@ENTRY,0,10,0,62,0,100,0,11705,0,0,0,62,1,0,0,0,0,0,7,0,0,0,2659.220459,-6163.652832,138.307510,0,"PNJ TP : Azshara fusorail - Station du terminus Sud"),
(@ENTRY,0,11,0,62,0,100,0,11705,2,0,0,62,1,0,0,0,0,0,7,0,0,0,3554.774902,-4793.672852,160.704224,0,"PNJ TP : Azshara fusorail - Station Palais de Gallywix"),
(@ENTRY,0,12,0,62,0,100,0,11705,3,0,0,62,1,0,0,0,0,0,7,0,0,0,4470.460449,-5715.648926,145.509689,0,"PNJ TP : Azshara fusorail - Station Nord (Camp de base Darnassien)"),
(@ENTRY,0,13,0,62,0,100,0,11705,4,0,0,62,1,0,0,0,0,0,7,0,0,0,4617.309082,-7033.515137,153.722672,0,"PNJ TP : Azshara fusorail - Station des confins Amers"),
(@ENTRY,0,14,0,62,0,100,0,11705,1,0,0,62,1,0,0,0,0,0,7,0,0,0,2954.566895,-4996.734375,165.674088,0,"PNJ TP : Azshara fusorail - Station d''orgrimmar");


Last point, the gossip generally do not close. It is necessary for each choice to create another entry ACTION_CLOSE_GOSSIP to close it. In my script this was not necessary since the player's teleportation automatically closes the window.


4) Add a generic option to the gossip_menu_option:


It can be interesting to add to our NPC an option of seller, sales manager, banker or other.
For that it will be necessary to edit the `option_id` and the` npc_option_npcflag` of our gossip_menu_option and the core will automatically manage this option by opening the related generic window, it will have nothing else to add. Of course the NPC flag must be activated.

Example of editing the gossip_menu_option of the NPC Fiona in order to add a seller option.

REPLACE INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `OptionBroadcastTextID`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_poi_id`, `box_coded`, `box_money`, `box_text`, `BoxBroadcastTextID`) VALUES

(12022, 0, 1, 'Montrez moi ce que vous avez a vendre Fiona.', 0, 3, 128, 0, 0, 0, 0, '', 0);

The option_id 3 designates the type of option as seller or master of profession etc.
The npc_option_npcflag 128 simply designates the flag or group of flags compatible with this option as seller or seller + repairer of the PNJ.
A gossip_menu_option line for an option.

Below is the list of generic options and corresponding flags:

option_id & npc_option_npcflag

0 nothing
1-1 gossip menu
2-2 Quest Giver
5-16 Coach
16-16 Clear TALENTS
16-17 Clear PET TALENTS
18-16 Double Specialty Coach
3-128 Seller
15-4096 Repairman
4-8192 Air Routes
6-16384 Guardian of Souls
7-32768 Spiritual Guide
8-65536 New Fireplace
9-131072 Bank
10-262144 Guild Creation
#
11-524288 Creation of Tabard
12-1048576 Battlefield
13-2097152 Auction House
14-4194304 Stable
? 6-67108864 Letter Box
? -268435456 Transmogrify
? -536870912 Vacuum chamber
? -1073741824 Battle Pet ?!
? -2147483648 Walking black
? -4294967296 ITEM_UPGRADE_MASTER
? -8589934592 Architect of the fief
? -17179869184 - CHIPMENT_CRAFTER
? -34359738368 - GARRISON_MISSION_NPC
? -68719476736 - TRADESKILL_NPC
? -137438953472 BLACK_MARKET_VIEW
? -549755813888 Black walk

thax for all and good game for you =)

Credit to : Stitch from Aquayoup
 
Last edited by a moderator:
Top