Example #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.CharDBManager.GetClient().ExecuteQuery("INSERT INTO Skillist (ID,Owner,SkillID,Upgrades,IsPassive) VALUES ('" + c.Character.ID + "','" + db.SkillID + "','" + db.Upgrades + "','" + Convert.ToInt32(IsPassive) + "')");
     skill = db;
 }
Example #2
0
 private void LoadSkillsFromDataTable(DataTable skilllistdata)
 {
     foreach (DataRow row in skilllistdata.Rows)
     {
         DatabaseSkill skill = new DatabaseSkill();
         skill.ID = long.Parse(row["ID"].ToString());
         skill.Upgrades = short.Parse(row["Upgrades"].ToString());
         skill.Character = Character;
         skill.SkillID = short.Parse(row["SkillID"].ToString());
         skill.IsPassive = (bool)row["IsPassive"];
         Skill s = new Skill(skill);
         if (s.IsPassive)
         {
             SkillsPassive.Add(s.ID, s);
         }
         else
         {
             SkillsActive.Add(s.ID, s);
         }
     }
 }
Example #3
0
        public void UseItem(byte slot)
        {
            Item item;
            if (!this.Inventory.InventoryItems.TryGetValue(slot, out item)) //TODO: not sure about return scrolls
            {
                //TODO: send item not found / error occured packet
                return;
            }

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

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

            if (item.ItemInfo.Type == ItemType.Useable) //potion
            {
                if (item.ItemInfo.Class == ItemClass.Scroll) //return scroll
                {
                    RecallCoordinate coord;
                    MapInfo map;
                    if (DataProvider.Instance.RecallCoordinates.TryGetValue(item.ItemInfo.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.ItemInfo.Class == ItemClass.Mount)
                {
                    Handler12.SendItemUsed(this, item);
                  /*  if (this.Mount == null)
                    {

                        if (item.Mount != null)
                        {
                            this.Mount = item.Mount;
                            this.Mount.Food = item.Mount.Food;
                            this.Mounting(item.Mount.Handle,false);
                        }
                        else
                        {
                            //no mount data found
                        }
                    }
                    else
                    {
                        if (this.Mount != null)
                        {
                            UnMount();
                        }
                        else if (this.LastUse.Subtract(DateTime.Now).TotalSeconds >= this.Mount.Cooldown)
                        {
                            Estrella.FiestaLib.Data.Mount mMount = null;
                            if (DataProvider.Instance.MountyByItemID.TryGetValue(item.ID, out mMount))
                            {

                                this.UnMount();
                                this.Mount = mMount;

                                this.Mounting(Mount.Handle,false);
                            }
                        }
                    }*/
                }
                else if (item.ItemInfo.Class == ItemClass.MountFood)
                {
                    if (this.Mount != null)
                    {
                        Mount cMount = null;
                        if (DataProvider.Instance.MountyByItemID.TryGetValue(item.ID, out cMount))
                        {
                            int newfoodcount = this.Mount.Food += 250;
                            if (cMount.Food >= newfoodcount)
                            {
                                this.Mount.Food = (ushort)newfoodcount;
                            }
                            else
                            {
                                this.Mount.Food = cMount.Food;
                            }
                            this.UpdateMountFood();
                        }
                    }
                }
                else if (item.ItemInfo.Class == ItemClass.SkillBook)
                {
                    //TODO: passive skills!
                    ActiveSkillInfo info;
                    if (DataProvider.Instance.ActiveSkillsByName.TryGetValue(item.ItemInfo.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;
                            Character.SkillList.Add(dskill);
                            Program.CharDBManager.GetClient().ExecuteQuery("INSERT INTO Skillist (ID,Owner,SkillID,Upgrades,IsPassive) VALUES ('" + dskill.ID + "','" + dskill.Character.ID + "','" + dskill.SkillID + "','" + dskill.Upgrades + "','" + Convert.ToInt32(dskill.IsPassive) + "')");
                            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.ID, out effects))
                    {
                        Log.WriteLine(LogLevel.Warn, "Missing ItemUseEffect for ID {0}", item.ID);
                        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.ID, effect.Type.ToString());
                                break;
                        }
                    }
                }
            }
            else
            {
                Log.WriteLine(LogLevel.Warn, "Invalid item use.");
            }
        }
Example #4
0
 public Skill(DatabaseSkill skill)
 {
     this.skill = skill;
 }