Exemple #1
0
 public NpcBuySellExchange(WorldClient client, NpcActionsRecord action, NpcSpawnRecord npc)
 {
     this.Action = action;
     this.Client = client;
     this.Items  = Action.OptionalValue1.ToSplitedList <short>().ConvertAll <ItemRecord>(
         x => ItemRecord.GetItem(x));
     this.Items.RemoveAll(x => x.IsNull());
     this.Npc     = npc;
     this.TokenId = ushort.Parse(action.OptionalValue2);
 }
Exemple #2
0
        public List <ItemRecord> ConvertAllToTemplates()
        {
            List <ItemRecord> records = new List <ItemRecord>();

            foreach (var item in Items)
            {
                records.Add(ItemRecord.GetItem(item.GID));
            }
            return(records);
        }
        public void DissociateLiving(CharacterItemRecord item)
        {
            EffectDice effect = item.FirstEffect <EffectDice>(EffectsEnum.Effect_LivingObjectId);

            if (effect != null)
            {
                var levelEffect    = item.FirstEffect <Effect>(EffectsEnum.Effect_LivingObjectLevel);
                var categoryEffect = item.FirstEffect <Effect>(EffectsEnum.Effect_LivingObjectCategory);
                var moodEffect     = item.FirstEffect <Effect>(EffectsEnum.Effect_LivingObjectMood);
                var skinEffect     = item.FirstEffect <Effect>(EffectsEnum.Effect_LivingObjectSkin);

                var newItem = ItemRecord.GetItem(effect.Const).GetCharacterItem(Character.Id, item.Quantity, false);
                newItem.Effects.Clear(); //RemoveAllEffects
                newItem.AddEffect(levelEffect);
                newItem.AddEffect(categoryEffect);
                newItem.AddEffect(moodEffect);
                newItem.AddEffect(skinEffect);
                newItem.AppearanceId = item.AppearanceId;
                item.RemoveAllEffects(EffectsEnum.Effect_LivingObjectId);
                item.RemoveAllEffects(EffectsEnum.Effect_LivingObjectLevel);
                item.RemoveAllEffects(EffectsEnum.Effect_LivingObjectCategory);
                item.RemoveAllEffects(EffectsEnum.Effect_LivingObjectMood);
                item.RemoveAllEffects(EffectsEnum.Effect_LivingObjectSkin);

                AddItem(newItem);

                if (item.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED)
                {
                    UpdateItemAppearence(item, item.Template.AppearanceId);
                    OnItemModified(item);
                }
                else
                {
                    item.AppearanceId = item.Template.AppearanceId;

                    if (item.PositionEnum == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED)
                    {
                        if (!CheckPassiveStacking(item))
                        {
                            OnItemModified(item);
                        }
                    }
                    else
                    {
                        OnItemModified(item);
                    }
                }

                Character.RefreshActorOnMap();
                item.UpdateElement();
                RefreshWeight();
            }
        }
Exemple #4
0
        public static void AddEventualBidShopGains(WorldClient client)
        {
            var gains = BidShopGainRecord.GetAllCharacterBidShopGains(client.Character.Id);

            foreach (var gain in gains)
            {
                var itemname = ItemRecord.GetItem(gain.ItemGID).Name;
                client.Account.Informations.BankKamas += gain.ItemPrice;
                client.Character.Reply("Banque : + " + gain.ItemPrice + " Kamas (vente de " + gain.ItemQuantity + "  <b>[" + itemname + "]</b> hors jeu).");
                gain.RemoveElement();
                client.Account.Informations.UpdateElement();
            }
        }
        public void ShowBidHouseType(uint itemtype)
        {
            List <uint> gids = new List <uint>();

            foreach (var item in BidShopItems)
            {
                var template = ItemRecord.GetItem(item.GID);
                if (template.TypeId == itemtype && !gids.Contains(item.GID))
                {
                    gids.Add(item.GID);
                }
            }
            Client.Send(new ExchangeTypesExchangerDescriptionForUserMessage(gids));
        }
Exemple #6
0
        public uint GetWeight()
        {
            uint actual = 0;

            foreach (var item in Items)
            {
                var template = ItemRecord.GetItem(item.GID);
                for (int i = 0; i < item.Quantity; i++)
                {
                    actual += (uint)template.Weight;
                }
            }
            return(actual);
        }
Exemple #7
0
        public static bool TrySendBishopGainAdded(int ownerid, ushort itemgid, int quantity, int price)
        {
            var client = WorldServer.Instance.GetOnlineClient(ownerid);

            if (client == null)
            {
                return(false);
            }
            var itemname = ItemRecord.GetItem(itemgid).Name;

            client.Account.Informations.BankKamas += (uint)price;
            client.Character.Reply("Banque : + " + price + " Kamas (vente de " + quantity + "  <b>[" + itemname + "]</b>).");
            return(true);
        }
