Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB/Gossip: Salanar the Horseman, constant gossip option #15603

Closed
ghost opened this issue Sep 26, 2015 · 23 comments
Closed

DB/Gossip: Salanar the Horseman, constant gossip option #15603

ghost opened this issue Sep 26, 2015 · 23 comments

Comments

@ghost
Copy link

ghost commented Sep 26, 2015

TrinityCore rev. 3f24853 2015-09-25 22:51:42 +0200 (3.3.5 branch) (Win64, Release)

salanar_gossip_quest_itros
http://www.wowhead.com/npc=28653/salanar-the-horseman
http://wotlk.openwow.com/npc=28653 (DK Quest giver NPC)
http://www.wowhead.com/quest=12687/into-the-realm-of-shadows

SELECT * FROM `gossip_menu_option` WHERE `menu_id` = 9739;
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
-------  ------  -----------  -----------------------------------------------  ---------------------  ---------  ------------------  --------------  -------------  ---------  ---------  --------  ------------------
   9739       0            0  Salanar, I must return to the Realm of Shadows.                  28863          1                   1               0              0          0          0                             0

Salanar the Horseman in Scarlet Enclave/Death's Breach is constantly showing the gossip menu option Salanar, I must return to the Realm of Shadows. in all his gossip windows. This option is not supposed to show unless you have taken quest 12687, "Into the Realm of Shadows".

Suggested SQL / DB fix to be inserted in the conditions table:

-- Gossip: Salanar the Horseman / Into the Realm of Shadows
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=9739 AND `ConditionValue1`=12687;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(15,9739,0,0,0,9,0,12687,0,0,0,0,0,'','Salanar the Horseman - on gossip select - Show gossip option only if player has accepted quest 12687, but not completed it.'),
(15,9739,1,0,0,9,0,12687,0,0,0,0,0,'','Salanar the Horseman - on gossip select - Show gossip option only if player has accepted quest 12687, but not completed it.');

Notice that I have based the 2 lines of values above on an already existing condition "Show gossip option only if player has taken quest 5247 but not complete", but I don't know if both of the lines are needed. This is my first attempt to suggest a solution based on conditions, suggested corrections are welcome.

Notice also that gossip_menu_option.menu_id 9739 does not work at all, neither with Quest 12687 accepted nor without it. I would have suggested a solution for that too, but I don't know how to connect a spell to gossip_menu_option.action_menu_id (it should probably be posted as a separate issue).

@MrSmite
Copy link
Contributor

MrSmite commented Sep 26, 2015

I think this would require a script.

For example, take a look at Sayge (14822), the fortune teller from the Darkmoon Faire. After clicking through a bunch of options he will cast a buff spell on the player.

His gossip_menu and gossip_menu_option don't indicate any spells however he does have npc_sayge listed in his creature_template.ScriptName

@ghost
Copy link
Author

ghost commented Sep 26, 2015

Thanks for the tip. I found the script npc_sayge in /src/server/scripts/World/npcs_special.cpp -- so it is a C++ script. I think I will wait and see if Killyana has got any suggestions before I try to write a C++ script.

@Killyana
Copy link
Member

You just need this for the condition :
And of course a cpp to cast the spell on gossip select.

DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=9739 AND `ConditionValue1`=12687;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(15,9739,0,0,0,9,0,12687,0,0,0,0,0,'','Salanar the Horseman - on gossip select - Show gossip option only if player has accepted quest 12687, but not completed it.');

@Pitcrawler
Copy link
Contributor

This can be easily done in SAI. Just have him cast http://www.wowhead.com/spell=52359 and close gossip on gossip option selected.

@CrisPj
Copy link
Contributor

CrisPj commented Sep 26, 2015

Maybe this can help

bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/) override
{
    if(player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
    {
        player->CLOSE_GOSSIP_MENU();
        player->CastSpell(player, SPELL_REALM_OF_SHADOWS, false);
    }
    return true;
}

@ghost
Copy link
Author

ghost commented Sep 27, 2015

Thanks for the tip, I guess that code belongs somewhere in https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp#L728-L807
I'm slightly uncertain about exactly where to place it, but I'll try and see if I can make it work.

Another thing I have noticed about that same quest, http://www.wowhead.com/quest=12687/into-the-realm-of-shadows, is that the level 55 version of Salanar the Horseman, NPC entry 28788, does not say his speech part before overtaking the stolen horse. The event just dismounts the player and removes the aura REALM_OF_SHADOWS, returning the player to the normal view. If I make a PR for the gossip_menu_item and spell, I might as well find a way to make him say his lines before he takes the horse and removes the aura too, since it would need to be inside the script npc_salanar_the_horseman.

Anyway, I am testing your suggestion first:

diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index b37d505..c056edc 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -773,8 +773,18 @@ public:
                 }
             }
         }

+        bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/)
+        {
+            if(player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
+            {
+                player->CLOSE_GOSSIP_MENU();
+                player->CastSpell(player, SPELL_REALM_OF_SHADOWS, false);
+            }
+            return true;
+        }
+
         void MoveInLineOfSight(Unit* who) override
         {
             ScriptedAI::MoveInLineOfSight(who);

Edit: had to remove the keyword override because it caused a general procedure error.

Edit 2: Nope, it compiled, but the code did not work in-game. It needs to be moved or changed.

Edit 3: My mistake, I mistook npc_salanar_the_horseman for the questgiver, though that creature is most likely the level 55 NPC inside the Realm of Shadows. I will have to put that script somewhere else.

@MrSmite
Copy link
Contributor

MrSmite commented Sep 27, 2015

player->GetQuestStatus(12687)

Don't the Trinity standards require the quest ID be defined instead of hard coded?

#define QUEST_INTO_REALM_OF_SHADOWS 12687;
player->GetQuestStatus(QUEST_INTO_REALM_OF_SHADOWS)

@CrisPj
Copy link
Contributor

CrisPj commented Sep 27, 2015

diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index eeb8bd9..1d5ae4a 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -729,8 +729,10 @@ class npc_dark_rider_of_acherus : public CreatureScript
 ## npc_salanar_the_horseman
 ######*/

-enum Spells_Salanar
+enum SalanarTheHorseMan
 {
+    SALANAR_SAY                       = 0,
+    QUEST_INTO_REALMS_OF_SHADOWS      = 12687,
     SPELL_REALM_OF_SHADOWS            = 52693,
     SPELL_EFFECT_STOLEN_HORSE         = 52263,
     SPELL_DELIVER_STOLEN_HORSE        = 52264,
@@ -747,6 +749,16 @@ public:
     {
         return new npc_salanar_the_horsemanAI(creature);
     }
+    
+    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 /*action*/) override
+    {
+        if(player->GetQuestStatus(QUEST_INTO_REALMS_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)
+        {
+            player->CLOSE_GOSSIP_MENU();
+            player->CastSpell(player, SPELL_REALM_OF_SHADOWS, false);
+        }
+        return true;
+    }

     struct npc_salanar_the_horsemanAI : public ScriptedAI
     {
@@ -765,6 +777,7 @@ public:
                             charmer->RemoveAurasDueToSpell(SPELL_EFFECT_STOLEN_HORSE);
                             caster->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                             caster->setFaction(35);
+                            Talk(SALANAR_SAY);
                             DoCast(caster, SPELL_CALL_DARK_RIDER, true);
                             if (Creature* Dark_Rider = me->FindNearestCreature(28654, 15))
                                 ENSURE_AI(npc_dark_rider_of_acherus::npc_dark_rider_of_acherusAI, Dark_Rider->AI())->InitDespawnHorse(caster);
@@ -785,9 +798,9 @@ public:
                     if (Player* player = charmer->ToPlayer())
                     {
                         // for quest Into the Realm of Shadows(12687)
-                        if (me->GetEntry() == 28788 && player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
+                        if (me->GetEntry() == 28788 && player->GetQuestStatus(QUEST_INTO_REALMS_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)
                         {
-                            player->GroupEventHappens(12687, me);
+                            player->GroupEventHappens(QUEST_INTO_REALMS_OF_SHADOWS, me);
                             charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
                             if (Creature* creature = who->ToCreature())
                             {

Text:

-- Salanar text
SET @ENTRY := 28788;
DELETE FROM creature_text WHERE entry = @ENTRY;
INSERT INTO `creature_text` (`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES 
(@ENTRY,0,0,'Impressive, death knight. Return to me in the world of the living for your reward.',12,0,100,0,0,28835,0,0,'Salanar the Horseman');

@ghost
Copy link
Author

ghost commented Sep 27, 2015

@MrSmite : Maybe that is true now, but it certainly doesn't seem like it used to be so. If you look at https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp#L787-L790, you will see that it is not defined like you suggested.

@CreshandKesh : 👍 Thanks a lot for the update, very nice. I'll test it soon and see how it works.

@Pitcrawler : SAI from @astrixoblix (m3 in #trinity), just a draft: http://pastebin.com/BWFVNgTv

-- SAI for quest 12687 (into-the-realm-of-shadow) - Salanar the horseman
SET @SALANAR := 28653;
SET @GOSSIP := 9739;

DELETE FROM `smart_scripts` WHERE `entryorguid`=@SALANAR 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
(@SALANAR, 0, 0, 10, 62, 0, 100, 0, @GOSSIP, 1, 0, 0, 11, 52359, 2, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Salanar the horseman - On Gossip Select - Cast Spell Realm of Shadows');

@Pitcrawler
Copy link
Contributor

Well, I didn't notice he already had a cpp script. So it's best to add the gossip script to it like suggested above.

@MrSmite
Copy link
Contributor

MrSmite commented Sep 28, 2015

@tkrokli : I only suggested it because in the past when I've copied existing code I was asked to change it because "there's no point in perpetuating bad coding style" ;)

@CreshandKesh Thanks for the update

@ghost
Copy link
Author

ghost commented Sep 29, 2015

OK, so now I have tested the suggested patch from @CreshandKesh with some minor additions to improve on the coding style where [NPC 28788] was directly referred to with DB entry instead of being enumerated at the start of the script npc_salanar_the_horseman .

With this patch from CreshandKesh, the SPELL_REALM_OF_SHADOWS is now properly cast when selecting the gossip option Salanar, I must return to the Realm of Shadows. .

diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index b37d505..1b5cd31 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -729,8 +729,12 @@ class npc_dark_rider_of_acherus : public CreatureScript
 ## npc_salanar_the_horseman
 ######*/

-enum Spells_Salanar
+enum SalanarTheHorseMan
 {
+    SALANAR_SAY                       = 0,
+    QUEST_INTO_REALM_OF_SHADOWS       = 12687,
+    DARK_RIDER_OF_ACHERUS             = 28654,
+    SALANAR_IN_REALM_OF_SHADOWS       = 28788,
     SPELL_REALM_OF_SHADOWS            = 52693,
     SPELL_EFFECT_STOLEN_HORSE         = 52263,
     SPELL_DELIVER_STOLEN_HORSE        = 52264,
@@ -747,6 +751,16 @@ public:
     {
         return new npc_salanar_the_horsemanAI(creature);
     }
+
+    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 /*action*/) override
+    {
+        if(player->GetQuestStatus(QUEST_INTO_REALM_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)
+        {
+            player->CLOSE_GOSSIP_MENU();
+            player->CastSpell(player, SPELL_REALM_OF_SHADOWS, false);
+        }
+        return true;
+    }

     struct npc_salanar_the_horsemanAI : public ScriptedAI
     {
@@ -765,8 +779,9 @@ public:
                             charmer->RemoveAurasDueToSpell(SPELL_EFFECT_STOLEN_HORSE);
                             caster->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                             caster->setFaction(35);
+                            Talk(SALANAR_SAY);
                             DoCast(caster, SPELL_CALL_DARK_RIDER, true);
-                            if (Creature* Dark_Rider = me->FindNearestCreature(28654, 15))
+                            if (Creature* Dark_Rider = me->FindNearestCreature(DARK_RIDER_OF_ACHERUS, 15))
                                 ENSURE_AI(npc_dark_rider_of_acherus::npc_dark_rider_of_acherusAI, Dark_Rider->AI())->InitDespawnHorse(caster);
                         }
                     }
@@ -784,10 +799,9 @@ public:
                 {
                     if (Player* player = charmer->ToPlayer())
                     {
-                        // for quest Into the Realm of Shadows(12687)
-                        if (me->GetEntry() == 28788 && player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
+                        if (me->GetEntry() == SALANAR_IN_REALM_OF_SHADOWS && player->GetQuestStatus(QUEST_INTO_REALM_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)
                         {
-                            player->GroupEventHappens(12687, me);
+                            player->GroupEventHappens(QUEST_INTO_REALM_OF_SHADOWS, me);
                             charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
                             if (Creature* creature = who->ToCreature())
                             {
-- Salanar the Horseman (NPC 28788) say line in Realm of Shadows
SET @ENTRY := 28788;
DELETE FROM `creature_text` WHERE `entry` = @ENTRY;
INSERT INTO `creature_text` (`entry`,`groupid`,`id`,`text`,`type`,`language`,`probability`,`emote`,`duration`,`sound`,`BroadcastTextId`,`TextRange`,`comment`) VALUES 
(@ENTRY,0,0,'Impressive, death knight. Return to me in the world of the living for your reward.',12,0,100,0,0,0,28835,0,'SALANAR_SAY');

-- Salanar the Horseman (NPC 28653) conditions for the gossip_menu_option to be shown for Into the Realm of Shadows
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=9739 AND `ConditionValue1`=12687;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
(15,9739,0,0,0,9,0,12687,0,0,0,0,0,'','Salanar the Horseman - on gossip select - Show gossip option only if player has accepted quest 12687, but not completed it.');

However, [Salanar the Horseman] does not say anything upon delivery of the [Acherus Deathcharger] (sub-issue unchanged), have I made any changes that I shouldn't have in the core script?

Edit: Never mind my idea that I made any unlucky changes, I tested the unchanged C++ script now, just had to make a minor change in the SQL part for inserting the text into creature_text because the values for sound (0) and BroadcastTextId (28835) were swapped in the suggested version. No change to the delivery part of the quest, Salanar (entry 28788) does not turn around or say any text to the player. This is of course just a cosmetic and minor part of the issue, so I could possibly create a PR without that part. I just think it would have made a nice addition if we were able to find a way to make NPC 28788 say his line before dismounting the player and removing aura 52693 (SPELL_REALM_OF_SHADOWS).

Anyway, I will try copying or moving the Talk(SALANAR_SAY); part between some of the other lines to see if I can get luck by taking pot shots on where it would be called by the script.

Edit 2: No luck, could not make the say line appear. Could there be anything worth looking at in the preceding script npc_dark_rider_of_acherus, in the following section?

                if (PhaseTimer <= diff)
                {
                    switch (Phase)
                    {
                       case 0:
                            Talk(SAY_DARK_RIDER);
                            PhaseTimer = 5000;
                            Phase = 1;
                            break;
                        case 1:
                            if (Unit* target = ObjectAccessor::GetUnit(*me, TargetGUID))
                                DoCast(target, SPELL_DESPAWN_HORSE, true);
                            PhaseTimer = 3000;
                            Phase = 2;
                            break;
                        case 2:
                            me->SetVisible(false);
                            PhaseTimer = 2000;
                            Phase = 3;
                            break;
                        case 3:
                            me->DespawnOrUnsummon();
                            break;
                        default:
                            break;
                    }
                }

I don't know enough to tell what sort of code would make that mini-event happen. Sorry about that.
Do you think I should make a PR out of my modified patch and see if any of the main developers could assist in finding out more about the missing action from Salanar (28788) inside the Realm of Shadows?

@CrisPj
Copy link
Contributor

CrisPj commented Sep 30, 2015

@MrSmite
Copy link
Contributor

MrSmite commented Sep 30, 2015

@tkrokli Try this:

Talk(SALANAR_SAY, charmer);

In the block for SPELL_DELIVER_STOLEN_HORSE, charmer refers to the player. Try adding that as a Talk() target and see if it works.

In CreatureTextMgr::SendChat(), without a target the creature uses itself as a target. I don't know if this is correct or not but it seems strange that a creature would say something to itself.

@ghost
Copy link
Author

ghost commented Sep 30, 2015

@CreshandKesh : Thank you for the updated suggestion. I did try to copy it there in addition to keeping it in your original line as well and also adding it to 2 more lines (though I have removed that info now because it did not seem to make any difference). I will test your new suggestion, to move it as just 1 insert (instead of using it in 3 or 4 lines) and see if that is where I went wrong.

@MrSmite :

In CreatureTextMgr::SendChat(), without a target, the creature uses itself as a target. I don't know if this is correct or not but it seems strange that a creature would say something to itself.

Now that is an interesting thought. I wonder if that is why the /say lines appear from the player char instead of the NPC, both in the quest event [The Endless Hunger] (quest 4 from the start) where the player targets the NPC and says lines like [Sate your hunger on cold steel, $r!] as well as the quest [Death's Challenge] where the player says [You don\'t stand a chance, $n.] and [Remember this day, $n, for it is the day that you will be thoroughly owned.] (which should be said by the NPC) because it is apparently not possible for the player char to look up any NPC race or name info.
This text should be filled in correctly when used in the opposite direction, said by the NPC while targeting the player char.

@ghost
Copy link
Author

ghost commented Sep 30, 2015

Sorry, no luck with any of your suggestions for where to put the line or how any of the 3 alternatives.

Talk(SALANAR_SAY);
Talk(SALANAR_SAY, player);
Talk(SALANAR_SAY, charmer);

But I think I have discovered why this doesn't work (or what is missing for it to work). None of the scripts in src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp refer to the built-in spells used to summon NPC 28788 (Salanar the Horseman). They seem to be used for the previous quest, GTP.

[SPELL_EFFECT_STOLEN_HORSE] (http://wotlk.openwow.com/spell=52263) belongs to [Grand Theft Palomino]
Spell name: [Stolen Horse]. Description: You've got the horse, now get it back to Salanar! (check spell icon)

[SPELL_DELIVER_STOLEN_HORSE] (http://wotlk.openwow.com/spell=52264) Delivers the stolen horse to Salanar. Must be within 5 yards of Salanar to activate. Effect 2: 28767 => http://wotlk.openwow.com/npc=28767 => [Phase 1] Havenshrie Horse Credit, Step 01 => Objective of [Grand Theft Palomino]

[SPELL_CALL_DARK_RIDER] (http://wotlk.openwow.com/spell=52266) is used to summon [NPC 28654, Dark Rider of Acherus (56)], not NPC 28788, Salanar the Horseman (55)

[SPELL_EFFECT_OVERTAKE] (http://wotlk.openwow.com/spell=52349, Overtake) is triggered by http://wotlk.openwow.com/spell=52350, Overtake (Use to overtake the Acherus Deathcharger once you have slain the Dark Rider of Acherus.)

Looking only at the spell enumerations (enums), it feels like the script stops halfway into the followup quest, [Into the Realm of Shadows]. Maybe we should add spells and script for the actual delivery?

Even so, it looks like these spells are already cast by the vehicle when clicking the toolbar button [1], but we are still stuck with NPC 28788 who does not react until the vehicle reaches 0 (zero) distance to the NPC, where he dismounts the player and removes aura 52693, [Realm of Shadows]

I am going to test moving the say line down to this section to see if anything useful happens:

        void MoveInLineOfSight(Unit* who) override
        {
            ScriptedAI::MoveInLineOfSight(who);

            if (who->GetTypeId() == TYPEID_UNIT && who->IsVehicle() && me->IsWithinDistInMap(who, 15.0f))
            {
                if (Unit* charmer = who->GetCharmer())
                {
                    if (Player* player = charmer->ToPlayer())
                    {
                        if (me->GetEntry() == SALANAR_IN_REALM_OF_SHADOWS && player->GetQuestStatus(QUEST_INTO_REALM_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)
                        {
                            player->GroupEventHappens(QUEST_INTO_REALM_OF_SHADOWS, me);
                            Talk(SALANAR_SAY, charmer);
                            charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
                            if (Creature* creature = who->ToCreature())
                            {
                                creature->DespawnOrUnsummon();
                                //creature->Respawn(true);
                            }
                        }

                        if (player->HasAura(SPELL_REALM_OF_SHADOWS))
                            player->RemoveAurasDueToSpell(SPELL_REALM_OF_SHADOWS);
                    }
                }
            }
        }

@ghost
Copy link
Author

ghost commented Sep 30, 2015

If the text you're trying to make him say is

(@ENTRY,0,0,'Impressive, death knight. Return to me in the world of the living for your reward.',12,0,100,0,0,28835,0,0,'Salanar the Horseman');

Then don't provide a target. Target should only be provided if there's any parser to receive it ($n, $c, $r etc).

@ghost
Copy link
Author

ghost commented Sep 30, 2015

Thanks, I will test that. Although when I changed the end value in https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp#L781,

if (who->GetTypeId() == TYPEID_UNIT && who->IsVehicle() && me->IsWithinDistInMap(who, 5.0f))

from 5.0f to 15.0f , it caused the player char to be dismounted immediately upon pressing the toolbar spell button and the say text appeared in the chat window (but no animation took place, maybe because of no wait time between the say command and the despawn action). Is there a general command to delay an action inside a script, or does it need switch and case like in https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp#L666-L700 ?

Edit: The distance between the player character and NPC 28788 is 10.0f when he is summoned. I am only able to produce that say line in the chat log/chat window at the exact same moment as my character gets close enough to NPC 28788 to become dismounted and have the aura removed. I wonder if this challenge is what kept the original writers of the script npc_salanar_the_horseman from finishing this, seeing as the delivery and quest credit gets completed without the cosmetic event and short speech.

@ghost
Copy link
Author

ghost commented Oct 1, 2015

SELECT `entry`,`name`,`gossip_menu_id`,`minlevel`,`maxlevel`,`exp`,`npcflag`,`speed_run`,`unit_flags`,`ScriptName`,`VerifiedBuild` FROM `creature_template` WHERE `name`= 'Salanar the Horseman';
 entry  name                  gossip_menu_id  minlevel  maxlevel     exp  npcflag  speed_run  unit_flags  ScriptName                VerifiedBuild
------  --------------------  --------------  --------  --------  ------  -------  ---------  ----------  ------------------------  -------------
 28653  Salanar the Horseman            9739        80        80       2        3    1.19048       32768  npc_salanar_the_horseman          12340
 28788  Salanar the Horseman               0        55        55       0        0    1.14286           0  npc_salanar_the_horseman          12340
 28908  Salanar the Horseman            9751        80        80       2        1    1.38571       32768                                    12340

Both NPC entry 28788 and NPC entry 28653 share the script npc_salanar_the_horseman. I don't think this is a good solution for 2 separate NPCs. Wouldn't it be better to let them have separate scripts?

@Pitcrawler : Maybe a SAI could be a better solution to have a separate script for "Realm of Shadows" Salanar the Horseman (entry 28788) and keep the core script for quest giver Salanar the Horseman, entry 28653 (lvl 80 elite). I will try to make one for the event where NPC 28788 walks up to the player character, pauses and says his text, before he dismounts the player and removes aura 52693.
Or am I making it too complicated? Do you have any useful tips to point me in the right direction? :)

EDIT: "quick-n-dirty" attempt at lining up all the actions, used Keira2 for this simplistic and untested draft. Feel free to correct me, I haven't tested it yet (likely lots of mistakes on my part).

-- Creating a new SmartAI script for [Creature] ENTRY 28788 (name: Salanar the Horseman)

-- Table `creature_template`
UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 28788;

-- Table `smart_scripts`
DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 28788);
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
(28788, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 21, 10, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - On Initialize - Set Orientation Closest Player'),
(28788, 0, 1, 0, 54, 0, 100, 0, 0, 0, 0, 0, 46, 5, 0, 0, 0, 0, 0, 21, 10, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - On Just Summoned - Move Forward 5 Yards'),
(28788, 0, 2, 0, 58, 0, 100, 0, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - On Waypoint Finished - Play Emote 2'),
(28788, 0, 3, 0, 9, 0, 100, 0, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - Within 0-5 Range - Say Line 0'),
(28788, 0, 4, 0, 52, 0, 100, 0, 0, 28788, 0, 0, 11, 52267, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - On Text 0 Over - Cast \'Despawn Horse\''),
(28788, 0, 5, 0, 52, 0, 100, 0, 0, 28788, 0, 0, 28, 52693, 0, 0, 0, 0, 0, 21, 5, 0, 0, 0, 0, 0, 0, 'Salanar the Horseman - On Text 0 Over - Remove Aura \'Realm of Shadows\'');

@MrSmite
Copy link
Contributor

MrSmite commented Oct 1, 2015

Both NPC entry 28788 and NPC entry 28653 share the script npc_salanar_the_horseman. I don't think this is a good solution for 2 separate NPCs. Wouldn't it be better to let them have separate scripts?

Depends how the script is written. If written properly, it can look at the NPC (switch()) and do one thing for 28788 and another for 28653.

@ghost
Copy link
Author

ghost commented Oct 2, 2015

OK, thanks for the feedback.
Maybe I am being overzealous with this attempt to make NPC 28788 say his line before throwing the player back out of the Realm of Shadows. Maybe I should just leave it for a different issue and just be happy with creating a PR for making the gossip_option work in-game and add the conditions line.
That is an actual improvement in itself, when looking back at my original post at the top of this page. 😏

@Killyana
Copy link
Member

Killyana commented Oct 2, 2015

I think this check is not required as there's already a condition on the DB:

&& player->GetQuestStatus(QUEST_INTO_REALM_OF_SHADOWS) == QUEST_STATUS_INCOMPLETE)

@ghost
Copy link
Author

ghost commented Oct 2, 2015

OK, thanks for the suggestion. 👍 I will test it tomorrow night, when I'm back from other activities.

Edit: I just tested removing that part of the code, but it failed to compile. Original line:

if (me->GetEntry() == 28788 && player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)

Then after modifying the line,

if me->GetEntry() == 28788

it did not compile due to missing semicolon or the if condition was invalid. It works if it is left unchanged.
https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp#L777-L804

joschiwald pushed a commit that referenced this issue Oct 4, 2015
- Show gossip_menu_option 9739 only if quest 12687 is accepted & not completed
- Cast spell 52693, SPELL_REALM_OF_SHADOWS, when gossip option is selected

Core script by @CreshandKesh (with some modifications)
SQL part by @CreshandKesh and @tkrokli, condition adjustment by @Killyana.

Closes #15603
Closes #15657
FrancescoBorzi pushed a commit to FrancescoBorzi/TrinityCore that referenced this issue Oct 8, 2015
- Show gossip_menu_option 9739 only if quest 12687 is accepted & not completed
- Cast spell 52693, SPELL_REALM_OF_SHADOWS, when gossip option is selected

Core script by @CreshandKesh (with some modifications)
SQL part by @CreshandKesh and @tkrokli, condition adjustment by @Killyana.

Closes TrinityCore#15603
Closes TrinityCore#15657
MitchesD pushed a commit that referenced this issue Nov 6, 2015
- Show gossip_menu_option 9739 only if quest 12687 is accepted & not completed
- Cast spell 52693, SPELL_REALM_OF_SHADOWS, when gossip option is selected

Core script by @CreshandKesh (with some modifications)
SQL part by @CreshandKesh and @tkrokli, condition adjustment by @Killyana.

Closes #15603
Closes #15657

(cherry picked from commit 359df54)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants