diff --git a/Client/MirControls/MirItemCell.cs b/Client/MirControls/MirItemCell.cs index ba1172a69..2c9fe37d7 100644 --- a/Client/MirControls/MirItemCell.cs +++ b/Client/MirControls/MirItemCell.cs @@ -1031,13 +1031,6 @@ private void MoveItem() } } - if (GameScene.SelectedCell.Item.Weight + MapObject.User.CurrentBagWeight > MapObject.User.Stats[Stat.BagWeight]) - { - GameScene.Scene.ChatDialog.ReceiveChat("Too heavy to get back.", ChatType.System); - GameScene.SelectedCell = null; - return; - } - if (Item != null) { if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize) @@ -1109,13 +1102,6 @@ private void MoveItem() } } - if (GameScene.SelectedCell.Item.Weight + MapObject.User.CurrentBagWeight > MapObject.User.Stats[Stat.BagWeight]) - { - GameScene.Scene.ChatDialog.ReceiveChat("Too heavy to get back.", ChatType.System); - GameScene.SelectedCell = null; - return; - } - if (Item != null) { if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize) @@ -1181,13 +1167,6 @@ private void MoveItem() } } - if (GameScene.SelectedCell.Item.Weight + MapObject.User.CurrentBagWeight > MapObject.User.Stats[Stat.BagWeight]) - { - GameScene.Scene.ChatDialog.ReceiveChat("Too heavy to get back.", ChatType.System); - GameScene.SelectedCell = null; - return; - } - if (Item != null) { if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize) @@ -1236,13 +1215,6 @@ private void MoveItem() return; } - if (GameScene.SelectedCell.Item.Weight + MapObject.User.CurrentBagWeight > MapObject.User.Stats[Stat.BagWeight]) - { - GameScene.Scene.ChatDialog.ReceiveChat("Too heavy to get back.", ChatType.System); - GameScene.SelectedCell = null; - return; - } - if (Item == null) { Network.Enqueue(new C.RetrieveRentalItem { From = GameScene.SelectedCell.ItemSlot, To = ItemSlot }); @@ -1272,13 +1244,6 @@ private void MoveItem() } } - if (GameScene.SelectedCell.Item.Weight + MapObject.User.CurrentBagWeight > MapObject.User.Stats[Stat.BagWeight]) - { - GameScene.Scene.ChatDialog.ReceiveChat("Too heavy to transfer.", ChatType.System); - GameScene.SelectedCell = null; - return; - } - if (Item != null) { if (GameScene.SelectedCell.Item.Info == Item.Info && Item.Count < Item.Info.StackSize) diff --git a/Client/MirNetwork/Network.cs b/Client/MirNetwork/Network.cs index 29068cfab..57ff0a97a 100644 --- a/Client/MirNetwork/Network.cs +++ b/Client/MirNetwork/Network.cs @@ -10,6 +10,8 @@ static class Network { private static TcpClient _client; public static int ConnectAttempt = 0; + public static int MaxAttempts = 20; + public static bool ErrorShown; public static bool Connected; public static long TimeOutTime, TimeConnected, RetryTime = CMain.Time + 5000; @@ -24,20 +26,46 @@ public static void Connect() if (_client != null) Disconnect(); - ConnectAttempt++; + if (ConnectAttempt >= MaxAttempts) + { + if (ErrorShown) + { + return; + } - _client = new TcpClient {NoDelay = true}; - _client.BeginConnect(Settings.IPAddress, Settings.Port, Connection, null); + ErrorShown = true; + + MirMessageBox errorBox = new("Error Connecting to Server", MirMessageBoxButtons.Cancel); + errorBox.CancelButton.Click += (o, e) => Program.Form.Close(); + errorBox.Label.Text = $"Maximum Connection Attempts Reached: {MaxAttempts}" + + $"{Environment.NewLine}Please try again later or check your connection settings."; + errorBox.Show(); + return; + } + + ConnectAttempt++; + try + { + _client = new TcpClient { NoDelay = true }; + _client?.BeginConnect(Settings.IPAddress, Settings.Port, Connection, null); + } + catch (ObjectDisposedException ex) + { + if (Settings.LogErrors) CMain.SaveError(ex.ToString()); + Disconnect(); + } } private static void Connection(IAsyncResult result) { try { - _client.EndConnect(result); + _client?.EndConnect(result); - if (!_client.Connected) + if ((_client != null && + !_client.Connected) || + _client == null) { Connect(); return; @@ -50,11 +78,11 @@ private static void Connection(IAsyncResult result) TimeOutTime = CMain.Time + Settings.TimeOut; TimeConnected = CMain.Time; - BeginReceive(); } catch (SocketException) { + Thread.Sleep(100); Connect(); } catch (Exception ex) @@ -142,12 +170,11 @@ private static void SendData(IAsyncResult result) { } } - public static void Disconnect() { if (_client == null) return; - _client.Close(); + _client?.Close(); TimeConnected = 0; Connected = false; diff --git a/Client/MirObjects/MapObject.cs b/Client/MirObjects/MapObject.cs index ba80e8e53..b82dae402 100644 --- a/Client/MirObjects/MapObject.cs +++ b/Client/MirObjects/MapObject.cs @@ -190,11 +190,19 @@ private void RestoreTargetStates() if (MagicObjectID == ObjectID) MagicObject = this; - /*if (TargetObject == null) + if (!this.Dead && + TargetObject == null && + LastTargetObjectId == ObjectID) { - if (lastTargetObjectId == ObjectID) - TargetObject = this; - }*/ + switch (Race) + { + case ObjectType.Player: + case ObjectType.Monster: + case ObjectType.Hero: + TargetObject = this; + break; + } + } } public void AddBuffEffect(BuffType type) diff --git a/Client/MirObjects/UserObject.cs b/Client/MirObjects/UserObject.cs index 23cd6a5b6..9876edd16 100644 --- a/Client/MirObjects/UserObject.cs +++ b/Client/MirObjects/UserObject.cs @@ -716,16 +716,9 @@ public ClientMagic GetMagic(Spell spell) public void GetMaxGain(UserItem item) { - if (CurrentBagWeight + item.Weight <= Stats[Stat.BagWeight] && FreeSpace(Inventory) > 0) return; - ushort min = 0; ushort max = item.Count; - if (CurrentBagWeight >= Stats[Stat.BagWeight]) - { - - } - if (item.Info.Type == ItemType.Amulet) { for (int i = 0; i < Inventory.Length; i++) @@ -748,9 +741,9 @@ public void GetMaxGain(UserItem item) } } - if (min == 0) + if (min == 0 && FreeSpace(Inventory) == 0) { - GameScene.Scene.ChatDialog.ReceiveChat(FreeSpace(Inventory) == 0 ? GameLanguage.NoBagSpace : "You do not have enough weight.", ChatType.System); + GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.NoBagSpace, ChatType.System); item.Count = 0; return; @@ -760,15 +753,11 @@ public void GetMaxGain(UserItem item) return; } - if (CurrentBagWeight + item.Weight > Stats[Stat.BagWeight]) + if (FreeSpace(Inventory) == 0) { - item.Count = (ushort)(Math.Max((Stats[Stat.BagWeight] - CurrentBagWeight), ushort.MinValue) / item.Info.Weight); - max = item.Count; - if (item.Count == 0) - { - GameScene.Scene.ChatDialog.ReceiveChat("You do not have enough weight.", ChatType.System); - return; - } + GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.NoBagSpace, ChatType.System); + item.Count = 0; + return; } if (item.Info.StackSize > 1) diff --git a/Client/MirScenes/Dialogs/NPCDialogs.cs b/Client/MirScenes/Dialogs/NPCDialogs.cs index 68eab962b..082ed7dcf 100644 --- a/Client/MirScenes/Dialogs/NPCDialogs.cs +++ b/Client/MirScenes/Dialogs/NPCDialogs.cs @@ -732,12 +732,6 @@ private void BuyItem() return; } - if (SelectedItem.Weight > (MapObject.User.Stats[Stat.BagWeight] - MapObject.User.CurrentBagWeight)) - { - GameScene.Scene.ChatDialog.ReceiveChat("You do not have enough weight.", ChatType.System); - return; - } - for (int i = 0; i < MapObject.User.Inventory.Length; i++) { if (MapObject.User.Inventory[i] == null) break; @@ -1979,12 +1973,6 @@ private void CraftItem() //TODO - Check Max slots spare against slots to be used (stacksize/quantity) //TODO - GetMaxItemGain - if (RecipeItem.Weight > (MapObject.User.Stats[Stat.BagWeight] - MapObject.User.CurrentBagWeight)) - { - GameScene.Scene.ChatDialog.ReceiveChat("You do not have enough weight.", ChatType.System); - return; - } - if (max == 1) { if (Recipe.Gold > GameScene.Gold) diff --git a/Client/MirScenes/GameScene.cs b/Client/MirScenes/GameScene.cs index 06d1c7803..158e69175 100644 --- a/Client/MirScenes/GameScene.cs +++ b/Client/MirScenes/GameScene.cs @@ -10403,11 +10403,7 @@ public void LoadMap() { if (SetMusic != Music) { - if (SoundManager.Music != null) - { - SoundManager.Music.Dispose(); - } - + SoundManager.Music?.Dispose(); SoundManager.PlayMusic(Music, true); } } diff --git a/Client/MirSounds/Libraries/NAudioLibrary.cs b/Client/MirSounds/Libraries/NAudioLibrary.cs index a39dd10f7..a8a6b48a7 100644 --- a/Client/MirSounds/Libraries/NAudioLibrary.cs +++ b/Client/MirSounds/Libraries/NAudioLibrary.cs @@ -15,6 +15,7 @@ internal class NAudioLibrary : ISoundLibrary, IDisposable private WaveOutEvent outputDevice; private AudioFileReader audioFile; + private int _unscaledVolume; private string _fileName; private bool _loop; private bool _isDisposing; @@ -110,7 +111,7 @@ private void OutputDevice_PlaybackStopped() if (_loop && !_isDisposing) { - outputDevice.Play(); + Play(_unscaledVolume); } } @@ -124,6 +125,8 @@ public void Dispose() private float ScaleVolume(int volume) { + _unscaledVolume = volume; + float scaled = 0.0f + (float)(volume - 0) / (100 - 0) * (1.0f - 0.0f); return scaled; } diff --git a/Server/MirObjects/HumanObject.cs b/Server/MirObjects/HumanObject.cs index 2e66f05dd..899aa46f7 100644 --- a/Server/MirObjects/HumanObject.cs +++ b/Server/MirObjects/HumanObject.cs @@ -1,6 +1,7 @@ using Server.MirDatabase; using Server.MirEnvir; using Server.MirNetwork; +using Server.MirObjects.Monsters; using System.Numerics; using S = ServerPackets; @@ -938,7 +939,7 @@ public void GetMinePayout(MineSet Mine) if (CheckGroupQuestItem(item)) continue; - if (CanGainItem(item, false)) + if (CanGainItem(item)) { GainItem(item); Report.ItemChanged(item, item.Count, 2); @@ -2475,6 +2476,11 @@ public bool Walk(MirDirection dir) } public bool Run(MirDirection dir) { + if (CurrentBagWeight > Stats[Stat.BagWeight]) + { + Walk(dir); + } + var steps = RidingMount || ActiveSwiftFeet && !Sneaking ? 3 : 2; if (!CanMove || !CanWalk || !CanRun) @@ -5590,14 +5596,29 @@ public void ArcherSummon(UserMagic magic, MapObject target, Point location) public void ArcherSummonStone(UserMagic magic, Point location, out bool cast) { cast = false; - if (!CurrentMap.ValidPoint(location)) return; - if (!CanFly(location)) return; - //if ((Info.MentalState != 1) && !CanFly(location)) return;// - uint duration = (uint)((magic.Level * 5 + 10) * 1000); - int value = (int)duration; - int delay = Functions.MaxDistance(CurrentLocation, location) * 50 + 500; //50 MS per Step - DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, value, location); + + if (!CurrentMap.ValidPoint(location) || + !CanFly(location)) + { + return; + } + + if (Pets.Exists(x => x.Info.GameName == Settings.StoneName)) + { + MonsterObject st = Pets.First(x => x.Info.GameName == Settings.StoneName); + if (!st.Dead) + { + ReceiveChat($"You can only have 1 active {Settings.StoneName} alive.", ChatType.Hint); + return; + } + } + + int duration = (((magic.Level * 5) + 10) * 1000); + int delay = Functions.MaxDistance(CurrentLocation, location) * 50 + 500; //50 MS per Step + // + DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + delay, magic, duration, location); ActionList.Add(action); + cast = true; } @@ -6556,7 +6577,7 @@ protected void CompleteMagic(IList data) break; case Spell.Stonetrap: { - value = (int)data[1]; + duration = (int)data[1]; location = (Point)data[2]; if (Pets.Where(x => x.Race == ObjectType.Monster).Count() >= magic.Level + 1) return; @@ -6573,6 +6594,9 @@ protected void CompleteMagic(IList data) monster.Direction = Direction; monster.ActionTime = Envir.Time + 1000; + StoneTrap st = monster as StoneTrap; + st.DieTime = Envir.Time + duration; + DelayedAction act = new DelayedAction(DelayedType.Magic, Envir.Time + 500, this, magic, monster, location); CurrentMap.ActionList.Add(act); break; @@ -7401,12 +7425,15 @@ protected int GetCurrentStatCount(UserItem gem, UserItem item) */ return 0; } - public bool CanGainItem(UserItem item, bool useWeight = true) + public bool CanGainItem(UserItem item) { - if (item.Info.Type == ItemType.Amulet) + if (FreeSpace(Info.Inventory) > 0) { - if (FreeSpace(Info.Inventory) > 0 && (CurrentBagWeight + item.Weight <= Stats[Stat.BagWeight] || !useWeight)) return true; + return true; + } + if (item.Info.Type == ItemType.Amulet) + { ushort count = item.Count; for (int i = 0; i < Info.Inventory.Length; i++) @@ -7423,10 +7450,6 @@ public bool CanGainItem(UserItem item, bool useWeight = true) return false; } - if (useWeight && CurrentBagWeight + (item.Weight) > Stats[Stat.BagWeight]) return false; - - if (FreeSpace(Info.Inventory) > 0) return true; - if (item.Info.StackSize > 1) { ushort count = item.Count; @@ -7448,7 +7471,6 @@ public bool CanGainItem(UserItem item, bool useWeight = true) public bool CanGainItems(UserItem[] items) { int itemCount = items.Count(e => e != null); - int itemWeight = 0; ushort stackOffset = 0; if (itemCount < 1) return true; @@ -7457,8 +7479,6 @@ public bool CanGainItems(UserItem[] items) { if (items[i] == null) continue; - itemWeight += items[i].Weight; - if (items[i].Info.StackSize > 1) { ushort count = items[i].Count; @@ -7476,7 +7496,6 @@ public bool CanGainItems(UserItem[] items) } } - if (CurrentBagWeight + (itemWeight) > Stats[Stat.BagWeight]) return false; if (FreeSpace(Info.Inventory) < itemCount + stackOffset) return false; return true; diff --git a/Server/MirObjects/MapObject.cs b/Server/MirObjects/MapObject.cs index 4c5ee93c0..89521c62e 100644 --- a/Server/MirObjects/MapObject.cs +++ b/Server/MirObjects/MapObject.cs @@ -200,7 +200,6 @@ public Point Back } - public virtual void Process() { if (Master != null && Master.Node == null) Master = null; diff --git a/Server/MirObjects/MonsterObject.cs b/Server/MirObjects/MonsterObject.cs index 17f357533..141df7d73 100644 --- a/Server/MirObjects/MonsterObject.cs +++ b/Server/MirObjects/MonsterObject.cs @@ -1,6 +1,7 @@ using Server.MirDatabase; using Server.MirEnvir; using Server.MirObjects.Monsters; +using System.Diagnostics.Eventing.Reader; using S = ServerPackets; namespace Server.MirObjects @@ -1717,12 +1718,36 @@ protected virtual void FindTarget() { case ObjectType.Monster: case ObjectType.Hero: + if (!ob.IsAttackTarget(this)) continue; if (ob.Hidden && (!CoolEye || Level < ob.Level)) continue; if (this is TrapRock && ob.InTrapRock) continue; - Target = ob; - return; + + if (ob.Race == ObjectType.Monster && + ob is StoneTrap) + { + if (Target is null || + (Target is not null && + Target is not StoneTrap)) + { + Target = ob; + } + + return; + } + else + { + Target ??= ob; + } + continue; + case ObjectType.Player: + + if (Target != null) + { + continue; + } + PlayerObject playerob = (PlayerObject)ob; if (!ob.IsAttackTarget(this)) continue; if (playerob.GMGameMaster || ob.Hidden && (!CoolEye || Level < ob.Level) || Envir.Time < HallucinationTime) continue; @@ -1740,7 +1765,7 @@ protected virtual void FindTarget() break; } } - return; + continue; default: continue; } diff --git a/Server/MirObjects/Monsters/StoneTrap.cs b/Server/MirObjects/Monsters/StoneTrap.cs index ff1985f6c..d9ee1369a 100644 --- a/Server/MirObjects/Monsters/StoneTrap.cs +++ b/Server/MirObjects/Monsters/StoneTrap.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using System.Threading; using Server.MirDatabase; using Server.MirEnvir; using S = ServerPackets; @@ -11,22 +12,85 @@ namespace Server.MirObjects.Monsters public class StoneTrap : MonsterObject { public bool Summoned; - public long AliveTime; public long DieTime; - protected internal StoneTrap(MonsterInfo info) : base(info) { Direction = MirDirection.Up; } + public override string Name { get { return Master == null ? Info.GameName : (Dead ? Info.GameName : string.Format("{0}({1})", Info.GameName, Master.Name)); } set { throw new NotSupportedException(); } } + protected override void ProcessRegen() { } + protected override void Attack() { } - protected override void FindTarget() { } + + protected override void ProcessAI() + { + for (int d = 0; d <= Info.ViewRange; d++) + { + for (int y = CurrentLocation.Y - d; y <= CurrentLocation.Y + d; y++) + { + if (y < 0) continue; + if (y >= CurrentMap.Height) break; + + for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2) + { + if (x < 0) continue; + if (x >= CurrentMap.Width) break; + + Cell cell = CurrentMap.GetCell(x, y); + if (!cell.Valid || cell.Objects == null) continue; + + for (int i = 0; i < cell.Objects.Count; i++) + { + MapObject ob = cell.Objects[i]; + + if (ob == this) + { + continue; + } + + switch (ob.Race) + { + case ObjectType.Monster: + case ObjectType.Hero: + + MonsterInfo mInfo = Envir.GetMonsterInfo(ob.Name); + if (mInfo == null) + { + continue; + } + + MonsterObject monster = MonsterObject.GetMonster(mInfo); + if (!monster.Dead) + { + if (monster.Master == null || + (monster.Master != null && + monster.IsAttackTarget(this.Master))) + { + if (Target != null && + Target is StoneTrap && + Target != this) + { + continue; + } + + monster.Target = this; + } + } + + break; + } + } + } + } + } + } public override void Turn(MirDirection dir) { @@ -38,77 +102,26 @@ public override bool Walk(MirDirection dir) public override void Spawned() { base.Spawned(); - AliveTime = Envir.Time + 15000; Summoned = true; } public override void Process() { - if (!Dead && Summoned) + if (!Dead && + Master != null) { - bool selfDestruct = false; - if (Master != null) + if (Master.CurrentMap != CurrentMap || + Envir.Time > DieTime || + !Functions.InRange(Master.CurrentLocation, CurrentLocation, 15)) { - if (Master.CurrentMap != CurrentMap) selfDestruct = true; - if (!Functions.InRange(Master.CurrentLocation, CurrentLocation, 15)) selfDestruct = true; - if (Summoned && Envir.Time > AliveTime) selfDestruct = true; - if (selfDestruct) - { - Die(); - //DieTime = Envir.Time + 3000; - } - base.Process(); + Die(); + } + else + { + FindTarget(); } } - base.Process(); - //else if (Envir.Time >= DieTime) Despawn(); - } - - public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility) - { - int armour = 0; - - switch (type) - { - case DefenceType.ACAgility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]); - break; - case DefenceType.AC: - armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]); - break; - case DefenceType.MACAgility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]); - break; - case DefenceType.MAC: - armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]); - break; - case DefenceType.Agility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - break; - } - - if (armour >= damage) return 0; - - ShockTime = 0; - - if (attacker.Info.AI == 6) - EXPOwner = null; - else if (attacker.Master != null) - { - if (EXPOwner == null || EXPOwner.Dead) - EXPOwner = attacker.Master; - - if (EXPOwner == attacker.Master) - EXPOwnerTime = Envir.Time + EXPOwnerDelay; - - } - - Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation }); - - ChangeHP(-1); - return 1; + base.Process(); } public override int Struck(int damage, DefenceType type = DefenceType.ACAgility) @@ -116,56 +129,6 @@ public override int Struck(int damage, DefenceType type = DefenceType.ACAgility) return 0; } - public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true) - { - int armour = 0; - - switch (type) - { - case DefenceType.ACAgility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]); - break; - case DefenceType.AC: - armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]); - break; - case DefenceType.MACAgility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]); - break; - case DefenceType.MAC: - armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]); - break; - case DefenceType.Agility: - if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0; - break; - } - - if (armour >= damage) return 0; - - if (damageWeapon) - attacker.DamageWeapon(); - - ShockTime = 0; - - if (Master != null && Master != attacker) - if (Envir.Time > Master.BrownTime && Master.PKPoints < 200) - attacker.BrownTime = Envir.Time + Settings.Minute; - - if (EXPOwner == null || EXPOwner.Dead) - EXPOwner = attacker; - - if (EXPOwner == attacker) - EXPOwnerTime = Envir.Time + EXPOwnerDelay; - - Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation }); - attacker.GatherElement(); - ChangeHP(-1); - - return 1; - } - - public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true) { } public override Packet GetInfo() { return new S.ObjectMonster diff --git a/Server/MirObjects/NPC/NPCSegment.cs b/Server/MirObjects/NPC/NPCSegment.cs index cfac373df..f38927118 100644 --- a/Server/MirObjects/NPC/NPCSegment.cs +++ b/Server/MirObjects/NPC/NPCSegment.cs @@ -2940,7 +2940,7 @@ private void Act(IList acts, PlayerObject player) item.Count = item.Info.StackSize; } - if (player.CanGainItem(item, false)) + if (player.CanGainItem(item)) player.GainItem(item); } } @@ -4064,7 +4064,7 @@ private void Act(IList acts, PlayerObject player) if (drop.QuestRequired) continue; - if (player.CanGainItem(item, false)) + if (player.CanGainItem(item)) { player.GainItem(item); } diff --git a/Server/MirObjects/PlayerObject.cs b/Server/MirObjects/PlayerObject.cs index 0a4298f42..6ab287346 100644 --- a/Server/MirObjects/PlayerObject.cs +++ b/Server/MirObjects/PlayerObject.cs @@ -2207,7 +2207,7 @@ public void Chat(string message, List linkedItems = null) item = Envir.CreateDropItem(iInfo); item.Count = itemCount; - if (CanGainItem(item, false)) GainItem(item); + if (CanGainItem(item)) GainItem(item); return; } @@ -2215,7 +2215,7 @@ public void Chat(string message, List linkedItems = null) item.Count = iInfo.StackSize; itemCount -= iInfo.StackSize; - if (!CanGainItem(item, false)) return; + if (!CanGainItem(item)) return; GainItem(item); } @@ -5161,13 +5161,6 @@ public void TakeBackItem(int from, int to) return; } - if (temp.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat("Too heavy to get back.", ChatType.System); - Enqueue(p); - return; - } - if (Info.Inventory[to] == null) { Info.Inventory[to] = temp; @@ -5365,13 +5358,6 @@ public void TakeBackHeroItem(int from, int to) return; } - if (temp.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat("Too heavy to transfer.", ChatType.System); - Enqueue(p); - return; - } - if (Info.Inventory[to] == null) { Info.Inventory[to] = temp; @@ -9477,12 +9463,6 @@ public void GuildStorageItemChange(byte type, int from, int to) Enqueue(p); return; } - if (Stats[Stat.BagWeight] < CurrentBagWeight + MyGuild.StoredItems[from].Item.Weight) - { - ReceiveChat("Too overweight to retrieve item.", ChatType.System); - Enqueue(p); - return; - } if (MyGuild.StoredItems[from].Item.Info.Bind.HasFlag(BindMode.DontStore)) { Enqueue(p); @@ -9743,13 +9723,6 @@ public void RetrieveTradeItem(int from, int to) return; } - if (temp.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat("Too heavy to get back.", ChatType.System); - Enqueue(p); - return; - } - if (Info.Inventory[to] == null) { Info.Inventory[to] = temp; @@ -11340,7 +11313,7 @@ public bool IntelligentCreatureProduceBlackStone() UserItem item = Envir.CreateDropItem(iInfo); item.Count = 1; - if (!CanGainItem(item, false)) + if (!CanGainItem(item)) { MailInfo mail = new MailInfo(Info.Index) { @@ -11679,13 +11652,6 @@ public void RetrieveRefineItem(int from, int to) return; } - if (temp.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat("Too heavy to get back.", ChatType.System); - Enqueue(p); - return; - } - if (Info.Inventory[to] == null) { Info.Inventory[to] = temp; @@ -11974,14 +11940,6 @@ public void CollectRefine() return; } - - if (Info.CurrentRefine.Info.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat(string.Format("Your {0} is too heavy to get back, try again after reducing your bag weight.", Info.CurrentRefine.FriendlyName), ChatType.System); - Enqueue(p); - return; - } - int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) @@ -13299,13 +13257,6 @@ public void RetrieveRentalItem(int from, int to) return; } - if (item.Weight + CurrentBagWeight > Stats[Stat.BagWeight]) - { - ReceiveChat("Item is too heavy to retrieve.", ChatType.System); - Enqueue(packet); - return; - } - if (Info.Inventory[to] == null) { Info.Inventory[to] = item; @@ -13690,7 +13641,7 @@ public void SealHero() UserItem item = Envir.CreateFreshItem(itemInfo); item.AddedStats[Stat.Hero] = CurrentHero.Index; - if (CanGainItem(item, false)) + if (CanGainItem(item)) GainItem(item); CurrentHero.SealCount++; diff --git a/Shared/ServerPackets.cs b/Shared/ServerPackets.cs index 8808e5ba5..b23e7dc78 100644 --- a/Shared/ServerPackets.cs +++ b/Shared/ServerPackets.cs @@ -4212,7 +4212,7 @@ public sealed class MarketFail : Packet * 2: Already Sold. * 3: Expired. * 4: Not enough Gold. - * 5: Too heavy or not enough bag space. + * 5: Not enough bag space. * 6: You cannot buy your own items. * 7: Trust Merchant is too far. * 8: Too much Gold.