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

Fix/misc quest changes #638

Merged
merged 2 commits into from
Dec 6, 2024
Merged
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
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
7 changes: 5 additions & 2 deletions Arrowgene.Ddon.Shared/Files/Assets/quests/q50101020.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"item_id": 9456,
"num": 3
},
{
"item_id": 7795,
"num": 200
}
]
},
Expand Down Expand Up @@ -290,7 +294,6 @@
"named_enemy_params_id": 631,
"level": 58,
"exp": 0,
"blood_orbs": 200,
"is_boss": true
},
{
Expand Down Expand Up @@ -490,4 +493,4 @@
]
}
]
}
}
7 changes: 5 additions & 2 deletions Arrowgene.Ddon.Shared/Files/Assets/quests/q50102020.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"item_id": 9457,
"num": 3
},
{
"item_id": 7795,
"num": 200
}
]
},
Expand Down Expand Up @@ -204,7 +208,6 @@
"index": 0,
"level": 60,
"exp": 0,
"blood_orbs": 200,
"named_enemy_params_id": 682,
"is_boss": true
}
Expand Down Expand Up @@ -304,4 +307,4 @@
]
}
]
}
}
8 changes: 5 additions & 3 deletions Arrowgene.Ddon.Shared/Files/Assets/quests/q50103020.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"item_id": 9788,
"num": 3
},
{
"item_id": 7795,
"num": 200
}
]
},
Expand Down Expand Up @@ -185,15 +189,13 @@
"enemy_id": "0x015711",
"level": 60,
"exp": 0,
"blood_orbs": 100,
"is_boss": true
},
{
"comment": "Mogok",
"enemy_id": "0x015840",
"level": 60,
"exp": 0,
"blood_orbs": 100,
"is_boss": true
}
]
Expand Down Expand Up @@ -308,4 +310,4 @@
]
}
]
}
}
7 changes: 5 additions & 2 deletions Arrowgene.Ddon.Shared/Files/Assets/quests/q50104000.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"item_id": 9789,
"num": 3
},
{
"item_id": 7795,
"num": 1000
}
]
},
Expand All @@ -49,7 +53,6 @@
"enemy_id": "0x021002",
"level": 60,
"exp": 0,
"blood_orbs": 1000,
"named_enemy_params_id": 440,
"is_boss": true
}
Expand Down Expand Up @@ -259,4 +262,4 @@
]
}
]
}
}
Loading
Loading