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(game): /set job 0 #270

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 src/Libraries/Game.Commands/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public async Task Handle(IGameConnection connection, string chatline)
connection.Player.SendChatMessage("The following commands are available:");
foreach (var handler in _commandHandlers)
{
connection.Player.SendChatMessage($"- /{handler.Key}");
connection.Player.SendChatInfo($"- /{handler.Key}");
}
}
else
Expand Down
9 changes: 8 additions & 1 deletion src/Libraries/Game.Server/Commands/SetJobCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommandLine;
using QuantumCore.API.Game;
using QuantumCore.Game.Skills;

namespace QuantumCore.Game.Commands;

Expand All @@ -8,6 +9,12 @@ public class SetJobCommand : ICommandHandler<SetJobCommandOptions>
{
public Task ExecuteAsync(CommandContext<SetJobCommandOptions> context)
{
if (context.Arguments.Job is 0 or > PlayerSkills.SkillGroupMaxNum)
{
context.Player.SendChatInfo("Job not valid");
return Task.CompletedTask;
}

var player = context.Player;
var job = context.Arguments.Job;

Expand All @@ -20,4 +27,4 @@ public Task ExecuteAsync(CommandContext<SetJobCommandOptions> context)
public class SetJobCommandOptions
{
[Value(0, Required = true)] public byte Job { get; set; } = 0;
}
}
91 changes: 26 additions & 65 deletions src/Libraries/Game.Server/Skills/PlayerSkills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private readonly ConcurrentDictionary<ESkillIndexes, Skill>
private const int SkillMaxLevel = 40;
private const int SkillCount = 6;
private const int JobMaxNum = 4;
private const int SkillGroupMaxNum = 2;
public const int SkillGroupMaxNum = 2;
private const int MinimumLevel = 5;
private const int MinimumLevelSubSkills = 10;
private const int MinimumSkillLevelUpgrade = 17;
Expand All @@ -39,77 +39,46 @@ private readonly ConcurrentDictionary<ESkillIndexes, Skill>
// Warrior
{
{
ESkillIndexes.ThreeWayCut,
ESkillIndexes.SwordSpin,
ESkillIndexes.BerserkerFury,
ESkillIndexes.AuraOfTheSword,
ESkillIndexes.Dash,
ESkillIndexes.Life
ESkillIndexes.ThreeWayCut, ESkillIndexes.SwordSpin, ESkillIndexes.BerserkerFury,
ESkillIndexes.AuraOfTheSword, ESkillIndexes.Dash, ESkillIndexes.Life
},
{
ESkillIndexes.Shockwave,
ESkillIndexes.Bash,
ESkillIndexes.Stump,
ESkillIndexes.StrongBody,
ESkillIndexes.SwordStrike,
ESkillIndexes.SwordOrb
ESkillIndexes.Shockwave, ESkillIndexes.Bash, ESkillIndexes.Stump, ESkillIndexes.StrongBody,
ESkillIndexes.SwordStrike, ESkillIndexes.SwordOrb
}
},
// Ninja
{
{
ESkillIndexes.Ambush,
ESkillIndexes.FastAttack,
ESkillIndexes.RollingDagger,
ESkillIndexes.Stealth,
ESkillIndexes.PoisonousCloud,
ESkillIndexes.InsidiousPoison
ESkillIndexes.Ambush, ESkillIndexes.FastAttack, ESkillIndexes.RollingDagger, ESkillIndexes.Stealth,
ESkillIndexes.PoisonousCloud, ESkillIndexes.InsidiousPoison
},
{
ESkillIndexes.RepetitiveShot,
ESkillIndexes.ArrowShower,
ESkillIndexes.FireArrow,
ESkillIndexes.RepetitiveShot, ESkillIndexes.ArrowShower, ESkillIndexes.FireArrow,
ESkillIndexes.FeatherWalk,
ESkillIndexes.PoisonArrow,
ESkillIndexes.Spark
ESkillIndexes.PoisonArrow, ESkillIndexes.Spark
}
},
// Sura
{
{
ESkillIndexes.FingerStrike,
ESkillIndexes.DragonSwirl,
ESkillIndexes.EnchantedBlade,
ESkillIndexes.Fear,
ESkillIndexes.EnchantedArmor,
ESkillIndexes.Dispel
ESkillIndexes.FingerStrike, ESkillIndexes.DragonSwirl, ESkillIndexes.EnchantedBlade, ESkillIndexes.Fear,
ESkillIndexes.EnchantedArmor, ESkillIndexes.Dispel
},
{
ESkillIndexes.DarkStrike,
ESkillIndexes.FlameStrike,
ESkillIndexes.FlameSpirit,
ESkillIndexes.DarkProtection,
ESkillIndexes.SpiritStrike,
ESkillIndexes.DarkOrb
ESkillIndexes.DarkStrike, ESkillIndexes.FlameStrike, ESkillIndexes.FlameSpirit,
ESkillIndexes.DarkProtection, ESkillIndexes.SpiritStrike, ESkillIndexes.DarkOrb
}
},
// Shaman
{
{
ESkillIndexes.FlyingTalisman,
ESkillIndexes.ShootingDragon,
ESkillIndexes.DragonRoar,
ESkillIndexes.Blessing,
ESkillIndexes.Reflect,
ESkillIndexes.DragonAid
ESkillIndexes.FlyingTalisman, ESkillIndexes.ShootingDragon, ESkillIndexes.DragonRoar,
ESkillIndexes.Blessing, ESkillIndexes.Reflect, ESkillIndexes.DragonAid
},
{
ESkillIndexes.LightningThrow,
ESkillIndexes.SummonLightning,
ESkillIndexes.LightningClaw,
ESkillIndexes.Cure,
ESkillIndexes.Swiftness,
ESkillIndexes.AttackUp
ESkillIndexes.LightningThrow, ESkillIndexes.SummonLightning, ESkillIndexes.LightningClaw,
ESkillIndexes.Cure, ESkillIndexes.Swiftness, ESkillIndexes.AttackUp
}
}
};
Expand Down Expand Up @@ -183,10 +152,7 @@ public void SetSkillGroup(byte skillGroup)

