diff --git a/Zennysoft.Game.Ma/src/enemy/Enemy2D.cs b/Zennysoft.Game.Ma/src/enemy/Enemy2D.cs index 640542b94..f0dd617fc 100644 --- a/Zennysoft.Game.Ma/src/enemy/Enemy2D.cs +++ b/Zennysoft.Game.Ma/src/enemy/Enemy2D.cs @@ -21,11 +21,13 @@ public abstract partial class Enemy2D : Enemy public void OnEnterTree() { LineOfSight.BodyEntered += LineOfSight_BodyEntered; + _previousPosition = GlobalPosition; } public override void _PhysicsProcess(double delta) { _enemyModelView.SetCurrentDirection(GlobalBasis, -_player.GlobalBasis.Z); + _previousPosition = GlobalPosition; } public override void _Process(double delta) @@ -37,7 +39,6 @@ public abstract partial class Enemy2D : Enemy _enemyLogic.Input(new EnemyLogic.Input.Idle()); else _enemyLogic.Input(new EnemyLogic.Input.Move()); - _previousPosition = GlobalPosition; } } @@ -55,7 +56,7 @@ public abstract partial class Enemy2D : Enemy protected void OnVelocityComputed(Vector3 safeVelocity) { - Velocity = safeVelocity; + Velocity = new Vector3(safeVelocity.X, 0, safeVelocity.Z); LookAtTarget(safeVelocity); MoveAndSlide(); } diff --git a/Zennysoft.Game.Ma/src/enemy/behaviors/PatrolBehavior.cs b/Zennysoft.Game.Ma/src/enemy/behaviors/PatrolBehavior.cs index 05f89fa43..2067684a4 100644 --- a/Zennysoft.Game.Ma/src/enemy/behaviors/PatrolBehavior.cs +++ b/Zennysoft.Game.Ma/src/enemy/behaviors/PatrolBehavior.cs @@ -23,7 +23,6 @@ public partial class PatrolBehavior : Node3D, IBehavior private Timer _patrolTimer { get; set; } = default!; private NavigationAgent3D _navigationAgent; - private int _recursiveCounter = 0; private Vector3 _homePosition; public Vector3 HomePosition diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 7dd810e69..8840cafa3 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -412,8 +412,16 @@ public partial class Game : Node3D, IGame { var restorativeScene = GD.Load("res://src/items/restorative/Restorative.tscn"); var restorative = restorativeScene.Instantiate(); - AddChild(restorative); restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z); + AddChild(restorative); + } + + private void DropItem(Vector3 vector) + { + var randomItem = ItemDatabase.Instance.PickItem() as Node3D; + var duplicated = randomItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D; + duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z); + AddChild(duplicated); } private void UseTeleportPrompt_CloseTeleportPrompt() @@ -691,7 +699,12 @@ public partial class Game : Node3D, IGame private void GameRepo_EnemyDied(IEnemy obj) { - DropRestorative(obj.GlobalPosition); + var rng = new RandomNumberGenerator(); + rng.Randomize(); + if (rng.Randf() < 0.15f) + DropItem(obj.GlobalPosition); + else + DropRestorative(obj.GlobalPosition); } private void BroadcastMessage(string obj) diff --git a/Zennysoft.Game.Ma/src/items/EffectService.cs b/Zennysoft.Game.Ma/src/items/EffectService.cs index 78d0a4010..122944ed8 100644 --- a/Zennysoft.Game.Ma/src/items/EffectService.cs +++ b/Zennysoft.Game.Ma/src/items/EffectService.cs @@ -234,7 +234,7 @@ public class EffectService var enemyPosition = new Vector3(enemy.GlobalPosition.X, 0f, enemy.GlobalPosition.Z); var enemyType = EnemyTypeToEnemyConverter.Convert(enemy); var duplicatedEnemy = EnemyTypeToEnemyConverter.Convert(enemyType); - duplicatedEnemy.Position = enemy.GlobalPosition + enemy.GlobalBasis.X; + duplicatedEnemy.GlobalPosition = enemy.GlobalPosition + enemy.GlobalBasis.X; _map.AddChild(duplicatedEnemy); } diff --git a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.tscn b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.tscn index c5e98ce2a..3fcb5252f 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.tscn +++ b/Zennysoft.Game.Ma/src/items/throwable/ThrowableItem.tscn @@ -33,5 +33,6 @@ shape = SubResource("BoxShape3D_03cqg") unique_name_in_owner = true pixel_size = 0.005 billboard = 2 +alpha_cut = 1 texture_filter = 0 render_priority = 100 diff --git a/Zennysoft.Game.Ma/src/map/dungeon/code/MonsterRoom.cs b/Zennysoft.Game.Ma/src/map/dungeon/code/MonsterRoom.cs index c4d8ce722..73958c16e 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/code/MonsterRoom.cs +++ b/Zennysoft.Game.Ma/src/map/dungeon/code/MonsterRoom.cs @@ -2,7 +2,6 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using System.Linq; -using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -41,8 +40,9 @@ public partial class MonsterRoom : DungeonRoom var index = rng.RandWeighted([.. enemyInfo.Values]); var selectedEnemy = enemyInfo.ElementAt((int)index); var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key); - instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 0f, spawnPoint.Position.Z); AddChild(instantiatedEnemy); + instantiatedEnemy.GlobalPosition = new Vector3(spawnPoint.GlobalPosition.X, 0f, spawnPoint.GlobalPosition.Z); + ResetPhysicsInterpolation(); } } @@ -65,7 +65,7 @@ public partial class MonsterRoom : DungeonRoom var selectedItem = database.PickItem() as Node3D; var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D; - duplicated.Position = new Vector3(spawnPoint.Position.X, 0, spawnPoint.Position.Z); + duplicated.GlobalPosition = new Vector3(spawnPoint.GlobalPosition.X, 0, spawnPoint.GlobalPosition.Z); AddChild(duplicated); } }