public CharacterInventory(Player character) { this.Player = character; if (!String.IsNullOrEmpty(character.Stuff)) { if (character.Stuff[character.Stuff.Length - 1] == '|') { character.Stuff = character.Stuff.Substring(0, character.Stuff.Length - 1); } InventoryItemTable.Load(character.Stuff.Replace("|", ",")); } foreach (String item in Regex.Split(character.Stuff, "\\|")) { if (String.IsNullOrEmpty(item)) { continue; } int guid = int.Parse(item); InventoryItemModel obj = InventoryItemTable.getItem(guid); if (obj != null) { Add(obj); } } }
public static void removeFromBank(Player character, int guid, int qua) { InventoryItemModel BankObj = InventoryItemTable.getItem(guid); if (BankObj == null) { character.Send(new BasicNoOperationMessage()); return; } if (!character.Client.Account.Data.bankItems.ContainsKey(guid)) { Logger.Error("Le joueur " + character.Name + " a tenter de retirer un Item en banque qu'il n'avait pas."); } InventoryItemModel PersoObj = character.InventoryCache.ItemsCache.Values.FirstOrDefault(x => x.TemplateID == BankObj.TemplateID && x.GetStats().ToItemStats() == BankObj.GetStats().ToItemStats() && x.ID != BankObj.ID && x.Position == -1); /* getSimilarBankItem(Character, BankObj);*/ int newQua = BankObj.Quantity - qua; if (PersoObj == null) { if (newQua <= 0) { character.Client.Account.Data.bankItems.Remove(guid); character.InventoryCache.Add(BankObj, false); String str = "O-" + guid; character.Send(new BankUpdateMessage(str)); } else { PersoObj = getCloneItem(BankObj, qua); InventoryItemTable.addItem(PersoObj, true); character.InventoryCache.Add(PersoObj, false); String str = "O+" + BankObj.ID + "|" + BankObj.Quantity + "|" + BankObj.TemplateID + "|" + BankObj.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); } } else { if (newQua <= 0) { character.Client.Account.Data.bankItems.Remove(BankObj.ID); InventoryItemTable.removeItem(BankObj.ID); PersoObj.Quantity += BankObj.Quantity; character.Send(new ObjectQuantityMessage(PersoObj.ID, PersoObj.Quantity)); String str = "O-" + guid; character.Send(new BankUpdateMessage(str)); } else { BankObj.Quantity = newQua; PersoObj.Quantity += qua; character.Send(new ObjectQuantityMessage(PersoObj.ID, PersoObj.Quantity)); String str = "O+" + BankObj.ID + "|" + BankObj.Quantity + "|" + BankObj.TemplateID + "|" + BankObj.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); } } //SEND POD MESSAGE ? character.GetClient().Account.Data.Save(); }
private static void ProcessObjectUseRequest(WorldClient Client, string Packet) { int guid = -1; int targetGuid = -1; int targetCell = -1; Player Target = null; try { String[] infos = Regex.Split(Packet.Substring(2), "\\|"); guid = int.Parse(infos[0]); if (infos.Length == 3) { targetCell = int.Parse(infos[2]); } try //try { targetGuid = int.Parse(infos[1]); } catch (Exception e) { targetGuid = -1; }; } catch (Exception e) { Logger.Error(e); return; } if (CharacterTable.GetCharacter(targetGuid) != null) { Target = CharacterTable.GetCharacter(targetGuid); } if (!Client.Character.InventoryCache.hasItemGuid(guid)) { return; } InventoryItemModel obj = InventoryItemTable.getItem(guid); ItemTemplateModel T = obj.Template; if (!T.Criterions.Equals("") && !ConditionParser.validConditions(Client.Character, T.Criterions)) { Client.Send(new ImMessage("119|43")); return; } if (T.ItemType == ItemTypeEnum.ITEM_TYPE_PAIN || T.ItemType == ItemTypeEnum.ITEM_TYPE_VIANDE_COMESTIBLE) { Client.Character.myMap.SendToMap(new MapEmoticoneMessage(Client.Character.ActorId, 17)); } else if (T.ItemType == ItemTypeEnum.ITEM_TYPE_BIERE) { Client.Character.myMap.SendToMap(new MapEmoticoneMessage(Client.Character.ActorId, 18)); } T.applyAction(Client.Character, Target, guid, (short)targetCell); }
private static void ProcessObjectUnEquipLivingItem(WorldClient Client, string Packet) { if (Client.GetFight() != null && (int)Client.GetFight().FightState > 2) { Client.Send(new BasicNoOperationMessage()); return; } var Data = Packet.Split('|'); long ItemGuid = 0; if (!long.TryParse(Data[0].Substring(2), out ItemGuid)) { Client.Send(new BasicNoOperationMessage()); return; } var Item = Client.Character.InventoryCache.GetItem(ItemGuid); var OldId = Item.SpeakingID; if (Item == null || Item.SpeakingItem == null) { Client.Send(new BasicNoOperationMessage()); return; } if (Item.SpeakingItem.Associated == 1) { long ObjeOriginialID = Item.SpeakingItem.LivingItem; var objv = InventoryItemTable.getItem(ObjeOriginialID); if (objv == null) { Client.Send(new BasicNoOperationMessage()); return; } objv.SpeakingID = OldId; Item.SpeakingItem.LinkedItem = ObjeOriginialID; Item.SpeakingItem.Associated = 0; Item.SpeakingID = 0; Client.Character.InventoryCache.Add(objv);; Client.Send(new ObjectRefreshMessage(Item)); Client.Character.myMap.SendToMap(new ObjectActualiseMessage(Client.Character)); if (Client.GetFight() != null) { Client.GetFight().SendToFight(new ObjectActualiseMessage(Client.Character)); } } }
public static void ProcessObjectDestroyMessage(WorldClient Client, string Packet) { String[] infos = Regex.Split(Packet.Substring(2), "\\|"); try { int guid = int.Parse(infos[0]); int qua = 1; try { qua = int.Parse(infos[1]); } catch (Exception e) { return; } InventoryItemModel obj = InventoryItemTable.getItem(guid); if (!Client.Character.InventoryCache.hasItemGuid(guid) || qua <= 0 || obj == null) { Client.Send(new BasicNoOperationMessage()); return; } int newQua = obj.Quantity - qua; if (newQua <= 0) { Client.Character.InventoryCache.remove(guid); InventoryItemTable.removeItem(guid); Client.Send(new ObjectRemoveMessage(guid)); } else { obj.Quantity = newQua; Client.Send(new ObjectQuantityMessage(guid, newQua)); } Client.Send(new AccountStatsMessage(Client.GetCharacter())); Client.Send(new InventoryWeightMessage(0, 2000)); } catch (Exception e) { Client.Send(new BasicNoOperationMessage()); } }
public void Intialize() { if (myIntialized) { return; } foreach (String str in ItemList.Split(';')) { try { if (String.IsNullOrEmpty(str)) { continue; } long idd; if (!long.TryParse(str, out idd)) { continue; } InventoryItemModel obj = InventoryItemTable.getItem(idd); if (obj != null) { Items.Add(obj.ID, obj); } else { obj = InventoryItemTable.Load(idd); if (obj != null) { Items.Add(obj.ID, obj); } } } catch (Exception e) { continue; } } myIntialized = true; }
public static void addInBank(Player character, int guid, int qua) { InventoryItemModel item = InventoryItemTable.getItem(guid); if (item == null) { character.Send(new BasicNoOperationMessage()); return; } if (!character.InventoryCache.hasItemGuid(guid)) { Logger.Error("Le joueur " + character.Name + " a tenter d'ajouter un Item en banque qu'il n'avait pas."); } if (item.Slot != ItemSlotEnum.SLOT_INVENTAIRE) { character.Send(new BasicNoOperationMessage()); return; } InventoryItemModel bankItem = getSimilarBankItem(character, item); int newQua = item.Quantity - qua; if (bankItem == null) { if (newQua <= 0) { character.InventoryCache.RemoveItem(item); character.Client.Account.Data.bankItems.Add(item.ID, item); String str = "O+" + item.ID + "|" + item.Quantity + "|" + item.TemplateID + "|" + item.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); character.Send(new ObjectRemoveMessage(guid)); } else { item.Quantity = newQua; bankItem = getCloneItem(item, qua); InventoryItemTable.addItem(bankItem, true); character.Client.Account.Data.bankItems.Add(bankItem.ID, bankItem); String str = "O+" + bankItem.ID + "|" + bankItem.Quantity + "|" + bankItem.TemplateID + "|" + bankItem.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); character.Send(new ObjectQuantityMessage(item.ID, item.Quantity)); } } else { if (newQua <= 0) { character.InventoryCache.RemoveItem(item); InventoryItemTable.removeItem(item.ID); bankItem.Quantity += item.Quantity; String str = "O+" + bankItem.ID + "|" + bankItem.Quantity + "|" + bankItem.TemplateID + "|" + bankItem.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); character.Send(new ObjectRemoveMessage(guid)); } else { item.Quantity = newQua; bankItem.Quantity += qua; String str = "O+" + bankItem.ID + "|" + bankItem.Quantity + "|" + bankItem.TemplateID + "|" + bankItem.GetStats().ToItemStats(); character.Send(new BankUpdateMessage(str)); character.Send(new ObjectQuantityMessage(item.ID, item.Quantity)); } } //SEND POD MESSAGE ? character.GetClient().Account.Data.Save(); }
internal static void EatOrDrinkItem(ActionModel actionModel, Player perso, Player target, int itemID, int cellID) { InventoryItemModel objPain = InventoryItemTable.getItem(itemID); if (objPain == null) { return; } if (objPain.GetStats().ContainsEffect(EffectEnum.AddVie)) { if (target != null) { if ((target.Life >= target.MaxLife) || (objPain.GetStats().GetEffect(EffectEnum.AddVie).Items <= 0)) { } else { target.Life += objPain.GetStats().GetEffect(EffectEnum.AddVie).Items; if (target.Life > target.MaxLife) { target.Life = target.MaxLife; } target.Send(new AccountStatsMessage(target)); } } else { if ((perso.Life >= perso.MaxLife) || (objPain.GetStats().GetEffect(EffectEnum.AddVie).Items <= 0)) { } else { perso.Life += objPain.GetStats().GetEffect(EffectEnum.AddVie).Items; if (perso.Life > perso.MaxLife) { perso.Life = perso.MaxLife; } perso.Send(new AccountStatsMessage(perso)); perso.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 1, objPain.GetStats().GetEffect(EffectEnum.AddVie).Items.ToString())); } } } if (objPain.GetStats().ContainsEffect(EffectEnum.AddEnergy)) { int val = objPain.GetStats().GetEffect(EffectEnum.AddEnergy).Items; if (target != null) { if (/*target.isDead()) || */ (target.Energy >= 10000) || (val <= 0)) { } else { target.Energy += val; if (target.Energy > 10000) { target.Energy = 10000; } target.Send(new AccountStatsMessage(target)); } } else { if ((perso.Energy >= 10000) || (val <= 0)) { } else { perso.Energy += val; if (perso.Energy > 10000) { target.Energy = 10000; } perso.Send(new AccountStatsMessage(perso)); } } } if (target == null) { perso.setEmoteActive(0); perso.myMap.SendToMap(new MapEatOrDrinkMessage(perso.ActorId)); } else { if (target.isSitted()) { return; } target.myMap.SendToMap(new MapEatOrDrinkMessage(target.ActorId)); if (target.Orientation != 2) { return; } target.Orientation = 3; } }
public void Initialize() { if (myInitialized) { return; } try { BHI = new Dictionary <int, List <BidHouseItem> >(); if (!BidHouseTable.BHITEMS.ContainsKey(this.Guid)) { BidHouseTable.BHITEMS.Add(Guid, new Dictionary <int, List <BidHouseItem> >()); } BHI = BidHouseTable.BHITEMS[Guid]; foreach (String s in Friends.Split(';')) { if (String.IsNullOrEmpty(s)) { continue; } FriendsList.Add(Convert.ToInt32(s.Split('|')[0]), s.Split('|')[1]); } foreach (String s in Ennemys.Split(';')) { if (String.IsNullOrEmpty(s)) { continue; } EnnemyList.Add(Convert.ToInt32(s.Split('|')[0]), s.Split('|')[1]); } foreach (String s in Bank.Split(';')) { if (String.IsNullOrEmpty(s)) { continue; } long id; if (!long.TryParse(s, out id)) { continue; } InventoryItemModel obj = InventoryItemTable.getItem(id); if (obj != null) { bankItems.Add(id, obj); } else { obj = InventoryItemTable.Load(id); if (obj != null) { bankItems.Add(id, obj); } } } foreach (String s in Stables.Split(';')) { if (String.IsNullOrEmpty(s)) { continue; } int id; if (!int.TryParse(s, out id)) { continue; } Mount DD = MountTable.getMount(id); if (DD != null) { Mounts.Add(id, DD); } } } catch (Exception e) { Logger.Error(e); } myInitialized = true; }