public void Cast(SkillCast skillCast) { int spiritCost = skillCast.GetSpCost(); int staminaCost = skillCast.GetStaCost(); if (Stats[PlayerStatId.Spirit].Current >= spiritCost && Stats[PlayerStatId.Stamina].Current >= staminaCost) { ConsumeSp(spiritCost); ConsumeStamina(staminaCost); SkillCast = skillCast; Session.SendNotice(skillCast.SkillId.ToString()); // TODO: Move this and all others combat cases like recover sp to its own class. // Since the cast is always sent by the skill, we have to check buffs even when not doing damage. if (skillCast.IsBuffToOwner() || skillCast.IsBuffToEntity() || skillCast.IsBuffShield() || skillCast.IsDebuffToOwner()) { Status status = new Status(skillCast, Session.FieldPlayer.ObjectId, Session.FieldPlayer.ObjectId, 1); StatusHandler.Handle(Session, status); } // Refresh out-of-combat timer if (CombatCTS != null) { CombatCTS.Cancel(); } CombatCTS = new CancellationTokenSource(); CombatCTS.Token.Register(() => CombatCTS.Dispose()); StartCombatStance(CombatCTS); } }
public SkillCast Cast(int skillId, short skillLevel, long skillSN, int unkValue) { SkillCast skillCast = new SkillCast(skillId, skillLevel, skillSN, unkValue); int spiritCost = skillCast.GetSpCost(); int staminaCost = skillCast.GetStaCost(); if (Stats[PlayerStatId.Spirit].Current >= spiritCost && Stats[PlayerStatId.Stamina].Current >= staminaCost) { ConsumeSp(spiritCost); ConsumeStamina(staminaCost); SkillCast = skillCast; if (skillCast.IsBuff()) { // TODO: Add buff timer } // Refresh out-of-combat timer if (CombatCTS != null) { CombatCTS.Cancel(); } CombatCTS = new CancellationTokenSource(); CombatCTS.Token.Register(() => CombatCTS.Dispose()); StartCombatEnd(CombatCTS); return(skillCast); } return(null); }