/// <summary> /// New Skill. /// </summary> /// <param name="creature"></param> /// <param name="id"></param> /// <param name="rank"></param> /// <param name="race"></param> public Skill(Creature creature, SkillId id, SkillRank rank, int race) { _creature = creature; _race = race; this.Info.Id = id; this.Info.Rank = rank; this.Info.MaxRank = rank; this.Info.Flag = SkillFlags.Shown; // The conditions are set to the max and are reduced afterwards, // making them "Complete" once they reach 0. Initializing to 1 // in case of problems. this.Info.ConditionCount1 = 1; this.Info.ConditionCount2 = 1; this.Info.ConditionCount3 = 1; this.Info.ConditionCount4 = 1; this.Info.ConditionCount5 = 1; this.Info.ConditionCount6 = 1; this.Info.ConditionCount7 = 1; this.Info.ConditionCount8 = 1; this.Info.ConditionCount9 = 1; this.LoadRankData(); }
/// <summary> /// Sends EntrustmentChanceUpdate to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="chance"></param> /// <param name="unkShort"></param> public static void EntrustmentChanceUpdate(Creature creature, float chance, SkillRank skillRank) { var packet = new Packet(Op.EntrustmentChanceUpdate, creature.EntityId); packet.PutFloat(chance); packet.PutShort((short)skillRank); creature.Client.Send(packet); }
protected QuestObjectiveInfo ReachRank(SkillConst skillId, SkillRank rank) { var result = new QuestObjectiveInfo(); result.Type = ObjectiveType.ReachRank; result.Id = (uint)skillId; result.Amount = (uint)rank; return result; }
protected QuestRewardInfo Skill(SkillConst skillId, SkillRank rank) { var result = new QuestRewardInfo(); result.Type = RewardType.Skill; result.Id = (uint)skillId; result.Amount = (uint)rank; return result; }
/// <summary> /// Returns success chance between 0 and 100. /// </summary> /// <remarks> /// Unofficial. It's unlikely that officials use a table, instead of /// a formula, but for a lack of formula, we're forced to go with /// this. The success rates actually seem to be rather static, /// so it should work fine. We have all possible combinations, /// and with this function we do get the correct base chance. /// </remarks> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="manualRank"></param> /// <returns></returns> protected int GetSuccessChance(Creature creature, Skill skill, SkillRank manualRank) { var diff = ((int)skill.Info.Rank - (int)manualRank); var chance = SuccessTable[29 - (diff + 15)]; // Production Mastery bonus var pm = creature.Skills.Get(SkillId.ProductionMastery); if (pm != null) chance += (byte)pm.Info.Rank; // Party bonus // http://mabination.com/threads/579-Sooni-s-Guide-to-Tailoring!-(Please-claim-back-from-me) if (creature.IsInParty) { var members = creature.Party.GetMembers(); var tailorsCount = members.Where(a => a != creature && a.Skills.Has(skill.Info.Id, SkillRank.RF)).Count(); if (tailorsCount != 0) chance += (int)(tailorsCount * 5 / 100f * chance); } return Math2.Clamp(0, 99, chance); }
/// <summary> /// Returns true if creature has skill and its rank is equal /// or greater than the given rank. /// </summary> /// <param name="id"></param> /// <param name="rank"></param> /// <returns></returns> public bool Has(SkillId id, SkillRank rank = SkillRank.Novice) { var skill = this.Get(id); return (skill != null && skill.Info.Rank >= rank); }
/// <summary> /// Trains condition in skill if it has the given rank. /// </summary> /// <param name="skillId"></param> /// <param name="rank">Rank to which the training is limited.</param> /// <param name="condition">Condition nr (1-9)</param> /// <param name="amount"></param> public void Train(SkillId skillId, SkillRank rank, int condition, int amount = 1) { var skill = this.Get(skillId); if (skill == null || skill.Info.Rank != rank) return; skill.Train(condition, amount); }
/// <summary> /// Returns true if rank of skill is equal. /// </summary> /// <param name="id"></param> /// <param name="rank"></param> /// <returns></returns> public bool Is(SkillId id, SkillRank rank) { var skill = this.Get(id); return(skill != null && skill.Info.Rank == rank); }
/// <summary> /// Adds skill silently. Returns false if the skill already exists, /// with a rank that's equal or higher. /// </summary> /// <param name="skillId"></param> /// <param name="skillRank"></param> /// <param name="raceId"></param> public bool Add(SkillId skillId, SkillRank skillRank, int raceId) { if (!AuraData.SkillDb.Exists((int)skillId)) { Log.Warning("CreatureSkills.Add: Skill '{0}' not found in data.", skillId); return false; } return this.Add(new Skill(_creature, skillId, skillRank, raceId)); }
public QuestPrerequisiteNotSkill(SkillId skillId, SkillRank rank = SkillRank.Novice) { this.Id = skillId; this.Rank = rank; }
/// <summary> /// Returns true if the skill is there and its rank exceeds rank. /// </summary> /// <param name="skillId"></param> /// <param name="rank"></param> /// <returns></returns> public bool Has(SkillConst skillId, SkillRank rank) { var skill = this.Get(skillId); return (skill != null && skill.Rank >= rank); }
protected QuestReward Skill(SkillId skillId, SkillRank rank, int training) { return new QuestRewardSkill(skillId, rank, training); }
/// <summary> /// Changes effect to check for a skill rank. /// </summary> /// <param name="skillId"></param> /// <param name="checkType">SkillRankEqual, SkillRankGreaterThan, or SkillRankLowerThan</param> /// <param name="rank"></param> public void SetSkillCheck(SkillId skillId, UpgradeCheckType checkType, SkillRank rank) { if (checkType < UpgradeCheckType.SkillRankEqual || checkType > UpgradeCheckType.SkillRankLowerThan) throw new ArgumentException(checkType + " is not a skill check."); CheckType = checkType; CheckSkillId = skillId; CheckValue = 0; CheckSkillRank = rank; }
/// <summary> /// Returns true if creature has skill and its rank is equal /// or greater than the given rank. /// </summary> /// <param name="id"></param> /// <param name="rank"></param> /// <returns></returns> public bool Has(SkillId id, SkillRank rank = SkillRank.Novice) { var skill = this.Get(id); return(skill != null && skill.Info.Rank >= rank); }
public Skill(SkillId id, SkillRank rank = SkillRank.Novice) { this.Id = id; this.Rank = rank; }
public QuestObjectiveReachRank(SkillId skillId, SkillRank rank) : base(1) { this.Id = skillId; this.Rank = rank; this.MetaData.SetUShort("TGTSKL", (ushort)skillId); this.MetaData.SetShort("TGTLVL", (short)rank); this.MetaData.SetInt("TARGETCOUNT", 1); }
protected QuestPrerequisite NotSkill(SkillId skillId, SkillRank rank = SkillRank.Novice) { return(new QuestPrerequisiteNotSkill(skillId, rank)); }
protected QuestReward Skill(SkillId skillId, SkillRank rank) { return new QuestRewardSkill(skillId, rank, 0); }
public QuestRewardSkill(SkillId id, SkillRank rank) { this.SkillId = id; this.Rank = rank; }
// ^ Skill check ^ /// <summary> /// Initializes upgrade effect, setting required default values. /// You should generally use this constructor! /// </summary> /// <param name="type"></param> public UpgradeEffect(UpgradeType type) { Type = type; Unk1 = 0; Unk2 = 0; Stat = 0; ValueType = 0; Value = 0; SkillId = 0; SkillVar = 0; Unk4 = 0x0A; Unk5 = 0; CheckType = UpgradeCheckType.None; CheckStat = 0; CheckRace = 0; CheckPtj = 0; CheckMonth = 0; CheckBroken = false; CheckTitleId = 0; CheckCondition = 0; CheckValueType = 0; CheckValue = 0; CheckSkillId = 0; CheckSkillRank = 0; }
/// <summary> /// Checks if player has the skill. /// </summary> /// <param name="skillId"></param> /// <param name="rank"></param> /// <returns></returns> public bool HasSkill(SkillId skillId, SkillRank rank = SkillRank.Novice) { return this.Player.Skills.Has(skillId, rank); }
/// <summary> /// Checks if player has the skill on the specified rank. /// </summary> /// <param name="skillId"></param> /// <param name="rank"></param> /// <returns></returns> public bool IsSkill(SkillId skillId, SkillRank rank) { return this.Player.Skills.Is(skillId, rank); }
/// <summary> /// Gives skill to player if he doesn't have it on that rank yet. /// </summary> /// <param name="skillId"></param> /// <param name="rank"></param> public void GiveSkill(SkillId skillId, SkillRank rank = SkillRank.Novice) { if (this.HasSkill(skillId, rank)) return; this.Player.Skills.Give(skillId, rank); }
/// <summary> /// Gives skills, or updates it. Updates bonuses and talent exp. /// </summary> /// <param name="skillId"></param> /// <param name="rank"></param> /// <param name="flash"></param> public void Give(SkillConst skillId, SkillRank rank, bool flash = true) { var skill = this.Get(skillId); if (skill == null) { this.Add(skill = new MabiSkill(skillId, rank, _creature.Race)); Send.SkillInfo(_creature.Client, _creature, skill); if (flash) Send.RankUp(_creature); EventManager.CreatureEvents.OnCreatureSkillChange(_creature, skill, true); } else { this.RemoveSkillBonuses(skill); skill.Info.Experience = 0; skill.Info.Rank = (byte)rank; skill.LoadRankInfo(); Send.SkillRankUp(_creature.Client, _creature, skill); if (flash) Send.RankUp(_creature, skill.Info.Id); EventManager.CreatureEvents.OnCreatureSkillChange(_creature, skill, false); } this.AddBonuses(skill); _creature.Talents.UpdateExp(skillId, rank, true); }
public void UpdateExp(SkillConst skill, SkillRank rank, bool notifyRankUp = false) { var mask = (byte)this.GetRaceMask(); var exps = MabiData.TalentExpDb.Entries.Where(a => a.SkillId == (ushort)skill && a.SkillRank <= (byte)rank && (a.Race & mask) != 0); if (exps == null) return; var info = exps.FirstOrDefault(a => a.SkillRank == (ushort)rank); if (info == null) return; foreach (var talent in info.Exps.Keys) { uint exp = (uint)exps.Sum(a => a.Exps[talent]); if (!this.ExpList.ContainsKey((TalentId)talent)) this.ExpList.Add((TalentId)talent, new Dictionary<SkillConst, uint>()); var expInfo = this.ExpList[(TalentId)talent]; if (!expInfo.ContainsKey(skill)) expInfo.Add(skill, 0); expInfo[skill] = exp; if (notifyRankUp) this.SendUpdate(); } }
/// <summary> /// Changes rank, resets experience, loads rank data. /// </summary> /// <param name="rank"></param> public void ChangeRank(SkillRank rank) { this.Info.Rank = rank; this.Info.Experience = 0; this.Info.Flag &= ~SkillFlags.Rankable; this.LoadRankData(); }
/// <summary> /// Checks rank for method, returns true if everything is in order. /// </summary> /// <param name="creature"></param> /// <param name="method"></param> /// <param name="skillRank"></param> /// <returns></returns> private bool CheckRank(Creature creature, string method, SkillRank skillRank) { switch (method) { case CookingMethod.Mixing: return true; case CookingMethod.Baking: return (skillRank >= SkillRank.RF); case CookingMethod.Simmering: return (skillRank >= SkillRank.RE); case CookingMethod.Kneading: return (skillRank >= SkillRank.RD); case CookingMethod.Boiling: return (skillRank >= SkillRank.RC); case CookingMethod.NoodleMaking: return (skillRank >= SkillRank.RB); case CookingMethod.DeepFrying: return (skillRank >= SkillRank.RA); case CookingMethod.StirFrying: return (skillRank >= SkillRank.R9); case CookingMethod.PastaMaking: return (skillRank >= SkillRank.R8); case CookingMethod.JamMaking: return (skillRank >= SkillRank.R7); case CookingMethod.PieMaking: return (skillRank >= SkillRank.R6); case CookingMethod.Steaming: return (skillRank >= SkillRank.R5); default: Log.Error("Cooking.CheckRank: Unknown cooking method."); return false; } }
public QuestRewardSkill(SkillId id, SkillRank rank, int training = 0) { this.SkillId = id; this.Rank = rank; this.Training = training; }
protected QuestPrerequisite ReachedRank(SkillId skillId, SkillRank rank) { return new QuestPrerequisiteReachedRank(skillId, rank); }
/// <summary> /// Adds skill at rank, or updates it. /// Sends appropriate packets. /// </summary> /// <param name="id"></param> /// <param name="rank"></param> public void Give(SkillId id, SkillRank rank) { var skill = this.Get(id); if (skill == null) { this.Add(skill = new Skill(_creature, id, rank, _creature.RaceId)); Send.SkillInfo(_creature, skill); if (_creature.Region != Region.Limbo) Send.RankUp(_creature); ChannelServer.Instance.Events.OnSkillRankChanged(_creature, skill); } else { this.RemoveBonuses(skill); skill.ChangeRank(rank); Send.SkillRankUp(_creature, skill); if (_creature.Region != Region.Limbo) Send.RankUp(_creature, skill.Info.Id); this.AddBonuses(skill); } Send.StatUpdate(_creature, StatUpdateType.Private, Stat.Str, Stat.Int, Stat.Dex, Stat.Will, Stat.Luck, Stat.Life, Stat.LifeInjured, Stat.LifeMaxMod, Stat.LifeMax, Stat.Mana, Stat.ManaMaxMod, Stat.ManaMax, Stat.Stamina, Stat.Hunger, Stat.StaminaMaxMod, Stat.StaminaMax ); Send.StatUpdate(_creature, StatUpdateType.Public, Stat.Life, Stat.LifeInjured, Stat.LifeMaxMod, Stat.LifeMax); this.RankChanged.Raise(_creature, skill); }
protected QuestPrerequisite NotSkill(SkillId skillId, SkillRank rank = SkillRank.Novice) { return new QuestPrerequisiteNotSkill(skillId, rank); }
/// <summary> /// Returns true if rank of skill is equal. /// </summary> /// <param name="id"></param> /// <param name="rank"></param> /// <returns></returns> public bool Is(SkillId id, SkillRank rank) { var skill = this.Get(id); return (skill != null && skill.Info.Rank == rank); }
protected QuestObjective ReachRank(SkillId skillId, SkillRank rank) { return new QuestObjectiveReachRank(skillId, rank); }
/// <summary> /// Returns duration for rank in minutes. /// </summary> /// <param name="rank"></param> /// <returns></returns> private int GetDuration(SkillRank rank, int regionId) { var duration = 4; if (rank >= SkillRank.RC && rank <= SkillRank.R6) duration = 5; else if (rank >= SkillRank.R5) duration = 6; // Lower duration during rain var weatherType = ChannelServer.Instance.Weather.GetWeatherType(regionId); if (weatherType == WeatherType.Rain) duration /= 2; // Unofficial return duration; }
public CreationEventArgs(Creature creature, CreationMethod method, Item item, SkillRank rank) { this.Creature = creature; this.Method = method; this.Item = item; this.Rank = rank; }