public void MeteorImpact_Callback(Point3D impactloc) { var queue = new EffectQueue(); queue.Deferred = true; for (int i = 0; i < 10; i++) { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile target in AcquireTargets(impactloc, MeteorRange)) { if (target is BaseCreature) { target.Damage(50, this); } else { target.Damage(10, this); } } }); e.Send(); } queue.Process(); }
public void Next() { RoundMark++; FlowWordQueue.Next(); EffectQueue.Next(); MissileQueue.Next(); if (RoundMark % 4 == 0) //200ms { float pastRound = (float)200 / GameConstants.RoundTime; MonsterQueue.NextAction(pastRound); //1回合 PlayerManager.Update(false, pastRound, StatisticData.Round); Round += pastRound; if (Round >= 1) { Round = 0; PlayerManager.CheckRoundCard(); //1回合 } } StatisticData.Round = RoundMark * 50 / GameConstants.RoundTime + 1;//50ms if (RoundMark % 10 == 0) { AIStrategy.AIProc(PlayerManager.RightPlayer); } }
public void Ultima_Callback() { var startloc = new Point3D(X, Y, 100); var point = new Point3D(Location); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 13920, 4, 1, EffectRender.Normal, TimeSpan.FromMilliseconds(60), () => { })); queue.Add( new MovingEffectInfo( startloc, point, Map, 14360, 0, 30, EffectRender.Normal, null, () => { })); queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point); }
public void UltimaImpact_Callback(Point3D impactloc) { CurrentSpell.Clear(); var queue = new EffectQueue(); queue.Deferred = true; BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance( impactloc, Map, 8, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile mobile in AcquireAllTargets(impactloc, 8)) { if (mobile is PlayerMobile) { mobile.Damage(UltimaDamage, this); } else { mobile.Damage(UltimaPetDamage, this); } } }); e.Send(); queue.Process(); CantWalk = false; }
public void SandMine_Callback() { List <Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } var startloc = new Point3D(X, Y, Z); var point = new Point3D(rangelist[index].Location); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 4586, 0, 5, EffectRender.Normal, TimeSpan.FromSeconds(1), () => { var sandmine = new SandMine(); sandmine.MoveToWorld(point, Map); })); queue.Process(); }
protected void GreaterExplosion_Callback() { var queue = new EffectQueue(); queue.Deferred = false; List <Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } Point3D endpoint = rangelist[index].Location; Point3D[] line = Location.GetLine3D(endpoint, Map); int n = 0; foreach (Point3D p in line) { n += 20; Point3D p1 = p; queue.Add( new EffectInfo( p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile player in AcquireTargets(p1, 0)) { player.Damage(50, this); } })); } queue.Callback = () => { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( endpoint, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile player in AcquireTargets(endpoint, 5)) { player.Damage(25, this); } }); e.Send(); }; queue.Process(); }
public void Init() { EffectQueue = new EffectQueue(); FlowWordQueue = new FlowWordQueue(); MonsterQueue = new MonsterQueue(); StatisticData = new BattleStatisticData(); RuleData = new BattleRuleData(); PlayerManager = new PlayerManager(); MissileQueue = new MissileQueue(); IsNight = false; }
public EffectQueueShould() { settings = new Settings() { subEffect1 = "subEffect1", subEffect3 = "subEffect3", subEffect6 = "subEffect6", bitsToSecRatio = 0.6, subEffectSec = 10 }; effectQueue = new EffectQueue(settings); }
public static void ExampleQueuedFlamestrikes(IPoint3D source, IPoint3D target, Map map) { //Create new standard queue. //Deferred option is true by default, meaning all effects will be processed sequentially. //If it was false, all effects would be processed at the same time, regardless of any delays. EffectQueue queue = new EffectQueue(); //Attach an optional effect handler. //This callback is fired for every effect in the queue when they are sent. queue.Handler = effect => { //It's handy for using the effect object to reference the location of //the effect and other values needed to do stuff. }; //Attach an optional callback handler. //This callback is fired when all effects in the queue have been processed and all delays have elapsed. queue.Callback = () => { //Handy for making sure an action only happens after the entire queue is done processing. }; //Generate a line of points (aka a 'path') var line = source.GetLine3D(target, map); //Build the queue based on the points in the line. foreach (Point3D p in line) { queue.Add( new EffectInfo( p, map, 14089, 0, 10, 30, EffectRender.Normal, null, () => { //Callback fired after effect is sent and any delay has elapsed. //I like to use this for sound effects, or maybe gather mobs to damage. //It's fired pretty much at the same time as the queue.Handler callback. })); } //Starts processing the queue and sending the effects! queue.Process(); }
public static void FlameSpiral(Point3D target, Map map) { var queue = new EffectQueue { Deferred = false }; var points = new List <Point3D>(); double d; double r = 1; int newx; int newy; points.Add(target); //calculate spiral vector for (d = 0; d < 4 * Math.PI; d += 0.01) { newx = (int)Math.Floor(target.X + (Math.Sin(d) * d) * r); newy = (int)Math.Floor(target.Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r); var to = new Point3D(newx, newy, target.Z); if (!points.Contains(to)) { points.Add(to); } } int n = 0; //Build the queue based on the points in the line. foreach (Point3D p in points) { n += 20; queue.Add( new EffectInfo(p, map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { })); } n += 400; //used to offset when the spiral reverses so it doesn't overlap foreach (Point3D p in points.AsEnumerable().Reverse()) { n += 20; queue.Add( new EffectInfo(p, map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { })); } queue.Process(); }
public void MeteorImpact_Callback(Point3D impactloc) { var queue = new EffectQueue(); queue.Deferred = true; BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile player in AcquireTargets(impactloc, MeteorRange)) { player.Damage(50, this); } }); e.Send(); queue.Process(); }
public bool PrepareEffect() { CurrentEffect = null; if (EffectQueue.Count > 0) { EffectDescription effDesc = null; lock (EffectQueue) { effDesc = EffectQueue.Dequeue(); } var eff = new Effect(effDesc, this); CurrentEffect = eff; Console.WriteLine($"{Name} должен {effDesc.direction} {eff.Count} {effDesc.item}"); } return(true); }
public void Ultima_Callback() { List <Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } var startloc = new Point3D(rangelist[index].X, rangelist[index].Y, 100); var point = new Point3D(rangelist[index].Location); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 13920, 60, 1, EffectRender.Normal, TimeSpan.FromMilliseconds(60), () => { })); queue.Add( new MovingEffectInfo( startloc, point, Map, 14360, 0, 30, EffectRender.Normal, null, () => { })); queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point); }
public override void Update(Timestep timestep, EntityUniverseFacade universe) { base.Update(timestep, universe); if (DockedItem.Stack.Item is ChargeableItem chargeable) { if (_oldItemCode != chargeable.Configuration.Code) { var newItem = (ChargeableItem)GameContext.ItemDatabase.InstanceFromItemConfiguration(chargeable.Configuration); newItem.SetPower(chargeable.ItemPower.CurrentCharge); EmptyWithoutExploding(universe); AddToDock(_entity, new ItemStack(newItem, 1)); EffectQueue.StopAll(); } } }
public override bool TryDock(Entity user, EntityUniverseFacade facade, ItemStack stack, uint rotation) { if (CanDock(stack) <= 0) { return(false); } var entry = FindEntry(stack.Item); if (!entry.PlaceSoundGroup.IsNullOrEmpty()) { BaseEffects.PlaySound(_entity, entry.PlaceSoundGroup); } if (!entry.EffectTrigger.IsNullOrEmpty()) { EffectQueue.Trigger(new EffectTrigger(entry.EffectTrigger)); } AddToDock(user, stack, entry, rotation); return(true); }
public static void SendFlameLine(Mobile from, Mobile target) { target.Frozen = true; var queue = new EffectQueue { Deferred = false }; Point3D endpoint = target.Location; Point3D[] line = from.Location.GetLine3D(endpoint, from.Map); int n = 0; foreach (Point3D p in line) { n += 20; //Point3D p1 = p; queue.Add( new EffectInfo(p, from.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { })); } queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(1), SendSpiral, target); }
public void Ultima_Callback() { List<Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } var startloc = new Point3D(rangelist[index].X, rangelist[index].Y, 100); var point = new Point3D(rangelist[index].Location); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 13920, 60, 1, EffectRender.Normal, TimeSpan.FromMilliseconds(60), () => { })); queue.Add( new MovingEffectInfo( startloc, point, Map, 14360, 0, 30, EffectRender.Normal, null, () => { })); queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point); }
public void UltimaImpact_Callback(Point3D impactloc) { CurrentSpell.Clear(); var queue = new EffectQueue(); queue.Deferred = true; BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance( impactloc, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile mobile in AcquireAllTargets(impactloc, 5)) { if (mobile is ZombieAvatar) { mobile.Damage(UltimaDamage, this); } } }); e.Send(); queue.Process(); CantWalk = false; }
public void FlamestrikeSpiral() { var queue = new EffectQueue(); queue.Deferred = false; var points = new List <Point3D>(); double d; double r = 1; int newx; int newy; points.Add(Location); //calculate spiral vector for (d = 0; d < 4 * Math.PI; d += 0.01) { newx = (int)Math.Floor(X + (Math.Sin(d) * d) * r); newy = (int) Math.Floor(Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r); var to = new Point3D(newx, newy, Z); if (!points.Contains(to)) { points.Add(to); } } int n = 0; //Build the queue based on the points in the line. foreach (Point3D p in points) { n += 20; Point3D p1 = p; queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile m in AcquireTargets(p1, 0)) { m.Damage(25, this); } } )); } n += 400; //used to offset when the spiral reverses so it doesn't overlap foreach (Point3D p in points.AsEnumerable().Reverse()) { n += 20; Point3D p1 = p; queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile m in AcquireTargets(p1, 0)) { m.Damage(25, this); } } )); } queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(6.0), Death_Callback); }
public void SandMine_Callback() { List<Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } var startloc = new Point3D(X, Y, Z); var point = new Point3D(rangelist[index].Location); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 4586, 0, 5, EffectRender.Normal, TimeSpan.FromSeconds(1), () => { var sandmine = new SandMine(); sandmine.MoveToWorld(point, Map); })); queue.Process(); }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } var list = ListPool <EffectQueue> .AcquireObject(); var cw = Utility.RandomBool(); for (int a = (cw ? 0 : 360), h = 0; (cw ? a <= 360 : a >= 0); a += (cw ? 1 : -1)) { var x = (int)Math.Round(aspect.X + (aspect.RangePerception * Math.Sin(Geometry.DegreesToRadians(a)))); var y = (int)Math.Round(aspect.Y + (aspect.RangePerception * Math.Cos(Geometry.DegreesToRadians(a)))); if (((x * 397) ^ y) == h) { // This location was just handled, ignore it to avoid small increments continue; } h = ((x * 397) ^ y); var start = aspect.Clone3D(0, 0, 10); var end = new Point3D(x, y, aspect.Z); end.Z = end.GetTopZ(aspect.Map); var l = start.GetLine3D(end, aspect.Map, false); var q = new EffectQueue { Deferred = false, Handler = e => HandleDeathRay(aspect, e) }; for (var i = 0; i < l.Length; i++) { var p = new Block3D(l[i], 5); var blocked = i + 1 >= l.Length; if (!blocked) { var land = aspect.Map.GetLandTile(p); if (p.Intersects(land.Z, land.Height)) { var o = TileData.LandTable[land.ID]; if (o.Flags.AnyFlags(_BlockingFlags)) { blocked = true; } } } if (!blocked) { var tiles = aspect.Map.GetStaticTiles(p); var data = tiles.Where(o => p.Intersects(o.Z, o.Height)).Select(t => TileData.ItemTable[t.ID]); if (data.Any(o => o.Flags.AnyFlags(_BlockingFlags))) { blocked = true; } } if (!blocked) { var items = p.FindItemsAt(aspect.Map); var data = items.Where(p.Intersects).Select(o => TileData.ItemTable[o.ItemID]); if (data.Any(o => o.Flags.AnyFlags(_BlockingFlags))) { blocked = true; } } var effect = blocked ? 14120 : Utility.RandomMinMax(12320, 12324); var hue = blocked ? 0 : 2075; if (blocked) { p = p.Clone3D(0, 0, -8); } q.Add( new EffectInfo(p, aspect.Map, effect, hue, 10, 10, EffectRender.Darken) { QueueIndex = i }); if (blocked) { break; } } if (q.Queue.Count > 0) { list.Add(q); } } if (list.Count == 0) { ObjectPool.Free(list); return; } for (var i = 0; i < list.Count; i++) { var cur = list[i]; if (i + 1 < list.Count) { var next = list[i + 1]; cur.Callback = () => { if (aspect.Deleted || !aspect.Alive) { list.ForEach(q => q.Dispose()); ObjectPool.Free(list); return; } if (next.Queue.Count > 0) { SpellHelper.Turn(aspect, next.Queue.Last().Source); } Timer.DelayCall(TimeSpan.FromSeconds(0.05), next.Process); }; } else { cur.Callback = () => { list.ForEach(q => q.Dispose()); ObjectPool.Free(list); aspect.CantWalk = false; aspect.LockDirection = false; }; } } if (list.Count == 0) { ObjectPool.Free(list); return; } aspect.CantWalk = true; aspect.LockDirection = true; if (list[0].Queue.Count > 0) { SpellHelper.Turn(aspect, list[0].Queue.Last().Source); } Timer.DelayCall(TimeSpan.FromSeconds(0.1), list[0].Process); }
private bool MyPeopleNeedMe() { if (IsFaction || Crystal == null || Crystal.Deleted || !Crystal.Visible || !Crystal.Movable || Utility.RandomBool()) { return false; } Crystal.PublicOverheadMessage(MessageType.Regular, 1287, false, "I MUST GO, MY PEOPLE NEED ME."); Point3D loc = Crystal.GetWorldLocation(); // (Lee) The reason for using effects is efficiency, // since whenever the physical item's location (Z) is changed, // it sends a bunch of update packets, I know it's trivial, // but i thought you might like this example of usage of the VNc effects :) // Create a new deferred effect queue. // When the queue has finished processing, delete the crystal. var q = new EffectQueue( () => { if (Crystal != null) { Crystal.Delete(); } }); // Add 10 effects to the queue, // each with a duration of 10 (default value), // which translates to 1000 milliseconds (10 * 100). // Since they are not moving effects and each effect lasts for 1 second, // it should produce the same illusion of the original implementation design. for (int i = 0; i < 10; i++) { q.Add( new EffectInfo( loc.Clone3D(0, 0, i), Crystal.Map, Crystal.ItemID, Crystal.Hue, 10, 10, EffectRender.Normal, TimeSpan.Zero)); } // Process the effect queue after waiting 5 seconds. Timer.DelayCall( TimeSpan.FromSeconds(5.0), () => { // Anything can happen in 5 seconds, so check it all again. if (Crystal != null && !Crystal.Deleted && Crystal.Visible && Crystal.Movable && !IsFaction) { // Hiding the crystal so the effects can handle the visuals Crystal.Visible = false; // Just in case anyone wants to try to mess with it, even when it's hidden. Crystal.Movable = false; q.Process(); } // We don't need the queue, so explicitly dispose for efficiency (optional) q.Dispose(); }); return true; }
public void DoFireEffect(IPoint3D target, Mobile from) { Map map = Map; if (target == null || map == null) { return; } //NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1); var startloc = new Point3D(Location); IPoint3D point = target; switch (Facing) { case 3: { Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 1: { Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 2: { Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 0: { Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } } Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 3699, 0, 10, EffectRender.Normal, TimeSpan.FromSeconds(0.1), () => { for (int count = 8; count > 0; count--) { IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1), target.Y + Utility.RandomMinMax(-1, 1), target.Z); int effect = Utility.RandomList(0x36B0); Effects.SendLocationEffect(location, map, effect, 25, 1); Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); } })); queue.Process(); }
protected void GreaterExplosion_Callback() { var queue = new EffectQueue(); queue.Deferred = false; List<Mobile> rangelist = AcquireTargets(Location, 15); int index = Utility.Random(rangelist.Count); if (index + 1 > rangelist.Count) { return; } Point3D endpoint = rangelist[index].Location; Point3D[] line = Location.GetLine3D(endpoint, Map); int n = 0; foreach (Point3D p in line) { n += 20; Point3D p1 = p; queue.Add( new EffectInfo( p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile player in AcquireTargets(p1, 0)) { player.Damage(50, this); } })); } queue.Callback = () => { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( endpoint, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile player in AcquireTargets(endpoint, 5)) { player.Damage(25, this); } }); e.Send(); }; queue.Process(); }
public void DoFireEffect(IPoint3D target, Mobile from) { Map map = Map; if (target == null || map == null) { return; } var startloc = new Point3D(Location); IPoint3D point = target; switch (Facing) { case 3: { Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 1: { Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 2: { Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 0: { Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } } Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, m_Projectile.AnimationID, m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue - 1 : 0, 10, EffectRender.Normal, TimeSpan.FromSeconds(0.1), () => { if (Projectile.ShipDamage > 0) { for (int count = 8; count > 0; count--) { IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1), target.Y + Utility.RandomMinMax(-1, 1), target.Z); int effect = Utility.RandomList(0x36B0); Effects.SendLocationEffect(location, map, effect, 25, 1); Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); } } foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange)) { if (from.CanBeHarmful(mob)) { mob.Damage(Projectile.PlayerDamage, from); if (from.IsHarmfulCriminal(mob) && !from.Criminal) { from.CriminalAction(true); } else if (from.IsHarmfulCriminal(mob)) { from.CriminalAction(false); } } } foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange)) { if (item is MainMast) { var mast = item as MainMast; if (mast.HullDurability < Projectile.ShipDamage) { mast.HullDurability = 0; } else { mast.HullDurability -= (ushort)Projectile.ShipDamage; } mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability); } if (item is BaseShipWeapon) { var cannon = item as BaseShipWeapon; if (cannon.Durability < Projectile.ShipDamage) { cannon.Durability = 0; } else { cannon.Durability -= Projectile.ShipDamage; } } if (item is NewBaseBoat) { var boat = item as NewBaseBoat; if (boat.HullDurability < Projectile.ShipDamage) { boat.HullDurability = 0; } else { boat.HullDurability -= (ushort)Projectile.ShipDamage; } boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability); } } })); queue.Process(); Projectile.Delete(); Projectile = null; this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15); }
protected override void OnInvoke(BaseAspect aspect) { if (aspect == null || aspect.Deleted) { return; } var map = aspect.Map; var x = aspect.X; var y = aspect.Y; var z = aspect.Z; var count = Utility.RandomMinMax(5, 10); var sect = 360 / count; var shift = Utility.RandomMinMax(0, sect); var range = Math.Max(3, aspect.RangePerception - 3); for (var i = 0; i < count; i++) { var t = Angle.GetPoint3D(x, y, z, shift + (i * sect), range); var l = aspect.PlotLine3D(t).TakeWhile(p => map.HasLand(p) && !map.HasWater(p)); var q = new EffectQueue(range); var c = -1; foreach (var p in l) { q.Add( new EffectInfo(p, map, 14089, 0, 8, 15, EffectRender.Darken) { QueueIndex = ++c }); } if (q.Count == 0) { q.Dispose(); continue; } q.Handler = fx => { var isEnd = fx.QueueIndex >= c; if (!TryBurst(aspect, fx, ref isEnd) || isEnd) { q.Clear(); } }; q.Callback = q.Dispose; Timer.DelayCall( TimeSpan.FromSeconds(0.2 * i), () => { aspect.Direction = aspect.GetDirection(t); if (aspect.PlayAttackAnimation()) { aspect.PlayAttackSound(); } q.Process(); }); } }
public void DoFireEffect(IPoint3D target) { Map map = Map; if (target == null || map == null) { return; } NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1); var startloc = new Point3D(Location); IPoint3D point = target; switch (CannonDirection) { case CannonDirection.South: { Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case CannonDirection.North: { Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case CannonDirection.East: { Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case CannonDirection.West: { Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } } Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, 3699, 0, 10, EffectRender.Normal, TimeSpan.FromSeconds(0.1), () => { for (int count = 8; count > 0; count--) { IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1), target.Y + Utility.RandomMinMax(-1, 1), target.Z); int effect = Utility.RandomList(0x36B0); Effects.SendLocationEffect(location, map, effect, 25, 1); Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); } foreach (Mobile player in AcquireAllTargets(new Point3D(point), 3)) { var damage = player.Hits * 0.4; player.Damage((int)Math.Round(damage)); } })); queue.Process(); }
public void DoAbilityMoltenBreath(BaseCreature target, BaseMetaPet pet) { pet.PlaySound(pet.BaseSoundID); pet.Animate(12, 5, 1, true, false, 0); var queue = new EffectQueue(); queue.Deferred = false; Point3D endpoint = target.Location; Point3D[] line = pet.Location.GetLine3D(endpoint, pet.Map); if (target.InRange(pet.Location, 10)) { int n = 0; foreach (Point3D p in line) { n += 20; Point3D p1 = p; queue.Add( new EffectInfo( p, pet.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile player in AcquireTargets(pet, p1, 0)) { player.Damage(Level * 9, pet); } })); } queue.Callback = () => { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( endpoint, pet.Map, 2, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile mobile in AcquireTargets(pet, endpoint, 2)) { mobile.Damage(Level * 8, pet); } }); e.Send(); }; queue.Process(); Experience++; if (Experience >= NextLevelExperience) { LevelUpMoltenBreath(pet.ControlMaster); } NextUse = DateTime.UtcNow + CoolDown; } }
public static void SendSpiral(Mobile target) { var queue = new EffectQueue { Deferred = false }; var points = new List<Point3D>(); double d; double r = 1; int newx; int newy; points.Add(target.Location); //calculate spiral vector for (d = 0; d < 4 * Math.PI; d += 0.01) { newx = (int)Math.Floor(target.X + (Math.Sin(d) * d) * r); newy = (int)Math.Floor(target.Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r); var to = new Point3D(newx, newy, target.Z); if (!points.Contains(to)) { points.Add(to); } } int n = 0; //Build the queue based on the points in the line. foreach (Point3D p in points) { n += 20; queue.Add( new EffectInfo(p, target.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { })); } n += 400; //used to offset when the spiral reverses so it doesn't overlap foreach (Point3D p in points.AsEnumerable().Reverse()) { n += 20; queue.Add( new EffectInfo(p, target.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { })); } queue.Process(); target.Frozen = false; }
public void DoFireEffect(IPoint3D target, Mobile from) { Map map = Map; if (target == null || map == null) { return; } var startloc = new Point3D(Location); IPoint3D point = target; switch (Facing) { case 3: { Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 1: { Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 2: { Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } case 0: { Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1); break; } } Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); var queue = new EffectQueue(); queue.Deferred = false; queue.Add( new MovingEffectInfo( startloc, point, Map, m_Projectile.AnimationID, m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue-1 : 0, 10, EffectRender.Normal, TimeSpan.FromSeconds(0.1), () => { if (Projectile.ShipDamage > 0) { for (int count = 8; count > 0; count--) { IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1), target.Y + Utility.RandomMinMax(-1, 1), target.Z); int effect = Utility.RandomList(0x36B0); Effects.SendLocationEffect(location, map, effect, 25, 1); Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); } } foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange)) { if (from.CanBeHarmful(mob)) { mob.Damage(Projectile.PlayerDamage, from); if (from.IsHarmfulCriminal(mob) && !from.Criminal) from.CriminalAction(true); else if (from.IsHarmfulCriminal(mob)) from.CriminalAction(false); } } foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange)) { if (item is MainMast) { var mast = item as MainMast; if (mast.HullDurability < Projectile.ShipDamage) mast.HullDurability = 0; else { mast.HullDurability -= (ushort)Projectile.ShipDamage; } mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability); } if (item is BaseShipWeapon) { var cannon = item as BaseShipWeapon; if (cannon.Durability < Projectile.ShipDamage) cannon.Durability = 0; else { cannon.Durability -= Projectile.ShipDamage; } } if (item is NewBaseBoat) { var boat = item as NewBaseBoat; if (boat.HullDurability < Projectile.ShipDamage) boat.HullDurability = 0; else { boat.HullDurability -= (ushort)Projectile.ShipDamage; } boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability); } } })); queue.Process(); Projectile.Delete(); Projectile = null; this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15); }
public void FlamestrikeSpiral() { var queue = new EffectQueue(); queue.Deferred = false; var points = new List<Point3D>(); double d; double r = 1; int newx; int newy; points.Add(Location); //calculate spiral vector for (d = 0; d < 4 * Math.PI; d += 0.01) { newx = (int) Math.Floor(X + (Math.Sin(d) * d) * r); newy = (int) Math.Floor(Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r); var to = new Point3D(newx, newy, Z); if (!points.Contains(to)) { points.Add(to); } } int n = 0; //Build the queue based on the points in the line. foreach (Point3D p in points) { n += 20; Point3D p1 = p; queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile m in AcquireTargets(p1, 0)) { m.Damage(25, this); } } )); } n += 400; //used to offset when the spiral reverses so it doesn't overlap foreach (Point3D p in points.AsEnumerable().Reverse()) { n += 20; Point3D p1 = p; queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile m in AcquireTargets(p1, 0)) { m.Damage(25, this); } } )); } queue.Process(); Timer.DelayCall(TimeSpan.FromSeconds(6.0), Death_Callback); }
private bool MyPeopleNeedMe() { if (IsFaction || Crystal == null || Crystal.Deleted || !Crystal.Visible || !Crystal.Movable || Utility.RandomBool()) { return(false); } Crystal.PublicOverheadMessage(MessageType.Regular, 1287, false, "I MUST GO, MY PEOPLE NEED ME."); Point3D loc = Crystal.GetWorldLocation(); // (Lee) The reason for using effects is efficiency, // since whenever the physical item's location (Z) is changed, // it sends a bunch of update packets, I know it's trivial, // but i thought you might like this example of usage of the VNc effects :) // Create a new deferred effect queue. // When the queue has finished processing, delete the crystal. var q = new EffectQueue( () => { if (Crystal != null) { Crystal.Delete(); } }); // Add 10 effects to the queue, // each with a duration of 10 (default value), // which translates to 1000 milliseconds (10 * 100). // Since they are not moving effects and each effect lasts for 1 second, // it should produce the same illusion of the original implementation design. for (int i = 0; i < 10; i++) { q.Add( new EffectInfo( loc.Clone3D(0, 0, i), Crystal.Map, Crystal.ItemID, Crystal.Hue, 10, 10, EffectRender.Normal, TimeSpan.Zero)); } // Process the effect queue after waiting 5 seconds. Timer.DelayCall( TimeSpan.FromSeconds(5.0), () => { // Anything can happen in 5 seconds, so check it all again. if (Crystal != null && !Crystal.Deleted && Crystal.Visible && Crystal.Movable && !IsFaction) { // Hiding the crystal so the effects can handle the visuals Crystal.Visible = false; // Just in case anyone wants to try to mess with it, even when it's hidden. Crystal.Movable = false; q.Process(); } // We don't need the queue, so explicitly dispose for efficiency (optional) q.Dispose(); }); return(true); }
public void UltimaImpact_Callback(Point3D impactloc) { var queue = new EffectQueue(); queue.Deferred = true; BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance( impactloc, Map, 4, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile mobile in AcquireAllTargets(impactloc, 4)) { if (mobile is PlayerMobile) { mobile.Damage(5, this); } else { mobile.Damage(25, this); } } }); e.Send(); queue.Process(); CantWalk = false; }
public OrtoBot(Settings settings) { this.settings = settings; queue = new EffectQueue(settings); }
public void DoAbilityMoltenBreath(BaseCreature target, BaseMetaPet pet) { pet.AIObject.NextMove = DateTime.UtcNow + TimeSpan.FromSeconds(1.0); pet.PlaySound(pet.BaseSoundID); pet.Animate(12, 5, 1, true, false, 0); var queue = new EffectQueue(); queue.Deferred = false; Point3D endpoint = target.Location; Point3D[] line = pet.Location.GetLine3D(endpoint, pet.Map); if (target.InRange(pet.Location, 10)) { int n = 0; foreach (Point3D p in line) { n += 20; Point3D p1 = p; queue.Add( new EffectInfo( p, pet.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { foreach (Mobile player in AcquireTargets(pet, p1, 0)) { player.Damage(Level * 5, pet); } })); } queue.Callback = () => { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( endpoint, pet.Map, 2, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile mobile in AcquireTargets(pet, endpoint, 2)) { mobile.Damage(Level * 3, pet); } }); e.Send(); }; queue.Process(); Experience++; if (Experience >= NextLevelExperience) { LevelUpMoltenBreath(pet.ControlMaster); } NextUse = DateTime.UtcNow + CoolDown; } }
public void MeteorImpact_Callback(Point3D impactloc) { var queue = new EffectQueue(); queue.Deferred = true; for (int i = 0; i < 10; i++) { BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance( impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () => { foreach (Mobile target in AcquireTargets(impactloc, MeteorRange)) { if (target is BaseCreature) target.Damage(50, this); else target.Damage(10, this); } }); e.Send(); } queue.Process(); }