here is a sample of the handler.
- Code: Select all
namespace DOL.GS.SkillHandler
{
[SkillHandlerAttribute(Abilities.ShadowStrike)]
public class ShadowStrikeAbilityHandler : IAbilityActionHandler
{
/// <summary>
/// Defines a logger for this class.
/// </summary>
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The reuse time in milliseconds for Shadow Strike ability
/// </summary>
protected const int REUSE_TIMER = 60000 * 10; // 10 minutes
/// <summary>
/// Execute Shadowstrike
/// </summary>
public void Execute(Ability ab, GamePlayer player)
{
if (player == null)
{
if (log.IsWarnEnabled)
log.Warn("Could not find player using ShadowStrikeAbility.");
return;
}
if (!player.IsAlive) //has to be alive.
{
player.Out.SendMessage("You cannot use this while Dead!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
if (player.IsMezzed) //cant be mezzed.
{
player.Out.SendMessage("You cannot use this while Mezzed!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
if (player.IsStunned) //cant be stunned.
{
player.Out.SendMessage("You cannot use this while Stunned!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
if (player.IsSitting) //cant be sitting.
{
player.Out.SendMessage("You must be standing to use this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
if (player.TargetObject != player) //target must be a player.
{
player.Out.SendMessage("You can only use this ability on a player!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
if (!player.IsStealthed)
{
player.Out.SendMessage("You must be Stealthed to use this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
GameLiving target = (GameLiving)player.TargetObject;
int xrange = 0;
int yrange = 0;
double angle = 0.00153248422;
player.MoveTo(player.CurrentRegionID, (int)(target.X - ((xrange + 5) * Math.Sin(angle * target.Heading))), (int)(target.Y + ((yrange + 5) * Math.Cos(angle * target.Heading))), target.Z, player.Heading);
player.DisableSkill(ab, REUSE_TIMER);
}
}
}
