protected override void TickCore(Entity host, RealmTime time, ref object state) { WanderStorage storage; if (state == null) storage = new WanderStorage(); else storage = (WanderStorage)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return; Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2)); storage.Direction.Normalize(); storage.RemainingDistance = period.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) { 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(-1, 2), Random.Next(-1, 2)); storage.Direction.Normalize(); storage.RemainingDistance = period.Next(Random) / 1000f; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed, time); if (avoidGround) { EmbeddedData data = host.Manager.GameData; float x = host.X + storage.Direction.X * dist; float y = host.Y + storage.Direction.Y * dist; WmapTile tile = host.Owner.Map[(int)x, (int)y]; if (tile.TileId == data.IdToTileType[ground]) { host.UpdateCount++; storage.RemainingDistance -= dist; state = storage; return; } } host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); host.UpdateCount++; storage.RemainingDistance -= dist; state = storage; //if (debug) //{ // double TPS = time.TickCount / (time.TotalElapsedMs / 1000.0); // log.Warn($"[{typeof(Wander).Name}] Speed: {speed} | Current Speed: {dist:n2} | TC: {time.TickCount:n2} | TEM: {(time.TotalElapsedMs / 1000.0):n2} | TPS: {TPS:n2}"); //} }
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) { 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(-1, 2), Random.Next(-1, 2)); storage.Direction.Normalize(); storage.RemainingDistance = period.Next(Random) / 1000f; Status = CycleStatus.Completed; } float dist = host.EntitySpeed(speed, time); if (avoidGround) { EmbeddedData data = GameServer.Manager.GameData; float x = host.X + storage.Direction.X * dist; float y = host.Y + storage.Direction.Y * dist; WmapTile tile = host.Owner.Map[(int)x, (int)y]; if (tile.TileId == data.IdToTileType[ground]) { host.UpdateCount++; storage.RemainingDistance -= dist; state = storage; return; } } 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) { 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(-1, 2), Random.Next(-1, 2)); storage.Direction.Normalize(); storage.RemainingDistance = period.Next(Random) / 1000f; Status = CycleStatus.Completed; } //var en = host.GetNearestEntity(20, null); //var player = en as Player; //if(en == null) //{ // return; //} 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; }
//static Cooldown period = new Cooldown(500, 200); protected override void TickCore(Entity host, RealmTime time, ref object state) { WanderStorage storage; if (state == null) { storage = new WanderStorage(); } else { storage = (WanderStorage)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { // old wander //storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2)); //storage.Direction.Normalize(); //storage.RemainingDistance = period.Next(Random) / 1000f; //Status = CycleStatus.Completed; // creepylava's newer wander storage.Direction = new Vector2(Random.Next() % 2 == 0 ? -1 : 1, Random.Next() % 2 == 0 ? -1 : 1); storage.Direction.Normalize(); storage.RemainingDistance = 600 / 1000f; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed) * (time.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); storage.RemainingDistance -= dist; state = storage; }
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) { if ((host as Pet)?.PlayerOwner != null) { return; } var map = host.Owner.Map; var x = (int)host.X; var y = (int)host.Y; WmapTile tile = null; if (map.Contains(x, y)) { tile = map[x, y]; } if (tile == null || (tile.Region == TileRegion.None && host.Owner is PetYard)) { host.Move(spawnPoint.X, spawnPoint.Y); return; } if (host.GetNearestEntity(1, null) != null) { return; } WanderStorage storage; if (state == null) { storage = new WanderStorage(); } else { storage = (WanderStorage)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.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.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); storage.RemainingDistance -= dist; state = storage; }