SHARE
TWEET

Untitled

a guest Apr 26th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.         public bool AddSkill(short skillVNum)
  3.         {
  4.             Skill skillinfo = ServerManager.GetSkill(skillVNum);
  5.             if (skillinfo == null)
  6.             {
  7.                 Session.SendPacket(GenerateSay(Language.Instance.GetMessageFromKey("SKILL_DOES_NOT_EXIST"), 11));
  8.                 return false;
  9.             }
  10.             if (skillinfo.SkillVNum < 200)
  11.             {
  12.                 if (Skills.GetAllItems()
  13.                     .Any(s => skillinfo.CastId == s.Skill.CastId && s.Skill.SkillVNum < 200 && s.Skill.UpgradeSkill > skillinfo.UpgradeSkill))
  14.                 {
  15.                     // Character already has a better passive skill of the same type.
  16.                     return false;
  17.                 }
  18.                 foreach (CharacterSkill skill in Skills.GetAllItems().Where(s => skillinfo.CastId == s.Skill.CastId && s.Skill.SkillVNum < 200))
  19.                 {
  20.                     Skills.Remove(skill.SkillVNum);
  21.                 }
  22.             }
  23.             else
  24.             {
  25.                 if (Skills.ContainsKey(skillVNum))
  26.                 {
  27.                     Session.SendPacket(GenerateSay(Language.Instance.GetMessageFromKey("SKILL_ALREADY_EXIST"), 11));
  28.                     return false;
  29.                 }
  30.  
  31.                 if (skillinfo.UpgradeSkill != 0)
  32.                 {
  33.                     CharacterSkill oldupgrade = Skills.FirstOrDefault(s =>
  34.                         s.Skill.UpgradeSkill == skillinfo.UpgradeSkill
  35.                         && s.Skill.UpgradeType == skillinfo.UpgradeType && s.Skill.UpgradeSkill != 0);
  36.                     if (oldupgrade != null)
  37.                     {
  38.                         Skills.Remove(oldupgrade.SkillVNum);
  39.                     }
  40.                 }
  41.             }
  42.             Skills[skillVNum] = new CharacterSkill
  43.             {
  44.                 SkillVNum = skillVNum,
  45.                 CharacterId = CharacterId
  46.             };
  47.  
  48.             Session.SendPackets(GenerateQuicklist());
  49.             Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SKILL_LEARNED"), 0));
  50.             return true;
  51.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top