protected override bool TickCore(Entity host, RealmTime time, ref object state) { if (host.GetNearestEntity(dist, target) == null && host.GetNearestEntity(dist, target2) == null) { return(true); } return(false); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { var s = (OrbitState) state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; Entity entity = host.GetNearestEntity(acquireRange, target); if (entity != null) { double angle; if (host.Y == entity.Y && host.X == entity.X) //small offset angle = Math.Atan2(host.Y - entity.Y + (Random.NextDouble()*2 - 1), host.X - entity.X + (Random.NextDouble()*2 - 1)); else angle = Math.Atan2(host.Y - entity.Y, host.X - entity.X); float angularSpd = host.GetSpeed(s.Speed)/s.Radius; angle += angularSpd*(time.thisTickTimes/1000f); double x = entity.X + Math.Cos(angle)*radius; double y = entity.Y + Math.Sin(angle)*radius; Vector2 vect = new Vector2((float) x, (float) y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= host.GetSpeed(s.Speed)*(time.thisTickTimes/1000f); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); host.UpdateCount++; Status = CycleStatus.InProgress; } state = s; }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { foreach (string children in childrens) if (host.GetNearestEntity(dist, GameServer.Manager.GameData.IdToObjectType[children]) != null) return false; return true; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { ChargeState s = (state == null) ? new ChargeState() : (ChargeState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Player player = (Player)host.GetNearestEntity(range, null); if (player == null) { return; } float length = new Vector2(player.X - host.X, player.Y - host.Y).Length; if (s.RemainingTime <= 0) { if (s.Direction == Vector2.Zero) { if (player.X != host.X && player.Y != host.Y) { s.Direction = new Vector2(player.X - host.X, player.Y - host.Y); float dist = s.Direction.Length; s.Direction.Normalize(); s.RemainingTime = (int)(dist / host.EntitySpeed(speed, time) * 1000); Status = CycleStatus.InProgress; } } else { s.Direction = Vector2.Zero; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; } } if (s.Direction != Vector2.Zero) { float dist = host.EntitySpeed(speed, time); host.ValidateAndMove(host.X + s.Direction.X * dist, host.Y + s.Direction.Y * dist); host.UpdateCount++; Status = CycleStatus.InProgress; } if (length <= 0.5) { s.Direction = Vector2.Zero; s.RemainingTime = 1000; Status = CycleStatus.Completed; } s.RemainingTime -= time.ElapsedMsDelta; state = s; }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { if (host.GetNearestEntity(100, 0x5e4b) != null) return; Entity opener = Entity.Resolve(host.Manager, "Realm Portal Opener"); host.Owner.EnterWorld(opener); opener.Move(host.X, host.Y); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cooldown; if (state == null) cooldown = 1000; else cooldown = (int)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; var player = (Player)host.GetNearestEntity(distance, null); if (player != null) { Vector2 vect; vect = new Vector2(player.X - host.X, player.Y - host.Y); vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist); host.UpdateCount++; if (cooldown <= 0) { Status = CycleStatus.Completed; cooldown = 1000; } else { Status = CycleStatus.InProgress; cooldown -= time.thisTickTimes; } } state = cooldown; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { var s = (OrbitState)state; double effectiveSpeed; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } if (host.HasConditionEffect(ConditionEffects.Slowed)) { effectiveSpeed = s.Speed * 0.5; } else { effectiveSpeed = s.Speed; } Entity entity = host.GetNearestEntity(acquireRange, target); if (entity != null) { double angle; if (host.Y == entity.Y && host.X == entity.X) //small offset { angle = Math.Atan2(host.Y - entity.Y + (Random.NextDouble() * 2 - 1), host.X - entity.X + (Random.NextDouble() * 2 - 1)); } else { angle = Math.Atan2(host.Y - entity.Y, host.X - entity.X); } float angularSpd = host.GetSpeed((float)effectiveSpeed) / s.Radius; if (orientation) { angle += angularSpd * (time.ElaspedMsDelta / 1000f); } else { angle -= angularSpd * (time.ElaspedMsDelta / 1000f); } double x = entity.X + Math.Cos(angle) * radius; double y = entity.Y + Math.Sin(angle) * radius; Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= host.GetSpeed((float)effectiveSpeed) * (time.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); host.UpdateCount++; Status = CycleStatus.InProgress; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffects.Stunned)) { return; } double?tossAngle = randomToss ? Random.Next(0, 360) * Math.PI / 180 : angle; Entity en = null; if (tossAngle == null) { en = host.GetNearestEntity(range, null); } if (tossAngle == null && en == null) { return; } Position target = tossAngle == null ? new Position { X = en.X, Y = en.Y } : new Position { X = host.X + (float)(range * Math.Cos(tossAngle.Value)), Y = host.Y + (float)(range * Math.Sin(tossAngle.Value)), }; host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffffbf00), TargetId = host.Id, PosA = target }, null); host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Entity entity = Entity.Resolve(world.Manager, child); entity.Move(target.X, target.Y); if (entity is Enemy && host is Enemy) { (entity as Enemy).Terrain = (host as Enemy).Terrain; } world.EnterWorld(entity); })); cool = coolDown.Next(Random); } else { cool -= time.thisTickTimes; } state = cool; }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { if (_targets == null) { return(false); } return(_targets.All(t => host.GetNearestEntity(_dist, t) == null)); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { ChargeState s; if (state == null) { s = new ChargeState(); } else { s = (ChargeState)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } if (s.RemainingTime <= 0) { if (s.Direction == Vector2.Zero) { var player = host.GetNearestEntity(range, null); if (player != null && player.X != host.X && player.Y != host.Y) { s.Direction = new Vector2(player.X - host.X, player.Y - host.Y); float d = s.Direction.Length(); s.Direction.Normalize(); s.RemainingTime = coolDown.Next(Random); if (d / host.GetSpeed(speed) < s.RemainingTime) { s.RemainingTime = (int)(d / host.GetSpeed(speed) * 1000); } Status = CycleStatus.InProgress; } } else { s.Direction = Vector2.Zero; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; } } if (s.Direction != Vector2.Zero) { float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + s.Direction.X * dist, host.Y + s.Direction.Y * dist); host.UpdateCount++; Status = CycleStatus.InProgress; } s.RemainingTime -= time.thisTickTimes; state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (host is Pet) { if ((host as Pet).PlayerOwner != null) { return; } } WmapTile tile = host.Owner.Map[(int)host.X, (int)host.Y].Clone(); if (tile.Region == TileRegion.None && host.Owner is PetYard) { Position pos = (host as Pet).SpawnPoint; host.Move(pos.X, pos.Y); return; } if (host.GetNearestEntity(1, null) == null) { WanderStorage storage; if (state == null) { storage = new WanderStorage(); } else { storage = (WanderStorage)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { storage.Direction = new Vector2(Random.Next(-2, 2), Random.Next(-2, 2)); storage.Direction.Normalize(); storage.RemainingDistance = coolDown.Next(Random) / 1000f; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); host.UpdateCount++; storage.RemainingDistance -= dist; state = storage; } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffects.Stunned)) return; Entity player = host.GetNearestEntity(range, null); if (player != null || fixedAngle != null) { Position target; if (fixedAngle != null) target = new Position() { X = (float)(range * Math.Cos(fixedAngle.Value)), Y = (float)(range * Math.Sin(fixedAngle.Value)), }; else target = new Position() { X = player.X, Y = player.Y, }; host.Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xffff0000), TargetId = host.Id, PosA = target }, null); host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { world.BroadcastPacket(new AOEPacket() { Position = target, Radius = radius, Damage = (ushort)damage, EffectDuration = 0, Effects = 0, OriginType = host.ObjectType }, null); EntityUtils.AOE(world, target, radius, true, p => { (p as IPlayer).Damage(damage, host as Character); }); })); } cool = coolDown.Next(Random); } else cool -= time.thisTickTimes; state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { double effectiveSpeed; int cooldown; if (state == null) { cooldown = 1000; } else { cooldown = (int)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } if (host.HasConditionEffect(ConditionEffects.Slowed)) { effectiveSpeed = speed * 0.5; } else { effectiveSpeed = speed; } var player = host.GetNearestEntity(distance, null); if (player != null) { Vector2 vect; vect = new Vector2(player.X - host.X, player.Y - host.Y); vect.Normalize(); float dist = host.GetSpeed((float)effectiveSpeed) * (time.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist); host.UpdateCount++; if (cooldown <= 0) { Status = CycleStatus.Completed; cooldown = 1000; } else { Status = CycleStatus.InProgress; cooldown -= time.ElaspedMsDelta; } } state = cooldown; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Sick)) { return; } Player entity = host.GetNearestEntity(range, null) as Player; if (entity != null) { int maxHp = entity.Stats[0] + entity.Boost[0]; int newHp = Math.Min(maxHp, entity.HP + amount); if (newHp != entity.HP) { int n = newHp - entity.HP; entity.HP = newHp; entity.UpdateCount++; entity.Owner.BroadcastPacket(new SHOWEFFECT { EffectType = EffectType.Heal, TargetId = entity.Id, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new SHOWEFFECT { EffectType = EffectType.Line, TargetId = host.Id, PosA = new Position { X = entity.X, Y = entity.Y }, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new NOTIFICATION { ObjectId = entity.Id, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + n + "\"}}", Color = new ARGB(0xff00ff00) }, null); } } cool = coolDown.Next(Random); } else { cool -= time.ElapsedMsDelta; } state = cool; }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { if (host.GetNearestEntity(100, 0x5e4b) != null) { return; } Entity opener = Entity.Resolve(host.Manager, "Realm Portal Opener"); host.Owner.EnterWorld(opener); opener.Move(host.X, host.Y); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } double?tossAngle = randomToss ? Random.Next(0, 360) * Math.PI / 180 : angle; Entity en = null; if (tossAngle == null) { en = host.GetNearestEntity(range, null); } if (tossAngle == null && en == null) { return; } Position target = tossAngle == null ? new Position { X = en.X, Y = en.Y } : new Position { X = host.X + (float)(range * Math.Cos(tossAngle.Value)), Y = host.Y + (float)(range * Math.Sin(tossAngle.Value)), }; if (target.X < 0 || target.Y < 0) { return; } host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ThrowProjectile, Color = new ARGB(projectileId), PosA = target, PosB = new Position { X = host.X, Y = host.Y } //host pos. }, null); cool = coolDown.Next(Random); } else { cool -= time.ElaspedMsDelta; } state = cool; }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { foreach (string children in childrens) { if (host.GetNearestEntity(dist, host.Manager.GameData.IdToObjectType[children]) != null) { return(false); } } return(true); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { state = (string)choices[Random.Next(0, choices.Length)]; } if (host.GetNearestEntity(dist, null) != null) { new SimpleTransition((string)state).Tick(host, time); } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Sick)) { return; } Player entity = host.GetNearestEntity(range, null) as Player; if (entity != null) { int maxMp = entity.Stats[1] + entity.Boost[1]; int newMp = Math.Min(maxMp, entity.Mp + amount); if (newMp != entity.Mp) { int n = newMp - entity.Mp; entity.Mp = newMp; entity.UpdateCount++; entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = entity.Id, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = entity.X, Y = entity.Y }, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new NotificationPacket { ObjectId = entity.Id, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + n + "\"}}", Color = new ARGB(0xff00ffff) }, null); } } cool = coolDown.Next(Random); } 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; } var entity = host.GetNearestEntity(range, null) as Player; if (entity != null) { int maxHp = entity.Stats[0] + entity.Boost[0]; int newHp = Math.Min(maxHp, entity.HP + amount); if (newHp != entity.HP) { int n = newHp - entity.HP; entity.HP = newHp; entity.UpdateCount++; entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = entity.Id, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = entity.X, Y = entity.Y }, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new NotificationPacket { ObjectId = entity.Id, Text = "+" + n, Color = new ARGB(0xff00ff00) }, null); } } cool = coolDown.Next(Random); } else { cool -= time.thisTickTimes; } state = cool; }
private void ProcessType(SpecialSetPiece type, int cool, Entity host, RealmTime time) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } var piece = (MapSetPiece)Activator.CreateInstance(Type.GetType($"server.realm.mapsetpiece.{(_special == SpecialSetPiece.ON_SELF ? "" : "special.")}" + _setpiece, true, true)); switch (type) { case SpecialSetPiece.ABYSS_IDOL: { if (cool <= 0) { Entity player = host.GetNearestEntity(_range, null); if (player != null) { Position target = new Position { X = player.X, Y = player.Y }; host?.Owner.BroadcastMessage(new SHOWEFFECT { EffectType = EffectType.Throw, Color = new ARGB(_color), TargetId = host.Id, PosA = target }, null); piece.RenderSetPiece(host.Owner, new IntPoint((int)target.X, (int)target.Y)); } cool = _coolDown.Next(Random); } else { cool -= time.ElapsedMsDelta; } } break; default: { piece.RenderSetPiece(host.Owner, new IntPoint((int)host.X, (int)host.Y)); } break; } }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { if (_attackTarget) { if (host.AttackTarget == null || host.Owner.Players.Values.Contains(host.AttackTarget)) { host.AttackTarget = null; return(true); } return(false); } return(host.GetNearestEntity(_dist, _target) == null); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { //var en = host.GetNearestEntity(20, null); //var player = en as Player; //if (en == null) //{ // return; //} OrbitState s = (OrbitState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Entity entity = host.GetNearestEntity(acquireRange, target); if (entity != null) { double angle; if (host.Y == entity.Y && host.X == entity.X) //small offset { angle = Math.Atan2(host.Y - entity.Y + (Random.NextDouble() * 2 - 1), host.X - entity.X + (Random.NextDouble() * 2 - 1)); } else { angle = Math.Atan2(host.Y - entity.Y, host.X - entity.X); } float angularSpd = host.GetSpeed(s.Speed) / s.Radius; angle -= angularSpd * (time.thisTickTimes / 1000f); double x = entity.X + Math.Cos(angle) * radius; double y = entity.Y + Math.Sin(angle) * radius; Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= host.GetSpeed(s.Speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); host.UpdateCount++; Status = CycleStatus.InProgress; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Sick)) return; Player entity = host.GetNearestEntity(range, null) as Player; if (entity != null) { int maxHp = entity.Stats[0] + entity.Boost[0]; int newHp = Math.Min(maxHp, entity.HP + amount); if (newHp != entity.HP) { int n = newHp - entity.HP; entity.HP = newHp; entity.UpdateCount++; entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = entity.Id, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = host.Id, PosA = new Position { X = entity.X, Y = entity.Y }, Color = new ARGB(0xffffffff) }, null); entity.Owner.BroadcastPacket(new NotificationPacket { ObjectId = entity.Id, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + n + "\"}}", Color = new ARGB(0xff00ff00) }, null); } } cool = coolDown.Next(Random); } else cool -= time.thisTickTimes; state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int) state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) return; double? tossAngle = randomToss ? Random.Next(0, 360)*Math.PI/180 : angle; Entity en = null; if(tossAngle == null) en = host.GetNearestEntity(range, null); if (tossAngle == null && en == null) return; Position target = tossAngle == null ? new Position { X = en.X, Y = en.Y } : new Position { X = host.X + (float)(range * Math.Cos(tossAngle.Value)), Y = host.Y + (float)(range * Math.Sin(tossAngle.Value)), }; host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffffbf00), TargetId = host.Id, PosA = target }, null); host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Entity entity = Entity.Resolve(world.Manager, child); entity.Move(target.X, target.Y); if(entity is Enemy && host is Enemy) (entity as Enemy).Terrain = (host as Enemy).Terrain; world.EnterWorld(entity); })); cool = coolDown.Next(Random); } else cool -= time.thisTickTimes; state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cooldown; if (state == null) { cooldown = 1000; } else { cooldown = (int)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } Entity e = entity != null? host.GetNearestEntityByName(distance, entity) : host.GetNearestEntity(distance, null); if (e != null) { Vector2 vect; vect = new Vector2(e.X - host.X, e.Y - host.Y); vect.Normalize(); float dist = host.GetSpeed(speed) * (time.ElapsedMsDelta / 1000f); host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist); if (cooldown <= 0) { Status = CycleStatus.Completed; cooldown = 1000; } else { Status = CycleStatus.InProgress; cooldown -= time.ElapsedMsDelta; } } state = cooldown; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; Status = CycleStatus.NotStarted; if (cool <= 0) { TextPacket packet = new TextPacket { Name = "#" + (host.ObjectDesc.DisplayId ?? host.ObjectDesc.ObjectId), ObjectId = host.Id, Stars = -1, BubbleTime = 5, Recipient = "", Text = text, CleanText = "" }; if (text.Contains("{PLAYER}")) { Entity player = host.GetNearestEntity(10, null); if (player == null) { return; } text.Replace("{PLAYER}", player.Name); } text.Replace("{HP}", (host as Enemy).HP.ToString()); foreach (Player i in host.Owner.PlayersCollision.HitTest(host.X, host.Y, 999).OfType <Player>()) { if (host.Dist(i) < 999) { i.Client.SendPacket(packet); } } } else { cool -= time.thisTickTimes; Status = CycleStatus.InProgress; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cooldown; if (state == null) { cooldown = 1000; } else { cooldown = (int)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Player player = (Player)host.GetNearestEntity(distance, null); if (player != null) { Vector2 vect; vect = new Vector2(player.X - host.X, player.Y - host.Y); vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist); host.UpdateCount++; if (cooldown <= 0) { Status = CycleStatus.Completed; cooldown = 1000; } else { Status = CycleStatus.InProgress; cooldown -= time.thisTickTimes; } } state = cooldown; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { OrbitState s = (OrbitState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Entity entity = host.GetNearestEntity(acquireRange, target); if (entity != null) { double angle; if (host.Y == entity.Y && host.X == entity.X) { angle = Math.Atan2(host.Y - entity.Y + (Random.NextDouble() * 2 - 1), host.X - entity.X + (Random.NextDouble() * 2 - 1)); } else { angle = Math.Atan2(host.Y - entity.Y, host.X - entity.X); } float angularSpd = host.GetSpeed(s.Speed, time) / s.Radius; angle += angularSpd; double x = entity.X + (_ == 0 ? Math.Cos(angle) * radius : Math.Sin(angle) * radius); double y = entity.Y + (_ == 0 ? Math.Sin(angle) * radius : Math.Cos(angle) * radius); Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= host.GetSpeed(s.Speed, time); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); host.UpdateCount++; Status = CycleStatus.InProgress; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { ChargeState s; if (state == null) s = new ChargeState(); else s = (ChargeState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; if (s.RemainingTime <= 0) { if (s.Direction == Vector2.Zero) { var player = (Player)host.GetNearestEntity(range, null); if (player != null && player.X != host.X && player.Y != host.Y) { s.Direction = new Vector2(player.X - host.X, player.Y - host.Y); var d = s.Direction.Length(); s.Direction.Normalize(); s.RemainingTime = coolDown.Next(Random); if (d / host.GetSpeed(speed) < s.RemainingTime) s.RemainingTime = (int)(d / host.GetSpeed(speed) * 1000); Status = CycleStatus.InProgress; } } else { s.Direction = Vector2.Zero; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; } } if (s.Direction != Vector2.Zero) { float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + s.Direction.X * dist, host.Y + s.Direction.Y * dist); host.UpdateCount++; Status = CycleStatus.InProgress; } s.RemainingTime -= time.thisTickTimes; state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (host is Pet) if ((host as Pet).PlayerOwner != null) return; WmapTile tile = host.Owner.Map[(int)host.X, (int)host.Y].Clone(); if (tile.Region == TileRegion.None && host.Owner is PetYard) { Position pos = (host as Pet).SpawnPoint; host.Move(pos.X, pos.Y); return; } if (host.GetNearestEntity(1, null) == null) { WanderStorage storage; if (state == null) storage = new WanderStorage(); else storage = (WanderStorage)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return; Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { storage.Direction = new Vector2(Random.Next(-2, 2), Random.Next(-2, 2)); storage.Direction.Normalize(); storage.RemainingDistance = coolDown.Next(Random) / 1000f; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); host.UpdateCount++; storage.RemainingDistance -= dist; state = storage; } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { OrbitState s = (OrbitState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } var entity = host.AttackTarget ?? host.GetNearestEntity(acquireRange, target); if (entity != null) { double angle; if (host.Y == entity.Y && host.X == entity.X)//small offset { angle = Math.Atan2(host.Y - entity.Y + (Random.NextDouble() * 2 - 1), host.X - entity.X + (Random.NextDouble() * 2 - 1)); } else { angle = Math.Atan2(host.Y - entity.Y, host.X - entity.X); } var angularSpd = s.Direction * host.GetSpeed(s.Speed) / s.Radius; angle += angularSpd * (time.ElapsedMsDelta / 1000f); double x = entity.X + Math.Cos(angle) * s.Radius; double y = entity.Y + Math.Sin(angle) * s.Radius; Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= host.GetSpeed(s.Speed) * (time.ElapsedMsDelta / 1000f); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); Status = CycleStatus.InProgress; } state = s; }
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) { FollowState s; if (state == null) { s = new FollowState(); } else { s = (FollowState)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) { return; } Entity en = host.GetNearestEntity(acquireRange, null); if (!(en is Player)) { return; //It returned me a enemy, thats why we check for a player here } Player player = en as Player; Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (player != null && s.RemainingTime <= 0) { s.State = F.Acquired; if (duration > 0) { s.RemainingTime = duration; } goto case F.Acquired; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } if (s.RemainingTime <= 0 && duration > 0) { s.State = F.DontKnowWhere; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; break; } if (s.RemainingTime > 0) { s.RemainingTime -= time.thisTickTimes; } vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > range) { Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } else { Status = CycleStatus.Completed; s.State = F.Resting; s.RemainingTime = 0; } break; case F.Resting: if (player == null) { s.State = F.DontKnowWhere; if (duration > 0) { s.RemainingTime = duration; } break; } Status = CycleStatus.Completed; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length > range + 1) { s.State = F.Acquired; s.RemainingTime = duration; goto case F.Acquired; } break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { FollowState s; if (state == null) s = new FollowState(); else s = (FollowState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; var player = (Player)host.GetNearestEntity(acquireRange, null); Vector2 vect; switch (s.State) { case F.DontKnowWhere: if (player != null && s.RemainingTime <= 0) { s.State = F.Acquired; if (duration > 0) s.RemainingTime = duration; goto case F.Acquired; } else if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; break; case F.Acquired: if (player == null) { s.State = F.DontKnowWhere; s.RemainingTime = 0; break; } else if (s.RemainingTime <= 0 && duration > 0) { s.State = F.DontKnowWhere; s.RemainingTime = coolDown.Next(Random); Status = CycleStatus.Completed; break; } if (s.RemainingTime > 0) s.RemainingTime -= time.thisTickTimes; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range) { Status = CycleStatus.InProgress; vect.X -= Random.Next(-2, 2) / 2f; vect.Y -= Random.Next(-2, 2) / 2f; vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } else { Status = CycleStatus.Completed; s.State = F.Resting; s.RemainingTime = 0; } break; case F.Resting: if (player == null) { s.State = F.DontKnowWhere; if (duration > 0) s.RemainingTime = duration; break; } Status = CycleStatus.Completed; vect = new Vector2(player.X - host.X, player.Y - host.Y); if (vect.Length() > range + 1) { s.State = F.Acquired; s.RemainingTime = duration; goto case F.Acquired; } break; } state = s; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { SwirlState s = (SwirlState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return; int period = (int)(1000 * radius / host.GetSpeed(speed) * (2 * Math.PI)); if (!s.Acquired && s.RemainingTime <= 0 && targeted) { Entity entity = host.GetNearestEntity(acquireRange, null); if (entity != null && entity.X != host.X && entity.Y != host.Y) { //find circle which pass through host and player pos double l = entity.Dist(host); float hx = (host.X + entity.X) / 2; float hy = (host.Y + entity.Y) / 2; double c = Math.Sqrt(Math.Abs(radius * radius - l * l) / 4); s.Center = new Vector2( (float)(hx + c * (host.Y - entity.Y) / l), (float)(hy + c * (entity.X - host.X) / l)); s.RemainingTime = period; s.Acquired = true; } else s.Acquired = false; } else if (s.RemainingTime <= 0 || (s.RemainingTime - period > 200 && host.GetNearestEntity(2, null) != null)) { if (targeted) { s.Acquired = false; Entity entity = host.GetNearestEntity(acquireRange, null); if (entity != null) s.RemainingTime = 0; else s.RemainingTime = 5000; } else s.RemainingTime = 5000; } else s.RemainingTime -= time.thisTickTimes; double angle; if (host.Y == s.Center.Y && host.X == s.Center.X) //small offset angle = Math.Atan2(host.Y - s.Center.Y + (Random.NextDouble() * 2 - 1), host.X - s.Center.X + (Random.NextDouble() * 2 - 1)); else angle = Math.Atan2(host.Y - s.Center.Y, host.X - s.Center.X); double spd = host.GetSpeed(speed) * (s.Acquired ? 1 : 0.2); double angularSpd = spd / radius; angle += angularSpd * (time.thisTickTimes / 1000f); double x = s.Center.X + Math.Cos(angle) * radius; double y = s.Center.Y + Math.Sin(angle) * radius; Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(host.X, host.Y); vect.Normalize(); vect *= (float)spd * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X, host.Y + vect.Y); host.UpdateCount++; Status = CycleStatus.InProgress; state = s; }
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; Status = CycleStatus.NotStarted; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) return; Entity player = host.GetNearestEntity(radius, null); if (player != null || defaultAngle != null || fixedAngle != null) { ProjectileDesc desc = host.ObjectDesc.Projectiles[projectileIndex]; double a = fixedAngle ?? (player == null ? defaultAngle.Value : Math.Atan2(player.Y - host.Y, player.X - host.X)); a += angleOffset; if (predictive != 0 && player != null) a += Predict(host, player, desc)*predictive; int dmg; if (host is Character) dmg = (host as Character).Random.Next(desc.MinDamage, desc.MaxDamage); else dmg = Random.Next(desc.MinDamage, desc.MaxDamage); double startAngle = a - shootAngle*(count - 1)/2; byte prjId = 0; Position prjPos = new Position {X = host.X, Y = host.Y}; for (int i = 0; i < count; i++) { Projectile prj = host.CreateProjectile( desc, host.ObjectType, dmg, time.tickTimes, prjPos, (float) (startAngle + shootAngle*i)); host.Owner.EnterWorld(prj); if (i == 0) prjId = prj.ProjectileId; } host.Owner.BroadcastPacket(new ShootPacket { BulletId = prjId, OwnerId = host.Id, Position = prjPos, Angle = (float)startAngle, Damage = (short)dmg, BulletType = (byte)desc.BulletType, AngleInc = (float)shootAngle, NumShots = (byte)count, }, null); } cool = coolDown.Next(Random); Status = CycleStatus.Completed; } else { cool -= time.thisTickTimes; Status = CycleStatus.InProgress; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int?)state ?? -1; Status = CycleStatus.NotStarted; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } int count = this.count; if (host.HasConditionEffect(ConditionEffectIndex.Dazed)) { count = Math.Max(1, count / 2); } Entity player = host.GetNearestEntity(radius, null); if (player != null || defaultAngle != null || fixedAngle != null) { ProjectileDesc desc = host.ObjectDesc.Projectiles[projectileIndex]; double a = fixedAngle ?? (player == null ? defaultAngle.Value : Math.Atan2(player.Y - host.Y, player.X - host.X)); a += angleOffset; if (predictive != 0 && player != null) { a += Predict(host, player, desc) * predictive; } int dmg; if (host is Character) { dmg = (host as Character).Random.Next(desc.MinDamage, desc.MaxDamage); } else { dmg = Random.Next(desc.MinDamage, desc.MaxDamage); } double startAngle = a - shootAngle * (count - 1) / 2; byte prjId = 0; Position prjPos = EnemyShootHistory(host); for (int i = 0; i < count; i++) { Projectile prj = host.CreateProjectile( desc, host.ObjectType, dmg, time.TotalElapsedMs, prjPos, (float)(startAngle + shootAngle * i)); host.Owner.EnterWorld(prj); if (i == 0) { prjId = prj.ProjectileId; } } if (rotateEffect) { Position target; if (rotateAngle != null) { target = new Position { X = host.X + (float)(Math.Cos(rotateAngle.Value)), Y = host.Y + (float)(Math.Sin(rotateAngle.Value)), } } ; else { target = new Position { X = player.X, Y = player.Y, } }; host.Owner.BroadcastPacket(new SHOWEFFECT { EffectType = EffectType.Coneblast, Color = new ARGB(rotateColor), TargetId = host.Id, PosA = target, PosB = new Position { X = rotateRadius }, //radius }, null); } host.Owner.BroadcastPacket(new ENEMYSHOOT { BulletId = prjId, OwnerId = host.Id, Position = prjPos, Angle = (float)startAngle, Damage = (short)dmg, BulletType = (byte)desc.BulletType, AngleInc = (float)shootAngle, NumShots = (byte)count, }, null); } cool = coolDown.Next(Random); Status = CycleStatus.Completed; } else { cool -= time.ElapsedMsDelta; Status = CycleStatus.InProgress; } state = cool; } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } Entity player = host.GetNearestEntity(range, null); if (player != null || fixedAngle != null) { Position target; if (fixedAngle != null) { target = new Position { X = host.X + (float)(range * Math.Cos(fixedAngle.Value)), Y = host.Y + (float)(range * Math.Sin(fixedAngle.Value)), } } ; else { target = new Position { X = player.X, Y = player.Y, } }; host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffff0000), TargetId = host.Id, PosA = target }, null); host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { world.BroadcastPacket(new AOEPacket { Position = target, Radius = radius, Damage = (ushort)damage, EffectDuration = 0, Effects = 0, OriginType = (short)host.ObjectType }, null); world.Aoe(target, radius, true, p => { (p as IPlayer).Damage(damage, host as Character); }); })); } 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; Status = CycleStatus.NotStarted; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } Entity player = host.GetNearestEntity(radius, null); if (player != null || defaultAngle != null || fixedAngle != null) { ProjectileDesc desc = host.ObjectDesc.Projectiles[projectileIndex]; double a = fixedAngle ?? (player == null ? defaultAngle.Value : Math.Atan2(player.Y - host.Y, player.X - host.X)); a += angleOffset; if (predictive != 0 && player != null) { a += Predict(host, player, desc) * predictive; } int dmg; if (host is Character) { dmg = (host as Character).Random.Next(desc.MinDamage, desc.MaxDamage); } else { dmg = Random.Next(desc.MinDamage, desc.MaxDamage); } if (host.HasConditionEffect(ConditionEffectIndex.Weak)) { dmg = dmg / 2; } double startAngle = a - shootAngle * (count - 1) / 2; byte prjId = 0; Position prjPos = new Position { X = host.X, Y = host.Y }; for (int i = 0; i < count; i++) { Projectile prj = host.CreateProjectile( desc, host.ObjectType, dmg, time.tickTimes, prjPos, (float)(startAngle + shootAngle * i)); host.Owner.EnterWorld(prj); if (i == 0) { prjId = prj.ProjectileId; } } host.Owner.BroadcastPacket(new ShootPacket { BulletId = prjId, OwnerId = host.Id, Position = prjPos, Angle = (float)startAngle, Damage = (short)dmg, BulletType = (byte)desc.BulletType, AngleInc = (float)shootAngle, NumShots = (byte)count, }, null); } cool = coolDown.Next(Random); Status = CycleStatus.Completed; } else { cool -= time.thisTickTimes; Status = CycleStatus.InProgress; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffects.Stunned)) { return; } if (Random.NextDouble() > _probability) { state = _coolDown.Next(Random); return; } Entity player = host.GetNearestEntity(_range, null); if (player != null || _angle != null) { if (_densityRange != null && _maxDensity != null) { var cnt = 0; if (_children.Length > 1) { cnt = host.CountEntity((double)_densityRange, _group); } else { cnt = host.CountEntity((double)_densityRange, _children[0]); } if (cnt >= _maxDensity) { state = _coolDown.Next(Random); return; } } var r = _range; if (_minRange != null && _maxRange != null) { r = (double)_minRange + Random.NextDouble() * ((double)_maxRange - (double)_minRange); } var a = _angle; if (_angle == null && _minAngle != null && _maxAngle != null) { a = (double)_minAngle + Random.NextDouble() * ((double)_maxAngle - (double)_minAngle); } Position target; if (a != null) { target = new Position() { X = host.X + (float)(r * Math.Cos(a.Value)), Y = host.Y + (float)(r * Math.Sin(a.Value)), } } ; else { target = new Position() { X = player.X, Y = player.Y, } }; if (_reproduceRegions != null && _reproduceRegions.Count > 0) { var sx = (int)host.X; var sy = (int)host.Y; var regions = _reproduceRegions .Where(p => Math.Abs(sx - p.X) <= _regionRange && Math.Abs(sy - p.Y) <= _regionRange).ToList(); var tile = regions[Random.Next(regions.Count)]; target = new Position() { X = tile.X, Y = tile.Y }; } if (!_tossInvis) { host.Owner.BroadcastPacketNearby(new ShowEffect() { EffectType = EffectType.Throw, TargetObjectId = host.Id, Pos1 = target }, target, PacketPriority.Low); } host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { if (!world.IsPassable(target.X, target.Y, true)) { return; } Entity entity = Entity.Resolve(host.Manager, _children[Random.Next(_children.Length)]); entity.Move(target.X, target.Y); if (host.Spawned) { entity.Spawned = true; } var enemyHost = host as Enemy; var enemyEntity = entity as Enemy; if (enemyHost != null && enemyEntity != null) { enemyEntity.Terrain = enemyHost.Terrain; if (enemyHost.Spawned) { enemyEntity.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.Invisible, DurationMS = -1 }); } } world.EnterWorld(entity); })); cool = _coolDown.Next(Random); } } else { cool -= time.ElaspedMsDelta; } state = cool; } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { ProtectState s; if (state == null) s = ProtectState.DontKnowWhere; else s = (ProtectState)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; var entity = host.GetNearestEntity(acquireRange, protectee); Vector2 vect; switch (s) { case ProtectState.DontKnowWhere: if (entity != null) { s = ProtectState.Protecting; goto case ProtectState.Protecting; } break; case ProtectState.Protecting: if (entity == null) { s = ProtectState.DontKnowWhere; break; } vect = new Vector2(entity.X - host.X, entity.Y - host.Y); if (vect.Length() > reprotectRange) { Status = CycleStatus.InProgress; vect.Normalize(); float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist); host.UpdateCount++; } else { Status = CycleStatus.Completed; s = ProtectState.Protected; } break; case ProtectState.Protected: if (entity == null) { s = ProtectState.DontKnowWhere; break; } Status = CycleStatus.Completed; vect = new Vector2(entity.X - host.X, entity.Y - host.Y); if (vect.Length() > protectionRange) { s = ProtectState.Protecting; goto case ProtectState.Protecting; } break; } state = s; }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { foreach (string children in childrens) if (host.GetNearestEntity(dist, host.Manager.GameData.IdToObjectType[children]) != null) return false; return true; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state != null && cooldown.CoolDown == 0) return; //cooldown = 0 -> once per state entry int c; if (state == null) c = cooldown.Next(Random); else c = (int)state; c -= time.thisTickTimes; state = c; if (c > 0) return; c = cooldown.Next(Random); state = c; if (Random.NextDouble() >= probability) return; var taunt = text.Length == 1 ? text[0] : text[Random.Next(text.Length)]; if (taunt.Contains("{PLAYER}")) { Entity player = host.GetNearestEntity(10, null); if (player == null) return; taunt = taunt.Replace("{PLAYER}", player.Name); } taunt = taunt.Replace("{HP}", (host as Enemy).HP.ToString()); var packet = new TextPacket() { Name = "#" + (host.ObjectDesc.DisplayId ?? host.ObjectDesc.ObjectId), ObjectId = host.Id, Stars = -1, BubbleTime = 5, Recipient = "", Text = taunt, CleanText = "" }; if (broadcast) host.Owner.BroadcastPacket(packet, null); else foreach (var i in host.Owner.PlayersCollision.HitTest(host.X, host.Y, 15)) { if (BehaviorUtils.Dist(host, i) < 15) (i as Player).Client.SendPacket(packet); } }
protected override bool TickCore(Entity host, RealmTime time, ref object state) { return host.GetNearestEntity(dist, null) != null; }