public void OnStateMode(IWorldClient client, StateModePacket packet) { if (client.Player.Object.StateMode == packet.StateMode) { if (packet.Flag == StateModeBaseMotion.BASEMOTION_CANCEL) { _specialEffectSystem.SetStateModeBaseMotion(client.Player, packet.Flag); client.Player.Delayer.CancelAction(client.Player.Inventory.ItemInUseActionId); client.Player.Inventory.ItemInUseActionId = Guid.Empty; } } }
public void UseBlinkwingItem(IPlayerEntity player, Item blinkwing) { if (player.Object.Level < blinkwing.Data.LimitLevel) { _logger.LogError($"Player {player.Object.Name} cannot use {blinkwing.Data.Name}. Level too low."); _textPacketFactory.SendDefinedText(player, DefineText.TID_GAME_USINGNOTLEVEL); return; } // TODO: Check if player is sit // TODO: Check if player is on Kebaras island // TODO: Check if player is in guild war map TeleportEventArgs teleportEvent; if (blinkwing.Data.ItemKind3 == ItemKind3.TOWNBLINKWING) { IMapRevivalRegion revivalRegion = player.Object.CurrentMap.GetNearRevivalRegion(player.Object.Position); if (revivalRegion == null) { _logger.LogError($"Cannot find any revival region for map '{player.Object.CurrentMap.Name}'."); return; } if (player.Object.MapId != revivalRegion.MapId) { IMapInstance revivalMap = _mapManager.GetMap(revivalRegion.MapId); if (revivalMap == null) { _logger.LogError($"Cannot find revival map with id '{revivalRegion.MapId}'."); // TODO: disconnect client //player.Connection.Server.DisconnectClient(player.Connection.Id); return; } revivalRegion = revivalMap.GetRevivalRegion(revivalRegion.Key); } teleportEvent = new TeleportEventArgs(revivalRegion.MapId, revivalRegion.RevivalPosition.X, revivalRegion.RevivalPosition.Z, revivalRegion.RevivalPosition.Y); } else { teleportEvent = new TeleportEventArgs(blinkwing.Data.WeaponTypeId, // Map Id blinkwing.Data.ItemAtkOrder1, // X blinkwing.Data.ItemAtkOrder3, // Z blinkwing.Data.ItemAtkOrder2, // Y blinkwing.Data.ItemAtkOrder4); // Angle } player.Inventory.ItemInUseActionId = player.Delayer.DelayAction(TimeSpan.FromMilliseconds(blinkwing.Data.SkillReadyType), () => { _teleportSystem.Teleport(player, teleportEvent.MapId, teleportEvent.PositionX, teleportEvent.PositionY, teleportEvent.PositionZ, teleportEvent.Angle); _specialEffectSystem.SetStateModeBaseMotion(player, StateModeBaseMotion.BASEMOTION_OFF); player.Inventory.ItemInUseActionId = Guid.Empty; DecreaseItem(player, blinkwing); }); _specialEffectSystem.SetStateModeBaseMotion(player, StateModeBaseMotion.BASEMOTION_ON, blinkwing); }