Skip to content

Commit

Permalink
Split exp modifier for enemies and quests
Browse files Browse the repository at this point in the history
- Made a new exp modifier group for quests and enemy rewards.
- Moved modifier calculation into a function for quest rewards.
  • Loading branch information
pacampbell committed Dec 6, 2024
1 parent e826966 commit 2a0f8e6
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 43 deletions.
19 changes: 14 additions & 5 deletions Arrowgene.Ddon.GameServer/Characters/ExpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,16 @@ private double CalculateTargetLvMultiplier(GameMode gameMode, PartyGroup party,
return multiplier;
}

private double ModifierBasedOnSource(RewardSource source)
{
return source == RewardSource.Enemy ? _GameSettings.EnemyExpModifier : _GameSettings.QuestExpModifier;
}

public uint GetAdjustedExp(GameMode gameMode, RewardSource source, PartyGroup party, uint baseExpAmount, uint targetLv)
{
if (_Server.GpCourseManager.DisablePartyExpAdjustment())
{
return (uint)(baseExpAmount * _GameSettings.ExpModifier);
return (uint)(baseExpAmount * ModifierBasedOnSource(source));
}

double multiplier = 1.0;
Expand All @@ -913,8 +918,12 @@ public uint GetAdjustedExp(GameMode gameMode, RewardSource source, PartyGroup pa
var partyRangeMultiplier = CalculatePartyRangeMultipler(gameMode, party);
multiplier = Math.Min(partyRangeMultiplier, targetMultiplier);
}

return (uint)(multiplier * baseExpAmount * _GameSettings.ExpModifier);
else if (source == RewardSource.Quest)
{
// Currently no adjustments
}

return (uint)(multiplier * baseExpAmount * ModifierBasedOnSource(source));
}

private uint GetMaxAllowedPartyRange()
Expand Down Expand Up @@ -996,13 +1005,13 @@ public uint GetAdjustedPawnExp(GameMode gameMode, RewardSource source, PartyGrou
{
if (!_GameSettings.EnablePawnCatchup || gameMode == GameMode.BitterblackMaze)
{
return (uint)(baseExpAmount * _GameSettings.ExpModifier);
return (uint)(baseExpAmount * ModifierBasedOnSource(source));
}

var targetMultiplier = CalculatePawnCatchupTargetLvMultiplier(gameMode, pawn, targetLv);
var multiplier = _GameSettings.PawnCatchupMultiplier * targetMultiplier;

return (uint)(multiplier * baseExpAmount * _GameSettings.ExpModifier);
return (uint)(multiplier * baseExpAmount * ModifierBasedOnSource(source));
}
}
}
81 changes: 55 additions & 26 deletions Arrowgene.Ddon.GameServer/Quests/QuestStateManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Arrowgene.Ddon.Database.Model;
using Arrowgene.Ddon.GameServer.Characters;
using Arrowgene.Ddon.GameServer.Party;
using Arrowgene.Ddon.Server;
Expand All @@ -10,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Drawing;
using System.Linq;

namespace Arrowgene.Ddon.GameServer.Quests
Expand Down Expand Up @@ -557,6 +559,27 @@ public QuestProcessState GetProcessState(uint questScheduleId, ushort processNo)
public abstract PacketQueue DistributeQuestRewards(uint questScheduleId, DbConnection? connectionIn = null);
public abstract PacketQueue UpdatePriorityQuestList(GameClient requestingClient, DbConnection? connectionIn = null);

private uint CalculateTotalPointAmount(DdonGameServer server, GameClient client, CDataQuestExp point)
{
uint amount = point.Reward;
double modifier = 1.0;
switch (point.Type)
{
case ExpType.ExperiencePoints:
amount = server.ExpManager.GetAdjustedExp(client.GameMode, RewardSource.Quest, null, point.Reward, 0);
break;
case ExpType.JobPoints:
modifier = (uint)(amount * server.Setting.GameLogicSetting.JpModifier);
break;
case ExpType.PlayPoints:
amount = (uint)(amount * server.Setting.GameLogicSetting.PpModifier);
break;
default:
break;
}
return amount;
}

