public override void AddItemToPanel(CharacterItemRecord obj, uint quantity) { if (obj.IsNull()) return; if (quantity == obj.Quantity) // on ajoute toute la quantité d'items { var addedItem = obj.CloneWithUID(); Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); CraftedItems.Add(addedItem); return; } else // on doit cut { var existing = CraftedItems.ExistingItem(obj); if (existing != null) { existing.Quantity += (uint)quantity; Client.Send(new ExchangeObjectModifiedMessage(false, existing.GetObjectItem())); return; } else { var addedItem = obj.CloneWithUID(); addedItem.Quantity = (uint)quantity; Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); CraftedItems.Add(addedItem); return; } } }
private bool CanMoveItem(CharacterItemRecord item, int quantity) { if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED || !item.CanBeExchanged()) { return(false); } CharacterItemRecord exchanged = null; exchanged = this.ExchangedItems.GetItem(item.GId, item.Effects); if (exchanged != null && exchanged.UId != item.UId) { return(false); } exchanged = this.ExchangedItems.GetItem(item.UId); if (exchanged == null) { return(true); } if (exchanged.Quantity + quantity > item.Quantity) { return(false); } else { return(true); } }
public override void MoveItem(uint uid, int quantity) { if (quantity > 0) { CharacterItemRecord item = this.Character.Inventory.GetItem(uid); if (item != null && item.Quantity >= quantity && item.CanBeExchanged()) { BankItemRecord bankItem = item.ToBankItemRecord(this.Character.Client.Account.Id); bankItem.Quantity = (uint)quantity; this.Character.Inventory.RemoveItem(item.UId, (uint)quantity); this.m_items.AddItem(bankItem); } } else { BankItemRecord item = this.m_items.GetItem(uid); uint removedQuantity = (uint)Math.Abs(quantity); if (item != null && item.Quantity >= removedQuantity) { CharacterItemRecord characterItemRecord = item.ToCharacterItemRecord(this.Character.Id); characterItemRecord.Quantity = removedQuantity; this.m_items.RemoveItem(uid, removedQuantity); this.Character.Inventory.AddItem(characterItemRecord); } } }
public override bool UseWeapon(short cellid) { var target = Fight.GetFighter(cellid); CharacterItemRecord weapon = Client.Character.Inventory.GetEquipedWeapon(); if (weapon == null) { UsePunch(cellid); return(true); } WeaponRecord template = WeaponRecord.GetWeapon(weapon.GID); FightSpellCastCriticalEnum critical = RollCriticalDice(template); Fight.TryStartSequence(this.ContextualId, 2); int targetId = target != null ? target.ContextualId : 0; Fight.Send(new GameActionFightCloseCombatMessage(0, this.ContextualId, targetId, cellid, (sbyte)critical, false, weapon.GID)); var effects = template.GetWeaponEffects(critical); this.HandleWeaponEffect(cellid, effects, critical); this.FighterStats.Stats.ActionPoints -= template.ApCost; this.GameActionFightPointsVariation(ActionsEnum.ACTION_CHARACTER_ACTION_POINTS_USE, (short)(-template.ApCost)); Fight.TryEndSequence(2, 0); return(true); }
private static void AttributeAction(WorldClient client, StartupActionRecord action, long characterId) { if (WorldServer.Instance.IsStatus(ServerStatusEnum.ONLINE)) { try { for (int i = 0; i < action.GIds.Count; i++) { ushort gid = action.GIds[i]; uint quantity = action.Quantities[i]; ItemRecord item = ItemRecord.GetItem(gid); var character = client.GetAccountCharacter(characterId); var characterItem = item.GetCharacterItem(characterId, quantity, ITEM_GENERATION_PERFECT); CharacterItemRecord.AddQuietCharacterItem(character, characterItem); } client.Send(new StartupActionFinishedMessage(true, false, action.Id)); } catch (Exception ex) { logger.Error("Unable to attribute action to " + client.Account.Username + " :" + ex); client.Send(new StartupActionFinishedMessage(false, false, action.Id)); } finally { action.RemoveInstantElement(); // How, its dangerous! } } else { client.Disconnect(); } }
public static bool HandleEffects(WorldClient client, CharacterItemRecord item) { bool remove = false; if (!ConditionProvider.ParseAndEvaluate(client,item.GetTemplate().Criteria)) { client.Character.Reply("Vous ne possédez pas les critères nécessaires pour utiliser cet objet."); return remove; } var effects = item.GetEffects(); foreach (var effect in effects) { var function = Functions.ToList().Find(x => x.Key == (EffectsEnum)effect.actionId); if (function.Value != null) { try { if (function.Value(client, effect, item.UID)) remove = true; } catch (Exception ex) { client.Character.NotificationError(ex.Message); } } else { client.Character.NotificationError((EffectsEnum)effect.actionId + " is not handled"); } } return remove; }
public override void AddItemToPanel(CharacterItemRecord obj, uint quantity) { if (quantity == obj.Quantity) { var addedItem = obj.CloneWithUID(); Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); SecondTrader.Send(new ExchangeObjectAddedMessage(true, addedItem.GetObjectItem())); ExchangedItems.Add(addedItem); return; } else { var existing = ExchangedItems.ExistingItem(obj); if (existing != null) { existing.Quantity += (uint)quantity; Client.Send(new ExchangeObjectModifiedMessage(false, existing.GetObjectItem())); SecondTrader.Send(new ExchangeObjectModifiedMessage(true, existing.GetObjectItem())); return; } else { var addedItem = obj.CloneWithUID(); addedItem.Quantity = (uint)quantity; Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); SecondTrader.Send(new ExchangeObjectAddedMessage(true, addedItem.GetObjectItem())); ExchangedItems.Add(addedItem); return; } } }
public override void AddItemToPanel(CharacterItemRecord obj, uint quantity) { if (obj.IsNull()) { return; } if (quantity == obj.Quantity) // on ajoute toute la quantité d'items { var addedItem = obj.CloneWithUID(); Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); CraftedItems.Add(addedItem); return; } else // on doit cut { var existing = CraftedItems.ExistingItem(obj); if (existing != null) { existing.Quantity += (uint)quantity; Client.Send(new ExchangeObjectModifiedMessage(false, existing.GetObjectItem())); return; } else { var addedItem = obj.CloneWithUID(); addedItem.Quantity = (uint)quantity; Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); CraftedItems.Add(addedItem); return; } } }
public void OnCertificateDestroyed(Character character, CharacterItemRecord item) { CharacterMountRecord record = character.Inventory.GetMount(item); record.RemoveElement(); character.Inventory.Mounts.Remove(record); }
private void EquipMount(uint itemUId) { CharacterItemRecord item = Character.Inventory.GetItem(itemUId); CharacterMountRecord mount = Character.Inventory.GetMount(item); Character.Inventory.SetMount(mount, item); }
public static bool HandleEffects(WorldClient client, CharacterItemRecord item) { bool remove = false; if (!ConditionProvider.ParseAndEvaluate(client, item.GetTemplate().Criteria)) { client.Character.Reply("Vous ne possédez pas les critères nécessaires pour utiliser cet objet."); return(remove); } var effects = item.GetEffects(); foreach (var effect in effects) { var function = Functions.ToList().Find(x => x.Key == (EffectsEnum)effect.actionId); if (function.Value != null) { try { if (function.Value(client, effect, item.UID)) { remove = true; } } catch (Exception ex) { client.Character.NotificationError(ex.Message); } } else { client.Character.NotificationError((EffectsEnum)effect.actionId + " is not handled"); } } return(remove); }
public static bool ChangeHeadPotion(Character character, CharacterItemRecord item) { character.Record.AddToRemodelingMask(CharacterRemodelingEnum.CHARACTER_REMODELING_COSMETIC); character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_POPUP, 58); return(true); }
public void Sell(uint uid, uint quantity) { CharacterItemRecord item = this.Character.Inventory.GetItem(uid); if (item != null && item.CanBeExchanged() && item.Quantity >= quantity) { int gained = (int)(((double)item.Template.GetPrice(this.LevelPrice) / (double)10) * quantity); if (gained >= item.Template.GetPrice(this.LevelPrice)) { return; } gained = gained == 0 ? 1 : gained; this.Character.Inventory.RemoveItem(uid, quantity); if (this.TokenId == 0) { this.Character.AddKamas(gained); } else { this.Character.Inventory.AddItem(this.TokenId, (uint)gained); } this.Character.Client.Send(new ExchangeSellOkMessage()); } }
public override void MoveItem(uint uid, int quantity) { if (!this.IsReady) { CharacterItemRecord item = this.Character.Inventory.GetItem(uid); if (item != null && this.CanMoveItem(item, quantity)) { if (this.SecondTrader.GetDialog <PlayerTradeExchange>().IsReady) { this.SecondTrader.GetDialog <PlayerTradeExchange>().Ready(false, 0); } if (quantity > 0) { if (item.Quantity >= quantity) { this.ExchangedItems.AddItem(item, (uint)quantity); } } else { this.ExchangedItems.RemoveItem(item.UId, (uint)(Math.Abs(quantity))); } } } }
protected void Add(ushort gid, uint quantity) { ItemRecord template = ItemRecord.GetItem(gid); CharacterItemRecord item = template.GetCharacterItem(Result.Id, quantity, false); this.Add(item); }
public void Buy(ushort objectGID, uint quantity) { ItemRecord template = ItemRecord.GetItem((int)objectGID); if (TokenId == 0) { if (!Client.Character.RemoveKamas((int)(template.Price * quantity), true)) { return; } } else { CharacterItemRecord item = Client.Character.Inventory.Items.Find(x => x.GID == TokenId); if (item.Quantity < quantity) { Client.Character.ReplyError("Vous ne possedez pas asser de token."); return; } else { Client.Character.Inventory.RemoveItem(item.UID, (uint)(quantity * template.Price)); } } Client.Character.Inventory.Add(objectGID, quantity); Client.Send(new ExchangeBuyOkMessage()); }
public static void DungeonCommand(string value, WorldClient client) { if (client.Character.Level < 15) { client.Character.Reply("Votre niveau est trop faible pour utiliser cette commande..."); return; } if (value == null || !Destinations.ContainsKey(value)) { client.Character.Reply("Le donjon n'existe pas, liste des donjons disponibles:", Color.Blue); client.Character.Reply(Destinations.ToList().ConvertAll <string>(x => x.Key).ToCSV(), Color.Blue); } else { if (client.Character.Inventory.Exist(TokenId, DungeonTokenQuantity)) { int mapId = Destinations[value]; client.Character.Teleport(mapId); CharacterItemRecord item = client.Character.Inventory.GetFirstItem(TokenId, DungeonTokenQuantity); client.Character.Inventory.RemoveItem(item, DungeonTokenQuantity); client.Character.OnItemLost(TokenId, DungeonTokenQuantity); } else { client.Character.Reply("Vous devez posséder " + DungeonTokenQuantity + "x <b>[Ticket Doré]</b>"); } } }
public void Buy(ushort gid, uint quantity) { ItemRecord template = this.ItemToSell.FirstOrDefault(x => x.Id == gid); if (template != null) { if (this.TokenId == 0) { int cost = (int)(template.GetPrice(this.LevelPrice) * quantity); if (!this.Character.RemoveKamas(cost)) { return; } } else { CharacterItemRecord tokenItem = this.Character.Client.Character.Inventory.GetFirstItem(this.TokenId, (uint)(template.GetPrice(this.LevelPrice) * quantity)); if (tokenItem == null) { this.Character.Client.Character.ReplyError("Vous ne possedez pas asser de token."); return; } else { this.Character.Inventory.RemoveItem(tokenItem.UId, (uint)(quantity * template.GetPrice(this.LevelPrice))); } } this.Character.Inventory.AddItem(gid, quantity, this.TokenId != 0); this.Character.Client.Send(new ExchangeBuyOkMessage()); } }
public static BankItemRecord ExistingItem(this List<BankItemRecord> itemlist, CharacterItemRecord item) { var existingItem = itemlist.Find(x => x.GID == item.GID && x.EffectsLinkedToList == item.EffectsLinkedToList); if (existingItem == null) return null; else return existingItem; }
private void OnCraftResulted(CraftResultEnum result, CharacterItemRecord item = null) { if (item != null) Character.Client.Send(new ExchangeCraftResultWithObjectDescMessage((sbyte)result, item.Template.GetObjectItemNotInContainer(item.UId, (uint)Count))); else Character.Client.Send(new ExchangeCraftResultMessage((sbyte)result)); }
public static void InitLivingObject(CharacterItemRecord item, Character character) { if (item.Effects.Count == 3) { LivingObjectRecord livingObjectDatas = LivingObjectRecord.GetLivingObjectDatas(item.GId); if (livingObjectDatas != null) { item.Effects.Clear(); item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectLevel, 361)); item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectCategory, livingObjectDatas.ItemType)); item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectMood, 0)); item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectSkin, 1)); if (livingObjectDatas.Skinnable) { item.AppearanceId = livingObjectDatas.Skins.FirstOrDefault(); } } else { logger.Error("Cannot initialize living object, no template: " + item.Template.Name); } } }
public void AddDroppedItem(CharacterItemRecord record, ushort quantity, ushort cellid) { DropItem item = DropItem.Create(record, quantity, cellid, this); m_droppedItems.Add(item); this.Send(new ObjectGroundAddedMessage(cellid, record.GId)); }
public static CharacterItemRecord AddEffectsAndClone(CharacterItemRecord baseItem, List <ObjectEffect> addedeffects, uint newQuantity) { var newItem = baseItem.CloneAndGetNewUID(); newItem.AddEffects(addedeffects); newItem.Quantity = newQuantity; return(newItem); }
private void UnequipMount(long mountUId) { CharacterMountRecord mount = Character.Inventory.GetMount(mountUId); CharacterItemRecord item = mount.CreateCertificate(Character); Character.Inventory.AddItem(item); Character.Inventory.UnsetMount(); }
public static void CloneCommand(string value, WorldClient client) { CharacterItemRecord weapon = client.Character.Inventory.GetWeapon(); weapon.Mage(EffectsEnum.Effect_DamageFire, 85); client.Character.Inventory.OnItemModified(weapon); }
public static void HandleLivingObjectChangeSkinRequest(LivingObjectChangeSkinRequestMessage message, WorldClient client) { CharacterItemRecord item = client.Character.Inventory.GetItem(message.livingUID); if (item != null) { client.Character.Inventory.ChangeLivingObjectSkin(item, (ushort)message.skinId, (CharacterInventoryPositionEnum)message.livingPosition); } }
public void OnItemRemoved(CharacterItemRecord obj) { var shortcut = GetItemShortcut(obj.UId); if (shortcut != null) { RemoveShortcut(shortcut.SlotId); } }
public static void HandleLivingObjectDissociate(LivingObjectDissociateMessage message, WorldClient client) { CharacterItemRecord item = client.Character.Inventory.GetItem(message.livingUID); if (item != null) { client.Character.Inventory.DissociateLiving(item); } }
public DropItem(CharacterItemRecord record, ushort quantity, ushort cellid, AbstractMapInstance map) { this.Id = map.PopNextDropItemId(); this.Record = record; this.Map = map; this.CellId = cellid; this.Quantity = quantity; Timer = new ActionTimer(900000, Remove, false); PickedUp = false; }
public static void InitPet(CharacterItemRecord item, Character character) { Effect effect = item.Effects.FindAll(x => x.EffectEnum != EffectsEnum.Effect_PetFeedQuantity).Random(); if (effect != null) { item.Effects.Clear(); item.AddEffect(effect); } }
public static void MinationCommand(string value, WorldClient client) { CharacterItemRecord mination = MinationLoot.CreateMinationItem(ItemRecord.GetItem(MinationLoot.MinationBossItemId), 1, client.Character.Id, MonsterRecord.GetMonster(ushort.Parse(value)), 1); client.Character.Inventory.AddItem(mination); }
public CharacterItemRecord GetCharacterItem(long characterId, uint quantity, bool perfect = false) { var effects = Effects.ConvertAll <Effect>(x => x.GenerateEffect(perfect)); effects.RemoveAll(x => x == null); var item = new CharacterItemRecord(characterId, 0, Id, (byte)CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, quantity, effects, AppearanceId); return(item); }
public static void HandleWrapperObjectDissociateRequest(WrapperObjectDissociateRequestMessage message, WorldClient client) { CharacterItemRecord item = client.Character.Inventory.GetItem(message.hostUID); if (item != null) { client.Character.Inventory.DissociateCompatibility(item, (CharacterInventoryPositionEnum)message.hostPos); } }
public override void AddItemToPanel(CharacterItemRecord obj, uint quantity) { if (obj.IsNull()) // il ajoute a son propre panel return; if (quantity == obj.Quantity) { var existing = BankItems.ExistingItem(obj); if (!existing.IsNull()) { existing.Quantity += quantity; SaveTask.UpdateElement(existing); Client.Character.Inventory.RemoveItem(obj.UID,obj.Quantity); Client.Send(new StorageObjectUpdateMessage(existing.GetObjectItem())); return; } else { var newBankItem = obj.GetBankItem(Client.Account.Id); Client.Send(new StorageObjectUpdateMessage(newBankItem.GetObjectItem())); SaveTask.AddElement(newBankItem); Client.Character.Inventory.RemoveItem(obj.UID, obj.Quantity); return; } } else { var existing = BankItems.ExistingItem(obj); if (existing != null) { existing.Quantity += (uint)quantity; Client.Send(new StorageObjectUpdateMessage(existing.GetObjectItem())); Client.Character.Inventory.RemoveItem(obj.UID, quantity); SaveTask.UpdateElement(existing); return; } else { var addedItem = obj.CloneWithUID(); // fonctionne addedItem.Quantity = (uint)quantity; Client.Send(new StorageObjectUpdateMessage(addedItem.GetObjectItem())); SaveTask.AddElement(addedItem.GetBankItem(Client.Account.Id)); Client.Character.Inventory.RemoveItem(obj.UID, quantity); return; } } }
public override void RemoveItemFromPanel(CharacterItemRecord obj, int quantity) { if (obj.Quantity == (uint)-quantity) { Client.Send(new ExchangeObjectRemovedMessage(false, obj.UID)); SecondTrader.Send(new ExchangeObjectRemovedMessage(true, obj.UID)); ExchangedItems.Remove(obj); return; } else { obj.Quantity = (uint)(obj.Quantity + quantity); Client.Send(new ExchangeObjectModifiedMessage(false, obj.GetObjectItem())); SecondTrader.Send(new ExchangeObjectModifiedMessage(true, obj.GetObjectItem())); } }
public virtual void AddItemToPanel(CharacterItemRecord obj, uint quantity) { }
public virtual void RemoveItemFromPanel(CharacterItemRecord obj, int quantity) { }
public override void RemoveItemFromPanel(CharacterItemRecord obj, int quantity) { if (obj.IsNull()) return; if (obj.Quantity == (uint)-quantity) { Client.Send(new ExchangeObjectRemovedMessage(false, obj.UID)); obj = null; return; } else { obj.Quantity = (uint)(obj.Quantity + quantity); Client.Send(new ExchangeObjectModifiedMessage(false, obj.GetObjectItem())); } }
public override void AddItemToPanel(CharacterItemRecord obj, uint quantity) { #region BackgroundCheck ItemRecord template = ItemRecord.GetItem(obj.GID); if (obj.IsNull()) return; #endregion if (template.Type == ItemTypeEnum.SMITHMAGIC_RUNE) { #region Ajout de Rune if (UsedRune != null) // bizzare de devoir faire ça, le client devrait s'en charger { if (obj.Quantity - UsedRune.Quantity <= 0) return; } if (quantity == obj.Quantity) { var addedItem = obj.CloneWithUID(); Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); UsedRune = addedItem; return; } else { if (UsedRune != null) { UsedRune.Quantity += (uint)quantity; Client.Send(new ExchangeObjectModifiedMessage(false, UsedRune.GetObjectItem())); return; } else { var addedItem = obj.CloneWithUID(); addedItem.Quantity = (uint)quantity; Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); UsedRune = addedItem; return; } } #endregion } else { if (quantity == obj.Quantity) { var addedItem = obj.CloneWithUID(); Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); UsedItem = addedItem; return; } else { if (UsedItem == null) { var addedItem = obj.CloneWithUID(); addedItem.Quantity = (uint)quantity; Client.Send(new ExchangeObjectAddedMessage(false, addedItem.GetObjectItem())); UsedItem = addedItem; return; } else { Client.Send(new ExchangeObjectRemovedMessage(false, UsedItem.UID)); UsedItem = null; AddItemToPanel(obj, quantity); } } } }