public void AddBuff(uint buffId) { var template = SkillManager.Instance.GetPassiveBuffTemplate(buffId); if (template.AbilityId > 0 && template.AbilityId != (byte)Owner.Ability1 && template.AbilityId != (byte)Owner.Ability2 && template.AbilityId != (byte)Owner.Ability3) { return; } var points = ExpirienceManager.Instance.GetSkillPointsForLevel(Owner.Level); points -= GetUsedSkillPoints(); if (template.ReqPoints > points) { return; } if (PassiveBuffs.ContainsKey(buffId)) { return; } var buff = new PassiveBuff(); buff.Id = buffId; buff.Template = template; PassiveBuffs.Add(buff.Id, buff); Owner.BroadcastPacket(new SCBuffLearnedPacket(Owner.ObjId, buff.Id), true); // TODO apply buff effect }
public void Load(MySqlConnection connection) { using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM skills WHERE `owner` = @owner"; command.Parameters.AddWithValue("@owner", Owner.Id); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var type = (SkillType)Enum.Parse(typeof(SkillType), reader.GetString("type"), true); switch (type) { case SkillType.Skill: var skill = new Skill { Id = reader.GetUInt32("id"), Level = reader.GetByte("level") }; Skills.Add(skill.Id, skill); break; case SkillType.Buff: var buff = new PassiveBuff { Id = reader.GetUInt32("id") }; PassiveBuffs.Add(buff.Id, buff); break; } } } } foreach (var skill in Skills.Values) { if (skill != null) { skill.Template = SkillManager.Instance.GetSkillTemplate(skill.Id); } } }