GivePlayerEffect.cs
I present to you GivePlayerEffect
Description :: Gives the nearest player within a distance an effect without the need to shoot them or anything else. if the player is Immune to the effect that you put then it won't take effect, and if you are invincible then it won't take effect but you can be invulnerable and it will still take effect.
Added Aesthetics :: There is a red trail(like the pet heal) from the enemy to the player, a red potion effect(like healing) on the player, and red text(just like when you stun en enemy) on the player.
Usage :: new GivePlayerEffect(ConditionalEffectIndex.(effect), #(time), #(distance))
Example :: new GivePlayerEffect(ConditionalEffectIndex.Paralyzed, 10000, 10)
// @Danny @Luis close it, anyone want to talk to me just PM me.
Description :: Gives the nearest player within a distance an effect without the need to shoot them or anything else. if the player is Immune to the effect that you put then it won't take effect, and if you are invincible then it won't take effect but you can be invulnerable and it will still take effect.
Added Aesthetics :: There is a red trail(like the pet heal) from the enemy to the player, a red potion effect(like healing) on the player, and red text(just like when you stun en enemy) on the player.
Usage :: new GivePlayerEffect(ConditionalEffectIndex.(effect), #(time), #(distance))
Example :: new GivePlayerEffect(ConditionalEffectIndex.Paralyzed, 10000, 10)
CODE
Code:
#region
using System.Linq;
using wServer.realm;
using wServer.networking.svrPackets;
using wServer.realm.entities;
using wServer.realm.entities.player;
#endregion
namespace wServer.logic.behaviors
{
public class GivePlayerEffect : Behavior
{
private readonly int dist;
private readonly int time;
private readonly ConditionEffectIndex effect;
public GivePlayerEffect(ConditionEffectIndex effect, int time, int dist) { this.dist = dist; this.effect = effect; this.time = time; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
if (host.GetNearestEntity(dist, null) == null) return;
Entity player = host.GetNearestEntity(dist, null) as Player;
string effectname = effect.ToString();
if (player.HasConditionEffect(ConditionEffectIndex.CurseImmune) && effect == ConditionEffectIndex.Curse) return;
if (player.HasConditionEffect(ConditionEffectIndex.ArmorBreakImmune) && effect == ConditionEffectIndex.ArmorBroken) return;
if (player.HasConditionEffect(ConditionEffectIndex.DazedImmune) && effect == ConditionEffectIndex.Dazed) return;
if (player.HasConditionEffect(ConditionEffectIndex.Invincible)) return;
if (player.HasConditionEffect(ConditionEffectIndex.ParalyzeImmune) && effect == ConditionEffectIndex.Paralyzed) return;
if (player.HasConditionEffect(ConditionEffectIndex.SlowedImmune) && effect == ConditionEffectIndex.Slowed) return;
if (player.HasConditionEffect(ConditionEffectIndex.StasisImmune) && effect == ConditionEffectIndex.Stasis) return;
if (player.HasConditionEffect(ConditionEffectIndex.StunImmune) && effect == ConditionEffectIndex.Stunned) return;
if (player.HasConditionEffect(ConditionEffectIndex.PetrifyImmune) && effect == ConditionEffectIndex.Petrify) return;
// This is ugly as fuck but its actually smaller then doing it as a case n' switch. ^^^^
player.ApplyConditionEffect(new ConditionEffect
{
Effect = effect,
DurationMS = time
});
player.Owner.BroadcastPacket(new ShowEffectPacket
{
EffectType = EffectType.Trail,
TargetId = host.Id,
PosA = new Position { X = player.X, Y = player.Y },
Color = new ARGB(0xffff0000)
}, null);
player.Owner.BroadcastPacket(new ShowEffectPacket
{
EffectType = EffectType.Potion,
TargetId = player.Id,
Color = new ARGB(0xffff0000)
}, null);
player.Owner.BroadcastPacket(new NotificationPacket
{
ObjectId = player.Id,
Color = new ARGB(0xffff0000),
Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\""+ effectname +"\"}}"
});
}
}
}
// @Danny @Luis close it, anyone want to talk to me just PM me.