Beispiel #1
0
        public override bool SellItem(WorldClient Client, InventoryItemModel Item, ushort Quantity)
        {
            if (this.myEnd)
            {
                return(false);
            }

            if (Quantity > Item.Quantity)
            {
                Quantity = (ushort)Item.Quantity;
            }

            uint Refund = (uint)Math.Floor((double)ItemTemplateTable.GetTemplate(Item.TemplateID).Price / 10) * Quantity;

            Client.Character.InventoryCache.AddKamas(Refund);
            if (Quantity == Item.Quantity)
            {
                //DatabaseEntities.TryDeleteItem(Item);
                InventoryItemTable.removeItem(Item.ID);
                Client.Send(new ObjectRemoveMessage(Item.ID));
            }
            else
            {
                Client.Character.InventoryCache.UpdateObjectquantity(Item, Item.Quantity - Quantity);
            }

            Client.Send(new AccountStatsMessage(Client.Character));

            return(true);
        }
Beispiel #2
0
 public static string GetItemNameForID(string id)
 {
     DataRow[] rows = ItemTemplateTable.Select(COL_ITEMTEMPLATE_ID + "='" + id + "'");
     if (rows.Length > 0)
     {
         return(Convert.ToString(rows[0][COL_ITEMTEMPLATE_NAME]));
     }
     else
     {
         return(id);
     }
 }
Beispiel #3
0
        public static void Initialize()
        {
            nextPlayerGuid = CharacterTable.getNextGuid();
            nextPlayerGuid++;
            nextItemGuid = InventoryItemTable.getNextGuid();
            nextItemGuid++;
            nextGuildId = GuildTable.getNextGuid();
            nextGuildId++;
            nextMountId = MountTable.getNextGuid();
            nextMountId++;
            nextSpeakingId = SpeakingTable.getNextGuid();
            nextSpeakingId++;
            SpellTable.Load();
            ExpFloorTable.Load();
            MonsterTable.Load();
            ItemTemplateTable.Load();
            ItemTemplateTable.LoadItemActions();
            ItemSetTable.Load();
            DropTable.Load();
            TitleTable.Load();
            IObjectTemplateTable.Load();
            AreaTable.Load();
            AreaSubTable.Load();
            MapTable.Load();
            MapTable.LoadActions();
            CellActionTable.Load();
            MobGroupFixTable.Load();
            BreedTable.Load();
            NpcTemplateTable.Load();
            NpcTemplateTable.LoadPlaces();
            NpcQuestionTable.Load();
            NpcReplyTable.Load();
            ShopNpcTable.Initialize();
            GuildTable.Load();
            CharactersGuildTable.Load();
            TaxCollectorTable.Load();
            PrismeTable.Load();
            BidHouseTable.Load();
            BidHouseTable.LoadItems();
            MountParkTable.Load();
            StaticMountTable.Load();
            MountTable.Load();//TODO Dynamic load of Character mount
            ZaapTable.Load();
            ZaapiTable.Load();

            var Timer = new System.Timers.Timer(1000 * 60 * 25);

            Timer.Elapsed += delegate(object sender, ElapsedEventArgs e)
            {
                Save();
            };
            Timer.Start();
        }
Beispiel #4
0
 public override void Execute(WorldClient client, CommandParameters parameters)
 {
     if (parameters.Lenght > 0)
     {
         int itemID = 0;
         try
         {
             itemID = parameters.GetIntParameter(0);
         }
         catch (FormatException e)
         {
             client.Send(new ConsoleMessage("Parametres invalide !", ConsoleColorEnum.RED));
             return;
         }
         var itemTemplate = ItemTemplateTable.GetTemplate(itemID);
         var quantity     = 1;
         var style        = false;
         if (itemTemplate != null)
         {
             if (parameters.Lenght > 1)
             {
                 try
                 {
                     quantity = parameters.GetIntParameter(1);
                 }
                 catch (FormatException e)
                 {
                     client.Send(new ConsoleMessage("Parametres invalide !", ConsoleColorEnum.RED));
                     return;
                 }
             }
             if (parameters.Lenght > 2)
             {
                 var styleStr = parameters.GetParameter(2).ToLower();
                 if (styleStr == "max")
                 {
                     style = true;
                 }
             }
             var item = InventoryItemTable.TryCreateItem(itemID, client.Character, 1, -1, null, style);
             client.Send(new ConsoleMessage("L'objet <b>'" + itemTemplate.Name + "'</b> a correctement ete generer !", ConsoleColorEnum.GREEN));
         }
         else
         {
             client.Send(new ConsoleMessage("Impossible de trouver l'objet n°" + itemID, ConsoleColorEnum.RED));
         }
     }
     else
     {
         client.Send(new ConsoleMessage("Parametres invalide !", ConsoleColorEnum.RED));
     }
 }