Exemple #8
0
        public static void AddItems(Character character, NpcReplyRecord reply)
        {
            List <CharacterItemRecord> added = new List <CharacterItemRecord>();

            foreach (var itemId in reply.Value1.FromCSV <ushort>())
            {
                added.Add(ItemRecord.GetItem(itemId).GetCharacterItem(character.Id, 1, false));
            }
            character.Inventory.AddItems(added);
            foreach (var item in added)
            {
                character.OnItemGained(item.GId, 1);
            }
        }
        /// <summary>
        /// Ajoute un Item
        /// </summary>
        /// <param name="gid">Id de l'item</param>
        /// <param name="quantity">Quantitée</param>
        /// <returns></returns>
        public CharacterItemRecord AddItem(ushort gid, uint quantity, bool perfect = false)
        {
            var template = ItemRecord.GetItem(gid);

            if (template != null)
            {
                var obj = template.GetCharacterItem(Character.Id, quantity, perfect);
                base.AddItem(obj);
                return(obj);
            }
            else
            {
                return(null);
            }
        }
Exemple #10
0
        public string getAlmanachRequestString()
        {
            var almanach = AlmanachRecord.GetAlmanachOfTheDay();

            ItemRecord item = ItemRecord.GetItem(almanach.ItemGId);

            if (almanach == null || item == null)
            {
                return("Aucune récompense n'est prévue aujourd'hui, repasse demain.");
            }
            else
            {
                return(string.Format("Rapporte moi {0}x <b>[{1}]</b> et tu auras honoré les merydes de t'avoir donner la vie.", almanach.Quantity, item.Name));
            }
        }
