Core/Quests: Implemented player choice rewards
DB/Creature: Cosmetic Mottled Raptor
This commit is contained in:
@@ -226,6 +226,7 @@ namespace Game.Misc
|
||||
|
||||
public ObjectGuid SourceGuid;
|
||||
public uint TrainerId;
|
||||
public uint PlayerChoiceId;
|
||||
}
|
||||
|
||||
public class PlayerMenu
|
||||
|
||||
@@ -838,6 +838,51 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RewardQuestPackage(uint questPackageId, uint onlyItemId = 0)
|
||||
{
|
||||
bool hasFilteredQuestPackageReward = false;
|
||||
var questPackageItems = Global.DB2Mgr.GetQuestPackageItems(questPackageId);
|
||||
if (questPackageItems != null)
|
||||
{
|
||||
foreach (QuestPackageItemRecord questPackageItem in questPackageItems)
|
||||
{
|
||||
if (onlyItemId != 0 && questPackageItem.ItemID != onlyItemId)
|
||||
continue;
|
||||
|
||||
if (CanSelectQuestPackageItem(questPackageItem))
|
||||
{
|
||||
hasFilteredQuestPackageReward = true;
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemCount) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemCount, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFilteredQuestPackageReward)
|
||||
{
|
||||
var questPackageItemsFallback = Global.DB2Mgr.GetQuestPackageItemsFallback(questPackageId);
|
||||
if (questPackageItemsFallback != null)
|
||||
{
|
||||
foreach (QuestPackageItemRecord questPackageItem in questPackageItemsFallback)
|
||||
{
|
||||
if (onlyItemId != 0 && questPackageItem.ItemID != onlyItemId)
|
||||
continue;
|
||||
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemCount) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemCount, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RewardQuest(Quest quest, uint reward, WorldObject questGiver, bool announce = true)
|
||||
{
|
||||
//this THING should be here to protect code from quest, which cast on player far teleport as a reward
|
||||
@@ -893,49 +938,7 @@ namespace Game.Entities
|
||||
|
||||
// QuestPackageItem.db2
|
||||
if (rewardProto != null && quest.PackageID != 0)
|
||||
{
|
||||
bool hasFilteredQuestPackageReward = false;
|
||||
var questPackageItems = Global.DB2Mgr.GetQuestPackageItems(quest.PackageID);
|
||||
if (questPackageItems != null)
|
||||
{
|
||||
foreach (var questPackageItem in questPackageItems)
|
||||
{
|
||||
if (questPackageItem.ItemID != reward)
|
||||
continue;
|
||||
|
||||
if (CanSelectQuestPackageItem(questPackageItem))
|
||||
{
|
||||
hasFilteredQuestPackageReward = true;
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemCount) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemCount, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFilteredQuestPackageReward)
|
||||
{
|
||||
List<QuestPackageItemRecord> questPackageItems1 = Global.DB2Mgr.GetQuestPackageItemsFallback(quest.PackageID);
|
||||
if (questPackageItems1 != null)
|
||||
{
|
||||
foreach (QuestPackageItemRecord questPackageItem in questPackageItems1)
|
||||
{
|
||||
if (questPackageItem.ItemID != reward)
|
||||
continue;
|
||||
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, questPackageItem.ItemID, questPackageItem.ItemCount) == InventoryResult.Ok)
|
||||
{
|
||||
Item item = StoreNewItem(dest, questPackageItem.ItemID, true, ItemEnchantment.GenerateItemRandomPropertyId(questPackageItem.ItemID));
|
||||
SendNewItem(item, questPackageItem.ItemCount, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RewardQuestPackage(quest.PackageID, reward);
|
||||
|
||||
if (quest.GetRewItemsCount() > 0)
|
||||
{
|
||||
|
||||
@@ -408,11 +408,11 @@ namespace Game.Entities
|
||||
SendPacket(cooldowns);
|
||||
}
|
||||
|
||||
bool UpdateSkillPro(SkillType skillId, int chance, uint step)
|
||||
public bool UpdateSkillPro(SkillType skillId, int chance, uint step)
|
||||
{
|
||||
return UpdateSkillPro((uint)skillId, chance, step);
|
||||
}
|
||||
bool UpdateSkillPro(uint skillId, int chance, uint step)
|
||||
public bool UpdateSkillPro(uint skillId, int chance, uint step)
|
||||
{
|
||||
// levels sync. with spell requirement for skill levels to learn
|
||||
// bonus abilities in sSkillLineAbilityStore
|
||||
|
||||
@@ -4994,37 +4994,97 @@ namespace Game.Entities
|
||||
SendMessageToSet(updateCollisionHeight, false);
|
||||
}
|
||||
|
||||
public void SendPlayerChoice(ObjectGuid sender, uint choiceID)
|
||||
public void SendPlayerChoice(ObjectGuid sender, int choiceId)
|
||||
{
|
||||
PlayerChoice playerChoice = Global.ObjectMgr.GetPlayerChoice((int)choiceID);
|
||||
PlayerChoice playerChoice = Global.ObjectMgr.GetPlayerChoice(choiceId);
|
||||
if (playerChoice == null)
|
||||
return;
|
||||
|
||||
PlayerChoice localizedPlayerChoice = playerChoice;
|
||||
|
||||
LocaleConstant locale = GetSession().GetSessionDbLocaleIndex();
|
||||
if (locale != LocaleConstant.enUS)
|
||||
{
|
||||
PlayerChoiceLocale playerChoiceLocale = Global.ObjectMgr.GetPlayerChoiceLocale((uint)localizedPlayerChoice.ChoiceId);
|
||||
if (playerChoiceLocale != null)
|
||||
ObjectManager.GetLocaleString(playerChoiceLocale.Question, locale, ref localizedPlayerChoice.Question);
|
||||
PlayerChoiceLocale playerChoiceLocale = locale != LocaleConstant.enUS ? Global.ObjectMgr.GetPlayerChoiceLocale(choiceId) : null;
|
||||
|
||||
foreach (var playerChoiceResponse in localizedPlayerChoice.Responses)
|
||||
PlayerTalkClass.GetInteractionData().Reset();
|
||||
PlayerTalkClass.GetInteractionData().SourceGuid = sender;
|
||||
PlayerTalkClass.GetInteractionData().PlayerChoiceId = (uint)choiceId;
|
||||
|
||||
DisplayPlayerChoice displayPlayerChoice = new DisplayPlayerChoice();
|
||||
displayPlayerChoice.SenderGUID = sender;
|
||||
displayPlayerChoice.ChoiceID = choiceId;
|
||||
displayPlayerChoice.Question = playerChoice.Question;
|
||||
if (playerChoiceLocale != null)
|
||||
ObjectManager.GetLocaleString(playerChoiceLocale.Question, locale, ref displayPlayerChoice.Question);
|
||||
|
||||
displayPlayerChoice.CloseChoiceFrame = false;
|
||||
|
||||
for (var i = 0; i < playerChoice.Responses.Count; ++i)
|
||||
{
|
||||
PlayerChoiceResponse playerChoiceResponseTemplate = playerChoice.Responses[i];
|
||||
var playerChoiceResponse = new Network.Packets.PlayerChoiceResponse();
|
||||
|
||||
playerChoiceResponse.ResponseID = playerChoiceResponseTemplate.ResponseId;
|
||||
playerChoiceResponse.ChoiceArtFileID = playerChoiceResponseTemplate.ChoiceArtFileId;
|
||||
playerChoiceResponse.Answer = playerChoiceResponseTemplate.Answer;
|
||||
playerChoiceResponse.Header = playerChoiceResponseTemplate.Header;
|
||||
playerChoiceResponse.Description = playerChoiceResponseTemplate.Description;
|
||||
playerChoiceResponse.Confirmation = playerChoiceResponseTemplate.Confirmation;
|
||||
if (playerChoiceLocale != null)
|
||||
{
|
||||
PlayerChoiceResponseLocale playerChoiceResponseLocale = Global.ObjectMgr.GetPlayerChoiceResponseLocale((uint)localizedPlayerChoice.ChoiceId, (uint)playerChoiceResponse.Value.ResponseID);
|
||||
PlayerChoiceResponseLocale playerChoiceResponseLocale = playerChoiceLocale.Responses.LookupByKey(playerChoiceResponseTemplate.ResponseId);
|
||||
if (playerChoiceResponseLocale != null)
|
||||
{
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Header, locale, ref playerChoiceResponse.Value.Header);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Answer, locale, ref playerChoiceResponse.Value.Answer);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Description, locale, ref playerChoiceResponse.Value.Description);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Confirmation, locale, ref playerChoiceResponse.Value.Confirmation);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Answer, locale, ref playerChoiceResponse.Answer);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Header, locale, ref playerChoiceResponse.Header);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Description, locale, ref playerChoiceResponse.Description);
|
||||
ObjectManager.GetLocaleString(playerChoiceResponseLocale.Confirmation, locale, ref playerChoiceResponse.Confirmation);
|
||||
}
|
||||
}
|
||||
|
||||
if (playerChoiceResponseTemplate.Reward.HasValue)
|
||||
{
|
||||
var reward = new Network.Packets.PlayerChoiceResponseReward();
|
||||
reward.TitleID = playerChoiceResponseTemplate.Reward.Value.TitleId;
|
||||
reward.PackageID = playerChoiceResponseTemplate.Reward.Value.PackageId;
|
||||
reward.SkillLineID = playerChoiceResponseTemplate.Reward.Value.SkillLineId;
|
||||
reward.SkillPointCount = playerChoiceResponseTemplate.Reward.Value.SkillPointCount;
|
||||
reward.ArenaPointCount = playerChoiceResponseTemplate.Reward.Value.ArenaPointCount;
|
||||
reward.HonorPointCount = playerChoiceResponseTemplate.Reward.Value.HonorPointCount;
|
||||
reward.Money = playerChoiceResponseTemplate.Reward.Value.Money;
|
||||
reward.Xp = playerChoiceResponseTemplate.Reward.Value.Xp;
|
||||
|
||||
foreach (var item in playerChoiceResponseTemplate.Reward.Value.Items)
|
||||
{
|
||||
var rewardEntry = new Network.Packets.PlayerChoiceResponseRewardEntry();
|
||||
rewardEntry.Item.ItemID = item.Id;
|
||||
rewardEntry.Quantity = item.Quantity;
|
||||
if (!item.BonusListIDs.Empty())
|
||||
{
|
||||
rewardEntry.Item.ItemBonus.HasValue = true;
|
||||
rewardEntry.Item.ItemBonus.Value.BonusListIDs = item.BonusListIDs;
|
||||
}
|
||||
reward.Items.Add(rewardEntry);
|
||||
}
|
||||
|
||||
foreach (var currency in playerChoiceResponseTemplate.Reward.Value.Currency)
|
||||
{
|
||||
var rewardEntry = new Network.Packets.PlayerChoiceResponseRewardEntry();
|
||||
rewardEntry.Item.ItemID = currency.Id;
|
||||
rewardEntry.Quantity = currency.Quantity;
|
||||
reward.Items.Add(rewardEntry);
|
||||
}
|
||||
|
||||
foreach (var faction in playerChoiceResponseTemplate.Reward.Value.Faction)
|
||||
{
|
||||
var rewardEntry = new Network.Packets.PlayerChoiceResponseRewardEntry();
|
||||
rewardEntry.Item.ItemID = faction.Id;
|
||||
rewardEntry.Quantity = faction.Quantity;
|
||||
reward.Items.Add(rewardEntry);
|
||||
}
|
||||
|
||||
playerChoiceResponse.Reward.Set(reward);
|
||||
displayPlayerChoice.Responses[i] = playerChoiceResponse;
|
||||
}
|
||||
}
|
||||
|
||||
DisplayPlayerChoice displayPlayerChoice = new DisplayPlayerChoice();
|
||||
displayPlayerChoice.Choice = localizedPlayerChoice;
|
||||
displayPlayerChoice.SenderGUID = sender;
|
||||
SendPacket(displayPlayerChoice);
|
||||
}
|
||||
|
||||
|
||||
@@ -590,15 +590,11 @@ namespace Game
|
||||
}
|
||||
public PlayerChoice GetPlayerChoice(int choiceId)
|
||||
{
|
||||
return _playerChoiceContainer.LookupByKey(choiceId);
|
||||
return _playerChoices.LookupByKey(choiceId);
|
||||
}
|
||||
public PlayerChoiceLocale GetPlayerChoiceLocale(uint ChoiceID)
|
||||
public PlayerChoiceLocale GetPlayerChoiceLocale(int ChoiceID)
|
||||
{
|
||||
return _playerChoiceLocaleContainer.LookupByKey(ChoiceID);
|
||||
}
|
||||
public PlayerChoiceResponseLocale GetPlayerChoiceResponseLocale(uint ChoiceID, uint ResponseID)
|
||||
{
|
||||
return _playerChoiceResponseLocaleContainer.LookupByKey(Tuple.Create(ChoiceID, ResponseID));
|
||||
return _playerChoiceLocales.LookupByKey(ChoiceID);
|
||||
}
|
||||
|
||||
//Gossip
|
||||
@@ -8646,9 +8642,9 @@ namespace Game
|
||||
public void LoadPlayerChoices()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
_playerChoiceContainer.Clear();
|
||||
_playerChoices.Clear();
|
||||
|
||||
SQLResult choiceResult = DB.World.Query("SELECT ChoiceID, Question FROM playerchoice");
|
||||
SQLResult choiceResult = DB.World.Query("SELECT ChoiceId, Question FROM playerchoice");
|
||||
if (choiceResult.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 player choices. DB table `playerchoice` is empty.");
|
||||
@@ -8657,6 +8653,9 @@ namespace Game
|
||||
|
||||
uint responseCount = 0;
|
||||
uint rewardCount = 0;
|
||||
uint itemRewardCount = 0;
|
||||
uint currencyRewardCount = 0;
|
||||
uint factionRewardCount = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -8665,124 +8664,261 @@ namespace Game
|
||||
PlayerChoice choice = new PlayerChoice();
|
||||
choice.ChoiceId = choiceId;
|
||||
choice.Question = choiceResult.Read<string>(1);
|
||||
_playerChoiceContainer[choiceId] = choice;
|
||||
_playerChoices[choiceId] = choice;
|
||||
|
||||
} while (choiceResult.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_playerChoiceContainer.Count} player choices in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
||||
|
||||
SQLResult responses = DB.World.Query("SELECT ChoiceID, ResponseID, ChoiceArtFileID, Header, Answer, Description, Confirmation FROM playerchoice_response");
|
||||
SQLResult responses = DB.World.Query("SELECT ChoiceId, ResponseId, ChoiceArtFileId, Header, Answer, Description, Confirmation FROM playerchoice_response ORDER BY `Index` ASC");
|
||||
if (!responses.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
++responseCount;
|
||||
|
||||
int choiceId = responses.Read<int>(0);
|
||||
int ResponseID = responses.Read<int>(1);
|
||||
int responseId = responses.Read<int>(1);
|
||||
|
||||
if (!_playerChoiceContainer.ContainsKey(choiceId))
|
||||
if (!_playerChoices.ContainsKey(choiceId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `playerchoice_response` has nonexistent choiceId: {choiceId} (ResponseID : {ResponseID}), skipped");
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response` references non-existing ChoiceId: {choiceId} (ResponseId: {responseId}), skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoice choice = _playerChoiceContainer[choiceId];
|
||||
PlayerChoice choice = _playerChoices[choiceId];
|
||||
PlayerChoiceResponse response = new PlayerChoiceResponse();
|
||||
|
||||
response.ResponseID = ResponseID;
|
||||
response.ChoiceArtFileID = responses.Read<int>(2);
|
||||
response.ResponseId = responseId;
|
||||
response.ChoiceArtFileId = responses.Read<int>(2);
|
||||
response.Header = responses.Read<string>(3);
|
||||
response.Answer = responses.Read<string>(4);
|
||||
response.Description = responses.Read<string>(5);
|
||||
response.Confirmation = responses.Read<string>(6);
|
||||
++responseCount;
|
||||
|
||||
choice.Responses[ResponseID] = response;
|
||||
choice.Responses[responseId] = response;
|
||||
} while (responses.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {responseCount} player choices response in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 player choices responses. DB table `playerchoice_response` is empty.");
|
||||
}
|
||||
|
||||
SQLResult rewards = DB.World.Query("SELECT ChoiceID, ResponseID, TitleID, PackageID, SkillLineID, SkillPointCount, ArenaPointCount, HonorPointCount, Money, Xp FROM playerchoice_response_reward");
|
||||
SQLResult rewards = DB.World.Query("SELECT ChoiceId, ResponseId, TitleId, PackageId, SkillLineId, SkillPointCount, ArenaPointCount, HonorPointCount, Money, Xp FROM playerchoice_response_reward");
|
||||
if (!rewards.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
++rewardCount;
|
||||
|
||||
int choiceId = rewards.Read<int>(0);
|
||||
int ResponseID = rewards.Read<int>(1);
|
||||
int responseId = rewards.Read<int>(1);
|
||||
|
||||
if (!_playerChoiceContainer.ContainsKey(choiceId))
|
||||
if (!_playerChoices.ContainsKey(choiceId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `playerchoice_response_reward` has nonexistent choiceId: {choiceId} (ResponseID : {ResponseID}), skipped");
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` references non-existing ChoiceId: {choiceId} (ResponseId: {responseId}), skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoice choice = _playerChoiceContainer[choiceId];
|
||||
|
||||
if (!choice.Responses.ContainsKey(ResponseID))
|
||||
PlayerChoice choice = _playerChoices[choiceId];
|
||||
if (!choice.Responses.Any(playerChoiceResponse => playerChoiceResponse.ResponseId == responseId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` has nonexistent ResponseID: {ResponseID} for choiceId {choiceId}, skipped");
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` references non-existing ResponseId: {responseId} for ChoiceId {choiceId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoiceResponse response = choice.Responses[ResponseID];
|
||||
|
||||
PlayerChoiceResponseReward reward = new PlayerChoiceResponseReward();
|
||||
|
||||
reward.TitleID = rewards.Read<int>(2);
|
||||
reward.PackageID = rewards.Read<int>(3);
|
||||
reward.SkillLineID = rewards.Read<int>(4);
|
||||
reward.TitleId = rewards.Read<int>(2);
|
||||
reward.PackageId = rewards.Read<int>(3);
|
||||
reward.SkillLineId = rewards.Read<int>(4);
|
||||
reward.SkillPointCount = rewards.Read<uint>(5);
|
||||
reward.ArenaPointCount = rewards.Read<uint>(6);
|
||||
reward.HonorPointCount = rewards.Read<uint>(7);
|
||||
reward.Money = rewards.Read<ulong>(8);
|
||||
reward.Xp = rewards.Read<uint>(9);
|
||||
++rewardCount;
|
||||
|
||||
response.Reward.Set(reward);
|
||||
if (reward.TitleId != 0 && !CliDB.CharTitlesStorage.ContainsKey(reward.TitleId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` references non-existing Title {reward.TitleId} for ChoiceId {choiceId}, ResponseId: {responseId}, set to 0");
|
||||
reward.TitleId = 0;
|
||||
}
|
||||
|
||||
if (reward.PackageId != 0 && Global.DB2Mgr.GetQuestPackageItems((uint)reward.PackageId) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` references non-existing QuestPackage {reward.TitleId} for ChoiceId {choiceId}, ResponseId: {responseId}, set to 0");
|
||||
reward.PackageId = 0;
|
||||
}
|
||||
|
||||
if (reward.SkillLineId != 0 && !CliDB.SkillLineStorage.ContainsKey(reward.SkillLineId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward` references non-existing SkillLine {reward.TitleId} for ChoiceId {choiceId}, ResponseId: {responseId}, set to 0");
|
||||
reward.SkillLineId = 0;
|
||||
reward.SkillPointCount = 0;
|
||||
}
|
||||
|
||||
choice.Responses[responseId].Reward.Set(reward);
|
||||
|
||||
} while (rewards.NextRow());
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {rewardCount} player choices reward in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
||||
}
|
||||
else
|
||||
SQLResult rewardItem = DB.World.Query("SELECT ChoiceId, ResponseId, ItemId, BonusListIDs, Quantity FROM playerchoice_response_reward_item ORDER BY `Index` ASC");
|
||||
if (!rewardItem.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 player choices responses reward. DB table `playerchoice_response_reward` is empty.");
|
||||
do
|
||||
{
|
||||
int choiceId = rewardItem.Read<int>(0);
|
||||
int responseId = rewardItem.Read<int>(1);
|
||||
uint itemId = rewardItem.Read<uint>(2);
|
||||
StringArray bonusListIDsTok = new StringArray(rewardItem.Read<string>(3), ' ');
|
||||
List<uint> bonusListIds = new List<uint>();
|
||||
foreach (uint token in bonusListIDsTok)
|
||||
bonusListIds.Add(token);
|
||||
int quantity = rewardItem.Read<int>(4);
|
||||
|
||||
PlayerChoice choice = _playerChoices.LookupByKey(choiceId);
|
||||
if (choice == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_item` references non-existing ChoiceId: {choiceId} (ResponseId: {responseId}), skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
var response = choice.Responses.FirstOrDefault(playerChoiceResponse => { return playerChoiceResponse.ResponseId == responseId; });
|
||||
if (response == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_item` references non-existing ResponseId: {responseId} for ChoiceId {choiceId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!response.Reward.HasValue)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_item` references non-existing player choice reward for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (GetItemTemplate(itemId) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_item` references non-existing item {itemId} for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
itemRewardCount++;
|
||||
response.Reward.Value.Items.Add(new PlayerChoiceResponseRewardItem(itemId, bonusListIds, quantity));
|
||||
|
||||
} while (rewardItem.NextRow());
|
||||
}
|
||||
|
||||
SQLResult rewardCurrency = DB.World.Query("SELECT ChoiceId, ResponseId, CurrencyId, Quantity FROM playerchoice_response_reward_currency ORDER BY `Index` ASC");
|
||||
if (!rewardCurrency.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
int choiceId = rewardCurrency.Read<int>(0);
|
||||
int responseId = rewardCurrency.Read<int>(1);
|
||||
uint currencyId = rewardCurrency.Read<uint>(2);
|
||||
int quantity = rewardCurrency.Read<int>(3);
|
||||
|
||||
PlayerChoice choice = _playerChoices.LookupByKey(choiceId);
|
||||
if (choice == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_currency` references non-existing ChoiceId: {choiceId} (ResponseId: {responseId}), skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
var response = choice.Responses.FirstOrDefault(playerChoiceResponse => { return playerChoiceResponse.ResponseId == responseId; });
|
||||
if (response == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_currency` references non-existing ResponseId: {responseId} for ChoiceId {choiceId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!response.Reward.HasValue)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_currency` references non-existing player choice reward for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CliDB.CurrencyTypesStorage.ContainsKey(currencyId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_currency` references non-existing currency {currencyId} for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
currencyRewardCount++;
|
||||
response.Reward.Value.Currency.Add(new PlayerChoiceResponseRewardEntry(currencyId, quantity));
|
||||
|
||||
} while (rewards.NextRow());
|
||||
}
|
||||
|
||||
SQLResult rewardFaction = DB.World.Query("SELECT ChoiceId, ResponseId, FactionId, Quantity FROM playerchoice_response_reward_faction ORDER BY `Index` ASC");
|
||||
if (!rewardFaction.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
int choiceId = rewardFaction.Read<int>(0);
|
||||
int responseId = rewardFaction.Read<int>(1);
|
||||
uint factionId = rewardFaction.Read<uint>(2);
|
||||
int quantity = rewardFaction.Read<int>(3);
|
||||
|
||||
PlayerChoice choice = _playerChoices.LookupByKey(choiceId);
|
||||
if (choice == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_faction` references non-existing ChoiceId: {choiceId} (ResponseId: {responseId}), skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
var response = choice.Responses.FirstOrDefault(playerChoiceResponse => { return playerChoiceResponse.ResponseId == responseId; });
|
||||
if (response == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_faction` references non-existing ResponseId: {responseId} for ChoiceId {choiceId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!response.Reward.HasValue)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_faction` references non-existing player choice reward for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CliDB.FactionStorage.ContainsKey(factionId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_response_reward_faction` references non-existing faction {factionId} for ChoiceId {choiceId}, ResponseId: {responseId}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
factionRewardCount++;
|
||||
response.Reward.Value.Faction.Add(new PlayerChoiceResponseRewardEntry(factionId, quantity));
|
||||
|
||||
} while (rewardFaction.NextRow());
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_playerChoices.Count} player choices, {responseCount} responses, {rewardCount} rewards, {itemRewardCount} item rewards, {currencyRewardCount} " +
|
||||
$"currency rewards and {factionRewardCount} faction rewards in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
|
||||
}
|
||||
public void LoadPlayerChoicesLocale()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// need for reload case
|
||||
_playerChoiceLocaleContainer.Clear();
|
||||
_playerChoiceResponseLocaleContainer.Clear();
|
||||
_playerChoiceLocales.Clear();
|
||||
|
||||
// 0 1 2
|
||||
SQLResult result = DB.World.Query("SELECT ChoiceID, locale, Question FROM playerchoice_locale");
|
||||
SQLResult result = DB.World.Query("SELECT ChoiceId, locale, Question FROM playerchoice_locale");
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
uint ChoiceID = result.Read<uint>(0);
|
||||
int choiceId = result.Read<int>(0);
|
||||
string localeName = result.Read<string>(1);
|
||||
LocaleConstant locale = localeName.ToEnum<LocaleConstant>();
|
||||
if (locale == LocaleConstant.enUS)
|
||||
continue;
|
||||
|
||||
if (!_playerChoiceLocaleContainer.ContainsKey(ChoiceID))
|
||||
_playerChoiceLocaleContainer[ChoiceID] = new PlayerChoiceLocale();
|
||||
if (GetPlayerChoice(choiceId) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_locale` references non-existing ChoiceId: {choiceId} for locale {localeName}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoiceLocale data = _playerChoiceLocaleContainer[ChoiceID];
|
||||
if (!_playerChoiceLocales.ContainsKey(choiceId))
|
||||
_playerChoiceLocales[choiceId] = new PlayerChoiceLocale();
|
||||
|
||||
PlayerChoiceLocale data = _playerChoiceLocales[choiceId];
|
||||
AddLocaleString(result.Read<string>(2), locale, data.Question);
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_playerChoiceLocaleContainer.Count} Player Choice locale strings in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_playerChoiceLocales.Count} Player Choice locale strings in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
}
|
||||
|
||||
oldMSTime = Time.GetMSTime();
|
||||
@@ -8791,27 +8927,39 @@ namespace Game
|
||||
result = DB.World.Query("SELECT ChoiceID, ResponseID, locale, Header, Answer, Description, Confirmation FROM playerchoice_response_locale");
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
uint count = 0;
|
||||
do
|
||||
{
|
||||
uint ChoiceID = result.Read<uint>(0);
|
||||
uint ResponseID = result.Read<uint>(1);
|
||||
int choiceId = result.Read<int>(0);
|
||||
int responseId = result.Read<int>(1);
|
||||
string localeName = result.Read<string>(2);
|
||||
LocaleConstant locale = localeName.ToEnum<LocaleConstant>();
|
||||
if (locale == LocaleConstant.enUS)
|
||||
continue;
|
||||
|
||||
Tuple<uint, uint> pair = Tuple.Create(ChoiceID, ResponseID);
|
||||
if (_playerChoiceResponseLocaleContainer.ContainsKey(pair))
|
||||
_playerChoiceResponseLocaleContainer[pair] = new PlayerChoiceResponseLocale();
|
||||
var playerChoiceLocale = _playerChoiceLocales.LookupByKey(choiceId);
|
||||
if (playerChoiceLocale == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_locale` references non-existing ChoiceId: {choiceId} for ResponseId {responseId} locale {localeName}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoiceResponseLocale data = _playerChoiceResponseLocaleContainer[pair];
|
||||
PlayerChoice playerChoice = GetPlayerChoice(choiceId);
|
||||
if (playerChoice.GetResponse(responseId) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `playerchoice_locale` references non-existing ResponseId: {responseId} for ChoiceId {choiceId} locale {localeName}, skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerChoiceResponseLocale data = playerChoiceLocale.Responses[responseId];
|
||||
AddLocaleString(result.Read<string>(3), locale, data.Header);
|
||||
AddLocaleString(result.Read<string>(4), locale, data.Answer);
|
||||
AddLocaleString(result.Read<string>(5), locale, data.Description);
|
||||
AddLocaleString(result.Read<string>(6), locale, data.Confirmation);
|
||||
count++;
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_playerChoiceResponseLocaleContainer} Player Choice Response locale strings in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} Player Choice Response locale strings in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9317,7 +9465,7 @@ namespace Game
|
||||
Dictionary<uint, RepSpilloverTemplate> _repSpilloverTemplateStorage = new Dictionary<uint, RepSpilloverTemplate>();
|
||||
MultiMap<byte, MailLevelReward> _mailLevelRewardStorage = new MultiMap<byte, MailLevelReward>();
|
||||
MultiMap<Tuple<uint, SummonerType, byte>, TempSummonData> _tempSummonDataStorage = new MultiMap<Tuple<uint, SummonerType, byte>, TempSummonData>();
|
||||
Dictionary<int /*choiceId*/, PlayerChoice> _playerChoiceContainer;
|
||||
Dictionary<int /*choiceId*/, PlayerChoice> _playerChoices = new Dictionary<int, PlayerChoice>();
|
||||
Dictionary<uint, PageText> _pageTextStorage = new Dictionary<uint, PageText>();
|
||||
List<string> _reservedNamesStorage = new List<string>();
|
||||
Dictionary<uint, SceneTemplate> _sceneTemplateStorage = new Dictionary<uint, SceneTemplate>();
|
||||
@@ -9427,8 +9575,7 @@ namespace Game
|
||||
Dictionary<uint, GossipMenuItemsLocale> _gossipMenuItemsLocaleStorage = new Dictionary<uint, GossipMenuItemsLocale>();
|
||||
Dictionary<uint, PageTextLocale> _pageTextLocaleStorage = new Dictionary<uint, PageTextLocale>();
|
||||
Dictionary<uint, PointOfInterestLocale> _pointOfInterestLocaleStorage = new Dictionary<uint, PointOfInterestLocale>();
|
||||
Dictionary<uint, PlayerChoiceLocale> _playerChoiceLocaleContainer = new Dictionary<uint, PlayerChoiceLocale>();
|
||||
Dictionary<Tuple<uint, uint>, PlayerChoiceResponseLocale> _playerChoiceResponseLocaleContainer = new Dictionary<Tuple<uint, uint>, PlayerChoiceResponseLocale>();
|
||||
Dictionary<int, PlayerChoiceLocale> _playerChoiceLocales = new Dictionary<int, PlayerChoiceLocale>();
|
||||
|
||||
List<uint> _tavernAreaTriggerStorage = new List<uint>();
|
||||
Dictionary<uint, AreaTriggerStruct> _areaTriggerStorage = new Dictionary<uint, AreaTriggerStruct>();
|
||||
@@ -10209,50 +10356,80 @@ namespace Game
|
||||
public class PlayerChoiceLocale
|
||||
{
|
||||
public StringArray Question = new StringArray((int)LocaleConstant.Total);
|
||||
public Dictionary<int /*ResponseId*/, PlayerChoiceResponseLocale> Responses = new Dictionary<int, PlayerChoiceResponseLocale>();
|
||||
}
|
||||
|
||||
public class PlayerChoiceResponseLocale
|
||||
{
|
||||
public StringArray Header = new StringArray((int)LocaleConstant.Total);
|
||||
public StringArray Answer = new StringArray((int)LocaleConstant.Total);
|
||||
public StringArray Header = new StringArray((int)LocaleConstant.Total);
|
||||
public StringArray Description = new StringArray((int)LocaleConstant.Total);
|
||||
public StringArray Confirmation = new StringArray((int)LocaleConstant.Total);
|
||||
}
|
||||
|
||||
public class PlayerChoiceResponseRewardItem
|
||||
{
|
||||
public PlayerChoiceResponseRewardItem() { }
|
||||
public PlayerChoiceResponseRewardItem(uint id, List<uint> bonusListIDs, int quantity)
|
||||
{
|
||||
Id = id;
|
||||
BonusListIDs = bonusListIDs;
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public uint Id;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
public int Quantity;
|
||||
}
|
||||
|
||||
public class PlayerChoiceResponseRewardEntry
|
||||
{
|
||||
public PlayerChoiceResponseRewardEntry(uint id, int quantity)
|
||||
{
|
||||
Id = id;
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public uint Id;
|
||||
public int Quantity;
|
||||
}
|
||||
|
||||
public class PlayerChoiceResponseReward
|
||||
{
|
||||
public int TitleID;
|
||||
public int PackageID;
|
||||
public int SkillLineID;
|
||||
public int TitleId;
|
||||
public int PackageId;
|
||||
public int SkillLineId;
|
||||
public uint SkillPointCount;
|
||||
public uint ArenaPointCount;
|
||||
public uint HonorPointCount;
|
||||
public ulong Money;
|
||||
public uint Xp;
|
||||
|
||||
//std::vector<Item> Items;
|
||||
//std::vector<Currency> Currency;
|
||||
//std::vector<Faction> Faction;
|
||||
//std::vector<ItemChoice> ItemChoice;
|
||||
public List<PlayerChoiceResponseRewardItem> Items = new List<PlayerChoiceResponseRewardItem>();
|
||||
public List<PlayerChoiceResponseRewardEntry> Currency = new List<PlayerChoiceResponseRewardEntry>();
|
||||
public List<PlayerChoiceResponseRewardEntry> Faction = new List<PlayerChoiceResponseRewardEntry>();
|
||||
}
|
||||
|
||||
public class PlayerChoiceResponse
|
||||
{
|
||||
public int ResponseID;
|
||||
public int ChoiceArtFileID;
|
||||
|
||||
public int ResponseId;
|
||||
public int ChoiceArtFileId;
|
||||
public string Header;
|
||||
public string Answer;
|
||||
public string Description;
|
||||
public string Confirmation;
|
||||
|
||||
public Optional<PlayerChoiceResponseReward> Reward;
|
||||
}
|
||||
|
||||
public class PlayerChoice
|
||||
{
|
||||
public PlayerChoiceResponse GetResponse(int responseId)
|
||||
{
|
||||
return Responses.FirstOrDefault(playerChoiceResponse => { return playerChoiceResponse.ResponseId == responseId; });
|
||||
}
|
||||
|
||||
public int ChoiceId;
|
||||
public string Question;
|
||||
public Dictionary<int /*ResponseID*/, PlayerChoiceResponse> Responses = new Dictionary<int, PlayerChoiceResponse>();
|
||||
public List<PlayerChoiceResponse> Responses = new List<PlayerChoiceResponse>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ using Game.Entities;
|
||||
using Game.Groups;
|
||||
using Game.Network;
|
||||
using Game.Network.Packets;
|
||||
using Game.DataStorage;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
@@ -650,9 +653,64 @@ namespace Game
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.ChoiceResponse)]
|
||||
void HandlePlayerChoiceResponse(PlayerChoiceResponsePkt packet)
|
||||
void HandlePlayerChoiceResponse(ChoiceResponse choiceResponse)
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerChoiceResponse(GetPlayer(), (uint)packet.ChoiceID, (uint)packet.ResponseID);
|
||||
if (_player.PlayerTalkClass.GetInteractionData().PlayerChoiceId != choiceResponse.ChoiceID)
|
||||
{
|
||||
Log.outError(LogFilter.Player, $"Error in CMSG_CHOICE_RESPONSE: {GetPlayerInfo()} tried to respond to invalid player choice {choiceResponse.ChoiceID} (allowed {_player.PlayerTalkClass.GetInteractionData().PlayerChoiceId}) (possible packet-hacking detected)");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerChoice playerChoice = Global.ObjectMgr.GetPlayerChoice(choiceResponse.ChoiceID);
|
||||
if (playerChoice == null)
|
||||
return;
|
||||
|
||||
PlayerChoiceResponse playerChoiceResponse = playerChoice.GetResponse(choiceResponse.ResponseID);
|
||||
if (playerChoiceResponse == null)
|
||||
{
|
||||
Log.outError(LogFilter.Player, $"Error in CMSG_CHOICE_RESPONSE: {GetPlayerInfo()} tried to select invalid player choice response {choiceResponse.ResponseID} (possible packet-hacking detected)");
|
||||
return;
|
||||
}
|
||||
|
||||
Global.ScriptMgr.OnPlayerChoiceResponse(GetPlayer(), (uint)choiceResponse.ChoiceID, (uint)choiceResponse.ResponseID);
|
||||
|
||||
if (playerChoiceResponse.Reward.HasValue)
|
||||
{
|
||||
var reward = playerChoiceResponse.Reward.Value;
|
||||
if (reward.TitleId != 0)
|
||||
_player.SetTitle(CliDB.CharTitlesStorage.LookupByKey(reward.TitleId), false);
|
||||
|
||||
if (reward.PackageId != 0)
|
||||
_player.RewardQuestPackage((uint)reward.PackageId);
|
||||
|
||||
if (reward.SkillLineId != 0 && _player.HasSkill((SkillType)reward.SkillLineId))
|
||||
_player.UpdateSkillPro((uint)reward.SkillLineId, 1000, reward.SkillPointCount);
|
||||
|
||||
if (reward.HonorPointCount != 0)
|
||||
_player.AddHonorXP(reward.HonorPointCount);
|
||||
|
||||
if (reward.Money != 0)
|
||||
_player.ModifyMoney((long)reward.Money, false);
|
||||
|
||||
if (reward.Xp != 0)
|
||||
_player.GiveXP(reward.Xp, null, 0.0f);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardItem item in reward.Items)
|
||||
{
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (_player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.Id, (uint)item.Quantity) == InventoryResult.Ok)
|
||||
{
|
||||
Item newItem = _player.StoreNewItem(dest, item.Id, true, ItemEnchantment.GenerateItemRandomPropertyId(item.Id), null, 0, item.BonusListIDs);
|
||||
_player.SendNewItem(newItem, (uint)item.Quantity, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry currency in reward.Currency)
|
||||
_player.ModifyCurrency((CurrencyTypes)currency.Id, currency.Quantity);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry faction in reward.Faction)
|
||||
_player.GetReputationMgr().ModifyReputation(CliDB.FactionStorage.LookupByKey(faction.Id), faction.Quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using System.Collections.Generic;
|
||||
using Framework.Dynamic;
|
||||
|
||||
namespace Game.Network.Packets
|
||||
{
|
||||
@@ -134,9 +135,9 @@ namespace Game.Network.Packets
|
||||
_worldPacket.WriteInt32(Info.RewardSpell);
|
||||
_worldPacket.WriteInt32(Info.RewardHonor);
|
||||
_worldPacket.WriteFloat(Info.RewardKillHonor);
|
||||
_worldPacket .WriteInt32(Info.RewardArtifactXPDifficulty);
|
||||
_worldPacket .WriteFloat(Info.RewardArtifactXPMultiplier);
|
||||
_worldPacket .WriteInt32(Info.RewardArtifactCategoryID);
|
||||
_worldPacket.WriteInt32(Info.RewardArtifactXPDifficulty);
|
||||
_worldPacket.WriteFloat(Info.RewardArtifactXPMultiplier);
|
||||
_worldPacket.WriteInt32(Info.RewardArtifactCategoryID);
|
||||
_worldPacket.WriteInt32(Info.StartItem);
|
||||
_worldPacket.WriteUInt32(Info.Flags);
|
||||
_worldPacket.WriteUInt32(Info.FlagsEx);
|
||||
@@ -822,74 +823,29 @@ namespace Game.Network.Packets
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteInt32(Choice.ChoiceId);
|
||||
_worldPacket.WriteUInt32(Choice.Responses.Count);
|
||||
_worldPacket.WriteInt32(ChoiceID);
|
||||
_worldPacket.WriteUInt32(Responses.Count);
|
||||
_worldPacket.WritePackedGuid(SenderGUID);
|
||||
_worldPacket.WriteBits(Choice.Question.Length, 8);
|
||||
_worldPacket.WriteBits(Question.Length, 8);
|
||||
_worldPacket.WriteBit(CloseChoiceFrame);
|
||||
_worldPacket.FlushBits();
|
||||
|
||||
foreach (var response in Choice.Responses.Values)
|
||||
{
|
||||
_worldPacket.WriteInt32(response.ResponseID);
|
||||
_worldPacket.WriteInt32(response.ChoiceArtFileID);
|
||||
foreach (PlayerChoiceResponse response in Responses)
|
||||
response.Write(_worldPacket);
|
||||
|
||||
_worldPacket.WriteBits(response.Answer.Length, 9);
|
||||
_worldPacket.WriteBits(response.Header.Length, 9);
|
||||
_worldPacket.WriteBits(response.Description.Length, 11);
|
||||
_worldPacket.WriteBits(response.Confirmation.Length, 7);
|
||||
|
||||
_worldPacket.WriteBit(response.Reward.HasValue);
|
||||
_worldPacket.FlushBits();
|
||||
|
||||
if (response.Reward.HasValue)
|
||||
{
|
||||
var reward = response.Reward.Value;
|
||||
|
||||
_worldPacket.WriteInt32(reward.TitleID);
|
||||
_worldPacket.WriteInt32(reward.PackageID);
|
||||
_worldPacket.WriteInt32(reward.SkillLineID);
|
||||
_worldPacket.WriteUInt32(reward.SkillPointCount);
|
||||
_worldPacket.WriteUInt32(reward.ArenaPointCount);
|
||||
_worldPacket.WriteUInt32(reward.HonorPointCount);
|
||||
_worldPacket.WriteUInt64(reward.Money);
|
||||
_worldPacket.WriteUInt32(reward.Xp);
|
||||
|
||||
_worldPacket.WriteUInt32(0); // itemCount
|
||||
_worldPacket.WriteUInt32(0); // currencyCount
|
||||
_worldPacket.WriteUInt32(0); // factionCount
|
||||
_worldPacket.WriteUInt32(0); // itemChoiceCount
|
||||
|
||||
/*for (var i = 0u; i < itemCount; ++i)
|
||||
ReadPlayerChoiceResponseRewardEntry(packet, "Item", i);
|
||||
|
||||
for (var i = 0u; i < currencyCount; ++i)
|
||||
ReadPlayerChoiceResponseRewardEntry(packet, "Currency", i);
|
||||
|
||||
for (var i = 0u; i < factionCount; ++i)
|
||||
ReadPlayerChoiceResponseRewardEntry(packet, "Faction", i);
|
||||
|
||||
for (var i = 0u; i < itemChoiceCount; ++i)
|
||||
ReadPlayerChoiceResponseRewardEntry(packet, "ItemChoice", i);*/
|
||||
}
|
||||
|
||||
_worldPacket.WriteString(response.Answer);
|
||||
_worldPacket.WriteString(response.Header);
|
||||
_worldPacket.WriteString(response.Description);
|
||||
_worldPacket.WriteString(response.Confirmation);
|
||||
}
|
||||
|
||||
_worldPacket.WriteString(Choice.Question);
|
||||
_worldPacket.WriteString(Question);
|
||||
}
|
||||
|
||||
public ObjectGuid SenderGUID;
|
||||
public PlayerChoice Choice;
|
||||
public int ChoiceID;
|
||||
public string Question;
|
||||
public List<PlayerChoiceResponse> Responses = new List<PlayerChoiceResponse>();
|
||||
public bool CloseChoiceFrame;
|
||||
}
|
||||
|
||||
class PlayerChoiceResponsePkt : ClientPacket
|
||||
class ChoiceResponse : ClientPacket
|
||||
{
|
||||
public PlayerChoiceResponsePkt(WorldPacket packet) : base(packet) { }
|
||||
public ChoiceResponse(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
@@ -934,7 +890,7 @@ namespace Game.Network.Packets
|
||||
PortraitGiverName = "";
|
||||
PortraitTurnInText = "";
|
||||
PortraitTurnInName = "";
|
||||
QuestCompletionLog = "";
|
||||
QuestCompletionLog = "";
|
||||
}
|
||||
|
||||
public uint QuestID;
|
||||
@@ -1210,4 +1166,94 @@ namespace Game.Network.Packets
|
||||
public int VariableID;
|
||||
public int Value;
|
||||
}
|
||||
}
|
||||
|
||||
struct PlayerChoiceResponseRewardEntry
|
||||
{
|
||||
public void Write(WorldPacket data)
|
||||
{
|
||||
Item.Write(data);
|
||||
data.WriteInt32(Quantity);
|
||||
}
|
||||
|
||||
public ItemInstance Item;
|
||||
public int Quantity;
|
||||
}
|
||||
|
||||
class PlayerChoiceResponseReward
|
||||
{
|
||||
public void Write(WorldPacket data)
|
||||
{
|
||||
data.WriteInt32(TitleID);
|
||||
data.WriteInt32(PackageID);
|
||||
data.WriteInt32(SkillLineID);
|
||||
data.WriteUInt32(SkillPointCount);
|
||||
data.WriteUInt32(ArenaPointCount);
|
||||
data.WriteUInt32(HonorPointCount);
|
||||
data.WriteUInt64(Money);
|
||||
data.WriteUInt32(Xp);
|
||||
|
||||
data.WriteUInt32(Items.Count);
|
||||
data.WriteUInt32(Currencies.Count);
|
||||
data.WriteUInt32(Factions.Count);
|
||||
data.WriteUInt32(ItemChoices.Count);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry item in Items)
|
||||
item.Write(data);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry currency in Currencies)
|
||||
currency.Write(data);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry faction in Factions)
|
||||
faction.Write(data);
|
||||
|
||||
foreach (PlayerChoiceResponseRewardEntry itemChoice in ItemChoices)
|
||||
itemChoice.Write(data);
|
||||
}
|
||||
|
||||
public int TitleID;
|
||||
public int PackageID;
|
||||
public int SkillLineID;
|
||||
public uint SkillPointCount;
|
||||
public uint ArenaPointCount;
|
||||
public uint HonorPointCount;
|
||||
public ulong Money;
|
||||
public uint Xp;
|
||||
public List<PlayerChoiceResponseRewardEntry> Items = new List<PlayerChoiceResponseRewardEntry>();
|
||||
public List<PlayerChoiceResponseRewardEntry> Currencies = new List<PlayerChoiceResponseRewardEntry>();
|
||||
public List<PlayerChoiceResponseRewardEntry> Factions = new List<PlayerChoiceResponseRewardEntry>();
|
||||
public List<PlayerChoiceResponseRewardEntry> ItemChoices = new List<PlayerChoiceResponseRewardEntry>();
|
||||
}
|
||||
|
||||
class PlayerChoiceResponse
|
||||
{
|
||||
public void Write(WorldPacket data)
|
||||
{
|
||||
data.WriteInt32(ResponseID);
|
||||
data.WriteInt32(ChoiceArtFileID);
|
||||
|
||||
data.WriteBits(Answer.Length, 9);
|
||||
data.WriteBits(Header.Length, 9);
|
||||
data.WriteBits(Description.Length, 11);
|
||||
data.WriteBits(Confirmation.Length, 7);
|
||||
|
||||
data.WriteBit(Reward.HasValue);
|
||||
data.FlushBits();
|
||||
|
||||
if (Reward.HasValue)
|
||||
Reward.Value.Write(data);
|
||||
|
||||
data.WriteString(Answer);
|
||||
data.WriteString(Header);
|
||||
data.WriteString(Description);
|
||||
data.WriteString(Confirmation);
|
||||
}
|
||||
|
||||
public int ResponseID;
|
||||
public int ChoiceArtFileID;
|
||||
public string Answer;
|
||||
public string Header;
|
||||
public string Description;
|
||||
public string Confirmation;
|
||||
public Optional<PlayerChoiceResponseReward> Reward;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +657,7 @@ namespace Game.Scripting
|
||||
public virtual void OnMovieComplete(Player player, uint movieId) { }
|
||||
|
||||
// Called when a player choose a response from a PlayerChoice
|
||||
public virtual void OnPlayerChoiceResponse(Player player, uint choiceID, uint responseID) { }
|
||||
public virtual void OnPlayerChoiceResponse(Player player, uint choiceId, uint responseId) { }
|
||||
}
|
||||
|
||||
public class GuildScript : ScriptObject
|
||||
|
||||
@@ -1175,9 +1175,9 @@ namespace Game.Scripting
|
||||
{
|
||||
ForEach<PlayerScript>(p => p.OnMovieComplete(player, movieId));
|
||||
}
|
||||
public void OnPlayerChoiceResponse(Player player, uint choiceID, uint responseID)
|
||||
public void OnPlayerChoiceResponse(Player player, uint choiceId, uint responseId)
|
||||
{
|
||||
ForEach<PlayerScript>(p => p.OnPlayerChoiceResponse(player, choiceID, responseID));
|
||||
ForEach<PlayerScript>(p => p.OnPlayerChoiceResponse(player, choiceId, responseId));
|
||||
}
|
||||
|
||||
// GuildScript
|
||||
|
||||
@@ -5602,7 +5602,7 @@ namespace Game.Spells
|
||||
if (!unitTarget || !unitTarget.IsPlayer())
|
||||
return;
|
||||
|
||||
unitTarget.ToPlayer().SendPlayerChoice(GetCaster().GetGUID(), (uint)GetEffect(effIndex).MiscValue);
|
||||
unitTarget.ToPlayer().SendPlayerChoice(GetCaster().GetGUID(), effectInfo.MiscValue);
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.UncageBattlepet)]
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
DELETE FROM `command` WHERE `name` IN ('debug send playerchoice');
|
||||
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
|
||||
('debug send playerchoice', 869, 'Syntax: .debug send playerchoice $choiceId\r\nSend given choice to player.');
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice`;
|
||||
CREATE TABLE `playerchoice` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`Question` varchar(255),
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_locale`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_locale`;
|
||||
CREATE TABLE `playerchoice_locale` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`locale` varchar(4) NOT NULL,
|
||||
`Question` varchar(255),
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`,`locale`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response`;
|
||||
CREATE TABLE `playerchoice_response` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`Index` int(10) UNSIGNED NOT NULL,
|
||||
`ChoiceArtFileId` int(11) NOT NULL DEFAULT '0',
|
||||
`Header` varchar(511) NOT NULL,
|
||||
`Answer` varchar(511) NOT NULL,
|
||||
`Description` varchar(2047) NOT NULL,
|
||||
`Confirmation` varchar(127) NOT NULL,
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`,`ResponseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response_locale`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response_locale`;
|
||||
CREATE TABLE `playerchoice_response_locale` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`locale` varchar(4) NOT NULL,
|
||||
`Header` varchar(511) NOT NULL DEFAULT '',
|
||||
`Answer` varchar(511) NOT NULL DEFAULT '',
|
||||
`Description` varchar(2047) NOT NULL DEFAULT '',
|
||||
`Confirmation` varchar(127) NOT NULL DEFAULT '',
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceID`,`ResponseID`,`locale`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response_reward`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response_reward`;
|
||||
CREATE TABLE `playerchoice_response_reward` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`TitleId` int(11) NOT NULL DEFAULT '0',
|
||||
`PackageId` int(11) NOT NULL DEFAULT '0',
|
||||
`SkillLineId` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`SkillPointCount` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ArenaPointCount` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`HonorPointCount` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`Money` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`Xp` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`, `ResponseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response_reward_currency`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response_reward_currency`;
|
||||
CREATE TABLE `playerchoice_response_reward_currency` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`Index` int(10) UNSIGNED NOT NULL,
|
||||
`CurrencyId` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`Quantity` int(11) NOT NULL DEFAULT '0',
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`, `ResponseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response_reward_faction`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response_reward_faction`;
|
||||
CREATE TABLE `playerchoice_response_reward_faction` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`Index` int(10) UNSIGNED NOT NULL,
|
||||
`FactionId` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`Quantity` int(11) NOT NULL DEFAULT '0',
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`, `ResponseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Table structure for table `playerchoice_response_reward_item`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playerchoice_response_reward_item`;
|
||||
CREATE TABLE `playerchoice_response_reward_item` (
|
||||
`ChoiceId` int(11) NOT NULL,
|
||||
`ResponseId` int(11) NOT NULL,
|
||||
`Index` int(10) UNSIGNED NOT NULL,
|
||||
`ItemId` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`BonusListIDs` text,
|
||||
`Quantity` int(11) NOT NULL DEFAULT '0',
|
||||
`VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ChoiceId`, `ResponseId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
--
|
||||
UPDATE `creature_template` SET `unit_flags`=`unit_flags`|768 WHERE `entry` IN(40495);
|
||||
Reference in New Issue
Block a user