protected override void TickCore(Entity host, RealmTime time, ref object state) { //sinceCopy_ += time.thisTickCounts; //if (sinceCopy_ < 1.0) //{ // return; //} //sinceCopy_ = 0.0; if (targetId_ == ushort.MaxValue) { targetId_ = host.Manager.GameData.IdToObjectType[this.targetName_]; } Entity[] target = (host.GetNearestEntities(range_, targetId_).ToArray()); if (target.FirstOrDefault() == null) { targetId_ = ushort.MaxValue; return; } for (var i = 0; i < target.Count(); i++) { if ((host as Enemy).DamageCounter.Total == (target[i] as Enemy).DamageCounter.Total) { return; } (target[i] as Enemy).SetDamageCounter((host as Enemy).DamageCounter, (target[i] as Enemy)); } return; }
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) this.targetState = FindState(BehaviorDb.Definitions[this.children].Item1, targetStateName); foreach (var i in host.GetNearestEntities(range, children)) if (!i.CurrentState.Is(targetState)) i.SwitchTo(targetState); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (targetState == null) targetState = FindState(host.Manager.Behaviors.Definitions[(ushort)target].Item1, targetStateName); foreach (Entity i in host.GetNearestEntities(range, target)) if (!i.CurrentState.Is(targetState)) i.SwitchTo(targetState); }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { var ens = host.GetNearestEntities(dist).ToArray(); foreach (var e in ens.Where(e => e.ObjectType == host.Manager.GameData.IdToObjectType[children])) { host.Owner.LeaveWorld(e); } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { foreach (var entity in host.GetNearestEntities(_range, null, true).OfType <Player>()) { if (entity.Owner == null) { continue; } if ((host.AttackTarget != null && host.AttackTarget != entity) || entity.HasConditionEffect(ConditionEffects.Sick)) { continue; } int maxHp = entity.Stats[0]; int newHp = Math.Min(entity.HP + _healAmount, maxHp); if (newHp != entity.HP) { int n = newHp - entity.HP; entity.HP = newHp; entity.Owner.BroadcastPacketNearby(new ShowEffect() { EffectType = EffectType.Potion, TargetObjectId = entity.Id, Color = new ARGB(0xffffffff) }, entity, null, PacketPriority.Low); entity.Owner.BroadcastPacketNearby(new ShowEffect() { EffectType = EffectType.Trail, TargetObjectId = host.Id, Pos1 = new Position { X = entity.X, Y = entity.Y }, Color = new ARGB(0xffffffff) }, host, null, PacketPriority.Low); entity.Owner.BroadcastPacketNearby(new Notification() { ObjectId = entity.Id, Message = "+" + n, Color = new ARGB(0xff00ff00) }, entity, null, PacketPriority.Low); } } cool = _coolDown.Next(Random); } else { cool -= time.ElapsedMsDelta; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Savage, true); } else { return; } if (level == null) { return; } Enemy[] targets = host.GetNearestEntities(7).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { var vectt = new Vector2(e.X - host.X, e.Y - host.Y); var pet = (Pet)host; var player = host.GetEntity(pet.PlayerOwner.Id) as Player; var vecttt = new Vector2(player.X - host.X, player.Y - host.Y); var distt = host.GetSpeed(0.5f); if (vectt.Length < 6 && vecttt.Length < 6 && vectt.Length > 1) { distt = host.GetSpeed(1); vectt.Normalize(); host.Move(e.X, e.Y); host.UpdateCount++; } else if (vecttt.Length > 5) { distt = host.GetSpeed(0.5f); host.UpdateCount++; } } cool = getCooldown(host as Pet, level); } else { cool -= time.thisTickTimes; } state = cool; }
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 TickCore(Entity host, RealmTime time, ref object state) { if (targetState == null) { targetState = FindState(host.Manager.Behaviors.Definitions[(ushort)target].Item1, targetStateName); } foreach (var i in host.GetNearestEntities(range, target).Where(i => !i.CurrentState.Is(targetState))) { i.SwitchTo(targetState); } }
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 OnStateEntry(Entity host, RealmTime time, ref object state) { Entity[] ens = host.GetNearestEntities(dist).ToArray(); foreach (Entity e in ens) { if (e.ObjectType == GameServer.Manager.GameData.IdToObjectType[children]) { host.Owner.LeaveWorld(e); } } }
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 SHOWEFFECT { EffectType = EffectType.Nova, Color = new ARGB(0x003298), TargetId = en.Id, PosA = new Position { X = 1, } }, null); en.Owner.BroadcastPacket(new SHOWEFFECT { EffectType = EffectType.Line, TargetId = host.Id, PosA = new Position { X = en.X, Y = en.Y }, Color = new ARGB(0x003298) }, null); en.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Paralyzed, DurationMS = 5000 }); } cool = 5000; } else { cool -= time.ElapsedMsDelta; } state = cool; }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { foreach (var i in host.GetNearestEntities(25, null).OfType <Player>()) { i.Client.SendMessage(new PLAYSOUND { 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 ShowEffect() { EffectType = EffectType.AreaBlast, Color = new ARGB(0x3E3A78), TargetObjectId = en.Id, Pos1 = new Position { X = 1, } }, null); en.Owner.BroadcastPacket(new ShowEffect() { EffectType = EffectType.Trail, TargetObjectId = host.Id, Pos1 = new Position { X = en.X, Y = en.Y }, Color = new ARGB(0x3E3A78) }, null); en.Damage(host.GetPlayerOwner(), time, _damage, true); en.ApplyConditionEffect(new ConditionEffect { Effect = _effect, DurationMS = _duration }); } cool = 600; } else { cool -= time.ElapsedMsDelta; } state = cool; }
public static Entity GetLowestHpEntity(this Entity entity, double dist, ushort?objType, bool seeInvis = false) // objType = null for player { var entities = entity.GetNearestEntities(dist, objType, seeInvis).OfType <Character>(); if (!entities.Any()) { return(null); } var lowestHp = entities.Min(e => e.HP); return(entities.FirstOrDefault(e => e.HP == lowestHp)); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (targetState == null) { targetState = FindState(GameServer.Manager.Behaviors.Definitions[name].Item1, targetStateName); } foreach (Entity i in host.GetNearestEntities(range, name)) { if (!i.CurrentState.Is(targetState)) { i.SwitchTo(targetState); } } }
public static Entity GetNearestEntity(this Entity entity, double dist, ushort?objType, bool seeInvis = false) //Null for player { //return entity.GetNearestEntities(dist, objType).FirstOrDefault(); // function speed might be a problem var entities = entity.GetNearestEntities(dist, objType, seeInvis).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 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; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (!CheckHp(host, threshold)) { return; } if (targetState == null) { targetState = FindState(host.Manager.Behaviors.Definitions[children].Item1, targetStateName); } foreach (var i in host.GetNearestEntities(dist, children).Where(i => !i.CurrentState.Is(targetState))) { i.SwitchTo(targetState); } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (_targetState == null) { _targetState = FindState(host.Manager.Behaviors.Definitions[_children].Item1, _targetStateName); } foreach (var i in host.GetNearestEntities(_range, _children)) { if (!i.CurrentState.Is(_targetState)) { i.SwitchTo(_targetState); } } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { Enemy en = null; Enemy[] targets = host.GetNearestEntities(7).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { 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(color), 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(color) }, null); en.Damage(host.GetPlayerOwner(), time, amount, trueDamage, new ConditionEffect[] { }); } cool = 200; } else { cool -= time.thisTickTimes; } state = cool; }
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 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(0x48D747), 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(0x48D747) }, null); en.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Slowed, DurationMS = 10000 }); } cool = 300; } else cool -= time.thisTickTimes; state = cool; }
protected override void OnStateExit(Entity host, RealmTime time, ref object state) { foreach (var player in host.GetNearestEntities(Player.Radius, null, true).OfType <Player>()) { if (player.clientEntities.Contains(host)) { child.OnStateExit(host, time); if (child is CycleBehavior) { Status = (child as CycleBehavior).Status; } else { Status = CycleStatus.InProgress; } return; } } Status = CycleStatus.NotStarted; }
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; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { var cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffects.Sick)) { return; } if (host.GetNearestEntity(radius, null) != null) { var pkts = new List <Packet>(); foreach (var player in host.GetNearestEntities(radius, null).Select(p => (p as Player)).Where(player => player.Stats[0] + player.Boost[0] != player.HP)) { player.EntityHealHp(player, host, amount, pkts); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = player.X, Y = player.Y }, Color = new ARGB(0xffffffff) }); } host.Owner.BroadcastPackets(pkts, null); } cool = coolDown.Next(Random); } else { cool -= time.thisTickTimes; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; /*if (host is Pet) * { * Pet p = host as Pet; * level = p.GetPetLevelFromAbility(Ability.Decoy, true); * } * else return;*/ if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); Player player = host.GetEntity((host as Pet).PlayerOwner.Id) as Player; Decoy decoy = new Decoy(host.Manager, player, 2000, tps: player.StatsManager.GetSpeed()); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 110) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } /*decoy.Move(host.X, host.Y); * * host.Owner.Timers.Add(new WorldTimer((5000 - level.Level*10), (w, t) => * host.Owner.EnterWorld(decoy) * ));*/ } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } else { cool -= time.thisTickTimes; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { Result = host.GetNearestEntities(dist, target).Count() > amount; }
// duty loop protected override void TickCore( Entity npc, RealmTime time, ref object state ) { if (_NPC == null) { return; } var entities = npc.GetNearestEntities(_range * 2, null).ToList(); Parallel.ForEach(entities, entity => { Player player; if (entity is Player) { player = entity as Player; } else { return; } if (_NPC.ReturnPlayersCache().Contains(player.Name) && !entities.Contains(player)) { _NPC.RemovePlayer(player); // Removing player into NPC's players cache. ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache. return; } try { if (npc.Dist(player) > _range && _NPC.ReturnPlayersCache().Contains(player.Name)) { _NPC.RemovePlayer(player); // Removing player into NPC's players cache. _NPC.Leave(player, false); // Player sent a valid leave message (polite: false), processing NPC reply. ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache. return; } if (ChatManager.ChatDataCache.ContainsKey(player.Name)) { //Chat data cache contains player var messageInfo = ChatManager.ChatDataCache[player.Name]; if (_NPC.ReturnPlayersCache().Contains(player.Name)) { // NPC's players cache contains player. if (npc.Dist(player) <= _range) { if (_playerWelcomeMessages.Contains(messageInfo.Item2.ToLower())) { _NPC.NoRepeat(player); // Duplicated NPC Welcome message! Sending non-repeat message to player ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache. return; } if (_playerLeaveMessages.Contains(messageInfo.Item2.ToLower()) && messageInfo.Item1 >= _now.AddMilliseconds(-_delay) && messageInfo.Item1 <= _now.AddMilliseconds(_delay)) { _NPC.RemovePlayer(player); // Removing player into NPC's players cache. _NPC.Leave(player, true); // Player sent a valid leave message (polite: true), processing NPC reply. ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache. return; } } } else { if (_playerWelcomeMessages.Contains(messageInfo.Item2.ToLower()) && npc.Dist(player) <= _range && messageInfo.Item1 >= _now.AddMilliseconds(-_delay) && messageInfo.Item1 <= _now.AddMilliseconds(_delay)) { _NPC.AddPlayer(player); // Adding player into NPC's players cache. _NPC.Welcome(player); // Processing Welcome message to player target. ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache. } } } } catch (InvalidOperationException) { } // collection can be updated, so new handler exception for it }); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { Result = host.GetNearestEntities(dist, target).Count() == amount; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { float flashPeriod = 0.5f; int flashRepeats = 10; int cooldown = 0; PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.RisingFury, true); } else { return; } if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 110) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 80, Effect = ConditionEffectIndex.Slowed }); e.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, Color = new ARGB(0x00FFA500), PosA = new Position { X = level.Level * 80 }, TargetId = e.Id }, null); while (cooldown <= 5000) { host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Flashing, PosA = new Position { X = flashPeriod, Y = flashRepeats }, TargetId = host.Owner.Id, Color = new ARGB(0x001E90FF) }, null); cooldown += time.thisTickTimes; } /*host.Owner.Timers.Add(new WorldTimer(500, (w, t) => * host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * Color = new ARGB(0x001E90FF), * PosA = new Position { X = host.X, Y = host.Y }, * TargetId = host.Id * }, null) * ));*/ /*host.Owner.Timers.Add(new WorldTimer(250, (w, t) => * { * host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * Color = new ARGB(0x001E90FF), * PosA = new Position { X = host.X, Y = host.Y }, * TargetId = host.Id * }, null); * (host as Entity).UpdateCount++; * }));*/ /*host.Owner.BroadcastPacket(new ShowEffectPacket * { * PosA = new Position { X = host.X, Y = host.Y }, * EffectType = EffectType.Flashing, * TargetId = host.Id, * }, null);*/ /*e.Damage(null, time, level.Level, true, new ConditionEffect * { * DurationMS = level.Level * 40, * Effect = ConditionEffectIndex.Paralyzed * });*/ } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } 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(28, 0x0d5e) .Concat(host.GetNearestEntities(28, 0x0d60)) .ToArray(); if (entities.Length != 5) { return; } var packets = new List <Message>(); 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 NOTIFICATION { 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 SHOWEFFECT { 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.ElapsedMsDelta; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { var 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.All(_ => _.ObjectType != 0x0d5e)) { var players = new HashSet <Entity>(); foreach (var i in entities.SelectMany(_ => (_ as Enemy).DamageCounter.GetPlayerData()).Where(i => i.Item1.Quest == host)) { players.Add(i.Item1); } packets.AddRange(players.Select(i => new NotificationPacket { ObjectId = i.Id, Color = new ARGB(0xFF00FF00), Text = "Quest Complete!" })); (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; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Electric, true); } else { return; } if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 100) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); e.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ElectricFlashing, PosA = new Position { X = level.Level * 40 }, TargetId = e.Id }, null); host.Owner.BroadcastPacket(new ShowEffectPacket { PosA = new Position { X = host.X, Y = host.Y }, EffectType = EffectType.ElectricBolts, TargetId = host.Id, }, null); e.Damage(null, time, level.Level, true, new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } else { cool -= time.thisTickTimes; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { var cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffects.Sick)) return; if(host.GetNearestEntity(radius, null) != null) { var pkts = new List<Packet>(); foreach (var player in host.GetNearestEntities(radius, null).Select(p => (p as Player)).Where(player => player.Stats[0] + player.Boost[0] != player.HP)) { player.EntityHealHp(player, host, amount, pkts); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position {X = player.X, Y = player.Y}, Color = new ARGB(0xffffffff) }); } host.Owner.BroadcastPackets(pkts, null); } cool = coolDown.Next(Random); } else cool -= time.thisTickTimes; state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Savage, true); /*host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * PosA = new Position { X = host.X, Y = host.Y }, * Color = new ARGB(0x00BFFF), * TargetId = host.Id, * }, null);*/ } else { return; } if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 110) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 25, Effect = ConditionEffectIndex.Curse }); host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = e.Id, PosA = new Position { X = host.X, Y = host.Y }, PosB = new Position { X = e.X, Y = e.Y }, Color = new ARGB(0x00FFFFF0) }, null); /*host.Owner.Timers.Add(new WorldTimer(1000, (w, t) => * host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.SavageEffect, * PosA = new Position { X = host.X, Y = host.Y }, * TargetId = host.Id * }, null) * ));*/ /*e.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * PosA = new Position { X = host.X, Y = host.Y }, * Color = new ARGB(0x00BFFF), * TargetId = host.Id, * }, null);*/ /*e.Damage(null, time, level.Level, true, new ConditionEffect * { * DurationMS = level.Level * 40, * Effect = ConditionEffectIndex.Paralyzed * });*/ } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } 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) { if (state == null) return; int cool = (int) state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Electric, true); } else return; if (level == null) return; double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType<Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) continue; if (Random.Next(0, 100) > level.Level) break; if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) continue; if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) continue; e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); e.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ElectricFlashing, PosA = new Position { X = level.Level * 40}, TargetId = e.Id }, null); host.Owner.BroadcastPacket(new ShowEffectPacket { PosA = new Position { X = host.X, Y = host.Y }, EffectType = EffectType.ElectricBolts, TargetId = host.Id, }, null); e.Damage(null, time, level.Level, true, new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } 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(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; }