Ejemplo n.º 1
0
 public Skill(ZoneCharacter c, ushort ID)
 {
     DatabaseSkill db = new DatabaseSkill();
     db.Owner = c.ID;
     db.SkillID = (short)ID;
     db.Upgrades = 0;
     db.IsPassive = false;
     db.Character = c.character;
     Program.Entity.AddToDatabaseSkills(db);
     Program.Entity.SaveChanges();
     _skill = db;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DatabaseSkills EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDatabaseSkills(DatabaseSkill databaseSkill)
 {
     base.AddObject("DatabaseSkills", databaseSkill);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new DatabaseSkill object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="owner">Initial value of the Owner property.</param>
 /// <param name="skillID">Initial value of the SkillID property.</param>
 /// <param name="upgrades">Initial value of the Upgrades property.</param>
 /// <param name="isPassive">Initial value of the IsPassive property.</param>
 public static DatabaseSkill CreateDatabaseSkill(global::System.Int32 id, global::System.Int32 owner, global::System.Int16 skillID, global::System.Int16 upgrades, global::System.Boolean isPassive)
 {
     DatabaseSkill databaseSkill = new DatabaseSkill();
     databaseSkill.ID = id;
     databaseSkill.Owner = owner;
     databaseSkill.SkillID = skillID;
     databaseSkill.Upgrades = upgrades;
     databaseSkill.IsPassive = isPassive;
     return databaseSkill;
 }
Ejemplo n.º 4
0
        public void UseItem(sbyte slot)
        {
            Item item;
            if (!InventoryItems.TryGetValue(slot, out item)) //TODO: not sure about return scrolls
            {
                //TODO: send item not found / error occured packet
                return;
            }

            if (item.Info.Level > Level)
            {
                Handler12.SendItemUsed(this, item, 1800);
                return;
            }

            if (((uint)item.Info.Jobs & (uint)Job) == 0)
            {
                Handler12.SendItemUsed(this, item, 1801);
                return;
            }

            if (item.Info.Type == ItemType.Useable) //potion
            {
                if (item.Info.Class == ItemClass.ReturnScroll) //return scroll
                {
                    RecallCoordinate coord;
                    MapInfo map;
                    if (DataProvider.Instance.RecallCoordinates.TryGetValue(item.Info.InxName, out coord)
                        && (map = DataProvider.Instance.MapsByID.Values.First(m => m.ShortName == coord.MapName)) != null)
                    {
                        Handler12.SendItemUsed(this, item); //No idea what this does, but normally it's sent.
                        UseOneItemStack(item);
                        ChangeMap(map.ID, coord.LinkX, coord.LinkY); //TODO: do this properly via world later.

                    }
                    else
                    {
                        Handler12.SendItemUsed(this, item, 1811);
                    }
                }
                else if (item.Info.Class == ItemClass.Skillbook)
                {
                    //TODO: passive skills!
                    ActiveSkillInfo info;
                    if (DataProvider.Instance.ActiveSkillsByName.TryGetValue(item.Info.InxName, out info))
                    {
                        if (SkillsActive.ContainsKey(info.ID))
                        {
                            Handler12.SendItemUsed(this, item, 1811);
                            //character has this skill already
                        }
                        else
                        {
                            Handler12.SendItemUsed(this, item);
                            UseOneItemStack(item);
                            DatabaseSkill dskill = new DatabaseSkill();
                            dskill.Character = character;
                            dskill.SkillID = (short)info.ID;
                            dskill.IsPassive = false;
                            dskill.Upgrades = 0;
                            Program.Entity.AddToDatabaseSkills(dskill);
                            Save();
                            Skill skill = new Skill(dskill);
                            SkillsActive.Add(skill.ID, skill);
                            Handler18.SendSkillLearnt(this, skill.ID);
                            //TODO: broadcast the animation of learning to others
                        }
                    }
                    else
                    {
                        Log.WriteLine(LogLevel.Error, "Character tried to use skillbook but ActiveSkill does not exist.");
                        Handler12.SendItemUsed(this, item, 1811);
                    }
                }
                else
                {
                    ItemUseEffectInfo effects;
                    if (!DataProvider.Instance.ItemUseEffects.TryGetValue(item.ItemID, out effects))
                    {
                        Log.WriteLine(LogLevel.Warn, "Missing ItemUseEffect for ID {0}", item.ItemID);
                        Handler12.SendItemUsed(this, item, 1811);
                        return;
                    }

                    Handler12.SendItemUsed(this, item); //No idea what this does, but normally it's sent.
                    UseOneItemStack(item);
                    foreach (ItemEffect effect in effects.Effects)
                    {
                        switch (effect.Type)
                        {
                            case ItemUseEffectType.AbState: //TOOD: add buffs for itemuse
                                continue;

                            case ItemUseEffectType.HP:
                                HealHP(effect.Value);
                                break;

                            case ItemUseEffectType.SP:
                                HealSP(effect.Value);
                                break;
                            case ItemUseEffectType.ScrollTier:

                                break;

                            default:
                                Log.WriteLine(LogLevel.Warn, "Invalid item effect for ID {0}: {1}", item.ItemID, effect.Type.ToString());
                                break;
                        }
                    }
                }
            }
            else
            {
                Log.WriteLine(LogLevel.Warn, "Invalid item use.");
            }
        }
Ejemplo n.º 5
0
 public Skill(DatabaseSkill skill)
 {
     _skill = skill;
 }