Core/Commands: Add ItemContext argument to .additem and .additemset commands
Port From (https://github.com/TrinityCore/TrinityCore/commit/f072bc4ca1375805691c5f98e7def74aa8ae9f31)
This commit is contained in:
@@ -377,21 +377,21 @@ namespace Framework.Constants
|
||||
RaidHeroic = 5,
|
||||
RaidMythic = 6,
|
||||
PvpUnranked1 = 7,
|
||||
PvpRanked1 = 8,
|
||||
PvpRanked1Unrated = 8,
|
||||
ScenarioNormal = 9,
|
||||
ScenarioHeroic = 10,
|
||||
QuestReward = 11,
|
||||
Store = 12,
|
||||
InGameStore = 12,
|
||||
TradeSkill = 13,
|
||||
Vendor = 14,
|
||||
BlackMarket = 15,
|
||||
ChallengeMode1 = 16,
|
||||
MythicplusEndOfRun = 16,
|
||||
DungeonLvlUp1 = 17,
|
||||
DungeonLvlUp2 = 18,
|
||||
DungeonLvlUp3 = 19,
|
||||
DungeonLvlUp4 = 20,
|
||||
ForceToNone = 21,
|
||||
Timewalker = 22,
|
||||
Timewalking = 22,
|
||||
DungeonMythic = 23,
|
||||
PvpHonorReward = 24,
|
||||
WorldQuest1 = 25,
|
||||
@@ -402,19 +402,19 @@ namespace Framework.Constants
|
||||
WorldQuest6 = 30,
|
||||
MissionReward1 = 31,
|
||||
MissionReward2 = 32,
|
||||
ChallengeMode2 = 33,
|
||||
ChallengeMode3 = 34,
|
||||
ChallengeModeJackpot = 35,
|
||||
MythicplusEndOfRunTimeChest = 33,
|
||||
ZzchallengeMode3 = 34,
|
||||
MythicplusJackpot = 35,
|
||||
WorldQuest7 = 36,
|
||||
WorldQuest8 = 37,
|
||||
PvpRanked2 = 38,
|
||||
PvpRanked3 = 39,
|
||||
PvpRanked4 = 40,
|
||||
PvpRanked2Combatant = 38,
|
||||
PvpRanked3Challenger = 39,
|
||||
PvpRanked4Rival = 40,
|
||||
PvpUnranked2 = 41,
|
||||
WorldQuest9 = 42,
|
||||
WorldQuest10 = 43,
|
||||
PvpRanked5 = 44,
|
||||
PvpRanked6 = 45,
|
||||
PvpRanked5Duelist = 44,
|
||||
PvpRanked6Elite = 45,
|
||||
PvpRanked7 = 46,
|
||||
PvpUnranked3 = 47,
|
||||
PvpUnranked4 = 48,
|
||||
@@ -427,7 +427,37 @@ namespace Framework.Constants
|
||||
WorldQuest13 = 55,
|
||||
PvpRankedJackpot = 56,
|
||||
TournamentRealm = 57,
|
||||
Relinquished = 58
|
||||
Relinquished = 58,
|
||||
LegendaryForge = 59,
|
||||
QuestBonusLoot = 60,
|
||||
CharacterBoostBfa = 61,
|
||||
CharacterBoostShadowlands = 62,
|
||||
LegendaryCrafting1 = 63,
|
||||
LegendaryCrafting2 = 64,
|
||||
LegendaryCrafting3 = 65,
|
||||
LegendaryCrafting4 = 66,
|
||||
LegendaryCrafting5 = 67,
|
||||
LegendaryCrafting6 = 68,
|
||||
LegendaryCrafting7 = 69,
|
||||
LegendaryCrafting8 = 70,
|
||||
LegendaryCrafting9 = 71,
|
||||
WeeklyRewardsAdditional = 72,
|
||||
WeeklyRewardsConcession = 73,
|
||||
WorldQuestJackpot = 74,
|
||||
NewCharacter = 75,
|
||||
WarMode = 76,
|
||||
PvpBrawl1 = 77,
|
||||
PvpBrawl2 = 78,
|
||||
Torghast = 79,
|
||||
CorpseRecovery = 80,
|
||||
WorldBoss = 81,
|
||||
RaidNormalExtended = 82,
|
||||
RaidRaidFinderExtended = 83,
|
||||
RaidHeroicExtended = 84,
|
||||
RaidMythicExtended = 85,
|
||||
CharacterTemplate91 = 86,
|
||||
|
||||
Max
|
||||
}
|
||||
|
||||
public enum ItemEnchantmentType : byte
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace Game.Chat
|
||||
|
||||
List<uint> bonusListIDs = new();
|
||||
var bonuses = args.NextString();
|
||||
var context = args.NextString();
|
||||
|
||||
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
|
||||
if (!bonuses.IsEmpty())
|
||||
@@ -92,7 +93,17 @@ namespace Game.Chat
|
||||
if (uint.TryParse(tokens[i], out uint id))
|
||||
bonusListIDs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
ItemContext itemContext = ItemContext.None;
|
||||
if (!context.IsEmpty())
|
||||
{
|
||||
itemContext = context.ToEnum<ItemContext>();
|
||||
if (itemContext != ItemContext.None && itemContext < ItemContext.Max)
|
||||
{
|
||||
var contextBonuses = Global.DB2Mgr.GetDefaultItemBonusTree(itemId, itemContext);
|
||||
bonusListIDs.AddRange(contextBonuses);
|
||||
}
|
||||
}
|
||||
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
@@ -132,7 +143,7 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId), null, ItemContext.None, bonusListIDs);
|
||||
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId), null, itemContext, bonusListIDs);
|
||||
|
||||
// remove binding (let GM give it to another player later)
|
||||
if (player == playerTarget)
|
||||
@@ -177,6 +188,7 @@ namespace Game.Chat
|
||||
|
||||
List<uint> bonusListIDs = new();
|
||||
var bonuses = args.NextString();
|
||||
var context = args.NextString();
|
||||
|
||||
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
|
||||
if (!bonuses.IsEmpty())
|
||||
@@ -189,6 +201,10 @@ namespace Game.Chat
|
||||
}
|
||||
}
|
||||
|
||||
ItemContext itemContext = ItemContext.None;
|
||||
if (!context.IsEmpty())
|
||||
itemContext = context.ToEnum<ItemContext>();
|
||||
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
Player playerTarget = handler.GetSelectedPlayer();
|
||||
if (!playerTarget)
|
||||
@@ -207,7 +223,14 @@ namespace Game.Chat
|
||||
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
|
||||
if (msg == InventoryResult.Ok)
|
||||
{
|
||||
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, ItemContext.None, bonusListIDs);
|
||||
List<uint> bonusListIDsForItem = new List<uint>(bonusListIDs); // copy, bonuses for each depending on context might be different for each item
|
||||
if (itemContext != ItemContext.None && itemContext < ItemContext.Max)
|
||||
{
|
||||
var contextBonuses = Global.DB2Mgr.GetDefaultItemBonusTree(template.Value.GetId(), itemContext);
|
||||
bonusListIDsForItem.AddRange(contextBonuses);
|
||||
}
|
||||
|
||||
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, itemContext, bonusListIDsForItem);
|
||||
|
||||
// remove binding (let GM give it to another player later)
|
||||
if (player == playerTarget)
|
||||
|
||||
Reference in New Issue
Block a user