Beispiel #1
0
 public void NewSkill(ActorPC pc, SkillType type, SkillInfo skill)
 {
 }
Beispiel #2
0
 public void UpdateSkill(ActorPC pc, SkillType type, SkillInfo skill)
 {
 }
Beispiel #3
0
        private void LoadSkills( ref ActorPC aChar )
        {
            string sqlstr;
            int i;
            DataRowCollection result = null;
            sqlstr = "SELECT * FROM  skills  WHERE charID=" + aChar.charID + "";
            try
            {
                result = db.GetDataTable(sqlstr).Rows;
            }
            catch (Exception ex)
            {
                Logger.ShowError( " can't get skills from database" + ex.Message, null );
                Logger.ShowError( ex, null );
            }
            aChar.BattleSkills = new Dictionary<uint, SkillInfo>();
            aChar.LivingSkills = new Dictionary<uint, SkillInfo>();
            aChar.SpecialSkills = new Dictionary<uint, SkillInfo>();
            aChar.InactiveSkills = new Dictionary<uint, SkillInfo>();

            for( i = 0; i < result.Count; i++ )
            {
                try
                {
                    byte type;
                    type = (byte)result[i]["type"];
                    SkillInfo info = new SkillInfo();
                    switch (type)
                    {
                        case 0:
                            info.exp = (uint)(int)result[i]["exp"];
                            info.slot = (byte)result[i]["slot"];
                            aChar.BattleSkills.Add((uint)result[i]["skillID"], info);
                            break;
                        case 1:
                            info.exp = (uint)(int)result[i]["exp"];
                            info.slot = (byte)result[i]["slot"];
                            aChar.LivingSkills.Add((uint)(int)result[i]["skillID"], info);
                            break;
                        case 2:
                            info.exp = (uint)result[i]["exp"];
                            info.slot = (byte)result[i]["slot"];
                            aChar.SpecialSkills.Add((uint)result[i]["skillID"], info);
                            break;
                        case 3:
                            info.exp = (uint)(int)result[i]["exp"];
                            info.slot = (byte)result[i]["slot"];
                            aChar.InactiveSkills.Add((uint)(int)result[i]["skillID"], info);
                            break;

                    }
                }
                catch (Exception)
                {
                }
            }
        }
Beispiel #4
0
 public void DeleteSkill(ActorPC pc, SkillInfo skill)
 {
 }
Beispiel #5
0
 public void UpdateSkill(ActorPC pc, SkillType type, SkillInfo skill)
 {
     string sqlstr = "";
     switch (type)
     {
         case SkillType.Battle:
             sqlstr = string.Format("UPDATE `skills` SET `charID`='{0}',`type`='{1}',`skillID`='{2}'," +
                 "`exp`='{3}',`slot`='{4}' WHERE `id`='{5}';",
                 pc.charID, 0, skill.ID, skill.exp, skill.slot, skill.dbID);
             break;
         case SkillType.Living:
             sqlstr = string.Format("UPDATE `skills` SET `charID`='{0}',`type`='{1}',`skillID`='{2}'," +
                 "`exp`='{3}',`slot`='{4}' WHERE `id`='{5}';",
                 pc.charID, 1, skill.ID, skill.exp, skill.slot, skill.dbID);
             break;
         case SkillType.Special:
             sqlstr = string.Format("UPDATE `skills` SET `charID`='{0}',`type`='{1}',`skillID`='{2}'," +
                 "`exp`='{3}',`slot`='{4}' WHERE `id`='{5}';",
                 pc.charID, 2, skill.ID, skill.exp, skill.slot, skill.dbID);
             break;
         case SkillType.Inactive:
             sqlstr = string.Format("UPDATE `skills` SET `charID`='{0}',`type`='{1}',`skillID`='{2}'," +
                 "`exp`='{3}',`slot`='{4}' WHERE `id`='{5}';",
                 pc.charID, 3, skill.ID, skill.exp, skill.slot, skill.dbID);
             break;
     }
     SQLExecuteNonQuery(sqlstr);
 }
Beispiel #6
0
 public void NewSkill(ActorPC pc, SkillType type, SkillInfo skill)
 {
     string sqlstr = "";
     switch (type)
     {
         case SkillType.Battle:
             sqlstr = string.Format("INSERT INTO `skills`(`charID`,`type`,`skillID`,`exp`,`slot`) VALUE('{0}','{1}','{2}','{3}','{4}');",
             pc.charID, 0, skill.ID, skill.exp, skill.slot);
             break;
         case SkillType.Living:
             sqlstr = string.Format("INSERT INTO `skills`(`charID`,`type`,`skillID`,`exp`,`slot`) VALUE('{0}','{1}','{2}','{3}','{4}');",
             pc.charID, 1, skill.ID, skill.exp, skill.slot);
             break;
         case SkillType.Special:
             sqlstr = string.Format("INSERT INTO `skills`(`charID`,`type`,`skillID`,`exp`,`slot`) VALUE('{0}','{1}','{2}','{3}','{4}');",
             pc.charID, 2, skill.ID, skill.exp, skill.slot);
             break;
         case SkillType.Inactive:
             sqlstr = string.Format("INSERT INTO `skills`(`charID`,`type`,`skillID`,`exp`,`slot`) VALUE('{0}','{1}','{2}','{3}','{4}');",
             pc.charID, 3, skill.ID, skill.exp, skill.slot);
             break;
     }
     SQLExecuteScalar(sqlstr, ref skill.dbID);
 }
Beispiel #7
0
 public void DeleteSkill(ActorPC pc, SkillInfo skill)
 {
     string sqlstr = "DELETE FROM `skills` WHERE id='" + skill.dbID + "';";
     SQLExecuteNonQuery(sqlstr);
 }
