protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { Entity[] ens = host.GetNearestEntities(dist).ToArray(); foreach (Entity e in ens) if (e.ObjectType == host.Manager.GameData.IdToObjectType[children]) host.Owner.LeaveWorld(e); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (targetState == null) targetState = FindState(host.Manager.Behaviors.Definitions[(ushort) children].Item1, targetStateName); foreach (Entity i in host.GetNearestEntities(range, children)) if (!i.CurrentState.Is(targetState)) i.SwitchTo(targetState); }
public static Entity GetNearestEntity(this Entity entity, double dist, ushort?objType) //Null for player { Entity[] entities = entity.GetNearestEntities(dist, objType).ToArray(); if (entities.Length <= 0) { return(null); } return(entities.Aggregate((curmin, x) => (curmin == null || x.DistSqr(entity) < curmin.DistSqr(entity) ? x : curmin))); }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { if (host is Enemy) { foreach (Entity i in host.GetNearestEntities(radius, children)) if (i is Enemy) if ((i as Enemy).LootState != (host as Enemy).LootState) (i as Enemy).LootState = (host as Enemy).LootState; } }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { foreach (var i in host.GetNearestEntities(25, null).OfType<Player>()) { i.Client.SendPacket(new PlaySoundPacket { OwnerId = host.Id, SoundId = soundId }); } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { var entities = host.GetNearestEntities(6); Enemy en = null; foreach (Entity e in entities) if (e is Enemy) { en = e as Enemy; break; } if (en != null & en.ObjectDesc.Enemy) { en.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0xEEEE73), TargetId = en.Id, PosA = new Position { X = 1, } }, null); en.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = en.X, Y = en.Y }, Color = new ARGB(0xEEEE73) }, null); en.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Bleeding, DurationMS = 10000 }); } cool = 1000; } else cool -= time.thisTickTimes; state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { var entities = host.GetNearestEntities(6); Enemy en = null; foreach (Entity e in entities) if (e is Enemy) { en = e as Enemy; break; } if (en != null & en.ObjectDesc.Enemy) { en.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0x3E3A78), TargetId = en.Id, PosA = new Position { X = 1, } }, null); en.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = en.X, Y = en.Y }, Color = new ARGB(0x3E3A78) }, null); en.Damage(host.GetPlayerOwner(), time, 35, false, new ConditionEffect[] { }); } cool = 300; } else cool -= time.thisTickTimes; state = cool; }
public static Entity GetNearestEntity(this Entity entity, double dist, ushort?objType) //Null for player { return(entity.GetNearestEntities(dist, objType).FirstOrDefault()); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { var entities = host.GetNearestEntities(28, 0x0d5e) .Concat(host.GetNearestEntities(28, 0x0d60)) .ToArray(); if (entities.Length != 5) return; var packets = new List<Packet>(); if (!entities.Any(_ => _.ObjectType == 0x0d5e)) { var players = new HashSet<Entity>(); foreach (var i in entities.SelectMany(_ => (_ as Enemy).DamageCounter.GetPlayerData())) if (i.Item1.Quest == host) players.Add(i.Item1); foreach (var i in players) packets.Add(new NotificationPacket { ObjectId = i.Id, Color = new ARGB(0xFF00FF00), Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Quest Complete!\"}}" }); if (host.Owner is GameWorld) (host.Owner as GameWorld).EnemyKilled(host as Enemy, (entities.Last() as Enemy).DamageCounter.Parent.LastHitter); new Decay(0).Tick(host, time); foreach (var i in entities) new Suicide().Tick(i, time); } else { var hasCorpse = entities.Any(_ => _.ObjectType == 0x0d60); for (var i = 0; i < entities.Length; i++) for (var j = i + 1; j < entities.Length; j++) { packets.Add(new ShowEffectPacket { TargetId = entities[i].Id, EffectType = EffectType.Stream, Color = new ARGB(hasCorpse ? 0xFFFFFF : 0xffff0000), PosA = new Position { X = entities[j].X, Y = entities[j].Y }, PosB = new Position { X = entities[i].X, Y = entities[i].Y } }); } } host.Owner.BroadcastPackets(packets, null); cool = this.cool.Next(Random); } else cool -= time.thisTickTimes; state = cool; }