From d4d8d8177fc1f1bff4888c3ecfa4ff794da61a08 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 7 Jan 2023 20:49:54 +0100 Subject: [PATCH] feat(game): update skills api to allow using skills on self (character) --- .../Apis/NostaleSkillsPacketApi.cs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs b/Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs index aa349ce..56b3320 100644 --- a/Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs +++ b/Core/NosSmooth.Game/Apis/NostaleSkillsPacketApi.cs @@ -20,14 +20,17 @@ namespace NosSmooth.Game.Apis; public class NostaleSkillsPacketApi { private readonly INostaleClient _client; + private readonly Game _game; /// /// Initializes a new instance of the class. /// /// The nostale client. - public NostaleSkillsPacketApi(INostaleClient client) + /// The game. + public NostaleSkillsPacketApi(INostaleClient client, Game game) { _client = client; + _game = game; } /// @@ -68,6 +71,45 @@ public class NostaleSkillsPacketApi ); } + /// + /// Use the given (targetable) skill on character itself. + /// + /// + /// For skills that cannot be targeted on an entity, proceed to UseSkillAt. + /// + /// The cast id of the skill. + /// The x coordinate on the map. (Used for non targeted dashes etc., says where the dash will be to.) + /// The y coordinate on the map. (Used for non targeted dashes etc., says where the dash will be to.) + /// The cancellation token for cancelling the operation. + /// A result that may or may not have succeeded. + public async Task UseSkillOnCharacter + ( + short castId, + short? mapX = default, + short? mapY = default, + CancellationToken ct = default + ) + { + var character = _game.Character; + if (character is null) + { + return new NotInitializedError("Character"); + } + + return await _client.SendPacketAsync + ( + new UseSkillPacket + ( + castId, + EntityType.Player, + character.Id, + mapX, + mapY + ), + ct + ); + } + /// /// Use the given (targetable) skill on specified entity. /// -- 2.48.1