Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server setting to enable substituting legendary key rewards emotes #3944

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/ACE.Server/Managers/PropertyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ public static void LoadDefaultProperties()

public static readonly ReadOnlyDictionary<string, Property<long>> DefaultLongProperties =
DictOf(
("award_wcid_for_legendary", new Property<long>(0, "the WCID to award for emote giving instead of legendary keys. 0 = disabled feature")),
("char_delete_time", new Property<long>(3600, "the amount of time in seconds a deleted character can be restored")),
("chat_requires_account_time_seconds", new Property<long>(0, "the amount of time in seconds an account is required to have existed for for global chat privileges")),
("chat_requires_player_age", new Property<long>(0, "the amount of time in seconds a player is required to have played for global chat privileges")),
Expand Down
40 changes: 38 additions & 2 deletions Source/ACE.Server/WorldObjects/Player_Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3383,7 +3383,34 @@ private void OnPutItemInContainer(uint itemGuid, uint containerGuid, int placeme
Prev_PutItemInContainer[1] = Prev_PutItemInContainer[0];
Prev_PutItemInContainer[0] = new PutItemInContainerEvent(itemGuid, containerGuid, placement);
}


// Map of the various legendary keys that may be given on emote/quest and the number of uses.
// Static map for quick comparisons
static Dictionary<uint, int> _LegendaryKeyUses = new Dictionary<uint, int>()
{
{48746, 1 }, // Aged Legendary Key
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is something I can use other than the literal values, please provide an example if that is preferred.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeenieClassName

{48747, 1 }, // 24 hour, single use
{48748, 2 }, // 24 hour, 2 use
{48749, 3 }, // 24 hour, 3 use
{48750, 4 }, // 24 hour, 4 use
{48914, 1 }, // 24 hour, 1 use, quest legendary chest key
{51558, 1 }, // 1 use
{51586, 3 }, // 24 hour, 3 use, quest legendary chest key
{51648, 3 }, // 24 hour, 3 use, quest legendary chest key
{51954, 10 }, // Durable Legendary Key
{51963, 25 }, // 25 use
{52010, 5 }, // 24 hour, 5 use, quest legendary chest key
{72048, 1 }, // 24 hour, 1 use, quest legendary chest key non-pcap
{72338, 3 }, // 24 hour, 3 use, quest legendary chest key non-pcap
{72474, 2 }, // 24 hour, 2 use, quest legendary chest key non-pcap
{72600, 1 }, // 24 hour, 1 use, quest legendary chest key non-pcap
{72628, 1 }, // 24 hour, 1 use, quest legendary chest key non-pcap
{72635, 3 }, // 24 hour, 3 use, quest legendary chest key non-pcap
{72669, 1 }, // 24 hour, 1 use, quest legendary chest key non-pcap
{72807, 2 }, // 24 hour, 2 use, quest legendary chest key non-pcap
{87168, 4 } // 24 hour, 4 use, quest legendary chest key non-pcap
};

public void GiveFromEmote(WorldObject emoter, uint weenieClassId, int amount = 1, int palette = 0, float shade = 0)
{
if (emoter is null || weenieClassId == 0)
Expand All @@ -3397,8 +3424,17 @@ public void GiveFromEmote(WorldObject emoter, uint weenieClassId, int amount = 1
}
var itemsToReceive = new ItemsToReceive(this);

itemsToReceive.Add(weenieClassId, amount);
// If supported by server setting, substitute emote given items across all interactions
uint substituteItem = (uint)PropertyManager.GetLong("award_wcid_for_legendary").Item;
if ((substituteItem != 0) && _LegendaryKeyUses.ContainsKey(weenieClassId))
{
// log.Debug($"Substituting {substituteItem} for {weenieClassId} with quantity {amount}");
amount *= _LegendaryKeyUses[weenieClassId];
weenieClassId = substituteItem;
// log.Debug($"Substituted quantity {amount}");
}

itemsToReceive.Add(weenieClassId, amount);
var itemStacks = itemsToReceive.RequiredSlots;

if (itemsToReceive.PlayerExceedsLimits)
Expand Down