public override bool OnTileCollide(Vector2 oldVelocity) { if (projectile.timeLeft > 800) //smells like boilerplate. IDG-it kinda is { Point16 point = new Point16((int)((projectile.Center.X + (projectile.width / 3f) * projectile.spriteDirection) / 16), Math.Min(Main.maxTilesY, (int)((projectile.Center.Y) / 16) + 1)); Tile tile = Framing.GetTileSafely(point.X, point.Y); //hard coded dust ids in worldgen.cs, still ew //Tile hit! if (tile != null && WorldGen.InWorld(point.X, point.Y, 1) && tile.active() && Main.tileSolid[tile.type]) { projectile.timeLeft = 20; projectile.ai[0] = tile.type; projectile.tileCollide = false; projectile.position.Y += 16; int dusttype = 0; DustHelper.TileDust(tile, ref dusttype); for (float num315 = 0.50f; num315 < 3; num315 += 0.25f) { float angle = MathHelper.ToRadians(-Main.rand.Next(70, 130)); Vector2 vecangle = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * num315 * 3f; int num316 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, (int)(projectile.height / 2f), dusttype, 0f, 0f, 50, default, (4f - num315) / 3f);
public override bool OnTileCollide(Vector2 oldVelocity) { if (!Collision.CanHit(projectile.Center, 4, 4, projectile.Center - new Vector2(0, 24), 0, 0)) { return(true); } for (int zz = 0; zz < Main.maxProjectiles; zz += 1) { Projectile proj = Main.projectile[zz]; if (proj.active && proj.type == ModContent.ProjectileType <VitricBookSpikeTrap>()) { if (proj.Distance(projectile.Center) < 24) { return(true); } } } Point16 point = new Point16((int)(projectile.Center.X / 16), Math.Min(Main.maxTilesY, (int)(projectile.Center.Y / 16) + 1)); Tile tile = Framing.GetTileSafely(point.X, point.Y); int dusttype = mod.DustType("Glass2"); //hard coded dust ids in worldgen.cs, ew if (tile != null && WorldGen.InWorld(point.X, point.Y, 1)) { if (tile.active()) { DustHelper.TileDust(tile, ref dusttype); } } for (float num315 = 0.2f; num315 < 8; num315 += 0.50f) { float angle = MathHelper.ToRadians(-Main.rand.Next(60, 120)); Vector2 vecangle = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * num315; int num316 = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y), projectile.width, projectile.height, dusttype, 0f, 0f, 50, default, (10f - num315) / 5f);
public virtual void DoAI() { if (projectile.localAI[0] > 300) { projectile.Kill(); return; } oldhitbox = new Vector2(projectile.width, projectile.height); if (projectile.localAI[0] == 1) { projectile.rotation = projectile.ai[0]; projectile.spriteDirection = projectile.rotation > 500 ? -1 : 1; if (projectile.rotation > 500) { projectile.rotation -= 1000; } projectile.ai[0] = 0; projectile.netUpdate = true; } Vector2 gothere; SwingUp(); SwingDown(); void SwingUp() { if (projectile.localAI[0] < 70) //Swing up { float lerpval = Math.Min(projectile.localAI[0] / 50f, 1f); if (Helper.IsTargetValid(enemy)) { strikewhere = enemy.Center + new Vector2(enemy.velocity.X, enemy.velocity.Y / 2f); enemysize = new Vector2(enemy.width, enemy.height); } projectile.rotation = projectile.rotation.AngleLerp(-MathHelper.Pi / 4f, 0.075f * lerpval); gothere = (strikewhere + new Vector2(projectile.spriteDirection * -(75 + (float)Math.Pow(projectile.localAI[0] * 2f, 0.80) + enemysize.X / 2f), -200)); projectile.velocity += ((gothere - projectile.Center) / 75f); if (projectile.velocity.Length() > 14f * lerpval) { projectile.velocity = Vector2.Normalize(projectile.velocity) * 14 * lerpval; } projectile.velocity /= 1.5f; } } void SwingDown() { if (projectile.localAI[0] >= 70) //Swing Down { if (Helper.IsTargetValid(enemy)) { strikewhere.X = enemy.Center.X + enemy.velocity.X * 1.50f; } projectile.velocity.X += Math.Min(Math.Abs(projectile.velocity.X), 0) * projectile.spriteDirection; float lerpval = Math.Min((projectile.localAI[0] - 70f) / 30f, 1f); projectile.rotation = projectile.rotation.AngleTowards(MathHelper.Pi / 4f, 0.075f * lerpval); gothere = (strikewhere + new Vector2(projectile.spriteDirection * -(32 + enemysize.X / 4f), -32)); projectile.velocity.X += (MathHelper.Clamp(gothere.X - projectile.Center.X, -80f, 80f)) / 24f; projectile.velocity.Y += 1f; if (projectile.velocity.Length() > 10 * lerpval) { projectile.velocity = Vector2.Normalize(projectile.velocity) * 10 * lerpval; } projectile.velocity.X /= 1.20f; Smash(); } } void Smash() { if (projectile.Center.Y > gothere.Y) //Smashing! { int tiley = (int)(projectile.Center.Y / 16) + 1; Point16 point = new Point16((int)((projectile.Center.X + (projectile.width / 3f) * projectile.spriteDirection) / 16), Math.Min(Main.maxTilesY, tiley)); Tile tile = Framing.GetTileSafely(point.X, point.Y); //hard coded dust ids in worldgen.cs, still ew //Tile hit! if (tile != null && WorldGen.InWorld(point.X, point.Y, 1) && tile.active() && Main.tileSolid[tile.type]) { projectile.localAI[0] = 301; int dusttype = mod.DustType("Glass2"); DustHelper.TileDust(tile, ref dusttype); int ai0 = (int)tile.type; int ai1 = 16 * projectile.spriteDirection; Vector2 tilepos16 = new Vector2(point.X, point.Y - 1) * 16; Projectile.NewProjectile(tilepos16, Vector2.Zero, ModContent.ProjectileType <ShockwaveSummon>(), (int)(projectile.damage * 0.25), 0, Main.myPlayer, ai0, ai1); Main.LocalPlayer.GetModPlayer <StarlightPlayer>().Shake += 10; for (float num315 = 2f; num315 < 15; num315 += 0.50f) { float angle = MathHelper.ToRadians(-Main.rand.Next(70, 130)); Vector2 vecangle = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * num315 * 3f; Vector2 position = new Vector2(projectile.position.X + (projectile.spriteDirection * (int)(projectile.width * 0.60)), projectile.Center.Y - projectile.height / 2f); int num316 = Dust.NewDust(position, projectile.width / 2, projectile.height, dusttype, 0f, 0f, 50, default, (12f - num315) / 5f);