Exemple #11
0
        public StartupActionAddObject GetStartupActionAddObject()
        {
            List <ObjectItemInformationWithQuantity> items = new List <ObjectItemInformationWithQuantity>();

            for (int i = 0; i < GIds.Count; i++)
            {
                ItemRecord item = ItemRecord.GetItem(GIds[i]);

                if (item != null)
                {
                    items.Add(item.GetObjectItemInformationWithQuantity(Quantities[i]));
                }
            }
            return(new StartupActionAddObject(Id, Title, string.Empty, string.Empty, string.Empty, items.ToArray()));
        }
        public static void Initialize()
        {
            foreach (var pet in PetRecord.Pets)
            {
                ItemRecord item = ItemRecord.GetItem(pet.Id);

                if (item != null)
                {
                    item.Effects = new List <EffectInstance>(pet.Effects);
                }
                else
                {
                    logger.Alert("Cannot find pet: " + pet.Id);
                }
            }
        }
        static void RemoveItem(WorldClient client, NpcReplyRecord reply)
        {
            ushort removedGID = ushort.Parse(reply.OptionalValue1);
            string itemName   = ItemRecord.GetItem(removedGID).Name;
            var    item       = client.Character.Inventory.Items.Find(x => x.GID == removedGID);

            if (item != null)
            {
                client.Character.Inventory.RemoveItem(item.UID, 1);
                client.Character.Reply("Vous avez perdu 1 " + itemName);
            }
            else
            {
                client.Character.NotificationError("Unable to delete  item " + itemName + " ... you do not have one, Teleporting to SpawnPoint");
                client.Character.TeleportToSpawnPoint();
            }
        }
        private static void RemoveDrop(WorldClient client, string[] args)
        {
            if (args.Length < 2)
            {
                client.Character.Reply("Remove a drop from a monster");
                client.Character.Reply("» .drops rmdrop|rm|rd $ItemId $MonsterId");
                client.Character.Reply("- <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply("- <b>$MonsterId</b> ⇒ The ID of the monster.");
                return;
            }

            ushort     itemId = ushort.Parse(args[1]);
            ItemRecord item   = ItemRecord.GetItem(itemId);

            if (args.Length != 3)
            {
                int count = 0;
                foreach (MonsterRecord monster in MonsterRecord.Monsters)
                {
                    MonsterDrop drop = monster.Drops.Find(d => d.ItemId == itemId);
                    if (drop != null)
                    {
                        monster.Drops.Remove(drop);
                        count++;
                        client.Character.Reply($" - Removed drop from monster {monster.Name} ({monster.Id}).");

                        monster.UpdateInstantElement();
                    }
                }

                client.Character.Reply($"Removed drop '{item.Name}' ({item.Id}) from {count} monsters.");
            }
            else
            {
                ushort monsterId = ushort.Parse(args[2]);

                MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
                monsterRecord.Drops.RemoveAll(d => d.ItemId == itemId);

                monsterRecord.UpdateInstantElement();

                client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
            }
        }
        private static void UpdateDrop(WorldClient client, string[] args)
        {
            if (args.Length < 6)
            {
                client.Character.Reply("Add a drop to a set of monsters");
                client.Character.Reply("» .drops updatedrop|ud $ItemId $MonsterId $DropRate $MinPP $MinCount $MaxCount");
                client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$DropRate</b> ⇒ The drop percent [0, 100].");
                client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0.");
                client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items.");
                client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items.");

                return;
            }

            ushort itemId    = ushort.Parse(args[1]);
            ushort monsterId = ushort.Parse(args[2]);
            short  dropRate  = short.Parse(args[3]);
            int    pp        = int.Parse(args[4]);
            int    minCount  = int.Parse(args[5]);
            int    maxCount  = int.Parse(args[6]);

            ItemRecord    item          = ItemRecord.GetItem(itemId);
            MonsterRecord monsterRecord = MonsterRecord.GetMonster(monsterId);
            MonsterDrop   monsterDrop   = monsterRecord.Drops.Find(d => d.ItemId == itemId);

            monsterDrop.PercentDropForGrade1 = dropRate;
            monsterDrop.PercentDropForGrade2 = (short)(dropRate + 2);
            monsterDrop.PercentDropForGrade3 = (short)(dropRate + 4);
            monsterDrop.PercentDropForGrade4 = (short)(dropRate + 6);
            monsterDrop.PercentDropForGrade5 = (short)(dropRate + 8);
            monsterDrop.Count           = minCount;
            monsterDrop.DropLimit       = maxCount;
            monsterDrop.ProspectingLock = pp;

            monsterRecord.UpdateInstantElement();

            client.Character.Reply($"Successfully removed drop '{item.Name}' ({item.Id}) from monster '{monsterRecord.Name}' {monsterId}");
        }
Exemple #16
0
        public CharacterItemRecord Add(ushort gid, uint quantity, bool notif = true, bool refresh = true)
        {
            ItemRecord template = ItemRecord.GetItem(gid);

            if (template == null)
            {
                Character.Reply("L'item n'éxiste pas");
                return(null);
            }
            var newObjitem = template.GenerateRandomObjectItem();

            newObjitem.quantity = quantity;
            CharacterItemRecord newItem = new CharacterItemRecord(newObjitem, Character.Id);

            ItemCustomEffects.Instance.Init(newItem);
            Add(newItem, refresh);
            if (notif)
            {
                Character.Reply("Vous avez obtenu " + quantity + " " + template.Name);
            }
            return(newItem);
        }
        public static void HandleMimicryObjectEraseRequest(MimicryObjectEraseRequestMessage message, WorldClient client)
        {
            CharacterItemRecord item = client.Character.Inventory.GetItem(message.hostUID);

            if (message.hostPos != 63)
            {
                client.Character.RefreshActorOnMap();
                client.Character.RefreshStats();
            }
            if (client.Character.Inventory.GetEquipedItems().Contains(item))
            {
                client.Character.Inventory.SetItemPosition(item.UId, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, 1);
            }
            item.RemoveAllEffects(EffectsEnum.Effect_ChangeAppearence1151);
            CharacterItemRecord newItem = (CharacterItemRecord)item.CloneWithoutUID();

            newItem.AppearanceId = ItemRecord.GetItem(newItem.GId).AppearanceId;
            client.Character.Inventory.RemoveItem(item, item.Quantity);
            client.Character.Inventory.AddItem(newItem, 1);
            client.Character.RefreshActorOnMap();
            client.Character.RefreshStats();
        }
Exemple #18
0
 public ItemRecord GetTemplate()
 {
     return(ItemRecord.GetItem(GID));
 }
Exemple #19
0
 /// <summary>
 /// Chargement des Templates.
 /// </summary>
 static MinationLoot()
 {
     MinationItemMiniBossTemplate = ItemRecord.GetItem(MinationMiniBossItemId);
     MinationItemBossTemplate     = ItemRecord.GetItem(MinationBossItemId);
     MinationItemTemplate         = ItemRecord.GetItem(MinationItemId);
 }
        private static void AddDrop(WorldClient client, string[] args)
        {
            if (args.Length < 4)
            {
                client.Character.Reply("Add a drop to a set of monsters");
                client.Character.Reply("» .drops adddrop|ad $ItemId $DropRateG1[,$G2,$G3,G4,G5] $MinPP $MinCount $MaxCount [$MonsterId ...]");
                client.Character.Reply(" - <b>$ItemId</b> ⇒ The ID of the item.");
                client.Character.Reply(" - <b>$DropRateG1</b> ⇒ The drop percent [0, 100]. ");
                client.Character.Reply(" - <b>$G2,3,4,5</b> ⇒ The drop percent [0, 100] for each grade. ");
                client.Character.Reply(" - <b>$MinPP</b> ⇒ The min PP value0.");
                client.Character.Reply(" - <b>$MinCount</b> ⇒ Minimum number of dropped items.");
                client.Character.Reply(" - <b>$MaxCount</b> ⇒ Maximum number of dropped items.");
                client.Character.Reply(" - <b>$MonsterId</b> ⇒ The ID of the monster.");

                return;
            }

            ushort itemId   = ushort.Parse(args[1]);
            string rates    = args[2];
            int    pp       = int.Parse(args[3]);
            int    minCount = int.Parse(args[4]);
            int    maxCount = int.Parse(args[5]);

            string[] ratesSplit = rates.Split(',');
            short    g1         = short.Parse(ratesSplit[0]);
            short    g2         = (short)(g1 + 2);
            short    g3         = (short)(g1 + 4);
            short    g4         = (short)(g1 + 6);
            short    g5         = (short)(g1 + 8);

            if (ratesSplit.Length == 5)
            {
                g2 = short.Parse(ratesSplit[1]);
                g3 = short.Parse(ratesSplit[2]);
                g4 = short.Parse(ratesSplit[3]);
                g5 = short.Parse(ratesSplit[4]);
            }


            ItemRecord item = ItemRecord.GetItem(itemId);

            int nextDropId = MonsterRecord.GetNextDropId();

            for (int i = 6; i < args.Length; i++)
            {
                ushort monsterId = ushort.Parse(args[i]);

                MonsterRecord monster = MonsterRecord.GetMonster(monsterId);

                MonsterDrop drop = new MonsterDrop()
                {
                    ItemId               = itemId,
                    Count                = minCount,
                    DropId               = nextDropId,
                    DropLimit            = maxCount,
                    HasCriteria          = false,
                    PercentDropForGrade1 = g1,
                    PercentDropForGrade2 = g2,
                    PercentDropForGrade3 = g3,
                    PercentDropForGrade4 = g4,
                    PercentDropForGrade5 = g5,
                    ProspectingLock      = pp
                };

                monster.Drops.Add(drop);

                // TODO: check if necessary.
                monster.UpdateInstantElement();

                client.Character.Reply($"Added drop '{item.Name}' ({itemId}) to monster '{monster.Name}' ({monsterId}) with drop rates {g1},{g2},{g3},{g4},{g5} (DropId={nextDropId}).");
                nextDropId++;
            }
        }
        public void PerformCraft(RecipeRecord currentRecipe)
        {
            var obj = new ObjectItem((byte)CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED, currentRecipe.ResultId, ItemRecord.GetItem(currentRecipe.ResultId).GenerateRandomEffect(), CharacterItemRecord.PopNextUID(), 1);

            Client.Character.Inventory.Add(new CharacterItemRecord(obj, Client.Character.Id));
            Client.Send(new ExchangeCraftResultWithObjectDescMessage(2, new ObjectItemNotInContainer(currentRecipe.ResultId, obj.effects, obj.objectUID, 1)));
            Client.Character.AddJobXp(JobId, (ulong)(currentRecipe.ResultLevel * XpRatio));
        }
        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);
                    }
                }
            }
        }
        public static void MinationCommand(string value, WorldClient client)
        {
            var mination = MinationLoot.CreateMinationItem(ItemRecord.GetItem(MinationLoot.MinationBossItemId), 1, client.Character.Id, MonsterRecord.GetMonster(ushort.Parse(value)), 1);

            client.Character.Inventory.AddItem(mination);
        }
        public static void BuySell(Character character, Npc npc, NpcActionRecord action)
        {
            ushort tokenId    = 0;
            bool   priceLevel = false;

            if (action.Value2 != null && action.Value2 != string.Empty)
            {
                var splitted = action.Value2.Split(',');
                tokenId    = ushort.Parse(splitted[0]);
                priceLevel = bool.Parse(splitted[1]);
            }

            ItemRecord[] items = Array.ConvertAll <ushort, ItemRecord>(action.Value1.FromCSV <ushort>().ToArray(), x => ItemRecord.GetItem(x));

            character.OpenNpcShop(npc, items, tokenId, priceLevel);
        }