Exemple #1
0
 public Recipe(ItemTemplate product, List <Ingredient> ingredients, eCraftingSkill requiredSkill, int level, bool makeTemplated)
     : this(product, ingredients)
 {
     RequiredCraftingSkill = requiredSkill;
     Level = level;
     IsForUniqueProduct = !makeTemplated;
 }
Exemple #2
0
 /// <summary>
 /// get a crafting skill by the enum index
 /// </summary>
 /// <param name="skill"></param>
 /// <returns></returns>
 public static AbstractCraftingSkill getSkillbyEnum(eCraftingSkill skill)
 {
     if (skill == eCraftingSkill.NoCrafting)
     {
         return(null);
     }
     return(m_craftingskills[(int)skill - 1] as AbstractCraftingSkill);
 }
        public override bool WhisperReceive(GameLiving source, string str)         // What to do when a player whispers me
        {
            if (!base.WhisperReceive(source, str))
            {
                return(false);
            }
            if (!(source is GamePlayer))
            {
                return(false);
            }
            GamePlayer player = (GamePlayer)source;

            TurnTo(player.X, player.Y); // Turn to face the player

            int iCraftNum = Convert.ToInt32(str);

            if (iCraftNum <= 0 || iCraftNum > 15)
            {
                return(false);
            }


            // 10p
            if (player.GetCurrentMoney() < 100000000)
            {
                SayTo(player, "You need 10p to reach 1000 craft skill");
                return(false);
            }

            eCraftingSkill craftingSkillID = (eCraftingSkill)Convert.ToUInt16(iCraftNum);

            if (player.GetCraftingSkillValue(craftingSkillID) >= 1000)
            {
                SayTo(player, "You are not newbies. Only newbies can use this.");
                return(false);
            }

            player.GainCraftingSkill(craftingSkillID, 1000 - player.GetCraftingSkillValue(craftingSkillID));

            player.RemoveMoney(100000000);
            player.Out.SendUpdateCraftingSkills();
            player.Out.SendUpdatePlayer();
            player.Out.SendUpdatePoints();
            player.Out.SendCharStatsUpdate();
            player.UpdatePlayerStatus();

            player.SaveIntoDatabase();

            SayTo(player, "I raise you skill. Good Bye !");

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Check if the player can begin to salvage an item
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool IsAllowedToBeginWork(GamePlayer player, InventoryItem item)
        {
            if (player.InCombat)
            {
                player.Out.SendMessage("You can't salvage while in combat.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.IsNotLosingDur || item.IsIndestructible)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ".  This item is indestructible"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            // using negative numbers to indicate item cannot be salvaged
            if (item.SalvageYieldID < 0)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Salvage.BeginWork.NoSalvage", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.SlotPosition < (int)eInventorySlot.FirstBackpack || item.SlotPosition > (int)eInventorySlot.LastBackpack)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.BackpackItems"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ".  You do not have the required secondary skill"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.IsCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.EndCurrentAction"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.GetCraftingSkillValue(skill) < (0.75 * CraftingMgr.GetItemCraftLevel(item)))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.NotEnoughSkill", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            return(true);
        }
Exemple #5
0
        /// <summary>
        /// Check if the player own can enchant the item
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <param name="percentNeeded">min 50 max 100</param>
        /// <returns></returns>
        public static bool IsAllowedToBeginWork(GamePlayer player, InventoryItem item, int percentNeeded)
        {
            if (item.IsNotLosingDur)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.CantRepair", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.SlotPosition < (int)eInventorySlot.FirstBackpack || item.SlotPosition > (int)eInventorySlot.LastBackpack)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.BackpackItems"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.CantRepair", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.IsCrafting)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.EndCurrentAction"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (item.Condition >= item.MaxCondition)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.FullyRepaired", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.GetCraftingSkillValue(skill) < ((percentNeeded / 100) * CraftingMgr.GetItemCraftLevel(item)))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.IsAllowedToBeginWork.NotEnoughSkill", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Calculate the chance of sucess
        /// </summary>
        protected static int CalculateSuccessChances(GamePlayer player, InventoryItem item)
        {
            eCraftingSkill skill = CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item);

            if (skill == eCraftingSkill.NoCrafting)
            {
                return(0);
            }

            int chancePercent = (int)((90 / (CraftingMgr.GetItemCraftLevel(item) * 0.5)) * player.GetCraftingSkillValue(skill)) - 80;             // 50% = 10% chance, 100% = 100% chance

            if (chancePercent > 100)
            {
                chancePercent = 100;
            }
            else if (chancePercent < 0)
            {
                chancePercent = 0;
            }

            return(chancePercent);
        }
        /// <summary>
        /// 1.109 items have an additional byte prior to item.Weight
        /// </summary>
        /// <param name="pak"></param>
        /// <param name="item"></param>
        protected override void WriteItemData(GSTCPPacketOut pak, InventoryItem item)
        {
            if (item == null)
            {
                pak.Fill(0x00, 20);                 // 1.109 +1 byte
                return;
            }

            // Create a GameInventoryItem so item will display correctly in inventory window
            item = GameInventoryItem.Create(item);

            pak.WriteByte((byte)item.Level);

            int value1;             // some object types use this field to display count
            int value2;             // some object types use this field to display count

            switch (item.Object_Type)
            {
            case (int)eObjectType.GenericItem:
                value1 = item.Count & 0xFF;
                value2 = (item.Count >> 8) & 0xFF;
                break;

            case (int)eObjectType.Arrow:
            case (int)eObjectType.Bolt:
            case (int)eObjectType.Poison:
                value1 = item.Count;
                value2 = item.SPD_ABS;
                break;

            case (int)eObjectType.Thrown:
                value1 = item.DPS_AF;
                value2 = item.Count;
                break;

            case (int)eObjectType.Instrument:
                value1 = (item.DPS_AF == 2 ? 0 : item.DPS_AF);
                value2 = 0;
                break;                         // unused

            case (int)eObjectType.Shield:
                value1 = item.Type_Damage;
                value2 = item.DPS_AF;
                break;

            case (int)eObjectType.AlchemyTincture:
            case (int)eObjectType.SpellcraftGem:
                value1 = 0;
                value2 = 0;

                /*
                 * must contain the quality of gem for spell craft and think same for tincture
                 */
                break;

            case (int)eObjectType.HouseWallObject:
            case (int)eObjectType.HouseFloorObject:
            case (int)eObjectType.GardenObject:
                value1 = 0;
                value2 = item.SPD_ABS;

                /*
                 * Value2 byte sets the width, only lower 4 bits 'seem' to be used (so 1-15 only)
                 *
                 * The byte used for "Hand" (IE: Mini-delve showing a weapon as Left-Hand
                 * usabe/TwoHanded), the lower 4 bits store the height (1-15 only)
                 */
                break;

            default:
                value1 = item.DPS_AF;
                value2 = item.SPD_ABS;
                break;
            }
            pak.WriteByte((byte)value1);
            pak.WriteByte((byte)value2);

            if (item.Object_Type == (int)eObjectType.GardenObject)
            {
                pak.WriteByte((byte)(item.DPS_AF));
            }
            else
            {
                pak.WriteByte((byte)(item.Hand << 6));
            }
            pak.WriteByte((byte)((item.Type_Damage > 3 ? 0 : item.Type_Damage << 6) | item.Object_Type));

            pak.Fill(0x00, 1);             // 1.109, +1 byte, no clue what this is  - Tolakram

            pak.WriteShort((ushort)item.Weight);
            pak.WriteByte(item.ConditionPercent);        // % of con
            pak.WriteByte(item.DurabilityPercent);       // % of dur
            pak.WriteByte((byte)item.Quality);           // % of qua
            pak.WriteByte((byte)item.Bonus);             // % bonus
            pak.WriteShort((ushort)item.Model);
            pak.WriteByte((byte)item.Extension);
            int flag = 0;

            if (item.Emblem != 0)
            {
                pak.WriteShort((ushort)item.Emblem);
                flag |= (item.Emblem & 0x010000) >> 16;                 // = 1 for newGuildEmblem
            }
            else
            {
                pak.WriteShort((ushort)item.Color);
            }
            //						flag |= 0x01; // newGuildEmblem
            flag |= 0x02;             // enable salvage button

            // Enable craft button if the item can be modified and the player has alchemy or spellcrafting
            eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item);

            switch (skill)
            {
            case eCraftingSkill.ArmorCrafting:
            case eCraftingSkill.Fletching:
            case eCraftingSkill.Tailoring:
            case eCraftingSkill.WeaponCrafting:
                if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) ||
                    m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting))
                {
                    flag |= 0x04;                             // enable craft button
                }
                break;

            default:
                break;
            }

            ushort icon1       = 0;
            ushort icon2       = 0;
            string spell_name1 = "";
            string spell_name2 = "";

            if (item.Object_Type != (int)eObjectType.AlchemyTincture)
            {
                SpellLine chargeEffectsLine = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);

                if (chargeEffectsLine != null)
                {
                    if (item.SpellID > 0 /* && item.Charges > 0*/)
                    {
                        Spell spell = SkillBase.FindSpell(item.SpellID, chargeEffectsLine);
                        if (spell != null)
                        {
                            flag       |= 0x08;
                            icon1       = spell.Icon;
                            spell_name1 = spell.Name;                             // or best spl.Name ?
                        }
                    }
                    if (item.SpellID1 > 0 /* && item.Charges > 0*/)
                    {
                        Spell spell = SkillBase.FindSpell(item.SpellID1, chargeEffectsLine);
                        if (spell != null)
                        {
                            flag       |= 0x10;
                            icon2       = spell.Icon;
                            spell_name2 = spell.Name;                             // or best spl.Name ?
                        }
                    }
                }
            }
            pak.WriteByte((byte)flag);
            if ((flag & 0x08) == 0x08)
            {
                pak.WriteShort((ushort)icon1);
                pak.WritePascalString(spell_name1);
            }
            if ((flag & 0x10) == 0x10)
            {
                pak.WriteShort((ushort)icon2);
                pak.WritePascalString(spell_name2);
            }
            pak.WriteByte((byte)item.Effect);
            string name = item.Name;

            if (item.Count > 1)
            {
                name = item.Count + " " + name;
            }
            if (item.SellPrice > 0)
            {
                if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                {
                    name += "[" + item.SellPrice.ToString() + " BP]";
                }
                else
                {
                    name += "[" + Money.GetShortString(item.SellPrice) + "]";
                }
            }

            if (name.Length > MAX_NAME_LENGTH)
            {
                name = name.Substring(0, MAX_NAME_LENGTH);
            }

            pak.WritePascalString(name);
        }
        //After registering for the OnPlayerEnterWorldFirstTime event this
        //function is called whenever a character enters the game
        public static void DOLTestPlayerEnterWorld(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = sender as GamePlayer;

            if (player == null)
            {
                return;
            }

            if (player.Level < 50)
            {
                foreach (GameClient thisClient in WorldMgr.GetAllPlayingClients())
                {
                    if (thisClient.Player.Realm == player.Realm)
                    {
                        thisClient.Player.Out.SendMessage(player.Name + " <level " + player.Level + ">" + " enter the game.", eChatType.CT_Broadcast, eChatLoc.CL_SystemWindow);
                    }
                }
            }

            if (player.Experience == 0)
            {
                bool bTest = false;
                if (player.Name.Length >= 4)
                {
                    if (player.Name.Substring(0, 4).ToLower() == "test")
                    {
                        bTest = true;
                    }
                }

                // I45, I50

                if (bTest)
                {
                    player.GainExperience(GameLiving.eXPSource.Other, 169999999950);
                }
                else
                {
                    player.GainExperience(GameLiving.eXPSource.Other, 53999999950);
                }


                // CRAFT
                for (int i = 0; i < 15; i++)
                {
                    eCraftingSkill craftingSkillID = (eCraftingSkill)Convert.ToUInt16(i + 1);
                    player.GainCraftingSkill(craftingSkillID, 99);
                }
                player.Out.SendUpdateCraftingSkills();
                player.Out.SendUpdatePlayer();
                player.Out.SendUpdatePoints();
                player.Out.SendCharStatsUpdate();
                player.UpdatePlayerStatus();

                player.SaveIntoDatabase();
            }

            //Now we check if our player is a certain distance from
            //DOLTopia (our selfproclaimed town to show off)
            //If the player is > 10.000 coordinates away or in another region
            //we send a dialog to the player and register a dialog-callback
        }
