From 0a01c60b3ab805fd9f6bee6d8c46e30d718a5ef5 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Thu, 4 May 2023 10:11:36 -0700 Subject: [PATCH] Prevent sitting while otherwise acting. Use map warp backoff when a refresh packet is received. --- EOLib/PacketHandlers/Refresh/RefreshReplyHandler.cs | 5 +++-- EndlessClient/Controllers/FunctionKeyController.cs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/EOLib/PacketHandlers/Refresh/RefreshReplyHandler.cs b/EOLib/PacketHandlers/Refresh/RefreshReplyHandler.cs index 2db88b4e3..23f99dbda 100644 --- a/EOLib/PacketHandlers/Refresh/RefreshReplyHandler.cs +++ b/EOLib/PacketHandlers/Refresh/RefreshReplyHandler.cs @@ -52,12 +52,11 @@ public override bool HandlePacket(IPacket packet) .WithMapY(updatedMainCharacter.RenderProperties.MapY); var withoutMainCharacter = data.Characters.Where(x => !IDMatches(x)); - data = data.WithCharacters(withoutMainCharacter.ToList()); _characterRepository.MainCharacter = _characterRepository.MainCharacter .WithRenderProperties(updatedRenderProperties); - _currentMapStateRepository.Characters = data.Characters.ToDictionary(k => k.ID, v => v); + _currentMapStateRepository.Characters = withoutMainCharacter.ToDictionary(k => k.ID, v => v); _currentMapStateRepository.NPCs = new HashSet(data.NPCs); _currentMapStateRepository.MapItems = new HashSet(data.Items); @@ -65,6 +64,8 @@ public override bool HandlePacket(IPacket packet) _currentMapStateRepository.PendingDoors.Clear(); _currentMapStateRepository.VisibleSpikeTraps.Clear(); + _currentMapStateRepository.MapWarpTime = Optional.Option.Some(System.DateTime.Now.AddMilliseconds(-100)); + foreach (var notifier in _mapChangedNotifiers) notifier.NotifyMapChanged(differentMapID: false, warpAnimation: WarpAnimation.None); diff --git a/EndlessClient/Controllers/FunctionKeyController.cs b/EndlessClient/Controllers/FunctionKeyController.cs index 4d2335e18..ca5d339f3 100644 --- a/EndlessClient/Controllers/FunctionKeyController.cs +++ b/EndlessClient/Controllers/FunctionKeyController.cs @@ -93,6 +93,9 @@ public bool SelectSpell(int index, bool isAlternate) public bool Sit() { + if (_characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Walking, CharacterActionState.Attacking, CharacterActionState.SpellCast)) + return false; + _characterActions.ToggleSit(); return true; }