Correctly clone and remap default preset before returning
This commit is contained in:
parent
e3cf4c3c92
commit
0a6a866ae8
@ -79,7 +79,7 @@ export class QuestController
|
|||||||
for (const quest of allQuests)
|
for (const quest of allQuests)
|
||||||
{
|
{
|
||||||
// Player already accepted the quest, show it regardless of status
|
// Player already accepted the quest, show it regardless of status
|
||||||
const questInProfile = profile.Quests.find((x) => x.qid === quest._id);
|
const questInProfile = profile.Quests.find((quest) => quest.qid === quest._id);
|
||||||
if (questInProfile)
|
if (questInProfile)
|
||||||
{
|
{
|
||||||
quest.sptStatus = questInProfile.status;
|
quest.sptStatus = questInProfile.status;
|
||||||
|
@ -1415,8 +1415,9 @@ export class ItemHelper
|
|||||||
* Update a root items _id property value to be unique
|
* Update a root items _id property value to be unique
|
||||||
* @param itemWithChildren Item to update root items _id property
|
* @param itemWithChildren Item to update root items _id property
|
||||||
* @param newId Optional: new id to use
|
* @param newId Optional: new id to use
|
||||||
|
* @returns New root id
|
||||||
*/
|
*/
|
||||||
public remapRootItemId(itemWithChildren: Item[], newId = this.hashUtil.generate()): void
|
public remapRootItemId(itemWithChildren: Item[], newId = this.hashUtil.generate()): string
|
||||||
{
|
{
|
||||||
const rootItemExistingId = itemWithChildren[0]._id;
|
const rootItemExistingId = itemWithChildren[0]._id;
|
||||||
|
|
||||||
@ -1436,6 +1437,8 @@ export class ItemHelper
|
|||||||
item.parentId = newId;
|
item.parentId = newId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return newId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ export class QuestHelper
|
|||||||
// Only process items with slots
|
// Only process items with slots
|
||||||
if (this.itemHelper.itemHasSlots(questReward.items[0]._tpl))
|
if (this.itemHelper.itemHasSlots(questReward.items[0]._tpl))
|
||||||
{
|
{
|
||||||
// Attempt to pull default preset from globals and add child items to reward
|
// Attempt to pull default preset from globals and add child items to reward (clones questReward.items)
|
||||||
this.generateArmorRewardChildSlots(questReward.items[0], questReward);
|
this.generateArmorRewardChildSlots(questReward.items[0], questReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +283,8 @@ export class QuestHelper
|
|||||||
{
|
{
|
||||||
item.upd = {};
|
item.upd = {};
|
||||||
}
|
}
|
||||||
// reward items are granted Found in Raid status
|
|
||||||
|
// Reward items are granted Found in Raid status
|
||||||
item.upd.SpawnedInSession = true;
|
item.upd.SpawnedInSession = true;
|
||||||
|
|
||||||
// Is root item, fix stacks
|
// Is root item, fix stacks
|
||||||
@ -349,10 +350,13 @@ export class QuestHelper
|
|||||||
if (defaultPreset)
|
if (defaultPreset)
|
||||||
{
|
{
|
||||||
// Preset exists, use mods to hydrate reward item
|
// Preset exists, use mods to hydrate reward item
|
||||||
questReward.items = this.jsonUtil.clone(defaultPreset._items);
|
const presetAndMods: Item[] = this.itemHelper.replaceIDs(null, this.jsonUtil.clone(defaultPreset._items));
|
||||||
|
const newRootId = this.itemHelper.remapRootItemId(presetAndMods);
|
||||||
|
|
||||||
|
questReward.items = presetAndMods;
|
||||||
|
|
||||||
// Remap target id to the new presets id
|
// Remap target id to the new presets id
|
||||||
questReward.target = questReward.items.find((item) => item._tpl === originalRewardRootItem._tpl)._id;
|
questReward.target = newRootId;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user