Skip to content

Commit

Permalink
Merge branch 'dev' into feat/net-8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru authored Oct 10, 2023
2 parents 46ade08 + caa1894 commit cd6db1f
Show file tree
Hide file tree
Showing 17 changed files with 381 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ IAttackMobEntry attackMob
)
{
var random = new Rotational<uint>(new uint[RndSize]);

_rndGenForCharacter.Next(random.Array);

var skill = attack.SkillID > 0 ? await _skills.Retrieve(attack.SkillID) : null;
var skillActingID = attack.SkillID;

Expand All @@ -89,15 +92,23 @@ IAttackMobEntry attackMob
: 0;
var weaponType = ItemConstants.GetWeaponType(weapon);
var damagePerMob = attack.Type == AttackType.Shoot
? skillLevel?.BulletCount ?? 1
? Math.Max(skillLevel?.BulletCount ?? 1, skillLevel?.AttackCount ?? 1)
: skillLevel?.AttackCount ?? 1;

damagePerMob = Math.Max((short)1, damagePerMob);

if (attack is { SkillID: 0, AttackActionType: AttackActionType.DualDagger })
damagePerMob = 2;

switch (attack.SkillID)
{
case Skill.SniperStrafe:
var ultimateStrafeSkill = await _skills.Retrieve(Skill.CrossbowmasterUltimateStrafe);
var ultimateStrafeLevel = ultimateStrafeSkill?[stats.SkillLevels[Skill.CrossbowmasterUltimateStrafe]];

_rndGenForCharacter.Next(random.Array);
damagePerMob = ultimateStrafeLevel?.BulletCount ?? damagePerMob;
break;
}

var darkForceSkill = await _skills.Retrieve(Skill.DarkknightDarkForce);
var darkForceLevel = darkForceSkill?[stats.SkillLevels[Skill.DarkknightDarkForce]];
Expand Down Expand Up @@ -317,6 +328,44 @@ Skill.Dual2SlashStorm or
skillDamageR = advancedChargeLevel?.Damage ?? skillDamageR;
break;
}

case Skill.ArcherArrowBlow:
case Skill.ArcherDoubleShot:
{
foreach (var skillID in new List<int>
{
Skill.HunterImproveBasic,
Skill.CrossbowmanImproveBasic,
}.Where(skillID => stats.SkillLevels[skillID] > 0))
{
var archerImproveBasicSkill = await _skills.Retrieve(skillID);
var archerImproveBasicLevel = archerImproveBasicSkill?[stats.SkillLevels[skillID]];

if (archerImproveBasicLevel == null) break;

skillDamageR += attack.SkillID == Skill.ArcherArrowBlow
? archerImproveBasicLevel.X
: archerImproveBasicLevel.Y;
break;
}

break;
}
case Skill.SniperStrafe:
var ultimateStrafeSkill = await _skills.Retrieve(Skill.CrossbowmasterUltimateStrafe);
var ultimateStrafeLevel = ultimateStrafeSkill?[stats.SkillLevels[Skill.CrossbowmasterUltimateStrafe]];

skillDamageR = ultimateStrafeLevel?.Damage ?? skillDamageR;
break;
case Skill.WildhunterFlashRain:
if (i == damagePerMob - 1)
{
var flashRainSkill = await _skills.Retrieve(Skill.WildhunterFlashRain);
var flashRainLevel = flashRainSkill?[stats.SkillLevels[Skill.WildhunterFlashRain]];

skillDamageR = flashRainLevel?.X ?? skillDamageR;
}
break;
}

damage *= skillDamageR / 100d;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
using Edelstein.Common.Gameplay.Constants;
using Edelstein.Protocol.Gameplay.Game.Combat;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Gameplay.Models.Characters.Stats;

namespace Edelstein.Common.Gameplay.Game.Combat.Skills.Normal.Dual;