Beispiel #8
0
        /// <summary>
        /// Reset skills of a PC on job change. 
        /// Move all skills into Inactive Skill table and get all skills in inactive skill table for current job
        /// </summary>
        /// <param name="pc">target PC</param>
        public static void SkillResetOnJobChange(ActorPC pc)
        {
            List<uint> tmptable = new List<uint>();
            byte job = (byte)(pc.job - 1);
            foreach (uint i in pc.BattleSkills.Keys)
            {
                if (SkillFactory.GetSkill(i).reqjob[job] == 255 || SkillFactory.GetSkill(i).reqjob[job] == 0)
                {
                    tmptable.Add(i);
                }
            }
            foreach (uint i in tmptable)
            {
                if (!pc.InactiveSkills.ContainsKey(i))
                {
                    pc.InactiveSkills.Add(i, pc.BattleSkills[i]);

                }
                MapServer.charDB.UpdateSkill(pc, SkillType.Inactive, pc.BattleSkills[i]);
                SendDeleteSkill(pc, i);
                pc.BattleSkills.Remove(i);
            }
            tmptable.Clear();
            foreach (uint i in pc.SpecialSkills.Keys)
            {
                tmptable.Add(i);
            }
            foreach (uint i in tmptable)
            {
                if (!pc.InactiveSkills.ContainsKey(i)) pc.InactiveSkills.Add(i, pc.SpecialSkills[i]);
                MapServer.charDB.UpdateSkill(pc, SkillType.Inactive, pc.SpecialSkills[i]);
                SendDeleteSpecial(pc, i);
                SendDeleteSkill(pc, i);
                pc.SpecialSkills.Remove(i);
            }
            tmptable.Clear();
            foreach (uint i in pc.InactiveSkills.Keys)
            {
                if (SkillFactory.GetSkill(i).reqjob[job] != 255 && SkillFactory.GetSkill(i).reqjob[job] != 0)
                {
                    tmptable.Add(i);
                }
            }
            foreach (uint i in tmptable)
            {
                if (!pc.BattleSkills.ContainsKey(i)) pc.BattleSkills.Add(i, pc.InactiveSkills[i]);
                MapServer.charDB.UpdateSkill(pc, SkillType.Battle, pc.InactiveSkills[i]);
                SendAddSkill(pc, i, 0);
                pc.InactiveSkills.Remove(i);
            }
            SkillInfo info = new SkillInfo();
            switch (pc.job)
            {
                case JobType.NOVICE:
                    if (!CheckSkill(pc, 1406901, 11))
                    {
                        info.ID = 1406901;
                        pc.BattleSkills.Add(1406901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1406901, 0);
                    }
                    break;
                case JobType.SWORDMAN:
                    if (!CheckSkill(pc, 1416901, 11))
                    {
                        info.ID = 1416901;
                        pc.BattleSkills.Add(1416901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1416901, 0);
                    }
                    break;
                case JobType.RECRUIT:
                    if (!CheckSkill(pc, 1426901, 11))
                    {
                        info.ID = 1426901;
                        pc.BattleSkills.Add(1426901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1426901, 0);
                    }
                    break;
                case JobType.THIEF:
                    if (!CheckSkill(pc, 1406901, 11))
                    {
                        info.ID = 1406901;
                        pc.BattleSkills.Add(1406901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1406901, 0);
                    }
                    break;
                case JobType.ENCHANTER:
                    if (!CheckSkill(pc, 1446901, 11))
                    {
                        info.ID = 1446901;
                        pc.BattleSkills.Add(1446901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1446901, 0);
                    }
                    break;
                case JobType.CLOWN:
                    if (!CheckSkill(pc, 1406901, 11))
                    {
                        info.ID = 1406901;
                        pc.BattleSkills.Add(1406901, info);
                        MapServer.charDB.NewSkill(pc, SkillType.Battle, info);
                        SendAddSkill(pc, 1406901, 0);
                    }
                    break;
            }
            CastPassivSkill(ref pc);
        }
Beispiel #9
0
 /// <summary>
 /// Learn a skill
 /// </summary>
 /// <param name="sActor">Player</param>
 /// <param name="skillid">Skill to be learned</param>
 /// <returns></returns>
 public static SkillAddResault SkillAddSpecial(ref ActorPC sActor, uint skillid)
 {
     if (sActor.BattleSkills.ContainsKey(skillid)) return SkillAddResault.ALREADY;
     uint baseid = ((skillid / 100) * 100) + 1;
     if (skillid != baseid)
     {
         if (!sActor.BattleSkills.ContainsKey(skillid - 1)) return SkillAddResault.PREVIOUS_SKILL_NOT_FOUND;
         Skills.Skill nskill = Skills.SkillFactory.GetSkill(skillid - 1);
         if (sActor.BattleSkills[skillid - 1].exp != nskill.maxsxp) return SkillAddResault.NOT_ENOUGH_SKILL_EXP;
         SkillInfo info = sActor.BattleSkills[skillid - 1];
         MapServer.charDB.DeleteSkill(sActor, sActor.BattleSkills[skillid - 1]);
         info.ID = skillid;
         sActor.BattleSkills.Remove(skillid - 1);
         sActor.BattleSkills.Add(skillid, info);
         MapServer.charDB.NewSkill(sActor, SkillType.Battle, info);
         return SkillAddResault.OK;
     }
     else
     {
         SkillInfo info = new SkillInfo();
         info.ID = skillid;
         sActor.BattleSkills.Add(skillid, info);
         MapServer.charDB.NewSkill(sActor, SkillType.Battle,info);
         CastPassivSkill(ref sActor);
         return SkillAddResault.OK;
     }
 }