protected PacketQueue SendWalletRewards(DdonGameServer server, GameClient client, Quest quest, DbConnection? connectionIn = null)
{
PacketQueue packets = new();
Expand All @@ -581,40 +604,47 @@ protected PacketQueue SendWalletRewards(DdonGameServer server, GameClient client
client.Enqueue(updateCharacterItemNtc, packets);
}

foreach (var expPoint in quest.ExpRewards)
foreach (var point in quest.ExpRewards)
{
uint amount = expPoint.Reward;
double modifier = 1.0;
switch (expPoint.Type)
uint amount = CalculateTotalPointAmount(server, client, point);
if (amount == 0)
{
continue;
}

switch (point.Type)
{
case ExpType.ExperiencePoints:
modifier = server.Setting.GameLogicSetting.ExpModifier;
packets.AddRange(server.ExpManager.AddExp(client, client.Character, amount, RewardSource.Quest, quest.QuestType, connectionIn));
if (server.Setting.GameLogicSetting.EnableMainPartyPawnsQuestRewards)
{
foreach (PartyMember member in client.Party.Members)
{
if (member is PawnPartyMember pawnMember && client.Character.Pawns.Contains(pawnMember.Pawn))
{
packets.AddRange(server.ExpManager.AddExp(client, pawnMember.Pawn, amount, RewardSource.Quest, quest.QuestType, connectionIn));
}
}
}
break;
case ExpType.JobPoints:
modifier = server.Setting.GameLogicSetting.JpModifier;
packets.AddRange(server.ExpManager.AddJp(client, client.Character, amount, RewardSource.Quest, quest.QuestType, connectionIn));
if (server.Setting.GameLogicSetting.EnableMainPartyPawnsQuestRewards)
{
foreach (PartyMember member in client.Party.Members)
{
if (member is PawnPartyMember pawnMember && client.Character.Pawns.Contains(pawnMember.Pawn))
{
packets.AddRange(server.ExpManager.AddJp(client, pawnMember.Pawn, amount, RewardSource.Quest, quest.QuestType, connectionIn));
}
}
}
break;
case ExpType.PlayPoints:
modifier = server.Setting.GameLogicSetting.PpModifier;
var ntc = server.PPManager.AddPlayPoint(client, amount, type: 1, connectionIn: connectionIn);
client.Enqueue(ntc, packets);
break;
}

amount = (uint)(amount * modifier);

if (expPoint.Type == ExpType.ExperiencePoints)
{
var ntcs = server.ExpManager.AddExp(client, client.Character, amount, RewardSource.Quest, quest.QuestType, connectionIn);
packets.AddRange(ntcs);
}
else if (expPoint.Type == ExpType.JobPoints)
{
var ntcs = server.ExpManager.AddJp(client, client.Character, amount, RewardSource.Quest, quest.QuestType, connectionIn);
packets.AddRange(ntcs);
}
else if (expPoint.Type == ExpType.PlayPoints)
{
var ntc = server.PPManager.AddPlayPoint(client, amount, type: 1, connectionIn: connectionIn);
client.Enqueue(ntc, packets);
}
}

if (QuestManager.IsClanQuest(quest) && client.Character.ClanId != 0)
Expand All @@ -630,7 +660,6 @@ protected PacketQueue SendWalletRewards(DdonGameServer server, GameClient client
packets.AddRange(completeNtcs);
}


return packets;
}

Expand Down
42 changes: 30 additions & 12 deletions Arrowgene.Ddon.Server/GameLogicSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,43 +169,53 @@ public class GameLogicSetting
/// <summary>
/// Global modifier for exp calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] public double ExpModifier { get; set; }
[DataMember(Order = 27)] public double EnemyExpModifier { get; set; }

/// <summary>
/// Global modifier for quest exp calculations to scale up or down.
/// </summary>
[DataMember(Order = 28)] public double QuestExpModifier { get; set; }

