public void SetTargetState(BaseAspect aspect, Mobile target, TimeSpan duration) { Dictionary <Mobile, State> states; if (!States.TryGetValue(this, out states) || states == null) { States[this] = states = new Dictionary <Mobile, State>(); } State state; if (!states.TryGetValue(target, out state) || state == null) { states[target] = state = new State(this, aspect, target, duration); } else { OnRemoved(state); state.Aspect = aspect; state.Target = target; if (Stackable && !state.IsExpired) { state.Expire += duration; } else { state.Expire = DateTime.UtcNow.Add(duration); } } OnAdded(state); }
public void SetTargetState(BaseAspect aspect, Mobile target, TimeSpan duration) { Dictionary <Mobile, State> states; if (!States.TryGetValue(this, out states) || states == null) { States.AddOrReplace(this, val => val ?? (states = new Dictionary <Mobile, State>())); } states.AddOrReplace( target, state => { if (state == null) { state = new State(this, aspect, target, duration); } else { OnRemoved(state); state.Aspect = aspect; state.Target = target; state.Expire = DateTime.UtcNow + duration; } OnAdded(state); return(state); }); }
protected override void OnInvoke(BaseAspect aspect) { var fx = CreateEffect(aspect); if (fx == null) { return; } fx.AverageZ = false; fx.EffectHandler = e => { if (e.ProcessIndex != 0) { return; } foreach (var t in AcquireTargets <Mobile>(aspect, e.Source.Location, 0)) { OnTargeted(aspect, t); } }; fx.Send(); }
public void Damage(BaseAspect aspect, Mobile target) { aspect.DoHarmful(target, true); var damage = Utility.RandomMinMax(aspect.DamageMin, aspect.DamageMax); if (DamageFactor != 1.0) { damage = (int)Math.Ceiling(damage * DamageFactor); } if (damage > 0) { OnDamage(aspect, target, ref damage); } if (damage > 0) { target.Damage(damage, aspect); if (target.PlayDamagedAnimation()) { target.PlayHurtSound(); } } }
protected IEnumerable <TMobile> AcquireTargets <TMobile>( BaseAspect aspect, bool cache = true, Func <TMobile, bool> filter = null) where TMobile : Mobile { return(AcquireTargets(aspect, aspect.Location, aspect.RangePerception, cache, filter)); }
protected override void OnDamage(BaseAspect aspect, Mobile target, ref int damage) { base.OnDamage(aspect, target, ref damage); if (Utility.RandomBool()) { int x = 0, y = 0; Movement.Movement.Offset(aspect.GetDirectionTo(target), ref x, ref y); var loc = target.Clone3D(x, y, target.Map.GetTopZ(target.Clone2D(x, y))); if (target.Map.CanSpawnMobile(loc)) { ScreenFX.LightFlash.Send(target); target.Location = loc; if (target.PlayDamagedAnimation()) { target.PlayHurtSound(); } } } }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } if (aspect.PlayAttackAnimation()) { aspect.PlayAttackSound(); } aspect.PlaySound(1230); var delay = 500; for (var range = 4; range <= aspect.RangePerception; range++, delay += 500) { Timer.DelayCall( TimeSpan.FromMilliseconds(delay), loc => { SpellHelper.Turn(aspect, loc); if (aspect.PlayAttackAnimation()) { aspect.PlayAttackSound(); } CaveInBoulder(aspect, loc); }, aspect.Location.GetRandomPoint2D(range, range).GetSurfaceTop(aspect.Map)); } }
protected virtual TMobile[] AcquireTargets <TMobile>( BaseAspect aspect, Point3D p, int range, bool cache = true, Func <TMobile, bool> filter = null) where TMobile : Mobile { if (aspect == null || aspect.Deleted || aspect.Map == null || aspect.Map == Map.Internal) { return(new TMobile[0]); } var targets = p.GetMobilesInRange(aspect.Map, range) .OfType <TMobile>() .Where(m => m != null && !m.Deleted && m != aspect && m.AccessLevel <= aspect.AccessLevel && m.Alive) .Where(m => aspect.CanBeHarmful(m, false, true) && SpellHelper.ValidIndirectTarget(aspect, m)) .Where(m => m.Party == null || m.Party != aspect.Party) .Where( m => m.Player || aspect.Combatant == m || aspect.FocusMob == m || (m is BaseCreature && (m as BaseCreature).GetMaster <PlayerMobile>() != null)) .ToArray(); if (cache && Duration > TimeSpan.Zero) { foreach (var t in targets) { SetTargetState(aspect, t, Duration); } } return(targets); }
public bool TryInvoke(BaseAspect aspect) { if (CanInvoke(aspect)) { return(VitaNexCore.TryCatchGet( () => { SetLock(aspect, true); OnInvoke(aspect); aspect.OnAbility(this); var locked = Lockdown.TotalSeconds; if (locked > 0) { locked -= aspect.Scale(locked * 0.10); } locked = Math.Max(0, locked); Timer.DelayCall(TimeSpan.FromSeconds(locked), a => SetLock(a, false), aspect); return true; }, x => x.ToConsole(true))); } return(false); }
public Singularity(BaseAspect aspect) : base(aspect, AIType.AI_Mage, FightMode.None, 0.2, 0.4) { Name = "Singularity"; Body = 261; CantWalk = true; }
public StamLeach(BaseAspect aspect) : base(aspect, AIType.AI_Mage, FightMode.None, 0.2, 0.4) { Name = "Stamina Leach"; Body = 129; CantWalk = true; }
private void CaveInBoulder(BaseAspect aspect, Point3D loc) { new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, 4534, 2999, 1).Send(); new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, 4534, 0, 4) { SoundID = 541 }.MovingImpact(e => BoulderImpact(aspect, e.Target.Location, 3)); }
private void Meteorite(BaseAspect aspect, Point3D loc) { new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, 4534, 2999, 1).Send(); new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, 4534, 1258, 4) { SoundID = 541 }.MovingImpact(e => MeteoriteImpact(aspect, e.Target.Location, 4)); }
public Void(BaseAspect aspect) : base(aspect, AIType.AI_Mage, FightMode.None, 0.2, 0.4) { Name = "Void"; Body = 261; CantWalk = true; }
public State(AspectAbility ability, BaseAspect aspect, Mobile target, TimeSpan duration) { Ability = ability; Aspect = aspect; Target = target; Expire = DateTime.UtcNow + duration; }
protected override BaseExplodeEffect CreateEffect(BaseAspect aspect) { return(new PoisonExplodeEffect( aspect.Location, aspect.Map, Math.Max(5, aspect.RangePerception / 2), 0, TimeSpan.FromMilliseconds(500))); }
protected override void OnDamage(BaseAspect aspect, Mobile target, ref int damage) { base.OnDamage(aspect, target, ref damage); if (target.ApplyPoison(aspect, Poison.Lethal) != ApplyPoisonResult.Poisoned) { damage *= 2; } }
public MechanicSpawner(BaseAspect aspect) : base(0x2ADD, 0x32F4) { Aspect = aspect; Hits = HitsMax = Aspect.Scale(1000); Register(this); }
private void Hailstorm(BaseAspect aspect, Point3D loc) { var effect = Utility.RandomMinMax(9006, 9007); new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, effect, 2999, 1).Send(); new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, effect, 0, 4) { SoundID = 247 }.MovingImpact(e => HailstormImpact(aspect, e.Target.Location, 4)); }
public TinkerSpawner(BaseAspect aspect) : base(0x2ADD, 0x32F4) { Aspect = aspect; Hue = 1150; Hits = HitsMax = Aspect.Scale(1000); Register(this); }
public override bool CanInvoke(BaseAspect aspect) { if (!base.CanInvoke(aspect)) { return(false); } List <IAspectSpawn> spawn; return(!Spawn.TryGetValue(aspect, out spawn) || spawn == null || spawn.Count < SpawnLimit); }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } aspect.ReflectMelee = true; Timer.DelayCall(Duration, a => a.ReflectMelee = false, aspect); }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } if (aspect.PlayAttackAnimation()) { aspect.PlayAttackSound(); } var targets = ListPool <Mobile> .AcquireObject(); targets.AddRange(AcquireTargets <Mobile>(aspect)); if (targets.Count > 0) { using (var fx = new EffectInfo(aspect, aspect.Map, 14120, 0, 10, 10, EffectRender.Lighten)) { fx.SoundID = 510; Mobile t; var i = targets.Count; foreach (var p in targets.Select(o => o.Location)) { t = targets[--i]; fx.SetSource(t); fx.Send(); t.Location = p; fx.Send(); } var l = aspect.Location; t = targets.GetRandom(); fx.SetSource(aspect); fx.Send(); aspect.Location = t.Location; fx.Send(); t.Location = l; } } ObjectPool.Free(targets); }
private void BoulderBlast(BaseAspect aspect, EffectInfo e) { if (aspect.Deleted || !aspect.Alive || e.ProcessIndex != 0) { return; } foreach (var t in AcquireTargets <Mobile>(aspect, e.Source.Location, 0)) { Damage(aspect, t); } }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } Point3D loc; var tries = 30; do { loc = aspect.GetRandomPoint3D(4, 8, aspect.Map, true, true); }while (loc.FindEntitiesInRange <IAspectSpawn>(aspect.Map, 8).Any() && --tries >= 0); if (tries < 0) { return; } var s = CreateSpawn(aspect); if (s == null) { return; } Register(s); if (aspect.PlayAttackAnimation()) { aspect.PlayAttackSound(); aspect.TryParalyze( TimeSpan.FromSeconds(1.5), m => { SpellHelper.Turn(m, loc); s.OnBeforeSpawn(loc, m.Map); s.MoveToWorld(loc, m.Map); s.OnAfterSpawn(); }); } else { SpellHelper.Turn(aspect, loc); s.OnBeforeSpawn(loc, aspect.Map); s.MoveToWorld(loc, aspect.Map); s.OnAfterSpawn(); } }
protected override void OnDamage(BaseAspect aspect, Mobile target, ref int damage) { base.OnDamage(aspect, target, ref damage); using (var fx = new EffectInfo(target, target.Map, 14000, 0, 10, 30)) { fx.SoundID = 519; fx.Send(); } target.TryParalyze(TimeSpan.FromSeconds(1.0)); target.Z = Math.Max(target.Z, Math.Min(aspect.Z + 40, target.Z + 5)); }
public void Damage(BaseAspect aspect, Mobile target) { int damage = Utility.RandomMinMax(DamageMin, DamageMax); if (damage > 0) { OnDamage(aspect, target, ref damage); } if (damage > 0) { target.Damage(damage, aspect); } }
private void BoulderImpact(BaseAspect aspect, Point3D loc, int blastRange) { if (aspect.Deleted || !aspect.Alive) { return; } new EarthExplodeEffect(loc, aspect.Map, blastRange) { AverageZ = false, EffectMutator = e => e.SoundID = 1231, EffectHandler = e => BoulderBlast(aspect, e) }.Send(); }
private void MeteoriteImpact(BaseAspect aspect, Point3D loc, int blastRange) { if (aspect.Deleted || !aspect.Alive) { return; } new FireExplodeEffect(loc, aspect.Map, blastRange) { AverageZ = false, EffectMutator = e => e.SoundID = 520, EffectHandler = e => MeteoriteBlast(aspect, e) }.Send(); }
private void HandleDeathRay(BaseAspect aspect, EffectInfo e) { if (aspect.Deleted || !aspect.Alive || e.ProcessIndex != 0) { return; } foreach (var t in AcquireTargets <Mobile>(aspect, e.Source.Location, 0)) { Effects.SendBoltEffect(t, true, e.Hue); Damage(aspect, t); } }