Jump to content

[Alt. added in 11852][patch]GOSSIP_OPTION_AUTOSCRIPT


Guest virusav

Recommended Posts

There are cases when you open the menu should trigger action, depending on various conditions.

Patch:

diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h
index 9e46bb2..163ae28 100644
--- a/src/game/GossipDef.h
+++ b/src/game/GossipDef.h
@@ -49,6 +49,7 @@ enum Gossip_Option
    GOSSIP_OPTION_ARMORER           = 15,                   //UNIT_NPC_FLAG_ARMORER             (4096)
    GOSSIP_OPTION_UNLEARNTALENTS    = 16,                   //UNIT_NPC_FLAG_TRAINER             (16) (bonus option for GOSSIP_OPTION_TRAINER)
    GOSSIP_OPTION_UNLEARNPETSKILLS  = 17,                   //UNIT_NPC_FLAG_TRAINER             (16) (bonus option for GOSSIP_OPTION_TRAINER)
+    GOSSIP_OPTION_AUTOSCRIPT        = 18,
    GOSSIP_OPTION_MAX
};

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index a8591ba..828a8ed 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -8737,9 +8737,9 @@ void ObjectMgr::LoadGossipMenuItems()

        if (gMenuItem.action_script_id)
        {
-            if (gMenuItem.option_id != GOSSIP_OPTION_GOSSIP)
+            if (gMenuItem.option_id != GOSSIP_OPTION_GOSSIP && gMenuItem.option_id != GOSSIP_OPTION_AUTOSCRIPT)
            {
-                sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u have action_script_id %u but option_id is not GOSSIP_OPTION_GOSSIP, ignoring", gMenuItem.menu_id, gMenuItem.id, gMenuItem.action_script_id);
+                sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u have action_script_id %u but option_id is not GOSSIP_OPTION_GOSSIP and is not GOSSIP_OPTION_AUTOSCRIPT, ignoring", gMenuItem.menu_id, gMenuItem.id, gMenuItem.action_script_id);
                continue;
            }

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d4e246e..ea3ab39 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -13011,6 +13011,9 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
                    canSeeQuests = false;
                continue;
            }
+
+            if (itr->second.option_id == GOSSIP_OPTION_AUTOSCRIPT)
+                GetMap()->ScriptsStart(sGossipScripts, itr->second.action_script_id, this, pSource);
        }

        if (pSource->GetTypeId() == TYPEID_UNIT) 

Requests for the test patch:

UPDATE `gameobject_template` SET `data3`=2211 WHERE `entry`=160445;
DELETE FROM `gossip_menu_option` WHERE `menu_id`=2211;
DELETE FROM `gossip_scripts` WHERE `id` IN (2211,6540,7);
REPLACE 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`, `cond_1`, `cond_1_val_1`, `cond_1_val_2`, `cond_2`, `cond_2_val_1`, `cond_2_val_2`, `cond_3`, `cond_3_val_1`, `cond_3_val_2`) VALUES
(2211, 0, 0, NULL, 18, 1, -1, 0, 2211, 0, 0, NULL, 9, 3821, 0, 0, 0, 0, 0, 0, 0),
(2211, 1, 0, NULL, 18, 1, -1, 0, 6540, 0, 0, NULL, 22, 3821, 0, 0, 0, 0, 0, 0, 0),
(2211, 2, 0, 'Я не служитель культа, ты, монстр! Иди сюда и встреть свою погибель!', 1, 1, -1, 0, 7, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0);
REPLACE INTO `gossip_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `datalong3`, `datalong4`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `comments`) VALUES
(2211, 1, 10, 9136, 60000, 0, 0, 1, 0, 0, 0, 0, -7917.38, -2610.53, 221.123, 5.04026, ''),
(7, 1, 15, 25035, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ''),
(6540, 1, 15, 24803, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '');

In this version of:

1. In the presence of Quest 3821 - summon NPC.

2. In the absence of Quest 3821 - cast spell.

3. Menu items are displayed regardless of autoscripts.

Link to comment
Share on other sites

EventAI is very fine with only doing combat stuff. I think extending it should be done very slowly and only related to the main focus. (normal mob scripting)

it would be possible to add a new collumn to gossip_menu, to identify a scriiptID, which would fit more naturally into current system.

However one important question: Are there many or more cases where an action would be required in OnGossip-Hello?

If we don't want to add a 'virtual' GOSSIP_OPTION (which is reasonable as of stlye issues)

and there are only very few cases where we need this feature, maybe adding these few gossips by SD2 is as good.

Link to comment
Share on other sites

  • 2 weeks later...

A few thoughts I had:

* EventAI cannot be extended reasonable to support this, mainly because we need such a "onGossipHello" feature for both npcs and GOs

* npc_spellclick_spells also is no reasonable place because of the required GO support

So from current point it looks like:

- either do these cases with sd2

- or do it like you suggest ;)

Link to comment
Share on other sites

  • 4 weeks later...

More thoughts:

RElated to discussion http://udb.no-ip.org/index.php/topic,12817.0.html we crossed this patch again.

Main reason why I still don't like this way the same as in my first note: it tends to break style.

Also there is another reason: currently the options are parsable from sniff (ofc not script ids and conditions), so with this option there would be a new cathegory of custom entries in a place with official entries.

crackm had the idea to change the sql-key fo `gossip_menu` so that multiple scriptIDs could be added to gossip_menu (if required) - with different conditions.

This looks more logical to me, but I am not yet sure of best ways to extend this key -- opinions would be appreciated :)

Edit: Some untested code - http://paste2.org/p/1776398 (sql-changes missing)

Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use