[WIP] Magister Hathorel & Arcanist Tybalin SAI

Hi all. I started working on the SAI of these two NPCs. They’re involved in the Battered Hilt quest chain, An Audience With The Arcanist (H - 24451) and A Meeting With The Magister (A - 20439) in particular.

When you accept the quest, the npc disguises you as a member of the opposite faction, then you go to the other npc and he gives you the book. If you lose the disguise (it’s a 5 min buff), you can return to the quest giver and he re-disguises you. After completing the quest, the disguise buff is removed.

Well, here’s the sql I wrote.

[CODE]
– Support for quests An Audience With The Arcanist (24451) / A Meeting With The Magister (20439)
– Spells
– Disguise for Horde players
SET @DISGUISE_SPELL_H := 69673;
SET @DISGUISE_H_F := 70971;
SET @DISGUISE_H_M := 70972;
– Disguise for Alliance players
SET @DISGUISE_SPELL_A := 69672;
SET @DISGUISE_A_F := 70973;
SET @DISGUISE_A_M := 70974;
– This spell gives the book to the player
SET @BOOK_SPELL := 69722;

– Magister Hathorel SAI
SET @ENTRY_H := 36670;
SET @MENU_ID_H := 10857;
– Quest An Audience With The Arcanist - 24451
SET @QUEST_H := 24451;
– Template
UPDATE creature_template SET npcflag=npcflag|1, AIName=‘SmartAI’ WHERE entry=@ENTRY_H;
– Delete double spawn
DELETE FROM creature WHERE guid=150186 AND id=@ENTRY_H;
– Gossip Menu Options
DELETE from gossip_menu_option WHERE menu_id=@MENU_ID_H AND id IN (0,1);
INSERT INTO gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, action_script_id, box_coded, box_money, box_text) VALUES
(@MENU_ID_H,0,0,‘I’‘m ready to deliver the tome, Magister Hathorel’,1,1,0,0,0,0,0,‘’),
(@MENU_ID_H,1,0,‘Please disguise me again.’,1,1,0,0,0,0,0,‘’);
– Texts
DELETE FROM creature_text WHERE entry=@ENTRY_H;
INSERT INTO creature_text (entry,groupid,id,text,type,language,probability,emote,duration,sound,comment) VALUES
(@ENTRY_H,0,0,‘You’‘re late, courier. No, I don’‘t want any exuses: this errand is far too important.’,0,0,100,0,0,0,‘Magister Hathorel: quest A Meeting With The Magister’),
(@ENTRY_H,1,0,‘Here’‘s the tome our representative brought from Wyrmrest. Get this to Myralion Sunblaze immediatly.’,0,0,100,0,0,0,‘Magister Hathorel: quest A Meeting With The Magister’);
– Scripts
DELETE FROM smart_scripts WHERE entryorguid IN (@ENTRY_H,@ENTRY_H100,@ENTRY_H100+1);
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
– When a player takes the quest, disguise must be casted on player
(@ENTRY_H,0,0,1,19,0,100,0,@QUEST_H,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ‘Magister Hathorel: close gossip menu when plyaer takes the quest’),
(@ENTRY_H,0,1,0,61,0,100,0,0,0,0,0,11,@DISGUISE_SPELL_H,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Magister Hathorel: then cast disguise’),
– When player asks for the book, cast spell to create it
(@ENTRY_H,0,2,0,62,0,100,0,@MENU_ID_H,0,0,0,80,@ENTRY_H100,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Magister Hathorel: start script to give book on gossip select’),
(@ENTRY_H
100,9,0,0,0,0,100,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Magister Hathorel: close gossip menu’),
(@ENTRY_H100,9,1,0,0,0,100,0,0,0,0,0,81,0,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Magister Hathorel: turn off Gossip & Questgiver flags’),
(@ENTRY_H
100,9,2,0,0,0,100,0,2000,2000,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Magister Hathorel: say text 0’),
(@ENTRY_H100,9,3,0,0,0,100,0,6000,6000,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Magister Hathorel: say text 1 after text 0’),
(@ENTRY_H
100,9,4,0,0,0,100,0,0,0,0,0,11,@BOOK_SPELL,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Magister Hathorel: give book’),
(@ENTRY_H100,9,5,0,0,0,100,0,0,0,0,0,81,3,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Magister Hathorel: turn on Gossip & Questgiver flags’),
– When player asks for a new disguise, cast disguise on player
(@ENTRY_H,0,3,0,62,0,100,0,@MENU_ID_H,1,0,0,80,@ENTRY_H
100+1,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Magister Hathorel: start script to cast disguise on gossip select’),
– Cast disguise
(@ENTRY_H100+1,9,0,0,0,0,100,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Magister Hathorel: close gossip menu’),
(@ENTRY_H
100+1,9,1,0,0,0,100,0,0,0,0,0,11,@DISGUISE_SPELL_H,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Magister Hathorel: cast disguise’),
– When player complete the quest, remove disguise
(@ENTRY_H,0,4,5,20,0,100,0,@QUEST_H,0,0,0,28,@DISGUISE_H_F,0,0,0,0,0,7,0,0,0,0,0,0,0, ‘Magister Hathorel: remove disguise on quest completing’),
(@ENTRY_H,0,5,0,61,0,100,0,0,0,0,0,28,@DISGUISE_H_M,0,0,0,0,0,7,0,0,0,0,0,0,0, ‘Magister Hathorel: remove disguise on quest completing’);
– Conditions
DELETE FROM conditions WHERE SourceTypeOrReferenceId=15 AND SourceGroup=10857 AND SourceEntry IN (0,1);
INSERT INTO conditions (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,ErrorTextId,ScriptName,Comment) VALUES
– If player from opposite faction is disguised, show gossip to obtain the book
(15,@MENU_ID_H,0,0,1,@DISGUISE_A_F,0,0,0,‘’,‘Magister Hathorel: show gossip to obtain the book if player is disguised’),
(15,@MENU_ID_H,0,1,1,@DISGUISE_A_M,0,0,0,‘’,‘Magister Hathorel: show gossip to obtain the book if player is disguised’),
– If player has the quest and is not disguised, show gossip to be disguised again
(15,@MENU_ID_H,1,0,11,@DISGUISE_H_F,0,0,0,‘’,‘Magister Hathorel: show gossip to be disguised if player is not disguised’),
(15,@MENU_ID_H,1,0,9,@QUEST_H,0,0,0,‘’,‘Magister Hathorel: show gossip to be disguised if player has the quest’),
(15,@MENU_ID_H,1,1,11,@DISGUISE_H_M,0,0,0,‘’,‘Magister Hathorel: show gossip to be disguised if player is not disguised’),
(15,@MENU_ID_H,1,1,9,@QUEST_H,0,0,0,‘’,‘Magister Hathorel: show gossip to be disguised if player has the quest’);

– Arcanist Tybalin SAI
SET @ENTRY_A := 36669;
SET @MENU_ID_A := 10858;
– Quest A Meeting With The Magister - 20439
SET @QUEST_A := 20439;
– Template
UPDATE creature_template SET npcflag=npcflag|1, AIName=‘SmartAI’ WHERE entry=@ENTRY_A;
– Gossip Menu Options
DELETE from gossip_menu_option WHERE menu_id=@MENU_ID_A AND id IN (0,1);
INSERT INTO gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, action_script_id, box_coded, box_money, box_text) VALUES
(@MENU_ID_A,0,0,‘I’‘ll deliver the tome to our contacts in Icecrown, arcanist.’,1,1,0,0,0,0,0,‘’),
(@MENU_ID_A,1,0,‘Please disguise me again.’,1,1,0,0,0,0,0,‘’);
DELETE FROM creature_text WHERE entry=@ENTRY_A;
INSERT INTO creature_text (entry,groupid,id,text,type,language,probability,emote,duration,sound,comment) VALUES
(@ENTRY_A,0,0,‘It’‘s good to finally see you, courier. Krasus has entrusted us with one of the few remaining copies of Ancient Dragonforged Blades.’,0,0,100,0,0,0,‘Arcanist Tybalin: quest An Audience With The Arcanist’),
(@ENTRY_A,1,0,‘Here is the book. You must ensure it gets to Caladis Brightspear in Icecrown before the Sunreavers realize what is happening.’,0,0,100,0,0,0,‘Arcanist Tybalin: quest An Audience With The Arcanist’),
(@ENTRY_A,2,0,‘Travel quickly! The Sunreavers will not waste any time once they realize that we have the informations they seek.’,0,0,100,0,0,0,‘Arcanist Tybalin: quest An Audience With The Arcanist’);
– Scripts
DELETE FROM smart_scripts WHERE entryorguid IN (@ENTRY_A,@ENTRY_A100,@ENTRY_A100+1);
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
– When a player takes the quest, disguise must be casted on player
(@ENTRY_A,0,0,1,19,0,100,0,@QUEST_A,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ‘Arcanist Tybalin: close gossip menu when plyaer takes the quest’),
(@ENTRY_A,0,1,0,61,0,100,0,0,0,0,0,11,@DISGUISE_SPELL_A,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Arcanist Tybalin: then cast disguise’),
– When player asks for the book, cast spell to create it
(@ENTRY_A,0,2,0,62,0,100,0,@MENU_ID_A,0,0,0,80,@ENTRY_A100,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Arcanist Tybalin: start script to give book on gossip select’),
(@ENTRY_A
100,9,0,0,0,0,100,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Arcanist Tybalin: close gossip menu’),
(@ENTRY_A100,9,1,0,0,0,100,0,0,0,0,0,81,0,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Magister Hathorel: turn off Gossip & Questgiver flags’),
(@ENTRY_A
100,9,2,0,0,0,100,0,2000,2000,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Arcanist Tybalin: say text 0’),
(@ENTRY_A100,9,3,0,0,0,100,0,6000,6000,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Arcanist Tybalin: say text 1 after text 0’),
(@ENTRY_A
100,9,4,0,0,0,100,0,0,0,0,0,11,@BOOK_SPELL,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Arcanist Tybalin: give book’),
(@ENTRY_A100,9,5,0,0,0,100,0,6000,6000,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Arcanist Tybalin: say text 2 after text 1’),
(@ENTRY_A
100,9,6,0,0,0,100,0,0,0,0,0,81,3,0,0,0,0,0,1,0,0,0,0,0,0,0,‘Magister Hathorel: turn on Gossip & Questgiver flags’),
– When player asks for a new disguise, cast disguise on player
(@ENTRY_A,0,3,0,62,0,100,0,@MENU_ID_A,1,0,0,80,@ENTRY_A100+1,0,0,0,0,0,1,0,0,0,0,0,0,0, ‘Arcanist Tybalin: start script to cast disguise on gossip select’),
– Cast disguise
(@ENTRY_A
100+1,9,0,0,0,0,100,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,‘Arcanist Tybalin: close gossip menu’),
(@ENTRY_A*100+1,9,1,0,0,0,100,0,0,0,0,0,11,@DISGUISE_SPELL_A,2,0,0,0,0,7,0,0,0,0,0,0,0, ‘Arcanist Tybalin: cast disguise’),
– When player complete the quest, remove disguise
(@ENTRY_A,0,4,5,20,0,100,0,@QUEST_A,0,0,0,28,@DISGUISE_A_F,0,0,0,0,0,7,0,0,0,0,0,0,0, ‘Arcanist Tybalin: remove disguise on quest completing’),
(@ENTRY_A,0,5,0,61,0,100,0,0,0,0,0,28,@DISGUISE_A_M,0,0,0,0,0,7,0,0,0,0,0,0,0, ‘Arcanist Tybalin: remove disguise on quest completing’);
– Conditions
DELETE FROM conditions WHERE SourceTypeOrReferenceId=15 AND SourceGroup=@MENU_ID_A AND SourceEntry IN (0,1);
INSERT INTO conditions (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,ErrorTextId,ScriptName,Comment) VALUES
– If player from opposite faction is disguised, show gossip to obtain the book
(15,@MENU_ID_A,0,0,1,@DISGUISE_H_F,0,0,0,‘’,‘Arcanist Tybalin: show gossip to obtain the book if player is disguised’),
(15,@MENU_ID_A,0,1,1,@DISGUISE_H_M,0,0,0,‘’,‘Arcanist Tybalin: show gossip to obtain the book if player is disguised’),
– If player has the quest and is not disguised, show gossip to be disguised again
(15,@MENU_ID_A,1,0,11,@DISGUISE_A_F,0,0,0,‘’,‘Arcanist Tybalin: show gossip to be disguised if player is not disguised’),
(15,@MENU_ID_A,1,0,9,@QUEST_A,0,0,0,‘’,‘Arcanist Tybalin: show gossip to be disguised if player has the quest’),
(15,@MENU_ID_A,1,1,11,@DISGUISE_A_M,0,0,0,‘’,‘Arcanist Tybalin: show gossip to be disguised if player is not disguised’),
(15,@MENU_ID_A,1,1,9,@QUEST_A,0,0,0,‘’,‘Arcanist Tybalin: show gossip to be disguised if player has the quest’);
– Misc - npc 35507 and 35494 must be passive (they otherwise attack disguised horde players)
UPDATE creature_template SET flags_extra=flags_extra|2, unit_flags=unit_flags|768 WHERE entry IN (35507,35494);
[/sql][/CODE]

Atm there are two problems I’m not able to resolve:

  1. even if you are disguised, the npc shows the option to be re-disguised. This must be due to conditions, but I think they’re right. I used the logical property that (x or y) and z = (x and z) or (y and z), where x = player hasn’t female disguise, y = player hasn’t male disguise, z = player has quest, to build the conditions for the gossip.

  2. more important, choosing the option to be re-disguised, the script that gives you the book is started instead of the script that makes the npc cast the disguise, so that, with bug 1, a player can complete the quest without going to the other npc. Here I really don’t know why this happens.

A quick solution would be to remove the option to be re-disguised (just abandon and retake the quest to be disguised again), but I want to know why the wrong script is called.

The texts are all taken from videos of the official servers. Here’s a link to one of them (the part related to this quest is at the end of the video, starting at 8:50).

NOTE: atm, Dalaran guards don’t allow you to go in the opposite faction zone of Dalaran even if you are disguised (I had to modify their script to fix this), so if you want to try my script, do it with a gm character or spawn the NPCs outside the faction-specific zones. Also, this patch is needed to make the disguising spell work.

SAI handling of gossip options is not working properly. This is a core issue that is being looked into.