Ejemplo n.º 1
0
 public void Save()
 {
     this.Friends = "";
     foreach (KeyValuePair <int, String> Key in this.FriendsList)
     {
         this.Friends += Key.Key + "|" + Key.Value + ";";
     }
     this.Ennemys = "";
     foreach (KeyValuePair <int, String> Key in this.EnnemyList)
     {
         this.Ennemys += Key.Key + "|" + Key.Value + ";";
     }
     this.Bank = "";
     foreach (KeyValuePair <long, InventoryItemModel> KeyPair in this.bankItems)
     {
         this.Bank += KeyPair.Key + ";";
         InventoryItemTable.Update(KeyPair.Value);
     }
     this.Stables = "";
     foreach (KeyValuePair <int, Mount> KeyPair in this.Mounts)
     {
         this.Stables += KeyPair.Key + ";";
     }
     AccountDataTable.Update(this);
 }
Ejemplo n.º 2
0
        public override bool MoveItem(Network.WorldClient Client, Database.Models.InventoryItemModel Item, ushort Quantity, bool Add = false)
        {
            if (Add)
            {
                if (Quantity > Item.Quantity)
                {
                    Quantity = (ushort)Item.Quantity;
                }

                InventoryItemModel ObjectEqualize = getSimilarItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Client.Character.InventoryCache.RemoveItem(Item);
                        Mount.Items.Add(Item);
                        str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                        Client.Send(new ObjectRemoveMessage(Item.ID));
                    }
                    else
                    {
                        Client.Character.InventoryCache.UpdateObjectquantity(Item, newQua);
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Mount, Quantity, Stats: Item.Effects);
                        str            = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Client.Character.InventoryCache.RemoveItem(Item);
                    ObjectEqualize.Quantity += Item.Quantity;
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    Client.Send(new ObjectRemoveMessage(Item.ID));
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Client.Character.InventoryCache.UpdateObjectquantity(Item, newQua);
                    ObjectEqualize.Quantity += Quantity;
                    str = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                Client.Send(new MountActualPodMessage(Mount));
                MountTable.Update(Mount);
            }
            else
            {
                if (!Mount.Items.Contains(Item))
                {
                    return(false);
                }
                InventoryItemModel ObjectEqualize = Client.Character.InventoryCache.getSimilarInventoryItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Mount.Items.Remove(Item);
                        if (Client.Character.InventoryCache.TryMergeItem(Item.TemplateID, Item.GetStats().ToItemStats(), Item.Slot, Item.Quantity))
                        {
                            InventoryItemTable.removeItem(Item.ID);
                        }
                        else
                        {
                            Client.Character.InventoryCache.Add(Item);
                        }
                        str = "O-" + Item.ID;
                    }
                    else
                    {
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Client.Character, Quantity, Stats: Item.Effects);
                        Item.Quantity  = newQua;
                        str            = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Mount.Items.Remove(Item);
                    ObjectEqualize.Quantity += Item.Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O-" + Item.ID;
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Item.Quantity            = newQua;
                    ObjectEqualize.Quantity += Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                Client.Send(new MountActualPodMessage(Mount));
                MountTable.Update(Mount);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public override void Execute(WorldClient Client, CommandParameters parameters)
        {
            if (Settings.AppSettings.GetBoolElement("NpcShop.Fm"))
            {
                if ((Program.currentTimeMillis() - Client.lastCheckPoint) < 3000)
                {
                    return;
                }
                if (parameters.Lenght < 2)
                {
                    Client.Send(new ChatGameMessage("Syntaxe invalide : .fm coiffe/cape pa/po/pm", "682B2B"));
                    return;
                }
                ItemSlotEnum Slot = ItemSlotEnum.SLOT_ITEMBAR_13;
                if (parameters.GetParameter(0) == "coiffe")
                {
                    Slot = ItemSlotEnum.SLOT_COIFFE;
                }
                else if (parameters.GetParameter(0) == "cape")
                {
                    Slot = ItemSlotEnum.SLOT_CAPE;
                }
                else
                {
                    Client.Send(new ChatGameMessage("Liste disponnible : coiffe/cape", "682B2B"));
                    return;
                }
                var Effect = EffectEnum.AddPods;
                switch (parameters.GetParameter(1))
                {
                case "pa":
                    Effect = EffectEnum.AddPA;
                    break;

                case "pm":
                    Effect = EffectEnum.AddPM;
                    break;

                case "po":
                    Effect = EffectEnum.AddPO;
                    break;

                default:
                    Client.Send(new ChatGameMessage("Liste disponnible : pa/pm/po", "682B2B"));
                    return;
                }
                var Points = AccountTable.getPoints(Client.Account);
                if (Settings.AppSettings.GetIntElement("NpcShop.FmCost") > Points)
                {
                    Client.Send(new ChatGameMessage("Il vous manque " + (Settings.AppSettings.GetIntElement("NpcShop.FmCost") - Points) + " points pour utiliser ce privilege", "682B2B"));
                    return;
                }
                var Object = Client.Character.InventoryCache.GetItemInSlot(Slot);
                if (Object == null)
                {
                    Client.Send(new ChatGameMessage("Vous ne portez pas de " + parameters.GetParameter(0), "682B2B"));
                    return;
                }
                if (Client.GetFight() != null)
                {
                    Client.Send(new ChatGameMessage("Impossible en combat", "682B2B"));
                    return;
                }
                if (Object.GetStats().GetEffectFM(Effect).Total != 0)
                {
                    Client.Send(new ChatGameMessage("Votre " + parameters.GetParameter(0) + " donne déjà un " + parameters.GetParameter(1), "682B2B"));
                    return;
                }
                if (Effect != EffectEnum.AddPO)
                {
                    if (Object.GetStats().GetEffectFM(EffectEnum.AddPM).Total != 0 || Object.GetStats().GetEffectFM(EffectEnum.AddPA).Total != 0)
                    {
                        Client.Send(new ChatGameMessage("Votre " + parameters.GetParameter(0) + " donne déjà un pa ou un pm", "682B2B"));
                        return;
                    }
                }
                AccountTable.SubstractPoints(Client.Account.ID, Settings.AppSettings.GetIntElement("NpcShop.FmCost"));
                Client.Character.GetStats().UnMerge(Object.GetStats());
                Object.GetStats().AddItem(Effect, 1);
                Client.Character.GetStats().Merge(Object.GetStats());

                Client.Send(new ObjectRemoveMessage(Object.ID));
                Client.Send(new ObjectAddInventoryMessage(Object));
                Client.Send(new FmMoveMessage("KO+" + Object.ID + "|1|" + Object.TemplateID + "|" + Object.GetStats().ToItemStats().Replace(";", "#")));
                Client.Send(new FmCMessage("K;" + Object.TemplateID));
                InventoryItemTable.Update(Object);
                Client.Send(new ChatGameMessage("Votre " + Object.Template.Name + " donne désormais +1" + parameters.GetParameter(1).ToUpper() + " en plus de ses jets habituels !", "FF0000"));
                Client.Send(new AccountStatsMessage(Client.Character));
                Client.lastCheckPoint = Program.currentTimeMillis();
                return;
            }
            else
            {
                Client.Send(new ChatGameMessage("Fromagerie desactivée", "046380"));
            }
        }