public class Dual5SkillHandler : Dual4SkillHandler
{
public override int ID => Job.Dual5;

public override Task HandleSkillUse(ISkillContext context, IFieldUser user)
{

switch (context.Skill?.ID)
{
case Skill.Dual5ThornsEffect:
var cr = context.SkillLevel!.X;
var cd = context.SkillLevel!.CDMax;

context.AddTemporaryStat(TemporaryStatType.ThornsEffect, (cr << 8) + cd);
break;
}

return base.HandleSkillUse(context, user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ protected override void WriteData(IPacketWriter writer)
writer.WriteInt(_slideMenuType);
writer.WriteInt(_selected);
writer.WriteString(string.Join(
"\r\n",
_menu.Select(p => "#L" + p.Key + "#" + p.Value + "#l")
string.Empty,
_menu.Select(p => "#" + p.Key + "#" + p.Value)
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Edelstein.Common.Gameplay.Packets;
using Edelstein.Protocol.Gameplay.Game;
using Edelstein.Protocol.Utilities.Packets;
using Microsoft.Extensions.Logging;

namespace Edelstein.Common.Gameplay.Login.Handlers;

public class ClientDumpLogHandler : IPacketHandler<IGameStageUser>
{
private ILogger _logger;

public ClientDumpLogHandler(ILogger<ClientDumpLogHandler> logger) => _logger = logger;

public short Operation => (short)PacketRecvOperations.ClientDumpLog;

public bool Check(IGameStageUser user) => true;
public Task Handle(IGameStageUser user, IPacketReader reader)
{
var callType = reader.ReadShort();
var errorCode = reader.ReadInt();
var backupBufferSize = reader.ReadShort();
var rawSeq = reader.ReadInt();
var type = reader.ReadShort();
var backupBuffer = reader.ReadBytes((short)(backupBufferSize - 6));

_logger.LogWarning(
"Received client dump log of type {Type} with buffer {Buffer}",
(PacketSendOperations)type,
Convert.ToHexString(backupBuffer )
);

return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Edelstein.Common.Gameplay.Packets;
using Edelstein.Common.Utilities.Packets;
using Edelstein.Protocol.Gameplay.Game.Contracts;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Utilities.Packets;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handlers;

public class UserPortableChairSitRequestHandler : AbstractPipedFieldHandler<FieldOnPacketUserPortableChairSitRequest>
{
public UserPortableChairSitRequestHandler(IPipeline<FieldOnPacketUserPortableChairSitRequest> pipeline) : base(pipeline)
{
}

public override short Operation => (short)PacketRecvOperations.UserPortableChairSitRequest;

protected override FieldOnPacketUserPortableChairSitRequest? Serialize(IFieldUser user, IPacketReader reader)
=> new(user, reader.ReadInt());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Edelstein.Common.Gameplay.Packets;
using Edelstein.Protocol.Gameplay.Game.Contracts;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Utilities.Packets;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handlers;

public class UserSitRequestHandler : AbstractPipedFieldHandler<FieldOnPacketUserSitRequest>
{
public UserSitRequestHandler(IPipeline<FieldOnPacketUserSitRequest> pipeline) : base(pipeline)
{
}

public override short Operation => (short)PacketRecvOperations.UserSitRequest;

protected override FieldOnPacketUserSitRequest? Serialize(IFieldUser user, IPacketReader reader)
=> new(user, reader.ReadShort());
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ ICharacter character
public bool IsInstantiated { get; set; }
public bool IsConversing => ActiveConversation != null;
public bool IsDialoguing => ActiveDialogue != null;

public short? ActiveChair { get; private set; }
public int ActivePortableChair { get; private set; }

public bool IsDirectionMode { get; private set; }
public bool IsStandAloneMode { get; private set; }
Expand Down Expand Up @@ -145,8 +148,8 @@ public override IPacket GetEnterFieldPacket()
packet.WriteInt(0);
packet.WriteInt(0);
packet.WriteInt(0);
packet.WriteInt(0);
packet.WriteInt(0);
packet.WriteInt(Stats.CompletedSetItemID);
packet.WriteInt(ActivePortableChair);

packet.WritePoint2D(Position);
packet.WriteByte(Action.Raw);
Expand Down Expand Up @@ -314,6 +317,35 @@ public async Task EndDialogue(Func<IDialogue, Task<bool>>? handleLeave = null)
await (handleLeave?.Invoke(ActiveDialogue) ?? ActiveDialogue.HandleLeave(this));
ActiveDialogue = null;
}

public Task SetActiveChair(short? chairID)
{
ActiveChair = chairID;

var p = new PacketWriter(PacketSendOperations.UserSitResult);

if (chairID != null)
{
p.WriteBool(true);
p.WriteShort(chairID.Value);
}
else
p.WriteBool(false);

return Dispatch(p.Build());
}

public async Task SetActivePortableChair(int templateID)
{
ActivePortableChair = templateID;

var p = new PacketWriter(PacketSendOperations.UserSetActivePortableChair);
p.WriteInt(Character.ID);
p.WriteInt(ActivePortableChair);

if (FieldSplit != null)
await FieldSplit.Dispatch(p.Build(), this);
}

public Task SetDirectionMode(bool enable, int delay = 0)
{
Expand Down
Loading

0 comments on commit cd6db1f

Please sign in to comment.