public static void StartHive(int i, int j) { const float strength = 2.4f; const float wallThickness = 4f; ushort fleshID = (ushort)ModContent.TileType <Riven_Flesh>(); ushort weakFleshID = (ushort)ModContent.TileType <Weak_Riven_Flesh>(); ushort fleshWallID = (ushort)ModContent.WallType <Riven_Flesh_Wall>(); lesionCount = 0; int j2 = j; if (j2 > Main.worldSurface) { j2 = (int)Main.worldSurface; } for (; !SolidTile(i, j2); j2++) { } Vector2 position = new Vector2(i, j2); for (int x = i - 30; x < i + 30; x++) { for (int y = j2 - 25; y < j2 + 15; y++) { float diff = (((y - j2) * (y - j2) * 1.5f) + (x - i) * (x - i)); if (diff > 800) { continue; } Main.tile[x, y].ResetToType(fleshID); if (diff < 750) { Main.tile[x, y].wall = fleshWallID; } } } Vector2 vector = new Vector2(0, -1).RotatedByRandom(1.6f, genRand); int distance = 0; while (Main.tile[(int)position.X, (int)position.Y].active() && Main.tileSolid[Main.tile[(int)position.X, (int)position.Y].type]) { //Main.tile[(int)position.X, (int)position.Y].ResetToType(TileID.EmeraldGemspark); //SquareTileFrame((int)position.X, (int)position.Y); position += vector; if (++distance >= 160) { break; } } vector = -vector; (Vector2 position, Vector2 velocity)last = (position, vector); //Tile t = Main.tile[(int)last.position.X, (int)last.position.Y]; (int x, int y, Vector2 direction, double length)startValues = ((int)last.position.X, (int)last.position.Y, last.velocity.RotatedByRandom(0.5f, genRand), distance *genRand.NextFloat(0.4f, 0.6f)); last = GenRunners.WalledVeinRunner(startValues.x, startValues.y, strength * genRand.NextFloat(0.9f, 1.1f), startValues.direction, startValues.length, weakFleshID, wallThickness); //t.ResetToType(TileID.AmethystGemspark); Vector2 manualVel = new Vector2(last.velocity.X, 0.2f); //t = Main.tile[(int)last.position.X, (int)last.position.Y]; GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(new Vector2(-manualVel.X, 0.2f)), genRand.NextFloat(distance * 0.4f, distance * 0.6f) * (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); last = GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(manualVel), genRand.NextFloat(distance * 0.4f, distance * 0.6f) / (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(manualVel), genRand.NextFloat(distance * 0.4f, distance * 0.6f) / (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); last = GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), new Vector2(0, 1).RotatedByRandom(0.2f, genRand), genRand.NextFloat(distance * 0.4f, distance * 0.6f), weakFleshID, wallThickness, wallType: fleshWallID); //t.ResetToType(TileID.AmethystGemspark); manualVel.X = -manualVel.X; //t = Main.tile[(int)last.position.X, (int)last.position.Y]; GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(new Vector2(-manualVel.X, 0.2f)), genRand.NextFloat(distance * 0.4f, distance * 0.6f) * (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); last = GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(manualVel), genRand.NextFloat(distance * 0.4f, distance * 0.6f) / (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), Vector2.Normalize(manualVel), genRand.NextFloat(distance * 0.4f, distance * 0.6f) / (Math.Abs(manualVel.X) + 0.5f), weakFleshID, wallThickness, wallType: fleshWallID); last = GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), new Vector2(0, 1).RotatedByRandom(0.2f, genRand), genRand.NextFloat(distance * 0.4f, distance * 0.6f), weakFleshID, wallThickness, wallType: fleshWallID); //t.ResetToType(TileID.AmethystGemspark); for (int index = 0; index < 10; index++) { //t = Main.tile[(int)last.position.X, (int)last.position.Y]; last = GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), last.velocity.RotatedByRandom(0.8f, genRand), genRand.NextFloat(distance * 0.2f, distance * 0.3f), weakFleshID, wallThickness, wallType: fleshWallID); if (index < 8) { GenRunners.WalledVeinRunner((int)last.position.X, (int)last.position.Y, strength * genRand.NextFloat(0.9f, 1.1f), last.velocity.RotatedBy(genRand.Next(2) * 2 - 1).RotatedByRandom(0.8f, genRand), genRand.NextFloat(distance * 0.4f, distance * 0.6f), weakFleshID, wallThickness, wallType: fleshWallID); } PolarVec2 vel = new PolarVec2(1, last.velocity.ToRotation()); OriginExtensions.AngularSmoothing(ref vel.Theta, MathHelper.PiOver2, 0.7f); //t.ResetToType(TileID.AmethystGemspark); last = (last.position, (Vector2)vel); } //t = Main.tile[(int)last.position.X, (int)last.position.Y]; //t.ResetToType(TileID.AmethystGemspark); Point caveCenter = HiveCave((int)last.position.X, (int)last.position.Y); Vector2 cavernOpening = last.position - caveCenter.ToVector2(); GenRunners.VeinRunner((int)last.position.X, (int)last.position.Y, strength, cavernOpening.SafeNormalize(Vector2.Zero), cavernOpening.Length()); GenRunners.VeinRunner(startValues.x, startValues.y, strength, startValues.direction, startValues.length); (Vector2 position, Vector2 velocity)[] arms = new (Vector2 position, Vector2 velocity)[4];
public void DrawAnimations(PlayerDrawInfo drawInfo) { Texture2D upperLegTexture = mod.GetTexture("NPCs/Fiberglass/Fiberglass_Threader_Leg_Upper"); Texture2D lowerLegTexture = mod.GetTexture("NPCs/Fiberglass/Fiberglass_Threader_Leg_Lower"); Texture2D pixelTexture = mod.GetTexture("Projectiles/Pixel"); switch (mode) { case 0: { Player player = Main.LocalPlayer; Vector2 start = player.Right; if (arm is null) { arm = new Arm() { bone0 = new PolarVec2(upperLegLength, upperLegAngle), bone1 = new PolarVec2(lowerLegLength, lowerLegAngle) }; } if (arm2 is null) { arm2 = new Arm() { bone0 = new PolarVec2(upperLegLength, upperLegAngle), bone1 = new PolarVec2(lowerLegLength, lowerLegAngle) }; } arm.start = start; float[] targets = arm.GetTargetAngles(target); OriginExtensions.AngularSmoothing(ref arm.bone0.Theta, targets[0], 0.2f); OriginExtensions.AngularSmoothing(ref arm.bone1.Theta, targets[1], 0.2f); Vector2 screenStart = arm.start - Main.screenPosition; Main.playerDrawData.Add(new DrawData(upperLegTexture, screenStart, null, Color.White, arm.bone0.Theta, new Vector2(3, 9), 1f, SpriteEffects.None, 0)); Main.playerDrawData.Add(new DrawData(lowerLegTexture, screenStart + (Vector2)arm.bone0, null, Color.White, arm.bone0.Theta + arm.bone1.Theta, new Vector2(4, 8), 1f, SpriteEffects.None, 0)); Vector2 start2 = player.Left; arm2.start = start2; float[] targets2 = arm2.GetTargetAngles(target2, true); OriginExtensions.AngularSmoothing(ref arm2.bone0.Theta, targets2[0], 0.2f); OriginExtensions.AngularSmoothing(ref arm2.bone1.Theta, targets2[1], 0.2f); Vector2 screenStart2 = arm2.start - Main.screenPosition; Main.playerDrawData.Add(new DrawData(upperLegTexture, screenStart2, null, Color.White, arm2.bone0.Theta, new Vector2(3, 3), 1f, SpriteEffects.FlipVertically, 0)); Main.playerDrawData.Add(new DrawData(lowerLegTexture, screenStart2 + (Vector2)arm2.bone0, null, Color.White, arm2.bone0.Theta + arm2.bone1.Theta, new Vector2(4, 0), 1f, SpriteEffects.FlipVertically, 0)); /**Vector2 diff = (target - start); * float dist = diff.Length() / (upperLegLength + lowerLegLength); * float minLength = 0.7f; * float maxLength = 0.9f; * if (player.controlUp) { * minLength = 1f; * maxLength = 1f; * }else if (player.controlDown) { * minLength = 0.3f; * maxLength = 0.7f; * } * if (dist != 0) { * if (dist < minLength) { * player.velocity -= diff.SafeNormalize(Vector2.Zero) / (dist * 3); * } else if (dist < 1f && dist > maxLength) { * player.velocity += diff.SafeNormalize(Vector2.Zero) * (dist * 8 - 4); * } * } * Vector2 diff2 = (target2 - start2); * float dist2 = diff2.Length() / (upperLegLength + lowerLegLength); * if (dist2 != 0) { * if (dist2 < minLength) { * player.velocity -= diff.SafeNormalize(Vector2.Zero) / (dist2 * 3); * } else if (dist2 < 1f && dist2 > maxLength) { * player.velocity += diff.SafeNormalize(Vector2.Zero) * (dist2 * 8 - 4); * } * }*/ } break; } }
public override void AI() { if (projectile.localAI[2] > 0f) { projectile.localAI[2]--; projectile.timeLeft--; } if (projectile.localAI[0] > 0f) { projectile.localAI[0]--; } if (projectile.localAI[0] == 0f && projectile.owner == Main.myPlayer) { projectile.localAI[0] = 5f; float currentTargetDist = projectile.ai[0] > 0?Main.npc[(int)projectile.ai[0] - 1].Distance(projectile.Center):0; for (int i = 0; i < Main.maxNPCs; i++) { NPC targetOption = Main.npc[i]; if (targetOption.CanBeChasedBy()) { float newTargetDist = targetOption.Distance(projectile.Center); bool selectNew = projectile.ai[0] <= 0f || currentTargetDist > newTargetDist; if (selectNew && (newTargetDist < 240f)) { projectile.ai[0] = i + 1; currentTargetDist = newTargetDist; } } } if (projectile.ai[0] > 0f) { projectile.timeLeft = 300 - Main.rand.Next(120); projectile.netUpdate = true; } } float scaleFactor = MathHelper.Clamp((30 - projectile.localAI[2]) * 0.04f, 0.1f, 1f); Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, 27, 0f, -2f); dust.noGravity = true; dust.velocity = projectile.oldVelocity * 0.5f; dust.scale = scaleFactor; dust.fadeIn = 0.5f; dust.alpha = 200; int target = (int)projectile.ai[0] - 1; if (target >= 0) { if (Main.npc[target].active) { if (projectile.Distance(Main.npc[target].Center) > 1f) { Vector2 dir = projectile.DirectionTo(Main.npc[target].Center); if (dir.HasNaNs()) { dir = Vector2.UnitY; } float angle = dir.ToRotation(); PolarVec2 velocity = (PolarVec2)projectile.velocity; float targetVel = projectile.ai[1]; bool changed = false; if (velocity.R != targetVel) { OriginExtensions.LinearSmoothing(ref velocity.R, targetVel, (targetVel - 0.5f) * 0.1f); changed = true; } if (velocity.Theta != angle) { OriginExtensions.AngularSmoothing(ref velocity.Theta, angle, 0.1f); changed = true; } if (changed) { projectile.velocity = (Vector2)velocity; } } return; } projectile.ai[0] = 0f; projectile.netUpdate = true; } else { PolarVec2 velocity = (PolarVec2)projectile.velocity; float targetVel = projectile.ai[1]; bool changed = false; if (velocity.R != targetVel) { OriginExtensions.LinearSmoothing(ref velocity.R, targetVel / 3f, (targetVel - 0.5f) * 0.1f); changed = true; } if (velocity.Theta != projectile.localAI[1]) { OriginExtensions.AngularSmoothing(ref velocity.Theta, projectile.localAI[1], (targetVel - 0.5f) * 0.03f); changed = true; } else { projectile.localAI[1] = Main.rand.NextFloat(-MathHelper.Pi, MathHelper.Pi); } if (changed) { projectile.velocity = (Vector2)velocity; } } }