Skip to content

Commit

Permalink
FIX: can't attack another target if current attack was not canceled o…
Browse files Browse the repository at this point in the history
…r entity still alive
  • Loading branch information
shnok committed Nov 15, 2024
1 parent d51d2d4 commit 8b7b1b7
Show file tree
Hide file tree
Showing 26 changed files with 309 additions and 260 deletions.
6 changes: 5 additions & 1 deletion l2-unity-todo.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TODO (priority from top to bottom)

FIX: be able to attack another target without moving
FIX: player animation glitch when killing an entity (wait for atk animation to fully play before idling)
FIX: attacking multiple time a dead entity shouldnt trigger the running animation

FIX: Desync in user positions

handle AOE hits
Expand All @@ -21,6 +23,8 @@ Nature renderer for deco layer

DONE

FIX: should be able to attack another target without moving if first entity still alive
when attacking a dead entity, run to interact range
FIX: hide nameplates when leaving char select
chat window message limit, scroll limit, message filtering, message history
FIX: Bug in anim when no weapon equiped
Expand Down
216 changes: 108 additions & 108 deletions l2-unity/Assets/Resources/Scenes/Menu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -118,76 +118,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!21 &183154704
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Override
m_Shader: {fileID: 4800000, guid: a3a3bc8785681554d9558e2ea68f100e, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _AdvancedCat: 1
- _Banner: 1
- _DirectionalCat: 1
- _DirectionalFalloff: 2
- _DirectionalIntensity: 1
- _FarDistanceHeight: 0
- _FarDistanceOffset: 0
- _FogAxisMode: 1
- _FogCameraMode: 0
- _FogCat: 1
- _FogColorDuo: 1
- _FogDistanceEnd: 100
- _FogDistanceFalloff: 2
- _FogDistanceStart: 0
- _FogHeightEnd: 100
- _FogHeightFalloff: 2
- _FogHeightStart: 0
- _FogIntensity: 1
- _FogLayersMode: 0
- _IsHeightFogPreset: 1
- _IsHeightFogShader: 1
- _JitterIntensity: 1
- _NoiseCat: 1
- _NoiseDistanceEnd: 50
- _NoiseIntensity: 1
- _NoiseMax: 1
- _NoiseMin: 0
- _NoiseModeBlend: 1
- _NoiseScale: 30
- _SkyboxCat: 1
- _SkyboxFogBottom: 0
- _SkyboxFogFalloff: 1
- _SkyboxFogFill: 1
- _SkyboxFogHeight: 1
- _SkyboxFogIntensity: 1
- _SkyboxFogOffset: 0
m_Colors:
- _DirectionalColor: {r: 1, g: 0.7793103, b: 0.5, a: 1}
- _DirectionalDir: {r: 0, g: 0, b: 0, a: 0}
- _FogAxisOption: {r: 0, g: 0, b: 0, a: 0}
- _FogColorEnd: {r: 0.8862745, g: 1.443137, b: 2, a: 1}
- _FogColorStart: {r: 0.4411765, g: 0.722515, b: 1, a: 1}
- _NoiseSpeed: {r: 0.5, g: 0, b: 0.5, a: 0}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1 &264437453
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -235,42 +165,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
_lastLoop: 489.67508
_loopDelay: 1
--- !u!21 &316664116
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Height Fog Global
m_Shader: {fileID: 4800000, guid: 3a7ef1b66bafb7a448a880ef76d2e6e6, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _AdvancedCat: 1
- _Banner: 1
- _DirectionalCat: 1
- _FogCat: 1
- _HeightFogGlobal: 1
- _IsHeightFogShader: 1
- _NoiseCat: 1
- _SkyboxCat: 1
m_Colors: []
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1 &413261805
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -936,7 +830,7 @@ PrefabInstance:
- target: {fileID: 14083907825353274, guid: 8742fc349ac4f354d9cfb98ebb79a0e3, type: 3}
propertyPath: 'm_Materials.Array.data[0]'
value:
objectReference: {fileID: 316664116}
objectReference: {fileID: 1740309145}
- target: {fileID: 2134954596300280144, guid: 8742fc349ac4f354d9cfb98ebb79a0e3, type: 3}
propertyPath: m_Name
value: Height Fog Global
Expand Down Expand Up @@ -1327,6 +1221,76 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6c0b294c4f11da043a50af17e2d967fa, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!21 &1562224740
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Override
m_Shader: {fileID: 4800000, guid: a3a3bc8785681554d9558e2ea68f100e, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _AdvancedCat: 1
- _Banner: 1
- _DirectionalCat: 1
- _DirectionalFalloff: 2
- _DirectionalIntensity: 1
- _FarDistanceHeight: 0
- _FarDistanceOffset: 0
- _FogAxisMode: 1
- _FogCameraMode: 0
- _FogCat: 1
- _FogColorDuo: 1
- _FogDistanceEnd: 100
- _FogDistanceFalloff: 2
- _FogDistanceStart: 0
- _FogHeightEnd: 100
- _FogHeightFalloff: 2
- _FogHeightStart: 0
- _FogIntensity: 1
- _FogLayersMode: 0
- _IsHeightFogPreset: 1
- _IsHeightFogShader: 1
- _JitterIntensity: 1
- _NoiseCat: 1
- _NoiseDistanceEnd: 50
- _NoiseIntensity: 1
- _NoiseMax: 1
- _NoiseMin: 0
- _NoiseModeBlend: 1
- _NoiseScale: 30
- _SkyboxCat: 1
- _SkyboxFogBottom: 0
- _SkyboxFogFalloff: 1
- _SkyboxFogFill: 1
- _SkyboxFogHeight: 1
- _SkyboxFogIntensity: 1
- _SkyboxFogOffset: 0
m_Colors:
- _DirectionalColor: {r: 1, g: 0.7793103, b: 0.5, a: 1}
- _DirectionalDir: {r: 0, g: 0, b: 0, a: 0}
- _FogAxisOption: {r: 0, g: 0, b: 0, a: 0}
- _FogColorEnd: {r: 0.8862745, g: 1.443137, b: 2, a: 1}
- _FogColorStart: {r: 0.4411765, g: 0.722515, b: 1, a: 1}
- _NoiseSpeed: {r: 0.5, g: 0, b: 0.5, a: 0}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1 &1592191233
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1400,6 +1364,42 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!21 &1740309145
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Height Fog Global
m_Shader: {fileID: 4800000, guid: 3a7ef1b66bafb7a448a880ef76d2e6e6, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _AdvancedCat: 1
- _Banner: 1
- _DirectionalCat: 1
- _FogCat: 1
- _HeightFogGlobal: 1
- _IsHeightFogShader: 1
- _NoiseCat: 1
- _SkyboxCat: 1
m_Colors: []
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1001 &417367616115605176
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1488,7 +1488,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2808076256991555282, guid: babd2d27777f4774581e9efa23af7856, type: 3}
propertyPath: _logReceivedPackets
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2808076256991555282, guid: babd2d27777f4774581e9efa23af7856, type: 3}
propertyPath: _positionSyncThreshold
Expand Down
4 changes: 2 additions & 2 deletions l2-unity/Assets/Scripts/Animation/Player/PlayerStateAtk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInf
if (_referenceHolder.Gear.WeaponType == WeaponType.bow)
{
// Lock on the target while attacking
PlayerController.Instance.StartLookAt(TargetManager.Instance.AttackTarget?.Data.ObjectTransform);
PlayerController.Instance.StartLookAt(TargetManager.Instance.AttackTarget?.transform);
}
return;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ private void ManageArrow(AnimatorStateInfo stateInfo)

if (normalizedRatio >= 1f)
{
Debug.LogWarning("Reset atk animation state");
// Debug.LogWarning("Reset atk animation state");
_nockedArrow = false;
_shotArrow = false;
_lastArrowNormalizedTime = stateInfo.normalizedTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,22 @@ public AttackIntention(PlayerStateMachine stateMachine) : base(stateMachine) { }

public override void Enter(object arg0)
{
Transform target = TargetManager.Instance.Target.Data.ObjectTransform;
Transform target = TargetManager.Instance.Target.transform;

if (target == null)
{
return;
}

if (_stateMachine.State == PlayerState.ATTACKING)
if (_stateMachine.State == PlayerState.ATTACKING && TargetManager.Instance.IsAttackTargetSet())
{
if (TargetManager.Instance.IsAttackTargetSet())
{
return;
}
else
{
_stateMachine.ChangeIntention(Intention.INTENTION_FOLLOW, MoveReason.ATTACK);
return;
}
Debug.LogWarning("Attacking target is target");
return;
}

Entity targetEntity = TargetManager.Instance.Target.Data.Entity;
Entity targetEntity = TargetManager.Instance.Target;

TargetManager.Instance.SetAttackTarget();
// TargetManager.Instance.SetAttackTarget();
float attackRange = WorldCombat.Instance.GetRealAttackRange(PlayerEntity.Instance, targetEntity);

Vector3 targetPos = targetEntity.transform.position;
Expand All @@ -39,7 +32,9 @@ public override void Enter(object arg0)
// Is close enough? Is player already waiting for server reply?
if (distance <= attackRange * 0.95f && !_stateMachine.WaitingForServerReply && !targetEntity.IsDead)
{
PlayerController.Instance.UpdateFinalAngleToLookAt(targetEntity.transform);
// PlayerController.Instance.UpdateFinalAngleToLookAt(targetEntity.transform); -> Update angle once attack is allowed instead

Debug.LogWarning("Attacking a new target");

_stateMachine.ChangeState(PlayerState.IDLE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class FollowIntention : IntentionBase
{
public static MoveReason MoveReason { get; private set; }

public FollowIntention(PlayerStateMachine stateMachine) : base(stateMachine) { }

public override void Enter(object arg0)
Expand All @@ -12,11 +14,13 @@ public override void Enter(object arg0)
return;
}

MoveReason = (MoveReason)arg0;

PlayerController.Instance.IntentionToRun = true;

if (_stateMachine.IsInMovableState())
{
RunOrWalk((MoveReason)arg0);
RunOrWalk(MoveReason);
}
else if (!_stateMachine.WaitingForServerReply)
{
Expand All @@ -29,7 +33,7 @@ public override void Enter(object arg0)
}
}

private void RunOrWalk(MoveReason moveReason)
public void RunOrWalk(MoveReason moveReason)
{
if (PlayerEntity.Instance.Running)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ public InteractIntention(PlayerStateMachine stateMachine) : base(stateMachine) {

public override void Enter(object arg0)
{
Transform target = TargetManager.Instance.Target.Data.ObjectTransform;
Transform target = TargetManager.Instance.Target.transform;

if (target == null)
{
return;
}

Entity targetEntity = TargetManager.Instance.Target.Data.Entity;
Entity targetEntity = TargetManager.Instance.Target;
float interactRange = WorldCombat.Instance.GetInteractRange(PlayerEntity.Instance, targetEntity);
Vector3 targetPos = targetEntity.transform.position;
float distance = Vector3.Distance(PlayerEntity.Instance.transform.position, targetPos);
Expand Down
Loading

0 comments on commit 8b7b1b7

Please sign in to comment.