/// <summary> /// Tells the skill user to start using the given <paramref name="skill"/>. This is more of a suggestion than a /// request since the skill user does not actually have to start casting the skill. If this skill user decides /// to use the skill, the CurrentCastingSkill must be set to the <paramref name="skill"/>. /// </summary> /// <param name="skill">The skill to be used.</param> /// <param name="target">The optional character to use the skill on. Can be null.</param> /// <returns>True if the <paramref name="skill"/> started being casted; otherwise false. This does not indicate /// whether or not the skill was or will be successfully used, just that it was attempted to be used. Common /// times this will return false is if there is a skill already being casted, or if the skill that was /// attempted to be used still needs to cool down.</returns> public bool TryStartCastingSkill(ISkill <SkillType, StatType, Character> skill, Character target) { if (!_character.IsAlive) { return(false); } // Check that the character knows the skill if (!_character.KnownSkills.Knows(skill.SkillType)) { return(false); } // Don't interrupt a skill that the character is already casting if (IsCastingSkill) { return(false); } // Check that the group is available for usage if (_cooldownManager.IsCoolingDown(skill.CooldownGroup, _character.GetTime())) { return(false); } // Only allow immediate-usage skills when moving if (_character.Velocity != Vector2.Zero && skill.CastingTime > 0) { return(false); } if (skill.CastingTime == 0) { // The skill to use has no usage delay, so use it immediately UseSkill(skill, target, true); } else { // The skill does have a delay, so queue it for usage _currentCastingSkill = skill; _castingSkillTarget = target; var castingTime = skill.CastingTime; _castingSkillUsageTime = _character.GetTime() + castingTime; // Tell the character the details about the skill they are casting if (_character is INetworkSender) { using (var pw = ServerPacket.SkillStartCasting_ToUser(skill.SkillType, castingTime)) { ((INetworkSender)_character).Send(pw, ServerMessageType.GUIUserStatus); } } // Tell the users on the map that the character is casting using (var pw = ServerPacket.SkillStartCasting_ToMap(_character.MapEntityIndex, skill.SkillType)) { _character.Map.Send(pw, ServerMessageType.MapDynamicEntityProperty); } } return(true); }