Ejemplo n.º 4
0
        public override bool MoveItem(Network.WorldClient Client, Database.Models.InventoryItemModel Item, ushort Quantity, bool Add = false)
        {
            if (!Add)
            {
                if (!Npc.Items.ContainsKey(Item.ID))
                {
                    return(false);
                }
                InventoryItemModel ObjectEqualize = Client.Character.InventoryCache.getSimilarInventoryItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Npc.Items.Remove(Item.ID);
                        if (Client.Character.InventoryCache.TryMergeItem(Item.TemplateID, Item.GetStats().ToItemStats(), Item.Slot, Item.Quantity))
                        {
                            InventoryItemTable.removeItem(Item.ID);
                        }
                        else
                        {
                            Client.Character.InventoryCache.Add(Item);
                        }
                        str = "O-" + Item.ID;
                    }
                    else
                    {
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Client.Character, Quantity, Stats: Item.Effects);
                        Item.Quantity  = newQua;
                        str            = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Npc.Items.Remove(Item.ID);
                    ObjectEqualize.Quantity += Item.Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O-" + Item.ID;
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Item.Quantity            = newQua;
                    ObjectEqualize.Quantity += Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                TaxCollectorTable.Update(Npc);

                Npc.LogItems.Add(Item.ID, Item);
            }
            Client.GetCharacter().AddExperience(Npc.XP);
            Npc.LogXP += Npc.XP;
            Npc.XP     = 0;
            TaxCollectorTable.Update(Npc);

            return(true);
        }
