diff --git a/Zennysoft.Game.Ma.Implementation/Equipment/Tags/ArmorTag.cs b/Zennysoft.Game.Ma.Implementation/Equipment/Tags/ArmorTag.cs index e564fa54..2b6458e1 100644 --- a/Zennysoft.Game.Ma.Implementation/Equipment/Tags/ArmorTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Equipment/Tags/ArmorTag.cs @@ -3,5 +3,6 @@ public enum ArmorTag { None, - DegradeOnHit + DegradeOnHit, + ImmuneToRust } diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 1891d43e..012bfbc7 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -313,6 +313,16 @@ public partial class Game : Node3D, IGame RemoveItemOrSubtractFromItemCount(item); } + public void ThrowItem(IBaseInventoryItem item, double throwAngle) + { + var thrownScene = GD.Load("res://src/items/thrown/ThrownItem.tscn"); + var thrown = thrownScene.Instantiate(); + thrown.ItemThatIsThrown = item; + _map.AddChild(thrown); + thrown.Throw(_effectService, throwAngle); + RemoveItemOrSubtractFromItemCount(item); + } + public void DoubleExp() { GameRepo.AnnounceMessageOnMainScreen("Experience points temporarily doubled."); @@ -596,11 +606,21 @@ public partial class Game : Node3D, IGame _player.Unequip(_player.EquipmentComponent.EquippedAccessory.Value); _player.Inventory.Items.Remove(boxItem); - foreach (var item in _player.Inventory.Items.ToList()) - ThrowItem(item); - _player.Inventory.Items.Clear(); GameRepo.CloseInventory(); + var itemsToThrow = _player.Inventory.Items.ToList(); + _player.Inventory.Items.Clear(); + double[] throwAngles = [0, -5, 5, -15, -25, 25]; + var throwIndex = 0; + var arrayDirection = 1; BroadcastMessage($"All items have been ejected from inventory."); + foreach (var item in itemsToThrow) + { + ThrowItem(item, throwAngles[throwIndex]); + throwIndex += (1 * arrayDirection); + if (throwIndex >= throwAngles.Length - 1 || throwIndex <= 0) + arrayDirection *= -1; + await ToSignal(GetTree().CreateTimer(0.2f), "timeout"); + } break; } } diff --git a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs index 755531ce..6be28cfb 100644 --- a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs +++ b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs @@ -66,6 +66,12 @@ public partial class ThrownItem : RigidBody3D, IThrownItem ApplyCentralImpulse(-Player.GlobalBasis.Z.Normalized() * ItemThatIsThrown.ThrowSpeed); } + public void Throw(EffectService effectService, double throwAngle) + { + _effectService = effectService; + ApplyCentralImpulse(-Player.GlobalBasis.Z.Normalized().Rotated(Vector3.Up, (float)Mathf.DegToRad(throwAngle)) * ItemThatIsThrown.ThrowSpeed); + } + public void RescueItem() { if (!Game.RescuedItems.TryAdd(ItemThatIsThrown)) diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 4bd34f6b..5db7d8cf 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -916,7 +916,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide if (SigilComponent.Sigil.ElementType == weapon.WeaponElement) totalDamage = Mathf.RoundToInt(totalDamage * 1.15f); - totalDamage = Mathf.RoundToInt(totalDamage * (1 + SigilComponent.Sigil.AttackModifier)); + totalDamage = Mathf.RoundToInt(totalDamage * (1 + SigilComponent.Sigil.AttackModifier)); if (isCriticalHit) { @@ -942,7 +942,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide rng.Randomize(); if (rng.Randf() <= rustChance) { - if (rng.Randf() >= 0.5f && ((Accessory)EquipmentComponent.EquippedAccessory.Value).AccessoryTag != AccessoryTag.StatusEffectImmunity) + if (rng.Randf() >= 0.5f && ((Accessory)EquipmentComponent.EquippedAccessory.Value).AccessoryTag != AccessoryTag.StatusEffectImmunity && ((Armor)EquipmentComponent.EquippedArmor.Value).ArmorTag != ArmorTag.ImmuneToRust) StatusEffectComponent.Rust.OnNext(true); else enemy.StatusEffectComponent.Rust.OnNext(true);