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

enhance: Add new global modifiers #657

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
31 changes: 24 additions & 7 deletions Arrowgene.Ddon.GameServer/Characters/ExpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Drawing;
using System.Linq;

namespace Arrowgene.Ddon.GameServer.Characters
Expand Down Expand Up @@ -509,7 +510,7 @@ public PacketQueue AddExp(GameClient client, CharacterCommon characterToAddExpTo

if (client.GameMode == GameMode.Normal)
{
addJobPoint += (uint)(LEVEL_UP_JOB_POINTS_EARNED[targetLevel] * _Server.Setting.GameLogicSetting.JpModifier);
addJobPoint += GetScaledPointAmount(RewardSource.None, ExpType.JobPoints, LEVEL_UP_JOB_POINTS_EARNED[targetLevel]);
}
}

Expand Down Expand Up @@ -899,16 +900,32 @@ private double CalculateTargetLvMultiplier(GameMode gameMode, PartyGroup party,
return multiplier;
}

private double ModifierBasedOnSource(RewardSource source)
public uint GetScaledPointAmount(RewardSource source, ExpType type, uint amount)
{
return source == RewardSource.Enemy ? _GameSettings.EnemyExpModifier : _GameSettings.QuestExpModifier;
double modifier = 1.0;
switch (type)
{
case ExpType.ExperiencePoints:
modifier = (source == RewardSource.Enemy) ? _GameSettings.EnemyExpModifier.Value : _GameSettings.QuestExpModifier.Value;
break;
case ExpType.JobPoints:
modifier = _GameSettings.JpModifier.Value;
break;
case ExpType.PlayPoints:
modifier = _GameSettings.PpModifier.Value;
break;
default:
modifier = 1.0;
break;
}
return (uint)(amount * modifier);
}

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

double multiplier = 1.0;
Expand All @@ -923,7 +940,7 @@ public uint GetAdjustedExp(GameMode gameMode, RewardSource source, PartyGroup pa
// Currently no adjustments
}

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

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

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

return (uint)(multiplier * baseExpAmount * ModifierBasedOnSource(source));
return (uint)(multiplier * baseExpAmount);
}
}
}
6 changes: 4 additions & 2 deletions Arrowgene.Ddon.GameServer/Characters/QuestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ private QuestManager()
private static Dictionary<uint, HashSet<uint>> gTutorialQuests = new Dictionary<uint, HashSet<uint>>();
private static Dictionary<QuestAreaId, HashSet<QuestId>> gWorldQuests = new Dictionary<QuestAreaId, HashSet<QuestId>>();

