internal static Composite CreateKitingBehavior() { return (new Decorator( ctx => BelphegorSettings.Instance.Kiting.IsKitingActive, new Sequence( new Action(ctx => RegenerateCache(MinimumDistance, (CombatContext)ctx)), new PrioritySelector( new Decorator( ctx => CheckTimer.IsFinished && _currentTargetPoint == Vector3.Zero && NeedsToGetGround, new Action( ctx => { Log.Info("Kiting behavior started."); _currentTargetPoint = ((CombatContext)ctx).PlayerPosition. GeneratePossibleTargetPointsInHalfCircleFacingAwayFromTarget( (CombatContext)ctx, ((CombatContext)ctx).TargetPosition, MaximumDistance - MinimumDistance). FirstOrDefault( p => ((CombatContext)ctx).UnitPositions.CachedPositions.Any( cp => cp.Position.DistanceSqr(p) < BelphegorSettings.Instance.Kiting.AggroRange * BelphegorSettings.Instance.Kiting.AggroRange)); if (_currentTargetPoint == Vector3.Zero) { Log.Info("Kiting failed to find target spot."); CheckTimer.Reset(); return RunStatus.Success; } Log.Info("Kiting target position found."); return RunStatus.Failure; } ) ), new Decorator( ctx => (_currentTargetPoint != Vector3.Zero && (_currentTargetPoint.DistanceSqr(((CombatContext)ctx).PlayerPosition) < 4f * 4f || _currentTargetPoint.DistanceSqr(((CombatContext)ctx).PlayerPosition) > (MaximumDistance - MinimumDistance) * (MaximumDistance - MinimumDistance))) || ZetaDia.Me.Movement.StuckFlags.HasFlag(StuckFlags.WasStuck), new Action(ret => { _currentTargetPoint = Vector3.Zero; CheckTimer.Reset(); Log.Info("Kiting behavior finished."); }) ), new Decorator( ctx => _currentTargetPoint != Vector3.Zero, CommonBehaviors.MoveAndStop(ret => _currentTargetPoint, 4f, true, "Kiting Position") ) ) ) )); }
public Sphere ToBoundingSphere() { var c = CenterPos; var radius = (float)Math.Sqrt( Math.Max( Math.Max( a.DistanceSqr(b), a.DistanceSqr(c) ), b.DistanceSqr(c) ) ); return(new Sphere(c, radius)); }
public void Tick() { Vector3 location = Core.Me.Location; if (location.DistanceSqr(_location) > Distance) { _location = location; _moveTimer.Reset(); } }
private void Generate(int xSize, int ySize, int zSize, int xOffset, int yOffset, int zOffset) { Voxels = new float[xSize, ySize, zSize]; for (int x = 0; x < xSize; ++x) { float posX = (float)(x + xOffset); for (int y = 0; y < ySize; ++y) { float posY = (float)(y + yOffset); for (int z = 0; z < zSize; ++z) { float posZ = (float)(z + zOffset); Vector3 pos = new Vector3(posX, posY, posZ); pos.x *= 0.125f; pos.y *= 0.25f; pos.z *= 0.125f; Voxels[x, y, z] = Noise.SmoothNoise(pos); const int startTop = 55, endTop = 60; int yPos = y + yOffset; if (yPos >= startTop && yPos <= endTop) { float heightLerp = Mathf.InverseLerp(startTop, endTop, yPos); Voxels[x, y, z] = Mathf.Lerp(Voxels[x, y, z], 1.0f, heightLerp); } else if (yPos > endTop) { Voxels[x, y, z] = Mathf.Lerp(0.0f, 0.3999f, NoiseAlgos2D.LinearNoise(new Vector2(pos.x, pos.z) * 6.0f)); } Vector3 worldPos = new Vector3(x, y, z) + new Vector3(xOffset, yOffset, zOffset), holePos = new Vector3(30.0f, 60.0f, 30.0f); float distSqr = worldPos.DistanceSqr(holePos); if (distSqr < 32.0f) { float distLerp = Mathf.Sqrt(distSqr) / 32.0f; Voxels[x, y, z] = Mathf.Lerp(0.0f, Voxels[x, y, z], distLerp); } } } } }
public MoveResult MoveToRandomSpotWithin(Vector3 location, float radius, string destination = null) { if (generatingPath) { return(MoveResult.GeneratingPath); } if (!playerMover.CanFly || (!MovementManager.IsFlying && !playerMover.ShouldFlyTo(location))) { return(innerNavigator.MoveTo(location, destination)); } var currentLocation = GameObjectManager.LocalPlayer.Location; if (location.DistanceSqr(currentLocation) > PathPrecisionSqr) { if (ShouldGeneratePath(location, radius)) { generatingPath = true; origin = currentLocation; requestedDestination = location; finalDestination = location.AddRandomDirection2D(radius); pathGeneratorStopwatch.Restart(); logger.Info("Generating path on {0} from {1} to {2}", WorldManager.ZoneId, origin, finalDestination); GeneratePath(origin, finalDestination).ContinueWith(HandlePathGenerationResult); return(MoveResult.GeneratingPath); } if (CurrentPath.Count == 0) { return(MoveResult.ReachedDestination); } return(MoveToNextHop(destination)); } logger.Info("Navigation reached current destination. Within {0}", currentLocation.Distance(location)); requestedDestination = Vector3.Zero; playerMover.MoveStop(); CurrentPath.Reset(); return(MoveResult.Done); }
public void Explode(Vector3 center, float radius) { if (cr != null) return; Vector3 minF = center - new Vector3(radius, radius, radius), maxF = center + new Vector3(radius, radius, radius); Vector3i min = new Vector3i(Mathf.Max((int)minF.x, XOffset), Mathf.Max((int)minF.y, YOffset), Mathf.Max((int)minF.z, ZOffset)), max = new Vector3i(Mathf.Min((int)maxF.x + 1, XOffset + XSize - 1), Mathf.Min((int)maxF.y + 1, YOffset + YSize - 1), Mathf.Min((int)maxF.z + 1, ZOffset + ZSize - 1)); int nChanged = 0; for (int x = min.x; x <= max.x; ++x) { for (int y = min.y; y <= max.y; ++y) { for (int z = min.z; z <= max.z; ++z) { Vector3 pos = new Vector3(x, y, z); Vector3i relPos = new Vector3i(x - XOffset, y - YOffset, z - ZOffset); if (Voxels[relPos.x, relPos.y, relPos.z] > 0.0f && pos.DistanceSqr(center) < (radius * radius)) { Voxels[relPos.x, relPos.y, relPos.z] = 0.0f; nChanged += 1; } } } } if (nChanged > 0) { cr = StartCoroutine(RunGenerator(false)); } }