private void DoWandering() { if (HasTarget()) { state = MonsterAIState.Chase; return; } Position destination; // last action time set here short toX = (short)XiahRandom.Next(Monster.SpawnX - (Monster.WanderRange), Monster.SpawnX + (Monster.WanderRange)); short toY = (short)XiahRandom.Next(Monster.SpawnY - (Monster.WanderRange), Monster.SpawnY + (Monster.WanderRange)); destination = new Position(toX, toY, 0); MoveTo(destination); }
public BaseItem PickupItem(int mapItemId, Client c, short mapItemAmount) { MapItem m = null; try { m = mapItems.Where(x => x.MapItemID == mapItemId).First(); } catch (Exception) { return(null); } BaseItem item = null; if (m.DroppedByCharacterID == 0 || m.DroppedByCharacterID == c.MyCharacter.CharacterId) { if (m.bType != (byte)bType.Jeon) { if (m.ItemID != 0) { item = itemDataManager.GetItemByItemID(m.ItemID); } else { item = itemDataManager.GetItemByReferenceID(m.ReferenceID); } BagSlot bagSlot = gameEngine.TryPickToBags(c.MyCharacter.Bags.ToArray(), item); item.Slot = bagSlot.Slot; item.Bag = bagSlot.Bag; mapItemManager.DeleteMapItem(m.MapItemID, 0); mapItems.Remove(m); item.OwnerID = c.MyCharacter.CharacterId; if (item.ItemID != 0) { itemDataManager.UpdateItem(item); } else { item.ItemID = itemDataManager.InsertItem(item); if (item is Equipment) { // later add chance to get these items blabla Equipment Item = item as Equipment; ImbueStat stat = ImbueStat.None; ImbueItem imbueitem = new ImbueItem { ImbueChance = 1, IncreaseValue = 1, }; // Possible plus for drop if (XiahRandom.PercentSuccess(40)) { int plus = gameEngine.RandomChance(0, 5); for (int i = 0; i < plus; i++) { gameEngine.BlackImbue(Item, ref stat, imbueitem, 1); Item.Plus++; } } if (XiahRandom.PercentSuccess(40)) { // Possible slvl for drop int slvl = gameEngine.RandomChance(0, 5); for (int i = 0; i < slvl && !(Item is Cape); i++) { gameEngine.WhiteImbue(Item, ref stat, imbueitem); Item.Slvl++; } } item = Item; itemDataManager.UpdateItem(item); } } } else { item = itemDataManager.GetItemByReferenceID(m.ReferenceID); mapItemManager.DeleteMapItem(m.MapItemID, 0); mapItems.Remove(m); item.Amount = mapItemAmount; } } else { c.Send(PacketEngine.PacketManager.SendPickUpText(0, 0, 0)); // send pickuperror blabal } return(item); }