Beispiel #5
0
        public IItemTemplateTable Execute(ItemTemplateID id)
        {
            var v = new ItemTemplateTable();

            using (var r = ExecuteReader(id))
            {
                if (!r.Read())
                {
                    return(null);
                }

                v.ReadValues(r);
            }

            return(v);
        }
Beispiel #6
0
        public void Initialize(String ItemList)
        {
            if (this.myInitialized)
            {
                return;
            }

            this.mySerializedItems = new StringBuilder();


            var Items = new List <ItemTemplateModel>();

            foreach (String s in ItemList.Split(','))
            {
                int templateId;
                if (!int.TryParse(s, out templateId))
                {
                    continue;
                }
                var Template = ItemTemplateTable.GetTemplate(templateId);
                if (Template != null)
                {
                    Items.Add(Template);
                }
            }
            Items.OrderByDescending(x => x.Level);

            foreach (var Template in Items)
            {
                if (Template != null)
                {
                    if (!this.myItems.ContainsKey(Template.ID))
                    {
                        this.mySerializedItems.Append(Template.ID);
                        this.mySerializedItems.Append(';');
                        this.mySerializedItems.Append(Template.StatsTemplate);
                        this.mySerializedItems.Append('|');

                        this.myItems.Add(Template.ID, Template);
                    }
                }
            }


            this.myInitialized = true;
        }