/// <summary>
/// Global modifier for pp calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] public double PpModifier { get; set; }
[DataMember(Order = 29)] public double PpModifier { get; set; }

/// <summary>
/// Global modifier for BO calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] public double BoModifier { get; set; }
[DataMember(Order = 30)] public double BoModifier { get; set; }

/// <summary>
/// Global modifier for HO calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] public double HoModifier { get; set; }
[DataMember(Order = 31)] public double HoModifier { get; set; }

/// <summary>
/// Global modifier for JP calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] public double JpModifier { get; set; }
[DataMember(Order = 32)] public double JpModifier { get; set; }

/// <summary>
/// Configures the maximum amount of reward box slots.
/// </summary>
[DataMember(Order = 27)] public byte RewardBoxMax { get; set; }
[DataMember(Order = 33)] public byte RewardBoxMax { get; set; }

/// <summary>
/// Configures the maximum amount of quests that can be ordered at one time.
/// </summary>
[DataMember(Order = 27)] public byte QuestOrderMax { get; set; }
[DataMember(Order = 34)] public byte QuestOrderMax { get; set; }

/// <summary>
/// Configures if epitaph rewards are limited once per weekly reset.
/// </summary>
[DataMember(Order = 28)] public bool EnableEpitaphWeeklyRewards { get; set; }
[DataMember(Order = 35)] public bool EnableEpitaphWeeklyRewards { get; set; }

/// Enables main pawns in party to gain EXP and JP from quests
/// Original game apparantly did not have pawns share quest reward, so will set to false for default,
/// change as needed
/// </summary>
[DataMember(Order = 36)] public bool EnableMainPartyPawnsQuestRewards { get; set; }

/// <summary>
/// Various URLs used by the client.
Expand Down Expand Up @@ -290,7 +300,8 @@ public GameLogicSetting()
DefaultMaxBazaarExhibits = 5;
DefaultWarpFavorites = 3;

ExpModifier = 1.0;
EnemyExpModifier = 1.0;
QuestExpModifier = 1.0;
PpModifier = 1.0;
BoModifier = 1.0;
HoModifier = 1.0;
Expand All @@ -299,6 +310,7 @@ public GameLogicSetting()
QuestOrderMax = 20;

EnableEpitaphWeeklyRewards = false;
EnableMainPartyPawnsQuestRewards = false;

string urlDomain = $"http://localhost:{52099}";
UrlManual = $"{urlDomain}/manual_nfb/";
Expand Down Expand Up @@ -352,7 +364,8 @@ public GameLogicSetting(GameLogicSetting setting)
DefaultMaxBazaarExhibits = setting.DefaultMaxBazaarExhibits;
DefaultWarpFavorites = setting.DefaultWarpFavorites;

ExpModifier = setting.ExpModifier;
EnemyExpModifier = setting.EnemyExpModifier;
QuestExpModifier = setting.QuestExpModifier;
PpModifier = setting.PpModifier;
BoModifier = setting.BoModifier;
HoModifier = setting.HoModifier;
Expand All @@ -361,6 +374,7 @@ public GameLogicSetting(GameLogicSetting setting)
QuestOrderMax = setting.QuestOrderMax;

EnableEpitaphWeeklyRewards = setting.EnableEpitaphWeeklyRewards;
EnableMainPartyPawnsQuestRewards = setting.EnableMainPartyPawnsQuestRewards;

UrlManual = setting.UrlManual;
UrlShopDetail = setting.UrlShopDetail;
Expand Down Expand Up @@ -436,9 +450,13 @@ void OnDeserialized(StreamingContext context)
{
PawnCatchupMultiplier = 1.0;
}
if (ExpModifier < 0)
if (EnemyExpModifier < 0)
{
EnemyExpModifier = 1.0;
}
if (QuestExpModifier < 0)
{
ExpModifier = 1.0;
QuestExpModifier = 1.0;
}
if (PpModifier < 0)
{
Expand Down

0 comments on commit 2a0f8e6

Please sign in to comment.