AssignDefaultActiveSkills();

_player.Connection.Send(new ChangeSkillGroup
{
SkillGroup = skillGroup
});
_player.Connection.Send(new ChangeSkillGroup {SkillGroup = skillGroup});
}

public void ClearSkills()
Expand Down Expand Up @@ -272,7 +238,7 @@ public void SetLevel(ESkillIndexes skillId, byte level)

if (!_skills.TryGetValue(skillId, out var skill)) return;

skill.Level = Math.Min((byte) 40, level);
skill.Level = Math.Min((byte)40, level);

skill.MasterType = level switch
{
Expand Down Expand Up @@ -382,14 +348,14 @@ public void SkillUp(ESkillIndexes skillId, ESkillLevelMethod method = ESkillLeve
return;
}

if ((int) idx == 0) return;
if ((int)idx == 0) return;

if (_player.GetPoint(idx) < 1) return;

_player.AddPoint(idx, -1);
}

SetLevel(proto.Id, (byte) (GetSkillLevel(proto.Id) + 1));
SetLevel(proto.Id, (byte)(GetSkillLevel(proto.Id) + 1));

if (proto.Type != ESkillCategoryType.PassiveSkills)
{
Expand Down Expand Up @@ -453,12 +419,12 @@ private bool IsLearnableSkill(ESkillIndexes skillId)
if (proto.Type == ESkillCategoryType.HorseSkills)
{
return skillId != ESkillIndexes.HorseWildAttackRange ||
_player.Player.PlayerClass == (int) EPlayerClass.Ninja;
_player.Player.PlayerClass == (int)EPlayerClass.Ninja;
}

if (_player.Player.SkillGroup == 0) return false;

return (int) proto.Type - 1 == _player.Player.PlayerClass;
return (int)proto.Type - 1 == _player.Player.PlayerClass;
}

private int GetSkillLevel(ESkillIndexes skillId)
Expand Down Expand Up @@ -626,19 +592,14 @@ private void SendSkillLevelsPacket()
var levels = new SkillLevels();
for (var i = 0; i < SkillMaxNum; i++)
{
levels.Skills[i] = new PlayerSkill
{
Level = 0,
MasterType = ESkillMasterType.Normal,
NextReadTime = 0
};
levels.Skills[i] = new PlayerSkill {Level = 0, MasterType = ESkillMasterType.Normal, NextReadTime = 0};
}

for (var i = 0; i < _skills.Count; i++)
{
var skill = _skills.ElementAt(i);

levels.Skills[(uint) skill.Key] = new PlayerSkill
levels.Skills[(uint)skill.Key] = new PlayerSkill
{
Level = skill.Value.Level,
MasterType = skill.Value.MasterType,
Expand Down Expand Up @@ -681,4 +642,4 @@ private void AssignDefaultPassiveSkills()
};
}
}
}
}
Loading