Ejemplo n.º 5
0
        public override void Execute(WorldClient Client, CommandParameters parameters)
        {
            if (Settings.AppSettings.GetBoolElement("NpcShop.FmCac"))
            {
                if ((Program.currentTimeMillis() - Client.lastCheckPoint) < 3000)
                {
                    return;
                }

                var Object = Client.Character.InventoryCache.GetItemInSlot(ItemSlotEnum.SLOT_ARME);
                if (Object == null)
                {
                    Client.Send(new ChatGameMessage("Vous ne portez pas d'arme", "682B2B"));
                    return;
                }
                if (Client.GetFight() != null)
                {
                    Client.Send(new ChatGameMessage("Impossible en combat", "682B2B"));
                    return;
                }
                String answer;

                try
                {
                    answer = parameters.GetParameter(0);
                }
                catch (Exception e)
                {
                    Client.Send(new ChatGameMessage("Action impossible : vous n'avez pas spécifié l'élément (air, feu, terre, eau) qui remplacera les dégats/vols de vies neutres", "682B2B"));
                    return;
                }
                if (!answer.Equals("air") && !answer.Equals("terre") && !answer.Equals("feu") && !answer.Equals("eau"))
                {
                    Client.Send(new ChatGameMessage("Action impossible : l'élément " + answer + " n'existe pas ! (dispo : air, feu, terre, eau)", "682B2B"));
                    return;
                }

                if (!Object.GetStats().GetWeaponEffects().ContainsKey(EffectEnum.VolNeutre) && !Object.GetStats().GetWeaponEffects().ContainsKey(EffectEnum.DamageNeutre))
                {
                    Client.Send(new ChatGameMessage("Action impossible : votre arme n'a pas de dégats neutre", "682B2B"));
                    return;
                }
                try
                {
                    var b = Object.GetStats().GetWeaponEffects().ToArray();
                    foreach (var i in b)
                    {
                        if (i.Key == EffectEnum.DamageNeutre)
                        {
                            if (answer.Equals("air"))
                            {
                                i.Value.EffectType = EffectEnum.DamageAir;
                            }
                            if (answer.Equals("feu"))
                            {
                                i.Value.EffectType = EffectEnum.DamageFeu;
                            }
                            if (answer.Equals("terre"))
                            {
                                i.Value.EffectType = EffectEnum.DamageTerre;
                            }
                            if (answer.Equals("eau"))
                            {
                                i.Value.EffectType = EffectEnum.DamageEau;
                            }
                            Object.GetStats().RemoveWeaponEffects(i.Key);
                            Object.GetStats().AdWeaponEffects(i.Value.EffectType, i.Value);
                        }

                        if (i.Key == EffectEnum.VolNeutre)
                        {
                            if (answer.Equals("air"))
                            {
                                i.Value.EffectType = EffectEnum.VolAir;
                            }
                            if (answer.Equals("feu"))
                            {
                                i.Value.EffectType = EffectEnum.VolFeu;
                            }
                            if (answer.Equals("terre"))
                            {
                                i.Value.EffectType = EffectEnum.VolTerre;
                            }
                            if (answer.Equals("eau"))
                            {
                                i.Value.EffectType = EffectEnum.VolEau;
                            }
                            Object.GetStats().RemoveWeaponEffects(i.Key);
                            Object.GetStats().AdWeaponEffects(i.Value.EffectType, i.Value);
                        }
                    }

                    Client.Send(new ObjectRemoveMessage(Object.ID));
                    Client.Send(new ObjectAddInventoryMessage(Object));
                    Client.Send(new FmMoveMessage("KO+" + Object.ID + "|1|" + Object.TemplateID + "|" + Object.GetStats().ToItemStats().Replace(";", "#")));
                    Client.Send(new FmCMessage("K;" + Object.TemplateID));
                    InventoryItemTable.Update(Object);
                    Client.Send(new ChatGameMessage("Votre " + Object.Template.Name + " a été FM avec succès en" + answer + " !", "FF0000"));
                    Client.Send(new AccountStatsMessage(Client.Character));
                    Client.lastCheckPoint = Program.currentTimeMillis();
                }
                catch (Exception e) { Logger.Error(e); return; }
            }
            else
            {
                Client.Send(new ChatGameMessage("Fromagerie d'Armes desactivée", "046380"));
            }
        }