Exemple #9
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            try
            {
                #region List
                if (args[1].ToLower() == "list")
                {
                    List <string> list  = new List <string>();
                    int           count = 0;
                    foreach (int value in Enum.GetValues(typeof(eCraftingSkill)))
                    {
                        if (++count < 16)                         // get rid of duplicate due to _Last
                        {
                            list.Add(value + " = " + Enum.GetName(typeof(eCraftingSkill), value));
                        }
                    }

                    client.Out.SendCustomTextWindow(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.SkillDescription"), list);
                    return;
                }
                #endregion List

                #region Salvage

                if (args[1].ToLower() == "salvageinfo")
                {
                    List <string> list      = new List <string>();
                    int           salvageID = Convert.ToInt32(args[2]);
                    SalvageYield  salvage   = GameServer.Database.SelectObject <SalvageYield>("ID=" + salvageID);

                    if (salvage == null)
                    {
                        DisplayMessage(client, "SalvageYield ID not found!");
                        return;
                    }

                    ItemTemplate template     = GameServer.Database.FindObjectByKey <ItemTemplate>(salvage.MaterialId_nb);
                    string       materialName = "Not Found!";

                    if (template != null)
                    {
                        materialName = template.Name;
                    }

                    list.Add("SalvageYield ID: " + salvageID);
                    list.Add("     ObjectType: " + (salvage.ObjectType == 0 ? "Unused" : salvage.ObjectType.ToString()));
                    list.Add("   SalvageLevel: " + (salvage.SalvageLevel == 0 ? "Unused" : salvage.SalvageLevel.ToString()));
                    list.Add("       Material: " + materialName + " (" + salvage.MaterialId_nb + ")");
                    list.Add("          Count: " + (salvage.Count == 0 ? "Calculated" : salvage.Count.ToString()));
                    list.Add("          Realm: " + (salvage.Realm == 0 ? "Any" : GlobalConstants.RealmToName((eRealm)salvage.Realm)));
                    list.Add("      PackageID: " + salvage.PackageID);

                    client.Out.SendCustomTextWindow("SalvageYield ID " + salvageID, list);
                    return;
                }

                if (args[1].ToLower() == "salvageadd" || args[1].ToLower() == "salvageupdate")
                {
                    try
                    {
                        int    salvageID = Convert.ToInt32(args[2]);
                        string material  = args[3];
                        int    count     = Convert.ToInt32(args[4]);
                        byte   realm     = 0;
                        string package   = "";

                        if (args.Length > 5)
                        {
                            realm = Convert.ToByte(args[5]);
                        }

                        if (args.Length > 6)
                        {
                            package = args[6];
                        }

                        ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(material);

                        if (template == null)
                        {
                            DisplayMessage(client, "Material id_nb " + material + " not found!");
                            return;
                        }

                        SalvageYield salvage = GameServer.Database.SelectObject <SalvageYield>("ID=" + salvageID);

                        if (args[1].ToLower() == "salvageadd")
                        {
                            if (salvage != null)
                            {
                                DisplayMessage(client, "This SalvageYield ID already exists, use salvageupdate to change it.");
                                return;
                            }

                            salvage = new SalvageYield();
                            if (salvageID > 0)
                            {
                                salvage.ID = salvageID;
                            }

                            salvage.MaterialId_nb = material;
                            salvage.Count         = Math.Max(1, count);
                            salvage.Realm         = realm;

                            if (package == "")
                            {
                                package = client.Player.Name;
                            }

                            salvage.PackageID = package;

                            GameServer.Database.AddObject(salvage);

                            DisplayMessage(client, string.Format("Created SalvageYield ID: {0}, Material: {1}, Count: {2}, Realm: {3}, PackageID: {4}",
                                                                 salvage.ID, salvage.MaterialId_nb, salvage.Count, salvage.Realm, salvage.PackageID));
                        }
                        else
                        {
                            if (salvage == null)
                            {
                                DisplayMessage(client, "SalvageID not found!");
                                return;
                            }

                            if (salvage.PackageID == SalvageYield.LEGACY_SALVAGE_ID)
                            {
                                DisplayMessage(client, "This SalvageYield ID is used for legacy salvage support and can not be updated.");
                                return;
                            }

                            salvage.MaterialId_nb = material;
                            salvage.Count         = Math.Max(1, count);
                            salvage.Realm         = realm;

                            if (string.IsNullOrEmpty(salvage.PackageID) && package == "")
                            {
                                package = client.Player.Name;
                            }

                            if (package != "")
                            {
                                salvage.PackageID = package;
                            }

                            GameServer.Database.SaveObject(salvage);

                            DisplayMessage(client, string.Format("Updated SalvageYield ID: {0}, Material: {1}, Count: {2}, Realm: {3}, PackageID: {4}",
                                                                 salvage.ID, salvage.MaterialId_nb, salvage.Count, salvage.Realm, salvage.PackageID));
                        }
                    }
                    catch
                    {
                        DisplaySyntax(client);
                    }

                    return;
                }

                #endregion Salvage

                GamePlayer target = null;
                if ((client.Player.TargetObject != null) && (client.Player.TargetObject is GamePlayer))
                {
                    target = client.Player.TargetObject as GamePlayer;
                }
                else
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.NoPlayerTarget"));
                    return;
                }

                switch (args[1].ToLower())
                {
                    #region Add
                case "add":
                {
                    eCraftingSkill craftingSkillID = eCraftingSkill.NoCrafting;
                    int            startLevel      = 1;
                    try
                    {
                        craftingSkillID = (eCraftingSkill)Convert.ToUInt16(args[2]);
                        if (args.Length > 3)
                        {
                            startLevel = Convert.ToUInt16(args[3]);
                        }

                        AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(craftingSkillID);
                        if (skill == null)
                        {
                            DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.InvalidSkill"));
                        }
                        else
                        {
                            if (target.AddCraftingSkill(craftingSkillID, startLevel))
                            {
                                target.Out.SendUpdateCraftingSkills();
                                target.SaveIntoDatabase();
                                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.SkillAdded", skill.Name));
                            }
                            else
                            {
                                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.AlreadyHaveSkill", target.Name, skill.Name));
                            }
                        }
                    }
                    catch (Exception)
                    {
                        DisplaySyntax(client);
                    }
                    break;
                }

                    #endregion Add
                    #region Change
                case "change":
                {
                    eCraftingSkill craftingSkillID = eCraftingSkill.NoCrafting;
                    int            amount          = 1;
                    try
                    {
                        craftingSkillID = (eCraftingSkill)Convert.ToUInt16(args[2]);

                        if (args.Length > 3)
                        {
                            amount = Convert.ToInt32(args[3]);
                        }

                        AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(craftingSkillID);
                        if (skill == null)
                        {
                            DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.InvalidSkill"));
                        }
                        else
                        {
                            if (target.GetCraftingSkillValue(craftingSkillID) < 0)
                            {
                                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.NotHaveSkillAddIt", target.Name, skill.Name));
                                return;
                            }

                            if (amount > 0)
                            {
                                target.GainCraftingSkill(craftingSkillID, amount);
                            }
                            else
                            {
                                target.CraftingSkills[craftingSkillID] += amount;
                            }
                            target.Out.SendUpdateCraftingSkills();
                            target.SaveIntoDatabase();
                            DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.SkillChanged", skill.Name));
                            DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Crafting.NowHasSkillPoints", target.Name, target.GetCraftingSkillValue(craftingSkillID), (eCraftingSkill)craftingSkillID));
                        }
                    }
                    catch (Exception)
                    {
                        DisplaySyntax(client);
                        return;
                    }
                    break;
                }

                    #endregion Change
                    #region Default
                default:
                {
                    DisplaySyntax(client);
                    break;
                }
                    #endregion Default
                }
            }
            catch
            {
                DisplaySyntax(client);
            }
        }
 public NextCraftingTierReachedEventArgs(eCraftingSkill skill, int points)
     : base()
 {
     m_skill = skill;
     m_points = points;
 }
