Skip to content

Commit

Permalink
Merge pull request #628 from pacampbell/new_config_settings
Browse files Browse the repository at this point in the history
feat: Add new settings to be configured and fixes
  • Loading branch information
pacampbell authored Nov 9, 2024
2 parents 5ddd181 + 2aa6402 commit d92b0b5
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Arrowgene.Ddon.GameServer/Characters/ExpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public PacketQueue AddExp(GameClient client, CharacterCommon characterToAddExpTo

if (client.GameMode == GameMode.Normal)
{
addJobPoint += LEVEL_UP_JOB_POINTS_EARNED[targetLevel];
addJobPoint += (uint)(LEVEL_UP_JOB_POINTS_EARNED[targetLevel] * _Server.Setting.GameLogicSetting.JpModifier);
}
}

Expand Down Expand Up @@ -903,7 +903,7 @@ public uint GetAdjustedExp(GameMode gameMode, RewardSource source, PartyGroup pa
{
if (_Server.GpCourseManager.DisablePartyExpAdjustment())
{
return baseExpAmount;
return (uint)(baseExpAmount * _GameSettings.ExpModifier);
}

double multiplier = 1.0;
Expand All @@ -914,7 +914,7 @@ public uint GetAdjustedExp(GameMode gameMode, RewardSource source, PartyGroup pa
multiplier = Math.Min(partyRangeMultiplier, targetMultiplier);
}

return (uint)(multiplier * baseExpAmount);
return (uint)(multiplier * baseExpAmount * _GameSettings.ExpModifier);
}

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

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

return (uint)(multiplier * baseExpAmount);
return (uint)(multiplier * baseExpAmount * _GameSettings.ExpModifier);
}
}
}
4 changes: 1 addition & 3 deletions Arrowgene.Ddon.GameServer/Characters/RewardManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace Arrowgene.Ddon.GameServer.Characters
{
public class RewardManager
{
private readonly int MAX_REWARD_BOX_RESULTS = 100;

private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(RewardManager));

private readonly DdonGameServer _Server;
Expand All @@ -26,7 +24,7 @@ public bool AddQuestRewards(GameClient client, Quest quest, DbConnection? connec
var rewards = quest.GenerateBoxRewards();

var currentRewards = GetQuestBoxRewards(client, connectionIn);
if (currentRewards.Count >= MAX_REWARD_BOX_RESULTS)
if (currentRewards.Count >= _Server.Setting.GameLogicSetting.RewardBoxMax)
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions Arrowgene.Ddon.GameServer/Handler/InstanceEnemyKillHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public override S2CInstanceEnemyKillRes Handle(GameClient client, C2SInstanceEne


uint calcExp = _gameServer.ExpManager.GetAdjustedExp(client.GameMode, RewardSource.Enemy, client.Party, enemyKilled.GetDroppedExperience(), enemyKilled.Lv);
uint calcPP = enemyKilled.GetDroppedPlayPoints();
uint calcPP = (uint)(enemyKilled.GetDroppedPlayPoints() * _gameServer.Setting.GameLogicSetting.PpModifier);

foreach (PartyMember member in client.Party.Members)
{
Expand Down Expand Up @@ -199,16 +199,16 @@ public override S2CInstanceEnemyKillRes Handle(GameClient client, C2SInstanceEne
if (enemyKilled.BloodOrbs > 0)
{
// Drop BO
uint gainedBo = enemyKilled.BloodOrbs;
uint bonusBo = (uint)(enemyKilled.BloodOrbs * _gameServer.GpCourseManager.EnemyBloodOrbBonus());
uint gainedBo = (uint) (enemyKilled.BloodOrbs * _gameServer.Setting.GameLogicSetting.BoModifier);
uint bonusBo = (uint)(gainedBo * _gameServer.GpCourseManager.EnemyBloodOrbBonus());
CDataUpdateWalletPoint boUpdateWalletPoint = _gameServer.WalletManager.AddToWallet(memberClient.Character, WalletType.BloodOrbs, gainedBo + bonusBo, bonusBo, connectionIn: connectionIn);
updateCharacterItemNtc.UpdateWalletList.Add(boUpdateWalletPoint);
}

if (enemyKilled.HighOrbs > 0)
{
// Drop HO
uint gainedHo = enemyKilled.HighOrbs;
uint gainedHo = (uint)(enemyKilled.HighOrbs * _gameServer.Setting.GameLogicSetting.HoModifier);
CDataUpdateWalletPoint hoUpdateWalletPoint = _gameServer.WalletManager.AddToWallet(memberClient.Character, WalletType.HighOrbs, gainedHo, connectionIn: connectionIn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public override S2CQuestGetCycleContentsStateListRes Handle(GameClient client, C
ntc.WorldManageQuestOrderList = pcap.WorldManageQuestOrderList; // Recover paths + change vocation

ntc.QuestDefine = pcap.QuestDefine; // Recover quest log data to be able to accept quests
ntc.QuestDefine.OrderMaxNum = Server.Setting.GameLogicSetting.QuestOrderMax;
ntc.QuestDefine.RewardBoxMaxNum = Server.Setting.GameLogicSetting.RewardBoxMax;

// pcap.MainQuestIdList; (this will add back all missing functionality which depends on complete MSQ)
var completedMsq = client.Character.CompletedQuests.Values.Where(x => x.QuestType == QuestType.Main);
Expand Down
36 changes: 18 additions & 18 deletions Arrowgene.Ddon.GameServer/Handler/QuestGetRewardBoxItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,34 @@ public override S2CQuestGetRewardBoxItemRes Handle(GameClient client, C2SQuestGe
}

var distinctRewards = packet.GetRewardBoxItemList.Select(x => x.UID).Distinct().ToList();
var slotCount = coalescedRewards.Sum(x =>
distinctRewards.Contains(x.Key)
? Server.ItemManager.PredictAddItemSlots(client.Character, StorageType.StorageBoxNormal, x.Value.ItemId, x.Value.Num)
: 0);

var slotCount = coalescedRewards.Sum(x => distinctRewards.Contains(x.Key) ? Server.ItemManager.PredictAddItemSlots(client.Character, StorageType.StorageBoxNormal, x.Value.ItemId, x.Value.Num) : 0);
if (slotCount > client.Character.Storage.GetStorage(StorageType.StorageBoxNormal).EmptySlots())
{
throw new ResponseErrorException(ErrorCode.ERROR_CODE_ITEM_STORAGE_OVERFLOW);
}

foreach (var rewardUID in distinctRewards)
Server.Database.ExecuteInTransaction(connection =>
{
var reward = coalescedRewards[rewardUID];
if (Server.ItemManager.IsItemWalletPoint(reward.ItemId))
foreach (var rewardUID in distinctRewards)
{
(WalletType walletType, uint amount) = Server.ItemManager.ItemToWalletPoint(reward.ItemId);
var result = Server.WalletManager.AddToWallet(client.Character, walletType, amount * reward.Num);
updateCharacterItemNtc.UpdateWalletList.Add(result);
var reward = coalescedRewards[rewardUID];
if (Server.ItemManager.IsItemWalletPoint(reward.ItemId))
{
(WalletType walletType, uint amount) = Server.ItemManager.ItemToWalletPoint(reward.ItemId);
var result = Server.WalletManager.AddToWallet(client.Character, walletType, amount * reward.Num, connectionIn: connection);
updateCharacterItemNtc.UpdateWalletList.Add(result);
}
else if (reward.Num > 0)
{
var result = Server.ItemManager.AddItem(Server, client.Character, false, reward.ItemId, reward.Num, connectionIn: connection);
updateCharacterItemNtc.UpdateItemList.AddRange(result);
}
}
else if (reward.Num > 0)
{
var result = Server.ItemManager.AddItem(Server, client.Character, false, reward.ItemId, reward.Num);
updateCharacterItemNtc.UpdateItemList.AddRange(result);
}
}
client.Send(updateCharacterItemNtc);
Server.RewardManager.DeleteQuestBoxReward(client, questBoxReward.UniqRewardId, connectionIn: connection);
});

Server.RewardManager.DeleteQuestBoxReward(client, questBoxReward.UniqRewardId);
client.Send(updateCharacterItemNtc);

return new S2CQuestGetRewardBoxItemRes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override S2CQuestGetRewardBoxListRes Handle(GameClient client, C2SQuestGe
var quest = QuestManager.GetQuestByScheduleId(boxReward.QuestScheduleId);
if (quest == null)
{
listNo += 1;
Logger.Error($"Quest reward for QuestScheduleId={boxReward.QuestScheduleId}, but no definition of quest exists.");
continue;
}
Expand Down
23 changes: 20 additions & 3 deletions Arrowgene.Ddon.GameServer/Quests/QuestStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,19 +576,36 @@ protected PacketQueue SendWalletRewards(DdonGameServer server, GameClient client

foreach (var expPoint in quest.ExpRewards)
{
uint amount = expPoint.Reward;
double modifier = 1.0;
switch (expPoint.Type)
{
case ExpType.ExperiencePoints:
modifier = server.Setting.GameLogicSetting.ExpModifier;
break;
case ExpType.JobPoints:
modifier = server.Setting.GameLogicSetting.JpModifier;
break;
case ExpType.PlayPoints:
modifier = server.Setting.GameLogicSetting.PpModifier;
break;
}

amount = (uint)(amount * modifier);

if (expPoint.Type == ExpType.ExperiencePoints)
{
var ntcs = server.ExpManager.AddExp(client, client.Character, expPoint.Reward, RewardSource.Quest, quest.QuestType, connectionIn);
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, expPoint.Reward, RewardSource.Quest, quest.QuestType, connectionIn);
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, expPoint.Reward, type: 1, connectionIn: connectionIn);
var ntc = server.PPManager.AddPlayPoint(client, amount, type: 1, connectionIn: connectionIn);
client.Enqueue(ntc, packets);
}
}
Expand Down
72 changes: 72 additions & 0 deletions Arrowgene.Ddon.Server/GameLogicSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,42 @@ public class GameLogicSetting
/// </summary>
[DataMember(Order = 26)] public bool DisableExpCorrectionForMyPawn { get; set; }

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

/// <summary>
/// Global modifier for pp calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] 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; }

/// <summary>
/// Global modifier for HO calculations to scale up or down.
/// </summary>
[DataMember(Order = 26)] 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; }

/// <summary>
/// Configures the maximum amount of reward box slots.
/// </summary>
[DataMember(Order = 27)] 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; }


/// <summary>
/// Various URLs used by the client.
/// Shared with the login server.
Expand Down Expand Up @@ -249,6 +285,14 @@ public GameLogicSetting()
DefaultMaxBazaarExhibits = 5;
DefaultWarpFavorites = 3;

ExpModifier = 1.0;
PpModifier = 1.0;
BoModifier = 1.0;
HoModifier = 1.0;
JpModifier = 1.0;
RewardBoxMax = 100;
QuestOrderMax = 20;

string urlDomain = $"http://localhost:{52099}";
UrlManual = $"{urlDomain}/manual_nfb/";
UrlShopDetail = $"{urlDomain}/shop/ingame/stone/detail";
Expand Down Expand Up @@ -301,6 +345,14 @@ public GameLogicSetting(GameLogicSetting setting)
DefaultMaxBazaarExhibits = setting.DefaultMaxBazaarExhibits;
DefaultWarpFavorites = setting.DefaultWarpFavorites;

ExpModifier = setting.ExpModifier;
PpModifier = setting.PpModifier;
BoModifier = setting.BoModifier;
HoModifier = setting.HoModifier;
JpModifier = setting.JpModifier;
RewardBoxMax = setting.RewardBoxMax;
QuestOrderMax = setting.QuestOrderMax;

UrlManual = setting.UrlManual;
UrlShopDetail = setting.UrlShopDetail;
UrlShopCounterA = setting.UrlShopCounterA;
Expand Down Expand Up @@ -375,6 +427,26 @@ void OnDeserialized(StreamingContext context)
{
PawnCatchupMultiplier = 1.0;
}
if (ExpModifier < 0)
{
ExpModifier = 1.0;
}
if (PpModifier < 0)
{
PpModifier = 1.0;
}
if (BoModifier < 0)
{
BoModifier = 1.0;
}
if (HoModifier < 0)
{
HoModifier = 1.0;
}
if (JpModifier < 0)
{
JpModifier = 1.0;
}

foreach (var walletMax in DefaultWalletLimits)
{
Expand Down

0 comments on commit d92b0b5

Please sign in to comment.