Skip to content
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
28 changes: 28 additions & 0 deletions docs-website/docs/admin-panel/game-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ This is where the values live which most server operators want to change:
* **Misc** — info range, recovery interval, letter settings, durability
consumption

### Party experience bonus

A party gets more experience than its members would get alone. The experience of
a party with *n* members is multiplied by `Party Experience Multiplier`^(*n* − 1),
so every additional member multiplies it once more. The value is configured
through the *Global base attribute values* of the game configuration, which you
reach through the full configuration tree.

The default is `1.05`, which is the party experience of all game versions
(0.75, 0.95d and Season 6):

| Members | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| Experience bonus | 5% | 10.25% | 15.76% | 21.55% |

A value of `0` or less (or an attribute which isn't configured) means no bonus,
and a single player never gets a bonus.

A party can additionally get a `Set Party Experience Bonus`, which is added to
the multiplier (`0.02` adds 2%). It defaults to `0`, so it's disabled until you
configure it. Zero or negative values are ignored. A **set party** is a party of
at least three members in which every member belongs to a different class line,
for example a Dark Wizard (or Soul Master, Grand Master, …), a Dark Knight and a
Fairy Elf.

The same attributes can also be defined per map, account or character, for
example for an event; the first member of the party decides.

## Monsters

Route `edit-config-grid/…MonsterDefinition/`
Expand Down
12 changes: 12 additions & 0 deletions src/AttributeSystem/Properties/AttributeTexts.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@
<data name="Name_OneHandedSwordBonusDamageMST" xml:space="preserve">
<value>Bonusschaden für Einhandschwerter (MST)</value>
</data>
<data name="Name_PartyExperienceMultiplier" xml:space="preserve">
<value>Erfahrungsmultiplikator der Gruppe</value>
</data>
<data name="Description_PartyExperienceMultiplier" xml:space="preserve">
<value>Definiert den Erfahrungsmultiplikator einer Gruppe für jedes zusätzliche Gruppenmitglied (1,05 = 5 % mehr Erfahrung für das zweite Mitglied, was für jedes weitere Mitglied multipliziert wird, d. h. eine Gruppe mit 3 Mitgliedern erhält 1,05 * 1,05). Ein Wert von 0 oder weniger deaktiviert ihn.</value>
</data>
<data name="Name_PetDurationIncrease" xml:space="preserve">
<value>Erhöhung der Begleiterhaltbarkeit</value>
</data>
Expand Down Expand Up @@ -903,6 +909,12 @@
<data name="Description_SDRateIncrease" xml:space="preserve">
<value>Erhöht die Schadensabsorptionsrate des Schilds im PvP entsprechend dem eingestellten Wert.</value>
</data>
<data name="Name_SetPartyExperienceBonus" xml:space="preserve">
<value>Erfahrungsbonus der Set-Gruppe</value>
</data>
<data name="Description_SetPartyExperienceBonus" xml:space="preserve">
<value>Definiert den Erfahrungsbonus, der zum Erfahrungsmultiplikator einer Set-Gruppe addiert wird, als Anteil der Erfahrung (0,02 = 2 %).</value>
</data>
<data name="Name_ShieldBypassChance" xml:space="preserve">
<value>Chance, den Schild (SD) zu umgehen</value>
</data>
Expand Down
12 changes: 12 additions & 0 deletions src/AttributeSystem/Properties/AttributeTexts.resx
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@
<data name="Name_OneHandedSwordBonusDamageMST" xml:space="preserve">
<value>One Handed Sword Bonus Damage (MST)</value>
</data>
<data name="Name_PartyExperienceMultiplier" xml:space="preserve">
<value>Party Experience Multiplier</value>
</data>
<data name="Description_PartyExperienceMultiplier" xml:space="preserve">
<value>Defines the experience multiplier of a party for each additional party member (1.05 = 5% more experience for the second member, which is multiplied for each further member, so a party of 3 members gets 1.05 * 1.05). A value of 0 or less disables it.</value>
</data>
<data name="Name_PetDurationIncrease" xml:space="preserve">
<value>Pet Duration Increase</value>
</data>
Expand Down Expand Up @@ -909,6 +915,12 @@
<data name="Description_SDRateIncrease" xml:space="preserve">
<value>Increases the shield’s damage absorb rate in PVP according to set value.</value>
</data>
<data name="Name_SetPartyExperienceBonus" xml:space="preserve">
<value>Set Party Experience Bonus</value>
</data>
<data name="Description_SetPartyExperienceBonus" xml:space="preserve">
<value>Defines the experience bonus which is added to the experience multiplier of a set party, as fraction of the experience (0.02 = 2%).</value>
</data>
<data name="Name_ShieldBypassChance" xml:space="preserve">
<value>Shield Bypass Chance</value>
</data>
Expand Down
12 changes: 12 additions & 0 deletions src/AttributeSystem/Properties/AttributeTexts.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@
<data name="Name_OneHandedSwordBonusDamageMST" xml:space="preserve">
<value>单手剑伤害加成(大师技能)</value>
</data>
<data name="Name_PartyExperienceMultiplier" xml:space="preserve">
<value>队伍经验倍率</value>
</data>
<data name="Description_PartyExperienceMultiplier" xml:space="preserve">
<value>定义每增加一名队伍成员时队伍经验所乘的倍率(1.05 = 第二名成员增加5%经验,并对之后每名成员继续相乘,即3名成员的队伍获得 1.05 * 1.05)。值为0或更小则禁用。</value>
</data>
<data name="Name_PetDurationIncrease" xml:space="preserve">
<value>宠物持续时间增加</value>
</data>
Expand Down Expand Up @@ -909,6 +915,12 @@
<data name="Description_SDRateIncrease" xml:space="preserve">
<value>对玩家战斗时,按设定值提高防护值的伤害吸收比例。</value>
</data>
<data name="Name_SetPartyExperienceBonus" xml:space="preserve">
<value>套装队伍经验加成</value>
</data>
<data name="Description_SetPartyExperienceBonus" xml:space="preserve">
<value>定义在套装队伍的经验倍率基础上额外增加的经验加成,以经验的比例表示(0.02 = 2%)。</value>
</data>
<data name="Name_ShieldBypassChance" xml:space="preserve">
<value>无视防护值概率</value>
</data>
Expand Down
20 changes: 20 additions & 0 deletions src/GameLogic/Attributes/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ public class Stats
/// </summary>
public static AttributeDefinition RandomExperienceMaxMultiplier { get; } = new(new Guid("74CE26C6-6D59-4420-AF3F-457E138AE41C"), "Random Experience Max Multiplier", "Defines the maximum multiplier for the randomized experience gain.");

/// <summary>
/// Gets the party experience multiplier, by which the experience of a party is multiplied for each additional party member.
/// </summary>
/// <remarks>
/// A party of n members gets <c>PartyExperienceMultiplier^(n-1)</c> times the experience, so with the default of 1.05,
/// a party of 3 members gets 1.05 * 1.05. A value of 0 or less disables it.
/// It can be defined in the <see cref="GameConfiguration.GlobalBaseAttributeValues"/>.
/// </remarks>
public static AttributeDefinition PartyExperienceMultiplier { get; } = new(new Guid("A086BE24-8849-4C26-8C7F-9CEF8DE27DEB"), "Party Experience Multiplier", "Defines the experience multiplier of a party for each additional party member (1.05 = 5% more experience for the second member, which is multiplied for each further member, so a party of 3 members gets 1.05 * 1.05). A value of 0 or less disables it.");

/// <summary>
/// Gets the bonus experience of a set party, which is added to <see cref="PartyExperienceMultiplier"/>.
/// </summary>
/// <remarks>
/// A set party is a party of at least three members, in which every member belongs to a different character class line.
/// The value is a fraction which is added to the multiplier of the party, so 0.02 increases the experience by an additional 2%. By default it's 0, which means no bonus.
/// It can be defined in the <see cref="GameConfiguration.GlobalBaseAttributeValues"/>.
/// </remarks>
public static AttributeDefinition SetPartyExperienceBonus { get; } = new(new Guid("BAEAC94C-9B06-4C15-BA7F-6E6B062CAF27"), "Set Party Experience Bonus", "Defines the experience bonus which is added to the experience multiplier of a set party, as fraction of the experience (0.02 = 2%).");

/// <summary>
/// Gets the bonus experience rate attribute definition, which is added to <see cref="ExperienceRate"/> or <see cref="MasterExperienceRate"/>.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/GameLogic/Party.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ private static float CalculatePartyExperiencePerLevel(List<Player> recipients, I
var averageLevel = totalLevel / memberCount;
var baseExperience = killed.CalculateBaseExperience(averageLevel);

var partyBonusMultiplier = Math.Pow(1.05, memberCount - 1);
var partyBonusMultiplier = PartyExperienceBonus.GetMultiplier(recipients);
var mapExperienceMultiplier = killed.CurrentMap?.Definition.ExpMultiplier ?? 1;
var totalBaseExperience = baseExperience * memberCount * partyBonusMultiplier * mapExperienceMultiplier;

Expand Down
129 changes: 129 additions & 0 deletions src/GameLogic/PartyExperienceBonus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// <copyright file="PartyExperienceBonus.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.GameLogic;

using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.GameLogic.Attributes;

/// <summary>
/// Determines the experience bonus of a party, depending on its size and composition.
/// </summary>
/// <remarks>
/// <para>
/// The bonuses are configurable through attributes, which are read from the attribute system of the party members,
/// so they can be defined globally, but also per map, account or character.
/// The first party member decides, as it does for the random experience multipliers.
/// </para>
/// <para>
/// The experience of a party with n members is multiplied by <see cref="Stats.PartyExperienceMultiplier"/>^(n - 1),
/// which is 1.05^(n - 1) by default. A party with at least <see cref="MinimumSetPartySize"/> members, in which every
/// member belongs to a different character class line (e.g. Dark Wizard, Dark Knight and Fairy Elf), is a "set party"
/// and additionally gets <see cref="Stats.SetPartyExperienceBonus"/> added, which is 0 by default.
/// </para>
/// </remarks>
internal static class PartyExperienceBonus
{
/// <summary>
/// The minimum number of members of a set party.
/// </summary>
internal const int MinimumSetPartySize = 3;

/// <summary>
/// The minimum number of members of a party which gets an experience bonus.
/// </summary>
internal const int MinimumBonusPartySize = 2;

/// <summary>
/// Gets the multiplier which is applied to the experience of the party.
/// </summary>
/// <param name="members">The party members which share the experience.</param>
/// <returns>The multiplier, which is <c>1</c> if the party doesn't get a bonus.</returns>
public static double GetMultiplier(IReadOnlyList<Player> members)
{
if (members.Count < MinimumBonusPartySize || members[0].Attributes is not { } attributes)
{
return 1;
}

var multiplier = 1.0;
var partyMultiplier = ToDouble(attributes[Stats.PartyExperienceMultiplier]);
if (partyMultiplier > 0)
{
multiplier = Math.Pow(partyMultiplier, members.Count - 1);
}

var setPartyBonus = ToDouble(attributes[Stats.SetPartyExperienceBonus]);
if (setPartyBonus > 0 && IsSetParty(members))
{
multiplier += setPartyBonus;
}

return multiplier;
}

/// <summary>
/// Determines whether the members form a set party, which means that they are at least
/// <see cref="MinimumSetPartySize"/> and each of them belongs to a different character class line.
/// </summary>
/// <param name="members">The party members.</param>
/// <returns><c>true</c>, if the members form a set party.</returns>
public static bool IsSetParty(IReadOnlyList<Player> members)
{
if (members.Count < MinimumSetPartySize)
{
return false;
}

// Resolve the class line only once per member. The class hierarchy is configuration data and
// can be edited at runtime, so it is intentionally not cached across calls.
// Reference equality is used on purpose: the members share one game configuration, so their
// classes are the same instances, while CharacterClass overrides Equals by its id.
var classLines = new HashSet<CharacterClass>(members.Count, ReferenceEqualityComparer.Instance);
foreach (var member in members)
{
if (GetLastClassOfLine(member) is not { } classLine
|| !classLines.Add(classLine))
{
return false;
}
}

return true;
}

/// <summary>
/// Gets the last class of the line of the character class of the player.
/// </summary>
private static CharacterClass? GetLastClassOfLine(Player player)
{
var characterClass = player.SelectedCharacter?.CharacterClass;
if (characterClass is null)
{
return null;
}

// The class count bounds the loop, so a misconfigured cycle can't hang the game logic.
var maximumSteps = player.GameContext.Configuration.CharacterClasses.Count;
for (var step = 0; step < maximumSteps && characterClass.NextGenerationClass is { } nextClass; step++)
{
characterClass = nextClass;
}

return characterClass;
}

/// <summary>
/// Converts the attribute value to a double.
/// </summary>
/// <remarks>
/// The attribute values are floats, which can't represent fractions like 1.05 exactly. A plain conversion would
/// turn it into 1.0499999..., and the experience would differ slightly from the one calculated with
/// the literal 1.05. Rounding to seven decimal places, which is more than a float can hold reliably, avoids that.
/// </remarks>
private static double ToDouble(float value)
{
return Math.Round((double)value, 7);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ private void AddGlobalBaseAttributeValues()
var randomExperienceMaxMultiplier = this.Context.CreateNew<ConstValueAttribute>(1.2f, Stats.RandomExperienceMaxMultiplier.GetPersistent(this.GameConfiguration), AggregateType.AddRaw);
this.GameConfiguration.GlobalBaseAttributeValues.Add(randomExperienceMaxMultiplier);

foreach (var (attribute, value) in PartyExperienceBonusDefaults.Values)
{
var partyExperienceBonus = this.Context.CreateNew<ConstValueAttribute>(value, attribute.GetPersistent(this.GameConfiguration), AggregateType.AddRaw);
this.GameConfiguration.GlobalBaseAttributeValues.Add(partyExperienceBonus);
}

var movementSpeedFactor = this.Context.CreateNew<ConstValueAttribute>(1f, Stats.MovementSpeedFactor.GetPersistent(this.GameConfiguration), AggregateType.AddRaw);
this.GameConfiguration.GlobalBaseAttributeValues.Add(movementSpeedFactor);

Expand Down
24 changes: 24 additions & 0 deletions src/Persistence/Initialization/PartyExperienceBonusDefaults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// <copyright file="PartyExperienceBonusDefaults.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence.Initialization;

using MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.GameLogic.Attributes;

/// <summary>
/// The default values of the party experience attributes. They are shared by the data initialization,
/// which is used for new databases, and by the update plugins for existing databases.
/// </summary>
internal static class PartyExperienceBonusDefaults
{
/// <summary>
/// Gets the party experience attributes with their default values.
/// </summary>
public static IReadOnlyList<(AttributeDefinition Attribute, float Value)> Values { get; } =
[
(Stats.PartyExperienceMultiplier, 1.05f),
(Stats.SetPartyExperienceBonus, 0f),
];
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@
</data>
<data name="AddCraftingBonusPercentageAttributePlugInBase_Name" xml:space="preserve"><value>Attribut für den Bonus der Erfolgsrate beim Kombinieren hinzufügen</value></data>
<data name="AddCraftingBonusPercentageAttributePlugInBase_Description" xml:space="preserve"><value>Fügt das Attribut hinzu, das die Prozentpunkte festlegt, die zur Erfolgsrate beim Kombinieren von Gegenständen addiert werden.</value></data>
<data name="AddPartyExperienceBonusAttributesPlugInBase_Name" xml:space="preserve"><value>Attribute für den Erfahrungsbonus von Gruppen hinzufügen</value></data>
<data name="AddPartyExperienceBonusAttributesPlugInBase_Description" xml:space="preserve"><value>Fügt die Attribute hinzu, die die Gruppenerfahrung festlegen (den Multiplikator für jedes zusätzliche Gruppenmitglied und einen Bonus für Set-Gruppen), mit Standardwerten, welche die aktuelle Gruppenerfahrung beibehalten: 1,05 für jedes zusätzliche Mitglied und kein Bonus für Set-Gruppen. Vorhandene Werte werden nicht geändert.</value></data>
<data name="FixSeedSphereMaximumItemLevelUpdatePlugIn_Name" xml:space="preserve"><value>Maximale Gegenstandsstufe der Seed Spheres korrigieren</value></data>
<data name="FixSeedSphereMaximumItemLevelUpdatePlugIn_Description" xml:space="preserve"><value>Diese Aktualisierung setzt die maximale Gegenstandsstufe der Seed Spheres auf die höchste Optionsnummer ihres Elements. Die Gegenstandsstufe einer Seed Sphere bestimmt ihre Option, daher konnten Seed Spheres mit einer anderen als der ersten Option nicht erstellt werden, z. B. mit dem Item-Chatbefehl.</value></data>
<data name="SetIntroducedGameVersionsPlugInBase_Name" xml:space="preserve">
Expand Down
Loading
Loading