public static void LoadQuests(AssetRepository assetRepository)
public static void LoadQuests(DdonGameServer server)
{
var assetRepository = server.AssetRepository;

// TODO: Quests should probably operate on the QuestScheduleID instead of QuestId so the global list can still contain all quests
// TODO: Then quests can be distributed to different lists for faster lookup (like world by area id or personal by stageno)
foreach (var questAsset in assetRepository.QuestAssets.Quests)
{
gQuests[questAsset.QuestScheduleId] = GenericQuest.FromAsset(questAsset);
gQuests[questAsset.QuestScheduleId] = GenericQuest.FromAsset(server, questAsset);

var quest = gQuests[questAsset.QuestScheduleId];
if (!quest.Enabled)
Expand Down
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.GameServer/Characters/RewardManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public bool AddQuestRewards(GameClient client, Quest quest, DbConnection? connec
var rewards = quest.GenerateBoxRewards();

var currentRewards = GetQuestBoxRewards(client, connectionIn);
if (currentRewards.Count >= _Server.Setting.GameLogicSetting.RewardBoxMax)
if (currentRewards.Count >= _Server.Setting.GameLogicSetting.RewardBoxMax.Value)
{
return false;
}
Expand Down
25 changes: 25 additions & 0 deletions Arrowgene.Ddon.GameServer/Characters/WalletManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,30 @@ public uint GetWalletAmount(Character Character, WalletType Type)
CDataWalletPoint Wallet = Character.WalletPointList.Where(wp => wp.Type == Type).Single();
return Wallet.Value;
}

public uint GetScaledWalletAmount(WalletType type, uint amount)
{
double modifier = 1.0;
switch (type)
{
case WalletType.Gold:
modifier = Server.Setting.GameLogicSetting.GoldModifier.Value;
break;
case WalletType.RiftPoints:
modifier = Server.Setting.GameLogicSetting.RiftModifier.Value;
break;
case WalletType.BloodOrbs:
modifier = Server.Setting.GameLogicSetting.BoModifier.Value;
break;
case WalletType.HighOrbs:
modifier = Server.Setting.GameLogicSetting.HoModifier.Value;
break;
default:
modifier = 1.0;
break;
}

return (uint)(amount * modifier);
}
}
}
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.GameServer/DdonGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public DdonGameServer(GameServerSetting setting, IDatabase database, AssetReposi

public override void Start()
{
QuestManager.LoadQuests(this.AssetRepository);
QuestManager.LoadQuests(this);
GpCourseManager.EvaluateCourses();
LoadChatHandler();
LoadPacketHandler();
Expand Down
6 changes: 3 additions & 3 deletions Arrowgene.Ddon.GameServer/Handler/InstanceEnemyKillHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,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 = (uint)(enemyKilled.GetDroppedPlayPoints() * _gameServer.Setting.GameLogicSetting.PpModifier);
uint calcPP = _gameServer.ExpManager.GetScaledPointAmount(RewardSource.Enemy, ExpType.PlayPoints, enemyKilled.GetDroppedPlayPoints());

foreach (PartyMember member in client.Party.Members)
{
Expand Down Expand Up @@ -209,7 +209,7 @@ public override S2CInstanceEnemyKillRes Handle(GameClient client, C2SInstanceEne
if (enemyKilled.BloodOrbs > 0)
{
// Drop BO
uint gainedBo = (uint) (enemyKilled.BloodOrbs * _gameServer.Setting.GameLogicSetting.BoModifier);
uint gainedBo = (uint) (enemyKilled.BloodOrbs * _gameServer.Setting.GameLogicSetting.BoModifier.Value);
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);
Expand All @@ -218,7 +218,7 @@ public override S2CInstanceEnemyKillRes Handle(GameClient client, C2SInstanceEne
if (enemyKilled.HighOrbs > 0)
{
// Drop HO
uint gainedHo = (uint)(enemyKilled.HighOrbs * _gameServer.Setting.GameLogicSetting.HoModifier);
uint gainedHo = (uint)(enemyKilled.HighOrbs * _gameServer.Setting.GameLogicSetting.HoModifier.Value);
CDataUpdateWalletPoint hoUpdateWalletPoint = _gameServer.WalletManager.AddToWallet(memberClient.Character, WalletType.HighOrbs, gainedHo, connectionIn: connectionIn);
updateCharacterItemNtc.UpdateWalletList.Add(hoUpdateWalletPoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,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;
ntc.QuestDefine.OrderMaxNum = Server.Setting.GameLogicSetting.QuestOrderMax.Value;
ntc.QuestDefine.RewardBoxMaxNum = Server.Setting.GameLogicSetting.RewardBoxMax.Value;

// 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
8 changes: 5 additions & 3 deletions Arrowgene.Ddon.GameServer/Quests/GenericQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GenericQuest : Quest
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(GenericQuest));

public static GenericQuest FromAsset(QuestAssetData questAsset)
public static GenericQuest FromAsset(DdonGameServer server, QuestAssetData questAsset)
{
var quest = new GenericQuest(questAsset.QuestId, questAsset.QuestScheduleId, questAsset.Type, questAsset.Discoverable);

Expand All @@ -40,19 +40,21 @@ public static GenericQuest FromAsset(QuestAssetData questAsset)

foreach (var pointReward in questAsset.PointRewards)
{
var reward = server.ExpManager.GetScaledPointAmount(RewardSource.Quest, pointReward.ExpType, pointReward.ExpReward);
quest.ExpRewards.Add(new CDataQuestExp()
{
Type = pointReward.ExpType,
Reward = pointReward.ExpReward
Reward = reward
});
}

foreach (var walletReward in questAsset.RewardCurrency)
{
var amount = server.WalletManager.GetScaledWalletAmount(walletReward.WalletType, walletReward.Amount);
quest.WalletRewards.Add(new CDataWalletPoint()
{
Type = walletReward.WalletType,
Value = walletReward.Amount
Value = amount
});
}

Expand Down
7 changes: 0 additions & 7 deletions Arrowgene.Ddon.GameServer/Quests/QuestStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,11 @@ public QuestProcessState GetProcessState(uint questScheduleId, ushort processNo)
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;
}
Expand Down
Loading
Loading