Skip to content

Commit

Permalink
FIX: removed extra delay before switching to atkwait
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Nov 16, 2024
1 parent 85910f8 commit a1a1ebb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions l2-unity-todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Nature renderer for deco layer

DONE

FIX: removed extra delay before switching to atkwait
FIX: wait for atk animation to fully play before idling
FIX: wrong play of run animation when attacking a dead entity
FIX: can't attack another target if current attack was not canceled or entity still alive
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine;

public class HumanoidStateAction : HumanoidStateBase
{
Expand Down Expand Up @@ -34,14 +35,11 @@ protected bool ShouldAtkWait()

protected bool DidAttackTimeout()
{
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();

// Check if AtkOnce was called, otherwise switch to AtkWait state
// Add the attack duration and the last auto attack packet timestamp
if (now > ((long)_referenceHolder.AnimationController.PAtkSpd) + _referenceHolder.Combat.CombatTimestamp + 150) //150 for acceptable ping delay
float now = Time.time;
if (now > _referenceHolder.Combat.AttackEndTime) // + 150) //50 for acceptable ping delay
{
return true;
// Debug.LogWarning("Should ATK WAIT! (StopAttack)");
return true;
}

return false;
Expand Down
10 changes: 4 additions & 6 deletions l2-unity/Assets/Scripts/Animation/Monster/MonsterStateAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine;

public class MonsterStateAction : MonsterStateBase
{
Expand Down Expand Up @@ -33,14 +34,11 @@ protected bool ShouldAtkWait()

protected bool DidAttackTimeout()
{
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();

// Check if AtkOnce was called, otherwise switch to AtkWait state
// Add the attack duration and the last auto attack packet timestamp
if (now > ((long)_referenceHolder.AnimationController.PAtkSpd) + _referenceHolder.Combat.CombatTimestamp + 150) //150 for acceptable ping delay
float now = Time.time;
if (now > _referenceHolder.Combat.AttackEndTime) // + 150) //50 for acceptable ping delay
{
return true;
// Debug.LogWarning("Should ATK WAIT! (StopAttack)");
return true;
}

return false;
Expand Down
5 changes: 3 additions & 2 deletions l2-unity/Assets/Scripts/Animation/Player/PlayerStateAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine;

public class PlayerStateAction : PlayerStateBase
{
Expand Down Expand Up @@ -103,8 +104,8 @@ protected bool ShouldStand()

protected bool DidAttackTimeout()
{
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
if (now > ((long)_referenceHolder.AnimationController.PAtkSpd) + _referenceHolder.Combat.CombatTimestamp + 150) //50 for acceptable ping delay
float now = Time.time;
if (now > _referenceHolder.Combat.AttackEndTime) // + 150) //50 for acceptable ping delay
{
// Debug.LogWarning("Should ATK WAIT! (StopAttack)");
return true;
Expand Down

0 comments on commit a1a1ebb

Please sign in to comment.