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

Update Operand enum values, RegistryOp method #45

Merged
merged 2 commits into from
Jun 29, 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
2 changes: 1 addition & 1 deletion UdpHosts/GameServer/Data/CharacterInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public void EquipVisualBySdbId(uint loadoutId, LoadoutVisualType visual, Loadout
if (sdb_id != 0)
{
// Update Visuals
_loadouts[(uint)loadoutId].LoadoutConfigs[0].Visuals = _loadouts[(uint)loadoutId].LoadoutConfigs[0].Visuals.Append(new LoadoutConfig_Visual() { ItemSdbId = sdb_id, VisualType = visual, Data1 = 0, Data2 = 0, Transform = []}).ToArray();
_loadouts[(uint)loadoutId].LoadoutConfigs[0].Visuals = _loadouts[(uint)loadoutId].LoadoutConfigs[0].Visuals.Append(new LoadoutConfig_Visual() { ItemSdbId = sdb_id, VisualType = visual, Data1 = 0, Data2 = 0, Transform = Array.Empty<float>() }).ToArray();
var item = _items.First(e => e.Value.SdbId == sdb_id).Value;
}

Expand Down
17 changes: 11 additions & 6 deletions UdpHosts/GameServer/Enums/Operand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

namespace GameServer.Enums;

[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "TODO")]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "Based on FUN_00bc1130")]
public enum Operand : byte
{
// Add and multiply appear twice in a switch inside client
ASSIGN = 0,
ADDITIVE = 1,
MULTIPLICATIVE = 2,
PERK_DAMAGE_SCALAR = 3, // Uncertain
DIVIDE_FIRST_BY_SECOND = 4, // Uncertain
DIVIDE_SECOND_BY_FIRST = 5, // Uncertain
ADD = 1,
MULTIPLY = 2,
EXPONENTIATE = 3,
SUBTRACT = 4,
DIVIDE = 5,
ADD_ALT = 6,
MULTIPLY_ALT = 7,
MINIMUM = 8,
MAXIMUM = 9,
}
6 changes: 6 additions & 0 deletions UdpHosts/GameServer/StaticDB/Loaders/StaticDBLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public Dictionary<uint, ImpactApplyEffectCommandDef> LoadImpactApplyEffectComman
.ToDictionary(row => row.Id);
}

public Dictionary<uint, ImpactToggleEffectCommandDef> LoadImpactToggleEffectCommandDef()
{
return LoadStaticDB<ImpactToggleEffectCommandDef>("apt::ImpactToggleEffectCommandDef")
.ToDictionary(row => row.Id);
}

public Dictionary<uint, ConditionalBranchCommandDef> LoadConditionalBranchCommandDef()
{
return LoadStaticDB<ConditionalBranchCommandDef>("apt::ConditionalBranchCommandDef")
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/StaticDB/SDBInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public static void Init(StaticDB instance)
CommandType = loader.LoadCommandType();
AbilityData = loader.LoadAbilityData();
ImpactApplyEffectCommandDef = loader.LoadImpactApplyEffectCommandDef();
ImpactToggleEffectCommandDef = loader.LoadImpactToggleEffectCommandDef();
WhileLoopCommandDef = loader.LoadWhileLoopCommandDef();
LogicNegateCommandDef = loader.LoadLogicNegateCommandDef();
LogicOrCommandDef = loader.LoadLogicOrCommandDef();
Expand Down
32 changes: 20 additions & 12 deletions UdpHosts/GameServer/Systems/Aptitude/AbilitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,27 @@ public static float RegistryOp(float first, float second, Operand op)
{
case Operand.ASSIGN:
return second;
case Operand.ADDITIVE:
return first + second;
case Operand.MULTIPLICATIVE:
return first * second;
case Operand.PERK_DAMAGE_SCALAR:
Console.WriteLine($"Uncertain RegistryOp {op}");
return first * second; // TODO: Uncertain
case Operand.DIVIDE_FIRST_BY_SECOND:
Console.WriteLine($"Uncertain RegistryOp {op}");
return first / second;
case Operand.DIVIDE_SECOND_BY_FIRST:
Console.WriteLine($"Uncertain RegistryOp {op}");
case Operand.ADD:
case Operand.ADD_ALT:
return second + first;
case Operand.MULTIPLY:
case Operand.MULTIPLY_ALT:
return second * first;
case Operand.EXPONENTIATE:
Console.WriteLine($"Uncertain RegistryOp {op}. {second} ^ {first} = {(float)Math.Pow(second, first)}");
return (float)Math.Pow(second, first);
case Operand.SUBTRACT:
Console.WriteLine($"Uncertain RegistryOp {op}. {second} - {first} = {second - first}");
return second - first;
case Operand.DIVIDE:
Console.WriteLine($"Uncertain RegistryOp {op}. {second} / {first} = {second / first}");
return second / first;
case Operand.MINIMUM:
Console.WriteLine($"Uncertain RegistryOp {op}. Min({second}, {first}) = {((first <= second) ? first : second)}");
return (first <= second) ? first : second;
case Operand.MAXIMUM:
Console.WriteLine($"Uncertain RegistryOp {op}. Max({second}, {first}) = {((first >= second) ? first : second)}");
return (first >= second) ? first : second;
default:
Console.WriteLine($"Unknown RegistryOp {op}");
return second;
Expand Down
Loading