Core/AdventureMap: Handle CMSG_ADVENTURE_MAP_START_QUEST

Port From (https://github.com/TrinityCore/TrinityCore/commit/08e017b3512ce8189adc6762e3670c20c900f54e)
This commit is contained in:
hondacrx
2021-03-17 13:38:49 -04:00
parent cf1f8e7385
commit 70cc1d7d50
9 changed files with 180 additions and 41 deletions
@@ -31,8 +31,8 @@ namespace Framework.Constants
AddIgnore = 0x36d4,
AddToy = 0x32a6,
AdventureJournalOpenQuest = 0x3206,
AdventureJournalStartQuest = 0x335b,
AdventureJournalUpdateSuggestions = 0x33e2,
AdventureMapStartQuest = 0x335b,
AlterAppearance = 0x3503,
AreaSpiritHealerQuery = 0x34b6,
AreaSpiritHealerQueue = 0x34b7,
@@ -33,6 +33,11 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_ADVENTURE_JOURNAL_LOCALE, "SELECT ID, Name_lang, Description_lang, ButtonText_lang, RewardDescription_lang, " +
"ContinueDescription_lang FROM adventure_journal_locale WHERE locale = ?");
// AdventureMapPoi.db2
PrepareStatement(HotfixStatements.SEL_ADVENTURE_MAP_POI, "SELECT ID, Title, Description, WorldPositionX, WorldPositionY, Type, PlayerConditionID, QuestID, " +
"LfgDungeonID, RewardItemID, UiTextureAtlasMemberID, UiTextureKitID, MapID, AreaTableID FROM adventure_map_poi");
PrepareStatement(HotfixStatements.SEL_ADVENTURE_MAP_POI_LOCALE, "SELECT ID, Title_lang, Description_lang FROM adventure_map_poi_locale WHERE locale = ?");
// AnimationData.db2
PrepareStatement(HotfixStatements.SEL_ANIMATION_DATA, "SELECT ID, BehaviorID, BehaviorTier, Fallback, Flags1, Flags2 FROM animation_data");
@@ -1158,6 +1163,9 @@ namespace Framework.Database
SEL_ADVENTURE_JOURNAL,
SEL_ADVENTURE_JOURNAL_LOCALE,
SEL_ADVENTURE_MAP_POI,
SEL_ADVENTURE_MAP_POI_LOCALE,
SEL_ANIMATION_DATA,
SEL_ANIM_KIT,
+2
View File
@@ -52,6 +52,7 @@ namespace Game.DataStorage
AchievementStorage = ReadDB2<AchievementRecord>("Achievement.db2", HotfixStatements.SEL_ACHIEVEMENT, HotfixStatements.SEL_ACHIEVEMENT_LOCALE);
AdventureJournalStorage = ReadDB2<AdventureJournalRecord>("AdventureJournal.db2", HotfixStatements.SEL_ADVENTURE_JOURNAL, HotfixStatements.SEL_ADVENTURE_JOURNAL_LOCALE);
AdventureMapPOIStorage = ReadDB2<AdventureMapPOIRecord>("AdventureMapPOI.db2", HotfixStatements.SEL_ADVENTURE_MAP_POI, HotfixStatements.SEL_ADVENTURE_MAP_POI_LOCALE);
AnimationDataStorage = ReadDB2<AnimationDataRecord>("AnimationData.db2", HotfixStatements.SEL_ANIMATION_DATA);
AnimKitStorage = ReadDB2<AnimKitRecord>("AnimKit.db2", HotfixStatements.SEL_ANIM_KIT);
AreaGroupMemberStorage = ReadDB2<AreaGroupMemberRecord>("AreaGroupMember.db2", HotfixStatements.SEL_AREA_GROUP_MEMBER);
@@ -412,6 +413,7 @@ namespace Game.DataStorage
#region Main Collections
public static DB6Storage<AchievementRecord> AchievementStorage;
public static DB6Storage<AdventureJournalRecord> AdventureJournalStorage;
public static DB6Storage<AdventureMapPOIRecord> AdventureMapPOIStorage;
public static DB6Storage<AnimationDataRecord> AnimationDataStorage;
public static DB6Storage<AnimKitRecord> AnimKitStorage;
public static DB6Storage<AreaGroupMemberRecord> AreaGroupMemberStorage;
+21 -4
View File
@@ -46,10 +46,10 @@ namespace Game.DataStorage
{
public uint Id;
public LocalizedString Name;
public LocalizedString Description;
public LocalizedString ButtonText;
public LocalizedString RewardDescription;
public LocalizedString ContinueDescription;
public string Description;
public string ButtonText;
public string RewardDescription;
public string ContinueDescription;
public byte Type;
public uint PlayerConditionID;
public byte Flags;
@@ -69,6 +69,23 @@ namespace Game.DataStorage
public byte[] BonusValue = new byte[2];
}
public sealed class AdventureMapPOIRecord
{
public uint Id;
public LocalizedString Title;
public string Description;
public Vector2 WorldPosition;
public sbyte Type;
public uint PlayerConditionID;
public uint QuestID;
public uint LfgDungeonID;
public int RewardItemID;
public uint UiTextureAtlasMemberID;
public uint UiTextureKitID;
public int MapID;
public uint AreaTableID;
}
public sealed class AnimationDataRecord
{
public uint Id;
@@ -58,30 +58,6 @@ namespace Game
_player.PlayerTalkClass.SendQuestGiverQuestDetails(quest, _player.GetGUID(), true, false);
}
[WorldPacketHandler(ClientOpcodes.AdventureJournalStartQuest)]
void HandleAdventureJournalStartQuest(AdventureJournalStartQuest startQuest)
{
Quest quest = Global.ObjectMgr.GetQuestTemplate(startQuest.QuestID);
if (quest == null)
return;
AdventureJournalRecord adventureJournalEntry = null;
foreach (var adventureJournal in CliDB.AdventureJournalStorage.Values)
{
if (quest.Id == adventureJournal.QuestID)
{
adventureJournalEntry = adventureJournal;
break;
}
}
if (adventureJournalEntry == null)
return;
if (_player.MeetPlayerCondition(adventureJournalEntry.PlayerConditionID) && _player.CanTakeQuest(quest, true))
_player.AddQuestAndCheckCompletion(quest, null);
}
[WorldPacketHandler(ClientOpcodes.AdventureJournalUpdateSuggestions)]
void HandleAdventureJournalUpdateSuggestions(AdventureJournalUpdateSuggestions updateSuggestions)
{
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Framework.IO;
using Game.BattleGrounds;
using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Guilds;
using Game.Maps;
using Game.Misc;
using Game.Networking;
using Game.Networking.Packets;
using Game.PvP;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Game
{
public partial class WorldSession
{
[WorldPacketHandler(ClientOpcodes.AdventureMapStartQuest)]
void HandleAdventureMapStartQuest(AdventureMapStartQuest startQuest)
{
Quest quest = Global.ObjectMgr.GetQuestTemplate(startQuest.QuestID);
if (quest == null)
return;
var adventureMapPOI = CliDB.AdventureMapPOIStorage.Values.FirstOrDefault(adventureMap =>
{
return adventureMap.QuestID == startQuest.QuestID && _player.MeetPlayerCondition(adventureMap.PlayerConditionID);
});
if (adventureMapPOI == null)
return;
if (_player.CanTakeQuest(quest, true))
_player.AddQuestAndCheckCompletion(quest, _player);
}
}
}
@@ -36,18 +36,6 @@ namespace Game.Networking.Packets
public uint AdventureJournalID;
}
class AdventureJournalStartQuest : ClientPacket
{
public AdventureJournalStartQuest(WorldPacket packet) : base(packet) { }
public override void Read()
{
QuestID = _worldPacket.ReadUInt32();
}
public uint QuestID;
}
class AdventureJournalUpdateSuggestions : ClientPacket
{
public AdventureJournalUpdateSuggestions(WorldPacket packet) : base(packet) { }
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Framework.Dynamic;
using Framework.GameMath;
using Game.Entities;
using System;
using System.Collections.Generic;
namespace Game.Networking.Packets
{
class AdventureMapStartQuest : ClientPacket
{
public AdventureMapStartQuest(WorldPacket packet) : base(packet) { }
public override void Read()
{
QuestID = _worldPacket.ReadUInt32();
}
public uint QuestID;
}
}
@@ -0,0 +1,52 @@
--
-- Table structure for table `adventure_map_poi`
--
DROP TABLE IF EXISTS `adventure_map_poi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `adventure_map_poi` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`Title` text,
`Description` text,
`WorldPositionX` float NOT NULL DEFAULT '0',
`WorldPositionY` float NOT NULL DEFAULT '0',
`Type` tinyint(4) NOT NULL DEFAULT '0',
`PlayerConditionID` int(10) unsigned NOT NULL DEFAULT '0',
`QuestID` int(10) unsigned NOT NULL DEFAULT '0',
`LfgDungeonID` int(10) unsigned NOT NULL DEFAULT '0',
`RewardItemID` int(11) NOT NULL DEFAULT '0',
`UiTextureAtlasMemberID` int(10) unsigned NOT NULL DEFAULT '0',
`UiTextureKitID` int(10) unsigned NOT NULL DEFAULT '0',
`MapID` int(11) NOT NULL DEFAULT '0',
`AreaTableID` int(10) unsigned NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `adventure_map_poi_locale`
--
DROP TABLE IF EXISTS `adventure_map_poi_locale`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `adventure_map_poi_locale` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`locale` varchar(4) NOT NULL,
`Title_lang` text,
`Description_lang` text,
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`locale`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
/*!50500 PARTITION BY LIST COLUMNS(locale)
(PARTITION deDE VALUES IN ('deDE') ENGINE = InnoDB,
PARTITION esES VALUES IN ('esES') ENGINE = InnoDB,
PARTITION esMX VALUES IN ('esMX') ENGINE = InnoDB,
PARTITION frFR VALUES IN ('frFR') ENGINE = InnoDB,
PARTITION itIT VALUES IN ('itIT') ENGINE = InnoDB,
PARTITION koKR VALUES IN ('koKR') ENGINE = InnoDB,
PARTITION ptBR VALUES IN ('ptBR') ENGINE = InnoDB,
PARTITION ruRU VALUES IN ('ruRU') ENGINE = InnoDB,
PARTITION zhCN VALUES IN ('zhCN') ENGINE = InnoDB,
PARTITION zhTW VALUES IN ('zhTW') ENGINE = InnoDB) */;
/*!40101 SET character_set_client = @saved_cs_client */;