Beispiel #7
0
        private void Initialize()
        {
            if (this.myInitialized)
            {
                return;
            }

            this.mySerializedItems = new StringBuilder();

            if ((this.TemplateCache.Ventes != string.Empty || this.TemplateCache.Ventes != "-1") && this.TemplateCache.Ventes.Contains(','))
            {
                var TemplateIds = this.TemplateCache.Ventes.Split(',');

                foreach (var TemplateId in TemplateIds)
                {
                    try
                    {
                        var Template = ItemTemplateTable.GetTemplate(int.Parse(TemplateId));

                        if (Template != null)
                        {
                            if (!this.myItems.ContainsKey(Template.ID))
                            {
                                this.mySerializedItems.Append(Template.ID);
                                this.mySerializedItems.Append(';');
                                this.mySerializedItems.Append(Template.StatsTemplate);
                                this.mySerializedItems.Append('|');

                                this.myItems.Add(Template.ID, Template);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Fail to Int::Parse " + TemplateId);
                    }
                }
            }

            this.myInitialized = true;
        }
Beispiel #8
0
        public void Initialize()
        {
            if (myInitialized)
            {
                return;
            }

            Items = new List <ItemTemplateModel>();

            foreach (String str in StringItems.Split(','))
            {
                try
                {
                    Items.Add(ItemTemplateTable.GetTemplate(int.Parse(str)));
                }
                catch (NullReferenceException e) { Logger.Error("Item " + str + " Introuvable dans la panoplie " + ID); }
                catch (FormatException e) { Logger.Error("Echoue lors de la convertion de l'item " + str); }
            }

            Stats = new List <GenericStats>();
            foreach (String str in StringBonus.Split(';'))
            {
                var stats = new GenericStats();

                foreach (String str2 in str.Split(','))
                {
                    try
                    {
                        String[] infos = str2.Split(':');
                        if (infos.Length < 2)
                        {
                            continue;
                        }
                        stats.AddItem((EffectEnum)int.Parse(infos[0], NumberStyles.Number, CultureInfo.InvariantCulture), int.Parse(infos[1], NumberStyles.Number, CultureInfo.InvariantCulture));
                    }
                    catch (FormatException e) { Logger.Error(str2.Split(':')[0] + "|" + str2.Split(':')[1] + ""); }
                }
                Stats.Add(stats);
            }
            myInitialized = true;
        }
Beispiel #9
0
        void RecvStartShopping(IIPSocket conn, BitStream r)
        {
            var shopOwnerIndex = r.ReadMapEntityIndex();
            var canBuy         = r.ReadBool();
            var name           = r.ReadString();
            var itemCount      = r.ReadByte();

            var items = new IItemTemplateTable[itemCount];

            for (var i = 0; i < itemCount; i++)
            {
                var value = new ItemTemplateTable();
                value.ReadState(r);
                items[i] = value;
            }

            var shopOwner = Map.GetDynamicEntity(shopOwnerIndex);
            var shopInfo  = new ShopInfo <IItemTemplateTable>(shopOwner, name, canBuy, items);

            GameplayScreen.ShopForm.DisplayShop(shopInfo);
        }
Beispiel #10
0
        public String SerializeStringItemID(int templateID)
        {
            int type = ItemTemplateTable.GetTemplate(templateID).Type;

            return(Categories[type].Items[templateID].SerializeLinePerObejct());
        }
/// <summary>
/// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
/// object's properties. The database column's name is used to as the key, so the value
/// will not be found if any aliases are used or not all columns were selected.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this ItemTemplateTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("action_display_id");

            source.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("description");

            source.Description = (System.String)(System.String) dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("equipped_body");

            source.EquippedBody = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("graphic");

            source.Graphic = (NetGore.GrhIndex)(NetGore.GrhIndex) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("height");

            source.Height = (System.Byte)(System.Byte) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("hp");

            source.HP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("mp");

            source.MP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("name");

            source.Name = (System.String)(System.String) dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("range");

            source.Range = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("stat_agi");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_defence");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_int");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhit");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhp");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxmp");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_minhit");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_agi");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_int");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_str");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_str");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("type");

            source.Type = (DemoGame.ItemType)(DemoGame.ItemType) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("value");

            source.Value = (System.Int32)(System.Int32) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("weapon_type");

            source.WeaponType = (DemoGame.WeaponType)(DemoGame.WeaponType) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("width");

            source.Width = (System.Byte)(System.Byte) dataRecord.GetByte(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this ItemTemplateTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "action_display_id":
                    source.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));
                    break;


                case "description":
                    source.Description = (System.String)(System.String) dataRecord.GetString(i);
                    break;


                case "equipped_body":
                    source.EquippedBody = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));
                    break;


                case "graphic":
                    source.Graphic = (NetGore.GrhIndex)(NetGore.GrhIndex) dataRecord.GetUInt16(i);
                    break;


                case "height":
                    source.Height = (System.Byte)(System.Byte) dataRecord.GetByte(i);
                    break;


                case "hp":
                    source.HP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);
                    break;


                case "id":
                    source.ID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID) dataRecord.GetUInt16(i);
                    break;


                case "mp":
                    source.MP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);
                    break;


                case "name":
                    source.Name = (System.String)(System.String) dataRecord.GetString(i);
                    break;


                case "range":
                    source.Range = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);
                    break;


                case "stat_agi":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_defence":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_int":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxhit":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxhp":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxmp":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_minhit":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_agi":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_int":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_str":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_str":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "type":
                    source.Type = (DemoGame.ItemType)(DemoGame.ItemType) dataRecord.GetByte(i);
                    break;


                case "value":
                    source.Value = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;


                case "weapon_type":
                    source.WeaponType = (DemoGame.WeaponType)(DemoGame.WeaponType) dataRecord.GetByte(i);
                    break;


                case "width":
                    source.Width = (System.Byte)(System.Byte) dataRecord.GetByte(i);
                    break;
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
        /// object's properties. Unlike ReadValues(), this method not only doesn't require
        /// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
        /// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
        /// Because of this, you need to be careful when using this method because values
        /// can easily be skipped without any indication.
        /// </summary>
        /// <param name="source">The object to add the extension method to.</param>
        /// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this ItemTemplateTable source, IDataRecord dataRecord)
        {
            for (var i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "action_display_id":
                    source.ActionDisplayID =
                        (Nullable <ActionDisplayID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));
                    break;

                case "description":
                    source.Description = dataRecord.GetString(i);
                    break;

                case "equipped_body":
                    source.EquippedBody = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));
                    break;

                case "graphic":
                    source.Graphic = (GrhIndex)dataRecord.GetUInt16(i);
                    break;

                case "height":
                    source.Height = dataRecord.GetByte(i);
                    break;

                case "hp":
                    source.HP = dataRecord.GetInt16(i);
                    break;

                case "id":
                    source.ID = (ItemTemplateID)dataRecord.GetUInt16(i);
                    break;

                case "mp":
                    source.MP = dataRecord.GetInt16(i);
                    break;

                case "name":
                    source.Name = dataRecord.GetString(i);
                    break;

                case "range":
                    source.Range = dataRecord.GetUInt16(i);
                    break;

                case "stat_agi":
                    source.SetStat(StatType.Agi, dataRecord.GetInt16(i));
                    break;

                case "stat_defence":
                    source.SetStat(StatType.Defence, dataRecord.GetInt16(i));
                    break;

                case "stat_int":
                    source.SetStat(StatType.Int, dataRecord.GetInt16(i));
                    break;

                case "stat_maxhit":
                    source.SetStat(StatType.MaxHit, dataRecord.GetInt16(i));
                    break;

                case "stat_maxhp":
                    source.SetStat(StatType.MaxHP, dataRecord.GetInt16(i));
                    break;

                case "stat_maxmp":
                    source.SetStat(StatType.MaxMP, dataRecord.GetInt16(i));
                    break;

                case "stat_minhit":
                    source.SetStat(StatType.MinHit, dataRecord.GetInt16(i));
                    break;

                case "stat_req_agi":
                    source.SetReqStat(StatType.Agi, dataRecord.GetInt16(i));
                    break;

                case "stat_req_int":
                    source.SetReqStat(StatType.Int, dataRecord.GetInt16(i));
                    break;

                case "stat_req_str":
                    source.SetReqStat(StatType.Str, dataRecord.GetInt16(i));
                    break;

                case "stat_str":
                    source.SetStat(StatType.Str, dataRecord.GetInt16(i));
                    break;

                case "type":
                    source.Type = (ItemType)dataRecord.GetByte(i);
                    break;

                case "value":
                    source.Value = dataRecord.GetInt32(i);
                    break;

                case "weapon_type":
                    source.WeaponType = (WeaponType)dataRecord.GetByte(i);
                    break;

                case "width":
                    source.Width = dataRecord.GetByte(i);
                    break;
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
        /// object's properties. The database column's name is used to as the key, so the value
        /// will not be found if any aliases are used or not all columns were selected.
        /// </summary>
        /// <param name="source">The object to add the extension method to.</param>
        /// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this ItemTemplateTable source, IDataRecord dataRecord)
        {
            Int32 i;

            i = dataRecord.GetOrdinal("action_display_id");

            source.ActionDisplayID = (Nullable <ActionDisplayID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("description");

            source.Description = dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("equipped_body");

            source.EquippedBody = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("graphic");

            source.Graphic = (GrhIndex)dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("height");

            source.Height = dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("hp");

            source.HP = dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (ItemTemplateID)dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("mp");

            source.MP = dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("name");

            source.Name = dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("range");

            source.Range = dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("stat_agi");

            source.SetStat(StatType.Agi, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_defence");

            source.SetStat(StatType.Defence, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_int");

            source.SetStat(StatType.Int, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhit");

            source.SetStat(StatType.MaxHit, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhp");

            source.SetStat(StatType.MaxHP, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxmp");

            source.SetStat(StatType.MaxMP, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_minhit");

            source.SetStat(StatType.MinHit, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_agi");

            source.SetReqStat(StatType.Agi, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_int");

            source.SetReqStat(StatType.Int, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_str");

            source.SetReqStat(StatType.Str, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_str");

            source.SetStat(StatType.Str, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("type");

            source.Type = (ItemType)dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("value");

            source.Value = dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("weapon_type");

            source.WeaponType = (WeaponType)dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("width");

            source.Width = dataRecord.GetByte(i);
        }
Beispiel #15
0
        public void MoveItem(int Guid, ItemSlotEnum Slot, bool Packet, int Quantity = 1)
        {
            var Item = this.get(Guid);

            // Item inexistant
            if (Item == null)
            {
                return;
            }

            // Meme endroit ?
            if (Item.Slot == Slot)
            {
                return;
            }

            // Veu equiper un item
            if (Slot > ItemSlotEnum.SLOT_INVENTAIRE && Slot <= ItemSlotEnum.SLOT_BOUCLIER)
            {
                if (Item.Template.Type == 113)
                {
                    if (this.GetItemInSlot(Slot) == null)
                    {
                        this.Player.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 161));
                        return;
                    }
                    if (Item.Quantity > 1)
                    {
                        if (Quantity > Item.Quantity)
                        {
                            Quantity = Item.Quantity;
                        }
                        int newQ = Item.Quantity - Quantity;
                        if (newQ > 0)
                        {
                            InventoryItemTable.TryCreateItem(Item.TemplateID, this.Player, newQ, -1, Item.GetStats().ToItemStats());
                            UpdateObjectquantity(Item, Quantity);
                        }
                    }
                    var EquipedItemB = this.GetItemInSlot(Slot);

                    var SpeakingTestItem = SpeakingTable.Cache.Values.FirstOrDefault(x => x != null && x.LinkedItem == Item.ID && x.Associated == 0);

                    if (SpeakingTestItem != null)
                    {
                        EquipedItemB.SpeakingID     = SpeakingTestItem.ID;
                        SpeakingTestItem.Stats      = EquipedItemB.GetStats().ToItemStats();
                        SpeakingTestItem.LinkedItem = EquipedItemB.ID;
                        SpeakingTestItem.Associated = 1;
                        remove(Item.ID);
                        Player.Send(new ObjectRemoveMessage(Item.ID));
                        Player.Send(new ObjectRefreshMessage(EquipedItemB));
                        Player.myMap.SendToMap(new ObjectActualiseMessage(Player));
                        if (Player.Client.GetFight() != null)
                        {
                            Player.Client.GetFight().SendToFight(new ObjectActualiseMessage(Player));
                        }
                        return;
                    }

                    var    ID        = DatabaseCache.nextSpeakingId++;
                    String Date      = DateTime.Now.Month + "" + DateTime.Now.Day;
                    String InterDate = (DateTime.Now.Month + 3) + "" + DateTime.Now.Day;
                    String Time      = DateTime.Now.Hour + "" + DateTime.Now.Minute;

                    Speaking newItem = new Speaking(ID, DateTime.Now.Year, int.Parse(Date), int.Parse(Time), 1, 1, EquipedItemB.Template.Type, EquipedItemB.ID, 0, DateTime.Now.Year, int.Parse(InterDate), int.Parse(Time), DateTime.Now.Year, int.Parse(Date), int.Parse(Time), 1, Item.TemplateID, Item.ID, EquipedItemB.GetStats().ToItemStats());
                    SpeakingTable.New(newItem);
                    EquipedItemB.SpeakingID = ID;
                    remove(Item.ID);
                    Player.Send(new ObjectRemoveMessage(Item.ID));
                    Player.Send(new ObjectRefreshMessage(EquipedItemB));
                    Player.myMap.SendToMap(new ObjectActualiseMessage(Player));
                    if (Player.Client.GetFight() != null)
                    {
                        Player.Client.GetFight().SendToFight(new ObjectActualiseMessage(Player));
                    }
                    return;
                }

                // Il peu placer l'item dans le slot desiré ?
                if (!ItemTemplateModel.CanPlaceInSlot(ItemTemplateTable.GetTemplate(Item.TemplateID).ItemType, Slot))
                {
                    return;
                }

                // Level requis
                if (ItemTemplateTable.GetTemplate(Item.TemplateID).Level > Player.Level)
                {
                    if (Packet)
                    {
                        Player.Send(new ObjectMoveFailMessage(ObjectMoveFailReasonEnum.REASON_LEVEL_REQUIRED));
                    }
                    return;
                }

                if (!ItemTemplateTable.GetTemplate(Item.TemplateID).Criterions.Equals("") && !ConditionParser.validConditions(this.Player, ItemTemplateTable.GetTemplate(Item.TemplateID).Criterions))
                {
                    this.Player.Send(new ImMessage("119|43"));
                    return;
                }

                var EquipedItem = this.GetItemInSlot(Slot);

                // Si item deja equipé dans le slot
                if (EquipedItem != null)
                {
                    // Deplacement dans l'inventaire
                    Player.GetStats().UnMerge(EquipedItem.GetStats());
                    this.Player.Life    -= EquipedItem.GetStats().GetTotal(EffectEnum.AddVitalite);
                    EquipedItem.Position = -1;
                    Player.Send(new ObjectMoveSucessMessage(EquipedItem.ID, -1));
                }

                // Template deja equipé
                if (this.HasTemplateEquiped(Item.TemplateID))
                {
                    if (Packet)
                    {
                        Player.Send(new ObjectMoveFailMessage(ObjectMoveFailReasonEnum.REASON_ALREADY_EQUIPED));
                    }
                    return;
                }

                /*var simlarItem = this.getSimilarInventoryItem(Item);
                 * if (simlarItem != null)
                 * {
                 *  this.UpdateObjectquantity(simlarItem, simlarItem.Quantity + Item.Quantity);
                 *  remove(Item.ID);
                 *  InventoryItemTable.removeItem(Item.ID);
                 *  Player.Send(new ObjectRemoveMessage(Item.ID));
                 *
                 * }
                 * else*/
                if (Item.Quantity > 1)
                {
                    var NewItem = InventoryItemTable.TryCreateItem(Item.TemplateID, this.Player, 1, (short)Slot, Item.Effects);
                    this.UpdateObjectquantity(Item, Item.Quantity - 1);
                }
                else
                {
                    // On modifi la position et fusionne les stats
                    Item.Position = (short)Slot;
                    Player.Send(new ObjectMoveSucessMessage(Item.ID, (short)Slot));
                    Player.Send(new ObjectMoveSucessMessage(Item.ID, (short)Item.Position));
                }

                if (GetItemInSlot(ItemSlotEnum.SLOT_ARME) != null)
                {
                    Player.Send(new ObjectTaskMessage(-1));
                }

                Player.GetStats().Merge(Item.GetStats());
                this.Player.Life += Item.GetStats().GetTotal(EffectEnum.AddVitalite);
                this.Player.Life += Item.GetStats().GetTotal(EffectEnum.AddVie);
                if (Packet)
                {
                    Player.Client.Send(new AccountStatsMessage(Player));
                    Player.myMap.SendToMap(new ObjectActualiseMessage(Player));
                    if (Player.Client.GetFight() != null)
                    {
                        Player.Client.GetFight().SendToFight(new ObjectActualiseMessage(Player));
                    }
                }
            }
            else
            {
                var NeedActualise = false;

                // Si l'item est equipé, on deduit les stats
                if (Item.Slot > ItemSlotEnum.SLOT_INVENTAIRE && Item.Slot < ItemSlotEnum.SLOT_BOUCLIER)
                {
                    // Retire les stats
                    Player.GetStats().UnMerge(Item.GetStats());
                    this.Player.Life -= Item.GetStats().GetTotal(EffectEnum.AddVitalite);
                    this.Player.Life -= Item.GetStats().GetTotal(EffectEnum.AddVie);
                    if (Player.Life <= 0)
                    {
                        Player.Life = 1;
                    }
                    if (Packet)
                    {
                        Player.Client.Send(new AccountStatsMessage(this.Player));
                        NeedActualise = true;
                    }
                }

                // On tente de fusionner
                if (!this.TryMergeItem(Item.TemplateID, Item.Effects, Slot, Item.Quantity, Item))
                {
                    Item.Position = (short)Slot;
                    if (Packet)
                    {
                        Player.Send(new ObjectMoveSucessMessage(Item.ID, (short)Item.Position));
                    }
                }

                if (NeedActualise)
                {
                    Player.myMap.SendToMap(new ObjectActualiseMessage(Player));
                    if (Player.Client.GetFight() != null)
                    {
                        Player.Client.GetFight().SendToFight(new ObjectActualiseMessage(Player));
                    }
                }
            }
            onMoveItem(Item);
        }