Exemple #11
0
        protected override void SendInventorySlotsUpdateRange(ICollection <int> slots, eInventoryWindowType windowType)
        {
            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.InventoryUpdate)))
            {
                pak.WriteByte((byte)(slots == null ? 0 : slots.Count));
                pak.WriteByte((byte)((m_gameClient.Player.IsCloakHoodUp ? 0x01 : 0x00) | (int)m_gameClient.Player.ActiveQuiverSlot));                 //bit0 is hood up bit4 to 7 is active quiver
                pak.WriteByte((byte)m_gameClient.Player.VisibleActiveWeaponSlots);
                pak.WriteByte((byte)windowType);
                if (slots != null)
                {
                    foreach (int updatedSlot in slots)
                    {
                        if (updatedSlot >= (int)eInventorySlot.Consignment_First && updatedSlot <= (int)eInventorySlot.Consignment_Last)
                        {
                            pak.WriteByte((byte)(updatedSlot - (int)eInventorySlot.Consignment_First + (int)eInventorySlot.HousingInventory_First));
                        }
                        else
                        {
                            pak.WriteByte((byte)(updatedSlot));
                        }

                        InventoryItem item = null;
                        item = m_gameClient.Player.Inventory.GetItem((eInventorySlot)updatedSlot);

                        if (item == null)
                        {
                            pak.Fill(0x00, 19);
                            continue;
                        }
                        pak.WriteByte((byte)item.Level);

                        int value1;                         // some object types use this field to display count
                        int value2;                         // some object types use this field to display count
                        switch (item.Object_Type)
                        {
                        case (int)eObjectType.Arrow:
                        case (int)eObjectType.Bolt:
                        case (int)eObjectType.Poison:
                        case (int)eObjectType.GenericItem:
                            value1 = item.Count;
                            value2 = item.SPD_ABS;
                            break;

                        case (int)eObjectType.Thrown:
                            value1 = item.DPS_AF;
                            value2 = item.Count;
                            break;

                        case (int)eObjectType.Instrument:
                            value1 = (item.DPS_AF == 2 ? 0 : item.DPS_AF);
                            value2 = 0;
                            break;                                     // unused

                        case (int)eObjectType.Shield:
                            value1 = item.Type_Damage;
                            value2 = item.DPS_AF;
                            break;

                        case (int)eObjectType.AlchemyTincture:
                        case (int)eObjectType.SpellcraftGem:
                            value1 = 0;
                            value2 = 0;

                            /*
                             * must contain the quality of gem for spell craft and think same for tincture
                             */
                            break;

                        case (int)eObjectType.HouseWallObject:
                        case (int)eObjectType.HouseFloorObject:
                        case (int)eObjectType.GardenObject:
                            value1 = 0;
                            value2 = item.SPD_ABS;

                            /*
                             * Value2 byte sets the width, only lower 4 bits 'seem' to be used (so 1-15 only)
                             *
                             * The byte used for "Hand" (IE: Mini-delve showing a weapon as Left-Hand
                             * usabe/TwoHanded), the lower 4 bits store the height (1-15 only)
                             */
                            break;

                        default:
                            value1 = item.DPS_AF;
                            value2 = item.SPD_ABS;
                            break;
                        }
                        pak.WriteByte((byte)value1);
                        pak.WriteByte((byte)value2);

                        if (item.Object_Type == (int)eObjectType.GardenObject)
                        {
                            pak.WriteByte((byte)(item.DPS_AF));
                        }
                        else
                        {
                            pak.WriteByte((byte)(item.Hand << 6));
                        }
                        pak.WriteByte((byte)((item.Type_Damage > 3 ? 0 : item.Type_Damage << 6) | item.Object_Type));
                        pak.WriteShort((ushort)item.Weight);
                        pak.WriteByte(item.ConditionPercent);                    // % of con
                        pak.WriteByte(item.DurabilityPercent);                   // % of dur
                        pak.WriteByte((byte)item.Quality);                       // % of qua
                        pak.WriteByte((byte)item.Bonus);                         // % bonus
                        pak.WriteShort((ushort)item.Model);
                        pak.WriteByte((byte)item.Extension);
                        int flag = 0;
                        if (item.Emblem != 0)
                        {
                            pak.WriteShort((ushort)item.Emblem);
                            flag |= (item.Emblem & 0x010000) >> 16;                             // = 1 for newGuildEmblem
                        }
                        else
                        {
                            pak.WriteShort((ushort)item.Color);
                        }
                        //						flag |= 0x01; // newGuildEmblem
                        flag |= 0x02;                         // enable salvage button

                        // Enable craft button if the item can be modified and the player has alchemy or spellcrafting
                        eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item);
                        switch (skill)
                        {
                        case eCraftingSkill.ArmorCrafting:
                        case eCraftingSkill.Fletching:
                        case eCraftingSkill.Tailoring:
                        case eCraftingSkill.WeaponCrafting:
                            if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) ||
                                m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting))
                            {
                                flag |= 0x04;                                         // enable craft button
                            }
                            break;

                        default:
                            break;
                        }

                        ushort icon1       = 0;
                        ushort icon2       = 0;
                        string spell_name1 = "";
                        string spell_name2 = "";
                        if (item.Object_Type != (int)eObjectType.AlchemyTincture)
                        {
                            SpellLine chargeEffectsLine = SkillBase.GetSpellLine(GlobalSpellsLines.Item_Effects);

                            if (chargeEffectsLine != null)
                            {
                                if (item.SpellID > 0 /* && item.Charges > 0*/)
                                {
                                    Spell spell = SkillBase.FindSpell(item.SpellID, chargeEffectsLine);
                                    if (spell != null)
                                    {
                                        flag       |= 0x08;
                                        icon1       = spell.Icon;
                                        spell_name1 = spell.Name;                                         // or best spl.Name ?
                                    }
                                }
                                if (item.SpellID1 > 0 /* && item.Charges > 0*/)
                                {
                                    Spell spell = SkillBase.FindSpell(item.SpellID1, chargeEffectsLine);
                                    if (spell != null)
                                    {
                                        flag       |= 0x10;
                                        icon2       = spell.Icon;
                                        spell_name2 = spell.Name;                                         // or best spl.Name ?
                                    }
                                }
                            }
                        }
                        pak.WriteByte((byte)flag);
                        if ((flag & 0x08) == 0x08)
                        {
                            pak.WriteShort((ushort)icon1);
                            pak.WritePascalString(spell_name1);
                        }
                        if ((flag & 0x10) == 0x10)
                        {
                            pak.WriteShort((ushort)icon2);
                            pak.WritePascalString(spell_name2);
                        }
                        pak.WriteByte((byte)item.Effect);
                        string name = item.Name;
                        if (item.Count > 1)
                        {
                            name = item.Count + " " + name;
                        }
                        if (item.SellPrice > 0)
                        {
                            if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                            {
                                name += "[" + item.SellPrice.ToString() + " BP]";
                            }
                            else
                            {
                                name += "[" + Money.GetString(item.SellPrice) + "]";
                            }
                        }
                        pak.WritePascalString(name);
                    }
                }
                SendTCP(pak);
            }
        }
Exemple #12
0
		/// <summary>
		/// get a crafting skill by the enum index
		/// </summary>
		/// <param name="skill"></param>
		/// <returns></returns>
		public static AbstractCraftingSkill getSkillbyEnum(eCraftingSkill skill)
		{
			if (skill == eCraftingSkill.NoCrafting) return null;
			return m_craftingskills[(int)skill - 1] as AbstractCraftingSkill;
		}
Exemple #13
0
 public NextCraftingTierReachedEventArgs(eCraftingSkill skill, int points)
     : base()
 {
     m_skill  = skill;
     m_points = points;
 }