Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wServer.realm;
using wServer.realm.entities;
using wServer.svrPackets;
namespace wServer.logic.attack
{
class AngleThrowAttack : Behavior
{
float angle;
float range;
float bombRadius;
int damage;
private AngleThrowAttack(float angle, float range, float bombRadius, int damage)
{
this.angle = angle;
this.range = range;
this.bombRadius = bombRadius;
this.damage = damage;
}
static readonly Dictionary<Tuple<float, float, float, int>, AngleThrowAttack> instances = new Dictionary<Tuple<float, float, float, int>, AngleThrowAttack>();
public static AngleThrowAttack Instance(float angle, float range, float bombRadius, int damage)
{
var key = new Tuple<float, float, float, int>(angle, range, bombRadius, damage);
AngleThrowAttack ret;
if (!instances.TryGetValue(key, out ret))
ret = instances[key] = new AngleThrowAttack(angle, range, bombRadius, damage);
return ret;
}
Random rand = new Random();
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Stunned)) return false;
var chr = Host as Character;
Position target = new Position()
{
X = Host.Self.X,
Y = Host.Self.Y
};
target.X += (float)Math.Cos(angle) * range;
target.Y += (float)Math.Sin(angle) * range;
chr.Owner.BroadcastPacket(new ShowEffectPacket()
{
EffectType = EffectType.Throw,
Color = new ARGB(0xffff0000),
TargetId = Host.Self.Id,
PosA = target
}, null);
chr.Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
{
world.BroadcastPacket(new AOEPacket()
{
Position = target,
Radius = bombRadius,
Damage = (ushort)damage,
EffectDuration = 0,
Effects = 0,
OriginType = Host.Self.ObjectType
}, null);
AOE(world, target, bombRadius, true, p =>
{
(p as IPlayer).Damage(damage, Host.Self as Character);
});
}));
return true;
}
}
}
6.) You are now able to use the AngleThrowAttack behavior.