PDA

Просмотр полной версии : [patch]GOSSIP_OPTION_AUTOSCRIPT


virusav
28.09.2011, 14:40
Есть случаи, когда при открытии меню должно срабатывать действие в зависимости от разных условий.

Патч во вложении, дубль кодом:
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)
Запросы для теста патча:
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, '');
В таком варианте:
1. При наличии квеста 3821 - суммон нпц.
2. При отсутствии квеста 3821 - каст спелла.
3. Пункты меню выводятся независимо от автоскриптов.

NeatElves
28.09.2011, 15:29
Продолжая тему, можно убрать принудительный кредит тогда в ядре, все равно он работает только тогда, когда условие квеста совпадает с ид нпц:
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index d4e246e..20fe76d 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -13025,8 +13025,6 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
switch(itr->second.option_id)
{
case GOSSIP_OPTION_GOSSIP:
- if (itr->second.action_menu_id != 0) // has sub menu (or close gossip), so do not "talk" with this NPC yet
- canTalkToCredit = false;
break;
case GOSSIP_OPTION_QUESTGIVER:
hasMenuItem = false;
@@ -13146,12 +13144,6 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
if (canSeeQuests)
PrepareQuestMenu(pSource->GetObjectGuid());

- if (canTalkToCredit)
- {
- if (pSource->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
- TalkedToCreature(pSource->GetEntry(), pSource->GetObjectGuid());
- }
-
// some gossips aren't handled in normal way ... so we need to do it this way .. TODO: handle it in normal way ;-)
/*if (pMenu->Empty())
{

Пример http://ru.wowhead.com/quest=9663
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
('7434', '0', '0', NULL, '18', '1', '-1', '0', '7434', '0', '0', NULL, '9', '9663', '0', '0, '0', '0', '0', '0', '0'),
('7370', '1', '0', NULL, '18', '1', '-1', '0', '7370', '0', '0', NULL, '9', '9663', '0', '0', '0', '0', '0', '0', '0'),
('7399', '1', '0', NULL, '18', '1', '-1', '0', '17', '0', '0', NULL, '9', '9663', '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
('7434', '1', '8', '17440', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', ''),
('7370', '1', '8', '17116', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', ''),
('17', '1', '8', '17240', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '');

schmoozerd
30.11.2011, 22:45
about the part of NeatElves:
Added in [11853] a new flag_extra (for temporay use - while converting) to prevent unneeded bugs until convertion progress is complete :)

virusav
30.11.2011, 23:07
Альтернативный патч принят в 11852.