Core/PacketIO: Implemented SMSG_DISPLAY_TOAST for quest money rewards
Port From (https://github.com/TrinityCore/TrinityCore/commit/e5417e9ce747d92822538da77d32cf7d0f26ce8a)
This commit is contained in:
@@ -806,4 +806,35 @@ namespace Framework.Constants
|
||||
InProgress,
|
||||
Completed
|
||||
}
|
||||
|
||||
public enum DisplayToastType : byte
|
||||
{
|
||||
NewItem = 0,
|
||||
NewCurrency = 1,
|
||||
Money = 2,
|
||||
Honor = 3
|
||||
}
|
||||
|
||||
public enum DisplayToastMethod : byte
|
||||
{
|
||||
DoNotDisplay = 0,
|
||||
Loot = 1,
|
||||
PetBattle = 2,
|
||||
PersonalLoot = 3,
|
||||
GarrisonMissionLoot = 4,
|
||||
QuestUpgrade = 5,
|
||||
QuestUpgradeEpic = 6,
|
||||
Shipment = 7,
|
||||
GarrisonMissionSalvage = 8,
|
||||
PvPFactionReward = 9,
|
||||
GarrisonCurrency = 10,
|
||||
LessAwesomeLoot = 11,
|
||||
UpgradedLoot = 12,
|
||||
LegendaryLoot = 13,
|
||||
InvasionLoot = 14,
|
||||
Default = 15,
|
||||
QuestComplete = 16,
|
||||
RatedPvPReward = 17,
|
||||
CorruptedLoot = 19
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1066,6 +1066,8 @@ namespace Game.Entities
|
||||
|
||||
if (moneyRew > 0)
|
||||
UpdateCriteria(CriteriaType.MoneyEarnedFromQuesting, (uint)moneyRew);
|
||||
|
||||
SendDisplayToast(0, DisplayToastType.Money, false, (uint)moneyRew, DisplayToastMethod.QuestComplete, questId);
|
||||
}
|
||||
|
||||
// honor reward
|
||||
@@ -3061,5 +3063,36 @@ namespace Game.Entities
|
||||
AddQuestAndCheckCompletion(quest, null);
|
||||
}
|
||||
}
|
||||
|
||||
void SendDisplayToast(uint entry, DisplayToastType type, bool isBonusRoll, uint quantity, DisplayToastMethod method, uint questId, Item item = null)
|
||||
{
|
||||
DisplayToast displayToast = new();
|
||||
displayToast.Quantity = quantity;
|
||||
displayToast.DisplayToastMethod = method;
|
||||
displayToast.QuestID = questId;
|
||||
displayToast.Type = type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DisplayToastType.NewItem:
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
displayToast.BonusRoll = isBonusRoll;
|
||||
displayToast.Item = new(item);
|
||||
displayToast.LootSpec = 0; // loot spec that was selected when loot was generated (not at loot time)
|
||||
displayToast.Gender = GetNativeGender();
|
||||
break;
|
||||
}
|
||||
case DisplayToastType.NewCurrency:
|
||||
displayToast.CurrencyID = entry;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SendPacket(displayToast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1296,6 +1296,51 @@ namespace Game.Networking.Packets
|
||||
|
||||
public uint UISplashScreenID;
|
||||
}
|
||||
|
||||
class DisplayToast : ServerPacket
|
||||
{
|
||||
public ulong Quantity;
|
||||
public DisplayToastMethod DisplayToastMethod;
|
||||
public bool Mailed;
|
||||
public DisplayToastType Type = DisplayToastType.Money;
|
||||
public uint QuestID;
|
||||
public bool IsSecondaryResult;
|
||||
public ItemInstance Item;
|
||||
public bool BonusRoll;
|
||||
public int LootSpec;
|
||||
public Gender Gender = Gender.None;
|
||||
public uint CurrencyID;
|
||||
|
||||
public DisplayToast() : base(ServerOpcodes.DisplayToast, ConnectionType.Instance) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteUInt64(Quantity);
|
||||
_worldPacket.WriteUInt8((byte)DisplayToastMethod);
|
||||
_worldPacket.WriteUInt32(QuestID);
|
||||
|
||||
_worldPacket.WriteBit(Mailed);
|
||||
_worldPacket.WriteBits((byte)Type, 2);
|
||||
_worldPacket.WriteBit(IsSecondaryResult);
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case DisplayToastType.NewItem:
|
||||
_worldPacket.WriteBit(BonusRoll);
|
||||
Item.Write(_worldPacket);
|
||||
_worldPacket.WriteInt32(LootSpec);
|
||||
_worldPacket.WriteInt32((int)Gender);
|
||||
break;
|
||||
case DisplayToastType.NewCurrency:
|
||||
_worldPacket.WriteUInt32(CurrencyID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_worldPacket.FlushBits();
|
||||
}
|
||||
}
|
||||
|
||||
class DisplayGameError : ServerPacket
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user