/// <summary>
        /// Warning !! this method is experimental, there is known issues dues to architectural problems:
        /// the Item wont be initialize by ItemGenerationProvider.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="item"></param>
        /// <param name="quantity"></param>
        public static void AddQuietCharacterItem(CharacterRecord character, CharacterItemRecord item)
        {
            lock (CharactersItems)
            {
                bool isOnline = WorldServer.Instance.IsOnline(character.Id);

                if (isOnline)
                {
                    Logger.Write <CharacterItemRecord>("Cannot attribute " + item.Template.Name + " to " + character.Name + " , the character is online!", ConsoleColor.Red);
                }
                else
                {
                    item.CharacterId = character.Id;
                    var items = CharacterItemRecord.GetCharacterItems(character.Id);
                    var same  = items.FirstOrDefault(x => x.GId == item.GId && x.PositionEnum == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && Inventory.SameEffects(x.Effects, item.Effects));

                    if (same != null)
                    {
                        same.Quantity += item.Quantity;
                        same.UpdateElement();
                    }
                    else
                    {
                        item.UId = ItemUIdPopper.PopUID();
                        item.AddElement();
                    }
                }
            }
        }
Example #2
0
        public static CharacterRecord New(long id, string name, int accountId, ContextActorLook look, sbyte breedId, ushort cosmeticId,
                                          bool sex)
        {
            ushort level  = WorldConfiguration.Instance.StartLevel;
            var    record = new CharacterRecord(id, name, accountId, look, breedId, cosmeticId, sex
                                                , WorldConfiguration.Instance.StartMapId,
                                                WorldConfiguration.Instance.StartCellId, 1, WorldConfiguration.Instance.StartKamas,
                                                ExperienceRecord.GetExperienceForLevel(level).Player, -1
                                                , new List <byte>()
            {
                1
            }, Stats.New(level, breedId), 0, 0
                                                , CharacterAlignment.New(), new List <ushort>(), new List <ushort>(), CharacterJob.New().ToList(),
                                                new List <short>(), new List <CharacterSpell>(), new List <CharacterHumanOption>(), ArenaRank.New(), new List <CharacterShortcut>(), 0, 0, 0, 0);

            return(record);
        }